diff options
author | Jake Petroules <jake.petroules@qt.io> | 2016-04-22 11:20:45 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2016-05-11 05:37:11 +0000 |
commit | 87a1478921d634dcd99a4bac2ea851ad1cc93c48 (patch) | |
tree | 3916c7926954bc6285ee3398f697bcb6cda7ace7 /src | |
parent | fa9f4293a0d25e0890d234b1a6d8fc863aa56cac (diff) | |
download | qbs-87a1478921d634dcd99a4bac2ea851ad1cc93c48.tar.gz |
Automatically determine the compiler's architecture.
Also, do extensive validation on the result by ensuring that the arch
specified by the user is what which the compiler will actually generate
when invoked, by constructing an appropriate argument list and doing a
dump of the compiler's macros.
This ensures a user cannot specify a bogus architecture which is not
actually the one the compiler will generate. Furthermore, compiler
probes will no longer generate the wrong value for qbs.architecture
for ARM-family architectures, since the triple returned by
$(CC) -dumpmachine does not include the subarch which needs to be passed
to the compiler.
Users will also be prevented from subverting proper operation by
attempting to pass raw ABI-related flags in the flags properties.
Change-Id: I2aed8e0afefdf7e5a4112183f2f9ea96b1e22b51
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/app/qbs-setup-android/android-setup.cpp | 8 | ||||
-rw-r--r-- | src/app/qbs-setup-toolchains/probe.cpp | 9 | ||||
-rw-r--r-- | src/lib/corelib/jsextensions/utilitiesextension.cpp | 14 |
3 files changed, 15 insertions, 16 deletions
diff --git a/src/app/qbs-setup-android/android-setup.cpp b/src/app/qbs-setup-android/android-setup.cpp index 3177ae07e..ae7c2d9e1 100644 --- a/src/app/qbs-setup-android/android-setup.cpp +++ b/src/app/qbs-setup-android/android-setup.cpp @@ -48,10 +48,10 @@ static QStringList expectedArchs() { return QStringList() << QStringLiteral("arm64") - << QStringLiteral("armv5") - << QStringLiteral("armv7") - << QStringLiteral("mipsel") - << QStringLiteral("mips64el") + << QStringLiteral("armv5te") + << QStringLiteral("armv7a") + << QStringLiteral("mips") + << QStringLiteral("mips64") << QStringLiteral("x86") << QStringLiteral("x86_64"); } diff --git a/src/app/qbs-setup-toolchains/probe.cpp b/src/app/qbs-setup-toolchains/probe.cpp index eef8dc6f7..e21d7148f 100644 --- a/src/app/qbs-setup-toolchains/probe.cpp +++ b/src/app/qbs-setup-toolchains/probe.cpp @@ -124,7 +124,7 @@ static QStringList standardCompilerFileNames() } static void setCommonProperties(Profile &profile, const QString &compilerFilePath, - const QStringList &toolchainTypes, const QString &architecture) + const QStringList &toolchainTypes) { const QFileInfo cfi(compilerFilePath); const QString compilerName = cfi.fileName(); @@ -138,7 +138,6 @@ static void setCommonProperties(Profile &profile, const QString &compilerFilePat profile.setValue(QLatin1String("cpp.toolchainInstallPath"), cfi.absolutePath()); profile.setValue(QLatin1String("qbs.toolchain"), toolchainTypes); - profile.setValue(QLatin1String("qbs.architecture"), canonicalArchitecture(architecture)); setCompilerVersion(compilerFilePath, toolchainTypes, profile); const QString suffix = compilerName.right(compilerName.size() - prefix.size()); @@ -183,21 +182,17 @@ static Profile createGccProfile(const QString &compilerFilePath, Settings *setti const QString &profileName = QString()) { const QString machineName = gccMachineName(compilerFilePath); - const QStringList compilerTriplet = machineName.split(QLatin1Char('-')); if (toolchainTypes.contains(QLatin1String("mingw"))) { if (!validMinGWMachines().contains(machineName)) { throw ErrorInfo(Tr::tr("Detected gcc platform '%1' is not supported.") .arg(machineName)); } - } else if (compilerTriplet.count() < 2) { - throw qbs::ErrorInfo(Tr::tr("Architecture of compiler for platform '%1' at '%2' not understood.") - .arg(machineName, compilerFilePath)); } Profile profile(!profileName.isEmpty() ? profileName : machineName, settings); profile.removeProfile(); - setCommonProperties(profile, compilerFilePath, toolchainTypes, compilerTriplet.first()); + setCommonProperties(profile, compilerFilePath, toolchainTypes); // Check whether auxiliary tools reside within the toolchain's install path. // This might not be the case when using icecc or another compiler wrapper. diff --git a/src/lib/corelib/jsextensions/utilitiesextension.cpp b/src/lib/corelib/jsextensions/utilitiesextension.cpp index ab77e2fba..87f0a0535 100644 --- a/src/lib/corelib/jsextensions/utilitiesextension.cpp +++ b/src/lib/corelib/jsextensions/utilitiesextension.cpp @@ -104,11 +104,15 @@ QScriptValue UtilitiesExtension::js_ctor(QScriptContext *context, QScriptEngine QScriptValue UtilitiesExtension::js_canonicalArchitecture(QScriptContext *context, QScriptEngine *engine) { - if (Q_UNLIKELY(context->argumentCount() != 1)) - return context->throwError(QScriptContext::SyntaxError, - QLatin1String("canonicalArchitecture expects 1 argument")); - const QString architecture = context->argument(0).toString(); - return engine->toScriptValue(canonicalArchitecture(architecture)); + const QScriptValue value = context->argument(0); + if (value.isUndefined() || value.isNull()) + return value; + + if (context->argumentCount() == 1 && value.isString()) + return engine->toScriptValue(canonicalArchitecture(value.toString())); + + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("canonicalArchitecture expects one argument of type string")); } QScriptValue UtilitiesExtension::js_canonicalToolchain(QScriptContext *context, |