From aec975a3f95f905b2d63ea1500ace28eddea7b9e Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Thu, 26 Sep 2019 18:05:21 +0300 Subject: baremetal: Fix assembler command for SDCC compiler We need to use the assembler command in the followiong format: Usage: [-Options] outfile file1 [file2 file3 ...] Besides, we have added an additional assembler option '-l' to explicitly generate of a listing file; without of this option the linking fails. Change-Id: I0240b354f44edac94e3e4305fe6b1a4c34ca4bf9 Reviewed-by: Richard Weickelt Reviewed-by: Christian Kandeler --- share/qbs/modules/cpp/sdcc.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js index 2f148d2c2..9e7c8097e 100644 --- a/share/qbs/modules/cpp/sdcc.js +++ b/share/qbs/modules/cpp/sdcc.js @@ -252,8 +252,6 @@ function assemblerFlags(project, product, input, output, explicitlyDependsOn) { var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags)); var args = []; - args.push(input.filePath); - args.push("-o", output.filePath); var allIncludePaths = []; var systemIncludePaths = input.cpp.systemIncludePaths; @@ -267,6 +265,10 @@ function assemblerFlags(project, product, input, output, explicitlyDependsOn) { args = args.concat(ModUtils.moduleProperty(input, "platformFlags", tag), ModUtils.moduleProperty(input, "flags", tag), ModUtils.moduleProperty(input, "driverFlags", tag)); + + args.push("-ol"); + args.push(output.filePath); + args.push(input.filePath); return args; } -- cgit v1.2.3 From de2a49bb6d90ac5bcd414a3a30cce7db212e0c80 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Thu, 26 Sep 2019 18:18:06 +0300 Subject: baremetal: Handle missed 'driverLinkerFlags' property for SDCC Change-Id: Ibd58a4bdf6c05af79c0d847ccaacaec5381b35d5 Reviewed-by: Christian Kandeler --- share/qbs/modules/cpp/sdcc.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js index 9e7c8097e..c84ec0f5d 100644 --- a/share/qbs/modules/cpp/sdcc.js +++ b/share/qbs/modules/cpp/sdcc.js @@ -332,7 +332,9 @@ function linkerFlags(project, product, input, outputs) { var escapedLinkerFlags = escapeLinkerFlags(product, escapableLinkerFlags); if (escapedLinkerFlags) Array.prototype.push.apply(args, escapedLinkerFlags); - + var driverLinkerFlags = useCompilerDriver ? product.cpp.driverLinkerFlags : undefined; + if (driverLinkerFlags) + Array.prototype.push.apply(args, driverLinkerFlags); return args; } -- cgit v1.2.3 From 51d8271a301b5767f797e57e73ba425a64b3a359 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Fri, 27 Sep 2019 18:46:42 +0300 Subject: baremetal: Fix missed linker artifact for C51 compiler We need to add a file with extension '.m51' which is a map file, generated by BL51 linker for 8051 architecture. Also the artifacts creation code is refactored and improved a bit. Change-Id: I49b487acf87263dde818696d5a3478333839c30b Reviewed-by: Christian Kandeler --- share/qbs/modules/cpp/keil.js | 39 ++++++++++++++++++++++++- share/qbs/modules/cpp/keil.qbs | 66 ++++++++---------------------------------- 2 files changed, 50 insertions(+), 55 deletions(-) diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js index c19fdd738..82c4400c0 100644 --- a/share/qbs/modules/cpp/keil.js +++ b/share/qbs/modules/cpp/keil.js @@ -33,6 +33,7 @@ var Environment = require("qbs.Environment"); var File = require("qbs.File"); var FileInfo = require("qbs.FileInfo"); var ModUtils = require("qbs.ModUtils"); +var PathTools = require("qbs.PathTools"); var Process = require("qbs.Process"); var TemporaryDir = require("qbs.TemporaryDir"); var TextFile = require("qbs.TextFile"); @@ -246,6 +247,42 @@ function filterStdOutput(cmd) { }; } +function compilerOutputArtifacts(input) { + var obj = { + fileTags: ["obj"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + input.cpp.objectSuffix + }; + return [obj]; +} + +function applicationLinkerOutputArtifacts(product) { + var app = { + fileTags: ["application"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + PathTools.applicationFilePath(product)) + }; + var mem_map = { + fileTags: ["mem_map"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + product.targetName + + (product.cpp.architecture === "mcs51" ? ".m51" : ".map")) + }; + return [app, mem_map] +} + +function staticLibraryLinkerOutputArtifacts(product) { + var staticLib = { + fileTags: ["staticlibrary"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + PathTools.staticLibraryFilePath(product)) + }; + return [staticLib] +} + function compilerFlags(project, product, input, output, explicitlyDependsOn) { // Determine which C-language we"re compiling. var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags)); @@ -474,7 +511,7 @@ function linkerFlags(project, product, input, outputs) { args.push("--output", outputs.application[0].filePath); if (product.cpp.generateMapFile) - args.push("--list", outputs.map_file[0].filePath); + args.push("--list", outputs.mem_map[0].filePath); var libraryPaths = product.cpp.libraryPaths; if (libraryPaths) diff --git a/share/qbs/modules/cpp/keil.qbs b/share/qbs/modules/cpp/keil.qbs index 10bc39e12..c87bf05f8 100644 --- a/share/qbs/modules/cpp/keil.qbs +++ b/share/qbs/modules/cpp/keil.qbs @@ -32,9 +32,7 @@ import qbs 1.0 import qbs.File import qbs.FileInfo import qbs.ModUtils -import qbs.PathTools import qbs.Probes -import qbs.Utilities import "keil.js" as KEIL CppModule { @@ -164,14 +162,9 @@ CppModule { Rule { id: assembler inputs: ["asm"] - - Artifact { - fileTags: ["obj"] - filePath: Utilities.getHash(input.baseDir) + "/" - + input.fileName + input.cpp.objectSuffix - } - - prepare: KEIL.prepareAssembler.apply(KEIL, arguments); + outputFileTags: ["obj"] + outputArtifacts: KEIL.compilerOutputArtifacts(input) + prepare: KEIL.prepareAssembler.apply(KEIL, arguments) } FileTagger { @@ -190,47 +183,18 @@ CppModule { id: compiler inputs: ["cpp", "c"] auxiliaryInputs: ["hpp"] - - Artifact { - fileTags: ["obj"] - filePath: Utilities.getHash(input.baseDir) + "/" - + input.fileName + input.cpp.objectSuffix - } - - prepare: KEIL.prepareCompiler.apply(KEIL, arguments); + outputFileTags: ["obj"] + outputArtifacts: KEIL.compilerOutputArtifacts(input) + prepare: KEIL.prepareCompiler.apply(KEIL, arguments) } Rule { id: applicationLinker multiplex: true inputs: ["obj", "linkerscript"] - - outputFileTags: { - var tags = ["application"]; - if (product.moduleProperty("cpp", "generateMapFile")) - tags.push("map_file"); - return tags; - } - outputArtifacts: { - var app = { - fileTags: ["application"], - filePath: FileInfo.joinPaths( - product.destinationDirectory, - PathTools.applicationFilePath(product)) - }; - var artifacts = [app]; - if (product.cpp.generateMapFile) { - artifacts.push({ - fileTags: ["map_file"], - filePath: FileInfo.joinPaths( - product.destinationDirectory, - product.targetName + ".map") - }); - } - return artifacts; - } - - prepare:KEIL.prepareLinker.apply(KEIL, arguments); + outputFileTags: ["application", "mem_map"] + outputArtifacts: KEIL.applicationLinkerOutputArtifacts(product) + prepare: KEIL.prepareLinker.apply(KEIL, arguments) } Rule { @@ -238,14 +202,8 @@ CppModule { multiplex: true inputs: ["obj"] inputsFromDependencies: ["staticlibrary"] - - Artifact { - fileTags: ["staticlibrary"] - filePath: FileInfo.joinPaths( - product.destinationDirectory, - PathTools.staticLibraryFilePath(product)) - } - - prepare: KEIL.prepareArchiver.apply(KEIL, arguments); + outputFileTags: ["staticlibrary"] + outputArtifacts: KEIL.staticLibraryLinkerOutputArtifacts(product) + prepare: KEIL.prepareArchiver.apply(KEIL, arguments) } } -- cgit v1.2.3 From 7822a01904d60a883cc089175d1ca5400663040c Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Fri, 27 Sep 2019 12:51:01 +0300 Subject: baremetal: Add missed output artifacts for SDCC compiler Compiler produces a lot of additional ".adb", ".lst", ".asm", ".sym", ".rst", ".lk", ".mem" files. This files should be also processed in SDCC module (e.g. it allows to remove this files by 'clean' command). Change-Id: Ib07dbe63ab27e263d67025ce5cd40a967910d354 Reviewed-by: Christian Kandeler --- share/qbs/modules/cpp/sdcc.js | 89 ++++++++++++++++++++++++++++++++++++++---- share/qbs/modules/cpp/sdcc.qbs | 64 ++++++------------------------ 2 files changed, 92 insertions(+), 61 deletions(-) diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js index c84ec0f5d..f8c0d3b12 100644 --- a/share/qbs/modules/cpp/sdcc.js +++ b/share/qbs/modules/cpp/sdcc.js @@ -33,6 +33,7 @@ var Environment = require("qbs.Environment"); var File = require("qbs.File"); var FileInfo = require("qbs.FileInfo"); var ModUtils = require("qbs.ModUtils"); +var PathTools = require("qbs.PathTools"); var Process = require("qbs.Process"); var TemporaryDir = require("qbs.TemporaryDir"); var TextFile = require("qbs.TextFile"); @@ -178,15 +179,87 @@ function collectLibraryDependencies(product) { return result; } -function compilerFlags(project, product, input, output, explicitlyDependsOn) { +function compilerOutputArtifacts(input) { + var obj = { + fileTags: ["obj"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + input.cpp.objectSuffix + }; + var asm_adb = { + fileTags: ["asm_adb"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".adb" + }; + var asm_lst = { + fileTags: ["asm_lst"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".lst" + }; + var asm_src = { + fileTags: ["asm_src"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".asm" + }; + var asm_sym = { + fileTags: ["asm_sym"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".sym" + }; + var rst_data = { + fileTags: ["rst_data"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".rst" + }; + return [obj, asm_adb, asm_lst, asm_src, asm_sym, rst_data]; +} + +function applicationLinkerOutputArtifacts(product) { + var app = { + fileTags: ["application"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + PathTools.applicationFilePath(product)) + }; + var lk_cmd = { + fileTags: ["lk_cmd"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + product.targetName + ".lk") + }; + var mem_summary = { + fileTags: ["mem_summary"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + product.targetName + ".mem") + }; + var mem_map = { + fileTags: ["mem_map"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + product.targetName + ".map") + }; + return [app, lk_cmd, mem_summary, mem_map] +} + +function staticLibraryLinkerOutputArtifacts(product) { + var staticLib = { + fileTags: ["staticlibrary"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + PathTools.staticLibraryFilePath(product)) + }; + return [staticLib] +} + +function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { // Determine which C-language we"re compiling. - var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags)); + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags)); var args = []; args.push(input.filePath); args.push("-c"); - args.push("-o", output.filePath); + args.push("-o", outputs.obj[0].filePath); switch (input.cpp.optimization) { case "small": @@ -247,9 +320,9 @@ function compilerFlags(project, product, input, output, explicitlyDependsOn) { return args; } -function assemblerFlags(project, product, input, output, explicitlyDependsOn) { +function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { // Determine which C-language we"re compiling - var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags)); + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags)); var args = []; @@ -267,7 +340,7 @@ function assemblerFlags(project, product, input, output, explicitlyDependsOn) { ModUtils.moduleProperty(input, "driverFlags", tag)); args.push("-ol"); - args.push(output.filePath); + args.push(outputs.obj[0].filePath); args.push(input.filePath); return args; } @@ -347,7 +420,7 @@ function archiverFlags(project, product, input, outputs) { } function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { - var args = compilerFlags(project, product, input, output, explicitlyDependsOn); + var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn); var compilerPath = input.cpp.compilerPath; var cmd = new Command(compilerPath, args) cmd.description = "compiling " + input.fileName; @@ -356,7 +429,7 @@ function prepareCompiler(project, product, inputs, outputs, input, output, expli } function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { - var args = assemblerFlags(project, product, input, output, explicitlyDependsOn); + var args = assemblerFlags(project, product, input, outputs, explicitlyDependsOn); var assemblerPath = input.cpp.assemblerPath; var cmd = new Command(assemblerPath, args) cmd.description = "assembling " + input.fileName; diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs index a0d795b40..7b65ec609 100644 --- a/share/qbs/modules/cpp/sdcc.qbs +++ b/share/qbs/modules/cpp/sdcc.qbs @@ -32,9 +32,7 @@ import qbs 1.0 import qbs.File import qbs.FileInfo import qbs.ModUtils -import qbs.PathTools import qbs.Probes -import qbs.Utilities import "sdcc.js" as SDCC CppModule { @@ -117,13 +115,8 @@ CppModule { Rule { id: assembler inputs: ["asm"] - - Artifact { - fileTags: ["obj"] - filePath: Utilities.getHash(input.baseDir) + "/" - + input.fileName + input.cpp.objectSuffix - } - + outputFileTags: ["obj", "asm_adb", "asm_lst", "asm_src", "asm_sym", "rst_data"] + outputArtifacts: SDCC.compilerOutputArtifacts(input) prepare: SDCC.prepareAssembler.apply(SDCC, arguments); } @@ -143,14 +136,9 @@ CppModule { id: compiler inputs: ["cpp", "c"] auxiliaryInputs: ["hpp"] - - Artifact { - fileTags: ["obj"] - filePath: Utilities.getHash(input.baseDir) + "/" - + input.fileName + input.cpp.objectSuffix - } - - prepare: SDCC.prepareCompiler.apply(SDCC, arguments); + outputFileTags: ["obj", "asm_adb", "asm_lst", "asm_src", "asm_sym", "rst_data"] + outputArtifacts: SDCC.compilerOutputArtifacts(input) + prepare: SDCC.prepareCompiler.apply(SDCC, arguments) } Rule { @@ -158,33 +146,9 @@ CppModule { multiplex: true inputs: ["obj", "linkerscript"] inputsFromDependencies: ["staticlibrary"] - - outputFileTags: { - var tags = ["application"]; - if (product.moduleProperty("cpp", "generateMapFile")) - tags.push("map_file"); - return tags; - } - outputArtifacts: { - var app = { - fileTags: ["application"], - filePath: FileInfo.joinPaths( - product.destinationDirectory, - PathTools.applicationFilePath(product)) - }; - var artifacts = [app]; - if (product.cpp.generateMapFile) { - artifacts.push({ - fileTags: ["map_file"], - filePath: FileInfo.joinPaths( - product.destinationDirectory, - product.targetName + ".map") - }); - } - return artifacts; - } - - prepare:SDCC.prepareLinker.apply(SDCC, arguments); + outputFileTags: ["application", "lk_cmd", "mem_summary", "mem_map"] + outputArtifacts: SDCC.applicationLinkerOutputArtifacts(product) + prepare:SDCC.prepareLinker.apply(SDCC, arguments) } Rule { @@ -192,14 +156,8 @@ CppModule { multiplex: true inputs: ["obj"] inputsFromDependencies: ["staticlibrary"] - - Artifact { - fileTags: ["staticlibrary"] - filePath: FileInfo.joinPaths( - product.destinationDirectory, - PathTools.staticLibraryFilePath(product)) - } - - prepare: SDCC.prepareArchiver.apply(SDCC, arguments); + outputFileTags: ["staticlibrary"] + outputArtifacts: SDCC.staticLibraryLinkerOutputArtifacts(product) + prepare: SDCC.prepareArchiver.apply(SDCC, arguments) } } -- cgit v1.2.3 From ad11bb7383bf730ca0241af24a8b4179af157c7f Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 2 Oct 2019 16:03:25 +0200 Subject: Darwin: Adapt to Xcode 11 - xcspec files can now refer to variables in variable names, as in the following line: CONTENTS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH_SHALLOW_BUNDLE_$ (SHALLOW_BUNDLE)) - Some new environment variables have been introduced and need to be set when running our probes; e.g. "SWIFT_PLATFORM_TARGET_PREFIX". - The symbolLinkMode autotest made an invalid assumption about order of output. Change-Id: Ic845c2c4a8eafb4ece0f0bb04e6e492681a02979 Reviewed-by: Joerg Bornemann --- share/qbs/imports/qbs/DarwinTools/darwin-tools.js | 31 ++++++++++------------- share/qbs/modules/bundle/BundleModule.qbs | 6 ++++- tests/auto/blackbox/tst_blackbox.cpp | 3 ++- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/share/qbs/imports/qbs/DarwinTools/darwin-tools.js b/share/qbs/imports/qbs/DarwinTools/darwin-tools.js index 889720fcd..5f9076004 100644 --- a/share/qbs/imports/qbs/DarwinTools/darwin-tools.js +++ b/share/qbs/imports/qbs/DarwinTools/darwin-tools.js @@ -162,17 +162,17 @@ var PropertyListVariableExpander = (function () { * Finds the first index of a replacement starting with one of the supported syntaxes * This is needed so we don't do recursive substitutions */ - function indexOfReplacementStart(syntaxes, str, offset) { + function indexOfReplacementStart(syntaxes, str) { var syntax; - var idx = str.length; + var idx = -1; for (var i in syntaxes) { - var j = str.indexOf(syntaxes[i].open, offset); - if (j !== -1 && j < idx) { + var j = str.lastIndexOf(syntaxes[i].open); + if (j > idx) { syntax = syntaxes[i]; idx = j; } } - return { "syntax": syntax, "index": idx === str.length ? -1 : idx }; + return { "syntax": syntax, "index": idx }; } function expandRecursive(obj, env, checked) { @@ -202,19 +202,16 @@ var PropertyListVariableExpander = (function () { // skip replacement if ($this.undefinedVariableFunction) $this.undefinedVariableFunction(key, varName); - i = j + repl.syntax.close.length; - } else { - changes = true; - varValue = String(varValue); - if (varFormatter !== undefined) - varFormatter = varFormatter.toLowerCase(); - if (varFormatter === "rfc1034identifier") - 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; + varValue = ""; } - repl = indexOfReplacementStart(syntaxes, value, i); + varValue = String(varValue); + if (varFormatter !== undefined) + varFormatter = varFormatter.toLowerCase(); + if (varFormatter === "rfc1034identifier") + varValue = Utilities.rfc1034Identifier(varValue); + value = value.slice(0, i) + varValue + value.slice(j + repl.syntax.close.length); + changes = true; + repl = indexOfReplacementStart(syntaxes, value); i = repl.index; } if (changes) diff --git a/share/qbs/modules/bundle/BundleModule.qbs b/share/qbs/modules/bundle/BundleModule.qbs index f1845fe30..1e83dc458 100644 --- a/share/qbs/modules/bundle/BundleModule.qbs +++ b/share/qbs/modules/bundle/BundleModule.qbs @@ -63,9 +63,13 @@ Module { "GENERATE_PKGINFO_FILE": generatePackageInfo !== undefined ? (generatePackageInfo ? "YES" : "NO") : undefined, + "IS_MACCATALYST": "NO", + "LD_RUNPATH_SEARCH_PATHS_NO": [], "PRODUCT_NAME": product.targetName, "LOCAL_APPS_DIR": Environment.getEnv("HOME") + "/Applications", "LOCAL_LIBRARY_DIR": Environment.getEnv("HOME") + "/Library", + "SWIFT_PLATFORM_TARGET_PREFIX": isMacOs ? "macos" + : qbs.targetOS.contains("ios") ? "ios" : "", "TARGET_BUILD_DIR": product.buildDirectory, "WRAPPER_NAME": bundleName, "WRAPPER_EXTENSION": extension @@ -427,7 +431,7 @@ Module { || {}; for (key in partialInfoPlist) { if (partialInfoPlist.hasOwnProperty(key) - && !aggregatePlist.hasOwnProperty(key)) + && aggregatePlist[key] === undefined) aggregatePlist[key] = partialInfoPlist[key]; } } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 19676d050..e612e9a3c 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -4262,7 +4262,8 @@ void TestBlackbox::symbolLinkMode() rmDirR(relativeBuildDir()); params.arguments = QStringList() << commonArgs << "project.lazy:true"; QCOMPARE(runQbs(params), 0); - QVERIFY2(m_qbsStdout.contains("meow\nLib was loaded!\n"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("meow\n") && m_qbsStdout.contains("Lib was loaded!\n"), + m_qbsStdout.constData()); } } -- cgit v1.2.3