2012-09-05 16:29:19 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2015-01-28 08:44:43 +00:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing/
|
2012-09-05 16:29:19 +00:00
|
|
|
**
|
|
|
|
** This file is part of the qmake application of the Qt Toolkit.
|
|
|
|
**
|
2014-08-21 13:51:22 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL21$
|
2012-09-19 12:28:29 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at http://www.qt.io/contact-us.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2012-09-05 16:29:19 +00:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-09-19 12:28:29 +00:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-08-21 13:51:22 +00:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2015-01-28 08:44:43 +00:00
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2012-09-05 16:29:19 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "qmakeglobals.h"
|
|
|
|
|
|
|
|
#include "qmakeevaluator.h"
|
|
|
|
#include "ioutils.h"
|
|
|
|
|
|
|
|
#include <qbytearray.h>
|
|
|
|
#include <qdatetime.h>
|
|
|
|
#include <qdebug.h>
|
|
|
|
#include <qdir.h>
|
|
|
|
#include <qfile.h>
|
|
|
|
#include <qfileinfo.h>
|
|
|
|
#include <qlist.h>
|
|
|
|
#include <qregexp.h>
|
|
|
|
#include <qset.h>
|
|
|
|
#include <qstack.h>
|
|
|
|
#include <qstring.h>
|
|
|
|
#include <qstringlist.h>
|
|
|
|
#include <qtextstream.h>
|
|
|
|
#ifdef PROEVALUATOR_THREAD_SAFE
|
|
|
|
# include <qthreadpool.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#else
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
#define QT_POPEN _popen
|
|
|
|
#define QT_PCLOSE _pclose
|
|
|
|
#else
|
|
|
|
#define QT_POPEN popen
|
|
|
|
#define QT_PCLOSE pclose
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
#define fL1S(s) QString::fromLatin1(s)
|
|
|
|
|
|
|
|
QMakeGlobals::QMakeGlobals()
|
|
|
|
{
|
|
|
|
do_cache = true;
|
|
|
|
|
|
|
|
#ifdef PROEVALUATOR_DEBUG
|
|
|
|
debugLevel = 0;
|
|
|
|
#endif
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
dirlist_sep = QLatin1Char(';');
|
|
|
|
dir_sep = QLatin1Char('\\');
|
|
|
|
#else
|
|
|
|
dirlist_sep = QLatin1Char(':');
|
|
|
|
dir_sep = QLatin1Char('/');
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
QMakeGlobals::~QMakeGlobals()
|
|
|
|
{
|
|
|
|
qDeleteAll(baseEnvs);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QMakeGlobals::cleanSpec(QMakeCmdLineParserState &state, const QString &spec)
|
|
|
|
{
|
|
|
|
QString ret = QDir::cleanPath(spec);
|
|
|
|
if (ret.contains(QLatin1Char('/'))) {
|
|
|
|
QString absRet = QDir(state.pwd).absoluteFilePath(ret);
|
|
|
|
if (QFile::exists(absRet))
|
|
|
|
ret = QDir::cleanPath(absRet);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
|
|
|
|
QMakeCmdLineParserState &state, QStringList &args, int *pos)
|
|
|
|
{
|
|
|
|
enum { ArgNone, ArgConfig, ArgSpec, ArgXSpec, ArgTmpl, ArgTmplPfx, ArgCache } argState = ArgNone;
|
|
|
|
for (; *pos < args.count(); (*pos)++) {
|
|
|
|
QString arg = args.at(*pos);
|
|
|
|
switch (argState) {
|
|
|
|
case ArgConfig:
|
|
|
|
if (state.after)
|
|
|
|
state.postconfigs << arg;
|
|
|
|
else
|
|
|
|
state.preconfigs << arg;
|
|
|
|
break;
|
|
|
|
case ArgSpec:
|
|
|
|
qmakespec = args[*pos] = cleanSpec(state, arg);
|
|
|
|
break;
|
|
|
|
case ArgXSpec:
|
|
|
|
xqmakespec = args[*pos] = cleanSpec(state, arg);
|
|
|
|
break;
|
|
|
|
case ArgTmpl:
|
|
|
|
user_template = arg;
|
|
|
|
break;
|
|
|
|
case ArgTmplPfx:
|
|
|
|
user_template_prefix = arg;
|
|
|
|
break;
|
|
|
|
case ArgCache:
|
|
|
|
cachefile = args[*pos] = QDir::cleanPath(QDir(state.pwd).absoluteFilePath(arg));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (arg.startsWith(QLatin1Char('-'))) {
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
if (arg == QLatin1String("-after"))
|
2012-09-05 16:29:19 +00:00
|
|
|
state.after = true;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-config"))
|
2012-09-05 16:29:19 +00:00
|
|
|
argState = ArgConfig;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-nocache"))
|
2012-09-05 16:29:19 +00:00
|
|
|
do_cache = false;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-cache"))
|
2012-09-05 16:29:19 +00:00
|
|
|
argState = ArgCache;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-platform") || arg == QLatin1String("-spec"))
|
2012-09-05 16:29:19 +00:00
|
|
|
argState = ArgSpec;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-xplatform") || arg == QLatin1String("-xspec"))
|
2012-09-05 16:29:19 +00:00
|
|
|
argState = ArgXSpec;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-template") || arg == QLatin1String("-t"))
|
2012-09-05 16:29:19 +00:00
|
|
|
argState = ArgTmpl;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-template_prefix") || arg == QLatin1String("-tp"))
|
2012-09-05 16:29:19 +00:00
|
|
|
argState = ArgTmplPfx;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-win32"))
|
2012-09-05 16:29:19 +00:00
|
|
|
dir_sep = QLatin1Char('\\');
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else if (arg == QLatin1String("-unix"))
|
2012-09-05 16:29:19 +00:00
|
|
|
dir_sep = QLatin1Char('/');
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
(cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403)
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2013-01-08 01:32:53 +00:00
|
|
|
else
|
2012-09-05 16:29:19 +00:00
|
|
|
return ArgumentUnknown;
|
|
|
|
} else if (arg.contains(QLatin1Char('='))) {
|
|
|
|
if (state.after)
|
|
|
|
state.postcmds << arg;
|
|
|
|
else
|
|
|
|
state.precmds << arg;
|
|
|
|
} else {
|
|
|
|
return ArgumentUnknown;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
argState = ArgNone;
|
|
|
|
}
|
|
|
|
if (argState != ArgNone)
|
|
|
|
return ArgumentMalformed;
|
|
|
|
return ArgumentsOk;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state)
|
|
|
|
{
|
|
|
|
if (!state.preconfigs.isEmpty())
|
2014-08-22 23:19:53 +00:00
|
|
|
state.precmds << (fL1S("CONFIG += ") + state.preconfigs.join(QLatin1Char(' ')));
|
|
|
|
precmds = state.precmds.join(QLatin1Char('\n'));
|
2012-09-05 16:29:19 +00:00
|
|
|
if (!state.postconfigs.isEmpty())
|
2014-08-22 23:19:53 +00:00
|
|
|
state.postcmds << (fL1S("CONFIG += ") + state.postconfigs.join(QLatin1Char(' ')));
|
|
|
|
postcmds = state.postcmds.join(QLatin1Char('\n'));
|
2012-09-05 16:29:19 +00:00
|
|
|
|
|
|
|
if (xqmakespec.isEmpty())
|
|
|
|
xqmakespec = qmakespec;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMakeGlobals::useEnvironment()
|
|
|
|
{
|
|
|
|
if (xqmakespec.isEmpty())
|
|
|
|
xqmakespec = getEnv(QLatin1String("XQMAKESPEC"));
|
|
|
|
if (qmakespec.isEmpty()) {
|
|
|
|
qmakespec = getEnv(QLatin1String("QMAKESPEC"));
|
|
|
|
if (xqmakespec.isEmpty())
|
|
|
|
xqmakespec = qmakespec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMakeGlobals::setCommandLineArguments(const QString &pwd, const QStringList &_args)
|
|
|
|
{
|
|
|
|
QStringList args = _args;
|
|
|
|
|
|
|
|
QMakeCmdLineParserState state(pwd);
|
|
|
|
for (int pos = 0; pos < args.size(); pos++)
|
|
|
|
addCommandLineArguments(state, args, &pos);
|
|
|
|
commitCommandLineArguments(state);
|
|
|
|
useEnvironment();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMakeGlobals::setDirectories(const QString &input_dir, const QString &output_dir)
|
|
|
|
{
|
|
|
|
if (input_dir != output_dir && !output_dir.isEmpty()) {
|
|
|
|
QString srcpath = input_dir;
|
|
|
|
if (!srcpath.endsWith(QLatin1Char('/')))
|
|
|
|
srcpath += QLatin1Char('/');
|
|
|
|
QString dstpath = output_dir;
|
|
|
|
if (!dstpath.endsWith(QLatin1Char('/')))
|
|
|
|
dstpath += QLatin1Char('/');
|
|
|
|
int srcLen = srcpath.length();
|
|
|
|
int dstLen = dstpath.length();
|
|
|
|
int lastSl = -1;
|
2013-07-03 14:54:44 +00:00
|
|
|
while (++lastSl, --srcLen, --dstLen,
|
|
|
|
srcLen && dstLen && srcpath.at(srcLen) == dstpath.at(dstLen))
|
2012-09-05 16:29:19 +00:00
|
|
|
if (srcpath.at(srcLen) == QLatin1Char('/'))
|
|
|
|
lastSl = 0;
|
|
|
|
source_root = srcpath.left(srcLen + lastSl);
|
|
|
|
build_root = dstpath.left(dstLen + lastSl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString QMakeGlobals::shadowedPath(const QString &fileName) const
|
|
|
|
{
|
|
|
|
if (source_root.isEmpty())
|
|
|
|
return fileName;
|
|
|
|
if (fileName.startsWith(source_root)
|
|
|
|
&& (fileName.length() == source_root.length()
|
|
|
|
|| fileName.at(source_root.length()) == QLatin1Char('/'))) {
|
|
|
|
return build_root + fileName.mid(source_root.length());
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2013-09-05 16:30:05 +00:00
|
|
|
QStringList QMakeGlobals::splitPathList(const QString &val) const
|
|
|
|
{
|
|
|
|
QStringList ret;
|
|
|
|
if (!val.isEmpty()) {
|
|
|
|
QDir bdir;
|
|
|
|
QStringList vals = val.split(dirlist_sep);
|
|
|
|
ret.reserve(vals.length());
|
|
|
|
foreach (const QString &it, vals)
|
|
|
|
ret << QDir::cleanPath(bdir.absoluteFilePath(it));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-09-05 16:29:19 +00:00
|
|
|
QString QMakeGlobals::getEnv(const QString &var) const
|
|
|
|
{
|
|
|
|
#ifdef PROEVALUATOR_SETENV
|
|
|
|
return environment.value(var);
|
|
|
|
#else
|
|
|
|
return QString::fromLocal8Bit(qgetenv(var.toLocal8Bit().constData()));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList QMakeGlobals::getPathListEnv(const QString &var) const
|
|
|
|
{
|
2013-09-05 16:30:05 +00:00
|
|
|
return splitPathList(getEnv(var));
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString QMakeGlobals::expandEnvVars(const QString &str) const
|
|
|
|
{
|
|
|
|
QString string = str;
|
2014-09-09 13:16:27 +00:00
|
|
|
int startIndex = 0;
|
|
|
|
forever {
|
|
|
|
startIndex = string.indexOf(QLatin1Char('$'), startIndex);
|
|
|
|
if (startIndex < 0)
|
|
|
|
break;
|
|
|
|
if (string.length() < startIndex + 3)
|
|
|
|
break;
|
|
|
|
if (string.at(startIndex + 1) != QLatin1Char('(')) {
|
|
|
|
startIndex++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int endIndex = string.indexOf(QLatin1Char(')'), startIndex + 2);
|
|
|
|
if (endIndex < 0)
|
|
|
|
break;
|
|
|
|
QString value = getEnv(string.mid(startIndex + 2, endIndex - startIndex - 2));
|
|
|
|
string.replace(startIndex, endIndex - startIndex + 1, value);
|
|
|
|
startIndex += value.length();
|
|
|
|
}
|
2012-09-05 16:29:19 +00:00
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef QT_BUILD_QMAKE
|
|
|
|
#ifdef PROEVALUATOR_INIT_PROPS
|
|
|
|
bool QMakeGlobals::initProperties()
|
|
|
|
{
|
|
|
|
QByteArray data;
|
|
|
|
#ifndef QT_BOOTSTRAPPED
|
|
|
|
QProcess proc;
|
|
|
|
proc.start(qmake_abslocation, QStringList() << QLatin1String("-query"));
|
|
|
|
if (!proc.waitForFinished())
|
|
|
|
return false;
|
|
|
|
data = proc.readAll();
|
|
|
|
#else
|
2012-10-31 10:12:58 +00:00
|
|
|
if (FILE *proc = QT_POPEN(QString(QMakeInternal::IoUtils::shellQuote(qmake_abslocation)
|
|
|
|
+ QLatin1String(" -query")).toLocal8Bit(), "r")) {
|
2012-09-05 16:29:19 +00:00
|
|
|
char buff[1024];
|
|
|
|
while (!feof(proc))
|
|
|
|
data.append(buff, int(fread(buff, 1, 1023, proc)));
|
|
|
|
QT_PCLOSE(proc);
|
|
|
|
}
|
|
|
|
#endif
|
2013-06-11 14:08:30 +00:00
|
|
|
foreach (QByteArray line, data.split('\n')) {
|
|
|
|
int off = line.indexOf(':');
|
|
|
|
if (off < 0) // huh?
|
|
|
|
continue;
|
|
|
|
if (line.endsWith('\r'))
|
|
|
|
line.chop(1);
|
|
|
|
QString name = QString::fromLatin1(line.left(off));
|
|
|
|
ProString value = ProString(QDir::fromNativeSeparators(
|
|
|
|
QString::fromLocal8Bit(line.mid(off + 1))));
|
|
|
|
properties.insert(ProKey(name), value);
|
|
|
|
if (name.startsWith(QLatin1String("QT_"))) {
|
|
|
|
bool plain = !name.contains(QLatin1Char('/'));
|
|
|
|
if (!plain) {
|
|
|
|
if (!name.endsWith(QLatin1String("/get")))
|
|
|
|
continue;
|
|
|
|
name.chop(4);
|
|
|
|
}
|
|
|
|
if (name.startsWith(QLatin1String("QT_INSTALL_"))) {
|
|
|
|
if (plain) {
|
2012-09-05 16:29:19 +00:00
|
|
|
properties.insert(ProKey(name + QLatin1String("/raw")), value);
|
|
|
|
properties.insert(ProKey(name + QLatin1String("/get")), value);
|
2013-06-11 14:08:30 +00:00
|
|
|
}
|
|
|
|
properties.insert(ProKey(name + QLatin1String("/src")), value);
|
|
|
|
if (name == QLatin1String("QT_INSTALL_PREFIX")
|
|
|
|
|| name == QLatin1String("QT_INSTALL_DATA")
|
|
|
|
|| name == QLatin1String("QT_INSTALL_BINS")) {
|
|
|
|
name.replace(3, 7, QLatin1String("HOST"));
|
|
|
|
if (plain) {
|
2012-09-05 16:29:19 +00:00
|
|
|
properties.insert(ProKey(name), value);
|
|
|
|
properties.insert(ProKey(name + QLatin1String("/get")), value);
|
|
|
|
}
|
2013-06-11 14:08:30 +00:00
|
|
|
properties.insert(ProKey(name + QLatin1String("/src")), value);
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
2013-06-11 14:08:30 +00:00
|
|
|
} else if (name.startsWith(QLatin1String("QT_HOST_"))) {
|
|
|
|
if (plain)
|
|
|
|
properties.insert(ProKey(name + QLatin1String("/get")), value);
|
|
|
|
properties.insert(ProKey(name + QLatin1String("/src")), value);
|
2012-09-05 16:29:19 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-11 14:08:30 +00:00
|
|
|
}
|
2012-09-05 16:29:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void QMakeGlobals::setProperties(const QHash<QString, QString> &props)
|
|
|
|
{
|
|
|
|
QHash<QString, QString>::ConstIterator it = props.constBegin(), eit = props.constEnd();
|
|
|
|
for (; it != eit; ++it)
|
|
|
|
properties.insert(ProKey(it.key()), ProString(it.value()));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif // QT_BUILD_QMAKE
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|