summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f291280)
raw | patch | inline | side by side (parent: f291280)
author | ishmal <ishmal@users.sourceforge.net> | |
Sat, 15 Dec 2007 17:27:02 +0000 (17:27 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Sat, 15 Dec 2007 17:27:02 +0000 (17:27 +0000) |
buildtool.cpp | patch | blob | history |
diff --git a/buildtool.cpp b/buildtool.cpp
index 42c6c3719ab8bfe7f756f3ef8b972c32b5984bc3..da437fae1650f621e94e0ff2d81aa6078710ac2c 100644 (file)
--- a/buildtool.cpp
+++ b/buildtool.cpp
*
*/
-#define BUILDTOOL_VERSION "BuildTool v0.7.2, 2007 Bob Jamison"
+#define BUILDTOOL_VERSION "BuildTool v0.7.3, 2007 Bob Jamison"
#include <stdio.h>
#include <fcntl.h>
* The path to the file associated with this object
*/
URI uri;
+
+ /**
+ * If this prefix is seen in a substitution, use an environment
+ * variable.
+ * example: <property environment="env"/>
+ * ${env.JAVA_HOME}
+ */
+ String envPrefix;
+
+
/**
else if (ch == '}')
{
std::map<String, String>::iterator iter;
- iter = properties.find(trim(varname));
- if (iter != properties.end())
+ varname = trim(varname);
+ if (varname.compare(0, envPrefix.size(), envPrefix) == 0)
{
- val.append(iter->second);
+ varname = varname.substr(envPrefix.size());
+ char *envstr = getenv(varname.c_str());
+ if (!envstr)
+ {
+ error("environment variable '%s' not defined", varname.c_str());
+ return false;
+ }
+ val.append(envstr);
}
else
{
- error("property ${%s} not found", varname.c_str());
- return false;
+ iter = properties.find(varname);
+ if (iter != properties.end())
+ {
+ val.append(iter->second);
+ }
+ else
+ {
+ error("property ${%s} not found", varname.c_str());
+ return false;
+ }
}
break;
}
String description;
- String envAlias;
-
//std::vector<Property> properties;
std::map<String, Target> targets;
specifiedTarget = "";
baseDir = "";
description = "";
- envAlias = "";
+ envPrefix = "";
properties.clear();
for (unsigned int i = 0 ; i < allTasks.size() ; i++)
delete allTasks[i];
}
else if (attrName == "environment")
{
- if (envAlias.size() > 0)
+ if (envPrefix.size() > 0)
+ {
+ error("environment prefix can only be set once");
+ return false;
+ }
+ if (attrVal.find('.') != attrVal.npos)
{
- error("environment property can only be set once");
+ error("environment prefix cannot have a '.' in it");
return false;
}
- envAlias = attrVal;
+ envPrefix = attrVal;
+ envPrefix.push_back('.');
}
}