diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2021-09-16 19:09:03 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2021-09-20 14:52:09 +0000 |
commit | b637dd6181bddab0e80aa0c04f96dfecb3f5cd51 (patch) | |
tree | 6894b3eba369a0e08b53e05bd060dbf3c2eaa7d7 /share/qbs | |
parent | 84170f738352f7af14663ea31de9b13be86a3de1 (diff) | |
download | qbs-b637dd6181bddab0e80aa0c04f96dfecb3f5cd51.tar.gz |
Use common Cpp.resourceCompilerOutput{Tags|Artifacts} functions
... to unify a codebase.
Resource output artifacts are now tagged with the 'res' instead of
the 'obj' as before (also the output file extensions are also changed
from '*.obj' to '*.res'). This only affected to the additional
processing for the new 'res' tags in the linker rules for the MSVC
and the MinGW.
The reason for adding the new 'res' tag is that for some compilers
(e.g. the future Open Watcom), the resource files must be linked using
the special flags (and not passed as like regular object files to the
linker).
Change-Id: Ibfc52a384816d3769a7c1f6564db079c118011a0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/qbs')
-rw-r--r-- | share/qbs/modules/cpp/GenericGCC.qbs | 10 | ||||
-rw-r--r-- | share/qbs/modules/cpp/gcc.js | 1 | ||||
-rw-r--r-- | share/qbs/modules/cpp/msvc.js | 3 | ||||
-rw-r--r-- | share/qbs/modules/cpp/windows-mingw.qbs | 11 | ||||
-rw-r--r-- | share/qbs/modules/cpp/windows-msvc-base.qbs | 19 |
5 files changed, 22 insertions, 22 deletions
diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs index 94b9c8069..ac30708d4 100644 --- a/share/qbs/modules/cpp/GenericGCC.qbs +++ b/share/qbs/modules/cpp/GenericGCC.qbs @@ -397,7 +397,7 @@ CppModule { condition: product.cpp.shouldLink multiplex: true inputs: { - var tags = ["obj", "linkerscript", "versionscript"]; + var tags = ["obj", "res", "linkerscript", "versionscript"]; if (product.bundle && product.bundle.embedInfoPlist && product.qbs.targetOS.contains("darwin")) { tags.push("aggregate_infoplist"); @@ -471,7 +471,7 @@ CppModule { name: "staticLibraryLinker" condition: product.cpp.shouldLink multiplex: true - inputs: ["obj", "linkerscript"] + inputs: ["obj", "res", "linkerscript"] inputsFromDependencies: ["dynamiclibrary_symbols", "dynamiclibrary_import", "staticlibrary"] outputFileTags: ["bundle.input", "staticlibrary", "c_staticlibrary", "cpp_staticlibrary"] @@ -501,6 +501,8 @@ CppModule { var args = ['rcs', output.filePath]; for (var i in inputs.obj) args.push(inputs.obj[i].filePath); + for (var i in inputs.res) + args.push(inputs.res[i].filePath); var cmd = new Command(product.cpp.archiverPath, args); cmd.description = 'creating ' + output.fileName; cmd.highlight = 'linker' @@ -515,7 +517,7 @@ CppModule { condition: product.cpp.shouldLink multiplex: true inputs: { - var tags = ["obj", "linkerscript"]; + var tags = ["obj", "res", "linkerscript"]; if (product.bundle && product.bundle.embedInfoPlist && product.qbs.targetOS.contains("darwin")) { tags.push("aggregate_infoplist"); @@ -560,7 +562,7 @@ CppModule { condition: product.cpp.shouldLink multiplex: true inputs: { - var tags = ["obj", "linkerscript"]; + var tags = ["obj", "res", "linkerscript"]; if (product.bundle && product.bundle.embedInfoPlist && product.qbs.targetOS.contains("darwin")) { tags.push("aggregate_infoplist"); diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js index 120e601a5..f7581d09b 100644 --- a/share/qbs/modules/cpp/gcc.js +++ b/share/qbs/modules/cpp/gcc.js @@ -426,6 +426,7 @@ function linkerFlags(project, product, inputs, outputs, primaryOutput, linkerPat args.push("-o", primaryOutput.filePath); args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + args = args.concat(Cpp.collectResourceObjectPaths(inputs)); for (i in frameworks) { frameworkExecutablePath = PathTools.frameworkExecutablePath(frameworks[i]); diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js index 8906cd9e3..b206bd4ba 100644 --- a/share/qbs/modules/cpp/msvc.js +++ b/share/qbs/modules/cpp/msvc.js @@ -386,7 +386,8 @@ function prepareLinker(project, product, inputs, outputs, input, output) { Cpp.collectMiscLinkerArguments(product)); } - var allInputs = Cpp.collectLinkerObjectPaths(inputs); + var allInputs = [].concat(Cpp.collectLinkerObjectPaths(inputs), + Cpp.collectResourceObjectPaths(inputs)); args = args.concat([].uniqueConcat(allInputs).map(function(path) { return FileInfo.toWindowsSeparators(path); })); diff --git a/share/qbs/modules/cpp/windows-mingw.qbs b/share/qbs/modules/cpp/windows-mingw.qbs index e1354736d..2a01d81a9 100644 --- a/share/qbs/modules/cpp/windows-mingw.qbs +++ b/share/qbs/modules/cpp/windows-mingw.qbs @@ -33,6 +33,7 @@ import qbs.FileInfo import qbs.ModUtils import qbs.Utilities +import 'cpp.js' as Cpp import "setuprunenv.js" as SetupRunEnv MingwBaseModule { @@ -66,13 +67,8 @@ MingwBaseModule { Rule { inputs: ["rc"] auxiliaryInputs: ["hpp"] - - Artifact { - filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), - input.completeBaseName + "_res" + input.cpp.objectSuffix) - fileTags: ["obj"] - } - + outputFileTags: Cpp.resourceCompilerOutputTags() + outputArtifacts: Cpp.resourceCompilerOutputArtifacts(input) prepare: { var platformDefines = input.cpp.platformDefines; var defines = input.cpp.defines; @@ -97,6 +93,7 @@ MingwBaseModule { args.push(systemIncludePaths[i]); } + args.push("-O", "coff"); // Set COFF format explicitly. args = args.concat(['-i', input.filePath, '-o', output.filePath]); var cmd = new Command(product.cpp.windresPath, args); cmd.description = 'compiling ' + input.fileName; diff --git a/share/qbs/modules/cpp/windows-msvc-base.qbs b/share/qbs/modules/cpp/windows-msvc-base.qbs index c6869462e..98efafe91 100644 --- a/share/qbs/modules/cpp/windows-msvc-base.qbs +++ b/share/qbs/modules/cpp/windows-msvc-base.qbs @@ -207,7 +207,7 @@ CppModule { Rule { name: "applicationLinker" multiplex: true - inputs: ['obj', 'native.pe.manifest', 'def'] + inputs: ['obj', 'res', 'native.pe.manifest', 'def'] inputsFromDependencies: ['staticlibrary', 'dynamiclibrary_import', "debuginfo_app"] outputFileTags: { @@ -253,7 +253,7 @@ CppModule { Rule { name: "dynamicLibraryLinker" multiplex: true - inputs: ['obj', 'native.pe.manifest', 'def'] + inputs: ['obj', 'res', 'native.pe.manifest', 'def'] inputsFromDependencies: ['staticlibrary', 'dynamiclibrary_import', "debuginfo_dll"] outputFileTags: { @@ -296,7 +296,7 @@ CppModule { Rule { name: "libtool" multiplex: true - inputs: ["obj"] + inputs: ["obj", "res"] inputsFromDependencies: ["staticlibrary", "dynamiclibrary_import"] outputFileTags: ["staticlibrary", "debuginfo_cl"] outputArtifacts: { @@ -324,6 +324,10 @@ CppModule { var fileName = FileInfo.toWindowsSeparators(inputs.obj[i].filePath) args.push(fileName) } + for (var i in inputs.res) { + var fileName = FileInfo.toWindowsSeparators(inputs.res[i].filePath) + args.push(fileName) + } var cmd = new Command("lib.exe", args); cmd.description = 'creating ' + lib.fileName; cmd.highlight = 'linker'; @@ -342,13 +346,8 @@ CppModule { Rule { inputs: ["rc"] auxiliaryInputs: ["hpp"] - - Artifact { - filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), - input.completeBaseName + ".res") - fileTags: ["obj"] - } - + outputFileTags: Cpp.resourceCompilerOutputTags() + outputArtifacts: Cpp.resourceCompilerOutputArtifacts(input) prepare: { // From MSVC 2010 on, the logo can be suppressed. var logo = product.cpp.compilerVersionMajor >= 16 |