Revert "Switch cc's use of bison and flex to prebuilt_build_tool"
Revert submission 1366377-prebuilt_build_tool_make
Reason for revert: breaks build
Reverted Changes:
I20bf062bb:Export prebuilt tools to Make
I4bb526492:Move some prebuilt build tool configs to Soong
I195b68813:Support per-module MakeVars
Ibcb257e7b:Fix dependency loop with flex
I6150f0f39:Switch cc's use of bison and flex to prebuilt_buil...
I6939451b8:Reland "Use genrules to build a consistent awk."
Idee60640f:Add prebuilt_build_tool modules for genrule use
I00893172b:Rename bison to bison_bin
I82c26be1c:Add prebuilt_build_tool to allow genrules to use p...
Change-Id: I1ca553ffe4b09250a441b9bc477c3ba98c6f6549
diff --git a/cc/gen.go b/cc/gen.go
index 6f9036b..b0aadc6 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -24,6 +24,7 @@
)
func init() {
+ pctx.SourcePathVariable("lexCmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/flex")
pctx.SourcePathVariable("m4Cmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/m4")
pctx.HostBinToolVariable("aidlCmd", "aidl-cpp")
@@ -31,6 +32,12 @@
}
var (
+ lex = pctx.AndroidStaticRule("lex",
+ blueprint.RuleParams{
+ Command: "M4=$m4Cmd $lexCmd -o$out $in",
+ CommandDeps: []string{"$lexCmd", "$m4Cmd"},
+ })
+
sysprop = pctx.AndroidStaticRule("sysprop",
blueprint.RuleParams{
Command: "$syspropCmd --header-dir=$headerOutDir --public-header-dir=$publicOutDir " +
@@ -59,8 +66,7 @@
}
func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile android.Path,
- outFile android.ModuleGenPath, props *YaccProperties,
- tools map[string]android.Path) (headerFiles android.Paths) {
+ outFile android.ModuleGenPath, props *YaccProperties) (headerFiles android.Paths) {
outDir := android.PathForModuleGen(ctx, "yacc")
headerFile := android.GenPathWithExt(ctx, "yacc", yaccFile, "h")
@@ -91,17 +97,9 @@
}
}
- bison, ok := tools["bison"]
- if !ok {
- ctx.ModuleErrorf("Unable to find bison")
- }
- m4, ok := tools["m4"]
- if !ok {
- ctx.ModuleErrorf("Unable to find m4")
- }
-
- cmd.FlagWithInput("M4=", m4).
- Tool(bison).
+ cmd.Text("BISON_PKGDATADIR=prebuilts/build-tools/common/bison").
+ FlagWithInput("M4=", ctx.Config().PrebuiltBuildTool(ctx, "m4")).
+ PrebuiltBuildTool(ctx, "bison").
Flag("-d").
Flags(flags).
FlagWithOutput("--defines=", headerFile).
@@ -155,23 +153,13 @@
}
}
-func genLex(ctx android.ModuleContext, rule *android.RuleBuilder, lexFile android.Path,
- outFile android.ModuleGenPath, tools map[string]android.Path) {
-
- flex, ok := tools["flex"]
- if !ok {
- ctx.ModuleErrorf("Unable to find flex")
- }
- m4, ok := tools["m4"]
- if !ok {
- ctx.ModuleErrorf("Unable to find m4")
- }
-
- rule.Command().
- FlagWithInput("M4=", m4).
- Tool(flex).
- FlagWithOutput("-o", outFile).
- Input(lexFile)
+func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: lex,
+ Description: "lex " + lexFile.Rel(),
+ Output: outFile,
+ Input: lexFile,
+ })
}
func genSysprop(ctx android.ModuleContext, syspropFile android.Path) (android.Path, android.Paths) {
@@ -218,22 +206,14 @@
return rcFile, headerFile
}
-func genSources(ctx android.ModuleContext, srcFiles android.Paths, buildFlags builderFlags,
- tools map[string]android.Path) (android.Paths, android.Paths) {
+func genSources(ctx android.ModuleContext, srcFiles android.Paths,
+ buildFlags builderFlags) (android.Paths, android.Paths) {
var deps android.Paths
var rsFiles android.Paths
var aidlRule *android.RuleBuilder
- var lexRule_ *android.RuleBuilder
- lexRule := func() *android.RuleBuilder {
- if lexRule_ == nil {
- lexRule_ = android.NewRuleBuilder().Sbox(android.PathForModuleGen(ctx, "lex"))
- }
- return lexRule_
- }
-
var yaccRule_ *android.RuleBuilder
yaccRule := func() *android.RuleBuilder {
if yaccRule_ == nil {
@@ -247,19 +227,19 @@
case ".y":
cFile := android.GenPathWithExt(ctx, "yacc", srcFile, "c")
srcFiles[i] = cFile
- deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cFile, buildFlags.yacc, tools)...)
+ deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cFile, buildFlags.yacc)...)
case ".yy":
cppFile := android.GenPathWithExt(ctx, "yacc", srcFile, "cpp")
srcFiles[i] = cppFile
- deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cppFile, buildFlags.yacc, tools)...)
+ deps = append(deps, genYacc(ctx, yaccRule(), srcFile, cppFile, buildFlags.yacc)...)
case ".l":
cFile := android.GenPathWithExt(ctx, "lex", srcFile, "c")
srcFiles[i] = cFile
- genLex(ctx, lexRule(), srcFile, cFile, tools)
+ genLex(ctx, srcFile, cFile)
case ".ll":
cppFile := android.GenPathWithExt(ctx, "lex", srcFile, "cpp")
srcFiles[i] = cppFile
- genLex(ctx, lexRule(), srcFile, cppFile, tools)
+ genLex(ctx, srcFile, cppFile)
case ".proto":
ccFile, headerFile := genProto(ctx, srcFile, buildFlags)
srcFiles[i] = ccFile
@@ -291,10 +271,6 @@
aidlRule.Build(pctx, ctx, "aidl", "gen aidl")
}
- if lexRule_ != nil {
- lexRule_.Build(pctx, ctx, "lex", "gen lex")
- }
-
if yaccRule_ != nil {
yaccRule_.Build(pctx, ctx, "yacc", "gen yacc")
}