qmake: add replacement function getenv
This is useful for querying environment variables which have parentheses in their name. Such jewels exist on Windows. The usual $$(VARNAME) syntax fails for those. Change-Id: I1d2766cabdc7f637caa9ae6408967685e02f5029 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
5fe0c9e9b0
commit
b73d6be6a0
@ -2559,6 +2559,13 @@
|
|||||||
|
|
||||||
See also \l{infile(filename, var, val)}{infile()}.
|
See also \l{infile(filename, var, val)}{infile()}.
|
||||||
|
|
||||||
|
\section2 getenv(variablename)
|
||||||
|
|
||||||
|
Returns the value of the environment variable \c variablename.
|
||||||
|
This is mostly equivalent to the \c $$(variablename) syntax.
|
||||||
|
The \c getenv function, however, supports environment variables with
|
||||||
|
parentheses in their name.
|
||||||
|
|
||||||
\section2 join(variablename, glue, before, after)
|
\section2 join(variablename, glue, before, after)
|
||||||
|
|
||||||
Joins the value of \c variablename with \c glue. If this value is
|
Joins the value of \c variablename with \c glue. If this value is
|
||||||
|
@ -99,7 +99,7 @@ enum ExpandFunc {
|
|||||||
E_UPPER, E_LOWER, E_TITLE, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE,
|
E_UPPER, E_LOWER, E_TITLE, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE,
|
||||||
E_REPLACE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS,
|
E_REPLACE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS,
|
||||||
E_SHADOWED, E_ABSOLUTE_PATH, E_RELATIVE_PATH, E_CLEAN_PATH,
|
E_SHADOWED, E_ABSOLUTE_PATH, E_RELATIVE_PATH, E_CLEAN_PATH,
|
||||||
E_SYSTEM_PATH, E_SHELL_PATH, E_SYSTEM_QUOTE, E_SHELL_QUOTE
|
E_SYSTEM_PATH, E_SHELL_PATH, E_SYSTEM_QUOTE, E_SHELL_QUOTE, E_GETENV
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TestFunc {
|
enum TestFunc {
|
||||||
@ -156,6 +156,7 @@ void QMakeEvaluator::initFunctionStatics()
|
|||||||
{ "shell_path", E_SHELL_PATH },
|
{ "shell_path", E_SHELL_PATH },
|
||||||
{ "system_quote", E_SYSTEM_QUOTE },
|
{ "system_quote", E_SYSTEM_QUOTE },
|
||||||
{ "shell_quote", E_SHELL_QUOTE },
|
{ "shell_quote", E_SHELL_QUOTE },
|
||||||
|
{ "getenv", E_GETENV },
|
||||||
};
|
};
|
||||||
for (unsigned i = 0; i < sizeof(expandInits)/sizeof(expandInits[0]); ++i)
|
for (unsigned i = 0; i < sizeof(expandInits)/sizeof(expandInits[0]); ++i)
|
||||||
statics.expands.insert(ProKey(expandInits[i].name), expandInits[i].func);
|
statics.expands.insert(ProKey(expandInits[i].name), expandInits[i].func);
|
||||||
@ -1090,6 +1091,15 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
|
|||||||
ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0)));
|
ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case E_GETENV:
|
||||||
|
if (args.count() != 1) {
|
||||||
|
evalError(fL1S("getenv(arg) requires one argument."));
|
||||||
|
} else {
|
||||||
|
const ProString &var = args.at(0);
|
||||||
|
const ProString &val = ProString(m_option->getEnv(var.toQString(m_tmp1)));
|
||||||
|
ret << val;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
evalError(fL1S("Function '%1' is not implemented.").arg(func.toQString(m_tmp1)));
|
evalError(fL1S("Function '%1' is not implemented.").arg(func.toQString(m_tmp1)));
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user