Add RuleBuilder helper functions for built and prebuilt tools
Replace the common pattern of: cmd.Tool(ctx.Config().HostToolPath(ctx, "tool")) with: cmd.BuiltTool("tool") And similarly for PrebuiltBuildTool. Test: m checkbuild Change-Id: I7d63188505362c7df6a3b3e7330b4a2cca5a2409
This commit is contained in:
parent
a3002fc7ab
commit
ee94d6ab14
|
@ -135,7 +135,7 @@ func ProtoRule(ctx ModuleContext, rule *RuleBuilder, protoFile Path, flags Proto
|
|||
}
|
||||
|
||||
rule.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "aprotoc")).
|
||||
BuiltTool(ctx, "aprotoc").
|
||||
FlagWithArg(flags.OutTypeFlag+"=", strings.Join(flags.OutParams, ",")+":"+outDir.String()).
|
||||
FlagWithDepFile("--dependency_out=", depFile).
|
||||
FlagWithArg("-I ", protoBase).
|
||||
|
@ -145,5 +145,5 @@ func ProtoRule(ctx ModuleContext, rule *RuleBuilder, protoFile Path, flags Proto
|
|||
ImplicitOutputs(outputs)
|
||||
|
||||
rule.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "dep_fixer")).Flag(depFile.String())
|
||||
BuiltTool(ctx, "dep_fixer").Flag(depFile.String())
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ var _ BuilderContext = SingletonContext(nil)
|
|||
|
||||
func (r *RuleBuilder) depFileMergerCmd(ctx PathContext, depFiles WritablePaths) *RuleBuilderCommand {
|
||||
return r.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "dep_fixer")).
|
||||
BuiltTool(ctx, "dep_fixer").
|
||||
Inputs(depFiles.Paths())
|
||||
}
|
||||
|
||||
|
@ -352,7 +352,7 @@ func (r *RuleBuilder) Build(pctx PackageContext, ctx BuilderContext, name string
|
|||
}
|
||||
|
||||
sboxCmd := &RuleBuilderCommand{}
|
||||
sboxCmd.Tool(ctx.Config().HostToolPath(ctx, "sbox")).
|
||||
sboxCmd.BuiltTool(ctx, "sbox").
|
||||
Flag("-c").Text(commandString).
|
||||
Flag("--sandbox-path").Text(shared.TempDirForOutDir(PathForOutput(ctx).String())).
|
||||
Flag("--output-root").Text(r.sboxOutDir.String()).
|
||||
|
@ -478,6 +478,24 @@ func (c *RuleBuilderCommand) Tool(path Path) *RuleBuilderCommand {
|
|||
return c.Text(path.String())
|
||||
}
|
||||
|
||||
// BuiltTool adds the specified tool path that was built using a host Soong module to the command line. The path will
|
||||
// be also added to the dependencies returned by RuleBuilder.Tools.
|
||||
//
|
||||
// It is equivalent to:
|
||||
// cmd.Tool(ctx.Config().HostToolPath(ctx, tool))
|
||||
func (c *RuleBuilderCommand) BuiltTool(ctx PathContext, tool string) *RuleBuilderCommand {
|
||||
return c.Tool(ctx.Config().HostToolPath(ctx, tool))
|
||||
}
|
||||
|
||||
// PrebuiltBuildTool adds the specified tool path from prebuils/build-tools. The path will be also added to the
|
||||
// dependencies returned by RuleBuilder.Tools.
|
||||
//
|
||||
// It is equivalent to:
|
||||
// cmd.Tool(ctx.Config().PrebuiltBuildTool(ctx, tool))
|
||||
func (c *RuleBuilderCommand) PrebuiltBuildTool(ctx PathContext, tool string) *RuleBuilderCommand {
|
||||
return c.Tool(ctx.Config().PrebuiltBuildTool(ctx, tool))
|
||||
}
|
||||
|
||||
// Input adds the specified input path to the command line. The path will also be added to the dependencies returned by
|
||||
// RuleBuilder.Inputs.
|
||||
func (c *RuleBuilderCommand) Input(path Path) *RuleBuilderCommand {
|
||||
|
|
|
@ -99,7 +99,7 @@ func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile andr
|
|||
|
||||
cmd.Text("BISON_PKGDATADIR=prebuilts/build-tools/common/bison").
|
||||
FlagWithInput("M4=", ctx.Config().PrebuiltBuildTool(ctx, "m4")).
|
||||
Tool(ctx.Config().PrebuiltBuildTool(ctx, "bison")).
|
||||
PrebuiltBuildTool(ctx, "bison").
|
||||
Flag("-d").
|
||||
Flags(flags).
|
||||
FlagWithOutput("--defines=", headerFile).
|
||||
|
@ -121,7 +121,7 @@ func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile andr
|
|||
headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h")
|
||||
|
||||
cmd := rule.Command()
|
||||
cmd.Tool(ctx.Config().HostToolPath(ctx, "aidl-cpp")).
|
||||
cmd.BuiltTool(ctx, "aidl-cpp").
|
||||
FlagWithDepFile("-d", depFile).
|
||||
Flag("--ninja").
|
||||
Flag(aidlFlags).
|
||||
|
|
|
@ -816,7 +816,7 @@ func (a *AndroidAppImport) uncompressEmbeddedJniLibs(
|
|||
rule := android.NewRuleBuilder()
|
||||
rule.Command().
|
||||
Textf(`if (zipinfo %s 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath).
|
||||
Tool(ctx.Config().HostToolPath(ctx, "zip2zip")).
|
||||
BuiltTool(ctx, "zip2zip").
|
||||
FlagWithInput("-i ", inputPath).
|
||||
FlagWithOutput("-o ", outputPath).
|
||||
FlagWithArg("-0 ", "'lib/**/*.so'").
|
||||
|
@ -843,7 +843,7 @@ func (a *AndroidAppImport) uncompressDex(
|
|||
rule := android.NewRuleBuilder()
|
||||
rule.Command().
|
||||
Textf(`if (zipinfo %s '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath).
|
||||
Tool(ctx.Config().HostToolPath(ctx, "zip2zip")).
|
||||
BuiltTool(ctx, "zip2zip").
|
||||
FlagWithInput("-i ", inputPath).
|
||||
FlagWithOutput("-o ", outputPath).
|
||||
FlagWithArg("-0 ", "'classes*.dex'").
|
||||
|
@ -1067,7 +1067,7 @@ func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, man
|
|||
outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml")
|
||||
|
||||
rule := android.NewRuleBuilder()
|
||||
cmd := rule.Command().Tool(ctx.Config().HostToolPath(ctx, "manifest_check")).
|
||||
cmd := rule.Command().BuiltTool(ctx, "manifest_check").
|
||||
Flag("--enforce-uses-libraries").
|
||||
Input(manifest).
|
||||
FlagWithOutput("-o ", outputFile)
|
||||
|
|
|
@ -229,7 +229,7 @@ func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootI
|
|||
if image.zip != nil {
|
||||
rule := android.NewRuleBuilder()
|
||||
rule.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "soong_zip")).
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
FlagWithOutput("-o ", image.zip).
|
||||
FlagWithArg("-C ", image.dir.String()).
|
||||
FlagWithInputList("-f ", allFiles, " -f ")
|
||||
|
@ -438,7 +438,7 @@ func dumpOatRules(ctx android.SingletonContext, image *bootImage) {
|
|||
rule := android.NewRuleBuilder()
|
||||
rule.Command().
|
||||
// TODO: for now, use the debug version for better error reporting
|
||||
Tool(ctx.Config().HostToolPath(ctx, "oatdumpd")).
|
||||
BuiltTool(ctx, "oatdumpd").
|
||||
FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPaths.Paths(), ":").
|
||||
FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocations, ":").
|
||||
FlagWithArg("--image=", dexpreopt.PathToLocation(image.images[arch], arch)).Implicit(image.images[arch]).
|
||||
|
|
|
@ -2094,14 +2094,14 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
|
||||
// use zip2zip to uncompress classes*.dex files
|
||||
rule.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "zip2zip")).
|
||||
BuiltTool(ctx, "zip2zip").
|
||||
FlagWithInput("-i ", inputJar).
|
||||
FlagWithOutput("-o ", temporary).
|
||||
FlagWithArg("-0 ", "'classes*.dex'")
|
||||
|
||||
// use zipalign to align uncompressed classes*.dex files
|
||||
rule.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "zipalign")).
|
||||
BuiltTool(ctx, "zipalign").
|
||||
Flag("-f").
|
||||
Text("4").
|
||||
Input(temporary).
|
||||
|
|
|
@ -34,7 +34,7 @@ func genProto(ctx android.ModuleContext, protoFile android.Path, flags android.P
|
|||
// Proto generated java files have an unknown package name in the path, so package the entire output directory
|
||||
// into a srcjar.
|
||||
rule.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "soong_zip")).
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
Flag("-jar").
|
||||
FlagWithOutput("-o ", srcJarFile).
|
||||
FlagWithArg("-C ", outDir.String()).
|
||||
|
|
|
@ -296,7 +296,7 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) {
|
|||
rule.Command().
|
||||
Text("rm -f").Output(aidl)
|
||||
rule.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "sdkparcelables")).
|
||||
BuiltTool(ctx, "sdkparcelables").
|
||||
Input(jar).
|
||||
Output(aidl)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func genProto(ctx android.ModuleContext, protoFile android.Path, flags android.P
|
|||
// Proto generated python files have an unknown package name in the path, so package the entire output directory
|
||||
// into a srcszip.
|
||||
zipCmd := rule.Command().
|
||||
Tool(ctx.Config().HostToolPath(ctx, "soong_zip")).
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
FlagWithOutput("-o ", srcsZipFile)
|
||||
if pkgPath != "" {
|
||||
zipCmd.FlagWithArg("-P ", pkgPath)
|
||||
|
|
Loading…
Reference in New Issue