Use prebuilts for more tools in unbundled builds

Move the logic from Make that uses prebuilts for more tools for
unbundled builds, and export the values back to make.

Test: m checkbuild
Change-Id: I8c7031e0feaa9328a2b73db6dc8e63e12d1d12f7
This commit is contained in:
Colin Cross 2019-08-08 12:56:34 -07:00
parent 08f9262577
commit bdf9514e45
4 changed files with 71 additions and 38 deletions

View File

@ -31,31 +31,13 @@ import (
var (
Signapk = pctx.AndroidStaticRule("signapk",
blueprint.RuleParams{
Command: `${config.JavaCmd} ${config.JavaVmFlags} -Djava.library.path=$$(dirname $signapkJniLibrary) ` +
`-jar $signapkCmd $flags $certificates $in $out`,
CommandDeps: []string{"$signapkCmd", "$signapkJniLibrary"},
Command: `${config.JavaCmd} ${config.JavaVmFlags} -Djava.library.path=$$(dirname ${config.SignapkJniLibrary}) ` +
`-jar ${config.SignapkCmd} $flags $certificates $in $out`,
CommandDeps: []string{"${config.SignapkCmd}", "${config.SignapkJniLibrary}"},
},
"flags", "certificates")
androidManifestMerger = pctx.AndroidStaticRule("androidManifestMerger",
blueprint.RuleParams{
Command: "java -classpath $androidManifestMergerCmd com.android.manifmerger.Main merge " +
"--main $in --libs $libsManifests --out $out",
CommandDeps: []string{"$androidManifestMergerCmd"},
Description: "merge manifest files",
},
"libsManifests")
)
func init() {
pctx.SourcePathVariable("androidManifestMergerCmd", "prebuilts/devtools/tools/lib/manifest-merger.jar")
pctx.HostBinToolVariable("aaptCmd", "aapt")
pctx.HostJavaToolVariable("signapkCmd", "signapk.jar")
// TODO(ccross): this should come from the signapk dependencies, but we don't have any way
// to express host JNI dependencies yet.
pctx.HostJNIToolVariable("signapkJniLibrary", "libconscrypt_openjdk_jni")
}
var combineApk = pctx.AndroidStaticRule("combineApk",
blueprint.RuleParams{
Command: `${config.MergeZipsCmd} $out $in`,

View File

@ -139,27 +139,66 @@ func init() {
pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar")
hostBinToolVariableWithPrebuilt := func(name, prebuiltDir, tool string) {
pctx.HostBinToolVariable("ManifestCheckCmd", "manifest_check")
pctx.HostBinToolVariable("ManifestFixerCmd", "manifest_fixer")
pctx.HostBinToolVariable("ManifestMergerCmd", "manifest-merger")
pctx.HostBinToolVariable("Class2Greylist", "class2greylist")
pctx.HostBinToolVariable("HiddenAPI", "hiddenapi")
hostBinToolVariableWithSdkToolsPrebuilt("Aapt2Cmd", "aapt2")
hostBinToolVariableWithBuildToolsPrebuilt("AidlCmd", "aidl")
hostBinToolVariableWithBuildToolsPrebuilt("ZipAlign", "zipalign")
hostJavaToolVariableWithSdkToolsPrebuilt("SignapkCmd", "signapk")
// TODO(ccross): this should come from the signapk dependencies, but we don't have any way
// to express host JNI dependencies yet.
hostJNIToolVariableWithSdkToolsPrebuilt("SignapkJniLibrary", "libconscrypt_openjdk_jni")
}
func hostBinToolVariableWithSdkToolsPrebuilt(name, tool string) {
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() {
return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool)
return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "bin", tool)
} else {
return pctx.HostBinToolPath(ctx, tool).String()
}
})
}
hostBinToolVariableWithPrebuilt("Aapt2Cmd", "prebuilts/sdk/tools", "aapt2")
func hostJavaToolVariableWithSdkToolsPrebuilt(name, tool string) {
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() {
return filepath.Join("prebuilts/sdk/tools/lib", tool+".jar")
} else {
return pctx.HostJavaToolPath(ctx, tool+".jar").String()
}
})
}
pctx.HostBinToolVariable("ManifestCheckCmd", "manifest_check")
pctx.HostBinToolVariable("ManifestFixerCmd", "manifest_fixer")
func hostJNIToolVariableWithSdkToolsPrebuilt(name, tool string) {
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() {
ext := ".so"
if runtime.GOOS == "darwin" {
ext = ".dylib"
}
return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "lib64", tool+ext)
} else {
return pctx.HostJNIToolPath(ctx, tool).String()
}
})
}
pctx.HostBinToolVariable("ManifestMergerCmd", "manifest-merger")
pctx.HostBinToolVariable("ZipAlign", "zipalign")
pctx.HostBinToolVariable("Class2Greylist", "class2greylist")
pctx.HostBinToolVariable("HiddenAPI", "hiddenapi")
func hostBinToolVariableWithBuildToolsPrebuilt(name, tool string) {
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
if ctx.Config().UnbundledBuild() || ctx.Config().IsPdkBuild() {
return filepath.Join("prebuilts/build-tools", ctx.Config().PrebuiltOS(), "bin", tool)
} else {
return pctx.HostBinToolPath(ctx, tool).String()
}
})
}
// JavaCmd returns a SourcePath object with the path to the java command.

View File

@ -82,4 +82,17 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("HIDDENAPI", "${HiddenAPI}")
ctx.Strict("DEX_FLAGS", "${DexFlags}")
ctx.Strict("AIDL", "${AidlCmd}")
ctx.Strict("AAPT2", "${Aapt2Cmd}")
ctx.Strict("ZIPALIGN", "${ZipAlign}")
ctx.Strict("SIGNAPK_JAR", "${SignapkCmd}")
ctx.Strict("SIGNAPK_JNI_LIBRARY_PATH", "${SignapkJniLibrary}")
ctx.Strict("SOONG_ZIP", "${SoongZipCmd}")
ctx.Strict("MERGE_ZIPS", "${MergeZipsCmd}")
ctx.Strict("ZIP2ZIP", "${Zip2ZipCmd}")
ctx.Strict("ZIPTIME", "${Ziptime}")
}

View File

@ -23,7 +23,6 @@ import (
)
func init() {
pctx.HostBinToolVariable("aidlCmd", "aidl")
pctx.HostBinToolVariable("syspropCmd", "sysprop_java")
pctx.SourcePathVariable("logtagsCmd", "build/make/tools/java-event-log-tags.py")
pctx.SourcePathVariable("mergeLogtagsCmd", "build/make/tools/merge-event-log-tags.py")
@ -33,8 +32,8 @@ func init() {
var (
aidl = pctx.AndroidStaticRule("aidl",
blueprint.RuleParams{
Command: "$aidlCmd -d$depFile $aidlFlags $in $out",
CommandDeps: []string{"$aidlCmd"},
Command: "${config.AidlCmd} -d$depFile $aidlFlags $in $out",
CommandDeps: []string{"${config.AidlCmd}"},
},
"depFile", "aidlFlags")