diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2021-05-06 15:27:32 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2021-05-14 11:20:45 +0000 |
commit | 79b9b022ceac0b66cdc4e3a4400926b76be3f41d (patch) | |
tree | 0f154038d4333cbf047563ae594194c983d73251 /share/qbs/modules/cpp/keil.js | |
parent | 05d16754fe403af343e256c032d83970420b058b (diff) | |
download | qbs-79b9b022ceac0b66cdc4e3a4400926b76be3f41d.tar.gz |
baremetal: Share generation of generic lists of tags and artifacts
It makes sense to put in separate functions the repeating code for
generating a list of tags and artifacts for compilation and linking.
The generic code has been moved into the ModUtils module, which
simplifies maintenance and minimizes copy-paste errors.
Change-Id: I28b8e5467cf6a6764cbe7b1b7b68797b1d6ec1f4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/qbs/modules/cpp/keil.js')
-rw-r--r-- | share/qbs/modules/cpp/keil.js | 124 |
1 files changed, 2 insertions, 122 deletions
diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js index a36fe592c..e1876e0b2 100644 --- a/share/qbs/modules/cpp/keil.js +++ b/share/qbs/modules/cpp/keil.js @@ -507,61 +507,6 @@ function dumpDefaultPaths(compilerFilePath, nullDevice) { return { "includePaths": includePaths }; } -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 filterMcsOutput(output) { var filteredLines = []; output.split(/\r\n|\r|\n/).forEach(function(line) { @@ -582,71 +527,6 @@ function filterC166Output(output) { return filteredLines.join('\n'); }; -function compilerOutputTags(needsListingFiles) { - var tags = ["obj"]; - if (needsListingFiles) - tags.push("lst"); - return tags; -} - -function applicationLinkerOutputTags(needsLinkerMapFile) { - var tags = ["application"]; - if (needsLinkerMapFile) - tags.push("mem_map"); - return tags; -} - -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 artifacts = [{ - fileTags: ["application"], - filePath: FileInfo.joinPaths( - product.destinationDirectory, - PathTools.applicationFilePath(product)) - }]; - if (product.cpp.generateLinkerMapFile) { - artifacts.push({ - fileTags: ["mem_map"], - filePath: FileInfo.joinPaths( - product.destinationDirectory, - product.targetName + product.cpp.linkerMapSuffix) - }); - } - return artifacts; -} - -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(outputs.obj[0].fileTags)); @@ -1006,7 +886,7 @@ function linkerFlags(project, product, inputs, outputs) { inputs.obj.map(function(obj) { allObjectPaths.push(obj.filePath) }); // Library dependencies. - var libraryObjects = collectLibraryDependencies(product); + var libraryObjects = ModUtils.collectLibraryDependencies(product); allObjectPaths = allObjectPaths.concat(libraryObjects.map(function(lib) { // Semi-intelligent handling the library paths. // We need to add the full path prefix to the library file if this @@ -1047,7 +927,7 @@ function linkerFlags(project, product, inputs, outputs) { args.push("--userlibpath=" + libraryPaths.join(",")); // Library dependencies. - var libraryDependencies = collectLibraryDependencies(product); + var libraryDependencies = ModUtils.collectLibraryDependencies(product); args = args.concat(libraryDependencies.map(function(dep) { return dep.filePath; })); // Debug information flag. |