aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2013-04-12 01:40:49 -0400
committerJoerg Bornemann <joerg.bornemann@digia.com>2013-04-12 15:04:09 +0200
commit88fdf28c0d499f6dea6193072e796c313e61c2b3 (patch)
tree50ed1a0559cd666fa4819337882ff9832ca3f339
parented53341676e8902600e6ef95936d6cfdab6087d9 (diff)
Fix handling of minimum Windows version and subsystem linker flags.
Both MSVC and MinGW now only pass their respective subsystem flags if product.consoleApplication is not undefined - the linkers use console by default. MSVC: as an exception to the above, a subsystem flag must be passed regardless of the value of product.consoleApplication if a minimum system version was specified - in this case subsystem will be set to console. MinGW now correctly handles setting the minimum subsystem/OS version; it was previously using totally nonexistent flags due to poor assumptions about its MSVC compatibility. The test case which tests this functionality was also broken, and is now fixed as well. Task-number: QBS-244 Change-Id: Ibca29ce673a81f1231d364d5b6e6875a462b379c Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
-rw-r--r--share/qbs/modules/cpp/GenericGCC.qbs17
-rw-r--r--share/qbs/modules/cpp/msvc.js15
-rw-r--r--share/qbs/modules/cpp/windows.js38
-rw-r--r--tests/manual/minimumSystemVersion/main.cpp3
-rw-r--r--tests/manual/minimumSystemVersion/minimumSystemVersion.qbs12
5 files changed, 56 insertions, 29 deletions
diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs
index 2f2d101d0..d3028a786 100644
--- a/share/qbs/modules/cpp/GenericGCC.qbs
+++ b/share/qbs/modules/cpp/GenericGCC.qbs
@@ -201,17 +201,26 @@ CppModule {
for (i in linkerFlags)
args.push(linkerFlags[i])
if (product.moduleProperty("qbs", "toolchain") === "mingw") {
- var subsystemSwitch = product.consoleApplication ? "-Wl,-subsystem,console" : "-Wl,-subsystem,windows";
+ if (product.consoleApplication !== undefined)
+ if (product.consoleApplication)
+ args.push("-Wl,-subsystem,console");
+ else
+ args.push("-Wl,-subsystem,windows");
var minimumWindowsVersion = ModUtils.moduleProperty(product, "minimumWindowsVersion");
if (minimumWindowsVersion) {
var subsystemVersion = Windows.getWindowsVersionInFormat(minimumWindowsVersion, 'subsystem');
if (subsystemVersion) {
- args.push(subsystemSwitch + ',' + subsystemVersion);
- args.push("-Wl,-osversion," + subsystemVersion);
+ var major = subsystemVersion.split('.')[0];
+ var minor = subsystemVersion.split('.')[1];
+
+ // http://sourceware.org/binutils/docs/ld/Options.html
+ args.push("-Wl,--major-subsystem-version," + major);
+ args.push("-Wl,--minor-subsystem-version," + minor);
+ args.push("-Wl,--major-os-version," + major);
+ args.push("-Wl,--minor-os-version," + minor);
} else {
print('WARNING: Unknown Windows version "' + minimumWindowsVersion + '"');
- args.push(subsystemSwitch);
}
}
}
diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js
index 257705b32..ed8af567b 100644
--- a/share/qbs/modules/cpp/msvc.js
+++ b/share/qbs/modules/cpp/msvc.js
@@ -121,20 +121,27 @@ function prepareLinker(product, inputs, outputs, libraryPaths, dynamicLibraries,
else
args.push('/INCREMENTAL:NO')
- var subsystemSwitch = product.consoleApplication ? '/SUBSYSTEM:CONSOLE' : '/SUBSYSTEM:WINDOWS';
-
var minimumWindowsVersion = ModUtils.moduleProperty(product, "minimumWindowsVersion");
+ var subsystemSwitch = undefined;
+ if (minimumWindowsVersion || product.consoleApplication !== undefined) {
+ // Ensure that we default to console if product.consoleApplication is undefined
+ // since that could still be the case if only minimumWindowsVersion had been defined
+ subsystemSwitch = product.consoleApplication === false ? '/SUBSYSTEM:WINDOWS' : '/SUBSYSTEM:CONSOLE';
+ }
+
if (minimumWindowsVersion) {
var subsystemVersion = Windows.getWindowsVersionInFormat(minimumWindowsVersion, 'subsystem');
if (subsystemVersion) {
- args.push(subsystemSwitch + ',' + subsystemVersion);
+ subsystemSwitch += ',' + subsystemVersion;
args.push('/OSVERSION:' + subsystemVersion);
} else {
print('WARNING: Unknown Windows version "' + minimumWindowsVersion + '"');
- args.push(subsystemSwitch);
}
}
+ if (subsystemSwitch)
+ args.push(subsystemSwitch);
+
var linkerOutputNativeFilePath;
var manifestFileName;
if (generateManifestFiles) {
diff --git a/share/qbs/modules/cpp/windows.js b/share/qbs/modules/cpp/windows.js
index 677a450ce..710b9f304 100644
--- a/share/qbs/modules/cpp/windows.js
+++ b/share/qbs/modules/cpp/windows.js
@@ -1,22 +1,26 @@
-function getWindowsVersionInFormat(systemVersion, format) {
+function isValidWindowsVersion(systemVersion) {
// Add new Windows versions to this list when they are released
var realVersions = [ '6.2', '6.1', '6.0', '5.2', '5.1', '5.0', '4.0' ];
- for (i in realVersions) {
- // Make sure the user specified a valid Windows version we have listed here
- if (systemVersion === realVersions[i]) {
- var major = parseInt(systemVersion.split('.')[0]);
- var minor = parseInt(systemVersion.split('.')[1]);
+ for (i in realVersions)
+ if (systemVersion === realVersions[i])
+ return true;
- if (format === 'hex') {
- return '0x' + major + (minor < 10 ? '0' : '') + minor;
- } else if (format === 'subsystem') {
- // http://msdn.microsoft.com/en-us/library/fcc1zstk.aspx
- return major + '.' + (minor < 10 ? '0' : '') + minor;
- } else {
- throw ("Unrecognized Windows version format " + format + ". Must be in {hex, subsystem}.");
- }
- }
- }
+ return false;
+}
- return undefined
+function getWindowsVersionInFormat(systemVersion, format) {
+ if (!isValidWindowsVersion(systemVersion))
+ return undefined;
+
+ var major = parseInt(systemVersion.split('.')[0]);
+ var minor = parseInt(systemVersion.split('.')[1]);
+
+ if (format === 'hex') {
+ return '0x' + major + (minor < 10 ? '0' : '') + minor;
+ } else if (format === 'subsystem') {
+ // http://msdn.microsoft.com/en-us/library/fcc1zstk.aspx
+ return major + '.' + (minor < 10 ? '0' : '') + minor;
+ } else {
+ throw ("Unrecognized Windows version format " + format + ". Must be in {hex, subsystem}.");
+ }
}
diff --git a/tests/manual/minimumSystemVersion/main.cpp b/tests/manual/minimumSystemVersion/main.cpp
index db5411d11..769428574 100644
--- a/tests/manual/minimumSystemVersion/main.cpp
+++ b/tests/manual/minimumSystemVersion/main.cpp
@@ -28,8 +28,7 @@ int main(int argc, char *argv[])
while (dumpbin.canReadLine()) {
QString line = dumpbin.readLine();
if (line.contains("version")) {
- out << line.trimmed();
- out.endl();
+ out << line.trimmed() << "\n";
}
}
}
diff --git a/tests/manual/minimumSystemVersion/minimumSystemVersion.qbs b/tests/manual/minimumSystemVersion/minimumSystemVersion.qbs
index 57316f2d9..24313ef5b 100644
--- a/tests/manual/minimumSystemVersion/minimumSystemVersion.qbs
+++ b/tests/manual/minimumSystemVersion/minimumSystemVersion.qbs
@@ -7,7 +7,11 @@ Project {
Depends { name: "Qt.core" }
name: "unspecified"
files: "main.cpp"
- cpp.frameworks: "Foundation"
+
+ Properties {
+ condition: qbs.targetPlatform.indexOf("darwin") !== -1
+ cpp.frameworks: "Foundation"
+ }
}
// no minimum versions are specified, and explicitly set to undefined in
@@ -17,11 +21,15 @@ Project {
Depends { name: "Qt.core" }
name: "unspecified-forced"
files: "main.cpp"
- cpp.frameworks: "Foundation"
cpp.minimumWindowsVersion: undefined
cpp.minimumMacVersion: undefined
cpp.minimumIosVersion: undefined
cpp.minimumAndroidVersion: undefined
+
+ Properties {
+ condition: qbs.targetPlatform.indexOf("darwin") !== -1
+ cpp.frameworks: "Foundation"
+ }
}
// a specific version of the operating systems is specified