diff options
author | Richard Weickelt <richard@weickelt.de> | 2020-08-14 11:46:27 +0200 |
---|---|---|
committer | Richard Weickelt <richard@weickelt.de> | 2020-08-14 11:46:37 +0200 |
commit | 2311a8224c3fc7141c44cc517f4ecdb882cd09f8 (patch) | |
tree | 1d83aed514d564b8e0ccc9934772508926a51882 | |
parent | 0820c2d3ca6ac2e01c1d68945beeba45f4212658 (diff) | |
parent | e42ad799703412d7375465df49282dd960f81e2e (diff) |
Merge branch 1.17 into master
Change-Id: Ibdf2afb9f05682e0624540af22330abc8580bafb
50 files changed, 536 insertions, 88 deletions
diff --git a/.travis.yml b/.travis.yml index 4a4bd2573..2a438ee04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -138,7 +138,7 @@ jobs: - <<: *build-on-macos name: With Qbs on macOS (xcode 11.5) using iOS profile - if: branch = master + if: NOT branch =~ ^gerrit env: # Address sanitizer slows autotests down too much. # We would hit the maximum build time on Travis. @@ -163,17 +163,17 @@ jobs: - <<: *build-on-macos name: With Qbs on macOS (xcode 10.3) osx_image: xcode10.3 - if: branch = master + if: NOT branch =~ ^gerrit - <<: *build-on-macos name: With Qbs on macOS (xcode 9.4) osx_image: xcode9.4 - if: branch = master + if: NOT branch =~ ^gerrit - &build-on-windows-with-docker stage: Build Qbs and and run autotests name: With Qbs on Windows with Docker (Visual Studio 2017) - if: branch = master + if: NOT branch =~ ^gerrit os: windows services: docker env: @@ -233,7 +233,7 @@ jobs: - <<: *build-on-windows name: With Qbs on Windows (clang-cl) - if: branch = master + if: NOT branch =~ ^gerrit script: - qbs setup-toolchains --detect - qbs setup-qt ${QMAKE_PATH} qt diff --git a/doc/reference/items/probe/path-probe.qdoc b/doc/reference/items/probe/path-probe.qdoc index df5fbb22f..b7749f09d 100644 --- a/doc/reference/items/probe/path-probe.qdoc +++ b/doc/reference/items/probe/path-probe.qdoc @@ -37,10 +37,11 @@ locations. PathProbe takes as input lists of paths to search files from and file name patterns. The paths - are specified by using the searchPaths, platformSearchPaths, environmentPaths, and - platformEnvironmentPaths properties. The file name patterns are specified by the \l names and - nameSuffixes properties. Returns the first file that matches the file name patterns. If no such - file is found, the \l {Probe::found}{probe.found} property is set to \c false. + are specified by using the environmentPaths, searchPaths, platformEnvironmentPaths and + platformSearchPaths properties; the path are searched in the same order as listed. The file + name patterns are specified by the \l names and nameSuffixes properties. Returns the first file + that matches the file name patterns. If no such file is found, the + \l {Probe::found}{probe.found} property is set to \c false. For example, a simple PathProbe that searches for the stdio.h header can be used as follows: diff --git a/doc/reference/modules/cpp-module.qdoc b/doc/reference/modules/cpp-module.qdoc index e92359377..da9996b85 100644 --- a/doc/reference/modules/cpp-module.qdoc +++ b/doc/reference/modules/cpp-module.qdoc @@ -1845,9 +1845,7 @@ \qmlproperty bool cpp::generateCompilerListingFiles \since Qbs 1.15 - \baremetalproperty - - Whether to auto-generate a compiler listing files. + Whether to auto-generate compiler listing files. \defaultvalue \c{false} */ diff --git a/doc/reference/modules/qbs-module.qdoc b/doc/reference/modules/qbs-module.qdoc index e72df697c..874e006e8 100644 --- a/doc/reference/modules/qbs-module.qdoc +++ b/doc/reference/modules/qbs-module.qdoc @@ -274,10 +274,15 @@ \li \c{"windows"} \li \c{["windows"]} \row + \li \c{"none"} + \li \c{["none"]} + \row \li \c{undefined} \li \c{[]} \endtable + \note The "none" value is usually used for a bare-metal platforms. + \sa {Target Platforms} \defaultvalue \l{qbs::hostPlatform}{hostPlatform} diff --git a/examples/rpaths/rpaths.qbs b/examples/rpaths/rpaths.qbs index 1e5411468..59d48174a 100644 --- a/examples/rpaths/rpaths.qbs +++ b/examples/rpaths/rpaths.qbs @@ -12,6 +12,7 @@ Project { cpp.sonamePrefix: qbs.targetOS.contains("macos") ? "@rpath" : undefined cpp.rpaths: cpp.rpathOrigin cpp.cxxLanguageVersion: "c++11" + cpp.minimumMacosVersion: "10.8" files: [ "objecta.cpp", "objecta.h", @@ -29,6 +30,7 @@ Project { name: "LibraryB" bundle.isBundle: false cpp.cxxLanguageVersion: "c++11" + cpp.minimumMacosVersion: "10.8" cpp.sonamePrefix: qbs.targetOS.contains("macos") ? "@rpath" : undefined cpp.rpaths: cpp.rpathOrigin files: [ @@ -51,6 +53,7 @@ Project { bundle.isBundle: false cpp.rpaths: FileInfo.joinPaths(cpp.rpathOrigin, "..", "lib") cpp.cxxLanguageVersion: "c++11" + cpp.minimumMacosVersion: "10.8" install: true installDir: "examples/bin" } diff --git a/share/qbs/imports/qbs/Probes/path-probe.js b/share/qbs/imports/qbs/Probes/path-probe.js index b4d745428..b1bdf9930 100644 --- a/share/qbs/imports/qbs/Probes/path-probe.js +++ b/share/qbs/imports/qbs/Probes/path-probe.js @@ -60,6 +60,17 @@ function canonicalSelectors(selectors, nameSuffixes) { return selectors.map(mapper); } +function pathsFromEnvs(envs, pathListSeparator) { + envs = envs || []; + var result = []; + for (var i = 0; i < envs.length; ++i) { + var value = Environment.getEnv(envs[i]) || ''; + if (value.length > 0) + result = result.concat(value.split(pathListSeparator)); + } + return result; +} + function configure(selectors, names, nameSuffixes, nameFilter, candidateFilter, searchPaths, pathSuffixes, platformSearchPaths, environmentPaths, platformEnvironmentPaths, pathListSeparator) { @@ -90,14 +101,11 @@ function configure(selectors, names, nameSuffixes, nameFilter, candidateFilter, }); // FIXME: Suggest how to obtain paths from system - var _paths = ModUtils.concatAll(searchPaths, platformSearchPaths); - // FIXME: Add getenv support - var envs = ModUtils.concatAll(platformEnvironmentPaths, environmentPaths); - for (var i = 0; i < envs.length; ++i) { - var value = Environment.getEnv(envs[i]) || ''; - if (value.length > 0) - _paths = _paths.concat(value.split(pathListSeparator)); - } + var _paths = ModUtils.concatAll( + pathsFromEnvs(environmentPaths, pathListSeparator), + searchPaths, + pathsFromEnvs(platformEnvironmentPaths, pathListSeparator), + platformSearchPaths); var _suffixes = ModUtils.concatAll('', pathSuffixes); _paths = _paths.map(function(p) { return FileInfo.fromNativeSeparators(p); }); _suffixes = _suffixes.map(function(p) { return FileInfo.fromNativeSeparators(p); }); diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs index 80de576a9..b69f26739 100644 --- a/share/qbs/modules/cpp/GenericGCC.qbs +++ b/share/qbs/modules/cpp/GenericGCC.qbs @@ -114,6 +114,9 @@ CppModule { compilerFrameworkPaths: gccProbe.frameworkPaths compilerLibraryPaths: gccProbe.libraryPaths + staticLibraryPrefix: "lib" + staticLibrarySuffix: ".a" + property bool compilerHasTargetOption: qbs.toolchain.contains("clang") && Utilities.versionCompare(compilerVersion, "3.1") >= 0 property bool assemblerHasTargetOption: qbs.toolchain.contains("xcode") diff --git a/share/qbs/modules/cpp/MingwBaseModule.qbs b/share/qbs/modules/cpp/MingwBaseModule.qbs index 60ad28b08..831512c5c 100644 --- a/share/qbs/modules/cpp/MingwBaseModule.qbs +++ b/share/qbs/modules/cpp/MingwBaseModule.qbs @@ -37,8 +37,6 @@ import "setuprunenv.js" as SetupRunEnv GenericGCC { condition: false - staticLibraryPrefix: "lib" - staticLibrarySuffix: ".a" dynamicLibrarySuffix: ".dll" executableSuffix: ".exe" debugInfoSuffix: ".debug" diff --git a/share/qbs/modules/cpp/UnixGCC.qbs b/share/qbs/modules/cpp/UnixGCC.qbs index 68eacea3f..94dfb1907 100644 --- a/share/qbs/modules/cpp/UnixGCC.qbs +++ b/share/qbs/modules/cpp/UnixGCC.qbs @@ -35,10 +35,8 @@ GenericGCC { && qbs.targetOS.contains("unix") priority: -50 - staticLibraryPrefix: "lib" dynamicLibraryPrefix: "lib" loadableModulePrefix: "lib" - staticLibrarySuffix: ".a" dynamicLibrarySuffix: ".so" debugInfoSuffix: ".debug" imageFormat: "elf" diff --git a/share/qbs/modules/cpp/android-gcc.qbs b/share/qbs/modules/cpp/android-gcc.qbs index f218a4991..bd58cbcca 100644 --- a/share/qbs/modules/cpp/android-gcc.qbs +++ b/share/qbs/modules/cpp/android-gcc.qbs @@ -74,6 +74,7 @@ LinuxGCC { property string toolchainTriple: [targetAbi === "androideabi" ? "arm" : targetArch, targetSystem, targetAbi].join("-") + internalVersion: undefined toolchainPrefix: undefined machineType: { diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js index c1dea56ab..0c912d0aa 100644 --- a/share/qbs/modules/cpp/iar.js +++ b/share/qbs/modules/cpp/iar.js @@ -579,10 +579,10 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { // Optimization flags. switch (input.cpp.optimization) { case "small": - args.push("-Ohs"); + args.push("-Ohz"); break; case "fast": - args.push("-Ohz"); + args.push("-Ohs"); break; case "none": args.push("-On"); @@ -661,7 +661,7 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { } // Listing files generation flag. - if (product.cpp.generateCompilerListingFiles) + if (input.cpp.generateCompilerListingFiles) args.push("-l", outputs.lst[0].filePath); // Misc flags. @@ -721,7 +721,7 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { } // Listing files generation flag. - if (product.cpp.generateAssemblerListingFiles) + if (input.cpp.generateAssemblerListingFiles) args.push("-l", outputs.lst[0].filePath); // Misc flags. @@ -730,7 +730,7 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { return args; } -function linkerFlags(project, product, input, outputs) { +function linkerFlags(project, product, inputs, outputs) { var args = []; // Inputs. @@ -794,7 +794,7 @@ function linkerFlags(project, product, input, outputs) { return args; } -function archiverFlags(project, product, input, outputs) { +function archiverFlags(project, product, inputs, outputs) { var args = []; // Inputs. @@ -830,7 +830,7 @@ function prepareAssembler(project, product, inputs, outputs, input, output, expl function prepareLinker(project, product, inputs, outputs, input, output) { var primaryOutput = outputs.application[0]; - var args = linkerFlags(project, product, input, outputs); + var args = linkerFlags(project, product, inputs, outputs); var linkerPath = product.cpp.linkerPath; var cmd = new Command(linkerPath, args); cmd.description = "linking " + primaryOutput.fileName; @@ -839,7 +839,7 @@ function prepareLinker(project, product, inputs, outputs, input, output) { } function prepareArchiver(project, product, inputs, outputs, input, output) { - var args = archiverFlags(project, product, input, outputs); + var args = archiverFlags(project, product, inputs, outputs); var archiverPath = product.cpp.archiverPath; var cmd = new Command(archiverPath, args); cmd.description = "linking " + output.fileName; diff --git a/share/qbs/modules/cpp/iar.qbs b/share/qbs/modules/cpp/iar.qbs index bc226389b..519d30f2a 100644 --- a/share/qbs/modules/cpp/iar.qbs +++ b/share/qbs/modules/cpp/iar.qbs @@ -54,6 +54,7 @@ CppModule { } qbs.architecture: iarProbe.found ? iarProbe.architecture : original + qbs.targetPlatform: "none" compilerVersionMajor: iarProbe.versionMajor compilerVersionMinor: iarProbe.versionMinor diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js index 4cb2946a6..fcea3c4b3 100644 --- a/share/qbs/modules/cpp/keil.js +++ b/share/qbs/modules/cpp/keil.js @@ -39,8 +39,17 @@ var TemporaryDir = require("qbs.TemporaryDir"); var TextFile = require("qbs.TextFile"); var Utilities = require("qbs.Utilities"); +function isMcs51Architecture(architecture) { + return architecture === "mcs51"; +} + +function isMcs251Architecture(architecture) { + return architecture === "mcs251"; +} + function isMcsArchitecture(architecture) { - return architecture === "mcs51" || architecture === "mcs251"; + return isMcs51Architecture(architecture) + || isMcs251Architecture(architecture); } function isC166Architecture(architecture) { @@ -156,7 +165,7 @@ function objectSuffix(qbs) { function mapFileSuffix(qbs) { var architecture = qbs.architecture; - if (isMcsArchitecture(architecture)) + if (isMcs51Architecture(architecture)) return ".m51"; if (isC166Architecture(architecture)) return ".m66"; @@ -204,6 +213,7 @@ function guessArmCCArchitecture(targetArchArm, targetArchThumb) { } function guessArmClangArchitecture(targetArchArm, targetArchProfile) { + targetArchProfile = targetArchProfile.replace(/'/g, ""); var arch = "arm"; if (targetArchArm !== "" && targetArchProfile !== "") arch += "v" + targetArchArm + targetArchProfile.toLowerCase(); @@ -643,7 +653,8 @@ function compilerOutputArtifacts(input, useListing) { artifacts.push({ fileTags: ["lst"], filePath: Utilities.getHash(input.baseDir) + "/" - + (isMcsArchitecture(input.cpp.architecture) + + ((isMcsArchitecture(input.cpp.architecture) + || isC166Architecture(input.cpp.architecture)) ? input.fileName : input.baseName) + ".lst" }); @@ -749,7 +760,7 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { } // Listing files generation flag. - if (!product.cpp.generateCompilerListingFiles) + if (!input.cpp.generateCompilerListingFiles) args.push("NOPRINT"); else args.push("PRINT(" + FileInfo.toWindowsSeparators(outputs.lst[0].filePath) + ")"); @@ -839,7 +850,7 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { } // Listing files generation flag. - if (product.cpp.generateCompilerListingFiles) { + if (input.cpp.generateCompilerListingFiles) { args.push("--list"); args.push("--list_dir", FileInfo.path(outputs.lst[0].filePath)); } @@ -963,7 +974,7 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { args.push("EP"); // Listing files generation flag. - if (!product.cpp.generateAssemblerListingFiles) + if (!input.cpp.generateAssemblerListingFiles) args.push("NOPRINT"); else args.push("PRINT(" + FileInfo.toWindowsSeparators(outputs.lst[0].filePath) + ")"); @@ -1005,7 +1016,7 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { args.push((endianness === "little") ? "--littleend" : "--bigend"); // Listing files generation flag. - if (product.cpp.generateAssemblerListingFiles) + if (input.cpp.generateAssemblerListingFiles) args.push("--list", outputs.lst[0].filePath); } @@ -1015,7 +1026,7 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { return args; } -function linkerFlags(project, product, input, outputs) { +function linkerFlags(project, product, inputs, outputs) { var args = []; var architecture = product.qbs.architecture; @@ -1048,7 +1059,9 @@ function linkerFlags(project, product, input, outputs) { // Map file generation flag. if (!product.cpp.generateLinkerMapFile) - args.push("NOMAP"); + args.push("NOPRINT"); + else + args.push("PRINT(" + FileInfo.toWindowsSeparators(outputs.mem_map[0].filePath) + ")"); } else if (isArmArchitecture(architecture)) { // Inputs. if (inputs.obj) @@ -1090,7 +1103,7 @@ function linkerFlags(project, product, input, outputs) { return args; } -function archiverFlags(project, product, input, outputs) { +function archiverFlags(project, product, inputs, outputs) { var args = []; var architecture = product.qbs.architecture; @@ -1170,7 +1183,7 @@ function prepareAssembler(project, product, inputs, outputs, input, output, expl function prepareLinker(project, product, inputs, outputs, input, output) { var primaryOutput = outputs.application[0]; - var args = linkerFlags(project, product, input, outputs); + var args = linkerFlags(project, product, inputs, outputs); var linkerPath = product.cpp.linkerPath; var architecture = product.cpp.architecture; var cmd = new Command(linkerPath, args); @@ -1187,7 +1200,7 @@ function prepareLinker(project, product, inputs, outputs, input, output) { } function prepareArchiver(project, product, inputs, outputs, input, output) { - var args = archiverFlags(project, product, input, outputs); + var args = archiverFlags(project, product, inputs, outputs); var archiverPath = product.cpp.archiverPath; var architecture = product.cpp.architecture; var cmd = new Command(archiverPath, args); diff --git a/share/qbs/modules/cpp/keil.qbs b/share/qbs/modules/cpp/keil.qbs index c57eb6751..7a994d7ea 100644 --- a/share/qbs/modules/cpp/keil.qbs +++ b/share/qbs/modules/cpp/keil.qbs @@ -52,6 +52,7 @@ CppModule { } qbs.architecture: keilProbe.found ? keilProbe.architecture : original + qbs.targetPlatform: "none" compilerVersionMajor: keilProbe.versionMajor compilerVersionMinor: keilProbe.versionMinor @@ -125,6 +126,7 @@ CppModule { id: applicationLinker multiplex: true inputs: ["obj", "linkerscript"] + inputsFromDependencies: ["staticlibrary"] outputFileTags: ["application", "mem_map"] outputArtifacts: KEIL.applicationLinkerOutputArtifacts(product) prepare: KEIL.prepareLinker.apply(KEIL, arguments) diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js index 72ee08fe9..df1f5eb5b 100644 --- a/share/qbs/modules/cpp/msvc.js +++ b/share/qbs/modules/cpp/msvc.js @@ -245,6 +245,9 @@ function prepareCompiler(project, product, inputs, outputs, input, output, expli if (product.cpp.debugInformation && product.cpp.separateDebugInformation) args.push("/Fd" + product.targetName + ".cl" + product.cpp.debugInfoSuffix); + if (input.cpp.generateCompilerListingFiles) + args.push("/Fa" + FileInfo.toWindowsSeparators(outputs.lst[0].filePath)); + var objectMap = outputs.obj || outputs.intermediate_obj var objOutput = objectMap ? objectMap[0] : undefined args.push('/Fo' + FileInfo.toWindowsSeparators(objOutput.filePath)) diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js index 49d74cb63..c34db1b22 100644 --- a/share/qbs/modules/cpp/sdcc.js +++ b/share/qbs/modules/cpp/sdcc.js @@ -238,14 +238,14 @@ function collectLibraryDependencies(product) { return result; } -function compilerOutputArtifacts(input) { +function compilerOutputArtifacts(input, useListing) { var obj = { fileTags: ["obj"], filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + input.cpp.objectSuffix }; - // We need to use the asm_adb, lst, asm_src, asm_sym and rst_data + // We need to use the asm_adb, asm_src, asm_sym and rst_data // artifacts without of any conditions. Because SDCC always generates // it (and seems, this behavior can not be disabled for SDCC). var asm_adb = { @@ -253,11 +253,6 @@ function compilerOutputArtifacts(input) { filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + ".adb" }; - var lst = { - fileTags: ["lst"], - filePath: Utilities.getHash(input.baseDir) + "/" - + input.fileName + ".lst" - }; var asm_src = { fileTags: ["asm_src"], filePath: Utilities.getHash(input.baseDir) + "/" @@ -273,7 +268,15 @@ function compilerOutputArtifacts(input) { filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + ".rst" }; - return [obj, asm_adb, lst, asm_src, asm_sym, rst_data]; + var artifacts = [obj, asm_adb, asm_src, asm_sym, rst_data]; + if (useListing) { + artifacts.push({ + fileTags: ["lst"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".lst" + }); + } + return artifacts; } function applicationLinkerOutputArtifacts(product) { @@ -455,7 +458,7 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { return args; } -function linkerFlags(project, product, input, outputs) { +function linkerFlags(project, product, inputs, outputs) { var args = []; // Target MCU flag. @@ -534,7 +537,7 @@ function linkerFlags(project, product, input, outputs) { return args; } -function archiverFlags(project, product, input, outputs) { +function archiverFlags(project, product, inputs, outputs) { var args = ["-rc"]; args.push(outputs.staticlibrary[0].filePath); if (inputs.obj) @@ -584,17 +587,42 @@ function prepareAssembler(project, product, inputs, outputs, input, output, expl } function prepareLinker(project, product, inputs, outputs, input, output) { + var cmds = []; var primaryOutput = outputs.application[0]; - var args = linkerFlags(project, product, input, outputs); + var args = linkerFlags(project, product, inputs, outputs); var linkerPath = effectiveLinkerPath(product); var cmd = new Command(linkerPath, args); cmd.description = "linking " + primaryOutput.fileName; cmd.highlight = "linker"; - return [cmd]; + cmds.push(cmd); + + // It is a workaround which removes the generated listing files + // if it is disabled by cpp.generateCompilerListingFiles property. + // Reason is that the SDCC compiler does not have an option to + // disable generation for a listing files. Besides, the SDCC + // compiler use this files and for the linking. So, we can to + // remove a listing files only after the linking completes. + if (!product.cpp.generateCompilerListingFiles) { + cmd = new JavaScriptCommand(); + cmd.objectPaths = inputs.obj.map(function(a) { return a.filePath; }); + cmd.objectSuffix = product.cpp.objectSuffix; + cmd.sourceCode = function() { + objectPaths.forEach(function(objectPath) { + if (!objectPath.endsWith(".c" + objectSuffix)) + return; // Skip the assembler objects. + var listingPath = FileInfo.joinPaths( + FileInfo.path(objectPath), + FileInfo.completeBaseName(objectPath) + ".lst"); + File.remove(listingPath); + }); + }; + cmds.push(cmd); + } + return cmds; } function prepareArchiver(project, product, inputs, outputs, input, output) { - var args = archiverFlags(project, product, input, outputs); + var args = archiverFlags(project, product, inputs, outputs); var archiverPath = product.cpp.archiverPath; var cmd = new Command(archiverPath, args); cmd.description = "linking " + output.fileName; diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs index a8d0df3c9..3c5be7cdd 100644 --- a/share/qbs/modules/cpp/sdcc.qbs +++ b/share/qbs/modules/cpp/sdcc.qbs @@ -52,6 +52,7 @@ CppModule { } qbs.architecture: sdccProbe.found ? sdccProbe.architecture : original + qbs.targetPlatform: "none" compilerVersionMajor: sdccProbe.versionMajor compilerVersionMinor: sdccProbe.versionMinor @@ -100,7 +101,7 @@ CppModule { id: assembler inputs: ["asm"] outputFileTags: ["obj", "asm_adb", "lst", "asm_src", "asm_sym", "rst_data"] - outputArtifacts: SDCC.compilerOutputArtifacts(input) + outputArtifacts: SDCC.compilerOutputArtifacts(input, true) prepare: SDCC.prepareAssembler.apply(SDCC, arguments) } @@ -114,7 +115,8 @@ CppModule { inputs: ["cpp", "c"] auxiliaryInputs: ["hpp"] outputFileTags: ["obj", "asm_adb", "lst", "asm_src", "asm_sym", "rst_data"] - outputArtifacts: SDCC.compilerOutputArtifacts(input) + outputArtifacts: SDCC.compilerOutputArtifacts( + input, input.cpp.generateCompilerListingFiles) prepare: SDCC.prepareCompiler.apply(SDCC, arguments) } diff --git a/share/qbs/modules/cpp/windows-msvc-base.qbs b/share/qbs/modules/cpp/windows-msvc-base.qbs index 34132ac49..e88c3f15f 100644 --- a/share/qbs/modules/cpp/windows-msvc-base.qbs +++ b/share/qbs/modules/cpp/windows-msvc-base.qbs @@ -149,15 +149,23 @@ CppModule { auxiliaryInputs: ["hpp"] explicitlyDependsOn: ["c_pch", "cpp_pch"] - outputFileTags: ["obj", "intermediate_obj"] + outputFileTags: ["obj", "intermediate_obj", "lst"] outputArtifacts: { var tags = input.fileTags.contains("cpp_intermediate_object") ? ["intermediate_obj"] : ["obj"]; - return [{ + var artifacts = []; + artifacts.push({ fileTags: tags, filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + ".obj" - }]; + }); + if (input.cpp.generateCompilerListingFiles) { + artifacts.push({ + fileTags: ["lst"], + filePath: Utilities.getHash(input.baseDir) + "/" + input.fileName + ".lst" + }); + } + return artifacts; } prepare: { diff --git a/src/app/qbs-setup-android/qbs-setup-android.qbs b/src/app/qbs-setup-android/qbs-setup-android.qbs index edadd5dd1..949c07c45 100644 --- a/src/app/qbs-setup-android/qbs-setup-android.qbs +++ b/src/app/qbs-setup-android/qbs-setup-android.qbs @@ -12,6 +12,11 @@ QbsApp { Group { name: "MinGW specific files" condition: qbs.toolchain.contains("mingw") - files: ["qbs-setup-android.exe.manifest", "qbs-setup-android.rc"] + files: "qbs-setup-android.rc" + Group { + name: "qbs-setup-android manifest" + files: "qbs-setup-android.exe.manifest" + fileTags: [] // the manifest is referenced by the rc file + } } } diff --git a/src/app/qbs-setup-qt/qbs-setup-qt.qbs b/src/app/qbs-setup-qt/qbs-setup-qt.qbs index f4cd9d6b8..44f2b7f05 100644 --- a/src/app/qbs-setup-qt/qbs-setup-qt.qbs +++ b/src/app/qbs-setup-qt/qbs-setup-qt.qbs @@ -12,7 +12,12 @@ QbsApp { Group { name: "MinGW specific files" condition: qbs.toolchain.contains("mingw") - files: ["qbs-setup-qt.exe.manifest", "qbs-setup-qt.rc"] + files: "qbs-setup-qt.rc" + Group { + name: "qbs-setup-qt manifest" + files: "qbs-setup-qt.exe.manifest" + fileTags: [] // the manifest is referenced by the rc file + } } } diff --git a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs index 554891fc4..3bc72700f 100644 --- a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs +++ b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs @@ -27,6 +27,11 @@ QbsApp { Group { name: "MinGW specific files" condition: qbs.toolchain.contains("mingw") - files: ["qbs-setup-toolchains.exe.manifest", "qbs-setup-toolchains.rc"] + files: "qbs-setup-toolchains.rc" + Group { + name: "qbs-setup-toolchains manifest" + files: "qbs-setup-toolchains.exe.manifest" + fileTags: [] // the manifest is referenced by the rc file + } } } diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index 09bfb00e8..1c331c60d 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -3844,7 +3844,7 @@ QVariantMap ModuleLoader::moduleProviderConfig(ModuleLoader::ProductContext &pro product.theModuleProviderConfig.insert(name.toString(), m); } }; - configItemValue->item()->setScope(product.scope); + configItemValue->item()->setScope(product.item); collectMap(configItemValue->item(), QualifiedId()); } for (auto it = product.moduleProperties.begin(); it != product.moduleProperties.end(); ++it) { diff --git a/tests/auto/blackbox/testdata-android/teapot/teapot.qbs b/tests/auto/blackbox/testdata-android/teapot/teapot.qbs index 2b5cb8aba..30cfbb820 100644 --- a/tests/auto/blackbox/testdata-android/teapot/teapot.qbs +++ b/tests/auto/blackbox/testdata-android/teapot/teapot.qbs @@ -133,6 +133,7 @@ Project { FileTagger { patterns: ["*.inl"]; fileTags: ["hpp"] } + version: "2.0" Android.sdk.apkBaseName: name Android.sdk.packageName: "com.sample.teapot" Android.sdk.sourceSetDir: teapotProbe.dir diff --git a/tests/auto/blackbox/testdata-baremetal/defines/defines.qbs b/tests/auto/blackbox/testdata-baremetal/defines/defines.qbs new file mode 100644 index 000000000..b257a8a4b --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/defines/defines.qbs @@ -0,0 +1,6 @@ +import "../BareMetalApplication.qbs" as BareMetalApplication + +BareMetalApplication { + cpp.defines: ["FOO", "BAR"] + files: ["main.c"] +} diff --git a/tests/auto/blackbox/testdata-baremetal/defines/main.c b/tests/auto/blackbox/testdata-baremetal/defines/main.c new file mode 100644 index 000000000..d2d4769e4 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/defines/main.c @@ -0,0 +1,11 @@ +#ifndef FOO +#error FOO missing! +#endif +#ifndef BAR +#error BAR missing! +#endif + +int main(void) +{ + return 0; +} diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs new file mode 100644 index 000000000..46faf9440 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/do-not-generate-compiler-listing.qbs @@ -0,0 +1,30 @@ +import "../BareMetalApplication.qbs" as BareMetalApplication + +BareMetalApplication { + condition: { + if (qbs.toolchainType === "sdcc") + return true; + if (qbs.toolchainType === "msvc") + return true; + if (qbs.toolchainType === "clang-cl") + return true; + if (qbs.toolchainType === "iar") + return true; + if (qbs.toolchainType === "keil") { + if (qbs.architecture === "mcs51" + || qbs.architecture === "mcs251" + || qbs.architecture === "c166") { + return true; + } + if (cpp.compilerName.startsWith("armcc")) { + console.info("using short listing file names"); + return true; + } + } + console.info("unsupported toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return false; + } + cpp.generateCompilerListingFiles: false + files: ["main.c", "fun.c"] +} diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/fun.c b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/fun.c new file mode 100644 index 000000000..3b8c8f2f4 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/fun.c @@ -0,0 +1,4 @@ +int f(void) +{ + return 0; +} diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/main.c b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/main.c new file mode 100644 index 000000000..2c3d7726c --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-compiler-listing/main.c @@ -0,0 +1,6 @@ +extern int f(void); + +int main(void) +{ + return f(); +} diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-linker-map/do-not-generate-linker-map.qbs b/tests/auto/blackbox/testdata-baremetal/do-not-generate-linker-map/do-not-generate-linker-map.qbs new file mode 100644 index 000000000..f0095a4a6 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-linker-map/do-not-generate-linker-map.qbs @@ -0,0 +1,16 @@ +import "../BareMetalApplication.qbs" as BareMetalApplication + +BareMetalApplication { + condition: { + if (qbs.toolchainType === "sdcc") { + console.info("unsupported toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return false; + } + console.info("current toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return true; + } + cpp.generateLinkerMapFile: false + files: ["main.c"] +} diff --git a/tests/auto/blackbox/testdata-baremetal/do-not-generate-linker-map/main.c b/tests/auto/blackbox/testdata-baremetal/do-not-generate-linker-map/main.c new file mode 100644 index 000000000..58fe69254 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/do-not-generate-linker-map/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs new file mode 100644 index 000000000..6fbbb8647 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs @@ -0,0 +1,48 @@ +import "../BareMetalApplication.qbs" as BareMetalApplication +import "../BareMetalStaticLibrary.qbs" as BareMetalStaticLibrary + +Project { + condition: { + // The KEIL C51/C251/C166 toolchains support only a + // full paths to the external libraries. + if (qbs.toolchainType === "keil") { + if (qbs.architecture === "mcs51" + || qbs.architecture === "mcs251" + || qbs.architecture === "c166") { + console.info("unsupported toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return false; + } + } + return true; + } + property string outputLibrariesDirectory: sourceDirectory + "/libs" + BareMetalStaticLibrary { + name: "lib-a" + destinationDirectory: project.outputLibrariesDirectory + Depends { name: "cpp" } + Properties { + condition: qbs.targetOS.contains("darwin") + bundle.isBundle: false + } + files: ["lib-a.c"] + } + BareMetalStaticLibrary { + name: "lib-b" + destinationDirectory: project.outputLibrariesDirectory + Depends { name: "cpp" } + Depends { name: "lib-a" } + Properties { + condition: qbs.targetOS.contains("darwin") + bundle.isBundle: false + } + files: ["lib-b.c"] + } + BareMetalApplication { + Depends { name: "lib-a"; cpp.link: false } + Depends { name: "lib-b"; cpp.link: false } + files: ["main.c"] + cpp.libraryPaths: [project.outputLibrariesDirectory] + cpp.staticLibraries: ["lib-b", "lib-a"] + } +} diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-a.c b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-a.c new file mode 100644 index 000000000..13401861f --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-a.c @@ -0,0 +1,4 @@ +int a(void) +{ + return 0; +} diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-b.c b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-b.c new file mode 100644 index 000000000..5d45b8175 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-b.c @@ -0,0 +1,6 @@ +extern int a(void); + +int b(void) +{ + return a(); +} diff --git a/tests/auto/blackbox/testdata-baremetal/external-static-libraries/main.c b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/main.c new file mode 100644 index 000000000..84ef5e51e --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/external-static-libraries/main.c @@ -0,0 +1,6 @@ +extern int b(); + +int main(void) +{ + return b(); +} diff --git a/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/fun.c b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/fun.c new file mode 100644 index 000000000..3b8c8f2f4 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/fun.c @@ -0,0 +1,4 @@ +int f(void) +{ + return 0; +} diff --git a/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs new file mode 100644 index 000000000..2596b441d --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/generate-compiler-listing.qbs @@ -0,0 +1,30 @@ +import "../BareMetalApplication.qbs" as BareMetalApplication + +BareMetalApplication { + condition: { + if (qbs.toolchainType === "sdcc") + return true; + if (qbs.toolchainType === "msvc") + return true; + if (qbs.toolchainType === "clang-cl") + return true; + if (qbs.toolchainType === "iar") + return true; + if (qbs.toolchainType === "keil") { + if (qbs.architecture === "mcs51" + || qbs.architecture === "mcs251" + || qbs.architecture === "c166") { + return true; + } + if (cpp.compilerName.startsWith("armcc")) { + console.info("using short listing file names"); + return true; + } + } + console.info("unsupported toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return false; + } + cpp.generateCompilerListingFiles: true + files: ["main.c", "fun.c"] +} diff --git a/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/main.c b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/main.c new file mode 100644 index 000000000..2c3d7726c --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/generate-compiler-listing/main.c @@ -0,0 +1,6 @@ +extern int f(void); + +int main(void) +{ + return f(); +} diff --git a/tests/auto/blackbox/testdata-baremetal/generate-linker-map/generate-linker-map.qbs b/tests/auto/blackbox/testdata-baremetal/generate-linker-map/generate-linker-map.qbs new file mode 100644 index 000000000..854391abb --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/generate-linker-map/generate-linker-map.qbs @@ -0,0 +1,16 @@ +import "../BareMetalApplication.qbs" as BareMetalApplication + +BareMetalApplication { + condition: { + if (qbs.toolchainType === "sdcc") { + console.info("unsupported toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return false; + } + console.info("current toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return true; + } + cpp.generateLinkerMapFile: true + files: ["main.c"] +} diff --git a/tests/auto/blackbox/testdata-baremetal/generate-linker-map/main.c b/tests/auto/blackbox/testdata-baremetal/generate-linker-map/main.c new file mode 100644 index 000000000..58fe69254 --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/generate-linker-map/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/tests/auto/blackbox/testdata-baremetal/target-platform/target-platform.qbs b/tests/auto/blackbox/testdata-baremetal/target-platform/target-platform.qbs new file mode 100644 index 000000000..50be8e91a --- /dev/null +++ b/tests/auto/blackbox/testdata-baremetal/target-platform/target-platform.qbs @@ -0,0 +1,18 @@ +Product { + Depends { name: "cpp" } + condition: { + if (qbs.toolchainType === "keil" + || qbs.toolchainType === "iar" + || qbs.toolchainType === "sdcc") { + var hasNoPlatform = (qbs.targetPlatform === "none"); + var hasNoOS = (qbs.targetOS.length === 1 && qbs.targetOS[0] === "none"); + console.info("has no platform: " + hasNoPlatform); + console.info("has no os: " + hasNoOS); + } else { + console.info("unsupported toolset: %%" + + qbs.toolchainType + "%%, %%" + qbs.architecture + "%%"); + return false; + } + return true; + } +} diff --git a/tests/auto/blackbox/testdata/module-providers/module-providers.qbs b/tests/auto/blackbox/testdata/module-providers/module-providers.qbs index 1ffa49038..0322cc0e0 100644 --- a/tests/auto/blackbox/testdata/module-providers/module-providers.qbs +++ b/tests/auto/blackbox/testdata/module-providers/module-providers.qbs @@ -12,7 +12,7 @@ Project { Depends { name: "mygenerator.module2" } Depends { name: "othergenerator" } moduleProviders.mygenerator.chooseLettersFrom: project.beginning - moduleProviders.othergenerator.someDefines: "app1" + moduleProviders.othergenerator.someDefines: name files: "main.cpp" } CppApplication { diff --git a/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs b/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs index 46f89cb60..13c69f72f 100644 --- a/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs +++ b/tests/auto/blackbox/testdata/path-probe/BaseApp.qbs @@ -39,6 +39,7 @@ CppApplication { property pathList inputSearchPaths property var inputNameFilter property var inputCandidateFilter + property stringList inputEnvironmentPaths property stringList outputFilePaths property var outputCandidatePaths @@ -52,6 +53,7 @@ CppApplication { candidateFilter: inputCandidateFilter searchPaths: inputSearchPaths platformSearchPaths: [] + environmentPaths: inputEnvironmentPaths } property bool validate: { diff --git a/tests/auto/blackbox/testdata/path-probe/environment-paths.qbs b/tests/auto/blackbox/testdata/path-probe/environment-paths.qbs new file mode 100644 index 000000000..fca824bfb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/environment-paths.qbs @@ -0,0 +1,10 @@ +import qbs.FileInfo + +BaseApp { + inputNames: "tool" + inputSearchPaths: ["bin", "usr/bin"] + // env takes precedence + inputEnvironmentPaths: "SEARCH_PATH" + outputFilePaths: ["usr/bin/tool"] + outputCandidatePaths: [["usr/bin/tool"]] +} diff --git a/tests/auto/blackbox/testdata/path-probe/usr/bin/tool b/tests/auto/blackbox/testdata/path-probe/usr/bin/tool new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/blackbox/testdata/path-probe/usr/bin/tool diff --git a/tests/auto/blackbox/testdata/product-in-exported-module/modules/m/m.qbs b/tests/auto/blackbox/testdata/product-in-exported-module/modules/m/m.qbs new file mode 100644 index 000000000..0e79d0abe --- /dev/null +++ b/tests/auto/blackbox/testdata/product-in-exported-module/modules/m/m.qbs @@ -0,0 +1,3 @@ +Module { + Depends { name: "dummy"; condition: { console.info("product: " + product.name); return false; } } +} diff --git a/tests/auto/blackbox/testdata/product-in-exported-module/product-in-exported-module.qbs b/tests/auto/blackbox/testdata/product-in-exported-module/product-in-exported-module.qbs new file mode 100644 index 000000000..f978aa778 --- /dev/null +++ b/tests/auto/blackbox/testdata/product-in-exported-module/product-in-exported-module.qbs @@ -0,0 +1,10 @@ +Project { + Product { + name: "p" + Depends { name: "dep" } + } + Product { + name: "dep" + Export { Depends { name: "m" } } + } +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 66f195ff0..f9777d90b 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -2965,6 +2965,7 @@ void TestBlackbox::pathProbe_data() QTest::newRow("mult-files-mult-suffixes") << QString("mult-files-mult-suffixes.qbs") << true; QTest::newRow("name-filter") << QString("name-filter.qbs") << true; QTest::newRow("candidate-filter") << QString("candidate-filter.qbs") << true; + QTest::newRow("environment-paths") << QString("environment-paths.qbs") << true; } void TestBlackbox::pathProbe() @@ -2976,6 +2977,7 @@ void TestBlackbox::pathProbe() QbsRunParameters buildParams("build", QStringList{"-f", projectFile}); buildParams.expectFailure = !successExpected; + buildParams.environment.insert("SEARCH_PATH", "usr/bin"); QCOMPARE(runQbs(buildParams) == 0, successExpected); if (!successExpected) QVERIFY2(m_qbsStderr.contains("Probe failed to find files"), m_qbsStderr); @@ -5697,6 +5699,14 @@ void TestBlackbox::productDependenciesByType() QVERIFY(apps.empty()); } +void TestBlackbox::productInExportedModule() +{ + QDir::setCurrent(testDataDir + "/product-in-exported-module"); + QCOMPARE(runQbs(), 0); + QEXPECT_FAIL(nullptr, "QBS-1576", Abort); + QVERIFY2(!m_qbsStdout.contains("product: dep"), m_qbsStdout.constData()); +} + void TestBlackbox::properQuoting() { QDir::setCurrent(testDataDir + "/proper quoting"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index e958a113c..578ccd3ad 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -242,6 +242,7 @@ private slots: void probesAndArrayProperties(); void probesInNestedModules(); void productDependenciesByType(); + void productInExportedModule(); void productProperties(); void propertyAssignmentOnNonPresentModule(); void propertyAssignmentInFailedModule(); diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.cpp b/tests/auto/blackbox/tst_blackboxbaremetal.cpp index 2f6169ff9..41f50a0ed 100644 --- a/tests/auto/blackbox/tst_blackboxbaremetal.cpp +++ b/tests/auto/blackbox/tst_blackboxbaremetal.cpp @@ -34,10 +34,10 @@ #include <QtCore/qregularexpression.h> -static bool extractUnsupportedToolset(const QByteArray &output, - QByteArray &toolchain, QByteArray &architecture) +static bool extractToolset(const QByteArray &output, + QByteArray &toolchain, QByteArray &architecture) { - const QRegularExpression re("%%(\\w+)%%, %%(\\w+)%%"); + const QRegularExpression re("%%([\\w\\-]+)%%, %%(\\w+)%%"); QRegularExpressionMatchIterator it = re.globalMatch(output); if (!it.hasNext()) return false; @@ -47,11 +47,43 @@ static bool extractUnsupportedToolset(const QByteArray &output, return true; } +static QByteArray unsupportedToolsetMessage(const QByteArray &output) +{ + QByteArray toolchain; + QByteArray architecture; + extractToolset(output, toolchain, architecture); + return "Unsupported toolchain '" + toolchain + + "' for architecture '" + architecture + "'"; +} + +static QString linkerMapFileExtension(const QByteArray &toolchain, const QByteArray &architecture) +{ + if (toolchain == "keil") { + if (architecture == "mcs51") + return QStringLiteral(".m51"); + if (architecture == "c166") + return QStringLiteral(".m66"); + } + return QStringLiteral(".map"); +} + TestBlackboxBareMetal::TestBlackboxBareMetal() : TestBlackboxBase (SRCDIR "/testdata-baremetal", "blackbox-baremetal") { } +void TestBlackboxBareMetal::targetPlatform() +{ + QDir::setCurrent(testDataDir + "/target-platform"); + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); + if (m_qbsStdout.contains("unsupported toolset:")) + QSKIP(unsupportedToolsetMessage(m_qbsStdout)); + const bool hasNoPlatform = m_qbsStdout.contains("has no platform: true"); + QCOMPARE(hasNoPlatform, true); + const bool hasNoOS = m_qbsStdout.contains("has no os: true"); + QCOMPARE(hasNoOS, true); +} + void TestBlackboxBareMetal::application_data() { QTest::addColumn<QString>("testPath"); @@ -65,15 +97,9 @@ void TestBlackboxBareMetal::application() QFETCH(QString, testPath); QDir::setCurrent(testDataDir + testPath); QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); - if (!m_qbsStdout.contains("unsupported toolset:")) { - QCOMPARE(runQbs(), 0); - } else { - QByteArray toolchain; - QByteArray architecture; - extractUnsupportedToolset(m_qbsStdout, toolchain, architecture); - QSKIP("Unsupported toolchain '" + toolchain - + "' for architecture '" + architecture + "'"); - } + if (m_qbsStdout.contains("unsupported toolset:")) + QSKIP(unsupportedToolsetMessage(m_qbsStdout)); + QCOMPARE(runQbs(), 0); } void TestBlackboxBareMetal::staticLibraryDependencies() @@ -89,6 +115,15 @@ void TestBlackboxBareMetal::staticLibraryDependencies() QVERIFY(output.contains("lib-e")); } +void TestBlackboxBareMetal::externalStaticLibraries() +{ + QDir::setCurrent(testDataDir + "/external-static-libraries"); + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); + if (m_qbsStdout.contains("unsupported toolset:")) + QSKIP(unsupportedToolsetMessage(m_qbsStdout)); + QCOMPARE(runQbs(), 0); +} + void TestBlackboxBareMetal::userIncludePaths() { QDir::setCurrent(testDataDir + "/user-include-paths"); @@ -111,15 +146,74 @@ void TestBlackboxBareMetal::preincludeHeaders() { QDir::setCurrent(testDataDir + "/preinclude-headers"); QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); - if (!m_qbsStdout.contains("unsupported toolset:")) { - QCOMPARE(runQbs(), 0); - } else { - QByteArray toolchain; - QByteArray architecture; - extractUnsupportedToolset(m_qbsStdout, toolchain, architecture); - QSKIP("Unsupported toolchain '" + toolchain - + "' for architecture '" + architecture + "'"); - } + if (m_qbsStdout.contains("unsupported toolset:")) + QSKIP(unsupportedToolsetMessage(m_qbsStdout)); + QCOMPARE(runQbs(), 0); +} + +void TestBlackboxBareMetal::defines() +{ + QDir::setCurrent(testDataDir + "/defines"); + QCOMPARE(runQbs(), 0); +} + +void TestBlackboxBareMetal::compilerListingFiles_data() +{ + QTest::addColumn<QString>("testPath"); + QTest::addColumn<bool>("generateListing"); + QTest::newRow("do-not-generate-compiler-listing") << "/do-not-generate-compiler-listing" << false; + QTest::newRow("generate-compiler-listing") << "/generate-compiler-listing" << true; +} + +void TestBlackboxBareMetal::compilerListingFiles() +{ + QFETCH(QString, testPath); + QFETCH(bool, generateListing); + QDir::setCurrent(testDataDir + testPath); + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); + if (m_qbsStdout.contains("unsupported toolset:")) + QSKIP(unsupportedToolsetMessage(m_qbsStdout)); + QCOMPARE(runQbs(), 0); + const bool isShortListingNames = m_qbsStdout.contains("using short listing file names"); + const QString productName = testPath.mid(1); + const QString productBuildDir = relativeProductBuildDir(productName); + const QString hash = inputDirHash("."); + const QString mainListing = productBuildDir + "/" + hash + (isShortListingNames ? "/main.lst" : "/main.c.lst"); + QCOMPARE(regularFileExists(mainListing), generateListing); + const QString funListing = productBuildDir + "/" + hash + (isShortListingNames ? "/fun.lst" : "/fun.c.lst"); + QCOMPARE(regularFileExists(funListing), generateListing); +} + +void TestBlackboxBareMetal::linkerMapFile_data() +{ + QTest::addColumn<QString>("testPath"); + QTest::addColumn<bool>("generateMap"); + QTest::newRow("do-not-generate-linker-map") << "/do-not-generate-linker-map" << false; + QTest::newRow("generate-linker-map") << "/generate-linker-map" << true; +} + +void TestBlackboxBareMetal::linkerMapFile() +{ + QFETCH(QString, testPath); + QFETCH(bool, generateMap); + QDir::setCurrent(testDataDir + testPath); + QCOMPARE(runQbs(QbsRunParameters("resolve", QStringList("-n"))), 0); + if (m_qbsStdout.contains("unsupported toolset:")) + QSKIP(unsupportedToolsetMessage(m_qbsStdout)); + if (!m_qbsStdout.contains("current toolset:")) + QFAIL("No current toolset pattern exists"); + + QByteArray toolchain; + QByteArray architecture; + if (!extractToolset(m_qbsStdout, toolchain, architecture)) + QFAIL("Unable to extract current toolset"); + + QCOMPARE(runQbs(), 0); + const QString productName = testPath.mid(1); + const QString productBuildDir = relativeProductBuildDir(productName); + const auto extension = linkerMapFileExtension(toolchain, architecture); + const QString linkerMap = productBuildDir + "/" + productName + extension; + QCOMPARE(regularFileExists(linkerMap), generateMap); } QTEST_MAIN(TestBlackboxBareMetal) diff --git a/tests/auto/blackbox/tst_blackboxbaremetal.h b/tests/auto/blackbox/tst_blackboxbaremetal.h index da31002e1..3695cb1c3 100644 --- a/tests/auto/blackbox/tst_blackboxbaremetal.h +++ b/tests/auto/blackbox/tst_blackboxbaremetal.h @@ -41,10 +41,13 @@ public: TestBlackboxBareMetal(); private slots: + void targetPlatform(); + void application_data(); void application(); void staticLibraryDependencies(); + void externalStaticLibraries(); void userIncludePaths(); void systemIncludePaths(); @@ -52,6 +55,14 @@ private slots: void preincludeHeaders(); + void defines(); + + void compilerListingFiles_data(); + void compilerListingFiles(); + + void linkerMapFile_data(); + void linkerMapFile(); + private: }; |