Use Rule-local implicit dependencies
Depends on https://github.com/google/blueprint/pull/78 This uses the new CommandDeps field to move implicit dependencies embedded in the Command string next to the definition, instead of having to specify them in every BuildParam struct. This should make it easier to verify dependencies. Change-Id: I2711b160920e22fa962a436e1f7041272166f50f
This commit is contained in:
@@ -45,6 +45,7 @@ var (
|
|||||||
Depfile: "${out}.d",
|
Depfile: "${out}.d",
|
||||||
Deps: blueprint.DepsGCC,
|
Deps: blueprint.DepsGCC,
|
||||||
Command: "$relPwd $ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
|
Command: "$relPwd $ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
|
||||||
|
CommandDeps: []string{"$ccCmd"},
|
||||||
Description: "cc $out",
|
Description: "cc $out",
|
||||||
},
|
},
|
||||||
"ccCmd", "cFlags")
|
"ccCmd", "cFlags")
|
||||||
@@ -53,6 +54,7 @@ var (
|
|||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$ldCmd ${ldDirFlags} ${crtBegin} @${out}.rsp " +
|
Command: "$ldCmd ${ldDirFlags} ${crtBegin} @${out}.rsp " +
|
||||||
"${libFlags} ${crtEnd} -o ${out} ${ldFlags}",
|
"${libFlags} ${crtEnd} -o ${out} ${ldFlags}",
|
||||||
|
CommandDeps: []string{"$ldCmd"},
|
||||||
Description: "ld $out",
|
Description: "ld $out",
|
||||||
Rspfile: "${out}.rsp",
|
Rspfile: "${out}.rsp",
|
||||||
RspfileContent: "${in}",
|
RspfileContent: "${in}",
|
||||||
@@ -62,6 +64,7 @@ var (
|
|||||||
partialLd = pctx.StaticRule("partialLd",
|
partialLd = pctx.StaticRule("partialLd",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$ldCmd -r ${in} -o ${out}",
|
Command: "$ldCmd -r ${in} -o ${out}",
|
||||||
|
CommandDeps: []string{"$ldCmd"},
|
||||||
Description: "partialLd $out",
|
Description: "partialLd $out",
|
||||||
},
|
},
|
||||||
"ldCmd")
|
"ldCmd")
|
||||||
@@ -69,6 +72,7 @@ var (
|
|||||||
ar = pctx.StaticRule("ar",
|
ar = pctx.StaticRule("ar",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "rm -f ${out} && $arCmd $arFlags $out @${out}.rsp",
|
Command: "rm -f ${out} && $arCmd $arFlags $out @${out}.rsp",
|
||||||
|
CommandDeps: []string{"$arCmd"},
|
||||||
Description: "ar $out",
|
Description: "ar $out",
|
||||||
Rspfile: "${out}.rsp",
|
Rspfile: "${out}.rsp",
|
||||||
RspfileContent: "${in}",
|
RspfileContent: "${in}",
|
||||||
@@ -78,6 +82,7 @@ var (
|
|||||||
darwinAr = pctx.StaticRule("darwinAr",
|
darwinAr = pctx.StaticRule("darwinAr",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "rm -f ${out} && $arCmd $arFlags $out $in",
|
Command: "rm -f ${out} && $arCmd $arFlags $out $in",
|
||||||
|
CommandDeps: []string{"$arCmd"},
|
||||||
Description: "ar $out",
|
Description: "ar $out",
|
||||||
},
|
},
|
||||||
"arCmd", "arFlags")
|
"arCmd", "arFlags")
|
||||||
@@ -85,6 +90,7 @@ var (
|
|||||||
darwinAppendAr = pctx.StaticRule("darwinAppendAr",
|
darwinAppendAr = pctx.StaticRule("darwinAppendAr",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "cp -f ${inAr} ${out}.tmp && $arCmd $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
|
Command: "cp -f ${inAr} ${out}.tmp && $arCmd $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
|
||||||
|
CommandDeps: []string{"$arCmd"},
|
||||||
Description: "ar $out",
|
Description: "ar $out",
|
||||||
},
|
},
|
||||||
"arCmd", "arFlags", "inAr")
|
"arCmd", "arFlags", "inAr")
|
||||||
@@ -92,6 +98,7 @@ var (
|
|||||||
prefixSymbols = pctx.StaticRule("prefixSymbols",
|
prefixSymbols = pctx.StaticRule("prefixSymbols",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$objcopyCmd --prefix-symbols=${prefix} ${in} ${out}",
|
Command: "$objcopyCmd --prefix-symbols=${prefix} ${in} ${out}",
|
||||||
|
CommandDeps: []string{"$objcopyCmd"},
|
||||||
Description: "prefixSymbols $out",
|
Description: "prefixSymbols $out",
|
||||||
},
|
},
|
||||||
"objcopyCmd", "prefix")
|
"objcopyCmd", "prefix")
|
||||||
@@ -103,6 +110,7 @@ var (
|
|||||||
Depfile: "${out}.d",
|
Depfile: "${out}.d",
|
||||||
Deps: blueprint.DepsGCC,
|
Deps: blueprint.DepsGCC,
|
||||||
Command: "$copyGccLibPath $out $ccCmd $cFlags -print-file-name=${libName}",
|
Command: "$copyGccLibPath $out $ccCmd $cFlags -print-file-name=${libName}",
|
||||||
|
CommandDeps: []string{"$copyGccLibPath", "$ccCmd"},
|
||||||
Description: "copy gcc $out",
|
Description: "copy gcc $out",
|
||||||
},
|
},
|
||||||
"ccCmd", "cFlags", "libName")
|
"ccCmd", "cFlags", "libName")
|
||||||
@@ -202,13 +210,11 @@ func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFil
|
|||||||
ccCmd = gccCmd(flags.toolchain, ccCmd)
|
ccCmd = gccCmd(flags.toolchain, ccCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
objDeps := append([]string{ccCmd}, deps...)
|
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: cc,
|
Rule: cc,
|
||||||
Outputs: []string{objFile},
|
Outputs: []string{objFile},
|
||||||
Inputs: []string{srcFile},
|
Inputs: []string{srcFile},
|
||||||
Implicits: objDeps,
|
Implicits: deps,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"cFlags": moduleCflags,
|
"cFlags": moduleCflags,
|
||||||
"ccCmd": ccCmd,
|
"ccCmd": ccCmd,
|
||||||
@@ -227,10 +233,9 @@ func TransformObjToStaticLib(ctx common.AndroidModuleContext, objFiles []string,
|
|||||||
arFlags := "crsPD"
|
arFlags := "crsPD"
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: ar,
|
Rule: ar,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
Inputs: objFiles,
|
Inputs: objFiles,
|
||||||
Implicits: []string{arCmd},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"arFlags": arFlags,
|
"arFlags": arFlags,
|
||||||
"arCmd": arCmd,
|
"arCmd": arCmd,
|
||||||
@@ -337,7 +342,6 @@ func TransformObjToDynamicBinary(ctx common.AndroidModuleContext,
|
|||||||
ldDirs = append(ldDirs, dir)
|
ldDirs = append(ldDirs, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
deps = append(deps, ldCmd)
|
|
||||||
deps = append(deps, sharedLibs...)
|
deps = append(deps, sharedLibs...)
|
||||||
deps = append(deps, staticLibs...)
|
deps = append(deps, staticLibs...)
|
||||||
deps = append(deps, lateStaticLibs...)
|
deps = append(deps, lateStaticLibs...)
|
||||||
@@ -368,13 +372,10 @@ func TransformObjsToObj(ctx common.AndroidModuleContext, objFiles []string,
|
|||||||
|
|
||||||
ldCmd := gccCmd(flags.toolchain, "ld")
|
ldCmd := gccCmd(flags.toolchain, "ld")
|
||||||
|
|
||||||
deps := []string{ldCmd}
|
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: partialLd,
|
Rule: partialLd,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
Inputs: objFiles,
|
Inputs: objFiles,
|
||||||
Implicits: deps,
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"ldCmd": ldCmd,
|
"ldCmd": ldCmd,
|
||||||
},
|
},
|
||||||
@@ -388,10 +389,9 @@ func TransformBinaryPrefixSymbols(ctx common.AndroidModuleContext, prefix string
|
|||||||
objcopyCmd := gccCmd(flags.toolchain, "objcopy")
|
objcopyCmd := gccCmd(flags.toolchain, "objcopy")
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: prefixSymbols,
|
Rule: prefixSymbols,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
Inputs: []string{inputFile},
|
Inputs: []string{inputFile},
|
||||||
Implicits: []string{objcopyCmd},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"objcopyCmd": objcopyCmd,
|
"objcopyCmd": objcopyCmd,
|
||||||
"prefix": prefix,
|
"prefix": prefix,
|
||||||
@@ -405,10 +405,6 @@ func CopyGccLib(ctx common.AndroidModuleContext, libName string,
|
|||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: copyGccLib,
|
Rule: copyGccLib,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
Implicits: []string{
|
|
||||||
"$copyGccLibPath",
|
|
||||||
gccCmd(flags.toolchain, "gcc"),
|
|
||||||
},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"ccCmd": gccCmd(flags.toolchain, "gcc"),
|
"ccCmd": gccCmd(flags.toolchain, "gcc"),
|
||||||
"cFlags": flags.globalFlags,
|
"cFlags": flags.globalFlags,
|
||||||
|
16
cc/gen.go
16
cc/gen.go
@@ -38,6 +38,7 @@ var (
|
|||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "BISON_PKGDATADIR=$yaccDataDir $yaccCmd -d $yaccFlags -o $cppFile $in && " +
|
Command: "BISON_PKGDATADIR=$yaccDataDir $yaccCmd -d $yaccFlags -o $cppFile $in && " +
|
||||||
"cp -f $hppFile $hFile",
|
"cp -f $hppFile $hFile",
|
||||||
|
CommandDeps: []string{"$yaccCmd"},
|
||||||
Description: "yacc $out",
|
Description: "yacc $out",
|
||||||
},
|
},
|
||||||
"yaccFlags", "cppFile", "hppFile", "hFile")
|
"yaccFlags", "cppFile", "hppFile", "hFile")
|
||||||
@@ -45,6 +46,7 @@ var (
|
|||||||
lex = pctx.StaticRule("lex",
|
lex = pctx.StaticRule("lex",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$lexCmd -o$out $in",
|
Command: "$lexCmd -o$out $in",
|
||||||
|
CommandDeps: []string{"$lexCmd"},
|
||||||
Description: "lex $out",
|
Description: "lex $out",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@@ -57,10 +59,9 @@ func genYacc(ctx common.AndroidModuleContext, yaccFile, yaccFlags string) (cppFi
|
|||||||
headerFile = pathtools.ReplaceExtension(cppFile, "h")
|
headerFile = pathtools.ReplaceExtension(cppFile, "h")
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: yacc,
|
Rule: yacc,
|
||||||
Outputs: []string{cppFile, headerFile},
|
Outputs: []string{cppFile, headerFile},
|
||||||
Inputs: []string{yaccFile},
|
Inputs: []string{yaccFile},
|
||||||
Implicits: []string{"$yaccCmd"},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"yaccFlags": yaccFlags,
|
"yaccFlags": yaccFlags,
|
||||||
"cppFile": cppFile,
|
"cppFile": cppFile,
|
||||||
@@ -78,10 +79,9 @@ func genLex(ctx common.AndroidModuleContext, lexFile string) (cppFile string) {
|
|||||||
cppFile = pathtools.ReplaceExtension(cppFile, "cpp")
|
cppFile = pathtools.ReplaceExtension(cppFile, "cpp")
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: lex,
|
Rule: lex,
|
||||||
Outputs: []string{cppFile},
|
Outputs: []string{cppFile},
|
||||||
Inputs: []string{lexFile},
|
Inputs: []string{lexFile},
|
||||||
Implicits: []string{"$lexCmd"},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return cppFile
|
return cppFile
|
||||||
|
@@ -33,6 +33,7 @@ var (
|
|||||||
androidbp = pctx.StaticRule("androidbp",
|
androidbp = pctx.StaticRule("androidbp",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: androidbpCmd + " ${srcDir}/Android.bp $in $out",
|
Command: androidbpCmd + " ${srcDir}/Android.bp $in $out",
|
||||||
|
CommandDeps: []string{androidbpCmd},
|
||||||
Description: "androidbp $out",
|
Description: "androidbp $out",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@ var (
|
|||||||
globRule = pctx.StaticRule("globRule",
|
globRule = pctx.StaticRule("globRule",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: fmt.Sprintf(`%s -o $out $excludes "$glob"`, globCmd),
|
Command: fmt.Sprintf(`%s -o $out $excludes "$glob"`, globCmd),
|
||||||
|
CommandDeps: []string{globCmd},
|
||||||
Description: "glob $glob",
|
Description: "glob $glob",
|
||||||
|
|
||||||
Restat: true,
|
Restat: true,
|
||||||
@@ -95,9 +96,8 @@ func GlobRule(ctx globContext, globPattern string, excludes []string,
|
|||||||
// Create a rule to rebuild fileListFile if a directory in depFile changes. fileListFile
|
// Create a rule to rebuild fileListFile if a directory in depFile changes. fileListFile
|
||||||
// will only be rewritten if it has changed, preventing unnecesary build.ninja regenerations.
|
// will only be rewritten if it has changed, preventing unnecesary build.ninja regenerations.
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: globRule,
|
Rule: globRule,
|
||||||
Outputs: []string{fileListFile},
|
Outputs: []string{fileListFile},
|
||||||
Implicits: []string{globCmd},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"glob": globPattern,
|
"glob": globPattern,
|
||||||
"excludes": JoinWithPrefixAndQuote(excludes, "-e "),
|
"excludes": JoinWithPrefixAndQuote(excludes, "-e "),
|
||||||
|
@@ -570,11 +570,10 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx blueprint.SingletonConte
|
|||||||
|
|
||||||
transMk := filepath.Join("androidmk", "Android_"+strings.Replace(filepath.Dir(origBp), "/", "_", -1)+".mk")
|
transMk := filepath.Join("androidmk", "Android_"+strings.Replace(filepath.Dir(origBp), "/", "_", -1)+".mk")
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: androidbp,
|
Rule: androidbp,
|
||||||
Outputs: []string{transMk},
|
Outputs: []string{transMk},
|
||||||
Inputs: []string{bpFile},
|
Inputs: []string{bpFile},
|
||||||
Implicits: []string{androidbpCmd},
|
Optional: true,
|
||||||
Optional: true,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
androidMks = append(androidMks, transMk)
|
androidMks = append(androidMks, transMk)
|
||||||
|
@@ -34,6 +34,7 @@ var (
|
|||||||
`$aaptCmd package -m $aaptFlags -P $publicResourcesFile -G $proguardOptionsFile ` +
|
`$aaptCmd package -m $aaptFlags -P $publicResourcesFile -G $proguardOptionsFile ` +
|
||||||
`-J $javaDir || ( rm -rf "$javaDir/*"; exit 41 ) && ` +
|
`-J $javaDir || ( rm -rf "$javaDir/*"; exit 41 ) && ` +
|
||||||
`find $javaDir -name "*.java" > $javaFileList`,
|
`find $javaDir -name "*.java" > $javaFileList`,
|
||||||
|
CommandDeps: []string{"$aaptCmd"},
|
||||||
Description: "aapt create R.java $out",
|
Description: "aapt create R.java $out",
|
||||||
},
|
},
|
||||||
"aaptFlags", "publicResourcesFile", "proguardOptionsFile", "javaDir", "javaFileList")
|
"aaptFlags", "publicResourcesFile", "proguardOptionsFile", "javaDir", "javaFileList")
|
||||||
@@ -41,6 +42,7 @@ var (
|
|||||||
aaptCreateAssetsPackage = pctx.StaticRule("aaptCreateAssetsPackage",
|
aaptCreateAssetsPackage = pctx.StaticRule("aaptCreateAssetsPackage",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `rm -f $out && $aaptCmd package $aaptFlags -F $out`,
|
Command: `rm -f $out && $aaptCmd package $aaptFlags -F $out`,
|
||||||
|
CommandDeps: []string{"$aaptCmd"},
|
||||||
Description: "aapt export package $out",
|
Description: "aapt export package $out",
|
||||||
},
|
},
|
||||||
"aaptFlags", "publicResourcesFile", "proguardOptionsFile", "javaDir", "javaFileList")
|
"aaptFlags", "publicResourcesFile", "proguardOptionsFile", "javaDir", "javaFileList")
|
||||||
@@ -49,6 +51,7 @@ var (
|
|||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
// TODO: add-jni-shared-libs-to-package
|
// TODO: add-jni-shared-libs-to-package
|
||||||
Command: `cp -f $in $out.tmp && $aaptCmd package -u $aaptFlags -F $out.tmp && mv $out.tmp $out`,
|
Command: `cp -f $in $out.tmp && $aaptCmd package -u $aaptFlags -F $out.tmp && mv $out.tmp $out`,
|
||||||
|
CommandDeps: []string{"$aaptCmd"},
|
||||||
Description: "aapt package $out",
|
Description: "aapt package $out",
|
||||||
},
|
},
|
||||||
"aaptFlags")
|
"aaptFlags")
|
||||||
@@ -56,6 +59,7 @@ var (
|
|||||||
zipalign = pctx.StaticRule("zipalign",
|
zipalign = pctx.StaticRule("zipalign",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `$zipalignCmd -f $zipalignFlags 4 $in $out`,
|
Command: `$zipalignCmd -f $zipalignFlags 4 $in $out`,
|
||||||
|
CommandDeps: []string{"$zipalignCmd"},
|
||||||
Description: "zipalign $out",
|
Description: "zipalign $out",
|
||||||
},
|
},
|
||||||
"zipalignFlags")
|
"zipalignFlags")
|
||||||
@@ -63,6 +67,7 @@ var (
|
|||||||
signapk = pctx.StaticRule("signapk",
|
signapk = pctx.StaticRule("signapk",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `java -jar $signapkCmd $certificates $in $out`,
|
Command: `java -jar $signapkCmd $certificates $in $out`,
|
||||||
|
CommandDeps: []string{"$signapkCmd"},
|
||||||
Description: "signapk $out",
|
Description: "signapk $out",
|
||||||
},
|
},
|
||||||
"certificates")
|
"certificates")
|
||||||
@@ -71,6 +76,7 @@ var (
|
|||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "java -classpath $androidManifestMergerCmd com.android.manifmerger.Main merge " +
|
Command: "java -classpath $androidManifestMergerCmd com.android.manifmerger.Main merge " +
|
||||||
"--main $in --libs $libsManifests --out $out",
|
"--main $in --libs $libsManifests --out $out",
|
||||||
|
CommandDeps: []string{"$androidManifestMergerCmd"},
|
||||||
Description: "merge manifest files $out",
|
Description: "merge manifest files $out",
|
||||||
},
|
},
|
||||||
"libsManifests")
|
"libsManifests")
|
||||||
@@ -96,8 +102,6 @@ func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string,
|
|||||||
publicResourcesFile := filepath.Join(common.ModuleOutDir(ctx), "public_resources.xml")
|
publicResourcesFile := filepath.Join(common.ModuleOutDir(ctx), "public_resources.xml")
|
||||||
proguardOptionsFile := filepath.Join(common.ModuleOutDir(ctx), "proguard.options")
|
proguardOptionsFile := filepath.Join(common.ModuleOutDir(ctx), "proguard.options")
|
||||||
|
|
||||||
deps = append([]string{"$aaptCmd"}, deps...)
|
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: aaptCreateResourceJavaFile,
|
Rule: aaptCreateResourceJavaFile,
|
||||||
Outputs: []string{publicResourcesFile, proguardOptionsFile, javaFileList},
|
Outputs: []string{publicResourcesFile, proguardOptionsFile, javaFileList},
|
||||||
@@ -117,8 +121,6 @@ func CreateResourceJavaFiles(ctx common.AndroidModuleContext, flags []string,
|
|||||||
func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps []string) string {
|
func CreateExportPackage(ctx common.AndroidModuleContext, flags []string, deps []string) string {
|
||||||
outputFile := filepath.Join(common.ModuleOutDir(ctx), "package-export.apk")
|
outputFile := filepath.Join(common.ModuleOutDir(ctx), "package-export.apk")
|
||||||
|
|
||||||
deps = append([]string{"$aaptCmd"}, deps...)
|
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: aaptCreateAssetsPackage,
|
Rule: aaptCreateAssetsPackage,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
@@ -137,10 +139,9 @@ func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile s
|
|||||||
resourceApk := filepath.Join(common.ModuleOutDir(ctx), "resources.apk")
|
resourceApk := filepath.Join(common.ModuleOutDir(ctx), "resources.apk")
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: aaptAddResources,
|
Rule: aaptAddResources,
|
||||||
Outputs: []string{resourceApk},
|
Outputs: []string{resourceApk},
|
||||||
Inputs: []string{jarFile},
|
Inputs: []string{jarFile},
|
||||||
Implicits: []string{"$aaptCmd"},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"aaptFlags": strings.Join(flags, " "),
|
"aaptFlags": strings.Join(flags, " "),
|
||||||
},
|
},
|
||||||
@@ -154,10 +155,9 @@ func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile s
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: signapk,
|
Rule: signapk,
|
||||||
Outputs: []string{signedApk},
|
Outputs: []string{signedApk},
|
||||||
Inputs: []string{resourceApk},
|
Inputs: []string{resourceApk},
|
||||||
Implicits: []string{"$signapkCmd"},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"certificates": strings.Join(certificateArgs, " "),
|
"certificates": strings.Join(certificateArgs, " "),
|
||||||
},
|
},
|
||||||
@@ -166,10 +166,9 @@ func CreateAppPackage(ctx common.AndroidModuleContext, flags []string, jarFile s
|
|||||||
outputFile := filepath.Join(common.ModuleOutDir(ctx), "package.apk")
|
outputFile := filepath.Join(common.ModuleOutDir(ctx), "package.apk")
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: zipalign,
|
Rule: zipalign,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
Inputs: []string{signedApk},
|
Inputs: []string{signedApk},
|
||||||
Implicits: []string{"$zipalignCmd"},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"zipalignFlags": "",
|
"zipalignFlags": "",
|
||||||
},
|
},
|
||||||
|
@@ -52,6 +52,7 @@ var (
|
|||||||
jar = pctx.StaticRule("jar",
|
jar = pctx.StaticRule("jar",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `$jarCmd -o $out $jarArgs`,
|
Command: `$jarCmd -o $out $jarArgs`,
|
||||||
|
CommandDeps: []string{"$jarCmd"},
|
||||||
Description: "jar $out",
|
Description: "jar $out",
|
||||||
},
|
},
|
||||||
"jarCmd", "jarArgs")
|
"jarCmd", "jarArgs")
|
||||||
@@ -61,6 +62,7 @@ var (
|
|||||||
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
||||||
`$dxCmd --dex --output=$outDir $dxFlags $in || ( rm -rf "$outDir"; exit 41 ) && ` +
|
`$dxCmd --dex --output=$outDir $dxFlags $in || ( rm -rf "$outDir"; exit 41 ) && ` +
|
||||||
`find "$outDir" -name "classes*.dex" > $out`,
|
`find "$outDir" -name "classes*.dex" > $out`,
|
||||||
|
CommandDeps: []string{"$dxCmd"},
|
||||||
Description: "dex $out",
|
Description: "dex $out",
|
||||||
},
|
},
|
||||||
"outDir", "dxFlags")
|
"outDir", "dxFlags")
|
||||||
@@ -68,6 +70,7 @@ var (
|
|||||||
jarjar = pctx.StaticRule("jarjar",
|
jarjar = pctx.StaticRule("jarjar",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "java -jar $jarjarCmd process $rulesFile $in $out",
|
Command: "java -jar $jarjarCmd process $rulesFile $in $out",
|
||||||
|
CommandDeps: []string{"$jarjarCmd", "$rulesFile"},
|
||||||
Description: "jarjar $out",
|
Description: "jarjar $out",
|
||||||
},
|
},
|
||||||
"rulesFile")
|
"rulesFile")
|
||||||
@@ -156,8 +159,6 @@ func TransformClassesToJar(ctx common.AndroidModuleContext, classes []jarSpec,
|
|||||||
jarArgs = append(jarArgs, "-m "+manifest)
|
jarArgs = append(jarArgs, "-m "+manifest)
|
||||||
}
|
}
|
||||||
|
|
||||||
deps = append(deps, "$jarCmd")
|
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: jar,
|
Rule: jar,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
@@ -177,10 +178,9 @@ func TransformClassesJarToDex(ctx common.AndroidModuleContext, classesJar string
|
|||||||
outputFile := filepath.Join(common.ModuleOutDir(ctx), "dex.filelist")
|
outputFile := filepath.Join(common.ModuleOutDir(ctx), "dex.filelist")
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: dx,
|
Rule: dx,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
Inputs: []string{classesJar},
|
Inputs: []string{classesJar},
|
||||||
Implicits: []string{"$dxCmd"},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"dxFlags": flags.dxFlags,
|
"dxFlags": flags.dxFlags,
|
||||||
"outDir": outDir,
|
"outDir": outDir,
|
||||||
@@ -205,8 +205,6 @@ func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
|
|||||||
deps = append(deps, dexJarSpec.fileList)
|
deps = append(deps, dexJarSpec.fileList)
|
||||||
jarArgs = append(jarArgs, dexJarSpec.soongJarArgs())
|
jarArgs = append(jarArgs, dexJarSpec.soongJarArgs())
|
||||||
|
|
||||||
deps = append(deps, "$jarCmd")
|
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: jar,
|
Rule: jar,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
@@ -222,10 +220,9 @@ func TransformDexToJavaLib(ctx common.AndroidModuleContext, resources []jarSpec,
|
|||||||
func TransformJarJar(ctx common.AndroidModuleContext, classesJar string, rulesFile string) string {
|
func TransformJarJar(ctx common.AndroidModuleContext, classesJar string, rulesFile string) string {
|
||||||
outputFile := filepath.Join(common.ModuleOutDir(ctx), "classes-jarjar.jar")
|
outputFile := filepath.Join(common.ModuleOutDir(ctx), "classes-jarjar.jar")
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: jarjar,
|
Rule: jarjar,
|
||||||
Outputs: []string{outputFile},
|
Outputs: []string{outputFile},
|
||||||
Inputs: []string{classesJar},
|
Inputs: []string{classesJar},
|
||||||
Implicits: []string{"$jarjarCmd"},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"rulesFile": rulesFile,
|
"rulesFile": rulesFile,
|
||||||
},
|
},
|
||||||
|
17
java/gen.go
17
java/gen.go
@@ -44,6 +44,7 @@ var (
|
|||||||
aidl = pctx.StaticRule("aidl",
|
aidl = pctx.StaticRule("aidl",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$aidlCmd -d$depFile $aidlFlags $in $out",
|
Command: "$aidlCmd -d$depFile $aidlFlags $in $out",
|
||||||
|
CommandDeps: []string{"$aidlCmd"},
|
||||||
Description: "aidl $out",
|
Description: "aidl $out",
|
||||||
},
|
},
|
||||||
"depFile", "aidlFlags")
|
"depFile", "aidlFlags")
|
||||||
@@ -51,12 +52,14 @@ var (
|
|||||||
logtags = pctx.StaticRule("logtags",
|
logtags = pctx.StaticRule("logtags",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$logtagsCmd -o $out $in $allLogtagsFile",
|
Command: "$logtagsCmd -o $out $in $allLogtagsFile",
|
||||||
|
CommandDeps: []string{"$logtagsCmd"},
|
||||||
Description: "logtags $out",
|
Description: "logtags $out",
|
||||||
})
|
})
|
||||||
|
|
||||||
mergeLogtags = pctx.StaticRule("mergeLogtags",
|
mergeLogtags = pctx.StaticRule("mergeLogtags",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$mergeLogtagsCmd -o $out $in",
|
Command: "$mergeLogtagsCmd -o $out $in",
|
||||||
|
CommandDeps: []string{"$mergeLogtagsCmd"},
|
||||||
Description: "merge logtags $out",
|
Description: "merge logtags $out",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@@ -68,10 +71,9 @@ func genAidl(ctx common.AndroidModuleContext, aidlFile, aidlFlags string) string
|
|||||||
depFile := javaFile + ".d"
|
depFile := javaFile + ".d"
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: aidl,
|
Rule: aidl,
|
||||||
Outputs: []string{javaFile},
|
Outputs: []string{javaFile},
|
||||||
Inputs: []string{aidlFile},
|
Inputs: []string{aidlFile},
|
||||||
Implicits: []string{"$aidlCmd"},
|
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"depFile": depFile,
|
"depFile": depFile,
|
||||||
"aidlFlags": aidlFlags,
|
"aidlFlags": aidlFlags,
|
||||||
@@ -87,10 +89,9 @@ func genLogtags(ctx common.AndroidModuleContext, logtagsFile string) string {
|
|||||||
javaFile = pathtools.ReplaceExtension(javaFile, "java")
|
javaFile = pathtools.ReplaceExtension(javaFile, "java")
|
||||||
|
|
||||||
ctx.Build(pctx, blueprint.BuildParams{
|
ctx.Build(pctx, blueprint.BuildParams{
|
||||||
Rule: logtags,
|
Rule: logtags,
|
||||||
Outputs: []string{javaFile},
|
Outputs: []string{javaFile},
|
||||||
Inputs: []string{logtagsFile},
|
Inputs: []string{logtagsFile},
|
||||||
Implicits: []string{"$logtagsCmd"},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return javaFile
|
return javaFile
|
||||||
|
Reference in New Issue
Block a user