91 enum { ArgNone, ArgConfig, ArgSpec, ArgXSpec, ArgTmpl, ArgTmplPfx, ArgCache, ArgQtConf } argState = ArgNone;
92 for (; *pos < args.size(); (*pos)++) {
93 QString arg = args.at(*pos);
96 state.configs[state
.phase] << arg;
99 qmakespec = args[*pos] = cleanSpec(state, arg);
102 xqmakespec = args[*pos] = cleanSpec(state, arg);
108 user_template_prefix = arg;
111 cachefile = args[*pos] = IoUtils::resolvePath(state.pwd, arg);
114 qtconf = args[*pos] = IoUtils::resolvePath(state.pwd, arg);
117 if (arg.startsWith(QLatin1Char(
'-'))) {
118 if (arg == QLatin1String(
"--")) {
119 state.extraargs = args.mid(*pos + 1);
120 args.erase(args.begin() + *pos, args.end());
123 if (arg == QLatin1String(
"-early"))
125 else if (arg == QLatin1String(
"-before"))
127 else if (arg == QLatin1String(
"-after"))
129 else if (arg == QLatin1String(
"-late"))
131 else if (arg == QLatin1String(
"-config"))
132 argState = ArgConfig;
133 else if (arg == QLatin1String(
"-nocache"))
135 else if (arg == QLatin1String(
"-cache"))
137 else if (arg == QLatin1String(
"-qtconf"))
138 argState = ArgQtConf;
139 else if (arg == QLatin1String(
"-platform") || arg == QLatin1String(
"-spec"))
141 else if (arg == QLatin1String(
"-xplatform") || arg == QLatin1String(
"-xspec"))
143 else if (arg == QLatin1String(
"-template") || arg == QLatin1String(
"-t"))
145 else if (arg == QLatin1String(
"-template_prefix") || arg == QLatin1String(
"-tp"))
146 argState = ArgTmplPfx;
147 else if (arg == QLatin1String(
"-win32"))
148 dir_sep = QLatin1Char(
'\\');
149 else if (arg == QLatin1String(
"-unix"))
150 dir_sep = QLatin1Char(
'/');
153 }
else if (arg.contains(QLatin1Char(
'='))) {
154 state.cmds[state
.phase] << arg;
162 if (argState != ArgNone)
169 if (!state.extraargs.isEmpty()) {
170 QString extra =
fL1S(
"QMAKE_EXTRA_ARGS =");
171 for (
const QString &ea : std::as_const(state.extraargs))
172 extra += QLatin1Char(
' ') + QMakeEvaluator::quoteValue(ProString(ea));
175 for (
int p = 0; p < 4; p++) {
176 if (!state.configs[p].isEmpty())
177 state.cmds[p] << (
fL1S(
"CONFIG += ") + state.configs[p].join(QLatin1Char(
' ')));
178 extra_cmds[p] = state.cmds[p].join(QLatin1Char(
'\n'));
181 if (xqmakespec.isEmpty())
182 xqmakespec = qmakespec;
209 if (input_dir != output_dir && !output_dir.isEmpty()) {
210 QString srcpath = input_dir;
211 if (!srcpath.endsWith(QLatin1Char(
'/')))
212 srcpath += QLatin1Char(
'/');
213 QString dstpath = output_dir;
214 if (!dstpath.endsWith(QLatin1Char(
'/')))
215 dstpath += QLatin1Char(
'/');
216 int srcLen = srcpath.size();
217 int dstLen = dstpath.size();
219 while (++lastSl, --srcLen, --dstLen,
220 srcLen && dstLen && srcpath.at(srcLen) == dstpath.at(dstLen))
221 if (srcpath.at(srcLen) == QLatin1Char(
'/'))
223 source_root = srcpath.left(srcLen + lastSl);
224 build_root = dstpath.left(dstLen + lastSl);
269 QString string = str;
272 startIndex = string.indexOf(QLatin1Char(
'$'), startIndex);
275 if (string.size() < startIndex + 3)
277 if (string.at(startIndex + 1) != QLatin1Char(
'(')) {
281 int endIndex = string.indexOf(QLatin1Char(
')'), startIndex + 2);
284 QString value = getEnv(string.mid(startIndex + 2, endIndex - startIndex - 2));
285 string.replace(startIndex, endIndex - startIndex + 1, value);
286 startIndex += value.size();
307 data.append(buff,
int(fread(buff, 1, 1023, proc)));
318 const auto lines = data.split(
'\n');
319 for (QByteArray line : lines) {
320 int off = line.indexOf(
':');
323 if (line.endsWith(
'\r'))
325 QString name = QString::fromLatin1(line.left(off));
326 ProString value = ProString(QDir::fromNativeSeparators(
327 QString::fromLocal8Bit(line.mid(off + 1))));
329 value = ProString(
"");
330 properties.insert(ProKey(name), value);
331 if (name.startsWith(QLatin1String(
"QT_"))) {
332 enum { PropPut, PropRaw, PropGet } variant;
333 if (name.contains(QLatin1Char(
'/'))) {
334 if (name.endsWith(QLatin1String(
"/raw")))
336 else if (name.endsWith(QLatin1String(
"/get")))
344 if (name.startsWith(QLatin1String(
"QT_INSTALL_"))) {
345 if (variant < PropRaw) {
346 if (name == QLatin1String(
"QT_INSTALL_PREFIX")
347 || name == QLatin1String(
"QT_INSTALL_DATA")
348 || name == QLatin1String(
"QT_INSTALL_LIBS")
349 || name == QLatin1String(
"QT_INSTALL_BINS")) {
351 QString hname = name;
352 hname.replace(3, 7, QLatin1String(
"HOST"));
353 properties.insert(ProKey(hname), value);
354 properties.insert(ProKey(hname + QLatin1String(
"/get")), value);
355 properties.insert(ProKey(hname + QLatin1String(
"/src")), value);
357 properties.insert(ProKey(name + QLatin1String(
"/raw")), value);
359 if (variant <= PropRaw)
360 properties.insert(ProKey(name + QLatin1String(
"/dev")), value);
361 }
else if (!name.startsWith(QLatin1String(
"QT_HOST_"))) {
364 if (variant != PropRaw) {
365 if (variant < PropGet)
366 properties.insert(ProKey(name + QLatin1String(
"/get")), value);
367 properties.insert(ProKey(name + QLatin1String(
"/src")), value);