From 4e442c034dcfee45c24a12d289894dbce09fdbc6 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 31 Mar 2016 17:27:20 -0700 Subject: Add a validate script to the bundle module. Also, adjust autotests to be more flexible. Some product types (for example, application extensions) may not exist in older versions of Xcode. This fixes the bundleStructure autotest. Change-Id: I2e73cd65f50f44017780001e9e0d5fb184edba31 Reviewed-by: Christian Kandeler --- share/qbs/modules/bundle/BundleModule.qbs | 67 ++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 6 deletions(-) (limited to 'share/qbs/modules/bundle/BundleModule.qbs') diff --git a/share/qbs/modules/bundle/BundleModule.qbs b/share/qbs/modules/bundle/BundleModule.qbs index 08c473356..6f45b07ed 100644 --- a/share/qbs/modules/bundle/BundleModule.qbs +++ b/share/qbs/modules/bundle/BundleModule.qbs @@ -70,11 +70,25 @@ Module { property var xcodeSettings: ({}) configure: { - if (xcodeDeveloperPath) { - var reader = new Bundle.XcodeBuildSpecsReader(xcodeDeveloperPath, - additionalSettings, - !qbs.targetOS.contains("osx")); - xcodeSettings = reader.expandedSettings(_productTypeIdentifier) || {}; + var specsPath = path; + var specsSeparator = "-"; + if (xcodeDeveloperPath && _useXcodeBuildSpecs) { + specsPath = xcodeDeveloperPath + + "/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications"; + specsSeparator = " "; + } + + var reader = new Bundle.XcodeBuildSpecsReader(specsPath, + specsSeparator, + additionalSettings, + !qbs.targetOS.contains("osx")); + var settings = reader.expandedSettings(_productTypeIdentifier); + if (settings) { + xcodeSettings = settings; + found = true; + } else { + xcodeSettings = {}; + found = false; } } } @@ -163,9 +177,11 @@ Module { readonly property string unlocalizedResourcesFolderPath: bundleSettingsProbe.xcodeSettings["UNLOCALIZED_RESOURCES_FOLDER_PATH"] readonly property string versionsFolderPath: bundleSettingsProbe.xcodeSettings["VERSIONS_FOLDER_PATH"] + // private properties property string _productTypeIdentifier: Bundle.productTypeIdentifier(product.type) - // private properties + property bool _useXcodeBuildSpecs: true // false to use ONLY the qbs build specs + readonly property var extraEnv: ({ "PRODUCT_BUNDLE_IDENTIFIER": identifier }) @@ -197,6 +213,45 @@ Module { }; } + validate: { + if (!bundleSettingsProbe.found) { + var error = "Bundle product type " + _productTypeIdentifier + " is not supported."; + if ((_productTypeIdentifier || "").startsWith("com.apple.product-type.")) + error += " You may need to upgrade Xcode."; + throw error; + } + + var validator = new ModUtils.PropertyValidator("bundle"); + validator.setRequiredProperty("bundleName", bundleName); + validator.setRequiredProperty("infoPlistPath", infoPlistPath); + validator.setRequiredProperty("pbdevelopmentPlistPath", pbdevelopmentPlistPath); + validator.setRequiredProperty("pkgInfoPath", pkgInfoPath); + validator.setRequiredProperty("versionPlistPath", versionPlistPath); + validator.setRequiredProperty("executablePath", executablePath); + validator.setRequiredProperty("contentsFolderPath", contentsFolderPath); + validator.setRequiredProperty("documentationFolderPath", documentationFolderPath); + validator.setRequiredProperty("executableFolderPath", executableFolderPath); + validator.setRequiredProperty("executablesFolderPath", executablesFolderPath); + validator.setRequiredProperty("frameworksFolderPath", frameworksFolderPath); + validator.setRequiredProperty("javaFolderPath", javaFolderPath); + validator.setRequiredProperty("localizedResourcesFolderPath", localizedResourcesFolderPath); + validator.setRequiredProperty("pluginsFolderPath", pluginsFolderPath); + validator.setRequiredProperty("privateHeadersFolderPath", privateHeadersFolderPath); + validator.setRequiredProperty("publicHeadersFolderPath", publicHeadersFolderPath); + validator.setRequiredProperty("scriptsFolderPath", scriptsFolderPath); + validator.setRequiredProperty("sharedFrameworksFolderPath", sharedFrameworksFolderPath); + validator.setRequiredProperty("sharedSupportFolderPath", sharedSupportFolderPath); + validator.setRequiredProperty("unlocalizedResourcesFolderPath", unlocalizedResourcesFolderPath); + + if (packageType === "FMWK") { + validator.setRequiredProperty("frameworkVersion", frameworkVersion); + validator.setRequiredProperty("versionsFolderPath", versionsFolderPath); + } + + // extension and infoStringsPath might not be set + return validator.validate(); + } + FileTagger { fileTags: ["infoplist"] patterns: ["Info.plist", "*-Info.plist"] -- cgit v1.2.3