diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2013-02-20 12:17:27 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-02-20 18:06:10 +0100 |
commit | ff9ea2eef48f0f3f593df27f449159fcc177045d (patch) | |
tree | ca1db9bcab4e199b1f57111d30748fb59dc4315a /share | |
parent | b723fb1247019b9b22b520bfcae217399bfee1b2 (diff) |
Move property look-up into the C++ backend.
Instead of exporting the complete property VariantMap of
products and artifacts to JavaScript and finding the
property values there, we introduce functions that do this
in C++ and just export their functionality.
This functionality will also be made available in the API.
Change-Id: I6b8631e78b74db563403caa47ae10021ca152fa0
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'share')
-rw-r--r-- | share/qbs/modules/cpp/GenericGCC.qbs | 68 | ||||
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 38 | ||||
-rw-r--r-- | share/qbs/modules/cpp/mac-gcc.qbs | 4 | ||||
-rw-r--r-- | share/qbs/modules/cpp/msvc.js | 32 | ||||
-rw-r--r-- | share/qbs/modules/cpp/windows-mingw.qbs | 2 | ||||
-rw-r--r-- | share/qbs/modules/cpp/windows-msvc.qbs | 23 | ||||
-rw-r--r-- | share/qbs/modules/qt/core/moc.js | 4 | ||||
-rw-r--r-- | share/qbs/modules/qt/core/qtcore.qbs | 15 | ||||
-rw-r--r-- | share/qbs/modules/qt/gui/qtgui.qbs | 4 | ||||
-rw-r--r-- | share/qbs/modules/utils.js | 62 |
10 files changed, 113 insertions, 139 deletions
diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs index 4ad80480d..81fb28ec4 100644 --- a/share/qbs/modules/cpp/GenericGCC.qbs +++ b/share/qbs/modules/cpp/GenericGCC.qbs @@ -35,7 +35,9 @@ CppModule { usings: ['dynamiclibrary', 'staticlibrary'] Artifact { - fileName: product.destinationDirectory + "/" + product.module.dynamicLibraryPrefix + product.targetName + product.module.dynamicLibrarySuffix + fileName: product.destinationDirectory + "/" + + ModUtils.findFirst(product, "dynamicLibraryPrefix") + product.targetName + + ModUtils.findFirst(product, "dynamicLibrarySuffix") fileTags: ["dynamiclibrary"] cpp.transitiveSOs: { var result = [] @@ -60,7 +62,7 @@ CppModule { var i; var args = Gcc.configFlags(product); args.push('-shared'); - if (product.modules.qbs.targetOS === 'linux') + if (product.moduleProperty("qbs", "targetOS") === 'linux') args = args.concat([ '-Wl,--hash-style=gnu', '-Wl,--as-needed', @@ -72,8 +74,9 @@ CppModule { args.push(linkerFlags[i]) for (i in inputs.obj) args.push(inputs.obj[i].fileName); - if (product.module.sysroot) - args.push('--sysroot=' + product.module.sysroot) + var sysroot = ModUtils.findFirst(product, "sysroot") + if (sysroot) + args.push('--sysroot=' + sysroot) var staticLibrariesI = []; for (i in inputs.staticlibrary) { staticLibrariesI.push(inputs.staticlibrary[i].fileName); @@ -85,8 +88,8 @@ CppModule { fileName = inputs.framework[i].fileName; frameworkPaths.push(FileInfo.path(fileName)); fileName = Gcc.removePrefixAndSuffix(FileInfo.fileName(fileName), - product.module.dynamicLibraryPrefix, - product.module.dynamicLibrarySuffix); + ModUtils.findFirst(product, "dynamicLibraryPrefix"), + ModUtils.findFirst(product, "dynamicLibrarySuffix")); frameworksI.push(fileName); } @@ -95,7 +98,7 @@ CppModule { args = args.concat(Gcc.libs(libraryPaths, frameworkPaths, rpaths, dynamicLibraries, staticLibrariesI, frameworksI)); for (i in inputs.dynamiclibrary) args.push(inputs.dynamiclibrary[i].fileName); - var cmd = new Command(product.module.compilerPath, args); + var cmd = new Command(ModUtils.findFirst(product, "compilerPath"), args); cmd.description = 'linking ' + FileInfo.fileName(output.fileName); cmd.highlight = 'linker'; return cmd; @@ -109,7 +112,8 @@ CppModule { usings: ['dynamiclibrary', 'staticlibrary'] Artifact { - fileName: product.destinationDirectory + "/" + product.module.staticLibraryPrefix + product.targetName + product.module.staticLibrarySuffix + fileName: product.destinationDirectory + "/" + ModUtils.findFirst(product, "staticLibraryPrefix") + + product.targetName + ModUtils.findFirst(product, "staticLibrarySuffix") fileTags: ["staticlibrary"] cpp.staticLibraries: { var result = [] @@ -137,7 +141,7 @@ CppModule { var args = ['rcs', output.fileName]; for (var i in inputs.obj) args.push(inputs.obj[i].fileName); - var cmd = new Command(product.module.archiverPath, args); + var cmd = new Command(ModUtils.findFirst(product, "archiverPath"), args); cmd.description = 'creating ' + FileInfo.fileName(output.fileName); cmd.highlight = 'linker' return cmd; @@ -151,7 +155,8 @@ CppModule { usings: ['dynamiclibrary', 'staticlibrary'] Artifact { - fileName: product.destinationDirectory + "/" + product.module.executablePrefix + product.targetName + product.module.executableSuffix + fileName: product.destinationDirectory + "/" + ModUtils.findFirst(product, "executablePrefix") + + product.targetName + ModUtils.findFirst(product, "executableSuffix") fileTags: ["application"] } @@ -166,11 +171,13 @@ CppModule { var args = Gcc.configFlags(product); for (var i in inputs.obj) args.push(inputs.obj[i].fileName) - if (product.module.sysroot) - args.push('--sysroot=' + product.module.sysroot) + var sysroot = ModUtils.findFirst(product, "sysroot") + if (sysroot) + args.push('--sysroot=' + sysroot) for (i in linkerFlags) args.push(linkerFlags[i]) - if (product.consoleApplication !== undefined && product.modules.qbs.toolchain === "mingw") { + if (product.consoleApplication !== undefined + && product.moduleProperty("qbs", "toolchain") === "mingw") { if (product.consoleApplication) args.push("-Wl,-subsystem,console"); else @@ -186,13 +193,14 @@ CppModule { staticLibrariesI = staticLibrariesI.concat(staticLibraries); var dynamicLibrariesI = []; + var dllPrefix = ModUtils.findFirst(product, "dynamicLibraryPrefix") + var dllSuffix = ModUtils.findFirst(product, "dynamicLibrarySuffix") for (i in dynamicLibraries) { - if (dynamicLibraries[i].match("^" + product.module.dynamicLibraryPrefix + ".*\\" + product.module.dynamicLibrarySuffix + "$") !== null) { + if (dynamicLibraries[i].match("^" + dllPrefix + ".*\\" + dllSuffix + "$") !== null) { // shared object filename found var libDir = FileInfo.path(dynamicLibraries[i]) var libName = FileInfo.fileName(dynamicLibraries[i]) - libName = Gcc.removePrefixAndSuffix(libName, product.module.dynamicLibraryPrefix, - product.module.dynamicLibrarySuffix); + libName = Gcc.removePrefixAndSuffix(libName, dllPrefix, dllSuffix); libraryPaths.push(libDir) dynamicLibrariesI.push(libName) } else { @@ -201,7 +209,7 @@ CppModule { } } - if (product.modules.qbs.targetOS === 'linux') { + if (product.moduleProperty("qbs", "targetOS") === 'linux') { var transitiveSOs = ModUtils.appendAllFromArtifacts(product, inputs.dynamiclibrary, 'cpp', 'transitiveSOs') for (i in transitiveSOs) { args.push("-Wl,-rpath-link=" + FileInfo.path(transitiveSOs[i])) @@ -212,16 +220,14 @@ CppModule { for (i in inputs.framework) { fileName = inputs.framework[i].fileName; frameworkPaths.push(FileInfo.path(fileName)); - fileName = Gcc.removePrefixAndSuffix(FileInfo.fileName(fileName), - product.module.dynamicLibraryPrefix, - product.module.dynamicLibrarySuffix); + fileName = Gcc.removePrefixAndSuffix(FileInfo.fileName(fileName), dllPrefix, dllSuffix); frameworksI.push(fileName); } args = args.concat(Gcc.libs(libraryPaths, frameworkPaths, rpaths, dynamicLibrariesI, staticLibrariesI, frameworksI)); for (i in inputs.dynamiclibrary) args.push(inputs.dynamiclibrary[i].fileName); - var cmd = new Command(product.module.compilerPath, args); + var cmd = new Command(ModUtils.findFirst(product, "compilerPath"), args); cmd.description = 'linking ' + FileInfo.fileName(output.fileName); cmd.highlight = 'linker' return cmd; @@ -246,14 +252,15 @@ CppModule { var cFlags = ModUtils.appendAll(input, 'cFlags'); var cxxFlags = ModUtils.appendAll(input, 'cxxFlags'); var objcFlags = ModUtils.appendAll(input, 'objcFlags'); - var visibility = ModUtils.findFirst(product.modules, 'cpp', 'visibility'); + var visibility = ModUtils.findFirst(product, 'visibility'); var args = Gcc.configFlags(input); var isCxx = true; var isObjC = false; args.push('-pipe'); - if (product.type.indexOf('staticlibrary') === -1 && (product.modules.qbs.toolchain !== "mingw")) { + if (product.type.indexOf('staticlibrary') === -1 + && product.moduleProperty("qbs", "toolchain") !== "mingw") { if (visibility === 'hidden') args.push('-fvisibility=hidden'); if (visibility === 'hiddenInlines') @@ -262,10 +269,10 @@ CppModule { args.push('-fvisibility=default') } - if (product.module.precompiledHeader) { + if (ModUtils.findFirst(product, "precompiledHeader")) { args.push('-include') args.push(product.name) - var pchPath = product.module.precompiledHeaderDir + var pchPath = ModUtils.findFirst(product, "precompiledHeaderDir") var pchPathIncluded = false for (var i in includePaths) { if (includePaths[i] == pchPath) { @@ -303,7 +310,7 @@ CppModule { args = args.concat(cFlags); } args = args.concat(Gcc.additionalFlags(product, includePaths, frameworkPaths, systemIncludePaths, input.fileName, output)) - var cmd = new Command(product.module.compilerPath, args); + var cmd = new Command(ModUtils.findFirst(product, "compilerPath"), args); cmd.description = 'compiling ' + FileInfo.fileName(input.fileName); cmd.highlight = "compiler"; return cmd; @@ -324,11 +331,12 @@ CppModule { var systemIncludePaths = ModUtils.appendAll(input, 'systemIncludePaths'); args.push('-x'); args.push('c++-header'); - if (product.module.cxxFlags) - args = args.concat(product.module.cxxFlags); + var cxxFlags = ModUtils.findFirst(product, "cxxFlags") + if (cxxFlags) + args = args.concat(cxxFlags); args = args.concat(Gcc.additionalFlags(product, includePaths, frameworkPaths, systemIncludePaths, - product.module.precompiledHeader, output)); - var cmd = new Command(product.module.compilerPath, args); + ModUtils.findFirst(product, "precompiledHeader"), output)); + var cmd = new Command(ModUtils.findFirst(product, "compilerPath"), args); cmd.description = 'precompiling ' + FileInfo.fileName(input.fileName); return cmd; } diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index e558b9e62..d33f93ac3 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -30,26 +30,29 @@ function libs(libraryPaths, frameworkPaths, rpaths, dynamicLibraries, staticLibr function configFlags(config) { var args = []; - // architecture - if (config.module.architecture === 'x86_64') + + var arch = ModUtils.findFirst(config, "architecture") + if (arch === 'x86_64') args.push('-m64'); - else if (config.module.architecture === 'x86') + else if (arch === 'x86') args.push('-m32'); - // optimization: - if (config.module.debugInformation) + + if (ModUtils.findFirst/config, "debugInformation") args.push('-g'); - if (config.module.optimization === 'fast') + var opt = ModUtils.findFirst(config, "optimization") + if (opt === 'fast') args.push('-O2'); - if (config.module.optimization === 'small') + if (opt === 'small') args.push('-Os'); - // warnings: - if (config.module.warningLevel === 'none') + + var warnings = ModUtils.findFirst(config, "warningLevel") + if (warnings === 'none') args.push('-w'); - if (config.module.warningLevel === 'all') { + if (warnings === 'all') { args.push('-Wall'); args.push('-Wextra'); } - if (config.module.treatWarningsAsErrors) + if (ModUtils.findFirst(config, "treatWarningsAsErrors")) args.push('-Werror'); return args; @@ -66,24 +69,25 @@ function additionalFlags(product, includePaths, frameworkPaths, systemIncludePat { var args = [] if (product.type.indexOf('staticlibrary') >= 0 || product.type.indexOf('dynamiclibrary') >= 0) { - if (product.modules.qbs.toolchain !== "mingw") + if (product.moduleProperty("qbs", "toolchain") !== "mingw") args.push('-fPIC'); } else if (product.type.indexOf('application') >= 0) { - var positionIndependentCode = ModUtils.findFirst(product.modules, 'cpp', 'positionIndependentCode') - if (positionIndependentCode && product.modules.qbs.toolchain !== "mingw") + var positionIndependentCode = product.moduleProperty('cpp', 'positionIndependentCode') + if (positionIndependentCode && product.moduleProperty("qbs", "toolchain") !== "mingw") args.push('-fPIE'); } else { throw ("The product's type must be in {staticlibrary, dynamiclibrary, application}. But it is " + product.type + '.'); } - if (product.module.sysroot) - args.push('--sysroot=' + product.module.sysroot) + var sysroot = ModUtils.findFirst(product, "sysroot") + if (sysroot) + args.push('--sysroot=' + sysroot) var i; var cppFlags = ModUtils.appendAll(input, 'cppFlags'); for (i in cppFlags) args.push('-Wp,' + cppFlags[i]) var platformDefines = ModUtils.appendAll(input, 'platformDefines'); for (i in platformDefines) - args.push('-D' + product.module.platformDefines[i]); + args.push('-D' + platformDefines[i]); var defines = ModUtils.appendAll(input, 'defines'); for (i in defines) args.push('-D' + defines[i]); diff --git a/share/qbs/modules/cpp/mac-gcc.qbs b/share/qbs/modules/cpp/mac-gcc.qbs index 479e7dd27..26a6262e3 100644 --- a/share/qbs/modules/cpp/mac-gcc.qbs +++ b/share/qbs/modules/cpp/mac-gcc.qbs @@ -22,7 +22,7 @@ UnixGCC { var cmd = new JavaScriptCommand(); cmd.description = "generating Info.plist"; cmd.highlight = "codegen"; - cmd.infoPlist = product.module.infoPlist || {}; + cmd.infoPlist = ModUtils.findFirst(product, "infoPlist") || {}; cmd.sourceCode = function() { var infoplist = new TextFile(outputs.infoplist[0].fileName, TextFile.WriteOnly); infoplist.writeLine('<?xml version="1.0" encoding="UTF-8"?>'); @@ -78,7 +78,7 @@ UnixGCC { var cmd = new JavaScriptCommand(); cmd.description = "generating PkgInfo"; cmd.highlight = "codegen"; - cmd.pkgInfo = product.module.pkgInfo || "FOO"; + cmd.pkgInfo = ModUtils.findFirst(product, "pkgInfo") || "FOO"; cmd.sourceCode = function() { var pkginfo = new TextFile(outputs.pkginfo[0].fileName, TextFile.WriteOnly); pkginfo.write(pkgInfo); diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js index 1368b6047..a32694fe9 100644 --- a/share/qbs/modules/cpp/msvc.js +++ b/share/qbs/modules/cpp/msvc.js @@ -1,9 +1,9 @@ function prepareCompiler(product, input, outputs, platformDefines, defines, includePaths, systemIncludePaths, cFlags, cxxFlags) { var i; - var optimization = input.module.optimization - var debugInformation = input.module.debugInformation - var architecture = input.module.architecture + var optimization = ModUtils.findFirst(input, "optimization") + var debugInformation = ModUtils.findFirst(input, "debugInformation") + var architecture = ModUtils.findFirst(input, "architecture") var args = ['/nologo', '/c'] @@ -28,12 +28,12 @@ function prepareCompiler(product, input, outputs, platformDefines, defines, incl args.push('/MD') } // warnings: - var warningLevel = input.module.warningLevel + var warningLevel = ModUtils.findFirst(input, "warningLevel") if (warningLevel === 'none') args.push('/w') if (warningLevel === 'all') args.push('/Wall') - if (input.module.treatWarningsAsErrors) + if (ModUtils.findFirst(input, "treatWarningsAsErrors")) args.push('/WX') for (i in includePaths) args.push('/I' + FileInfo.toWindowsSeparators(includePaths[i])) @@ -48,7 +48,8 @@ function prepareCompiler(product, input, outputs, platformDefines, defines, incl var pchOutput = outputs["c++_pch"] ? outputs["c++_pch"][0] : undefined // precompiled header file - if (product.module.precompiledHeader) { + var pch = ModUtils.findFirst(product, "precompiledHeader") + if (pch) { if (pchOutput) { // create pch args.push('/Yc') @@ -58,8 +59,9 @@ function prepareCompiler(product, input, outputs, platformDefines, defines, incl args.push(FileInfo.toWindowsSeparators(input.fileName)) } else { // use pch - var pchHeaderName = FileInfo.toWindowsSeparators(product.module.precompiledHeader) - var pchName = FileInfo.toWindowsSeparators(product.module.precompiledHeaderDir + "\\.obj\\" + product.name + "\\" + product.name + ".pch") + var pchHeaderName = FileInfo.toWindowsSeparators(pch) + var pchName = FileInfo.toWindowsSeparators(ModUtils.findFirst(product, "precompiledHeaderDir") + + "\\.obj\\" + product.name + "\\" + product.name + ".pch") args.push("/FI" + pchHeaderName) args.push("/Yu" + pchHeaderName) args.push("/Fp" + pchName) @@ -80,7 +82,7 @@ function prepareCompiler(product, input, outputs, platformDefines, defines, incl cmd.description = (pchOutput ? 'pre' : '') + 'compiling ' + FileInfo.fileName(input.fileName) cmd.highlight = "compiler"; cmd.workingDirectory = FileInfo.path(objOutput.fileName) - cmd.responseFileThreshold = product.module.responseFileThreshold + cmd.responseFileThreshold = ModUtils.findFirst(product, "responseFileThreshold") cmd.responseFileUsagePrefix = '@'; // cl.exe outputs the cpp file name. We filter that out. cmd.stdoutFilterFunction = "function(output) {"; @@ -94,11 +96,11 @@ function prepareLinker(product, inputs, outputs, libraryPaths, dynamicLibraries, var i; var linkDLL = (outputs.dynamiclibrary ? true : false) var primaryOutput = (linkDLL ? outputs.dynamiclibrary[0] : outputs.application[0]) - var optimization = product.module.optimization - var debugInformation = product.module.debugInformation - var architecture = product.module.architecture - var windowsSDKPath = product.module.windowsSDKPath - var generateManifestFiles = !linkDLL && product.module.generateManifestFiles + var optimization = ModUtils.findFirst(product, "optimization") + var debugInformation = ModUtils.findFirst(product, "debugInformation") + var architecture = ModUtils.findFirst(product, "architecture") + var windowsSDKPath = ModUtils.findFirst(product, "windowsSDKPath") + var generateManifestFiles = !linkDLL && ModUtils.findFirst(product, "generateManifestFiles") var args = ['/nologo'] if (linkDLL) { @@ -157,7 +159,7 @@ function prepareLinker(product, inputs, outputs, libraryPaths, dynamicLibraries, cmd.description = 'linking ' + FileInfo.fileName(primaryOutput.fileName) cmd.highlight = 'linker'; cmd.workingDirectory = FileInfo.path(primaryOutput.fileName) - cmd.responseFileThreshold = product.module.responseFileThreshold + cmd.responseFileThreshold = ModUtils.findFirst(product, "responseFileThreshold") cmd.responseFileUsagePrefix = '@'; cmd.stdoutFilterFunction = function(output) diff --git a/share/qbs/modules/cpp/windows-mingw.qbs b/share/qbs/modules/cpp/windows-mingw.qbs index 9df586a59..6eb5572a3 100644 --- a/share/qbs/modules/cpp/windows-mingw.qbs +++ b/share/qbs/modules/cpp/windows-mingw.qbs @@ -60,7 +60,7 @@ GenericGCC { } args = args.concat(['-i', input.fileName, '-o', output.fileName]); - var cmd = new Command(product.module.windresPath, args); + var cmd = new Command(ModUtils.findFirst(product, "windresPath"), args); cmd.description = 'compiling ' + FileInfo.fileName(input.fileName); cmd.highlight = 'compiler'; return cmd; diff --git a/share/qbs/modules/cpp/windows-msvc.qbs b/share/qbs/modules/cpp/windows-msvc.qbs index f992db998..6f91559db 100644 --- a/share/qbs/modules/cpp/windows-msvc.qbs +++ b/share/qbs/modules/cpp/windows-msvc.qbs @@ -67,7 +67,8 @@ CppModule { Artifact { fileTags: ['obj'] fileName: { - var completeBaseName = FileInfo.completeBaseName(product.modules.cpp.precompiledHeader); + var completeBaseName = FileInfo.completeBaseName(product.moduleProperty("cpp", + "precompiledHeader")); // ### make the object file dir overridable return ".obj/" + product.name + "/" + completeBaseName + '.obj' } @@ -116,7 +117,8 @@ CppModule { usings: ['staticlibrary', 'dynamiclibrary_import'] Artifact { fileTags: ["application"] - fileName: product.destinationDirectory + "/" + product.module.executablePrefix + product.targetName + product.module.executableSuffix + fileName: product.destinationDirectory + "/" + ModUtils.findFirst(product, "executablePrefix") + + product.targetName + ModUtils.findFirst(product, "executableSuffix") } prepare: { @@ -136,12 +138,16 @@ CppModule { Artifact { fileTags: ["dynamiclibrary"] - fileName: product.destinationDirectory + "/" + product.module.dynamicLibraryPrefix + product.targetName + product.module.dynamicLibrarySuffix + fileName: product.destinationDirectory + "/" + + ModUtils.findFirst(product, "dynamicLibraryPrefix") + product.targetName + + ModUtils.findFirst(product, "dynamicLibrarySuffix") } Artifact { fileTags: ["dynamiclibrary_import"] - fileName: product.destinationDirectory + "/" + product.module.dynamicLibraryPrefix + product.targetName + product.module.dynamicLibraryImportSuffix + fileName: product.destinationDirectory + "/" + + ModUtils.findFirst(product, "dynamicLibraryPrefix") + product.targetName + + ModUtils.findFirst(product, "dynamicLibraryImportSuffix") alwaysUpdated: false } @@ -162,7 +168,8 @@ CppModule { Artifact { fileTags: ["staticlibrary"] - fileName: product.destinationDirectory + "/" + product.module.staticLibraryPrefix + product.targetName + product.module.staticLibrarySuffix + fileName: product.destinationDirectory + "/" + ModUtils.findFirst(product, "staticLibraryPrefix") + + product.targetName + ModUtils.findFirst(product, "staticLibrarySuffix") cpp.staticLibraries: { var result = [] for (var i in inputs.staticlibrary) { @@ -176,7 +183,7 @@ CppModule { } prepare: { - var toolchainInstallPath = product.module.toolchainInstallPath + var toolchainInstallPath = ModUtils.findFirst(product, "toolchainInstallPath") var args = ['/nologo'] var nativeOutputFileName = FileInfo.toWindowsSeparators(output.fileName) @@ -185,7 +192,7 @@ CppModule { var fileName = FileInfo.toWindowsSeparators(inputs.obj[i].fileName) args.push(fileName) } - var is64bit = (product.module.architecture == "x86_64") + var is64bit = (ModUtils.findFirst(product, "architecture") == "x86_64") var linkerPath = toolchainInstallPath + '/VC/bin/' if (is64bit) linkerPath += 'amd64/' @@ -194,7 +201,7 @@ CppModule { cmd.description = 'creating ' + FileInfo.fileName(output.fileName) cmd.highlight = 'linker'; cmd.workingDirectory = FileInfo.path(output.fileName) - cmd.responseFileThreshold = product.module.responseFileThreshold + cmd.responseFileThreshold = ModUtils.findFirst(product, "responseFileThreshold") cmd.responseFileUsagePrefix = '@'; return cmd; } diff --git a/share/qbs/modules/qt/core/moc.js b/share/qbs/modules/qt/core/moc.js index 76ad66160..43f174408 100644 --- a/share/qbs/modules/qt/core/moc.js +++ b/share/qbs/modules/qt/core/moc.js @@ -13,7 +13,7 @@ function args(product, input, outputFileName) return args; } -function fullPath(module) +function fullPath(product) { - return module.binPath + '/' + module.mocName; + return ModUtils.findFirst(product, "binPath") + '/' + ModUtils.findFirst(product, "mocName"); } diff --git a/share/qbs/modules/qt/core/qtcore.qbs b/share/qbs/modules/qt/core/qtcore.qbs index 356343950..64db5793d 100644 --- a/share/qbs/modules/qt/core/qtcore.qbs +++ b/share/qbs/modules/qt/core/qtcore.qbs @@ -118,7 +118,7 @@ Module { } prepare: { - var cmd = new Command(Moc.fullPath(product.module), + var cmd = new Command(Moc.fullPath(product), Moc.args(product, input, output.fileName)); cmd.description = 'moc ' + FileInfo.fileName(input.fileName); cmd.highlight = 'codegen'; @@ -135,7 +135,7 @@ Module { } prepare: { - var cmd = new Command(Moc.fullPath(product.module), + var cmd = new Command(Moc.fullPath(product), Moc.args(product, input, output.fileName)); cmd.description = 'moc ' + FileInfo.fileName(input.fileName); cmd.highlight = 'codegen'; @@ -152,7 +152,7 @@ Module { } prepare: { - var cmd = new Command(Moc.fullPath(product.module), + var cmd = new Command(Moc.fullPath(product), Moc.args(product, input, output.fileName)); cmd.description = 'moc ' + FileInfo.fileName(input.fileName); cmd.highlight = 'codegen'; @@ -169,7 +169,7 @@ Module { fileTags: ["cpp"] } prepare: { - var cmd = new Command(product.module.binPath + '/rcc', + var cmd = new Command(ModUtils.findFirst(product, "binPath") + '/rcc', [input.fileName, '-name', FileInfo.completeBaseName(input.fileName), '-o', output.fileName]); @@ -183,12 +183,15 @@ Module { inputs: ["ts"] Artifact { - fileName: FileInfo.joinPaths(product.module.qmFilesDir, input.completeBaseName + ".qm") + fileName: FileInfo.joinPaths(ModUtils.findFirst(product, "qmFilesDir"), + input.completeBaseName + ".qm") fileTags: ["qm"] } prepare: { - var cmd = new Command(product.module.binPath + '/' + product.module.lreleaseName, ['-silent', input.fileName, '-qm', output.fileName]); + var cmd = new Command(ModUtils.findFirst(product, "binPath") + '/' + + ModUtils.findFirst(product, "lreleaseName"), + ['-silent', input.fileName, '-qm', output.fileName]); cmd.description = 'lrelease ' + FileInfo.fileName(input.fileName); cmd.highlight = 'filegen'; return cmd; diff --git a/share/qbs/modules/qt/gui/qtgui.qbs b/share/qbs/modules/qt/gui/qtgui.qbs index 24a1a248c..8a2391a03 100644 --- a/share/qbs/modules/qt/gui/qtgui.qbs +++ b/share/qbs/modules/qt/gui/qtgui.qbs @@ -1,6 +1,7 @@ import qbs.base 1.0 import qbs.fileinfo 1.0 as FileInfo import '../QtModule.qbs' as QtModule +import '../../utils.js' as ModUtils QtModule { qtModuleName: "Gui" @@ -22,7 +23,8 @@ QtModule { } prepare: { - var cmd = new Command(product.module.binPath + '/' + product.module.uicName, + var cmd = new Command(ModUtils.findFirst(product, "binPath") + '/' + + ModUtils.findFirst(product, "uicName"), [input.fileName, '-o', output.fileName]) cmd.description = 'uic ' + FileInfo.fileName(input.fileName); cmd.highlight = 'codegen'; diff --git a/share/qbs/modules/utils.js b/share/qbs/modules/utils.js index 9308fa072..8d7b037df 100644 --- a/share/qbs/modules/utils.js +++ b/share/qbs/modules/utils.js @@ -2,75 +2,23 @@ // utility functions for modules // -function appendAll_internal_recursive(modules, name, key, seenValues) -{ - var result = [] - var propertyValue - var m - for (m in modules) { - if (m === name) { - propertyValue = modules[m][key] - if (propertyValue instanceof Array) { - for (var i = 0; i < propertyValue.length; ++i) { - var value = propertyValue[i] - if (!seenValues[value]) { - seenValues[value] = true - result.push(value) - } - } - } else if (propertyValue) { - if (!seenValues[propertyValue]) { - seenValues[propertyValue] = true - result.push(propertyValue) - } - } - } else { - propertyValue = appendAll_internal_recursive(modules[m].modules, name, key, seenValues) - if (propertyValue.length > 0) { - result = result.concat(propertyValue) - } - } - } - return result -} - -function appendAll_internal(modules, name, key, seenValues) -{ - if (!seenValues) - seenValues = [] - return appendAll_internal_recursive(modules, name, key, seenValues) -} - function appendAll(config, key) { - return appendAll_internal(config.modules, config.module.name, key) + return config.moduleProperties(config.moduleName, key) } function appendAllFromArtifacts(product, artifacts, moduleName, propertyName) { var seenValues = [] - var result = appendAll_internal(product.modules, moduleName, propertyName, seenValues) + var result = product.moduleProperties(moduleName, propertyName) for (var i in artifacts) - result = result.concat(appendAll_internal(artifacts[i].modules, moduleName, propertyName, seenValues)) + result = result.concat(artifacts[i].moduleProperties(moduleName, propertyName)) return result } -function findFirst(modules, name, property) +function findFirst(product, propertyName) { - var value; - var module; - for (var moduleName in modules) { - module = modules[moduleName]; - if (moduleName === name) { - value = module[property]; - if (value !== undefined) - return value; - } - value = findFirst(module.modules, name, property); - if (value !== undefined) - return value; - } - return undefined; + return product.moduleProperty(product.moduleName, propertyName) } function dumpProperty(key, value, level) |