diff options
author | Jake Petroules <jake.petroules@theqtcompany.com> | 2015-11-11 19:23:37 -0800 |
---|---|---|
committer | Jake Petroules <jake.petroules@theqtcompany.com> | 2015-11-27 10:26:08 +0000 |
commit | a08c71b90d7dc88fd4175bb64797a43254cc14d7 (patch) | |
tree | 667f75eb37e5e6f21f5295809ec8ee4482c1641e /share | |
parent | 8035c6a5babd0e41e54dc7bce06842978a34cbd9 (diff) |
Move global auxiliary functions into a new Utilities extension.
Change-Id: If0f12b9d28b83080f4435d91b55d70d5cff5d42e
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'share')
-rw-r--r-- | share/qbs/imports/qbs/DarwinTools/darwin-tools.js | 3 | ||||
-rw-r--r-- | share/qbs/imports/qbs/base/AutotestRunner.qbs | 3 | ||||
-rw-r--r-- | share/qbs/modules/Android/sdk/sdk.qbs | 3 | ||||
-rw-r--r-- | share/qbs/modules/bundle/BundleModule.qbs | 3 | ||||
-rwxr-xr-x | share/qbs/modules/cli/windows-dotnet.qbs | 5 | ||||
-rw-r--r-- | share/qbs/modules/cpp/CppModule.qbs | 5 | ||||
-rw-r--r-- | share/qbs/modules/cpp/GenericGCC.qbs | 5 | ||||
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 3 | ||||
-rw-r--r-- | share/qbs/modules/cpp/windows-mingw.qbs | 3 | ||||
-rw-r--r-- | share/qbs/modules/cpp/windows-msvc.qbs | 11 | ||||
-rw-r--r-- | share/qbs/modules/java/utils.js | 9 | ||||
-rw-r--r-- | share/qbs/modules/nsis/NSISModule.qbs | 13 | ||||
-rw-r--r-- | share/qbs/modules/qbs/common.qbs | 19 | ||||
-rw-r--r-- | share/qbs/modules/wix/WiXModule.qbs | 13 |
14 files changed, 56 insertions, 42 deletions
diff --git a/share/qbs/imports/qbs/DarwinTools/darwin-tools.js b/share/qbs/imports/qbs/DarwinTools/darwin-tools.js index 056b54af6..670ca8181 100644 --- a/share/qbs/imports/qbs/DarwinTools/darwin-tools.js +++ b/share/qbs/imports/qbs/DarwinTools/darwin-tools.js @@ -29,6 +29,7 @@ ****************************************************************************/ var FileInfo = loadExtension("qbs.FileInfo"); +var Utilities = loadExtension("qbs.Utilities"); /** * Returns the numeric identifier corresponding to an Apple device name @@ -193,7 +194,7 @@ function expandPlistEnvironmentVariables(obj, env, warn) { if (varFormatter !== undefined) varFormatter = varFormatter.toLowerCase(); if (varFormatter === "rfc1034identifier") - varValue = qbs.rfc1034Identifier(varValue); + varValue = Utilities.rfc1034Identifier(varValue); value = value.slice(0, i) + varValue + value.slice(j + repl.syntax.close.length); // avoid recursive substitutions to avoid potentially infinite loops i += varValue.length; diff --git a/share/qbs/imports/qbs/base/AutotestRunner.qbs b/share/qbs/imports/qbs/base/AutotestRunner.qbs index b939b8b8b..67c5524a5 100644 --- a/share/qbs/imports/qbs/base/AutotestRunner.qbs +++ b/share/qbs/imports/qbs/base/AutotestRunner.qbs @@ -30,6 +30,7 @@ import qbs import qbs.ModUtils +import qbs.Utilities Product { name: "autotest-runner" @@ -46,7 +47,7 @@ Product { Rule { inputsFromDependencies: "application" Artifact { - filePath: qbs.getHash(input.filePath) + ".result.dummy" // Will never exist. + filePath: Utilities.getHash(input.filePath) + ".result.dummy" // Will never exist. fileTags: "autotest-result" alwaysUpdated: false } diff --git a/share/qbs/modules/Android/sdk/sdk.qbs b/share/qbs/modules/Android/sdk/sdk.qbs index 41cbb474e..9ce60fb35 100644 --- a/share/qbs/modules/Android/sdk/sdk.qbs +++ b/share/qbs/modules/Android/sdk/sdk.qbs @@ -34,6 +34,7 @@ import qbs.FileInfo import qbs.ModUtils import qbs.Probes import qbs.TextFile +import qbs.Utilities import "utils.js" as SdkUtils Module { @@ -107,7 +108,7 @@ Module { Rule { inputs: ["android.aidl"] Artifact { - filePath: FileInfo.joinPaths(qbs.getHash(input.filePath), + filePath: FileInfo.joinPaths(Utilities.getHash(input.filePath), input.completeBaseName + ".java") fileTags: ["java.java"] } diff --git a/share/qbs/modules/bundle/BundleModule.qbs b/share/qbs/modules/bundle/BundleModule.qbs index 5f7b3dfac..8ec0e8458 100644 --- a/share/qbs/modules/bundle/BundleModule.qbs +++ b/share/qbs/modules/bundle/BundleModule.qbs @@ -36,6 +36,7 @@ import qbs.FileInfo import qbs.ModUtils import qbs.PropertyList import qbs.TextFile +import qbs.Utilities Module { additionalProductTypes: ["bundle"] @@ -48,7 +49,7 @@ Module { property bool isShallow: !qbs.targetOS.contains("osx") && product.type.contains("application") property string identifierPrefix: "org.example" - property string identifier: [identifierPrefix, qbs.rfc1034Identifier(product.targetName)].join(".") + property string identifier: [identifierPrefix, Utilities.rfc1034Identifier(product.targetName)].join(".") property string extension: { if (packageType === undefined) { diff --git a/share/qbs/modules/cli/windows-dotnet.qbs b/share/qbs/modules/cli/windows-dotnet.qbs index b437e1276..a51eb4c40 100755 --- a/share/qbs/modules/cli/windows-dotnet.qbs +++ b/share/qbs/modules/cli/windows-dotnet.qbs @@ -1,4 +1,5 @@ import qbs +import qbs.Utilities CLIModule { condition: qbs.toolchain.contains("dotnet") @@ -8,7 +9,7 @@ CLIModule { vbCompilerName: "vbc" fsharpCompilerName: "fsc" - toolchainInstallPath: qbs.getNativeSetting(registryKey, "InstallPath") + toolchainInstallPath: Utilities.getNativeSetting(registryKey, "InstallPath") // private properties property string registryKey: { @@ -21,7 +22,7 @@ CLIModule { ]; for (var i in keys) { var key = keys[i] + "\\v4\\Full"; - if (qbs.getNativeSetting(key, "InstallPath")) + if (Utilities.getNativeSetting(key, "InstallPath")) return key; } } diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs index 294590154..f24681b08 100644 --- a/share/qbs/modules/cpp/CppModule.qbs +++ b/share/qbs/modules/cpp/CppModule.qbs @@ -30,6 +30,7 @@ // base for Cpp modules import qbs.ModUtils +import qbs.Utilities Module { condition: false @@ -315,9 +316,9 @@ Module { validate: { var validator = new ModUtils.PropertyValidator("cpp"); validator.addCustomValidator("architecture", architecture, function (value) { - return !architecture || architecture === canonicalArchitecture(architecture); + return !architecture || architecture === Utilities.canonicalArchitecture(architecture); }, "'" + architecture + "' is invalid. You must use the canonical name '" + - canonicalArchitecture(architecture) + "'"); + Utilities.canonicalArchitecture(architecture) + "'"); validator.validate(); } diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs index 0628be578..ae8c5b29d 100644 --- a/share/qbs/modules/cpp/GenericGCC.qbs +++ b/share/qbs/modules/cpp/GenericGCC.qbs @@ -34,6 +34,7 @@ import qbs.FileInfo import qbs.ModUtils import qbs.PathTools import qbs.Process +import qbs.Utilities import qbs.UnixUtils import qbs.WindowsUtils import 'gcc.js' as Gcc @@ -342,7 +343,7 @@ CppModule { Artifact { fileTags: ["obj"] - filePath: FileInfo.joinPaths(".obj", qbs.getHash(input.baseDir), input.fileName + ".o") + filePath: FileInfo.joinPaths(".obj", Utilities.getHash(input.baseDir), input.fileName + ".o") } prepare: { @@ -356,7 +357,7 @@ CppModule { Artifact { fileTags: ["obj"] - filePath: FileInfo.joinPaths(".obj", qbs.getHash(input.baseDir), input.fileName + ".o") + filePath: FileInfo.joinPaths(".obj", Utilities.getHash(input.baseDir), input.fileName + ".o") } prepare: { diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index 6ba260921..ac4d204e4 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -35,6 +35,7 @@ var ModUtils = loadExtension("qbs.ModUtils"); var PathTools = loadExtension("qbs.PathTools"); var Process = loadExtension("qbs.Process"); var UnixUtils = loadExtension("qbs.UnixUtils"); +var Utilities = loadExtension("qbs.Utilities"); var WindowsUtils = loadExtension("qbs.WindowsUtils"); function escapeLinkerFlags(product, linkerFlags) { @@ -396,7 +397,7 @@ function compilerFlags(product, input, output) { var toolchain = product.moduleProperty("qbs", "toolchain"); if (!toolchain.contains("clang")) { var hashString = FileInfo.relativePath(project.sourceDirectory, input.filePath); - var hash = qbs.getHash(hashString); + var hash = Utilities.getHash(hashString); args.push("-frandom-seed=0x" + hash.substring(0, 8)); } diff --git a/share/qbs/modules/cpp/windows-mingw.qbs b/share/qbs/modules/cpp/windows-mingw.qbs index 10f360c38..e6478eaec 100644 --- a/share/qbs/modules/cpp/windows-mingw.qbs +++ b/share/qbs/modules/cpp/windows-mingw.qbs @@ -30,6 +30,7 @@ import qbs 1.0 import qbs.ModUtils +import qbs.Utilities import qbs.WindowsUtils GenericGCC { @@ -70,7 +71,7 @@ GenericGCC { auxiliaryInputs: ["hpp"] Artifact { - filePath: ".obj/" + qbs.getHash(input.baseDir) + "/" + input.completeBaseName + "_res.o" + filePath: ".obj/" + Utilities.getHash(input.baseDir) + "/" + input.completeBaseName + "_res.o" fileTags: ["obj"] } diff --git a/share/qbs/modules/cpp/windows-msvc.qbs b/share/qbs/modules/cpp/windows-msvc.qbs index f5dd19d5d..6b5c581cf 100644 --- a/share/qbs/modules/cpp/windows-msvc.qbs +++ b/share/qbs/modules/cpp/windows-msvc.qbs @@ -33,6 +33,7 @@ import qbs.File import qbs.FileInfo import qbs.ModUtils import qbs.PathTools +import qbs.Utilities import qbs.WindowsUtils import 'msvc.js' as MSVC @@ -98,7 +99,7 @@ CppModule { filePath: { var completeBaseName = FileInfo.completeBaseName(product.moduleProperty("cpp", "cPrecompiledHeader")); - return ".obj/" + qbs.getHash(completeBaseName) + '_c.obj' + return ".obj/" + Utilities.getHash(completeBaseName) + '_c.obj' } } Artifact { @@ -119,7 +120,7 @@ CppModule { filePath: { var completeBaseName = FileInfo.completeBaseName(product.moduleProperty("cpp", "cxxPrecompiledHeader")); - return ".obj/" + qbs.getHash(completeBaseName) + '_cpp.obj' + return ".obj/" + Utilities.getHash(completeBaseName) + '_cpp.obj' } } Artifact { @@ -139,7 +140,7 @@ CppModule { Artifact { fileTags: ['obj'] - filePath: ".obj/" + qbs.getHash(input.baseDir) + "/" + input.fileName + ".obj" + filePath: ".obj/" + Utilities.getHash(input.baseDir) + "/" + input.fileName + ".obj" } prepare: { @@ -262,7 +263,7 @@ CppModule { auxiliaryInputs: ["hpp"] Artifact { - filePath: ".obj/" + qbs.getHash(input.baseDir) + "/" + input.completeBaseName + ".res" + filePath: ".obj/" + Utilities.getHash(input.baseDir) + "/" + input.completeBaseName + ".res" fileTags: ["obj"] } @@ -321,7 +322,7 @@ CppModule { Rule { inputs: ["asm"] Artifact { - filePath: ".obj/" + qbs.getHash(input.baseDir) + "/" + input.completeBaseName + ".obj" + filePath: ".obj/" + Utilities.getHash(input.baseDir) + "/" + input.completeBaseName + ".obj" fileTags: ["obj"] } prepare: { diff --git a/share/qbs/modules/java/utils.js b/share/qbs/modules/java/utils.js index 34ee80897..c1104a138 100644 --- a/share/qbs/modules/java/utils.js +++ b/share/qbs/modules/java/utils.js @@ -33,13 +33,14 @@ var FileInfo = loadExtension("qbs.FileInfo"); var ModUtils = loadExtension("qbs.ModUtils"); var Process = loadExtension("qbs.Process"); var TextFile = loadExtension("qbs.TextFile"); +var Utilities = loadExtension("qbs.Utilities"); var WindowsUtils = loadExtension("qbs.WindowsUtils"); function is64bitProcess() { var y = jdkRootRegistryKey(true); var n = jdkRootRegistryKey(false); - y = qbs.getNativeSetting(y + "\\" + qbs.getNativeSetting(y, "CurrentVersion"), "JavaHome"); - n = qbs.getNativeSetting(n + "\\" + qbs.getNativeSetting(n, "CurrentVersion"), "JavaHome"); + y = Utilities.getNativeSetting(y + "\\" + Utilities.getNativeSetting(y, "CurrentVersion"), "JavaHome"); + n = Utilities.getNativeSetting(n + "\\" + Utilities.getNativeSetting(n, "CurrentVersion"), "JavaHome"); return y !== n; } @@ -82,9 +83,9 @@ function findJdkPath(hostOS, arch, environmentPaths, searchPaths) { if (hostOS.contains("windows")) { var rootKey = jdkRootRegistryKey(useWow64Key(arch)); if (rootKey) { - var current = qbs.getNativeSetting(rootKey, "CurrentVersion"); // 1.8 etc. + var current = Utilities.getNativeSetting(rootKey, "CurrentVersion"); // 1.8 etc. if (current) { - var home = qbs.getNativeSetting([rootKey, current].join("\\"), "JavaHome"); + var home = Utilities.getNativeSetting([rootKey, current].join("\\"), "JavaHome"); if (home) { return home; } diff --git a/share/qbs/modules/nsis/NSISModule.qbs b/share/qbs/modules/nsis/NSISModule.qbs index 5930a4dec..50d2c06d5 100644 --- a/share/qbs/modules/nsis/NSISModule.qbs +++ b/share/qbs/modules/nsis/NSISModule.qbs @@ -32,18 +32,19 @@ import qbs 1.0 import qbs.File import qbs.FileInfo import qbs.ModUtils +import qbs.Utilities Module { condition: qbs.targetOS.contains("windows") - property path toolchainInstallPath: qbs.getNativeSetting(registryKey) + property path toolchainInstallPath: Utilities.getNativeSetting(registryKey) property string version: (versionMajor !== undefined && versionMinor !== undefined) ? (versionMajor + "." + versionMinor) : undefined property var versionParts: [ versionMajor, versionMinor, versionPatch, versionBuild ] - property int versionMajor: qbs.getNativeSetting(registryKey, "VersionMajor") - property int versionMinor: qbs.getNativeSetting(registryKey, "VersionMinor") - property int versionPatch: qbs.getNativeSetting(registryKey, "VersionBuild") - property int versionBuild: qbs.getNativeSetting(registryKey, "VersionRevision") + property int versionMajor: Utilities.getNativeSetting(registryKey, "VersionMajor") + property int versionMinor: Utilities.getNativeSetting(registryKey, "VersionMinor") + property int versionPatch: Utilities.getNativeSetting(registryKey, "VersionBuild") + property int versionBuild: Utilities.getNativeSetting(registryKey, "VersionRevision") property string compilerName: "makensis" property string compilerPath: compilerName @@ -94,7 +95,7 @@ Module { var keys = [ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS" ]; for (var i in keys) { - if (qbs.getNativeSetting(keys[i])) + if (Utilities.getNativeSetting(keys[i])) return keys[i]; } } diff --git a/share/qbs/modules/qbs/common.qbs b/share/qbs/modules/qbs/common.qbs index ff57f7d53..733a3096f 100644 --- a/share/qbs/modules/qbs/common.qbs +++ b/share/qbs/modules/qbs/common.qbs @@ -32,6 +32,7 @@ import qbs 1.0 import qbs.FileInfo import qbs.ModUtils import qbs.PathTools +import qbs.Utilities Module { property string buildVariant: "debug" @@ -41,20 +42,20 @@ Module { readonly property stringList hostOS: undefined // set internally property string hostOSVersion: { if (hostOS && hostOS.contains("osx")) { - return getNativeSetting("/System/Library/CoreServices/ServerVersion.plist", "ProductVersion") || - getNativeSetting("/System/Library/CoreServices/SystemVersion.plist", "ProductVersion"); + return Utilities.getNativeSetting("/System/Library/CoreServices/ServerVersion.plist", "ProductVersion") || + Utilities.getNativeSetting("/System/Library/CoreServices/SystemVersion.plist", "ProductVersion"); } else if (hostOS && hostOS.contains("windows")) { - var version = getNativeSetting(windowsRegistryKey, "CurrentVersion"); + var version = Utilities.getNativeSetting(windowsRegistryKey, "CurrentVersion"); return version + "." + hostOSBuildVersion; } } property string hostOSBuildVersion: { if (hostOS.contains("osx")) { - return getNativeSetting("/System/Library/CoreServices/ServerVersion.plist", "ProductBuildVersion") || - getNativeSetting("/System/Library/CoreServices/SystemVersion.plist", "ProductBuildVersion"); + return Utilities.getNativeSetting("/System/Library/CoreServices/ServerVersion.plist", "ProductBuildVersion") || + Utilities.getNativeSetting("/System/Library/CoreServices/SystemVersion.plist", "ProductBuildVersion"); } else if (hostOS.contains("windows")) { - return getNativeSetting(windowsRegistryKey, "CurrentBuildNumber"); + return Utilities.getNativeSetting(windowsRegistryKey, "CurrentBuildNumber"); } } @@ -109,16 +110,16 @@ Module { } validator.addCustomValidator("architecture", architecture, function (value) { - return !architecture || architecture === canonicalArchitecture(architecture); + return !architecture || architecture === Utilities.canonicalArchitecture(architecture); }, "'" + architecture + "' is invalid. You must use the canonical name '" + - canonicalArchitecture(architecture) + "'"); + Utilities.canonicalArchitecture(architecture) + "'"); validator.validate(); } // private properties property string windowsRegistryKey: "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion" - property path windowsSystemRoot: FileInfo.fromWindowsSeparators(getNativeSetting(windowsRegistryKey, "SystemRoot")) + property path windowsSystemRoot: FileInfo.fromWindowsSeparators(Utilities.getNativeSetting(windowsRegistryKey, "SystemRoot")) property path windowsShellPath: FileInfo.fromWindowsSeparators(getEnv("COMSPEC")) || FileInfo.joinPaths(windowsSystemRoot, "System32", "cmd.exe") property var commonRunEnvironment: { diff --git a/share/qbs/modules/wix/WiXModule.qbs b/share/qbs/modules/wix/WiXModule.qbs index e48af0a2e..568a57f64 100644 --- a/share/qbs/modules/wix/WiXModule.qbs +++ b/share/qbs/modules/wix/WiXModule.qbs @@ -32,13 +32,14 @@ import qbs import qbs.File import qbs.FileInfo import qbs.ModUtils +import qbs.Utilities Module { condition: qbs.targetOS.contains("windows") - property path toolchainInstallPath: qbs.getNativeSetting(registryKey, "InstallFolder") - property path toolchainInstallRoot: qbs.getNativeSetting(registryKey, "InstallRoot") - property string version: qbs.getNativeSetting(registryKey, "ProductVersion") + property path toolchainInstallPath: Utilities.getNativeSetting(registryKey, "InstallFolder") + property path toolchainInstallRoot: Utilities.getNativeSetting(registryKey, "InstallRoot") + property string version: Utilities.getNativeSetting(registryKey, "ProductVersion") property var versionParts: version ? version.split('.').map(function(item) { return parseInt(item, 10); }) : [] property int versionMajor: versionParts[0] property int versionMinor: versionParts[1] @@ -130,9 +131,9 @@ Module { var keyWoW64 = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Installer XML\\"; for (i in knownVersions) { - if (qbs.getNativeSetting(keyNative + knownVersions[i], "ProductVersion")) + if (Utilities.getNativeSetting(keyNative + knownVersions[i], "ProductVersion")) return keyNative + knownVersions[i]; - if (qbs.getNativeSetting(keyWoW64 + knownVersions[i], "ProductVersion")) + if (Utilities.getNativeSetting(keyWoW64 + knownVersions[i], "ProductVersion")) return keyWoW64 + knownVersions[i]; } } @@ -186,7 +187,7 @@ Module { Artifact { fileTags: ["wixobj"] - filePath: FileInfo.joinPaths(".obj", qbs.getHash(input.baseDir), + filePath: FileInfo.joinPaths(".obj", Utilities.getHash(input.baseDir), FileInfo.baseName(input.fileName) + ".wixobj") } |