Loading android/rule_builder.go +9 −0 Original line number Diff line number Diff line Loading @@ -525,6 +525,15 @@ func (c *RuleBuilderCommand) Outputs(paths WritablePaths) *RuleBuilderCommand { return c } // OutputDir adds the output directory to the command line. This is only available when used with RuleBuilder.Sbox, // and will be the temporary output directory managed by sbox, not the final one. func (c *RuleBuilderCommand) OutputDir() *RuleBuilderCommand { if !c.sbox { panic("OutputDir only valid with Sbox") } return c.Text("__SBOX_OUT_DIR__") } // DepFile adds the specified depfile path to the paths returned by RuleBuilder.DepFiles and adds it to the command // line, and causes RuleBuilder.Build file to set the depfile flag for ninja. If multiple depfiles are added to // commands in a single RuleBuilder then RuleBuilder.Build will add an extra command to merge the depfiles together. Loading cc/gen.go +42 −23 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package cc import ( "path/filepath" "strings" "github.com/google/blueprint" Loading @@ -36,15 +37,6 @@ var ( CommandDeps: []string{"$lexCmd"}, }) aidl = pctx.AndroidStaticRule("aidl", blueprint.RuleParams{ Command: "$aidlCmd -d${out}.d --ninja $aidlFlags $in $outDir $out", CommandDeps: []string{"$aidlCmd"}, Depfile: "${out}.d", Deps: blueprint.DepsGCC, }, "aidlFlags", "outDir") sysprop = pctx.AndroidStaticRule("sysprop", blueprint.RuleParams{ Command: "$syspropCmd --header-dir=$headerOutDir --system-header-dir=$systemOutDir " + Loading Loading @@ -114,20 +106,37 @@ func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile andr return ret } func genAidl(ctx android.ModuleContext, aidlFile android.Path, outFile android.ModuleGenPath, aidlFlags string) android.Paths { ctx.Build(pctx, android.BuildParams{ Rule: aidl, Description: "aidl " + aidlFile.Rel(), Output: outFile, Input: aidlFile, Args: map[string]string{ "aidlFlags": aidlFlags, "outDir": android.PathForModuleGen(ctx, "aidl").String(), }, func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile android.Path, outFile, depFile android.ModuleGenPath, aidlFlags string) android.Paths { aidlPackage := strings.TrimSuffix(aidlFile.Rel(), aidlFile.Base()) baseName := strings.TrimSuffix(aidlFile.Base(), aidlFile.Ext()) shortName := strings.TrimPrefix(baseName, "I") outDir := android.PathForModuleGen(ctx, "aidl") headerI := outDir.Join(ctx, aidlPackage, baseName+".h") headerBn := outDir.Join(ctx, aidlPackage, "Bn"+shortName+".h") headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h") cmd := rule.Command() cmd.Tool(ctx.Config().HostToolPath(ctx, "aidl-cpp")). FlagWithDepFile("-d", depFile). Flag("--ninja"). Flag(aidlFlags). Input(aidlFile). OutputDir(). Output(outFile). ImplicitOutputs(android.WritablePaths{ headerI, headerBn, headerBp, }) // TODO: This should return the generated headers, not the source file. return android.Paths{outFile} return android.Paths{ headerI, headerBn, headerBp, } } func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) { Loading Loading @@ -187,6 +196,8 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, var deps android.Paths var rsFiles android.Paths var aidlRule *android.RuleBuilder var yaccRule_ *android.RuleBuilder yaccRule := func() *android.RuleBuilder { if yaccRule_ == nil { Loading Loading @@ -218,9 +229,13 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, srcFiles[i] = ccFile deps = append(deps, headerFile) case ".aidl": if aidlRule == nil { aidlRule = android.NewRuleBuilder().Sbox(android.PathForModuleGen(ctx, "aidl")) } cppFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp") depFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp.d") srcFiles[i] = cppFile deps = append(deps, genAidl(ctx, srcFile, cppFile, buildFlags.aidlFlags)...) deps = append(deps, genAidl(ctx, aidlRule, srcFile, cppFile, depFile, buildFlags.aidlFlags)...) case ".rs", ".fs": cppFile := rsGeneratedCppFile(ctx, srcFile) rsFiles = append(rsFiles, srcFiles[i]) Loading @@ -236,6 +251,10 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, } } if aidlRule != nil { aidlRule.Build(pctx, ctx, "aidl", "gen aidl") } if yaccRule_ != nil { yaccRule_.Build(pctx, ctx, "yacc", "gen yacc") } Loading cc/gen_test.go +3 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package cc import ( "path/filepath" "testing" ) Loading @@ -32,7 +33,7 @@ func TestGen(t *testing.T) { aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl") libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) if !inList("-I"+aidl.Args["outDir"], libfoo.flags.GlobalFlags) { if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) { t.Errorf("missing aidl includes in global flags") } }) Loading @@ -55,7 +56,7 @@ func TestGen(t *testing.T) { aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl") libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) if !inList("-I"+aidl.Args["outDir"], libfoo.flags.GlobalFlags) { if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) { t.Errorf("missing aidl includes in global flags") } }) Loading Loading
android/rule_builder.go +9 −0 Original line number Diff line number Diff line Loading @@ -525,6 +525,15 @@ func (c *RuleBuilderCommand) Outputs(paths WritablePaths) *RuleBuilderCommand { return c } // OutputDir adds the output directory to the command line. This is only available when used with RuleBuilder.Sbox, // and will be the temporary output directory managed by sbox, not the final one. func (c *RuleBuilderCommand) OutputDir() *RuleBuilderCommand { if !c.sbox { panic("OutputDir only valid with Sbox") } return c.Text("__SBOX_OUT_DIR__") } // DepFile adds the specified depfile path to the paths returned by RuleBuilder.DepFiles and adds it to the command // line, and causes RuleBuilder.Build file to set the depfile flag for ninja. If multiple depfiles are added to // commands in a single RuleBuilder then RuleBuilder.Build will add an extra command to merge the depfiles together. Loading
cc/gen.go +42 −23 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package cc import ( "path/filepath" "strings" "github.com/google/blueprint" Loading @@ -36,15 +37,6 @@ var ( CommandDeps: []string{"$lexCmd"}, }) aidl = pctx.AndroidStaticRule("aidl", blueprint.RuleParams{ Command: "$aidlCmd -d${out}.d --ninja $aidlFlags $in $outDir $out", CommandDeps: []string{"$aidlCmd"}, Depfile: "${out}.d", Deps: blueprint.DepsGCC, }, "aidlFlags", "outDir") sysprop = pctx.AndroidStaticRule("sysprop", blueprint.RuleParams{ Command: "$syspropCmd --header-dir=$headerOutDir --system-header-dir=$systemOutDir " + Loading Loading @@ -114,20 +106,37 @@ func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile andr return ret } func genAidl(ctx android.ModuleContext, aidlFile android.Path, outFile android.ModuleGenPath, aidlFlags string) android.Paths { ctx.Build(pctx, android.BuildParams{ Rule: aidl, Description: "aidl " + aidlFile.Rel(), Output: outFile, Input: aidlFile, Args: map[string]string{ "aidlFlags": aidlFlags, "outDir": android.PathForModuleGen(ctx, "aidl").String(), }, func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile android.Path, outFile, depFile android.ModuleGenPath, aidlFlags string) android.Paths { aidlPackage := strings.TrimSuffix(aidlFile.Rel(), aidlFile.Base()) baseName := strings.TrimSuffix(aidlFile.Base(), aidlFile.Ext()) shortName := strings.TrimPrefix(baseName, "I") outDir := android.PathForModuleGen(ctx, "aidl") headerI := outDir.Join(ctx, aidlPackage, baseName+".h") headerBn := outDir.Join(ctx, aidlPackage, "Bn"+shortName+".h") headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h") cmd := rule.Command() cmd.Tool(ctx.Config().HostToolPath(ctx, "aidl-cpp")). FlagWithDepFile("-d", depFile). Flag("--ninja"). Flag(aidlFlags). Input(aidlFile). OutputDir(). Output(outFile). ImplicitOutputs(android.WritablePaths{ headerI, headerBn, headerBp, }) // TODO: This should return the generated headers, not the source file. return android.Paths{outFile} return android.Paths{ headerI, headerBn, headerBp, } } func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) { Loading Loading @@ -187,6 +196,8 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, var deps android.Paths var rsFiles android.Paths var aidlRule *android.RuleBuilder var yaccRule_ *android.RuleBuilder yaccRule := func() *android.RuleBuilder { if yaccRule_ == nil { Loading Loading @@ -218,9 +229,13 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, srcFiles[i] = ccFile deps = append(deps, headerFile) case ".aidl": if aidlRule == nil { aidlRule = android.NewRuleBuilder().Sbox(android.PathForModuleGen(ctx, "aidl")) } cppFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp") depFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp.d") srcFiles[i] = cppFile deps = append(deps, genAidl(ctx, srcFile, cppFile, buildFlags.aidlFlags)...) deps = append(deps, genAidl(ctx, aidlRule, srcFile, cppFile, depFile, buildFlags.aidlFlags)...) case ".rs", ".fs": cppFile := rsGeneratedCppFile(ctx, srcFile) rsFiles = append(rsFiles, srcFiles[i]) Loading @@ -236,6 +251,10 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, } } if aidlRule != nil { aidlRule.Build(pctx, ctx, "aidl", "gen aidl") } if yaccRule_ != nil { yaccRule_.Build(pctx, ctx, "yacc", "gen yacc") } Loading
cc/gen_test.go +3 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package cc import ( "path/filepath" "testing" ) Loading @@ -32,7 +33,7 @@ func TestGen(t *testing.T) { aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl") libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) if !inList("-I"+aidl.Args["outDir"], libfoo.flags.GlobalFlags) { if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) { t.Errorf("missing aidl includes in global flags") } }) Loading @@ -55,7 +56,7 @@ func TestGen(t *testing.T) { aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl") libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) if !inList("-I"+aidl.Args["outDir"], libfoo.flags.GlobalFlags) { if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) { t.Errorf("missing aidl includes in global flags") } }) Loading