diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-08-16 15:14:18 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-10-04 14:56:05 +0000 |
commit | 1ce4105a7d3207410c9be8d202464e6f2b2c6861 (patch) | |
tree | c468e3967fe53c49ddb8b5edb5dc2ba21d89c86f /share/qbs | |
parent | bb27df0890e22979706455bd756e33d2bdf17240 (diff) |
Android: Rewrite the rules gathering binaries for packaging
These rules were unnecessarily complicated; in particular, the
indirection via a text file for the gdbserver and STL binaries was not
needed.
This also fixed the gdbserver file name in the package: It has to be
libgdbserver.so, rather than just gdbserver as on the host.
Change-Id: I2315660983904e8b922164be9054d6bba51f852d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'share/qbs')
-rw-r--r-- | share/qbs/modules/Android/ndk/ndk.qbs | 2 | ||||
-rw-r--r-- | share/qbs/modules/Android/sdk/sdk.qbs | 116 | ||||
-rw-r--r-- | share/qbs/modules/Android/sdk/utils.js | 49 | ||||
-rw-r--r-- | share/qbs/modules/cpp/android-gcc.qbs | 87 |
4 files changed, 108 insertions, 146 deletions
diff --git a/share/qbs/modules/Android/ndk/ndk.qbs b/share/qbs/modules/Android/ndk/ndk.qbs index a664a62bb..94211ea39 100644 --- a/share/qbs/modules/Android/ndk/ndk.qbs +++ b/share/qbs/modules/Android/ndk/ndk.qbs @@ -145,8 +145,6 @@ Module { return toolchainVersion; } - property string gdbserverFileName: "gdbserver" - property string armMode: abi && abi.startsWith("armeabi") ? (qbs.buildVariant === "debug" ? "arm" : "thumb") : undefined; diff --git a/share/qbs/modules/Android/sdk/sdk.qbs b/share/qbs/modules/Android/sdk/sdk.qbs index d5bd29477..e2eb97929 100644 --- a/share/qbs/modules/Android/sdk/sdk.qbs +++ b/share/qbs/modules/Android/sdk/sdk.qbs @@ -296,58 +296,82 @@ Module { Rule { condition: _enableRules + property stringList inputTags: "android.nativelibrary" + inputsFromDependencies: inputTags + inputs: product.aggregate ? [] : inputTags + Artifact { + filePath: FileInfo.joinPaths(product.Android.sdk.apkContentsDir, "lib", + input.Android.ndk.abi, input.fileName) + fileTags: "android.nativelibrary_deployed" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "copying " + input.fileName + " for packaging"; + cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); }; + return cmd; + } + } + + Rule { + condition: _enableRules multiplex: true - inputsFromDependencies: [ - "android.gdbserver-info", "android.stl-info", "android.nativelibrary" - ] - outputFileTags: ["android.gdbserver", "android.stl", "android.nativelibrary-deployed"] + property stringList inputTags: "android.gdbserver" + inputsFromDependencies: inputTags + inputs: product.aggregate ? [] : inputTags + outputFileTags: "android.gdbserver_deployed" outputArtifacts: { - var libArtifacts = []; - if (inputs["android.nativelibrary"]) { - for (var i = 0; i < inputs["android.nativelibrary"].length; ++i) { - var inp = inputs["android.nativelibrary"][i]; - var destDir = FileInfo.joinPaths(product.Android.sdk.apkContentsDir, "lib", - inp.moduleProperty("Android.ndk", "abi")); - libArtifacts.push({ - filePath: FileInfo.joinPaths(destDir, inp.fileName), - fileTags: ["android.nativelibrary-deployed"] - }); - } + var deploymentData = SdkUtils.gdbserverOrStlDeploymentData(product, inputs, + "gdbserver"); + var outputs = []; + for (i = 0; i < deploymentData.outputFilePaths.length; ++i) { + outputs.push({filePath: deploymentData.outputFilePaths[i], + fileTags: "android.gdbserver_deployed"}); } - var gdbServerArtifacts = SdkUtils.outputArtifactsFromInfoFiles(inputs, - product, "android.gdbserver-info", "android.gdbserver"); - var stlArtifacts = SdkUtils.outputArtifactsFromInfoFiles(inputs, product, - "android.stl-info", "android.stl"); - return libArtifacts.concat(gdbServerArtifacts).concat(stlArtifacts); + return outputs; } prepare: { - var cmd = new JavaScriptCommand(); - cmd.description = "Pre-packaging native binaries"; + var cmd = new JavaScriptCommand; + cmd.description = "deploying gdbserver binaries"; cmd.sourceCode = function() { - if (inputs["android.nativelibrary"]) { - for (var i = 0; i < inputs["android.nativelibrary"].length; ++i) { - for (var j = 0; j < outputs["android.nativelibrary-deployed"].length; ++j) { - var inp = inputs["android.nativelibrary"][i]; - var outp = outputs["android.nativelibrary-deployed"][j]; - var inpAbi = inp.moduleProperty("Android.ndk", "abi"); - var outpAbi = FileInfo.fileName(outp.baseDir); - if (inp.fileName === outp.fileName && inpAbi === outpAbi) { - File.copy(inp.filePath, outp.filePath); - break; - } - } - } + var deploymentData = SdkUtils.gdbserverOrStlDeploymentData(product, inputs, + "gdbserver"); + for (var i = 0; i < deploymentData.uniqueInputs.length; ++i) { + File.copy(deploymentData.uniqueInputs[i].filePath, + deploymentData.outputFilePaths[i]); } - var pathsSpecs = SdkUtils.sourceAndTargetFilePathsFromInfoFiles(inputs, product, - "android.gdbserver-info"); - for (i = 0; i < pathsSpecs.sourcePaths.length; ++i) - File.copy(pathsSpecs.sourcePaths[i], pathsSpecs.targetPaths[i]); - pathsSpecs = SdkUtils.sourceAndTargetFilePathsFromInfoFiles(inputs, product, - "android.stl-info"); - for (i = 0; i < pathsSpecs.sourcePaths.length; ++i) - File.copy(pathsSpecs.sourcePaths[i], pathsSpecs.targetPaths[i]); }; - return [cmd]; + return cmd; + } + } + + Rule { + condition: _enableRules + multiplex: true + property stringList inputTags: "android.stl" + inputsFromDependencies: inputTags + inputs: product.aggregate ? [] : inputTags + outputFileTags: "android.stl_deployed" + outputArtifacts: { + var deploymentData = SdkUtils.gdbserverOrStlDeploymentData(product, inputs, "stl"); + var outputs = []; + for (i = 0; i < deploymentData.outputFilePaths.length; ++i) { + outputs.push({filePath: deploymentData.outputFilePaths[i], + fileTags: "android.stl_deployed"}); + } + return outputs; + } + prepare: { + var cmds = []; + var deploymentData = SdkUtils.gdbserverOrStlDeploymentData(product, inputs); + for (var i = 0; i < deploymentData.uniqueInputs.length; ++i) { + var input = deploymentData.uniqueInputs[i]; + var stripArgs = ["--strip-unneeded", "-o", deploymentData.outputFilePaths[i], + input.filePath]; + var cmd = new Command(input.cpp.stripPath, stripArgs); + cmd.description = "deploying " + input.fileName; + cmds.push(cmd); + } + return cmds; } } @@ -356,8 +380,8 @@ Module { multiplex: true inputs: [ "android.resources", "android.assets", "android.manifest", - "android.dex", "android.gdbserver", "android.stl", - "android.nativelibrary-deployed", "android.keystore" + "android.dex", "android.gdbserver_deployed", "android.stl_deployed", + "android.nativelibrary_deployed", "android.keystore" ] Artifact { filePath: product.Android.sdk.apkBaseName + ".apk" diff --git a/share/qbs/modules/Android/sdk/utils.js b/share/qbs/modules/Android/sdk/utils.js index 49b0ea786..fab1fc0b5 100644 --- a/share/qbs/modules/Android/sdk/utils.js +++ b/share/qbs/modules/Android/sdk/utils.js @@ -34,34 +34,6 @@ var Process = require("qbs.Process"); var TextFile = require("qbs.TextFile"); var Utilities = require("qbs.Utilities"); -function sourceAndTargetFilePathsFromInfoFiles(inputs, product, inputTag) -{ - var sourceFilePaths = []; - var targetFilePaths = []; - var inputsLength = inputs[inputTag] ? inputs[inputTag].length : 0; - for (var i = 0; i < inputsLength; ++i) { - var infoFile = new TextFile(inputs[inputTag][i].filePath, TextFile.ReadOnly); - var sourceFilePath = infoFile.readLine(); - var targetFilePath = FileInfo.joinPaths(product.Android.sdk.apkContentsDir, - infoFile.readLine()); - if (!targetFilePaths.contains(targetFilePath)) { - sourceFilePaths.push(sourceFilePath); - targetFilePaths.push(targetFilePath); - } - infoFile.close(); - } - return { sourcePaths: sourceFilePaths, targetPaths: targetFilePaths }; -} - -function outputArtifactsFromInfoFiles(inputs, product, inputTag, outputTag) -{ - var pathSpecs = sourceAndTargetFilePathsFromInfoFiles(inputs, product, inputTag) - var artifacts = []; - for (i = 0; i < pathSpecs.targetPaths.length; ++i) - artifacts.push({filePath: pathSpecs.targetPaths[i], fileTags: [outputTag]}); - return artifacts; -} - function availableSdkPlatforms(sdkDir) { var re = /^android-([0-9]+)$/; var platforms = File.directoryEntries(FileInfo.joinPaths(sdkDir, "platforms"), @@ -210,3 +182,24 @@ function createDebugKeyStoreCommandString(keytoolFilePath, keystoreFilePath) { "CN=Android Debug,O=Android,C=US"]; return Process.shellQuote(keytoolFilePath, args); } + +function gdbserverOrStlDeploymentData(product, inputs, type) +{ + var data = { uniqueInputs: [], outputFilePaths: []}; + var uniqueFilePaths = []; + var theInputs = inputs[type === "gdbserver" ? "android.gdbserver" : "android.stl"]; + if (!theInputs) + return data; + for (var i = 0; i < theInputs.length; ++i) { + var currentInput = theInputs[i]; + if (uniqueFilePaths.contains(currentInput.filePath)) + continue; + uniqueFilePaths.push(currentInput.filePath); + data.uniqueInputs.push(currentInput); + var outputFileName = type === "gdbserver" ? "libgdbserver.so" : currentInput.fileName; + data.outputFilePaths.push(FileInfo.joinPaths(product.Android.sdk.apkContentsDir, "lib", + currentInput.Android.ndk.abi, + outputFileName)); + } + return data; +} diff --git a/share/qbs/modules/cpp/android-gcc.qbs b/share/qbs/modules/cpp/android-gcc.qbs index 749fef37d..18ca1c25d 100644 --- a/share/qbs/modules/cpp/android-gcc.qbs +++ b/share/qbs/modules/cpp/android-gcc.qbs @@ -89,7 +89,16 @@ LinuxGCC { name: "Android STL" condition: product.cpp.sharedStlFilePath && product.cpp.shouldLink files: product.cpp.sharedStlFilePath ? [product.cpp.sharedStlFilePath] : [] - fileTags: ["android.unstripped-stl"] + fileTags: "android.stl" + } + + Group { + name: "gdbserver" + condition: qbs.buildVariant !== "release" && product.cpp.shouldLink + files: FileInfo.joinPaths(Android.ndk.ndkDir, "prebuilt", + "android-" + NdkUtils.abiNameToDirName(Android.ndk.abi), + "gdbserver", "gdbserver") + fileTags: "android.gdbserver" } toolchainInstallPath: FileInfo.joinPaths(Android.ndk.ndkDir, "toolchains", @@ -211,78 +220,16 @@ LinuxGCC { Rule { condition: shouldLink - inputs: ["android.unstripped-stl"] + inputs: "dynamiclibrary" Artifact { - filePath: FileInfo.joinPaths("stripped-libs", input.fileName); - fileTags: ["android.stripped-stl"] + filePath: FileInfo.joinPaths("stripped-libs", input.fileName) + fileTags: "android.nativelibrary" } prepare: { - var args = ["--strip-unneeded", "-o", output.filePath, input.filePath]; - var cmd = new Command(product.cpp.stripPath, args); - cmd.description = "stripping " + input.fileName; - return [cmd]; - } - } - - Rule { - condition: shouldLink - inputs: ["dynamiclibrary"] - explicitlyDependsOn: ["android.stripped-stl"]; - outputFileTags: ["android.nativelibrary", "android.gdbserver-info", "android.stl-info"] - outputArtifacts: { - var artifacts = [{ - filePath: FileInfo.joinPaths("stripped-libs", - inputs["dynamiclibrary"][0].fileName), - fileTags: ["android.nativelibrary"] - }]; - if (product.moduleProperty("qbs", "buildVariant") === "debug") { - artifacts.push({ - filePath: "android.gdbserver-info.txt", - fileTags: ["android.gdbserver-info"] - }); - } - if (explicitlyDependsOn["android.stripped-stl"]) - artifacts.push({filePath: "android.stl-info.txt", fileTags: ["android.stl-info"]}); - return artifacts; - } - - prepare: { - var copyCmd = new JavaScriptCommand(); - copyCmd.silent = true; - copyCmd.sourceCode = function() { - File.copy(inputs["dynamiclibrary"][0].filePath, - outputs["android.nativelibrary"][0].filePath); - var arch = product.moduleProperty("Android.ndk", "abi"); - var destDir = FileInfo.joinPaths("lib", arch); - if (product.moduleProperty("qbs", "buildVariant") === "debug") { - arch = NdkUtils.abiNameToDirName(arch); - var srcPath = FileInfo.joinPaths( - product.moduleProperty("Android.ndk", "ndkDir"), - "prebuilt/android-" + arch, "gdbserver/gdbserver"); - var targetPath = FileInfo.joinPaths(destDir, - product.moduleProperty("Android.ndk", "gdbserverFileName")); - var infoFile = new TextFile(outputs["android.gdbserver-info"][0].filePath, - TextFile.WriteOnly); - infoFile.writeLine(srcPath); - infoFile.writeLine(targetPath); - infoFile.close(); - } - var strippedStlList = explicitlyDependsOn["android.stripped-stl"]; - if (strippedStlList) { - var srcPath = strippedStlList[0].filePath; - var targetPath = FileInfo.joinPaths(destDir, FileInfo.fileName(srcPath)); - var infoFile = new TextFile(outputs["android.stl-info"][0].filePath, - TextFile.WriteOnly); - infoFile.writeLine(srcPath); - infoFile.writeLine(targetPath); - infoFile.close(); - } - } - var stripArgs = ["--strip-unneeded", outputs["android.nativelibrary"][0].filePath]; - var stripCmd = new Command(product.moduleProperty("cpp", "stripPath"), stripArgs); - stripCmd.description = "Stripping unneeded symbols from " - + outputs["android.nativelibrary"][0].fileName; - return [copyCmd, stripCmd]; + var stripArgs = ["--strip-unneeded", "-o", output.filePath, input.filePath]; + var stripCmd = new Command(product.cpp.stripPath, stripArgs); + stripCmd.description = "Stripping unneeded symbols from " + input.fileName; + return stripCmd; } } |