aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/cpp/iar.js
diff options
context:
space:
mode:
Diffstat (limited to 'share/qbs/modules/cpp/iar.js')
-rw-r--r--share/qbs/modules/cpp/iar.js461
1 files changed, 123 insertions, 338 deletions
diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js
index 416de7ee2..3848761f5 100644
--- a/share/qbs/modules/cpp/iar.js
+++ b/share/qbs/modules/cpp/iar.js
@@ -210,156 +210,103 @@ function architectureCode(architecture) {
}
}
-function compilerName(qbs) {
+function toolchainDetails(qbs) {
var architecture = qbs.architecture;
- if (architecture.startsWith("arm"))
- return "iccarm";
- else if (architecture === "78k")
- return "icc78k";
- else if (architecture === "avr")
- return "iccavr";
- else if (architecture === "avr32")
- return "iccavr32";
- else if (architecture === "cr16")
- return "icccr16c";
- else if (architecture === "hcs12")
- return "icchcs12";
- else if (architecture === "hcs8")
- return "iccs08";
- else if (architecture === "m16c")
- return "iccm16c";
- else if (architecture === "m32c")
- return "iccm32c";
- else if (architecture === "m68k")
- return "icccf";
- else if (architecture === "mcs51")
- return "icc8051";
- else if (architecture === "msp430")
- return "icc430";
- else if (architecture === "r32c")
- return "iccr32c";
- else if (architecture === "rh850")
- return "iccrh850";
- else if (architecture === "riscv")
- return "iccriscv";
- else if (architecture === "rl78")
- return "iccrl78";
- else if (architecture === "rx")
- return "iccrx";
- else if (architecture === "sh")
- return "iccsh";
- else if (architecture === "stm8")
- return "iccstm8";
- else if (architecture === "v850")
- return "iccv850";
- throw "Unable to deduce compiler name for unsupported architecture: '"
- + architecture + "'";
-}
-
-function assemblerName(qbs) {
- var architecture = qbs.architecture;
- if (architecture.startsWith("arm"))
- return "iasmarm";
- else if (architecture === "78k")
- return "a78k";
- else if (architecture === "avr")
- return "aavr";
- else if (architecture === "avr32")
- return "aavr32";
- else if (architecture === "cr16")
- return "acr16c";
- else if (architecture === "hcs12")
- return "ahcs12";
- else if (architecture === "hcs8")
- return "as08";
- else if (architecture === "m16c")
- return "am16c";
- else if (architecture === "m32c")
- return "am32c";
- else if (architecture === "m68k")
- return "acf";
- else if (architecture === "mcs51")
- return "a8051";
- else if (architecture === "msp430")
- return "a430";
- else if (architecture === "r32c")
- return "ar32c";
- else if (architecture === "rh850")
- return "iasmrh850";
- else if (architecture === "riscv")
- return "iasmriscv";
- else if (architecture === "rl78")
- return "iasmrl78";
- else if (architecture === "rx")
- return "iasmrx";
- else if (architecture === "sh")
- return "iasmsh";
- else if (architecture === "stm8")
- return "iasmstm8";
- else if (architecture === "v850")
- return "av850";
- throw "Unable to deduce assembler name for unsupported architecture: '"
- + architecture + "'";
-}
-
-function linkerName(qbs) {
- var architecture = qbs.architecture;
- if (supportXLinker(architecture))
- return "xlink";
- else if (supportILinker(architecture))
- return architecture.startsWith("arm") ? "ilinkarm" : ("ilink" + architecture);
- throw "Unable to deduce linker name for unsupported architecture: '"
- + architecture + "'";
-}
+ var code = architectureCode(architecture);
+ var details = {};
+
+ if (supportXLinker(architecture)) {
+ details.libraryPathFlag = "-I";
+ details.linkerScriptFlag = "-f";
+ details.linkerName = "xlink";
+ details.linkerSilentFlag = "-S";
+ details.linkerMapFileFlag = "-l";
+ details.linkerEntryPointFlag = "-s";
+ } else if (supportILinker(architecture)) {
+ details.libraryPathFlag = "-L";
+ details.linkerScriptFlag = "--config";
+ details.linkerSilentFlag = "--silent";
+ details.linkerMapFileFlag = "--map";
+ details.linkerEntryPointFlag = "--entry";
+ details.linkerName = architecture.startsWith("arm")
+ ? "ilinkarm" : ("ilink" + architecture);
+ }
-function archiverName(qbs) {
- var architecture = qbs.architecture;
if (supportXArchiver(architecture))
- return "xar";
+ details.archiverName = "xar";
else if (supportIArchiver(architecture))
- return "iarchive";
- throw "Unable to deduce archiver name for unsupported architecture: '"
- + architecture + "'";
-}
-
-function staticLibrarySuffix(qbs) {
- var architecture = qbs.architecture;
- var code = architectureCode(architecture);
- if (code === undefined) {
- throw "Unable to deduce static library suffix for unsupported architecture: '"
- + architecture + "'";
- }
- return (code !== "") ? (".r" + code) : ".a";
-}
+ details.archiverName = "iarchive";
-function executableSuffix(qbs) {
- var architecture = qbs.architecture;
- var code = architectureCode(architecture);
- if (code === undefined) {
- throw "Unable to deduce executable suffix for unsupported architecture: '"
- + architecture + "'";
- }
- return (code !== "") ? ((qbs.debugInformation) ? (".d" + code) : (".a" + code)) : ".out";
-}
+ var hasCode = (code !== "");
+ details.staticLibrarySuffix = hasCode ? (".r" + code) : ".a";
+ details.executableSuffix = hasCode
+ ? ((qbs.debugInformation) ? (".d" + code) : (".a" + code)) : ".out";
+ details.objectSuffix = hasCode ? (".r" + code) : ".o";
+ details.imageFormat = hasCode ? "ubrof" : "elf";
-function objectSuffix(qbs) {
- var architecture = qbs.architecture;
- var code = architectureCode(architecture);
- if (code === undefined) {
- throw "Unable to deduce object file suffix for unsupported architecture: '"
- + architecture + "'";
+ if (architecture.startsWith("arm")) {
+ details.compilerName = "iccarm";
+ details.assemblerName = "iasmarm";
+ } else if (architecture === "78k") {
+ details.compilerName = "icc78k";
+ details.assemblerName = "a78k";
+ } else if (architecture === "avr") {
+ details.compilerName = "iccavr";
+ details.assemblerName = "aavr";
+ } else if (architecture === "avr32") {
+ details.compilerName = "iccavr32";
+ details.assemblerName = "aavr32";
+ } else if (architecture === "cr16") {
+ details.compilerName = "icccr16c";
+ details.assemblerName = "acr16c";
+ } else if (architecture === "hcs12") {
+ details.compilerName = "icchcs12";
+ details.assemblerName = "ahcs12";
+ } else if (architecture === "hcs8") {
+ details.compilerName = "iccs08";
+ details.assemblerName = "as08";
+ } else if (architecture === "m16c") {
+ details.compilerName = "iccm16c";
+ details.assemblerName = "am16c";
+ } else if (architecture === "m32c") {
+ details.compilerName = "iccm32c";
+ details.assemblerName = "am32c";
+ } else if (architecture === "m68k") {
+ details.compilerName = "icccf";
+ details.assemblerName = "acf";
+ } else if (architecture === "mcs51") {
+ details.compilerName = "icc8051";
+ details.assemblerName = "a8051";
+ } else if (architecture === "msp430") {
+ details.compilerName = "icc430";
+ details.assemblerName = "a430";
+ } else if (architecture === "r32c") {
+ details.compilerName = "iccr32c";
+ details.assemblerName = "ar32c";
+ } else if (architecture === "rh850") {
+ details.compilerName = "iccrh850";
+ details.assemblerName = "iasmrh850";
+ } else if (architecture === "riscv") {
+ details.compilerName = "iccriscv";
+ details.assemblerName = "iasmriscv";
+ } else if (architecture === "rl78") {
+ details.compilerName = "iccrl78";
+ details.assemblerName = "iasmrl78";
+ } else if (architecture === "rx") {
+ details.compilerName = "iccrx";
+ details.assemblerName = "iasmrx";
+ } else if (architecture === "sh") {
+ details.compilerName = "iccsh";
+ details.assemblerName = "iasmsh";
+ } else if (architecture === "stm8") {
+ details.compilerName = "iccstm8";
+ details.assemblerName = "iasmstm8";
+ } else if (architecture === "v850") {
+ details.compilerName = "iccv850";
+ details.assemblerName = "av850";
}
- return (code !== "") ? (".r" + code) : ".o";
-}
-function imageFormat(qbs) {
- var architecture = qbs.architecture;
- var code = architectureCode(architecture);
- if (code === undefined) {
- throw "Unable to deduce image format for unsupported architecture: '"
- + architecture + "'";
- }
- return (code !== "") ? "ubrof" : "elf";
+ return details;
}
function guessArmArchitecture(core) {
@@ -490,8 +437,6 @@ function cppLanguageOption(compilerFilePath) {
case "iccv850":
return "--ec++";
}
- throw "Unable to deduce C++ language option for unsupported compiler: '"
- + FileInfo.toNativeSeparators(compilerFilePath) + "'";
}
function dumpMacros(compilerFilePath, tag) {
@@ -507,7 +452,7 @@ function dumpMacros(compilerFilePath, tag) {
var p = new Process();
p.exec(compilerFilePath, args, true);
var outFile = new TextFile(outFilePath, TextFile.ReadOnly);
- return ModUtils.extractMacros(outFile.readAll());
+ return Cpp.extractMacros(outFile.readAll());
}
function dumpCompilerIncludePaths(compilerFilePath, tag) {
@@ -557,110 +502,6 @@ function dumpDefaultPaths(compilerFilePath, tag) {
};
}
-function collectLibraryDependencies(product) {
- var seen = {};
- var result = [];
-
- function addFilePath(filePath) {
- result.push({ filePath: filePath });
- }
-
- function addArtifactFilePaths(dep, artifacts) {
- if (!artifacts)
- return;
- var artifactFilePaths = artifacts.map(function(a) { return a.filePath; });
- artifactFilePaths.forEach(addFilePath);
- }
-
- function addExternalStaticLibs(obj) {
- if (!obj.cpp)
- return;
- function ensureArray(a) {
- return (a instanceof Array) ? a : [];
- }
- function sanitizedModuleListProperty(obj, moduleName, propertyName) {
- return ensureArray(ModUtils.sanitizedModuleProperty(obj, moduleName, propertyName));
- }
- var externalLibs = [].concat(
- sanitizedModuleListProperty(obj, "cpp", "staticLibraries"));
- var staticLibrarySuffix = obj.moduleProperty("cpp", "staticLibrarySuffix");
- externalLibs.forEach(function(staticLibraryName) {
- if (!staticLibraryName.endsWith(staticLibrarySuffix))
- staticLibraryName += staticLibrarySuffix;
- addFilePath(staticLibraryName);
- });
- }
-
- function traverse(dep) {
- if (seen.hasOwnProperty(dep.name))
- return;
- seen[dep.name] = true;
-
- if (dep.parameters.cpp && dep.parameters.cpp.link === false)
- return;
-
- var staticLibraryArtifacts = dep.artifacts["staticlibrary"];
- if (staticLibraryArtifacts) {
- dep.dependencies.forEach(traverse);
- addArtifactFilePaths(dep, staticLibraryArtifacts);
- addExternalStaticLibs(dep);
- }
- }
-
- product.dependencies.forEach(traverse);
- addExternalStaticLibs(product);
- return result;
-}
-
-function compilerOutputArtifacts(input, isCompilerArtifacts) {
- var artifacts = [];
- artifacts.push({
- fileTags: ["obj"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + input.cpp.objectSuffix
- });
- if (isCompilerArtifacts && input.cpp.generateCompilerListingFiles) {
- artifacts.push({
- fileTags: ["lst"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + input.cpp.compilerListingSuffix
- });
- } else if (!isCompilerArtifacts && input.cpp.generateAssemblerListingFiles) {
- artifacts.push({
- fileTags: ["lst"],
- filePath: Utilities.getHash(input.baseDir) + "/"
- + input.fileName + input.cpp.assemblerListingSuffix
- });
- }
- return artifacts;
-}
-
-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.linkerMapSuffix)
- };
- 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, outputs, explicitlyDependsOn) {
var args = [];
@@ -670,32 +511,15 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
// Output.
args.push("-o", outputs.obj[0].filePath);
- var prefixHeaders = input.cpp.prefixHeaders;
- for (var i in prefixHeaders)
- args.push("--preinclude", prefixHeaders[i]);
+ // Preinclude headers.
+ args = args.concat(Cpp.collectPreincludePathsArguments(input, true));
// Defines.
- var allDefines = [];
- var platformDefines = input.cpp.platformDefines;
- if (platformDefines)
- allDefines = allDefines.uniqueConcat(platformDefines);
- var defines = input.cpp.defines;
- if (defines)
- allDefines = allDefines.uniqueConcat(defines);
- args = args.concat(allDefines.map(function(define) { return "-D" + define }));
+ args = args.concat(Cpp.collectDefinesArguments(input));
// Includes.
- var allIncludePaths = [];
- var includePaths = input.cpp.includePaths;
- if (includePaths)
- allIncludePaths = allIncludePaths.uniqueConcat(includePaths);
- var systemIncludePaths = input.cpp.systemIncludePaths;
- if (systemIncludePaths)
- allIncludePaths = allIncludePaths.uniqueConcat(systemIncludePaths);
- var distributionIncludePaths = input.cpp.distributionIncludePaths;
- if (distributionIncludePaths)
- allIncludePaths = allIncludePaths.uniqueConcat(distributionIncludePaths);
- args = args.concat(allIncludePaths.map(function(include) { return "-I" + include }));
+ args = args.concat(Cpp.collectIncludePathsArguments(input));
+ args = args.concat(Cpp.collectSystemIncludePathsArguments(input));
// Silent output generation flag.
args.push("--silent");
@@ -783,18 +607,12 @@ function compilerFlags(project, product, input, outputs, explicitlyDependsOn) {
args.push("-l", outputs.lst[0].filePath);
// Misc flags.
- args = args.concat(ModUtils.moduleProperty(input, "platformFlags"),
- ModUtils.moduleProperty(input, "flags"),
- ModUtils.moduleProperty(input, "platformFlags", tag),
- ModUtils.moduleProperty(input, "flags", tag),
- ModUtils.moduleProperty(input, "driverFlags", tag));
+ args = args.concat(Cpp.collectMiscCompilerArguments(input, tag),
+ Cpp.collectMiscDriverArguments(product));
return args;
}
function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) {
- // Determine which C-language we"re compiling
- var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags));
-
var args = [];
// Input.
@@ -807,21 +625,12 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) {
// The `--preinclude` flag is only supported for a certain
// set of assemblers, not for all.
- if (supportIAssembler(architecture)) {
- var prefixHeaders = input.cpp.prefixHeaders;
- for (var i in prefixHeaders)
- args.push("--preinclude", prefixHeaders[i]);
- }
+ if (supportIAssembler(architecture))
+ args = args.concat(Cpp.collectPreincludePathsArguments(input));
// Includes.
- var allIncludePaths = [];
- var systemIncludePaths = input.cpp.systemIncludePaths;
- if (systemIncludePaths)
- allIncludePaths = allIncludePaths.uniqueConcat(systemIncludePaths);
- var distributionIncludePaths = input.cpp.distributionIncludePaths;
- if (distributionIncludePaths)
- allIncludePaths = allIncludePaths.uniqueConcat(distributionIncludePaths);
- args = args.concat(allIncludePaths.map(function(include) { return "-I" + include }));
+ args = args.concat(Cpp.collectIncludePathsArguments(input));
+ args = args.concat(Cpp.collectSystemIncludePathsArguments(input));
// Debug information flags.
if (input.cpp.debugInformation)
@@ -853,8 +662,7 @@ function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) {
args.push("-l", outputs.lst[0].filePath);
// Misc flags.
- args = args.concat(ModUtils.moduleProperty(input, "platformFlags", tag),
- ModUtils.moduleProperty(input, "flags", tag));
+ args = args.concat(Cpp.collectMiscAssemblerArguments(input, "asm"));
return args;
}
@@ -862,63 +670,41 @@ function linkerFlags(project, product, inputs, outputs) {
var args = [];
// Inputs.
- if (inputs.obj)
- args = args.concat(inputs.obj.map(function(obj) { return obj.filePath }));
+ args = args.concat(Cpp.collectLinkerObjectPaths(inputs));
// Output.
args.push("-o", outputs.application[0].filePath);
// Library paths.
- var allLibraryPaths = [];
- var libraryPaths = product.cpp.libraryPaths;
- if (libraryPaths)
- allLibraryPaths = allLibraryPaths.uniqueConcat(libraryPaths);
- var distributionLibraryPaths = product.cpp.distributionLibraryPaths;
- if (distributionLibraryPaths)
- allLibraryPaths = allLibraryPaths.uniqueConcat(distributionLibraryPaths);
+ args = args.concat(Cpp.collectLibraryPathsArguments(product));
// Library dependencies.
- var libraryDependencies = collectLibraryDependencies(product);
- if (libraryDependencies)
- args = args.concat(libraryDependencies.map(function(dep) { return dep.filePath }));
+ args = args.concat(Cpp.collectLibraryDependenciesArguments(product));
// Linker scripts.
- var linkerScripts = inputs.linkerscript
- ? inputs.linkerscript.map(function(a) { return a.filePath; }) : [];
+ args = args.concat(Cpp.collectLinkerScriptPathsArguments(product, inputs));
- // Architecture specific flags.
- var architecture = product.qbs.architecture;
- if (supportILinker(architecture)) {
- args = args.concat(allLibraryPaths.map(function(path) { return '-L' + path }));
- // Silent output generation flag.
- args.push("--silent");
- // Map file generation flag.
- if (product.cpp.generateLinkerMapFile)
- args.push("--map", outputs.mem_map[0].filePath);
- // Entry point flag.
- if (product.cpp.entryPoint)
- args.push("--entry", product.cpp.entryPoint);
- // Linker scripts flags.
- linkerScripts.forEach(function(script) { args.push("--config", script); });
- } else if (supportXLinker(architecture)) {
- args = args.concat(allLibraryPaths.map(function(path) { return '-I' + path }));
- // Silent output generation flag.
- args.push("-S");
- // Debug information flag.
+ // Silent output generation flag.
+ args.push(product.cpp.linkerSilentFlag);
+
+ // Map file generation flag.
+ if (product.cpp.generateLinkerMapFile)
+ args.push(product.cpp.linkerMapFileFlag, outputs.mem_map[0].filePath);
+
+ // Entry point flag.
+ if (product.cpp.entryPoint)
+ args.push(product.cpp.linkerEntryPointFlag, product.cpp.entryPoint);
+
+ // Debug information flag.
+ if (supportXLinker(product.qbs.architecture)) {
if (product.cpp.debugInformation)
args.push("-rt");
- // Map file generation flag.
- if (product.cpp.generateLinkerMapFile)
- args.push("-l", outputs.mem_map[0].filePath);
- // Entry point flag.
- if (product.cpp.entryPoint)
- args.push("-s", product.cpp.entryPoint);
- // Linker scripts flags.
- linkerScripts.forEach(function(script) { args.push("-f", script); });
}
// Misc flags.
- args = args.concat(ModUtils.moduleProperty(product, "driverLinkerFlags"));
+ args = args.concat(Cpp.collectMiscEscapableLinkerArguments(product),
+ Cpp.collectMiscLinkerArguments(product),
+ Cpp.collectMiscDriverArguments(product));
return args;
}
@@ -926,8 +712,7 @@ function archiverFlags(project, product, inputs, outputs) {
var args = [];
// Inputs.
- if (inputs.obj)
- args = args.concat(inputs.obj.map(function(obj) { return obj.filePath }));
+ args = args.concat(Cpp.collectLinkerObjectPaths(inputs));
// Output.
var architecture = product.qbs.architecture;