Merge "Convert cc aidl to rule builder"
am: 733728b42c
Change-Id: I10b1c99b47e5d83e0d24d5f353392f7dd380b5df
This commit is contained in:
@@ -525,6 +525,15 @@ func (c *RuleBuilderCommand) Outputs(paths WritablePaths) *RuleBuilderCommand {
|
|||||||
return c
|
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
|
// 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
|
// 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.
|
// commands in a single RuleBuilder then RuleBuilder.Build will add an extra command to merge the depfiles together.
|
||||||
|
63
cc/gen.go
63
cc/gen.go
@@ -16,6 +16,7 @@ package cc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
|
||||||
@@ -36,15 +37,6 @@ var (
|
|||||||
CommandDeps: []string{"$lexCmd"},
|
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",
|
sysprop = pctx.AndroidStaticRule("sysprop",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$syspropCmd --header-dir=$headerOutDir --system-header-dir=$systemOutDir " +
|
Command: "$syspropCmd --header-dir=$headerOutDir --system-header-dir=$systemOutDir " +
|
||||||
@@ -114,20 +106,37 @@ func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile andr
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func genAidl(ctx android.ModuleContext, aidlFile android.Path, outFile android.ModuleGenPath, aidlFlags string) android.Paths {
|
func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile android.Path,
|
||||||
ctx.Build(pctx, android.BuildParams{
|
outFile, depFile android.ModuleGenPath, aidlFlags string) android.Paths {
|
||||||
Rule: aidl,
|
|
||||||
Description: "aidl " + aidlFile.Rel(),
|
aidlPackage := strings.TrimSuffix(aidlFile.Rel(), aidlFile.Base())
|
||||||
Output: outFile,
|
baseName := strings.TrimSuffix(aidlFile.Base(), aidlFile.Ext())
|
||||||
Input: aidlFile,
|
shortName := strings.TrimPrefix(baseName, "I")
|
||||||
Args: map[string]string{
|
|
||||||
"aidlFlags": aidlFlags,
|
outDir := android.PathForModuleGen(ctx, "aidl")
|
||||||
"outDir": android.PathForModuleGen(ctx, "aidl").String(),
|
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{
|
||||||
return android.Paths{outFile}
|
headerI,
|
||||||
|
headerBn,
|
||||||
|
headerBp,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) {
|
func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) {
|
||||||
@@ -187,6 +196,8 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
|||||||
var deps android.Paths
|
var deps android.Paths
|
||||||
var rsFiles android.Paths
|
var rsFiles android.Paths
|
||||||
|
|
||||||
|
var aidlRule *android.RuleBuilder
|
||||||
|
|
||||||
var yaccRule_ *android.RuleBuilder
|
var yaccRule_ *android.RuleBuilder
|
||||||
yaccRule := func() *android.RuleBuilder {
|
yaccRule := func() *android.RuleBuilder {
|
||||||
if yaccRule_ == nil {
|
if yaccRule_ == nil {
|
||||||
@@ -218,9 +229,13 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
|||||||
srcFiles[i] = ccFile
|
srcFiles[i] = ccFile
|
||||||
deps = append(deps, headerFile)
|
deps = append(deps, headerFile)
|
||||||
case ".aidl":
|
case ".aidl":
|
||||||
|
if aidlRule == nil {
|
||||||
|
aidlRule = android.NewRuleBuilder().Sbox(android.PathForModuleGen(ctx, "aidl"))
|
||||||
|
}
|
||||||
cppFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp")
|
cppFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp")
|
||||||
|
depFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp.d")
|
||||||
srcFiles[i] = cppFile
|
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":
|
case ".rs", ".fs":
|
||||||
cppFile := rsGeneratedCppFile(ctx, srcFile)
|
cppFile := rsGeneratedCppFile(ctx, srcFile)
|
||||||
rsFiles = append(rsFiles, srcFiles[i])
|
rsFiles = append(rsFiles, srcFiles[i])
|
||||||
@@ -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 {
|
if yaccRule_ != nil {
|
||||||
yaccRule_.Build(pctx, ctx, "yacc", "gen yacc")
|
yaccRule_.Build(pctx, ctx, "yacc", "gen yacc")
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ func TestGen(t *testing.T) {
|
|||||||
aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl")
|
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)
|
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")
|
t.Errorf("missing aidl includes in global flags")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -55,7 +56,7 @@ func TestGen(t *testing.T) {
|
|||||||
aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl")
|
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)
|
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")
|
t.Errorf("missing aidl includes in global flags")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user