aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-06-09 13:50:15 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2017-06-09 13:51:34 +0200
commit7343f24c774af89e7ddf9cf24c3932c703b5937c (patch)
tree5d29be927aa90fbb25d95007a475a6110d5e855a /share
parent525165a38302cf43a908a93f57a3a88cd6abc0e0 (diff)
parent7ccc08f33153cd3093081567ac653e371759d69a (diff)
Merge 1.8 into master
Diffstat (limited to 'share')
-rw-r--r--share/qbs/imports/qbs/ModUtils/utils.js6
-rw-r--r--share/qbs/imports/qbs/Probes/GccProbe.qbs9
-rw-r--r--share/qbs/imports/qbs/Probes/NpmProbe.qbs1
-rw-r--r--share/qbs/imports/qbs/Probes/PathProbe.qbs4
-rw-r--r--share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs1
-rw-r--r--share/qbs/imports/qbs/Probes/path-probe.js27
-rw-r--r--share/qbs/modules/cpp/DarwinGCC.qbs1
-rw-r--r--share/qbs/modules/cpp/GenericGCC.qbs17
-rw-r--r--share/qbs/modules/cpp/gcc.js75
-rw-r--r--share/qbs/modules/cpp/qnx-qcc.qbs3
-rw-r--r--share/qbs/modules/qnx/qnx.qbs37
11 files changed, 128 insertions, 53 deletions
diff --git a/share/qbs/imports/qbs/ModUtils/utils.js b/share/qbs/imports/qbs/ModUtils/utils.js
index 5f6d17e78..50715f126 100644
--- a/share/qbs/imports/qbs/ModUtils/utils.js
+++ b/share/qbs/imports/qbs/ModUtils/utils.js
@@ -263,6 +263,12 @@ function flattenDictionary(dict, separator) {
return list;
}
+function ModuleError(message) {
+ var e = new Error(message);
+ e.fileName = "";
+ return e;
+}
+
var EnvironmentVariable = (function () {
function EnvironmentVariable(name, separator, convertPathSeparators) {
if (!name)
diff --git a/share/qbs/imports/qbs/Probes/GccProbe.qbs b/share/qbs/imports/qbs/Probes/GccProbe.qbs
index 77fac9e04..7214ffacb 100644
--- a/share/qbs/imports/qbs/Probes/GccProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/GccProbe.qbs
@@ -29,6 +29,7 @@
****************************************************************************/
import qbs
+import qbs.File
import qbs.ModUtils
import "../../../modules/cpp/gcc.js" as Gcc
@@ -41,7 +42,6 @@ PathProbe {
property string _nullDevice: qbs.nullDevice
property stringList _toolchain: qbs.toolchain
property string _pathListSeparator: qbs.pathListSeparator
- property stringList _targetOS: qbs.targetOS
property string _sysroot: qbs.sysroot
// Outputs
@@ -54,9 +54,14 @@ PathProbe {
property stringList frameworkPaths
configure: {
+ if (!File.exists(compilerFilePath)) {
+ found = false;
+ return;
+ }
+
var macros = Gcc.dumpMacros(environment, compilerFilePath, flags, _nullDevice);
var defaultPaths = Gcc.dumpDefaultPaths(environment, compilerFilePath, flags, _nullDevice,
- _pathListSeparator, _targetOS, _sysroot);
+ _pathListSeparator, _sysroot);
found = !!macros && !!defaultPaths;
includePaths = defaultPaths.includePaths;
diff --git a/share/qbs/imports/qbs/Probes/NpmProbe.qbs b/share/qbs/imports/qbs/Probes/NpmProbe.qbs
index efe26390e..d26e07eec 100644
--- a/share/qbs/imports/qbs/Probes/NpmProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/NpmProbe.qbs
@@ -49,6 +49,7 @@ NodeJsProbe {
result.npmPrefix = result.found ? NodeJs.findLocation(result.filePath, "prefix") : undefined;
found = result.found;
+ candidatePaths = result.candidatePaths;
path = result.path;
filePath = result.filePath;
fileName = result.fileName;
diff --git a/share/qbs/imports/qbs/Probes/PathProbe.qbs b/share/qbs/imports/qbs/Probes/PathProbe.qbs
index 068fa03ff..0e130c5fa 100644
--- a/share/qbs/imports/qbs/Probes/PathProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/PathProbe.qbs
@@ -38,12 +38,13 @@ Probe {
property var nameFilter
property pathList pathPrefixes
property stringList pathSuffixes
- property pathList platformPaths: [ '/usr', '/usr/local' ]
+ property pathList platformPaths: qbs.hostOS.contains("unix") ? ['/usr', '/usr/local'] : []
property pathList environmentPaths
property pathList platformEnvironmentPaths
property string pathListSeparator: qbs.pathListSeparator
// Output
+ property stringList candidatePaths
property string path
property string filePath
property string fileName
@@ -53,6 +54,7 @@ Probe {
pathSuffixes, platformPaths, environmentPaths,
platformEnvironmentPaths, pathListSeparator);
found = result.found;
+ candidatePaths = result.candidatePaths;
path = result.path;
filePath = result.filePath;
fileName = result.fileName;
diff --git a/share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs b/share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs
index f8b773db8..3e6a6cebe 100644
--- a/share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs
@@ -70,6 +70,7 @@ BinaryProbe {
}
found = result.found;
+ candidatePaths = result.candidatePaths;
path = result.path;
filePath = result.filePath;
fileName = result.fileName;
diff --git a/share/qbs/imports/qbs/Probes/path-probe.js b/share/qbs/imports/qbs/Probes/path-probe.js
index 0a0ccc772..bf30e8ec6 100644
--- a/share/qbs/imports/qbs/Probes/path-probe.js
+++ b/share/qbs/imports/qbs/Probes/path-probe.js
@@ -35,6 +35,7 @@ var ModUtils = require("qbs.ModUtils");
function configure(names, nameSuffixes, nameFilter, pathPrefixes, pathSuffixes, platformPaths,
environmentPaths, platformEnvironmentPaths, pathListSeparator) {
+ var result = { found: false, candidatePaths: [] };
if (!names)
throw '"names" must be specified';
var _names = ModUtils.concatAll(names);
@@ -59,24 +60,24 @@ function configure(names, nameSuffixes, nameFilter, pathPrefixes, pathSuffixes,
for (var j = 0; j < _paths.length; ++j) {
for (var k = 0; k < _suffixes.length; ++k) {
var _filePath = FileInfo.joinPaths(_paths[j], _suffixes[k], _names[i]);
+ result.candidatePaths.push(_filePath);
if (File.exists(_filePath)) {
- return {
- found: true,
- filePath: _filePath,
+ result.found = true;
+ result.filePath = _filePath;
- // Manually specify the path components that constitute _filePath rather
- // than using the FileInfo.path and FileInfo.fileName functions because we
- // want to break _filePath into its constituent parts based on the input
- // originally given by the user. For example, the FileInfo functions would
- // produce a different result if any of the items in the names property
- // contained more than a single path component.
- fileName: _names[i],
- path: FileInfo.joinPaths(_paths[j], _suffixes[k]),
- }
+ // Manually specify the path components that constitute _filePath rather
+ // than using the FileInfo.path and FileInfo.fileName functions because we
+ // want to break _filePath into its constituent parts based on the input
+ // originally given by the user. For example, the FileInfo functions would
+ // produce a different result if any of the items in the names property
+ // contained more than a single path component.
+ result.fileName = _names[i];
+ result.path = FileInfo.joinPaths(_paths[j], _suffixes[k]);
+ return result;
}
}
}
}
- return { found: false };
+ return result;
}
diff --git a/share/qbs/modules/cpp/DarwinGCC.qbs b/share/qbs/modules/cpp/DarwinGCC.qbs
index 9398c0df9..b985e6862 100644
--- a/share/qbs/modules/cpp/DarwinGCC.qbs
+++ b/share/qbs/modules/cpp/DarwinGCC.qbs
@@ -70,6 +70,7 @@ UnixGCC {
toolchainInstallPath: xcode.present
? FileInfo.joinPaths(xcode.toolchainPath, "usr", "bin") : base
sysroot: xcode.present ? xcode.sdkPath : base
+ sysrootFlags: sysroot ? ["-isysroot", sysroot] : []
setupBuildEnvironment: {
for (var key in buildEnv) {
diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs
index dd7618e06..ff2e6d679 100644
--- a/share/qbs/modules/cpp/GenericGCC.qbs
+++ b/share/qbs/modules/cpp/GenericGCC.qbs
@@ -53,7 +53,8 @@ CppModule {
id: gccProbe
compilerFilePath: compilerPath
environment: buildEnv
- flags: targetDriverFlags
+ flags: targetDriverFlags.concat(sysrootFlags)
+ _sysroot: sysroot
}
targetLinkerFlags: Gcc.targetFlags("linker", false,
@@ -113,6 +114,7 @@ CppModule {
property string lipoName: "lipo"
property string sysroot: qbs.sysroot
property string syslibroot: sysroot
+ property stringList sysrootFlags: sysroot ? ["--sysroot=" + sysroot] : []
property string linkerMode: "automatic"
PropertyOptions {
@@ -179,6 +181,8 @@ CppModule {
property stringList dsymutilFlags
property bool alwaysUseLipo: false
+ property string includeFlag: "-I"
+ property string systemIncludeFlag: "-isystem"
readonly property bool shouldCreateSymlinks: {
return createSymlinks && internalVersion && ["macho", "elf"].contains(cpp.imageFormat);
@@ -242,6 +246,17 @@ CppModule {
}
validate: {
+ if (!File.exists(compilerPath)) {
+ var pathMessage = FileInfo.isAbsolutePath(compilerPath)
+ ? "at '" + compilerPath + "'"
+ : "'" + compilerPath + "' in PATH";
+ throw ModUtils.ModuleError("Could not find selected C++ compiler " + pathMessage + ". "
+ + "Ensure that the compiler is properly "
+ + "installed, or set cpp.toolchainInstallPath to a valid "
+ + "toolchain path, or consider whether you meant to set "
+ + "cpp.compilerName instead.");
+ }
+
var validator = new ModUtils.PropertyValidator("cpp");
validator.setRequiredProperty("architecture", architecture,
"you might want to re-run 'qbs-setup-toolchains'");
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index 15c57b30c..1534deedc 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -217,7 +217,7 @@ function escapeLinkerFlags(product, inputs, linkerFlags) {
return linkerFlags;
}
-function linkerFlags(project, product, inputs, output) {
+function linkerFlags(project, product, inputs, output, linkerPath) {
var libraryPaths = product.cpp.libraryPaths;
var distributionLibraryPaths = product.cpp.distributionLibraryPaths;
var libraryDependencies = collectLibraryDependencies(product);
@@ -258,6 +258,13 @@ function linkerFlags(project, product, inputs, output) {
["--as-needed"]));
}
+ if (isLegacyQnxSdk(product)) {
+ ["c", "cpp"].map(function (tag) {
+ if (linkerPath === product.cpp.compilerPathByLanguage[tag])
+ args = args.concat(qnxLangArgs(product, tag));
+ });
+ }
+
var targetLinkerFlags = product.cpp.targetLinkerFlags;
if (targetLinkerFlags)
args = args.concat(escapeLinkerFlags(product, inputs, targetLinkerFlags));
@@ -483,6 +490,12 @@ function languageTagFromFileExtension(toolchain, fileName) {
return m[fileName.substring(i + 1)];
}
+// Older versions of the QNX SDK have C and C++ compilers whose filenames differ only by case,
+// which won't work in case insensitive environments like Win32+NTFS, HFS+ and APFS
+function isLegacyQnxSdk(config) {
+ return config.qbs.toolchain.contains("qcc") && config.qnx && !config.qnx.qnx7;
+}
+
function effectiveCompilerInfo(toolchain, input, output) {
var compilerPath, language;
var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags));
@@ -493,8 +506,14 @@ function effectiveCompilerInfo(toolchain, input, output) {
var compilerPathByLanguage = input.cpp.compilerPathByLanguage;
if (compilerPathByLanguage)
compilerPath = compilerPathByLanguage[tag];
- if (!compilerPath || tag !== languageTagFromFileExtension(toolchain, input.fileName))
- language = languageName(tag) + (pchOutput ? '-header' : '');
+ if (!compilerPath
+ || tag !== languageTagFromFileExtension(toolchain, input.fileName)
+ || isLegacyQnxSdk(input)) {
+ if (input.qbs.toolchain.contains("qcc"))
+ language = qnxLangArgs(input, tag);
+ else
+ language = ["-x", languageName(tag) + (pchOutput ? '-header' : '')];
+ }
if (!compilerPath)
// fall back to main compiler
compilerPath = input.cpp.compilerPath;
@@ -505,6 +524,18 @@ function effectiveCompilerInfo(toolchain, input, output) {
};
}
+
+function qnxLangArgs(config, tag) {
+ switch (tag) {
+ case "c":
+ return ["-lang-c"];
+ case "cpp":
+ return ["-lang-c++"];
+ default:
+ return [];
+ }
+}
+
function compilerFlags(project, product, input, output) {
var i;
@@ -525,15 +556,7 @@ function compilerFlags(project, product, input, output) {
var args = additionalCompilerAndLinkerFlags(product);
- var sysroot = product.cpp.sysroot;
- if (sysroot) {
- if (product.qbs.toolchain.contains("qcc"))
- args.push("-I" + FileInfo.joinPaths(sysroot, "usr", "include"));
- else if (product.qbs.targetOS.contains("darwin"))
- args.push("-isysroot", sysroot);
- else
- args.push("--sysroot=" + sysroot);
- }
+ Array.prototype.push.apply(args, product.cpp.sysrootFlags);
if (input.cpp.debugInformation)
args.push('-g');
@@ -615,8 +638,8 @@ function compilerFlags(project, product, input, output) {
}
if (compilerInfo.language)
- // Only push '-x language' if we have to.
- args.push("-x", compilerInfo.language);
+ // Only push language arguments if we have to.
+ Array.prototype.push.apply(args, compilerInfo.language);
args = args.concat(ModUtils.moduleProperty(input, 'platformFlags'),
ModUtils.moduleProperty(input, 'flags'),
@@ -644,15 +667,20 @@ function compilerFlags(project, product, input, output) {
if (defines)
allDefines = allDefines.uniqueConcat(defines);
args = args.concat(allDefines.map(function(define) { return '-D' + define }));
- if (includePaths)
- args = args.concat([].uniqueConcat(includePaths).map(function(path) { return '-I' + path }));
+ if (includePaths) {
+ args = args.concat([].uniqueConcat(includePaths).map(function(path) {
+ return input.cpp.includeFlag + path;
+ }));
+ }
var allSystemIncludePaths = [];
if (systemIncludePaths)
allSystemIncludePaths = allSystemIncludePaths.uniqueConcat(systemIncludePaths);
if (distributionIncludePaths)
allSystemIncludePaths = allSystemIncludePaths.uniqueConcat(distributionIncludePaths);
- args = args.concat(allSystemIncludePaths.map(function(path) { return '-isystem' + path }));
+ args = args.concat(allSystemIncludePaths.map(function(path) {
+ return input.cpp.systemIncludeFlag + path;
+ }));
var minimumWindowsVersion = input.cpp.minimumWindowsVersion;
if (minimumWindowsVersion && product.qbs.targetOS.contains("windows")) {
@@ -750,7 +778,7 @@ function prepareAssembler(project, product, inputs, outputs, input, output) {
allIncludePaths = allIncludePaths.uniqueConcat(systemIncludePaths);
if (distributionIncludePaths)
allIncludePaths = allIncludePaths.uniqueConcat(distributionIncludePaths);
- args = args.concat(allIncludePaths.map(function(path) { return '-I' + path }));
+ args = args.concat(allIncludePaths.map(function(path) { return input.cpp.includeFlag + path }));
args.push("-o", output.filePath);
args.push(input.filePath);
@@ -1027,7 +1055,7 @@ function prepareLinker(project, product, inputs, outputs, input, output) {
var linkerPath = effectiveLinkerPath(product, inputs)
- var args = linkerFlags(project, product, inputs, primaryOutput)
+ var args = linkerFlags(project, product, inputs, primaryOutput, linkerPath);
var wrapperArgsLength = 0;
var wrapperArgs = product.cpp.linkerWrapper;
if (wrapperArgs && wrapperArgs.length > 0) {
@@ -1205,20 +1233,13 @@ function dumpMacros(env, compilerFilePath, args, nullDevice) {
}
}
-function dumpDefaultPaths(env, compilerFilePath, args, nullDevice, pathListSeparator, targetOS,
- sysroot) {
+function dumpDefaultPaths(env, compilerFilePath, args, nullDevice, pathListSeparator, sysroot) {
var p = new Process();
try {
p.setEnv("LC_ALL", "C");
for (var key in env)
p.setEnv(key, env[key]);
args = args || [];
- if (sysroot) {
- if (targetOS.contains("darwin"))
- args.push("-isysroot", sysroot);
- else
- args.push("--sysroot=" + sysroot);
- }
p.exec(compilerFilePath, args.concat(["-v", "-E", "-x", "c++", nullDevice]), true);
var suffix = " (framework directory)";
var includePaths = [];
diff --git a/share/qbs/modules/cpp/qnx-qcc.qbs b/share/qbs/modules/cpp/qnx-qcc.qbs
index fcb4ceea0..7fcd16548 100644
--- a/share/qbs/modules/cpp/qnx-qcc.qbs
+++ b/share/qbs/modules/cpp/qnx-qcc.qbs
@@ -42,12 +42,15 @@ UnixGCC {
toolchainInstallPath: FileInfo.joinPaths(qnx.hostDir, "usr", "bin")
sysroot: qnx.targetDir
+ sysrootFlags: sysroot ? [systemIncludeFlag + FileInfo.joinPaths(sysroot, "usr", "include")] : []
cCompilerName: "qcc" + compilerExtension
cxxCompilerName: (qnx.qnx7 ? "q++" : "QCC") + compilerExtension
targetDriverFlags: qnxTarget ? ["-V" + qnxTarget] : []
+ systemIncludeFlag: !qnx.qnx7 ? includeFlag : base
+
property string qnxTarget: qbs.architecture
? qnx.compilerName + "_" + targetSystem + qnxTargetArchName
: undefined
diff --git a/share/qbs/modules/qnx/qnx.qbs b/share/qbs/modules/qnx/qnx.qbs
index 8a0c1460c..8eb952290 100644
--- a/share/qbs/modules/qnx/qnx.qbs
+++ b/share/qbs/modules/qnx/qnx.qbs
@@ -34,13 +34,15 @@ import qbs.File
import qbs.FileInfo
import qbs.ModUtils
import qbs.Probes
+import qbs.Utilities
Module {
Probes.PathProbe {
id: qnxSdkProbe
names: ["qnx700", "qnx660", "qnx650"]
- pathPrefixes: [Environment.getEnv("HOME"),
- qbs.targetOS.contains("windows") ? "C:/" : "/opt"]
+ pathPrefixes: qbs.hostOS.contains("windows")
+ ? [Environment.getEnv("USERPROFILE"), "C:/"]
+ : [Environment.getEnv("HOME"), "/opt"]
}
Probe {
@@ -69,7 +71,7 @@ Module {
version: qnxSdkProbe.found ? qnxSdkProbe.fileName.substr(3, 3).split("").join(".") : undefined
- readonly property bool qnx7: Utilities.versionCompare(version, "7") >= 0
+ readonly property bool qnx7: version ? Utilities.versionCompare(version, "7") >= 0 : false
property string sdkDir: qnxSdkProbe.filePath
@@ -98,12 +100,29 @@ Module {
"QNX_CONFIGURATION": configurationDir
})
+ qbs.sysroot: targetDir
+
validate: {
- var validator = new ModUtils.PropertyValidator("qnx");
- validator.setRequiredProperty("sdkDir", sdkDir);
- validator.setRequiredProperty("hostArch", hostArch);
- validator.setRequiredProperty("hostOs", hostOs);
- validator.setRequiredProperty("targetOs", targetOs);
- return validator.validate();
+ if (!sdkDir) {
+ throw ModUtils.ModuleError("Could not find a QNX SDK in any of the following "
+ + "locations:\n\t" + qnxSdkProbe.candidatePaths.join("\n\t")
+ + "\nInstall the QNX SDK to one of the above locations, "
+ + "or set the qnx.sdkDir property to a valid QNX SDK "
+ + "location.");
+ }
+
+ if (!hostOs) {
+ throw ModUtils.ModuleError("Host operating system '" + qbs.hostOS
+ + "' is not supported by the QNX SDK.");
+ } else if (!File.exists(hostDir)) {
+ throw ModUtils.ModuleError("Detected host tools operating system '" + hostOs
+ + "' and architecture '" + hostArch + "' directory is not "
+ + "present in the QNX SDK installed at '" + sdkDir
+ + "' in the expected location '" + hostDir
+ + "'; did you forget to install it?");
+ }
+
+ if (!targetOs)
+ throw ModUtils.ModuleError("Could not find any QNX targets in '" + targetDir + "'");
}
}