diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2015-06-09 23:48:35 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@petroules.com> | 2015-07-29 19:17:07 +0000 |
commit | e8963d2a2ff314355ec6a44df2647eb84eda634f (patch) | |
tree | bba83ecbc2583f9656eafa5ad192fc27f1375a16 /share/qbs/modules | |
parent | c50827bf53e3863adcfd8c0e38aa5b7773eb075f (diff) |
Introduce Xcode module.
Change-Id: I3d338b1f3a41bb4c19e0c3c213139e09493ae10b
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'share/qbs/modules')
-rw-r--r-- | share/qbs/modules/bundle/BundleModule.qbs | 8 | ||||
-rw-r--r-- | share/qbs/modules/cpp/CppModule.qbs | 3 | ||||
-rw-r--r-- | share/qbs/modules/cpp/DarwinGCC.qbs | 28 | ||||
-rw-r--r-- | share/qbs/modules/cpp/GenericGCC.qbs | 1 | ||||
-rw-r--r-- | share/qbs/modules/cpp/ios-gcc.qbs | 2 | ||||
-rw-r--r-- | share/qbs/modules/cpp/osx-gcc.qbs | 2 | ||||
-rw-r--r-- | share/qbs/modules/ib/IBModule.qbs | 2 | ||||
-rw-r--r-- | share/qbs/modules/xcode/xcode.js | 99 | ||||
-rw-r--r-- | share/qbs/modules/xcode/xcode.qbs | 148 |
9 files changed, 260 insertions, 33 deletions
diff --git a/share/qbs/modules/bundle/BundleModule.qbs b/share/qbs/modules/bundle/BundleModule.qbs index 8572208e1..c553946d8 100644 --- a/share/qbs/modules/bundle/BundleModule.qbs +++ b/share/qbs/modules/bundle/BundleModule.qbs @@ -211,7 +211,7 @@ Module { cmd.infoPlistFormat = ModUtils.moduleProperty(product, "infoPlistFormat"); cmd.qmakeEnv = ModUtils.moduleProperty(product, "qmakeEnv"); - cmd.platformPath = product.moduleProperty("cpp", "platformPath"); + cmd.platformPath = product.moduleProperty("xcode", "platformPath"); cmd.toolchainInstallPath = product.moduleProperty("cpp", "toolchainInstallPath"); cmd.buildEnv = product.moduleProperty("cpp", "buildEnv"); cmd.defines = product.moduleProperty("cpp", "defines"); @@ -219,9 +219,9 @@ Module { cmd.compilerDefines = product.moduleProperty("cpp", "compilerDefines"); cmd.allDefines = [].concat(cmd.defines || []).concat(cmd.platformDefines || []).concat(cmd.compilerDefines || []); - cmd.platformInfoPlist = product.moduleProperty("cpp", "platformInfoPlist"); - cmd.sdkSettingsPlist = product.moduleProperty("cpp", "sdkSettingsPlist"); - cmd.toolchainInfoPlist = product.moduleProperty("cpp", "toolchainInfoPlist"); + cmd.platformInfoPlist = product.moduleProperty("xcode", "platformInfoPlist"); + cmd.sdkSettingsPlist = product.moduleProperty("xcode", "sdkSettingsPlist"); + cmd.toolchainInfoPlist = product.moduleProperty("xcode", "toolchainInfoPlist"); cmd.sysroot = product.moduleProperty("qbs", "sysroot"); cmd.osBuildVersion = product.moduleProperty("qbs", "hostOSBuildVersion"); diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs index 62b6659aa..3443f1c7b 100644 --- a/share/qbs/modules/cpp/CppModule.qbs +++ b/share/qbs/modules/cpp/CppModule.qbs @@ -244,9 +244,6 @@ Module { property string signingIdentity property path provisioningProfile - property string xcodeSdkName - property string xcodeSdkVersion - property bool automaticReferenceCounting PropertyOptions { name: "automaticReferenceCounting" diff --git a/share/qbs/modules/cpp/DarwinGCC.qbs b/share/qbs/modules/cpp/DarwinGCC.qbs index 43ea72bc5..05e40d9d3 100644 --- a/share/qbs/modules/cpp/DarwinGCC.qbs +++ b/share/qbs/modules/cpp/DarwinGCC.qbs @@ -29,11 +29,14 @@ ****************************************************************************/ import qbs +import qbs.FileInfo import qbs.ModUtils UnixGCC { condition: false + Depends { name: "xcode"; required: false } + compilerDefines: ["__GNUC__", "__APPLE__"] loadableModulePrefix: "" loadableModuleSuffix: ".bundle" @@ -41,26 +44,11 @@ UnixGCC { separateDebugInformation: true debugInfoSuffix: ".dSYM" - validate: { - if (qbs.sysroot) { - var validator = new ModUtils.PropertyValidator("cpp"); - validator.setRequiredProperty("xcodeSdkName", xcodeSdkName); - validator.setRequiredProperty("xcodeSdkVersion", xcodeSdkVersion); - validator.validate(); - } - } + toolchainInstallPath: xcode.present + ? FileInfo.joinPaths(xcode.toolchainPath, "usr", "bin") : base + sysroot: xcode.present ? xcode.sdkPath : base setupBuildEnvironment: { - var v = new ModUtils.EnvironmentVariable("PATH", ":", false); - if (platformPath) { - v.prepend(platformPath + "/Developer/usr/bin"); - var platformPathL = platformPath.split("/"); - platformPathL.pop(); - platformPathL.pop(); - var devPath = platformPathL.join("/") - v.prepend(devPath + "/usr/bin"); - v.set(); - } for (var key in buildEnv) { v = new ModUtils.EnvironmentVariable(key); v.value = buildEnv[key]; @@ -113,8 +101,4 @@ UnixGCC { env["MACOSX_DEPLOYMENT_TARGET"] = minimumOsxVersion; return env; } - - readonly property path platformInfoPlist: platformPath ? [platformPath, "Info.plist"].join("/") : undefined - readonly property path sdkSettingsPlist: sysroot ? [sysroot, "SDKSettings.plist"].join("/") : undefined - readonly property path toolchainInfoPlist: toolchainInstallPath ? [toolchainInstallPath, "../../ToolchainInfo.plist"].join("/") : undefined } diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs index 1c7926136..f218434d5 100644 --- a/share/qbs/modules/cpp/GenericGCC.qbs +++ b/share/qbs/modules/cpp/GenericGCC.qbs @@ -58,7 +58,6 @@ CppModule { property string stripName: "strip" property string dsymutilName: "dsymutil" property path sysroot: qbs.sysroot - property path platformPath property string exportedSymbolsCheckMode: "ignore-undefined" PropertyOptions { diff --git a/share/qbs/modules/cpp/ios-gcc.qbs b/share/qbs/modules/cpp/ios-gcc.qbs index d087bb6d2..93df91c9c 100644 --- a/share/qbs/modules/cpp/ios-gcc.qbs +++ b/share/qbs/modules/cpp/ios-gcc.qbs @@ -39,7 +39,7 @@ DarwinGCC { qbs.toolchain && qbs.toolchain.contains('gcc') // Setting a minimum is especially important for Simulator or CC/LD thinks the target is OS X - minimumIosVersion: xcodeSdkVersion || (cxxStandardLibrary === "libc++" ? "5.0" : undefined) + minimumIosVersion: xcode.sdkVersion || (cxxStandardLibrary === "libc++" ? "5.0" : undefined) platformObjcFlags: base.concat(simulatorObjcFlags) platformObjcxxFlags: base.concat(simulatorObjcFlags) diff --git a/share/qbs/modules/cpp/osx-gcc.qbs b/share/qbs/modules/cpp/osx-gcc.qbs index a9263ec36..83246f509 100644 --- a/share/qbs/modules/cpp/osx-gcc.qbs +++ b/share/qbs/modules/cpp/osx-gcc.qbs @@ -36,5 +36,5 @@ DarwinGCC { qbs.targetOS.contains('osx') && qbs.toolchain && qbs.toolchain.contains('gcc') - minimumOsxVersion: xcodeSdkVersion || (cxxStandardLibrary === "libc++" ? "10.7" : undefined) + minimumOsxVersion: xcode.sdkVersion || (cxxStandardLibrary === "libc++" ? "10.7" : undefined) } diff --git a/share/qbs/modules/ib/IBModule.qbs b/share/qbs/modules/ib/IBModule.qbs index 5bed74d65..dd52984e5 100644 --- a/share/qbs/modules/ib/IBModule.qbs +++ b/share/qbs/modules/ib/IBModule.qbs @@ -37,8 +37,8 @@ import qbs.Process import 'ib.js' as Ib Module { - Depends { name: "cpp" } // to put toolchainInstallPath in the PATH for actool Depends { name: "bundle" } + Depends { name: "xcode" } condition: qbs.hostOS.contains("darwin") && qbs.targetOS.contains("darwin") diff --git a/share/qbs/modules/xcode/xcode.js b/share/qbs/modules/xcode/xcode.js new file mode 100644 index 000000000..6b93b9985 --- /dev/null +++ b/share/qbs/modules/xcode/xcode.js @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of the Qt Build Suite. +** +** 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 +** 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** 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. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = loadExtension("qbs.File"); +var FileInfo = loadExtension("qbs.FileInfo"); +var PropertyList = loadExtension("qbs.PropertyList"); + +function applePlatformDirectoryName(targetOSList, version, throwOnError) { + if (!version) + version = ""; + if (targetOSList.contains("ios-simulator")) + return "iPhoneSimulator" + version; + else if (targetOSList.contains("ios")) + return "iPhoneOS" + version; + else if (targetOSList.contains("osx")) + return "MacOSX" + version; + if (throwOnError || throwOnError === undefined) + throw("No Apple platform corresponds to target OS list: " + targetOSList); +} + +function sdkInfoList(sdksPath) { + var sdkInfo = []; + var sdks = File.directoryEntries(sdksPath, File.Dirs | File.NoDotAndDotDot); + for (var i in sdks) { + // SDK directory name must contain a version number; + // we don't want the versionless iPhoneOS.sdk directory for example + if (!sdks[i].match(/[0-9]+/)) + continue; + + var settingsPlist = FileInfo.joinPaths(sdksPath, sdks[i], "SDKSettings.plist"); + var propertyList = new PropertyList(); + try { + propertyList.readFromFile(settingsPlist); + + function checkPlist(plist) { + if (!plist || !plist["CanonicalName"] || !plist["Version"]) + return false; + + var re = /^([0-9]+)\.([0-9]+)$/; + return plist["Version"].match(re); + } + + var plist = propertyList.toObject(); + if (!checkPlist(plist)) { + print("WARNING: Skipping corrupted SDK installation: " + + FileInfo.joinPaths(sdksPath, sdks[i])); + continue; + } + + sdkInfo.push(plist); + } finally { + propertyList.clear(); + } + } + + // Sort by SDK version number + sdkInfo.sort(function (a, b) { + var re = /^([0-9]+)\.([0-9]+)$/; + a = a["Version"].match(re); + if (a) + a = {major: a[1], minor: a[2]}; + b = b["Version"].match(re); + if (b) + b = {major: b[1], minor: b[2]}; + + if (a.major === b.major) + return a.minor - b.minor; + return a.major - b.major; + }); + + return sdkInfo; +} diff --git a/share/qbs/modules/xcode/xcode.qbs b/share/qbs/modules/xcode/xcode.qbs new file mode 100644 index 000000000..c363ff101 --- /dev/null +++ b/share/qbs/modules/xcode/xcode.qbs @@ -0,0 +1,148 @@ +import qbs +import qbs.File +import qbs.FileInfo +import qbs.DarwinTools +import qbs.ModUtils +import 'xcode.js' as Utils + +Module { + condition: qbs.hostOS.contains("darwin") && qbs.targetOS.contains("darwin") && + qbs.toolchain.contains("xcode") + + property path developerPath: "/Applications/Xcode.app/Contents/Developer" + property string sdk: DarwinTools.applePlatformName(qbs.targetOS) + + readonly property string sdkName: { + if (_sdkSettings) { + return _sdkSettings["CanonicalName"]; + } + } + + readonly property string sdkVersion: { + if (_sdkSettings) { + return _sdkSettings["Version"]; + } + } + + readonly property string latestSdkName: { + if (_availableSdks) { + return _availableSdks[_availableSdks.length - 1]["CanonicalName"]; + } + } + + readonly property string latestSdkVersion: { + if (_availableSdks) { + return _availableSdks[_availableSdks.length - 1]["Version"]; + } + } + + readonly property stringList availableSdkNames: { + if (_availableSdks) { + return _availableSdks.map(function (obj) { return obj["CanonicalName"]; }); + } + } + + readonly property stringList availableSdkVersions: { + if (_availableSdks) { + return _availableSdks.map(function (obj) { return obj["Version"]; }); + } + } + + readonly property path toolchainPath: FileInfo.joinPaths(toolchainsPath, + "XcodeDefault" + ".xctoolchain") + readonly property path platformPath: FileInfo.joinPaths(platformsPath, + Utils.applePlatformDirectoryName( + qbs.targetOS) + + ".platform") + readonly property path sdkPath: FileInfo.joinPaths(sdksPath, + Utils.applePlatformDirectoryName( + qbs.targetOS, sdkVersion) + + ".sdk") + + // private properties + readonly property path toolchainsPath: FileInfo.joinPaths(developerPath, "Toolchains") + readonly property path platformsPath: FileInfo.joinPaths(developerPath, "Platforms") + readonly property path sdksPath: FileInfo.joinPaths(platformPath, "Developer", "SDKs") + + readonly property path platformInfoPlist: FileInfo.joinPaths(platformPath, "Info.plist") + readonly property path sdkSettingsPlist: FileInfo.joinPaths(sdkPath, "SDKSettings.plist") + readonly property path toolchainInfoPlist: FileInfo.joinPaths(toolchainPath, + "ToolchainInfo.plist") + + readonly property var _availableSdks: Utils.sdkInfoList(sdksPath) + + readonly property var _sdkSettings: { + if (_availableSdks) { + for (var i in _availableSdks) { + if (_availableSdks[i]["Version"] === sdk) + return _availableSdks[i]; + if (_availableSdks[i]["CanonicalName"] === sdk) + return _availableSdks[i]; + } + + // Latest SDK available for the platform + if (DarwinTools.applePlatformName(qbs.targetOS) === sdk) + return _availableSdks[_availableSdks.length - 1]; + } + } + + readonly property pathList _availableProvisioningProfiles: { + var profiles = File.directoryEntries(provisioningProfilesPath, + File.Files | File.NoDotAndDotDot); + return profiles.map(function (s) { + return FileInfo.joinPaths(provisioningProfilesPath, s); + }).filter(function (s) { + return s.endsWith(".mobileprovision") || s.endsWith(".provisionprofile"); + }); + } + + qbs.sysroot: sdkPath + + validate: { + if (!_availableSdks) { + throw "There are no SDKs available for this platform in the Xcode installation."; + } + + if (!_sdkSettings) { + throw "There is no matching SDK available for ' + sdk + '."; + } + + var validator = new ModUtils.PropertyValidator("xcode"); + validator.setRequiredProperty("developerPath", developerPath); + validator.setRequiredProperty("sdk", sdk); + validator.setRequiredProperty("sdkName", sdkName); + validator.setRequiredProperty("sdkVersion", sdkVersion); + validator.setRequiredProperty("toolchainsPath", toolchainsPath); + validator.setRequiredProperty("toolchainPath", toolchainPath); + validator.setRequiredProperty("platformsPath", platformsPath); + validator.setRequiredProperty("platformPath", platformPath); + validator.setRequiredProperty("sdksPath", sdkPath); + validator.setRequiredProperty("sdkPath", sdkPath); + validator.addVersionValidator("sdkVersion", sdkVersion, 2, 2); + validator.addCustomValidator("sdkName", sdkName, function (value) { + return value === Utils.applePlatformDirectoryName( + qbs.targetOS, sdkVersion, false).toLowerCase(); + }, " is '" + sdkName + "', but target OS is [" + qbs.targetOS.join(",") + + "] and Xcode SDK version is '" + sdkVersion + "'"); + validator.validate(); + } + + property var buildEnv: { + return { + "DEVELOPER_DIR": developerPath + }; + } + + setupBuildEnvironment: { + var v = new ModUtils.EnvironmentVariable("PATH", qbs.pathListSeparator, false); + v.prepend(platformPath + "/Developer/usr/bin"); + v.prepend(developerPath + "/usr/bin"); + v.set(); + + for (var key in buildEnv) { + v = new ModUtils.EnvironmentVariable(key); + v.value = buildEnv[key]; + v.set(); + } + } +} |