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
This commit is contained in:
31
cc/cc.go
31
cc/cc.go
@@ -116,8 +116,6 @@ type Deps struct {
|
|||||||
// Used for host bionic
|
// Used for host bionic
|
||||||
LinkerFlagsFile string
|
LinkerFlagsFile string
|
||||||
DynamicLinker string
|
DynamicLinker string
|
||||||
|
|
||||||
Tools []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PathDeps struct {
|
type PathDeps struct {
|
||||||
@@ -160,8 +158,6 @@ type PathDeps struct {
|
|||||||
|
|
||||||
// Path to the dynamic linker binary
|
// Path to the dynamic linker binary
|
||||||
DynamicLinker android.OptionalPath
|
DynamicLinker android.OptionalPath
|
||||||
|
|
||||||
Tools map[string]android.Path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module
|
// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module
|
||||||
@@ -429,12 +425,6 @@ type xref interface {
|
|||||||
XrefCcFiles() android.Paths
|
XrefCcFiles() android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToolDependencyTag struct {
|
|
||||||
blueprint.BaseDependencyTag
|
|
||||||
|
|
||||||
Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
dataLibDepTag = DependencyTag{Name: "data_lib", Library: true, Shared: true}
|
dataLibDepTag = DependencyTag{Name: "data_lib", Library: true, Shared: true}
|
||||||
sharedExportDepTag = DependencyTag{Name: "shared", Library: true, Shared: true, ReexportFlags: true}
|
sharedExportDepTag = DependencyTag{Name: "shared", Library: true, Shared: true, ReexportFlags: true}
|
||||||
@@ -1704,7 +1694,6 @@ func (c *Module) deps(ctx DepsContext) Deps {
|
|||||||
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
|
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
|
||||||
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
|
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
|
||||||
deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
|
deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
|
||||||
deps.Tools = android.LastUniqueStrings(deps.Tools)
|
|
||||||
|
|
||||||
for _, lib := range deps.ReexportSharedLibHeaders {
|
for _, lib := range deps.ReexportSharedLibHeaders {
|
||||||
if !inList(lib, deps.SharedLibs) {
|
if !inList(lib, deps.SharedLibs) {
|
||||||
@@ -2048,11 +2037,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
}, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
|
}, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tool := range deps.Tools {
|
|
||||||
actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(),
|
|
||||||
ToolDependencyTag{Name: tool}, tool)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func BeginMutator(ctx android.BottomUpMutatorContext) {
|
func BeginMutator(ctx android.BottomUpMutatorContext) {
|
||||||
@@ -2235,21 +2219,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
depName := ctx.OtherModuleName(dep)
|
depName := ctx.OtherModuleName(dep)
|
||||||
depTag := ctx.OtherModuleDependencyTag(dep)
|
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||||
|
|
||||||
if toolDep, ok := depTag.(ToolDependencyTag); ok {
|
|
||||||
if toolMod, ok := dep.(android.HostToolProvider); ok {
|
|
||||||
if depPaths.Tools == nil {
|
|
||||||
depPaths.Tools = make(map[string]android.Path)
|
|
||||||
}
|
|
||||||
toolPath := toolMod.HostToolPath()
|
|
||||||
if !toolPath.Valid() {
|
|
||||||
ctx.ModuleErrorf("Failed to find path for host tool %q", toolDep.Name)
|
|
||||||
}
|
|
||||||
depPaths.Tools[toolDep.Name] = toolPath.Path()
|
|
||||||
} else {
|
|
||||||
ctx.ModuleErrorf("Found module, but not host tool for %q", toolDep.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ccDep, ok := dep.(LinkableInterface)
|
ccDep, ok := dep.(LinkableInterface)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
||||||
|
@@ -251,14 +251,6 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|||||||
deps.StaticLibs = append(deps.StaticLibs, "libomp")
|
deps.StaticLibs = append(deps.StaticLibs, "libomp")
|
||||||
}
|
}
|
||||||
|
|
||||||
if compiler.hasSrcExt(".y") || compiler.hasSrcExt(".yy") {
|
|
||||||
deps.Tools = append(deps.Tools, "bison", "m4")
|
|
||||||
}
|
|
||||||
|
|
||||||
if compiler.hasSrcExt(".l") || compiler.hasSrcExt(".ll") {
|
|
||||||
deps.Tools = append(deps.Tools, "flex", "m4")
|
|
||||||
}
|
|
||||||
|
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +581,7 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
|
|||||||
|
|
||||||
srcs := append(android.Paths(nil), compiler.srcsBeforeGen...)
|
srcs := append(android.Paths(nil), compiler.srcsBeforeGen...)
|
||||||
|
|
||||||
srcs, genDeps := genSources(ctx, srcs, buildFlags, deps.Tools)
|
srcs, genDeps := genSources(ctx, srcs, buildFlags)
|
||||||
pathDeps = append(pathDeps, genDeps...)
|
pathDeps = append(pathDeps, genDeps...)
|
||||||
|
|
||||||
compiler.pathDeps = pathDeps
|
compiler.pathDeps = pathDeps
|
||||||
|
72
cc/gen.go
72
cc/gen.go
@@ -24,6 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
pctx.SourcePathVariable("lexCmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/flex")
|
||||||
pctx.SourcePathVariable("m4Cmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/m4")
|
pctx.SourcePathVariable("m4Cmd", "prebuilts/build-tools/${config.HostPrebuiltTag}/bin/m4")
|
||||||
|
|
||||||
pctx.HostBinToolVariable("aidlCmd", "aidl-cpp")
|
pctx.HostBinToolVariable("aidlCmd", "aidl-cpp")
|
||||||
@@ -31,6 +32,12 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
lex = pctx.AndroidStaticRule("lex",
|
||||||
|
blueprint.RuleParams{
|
||||||
|
Command: "M4=$m4Cmd $lexCmd -o$out $in",
|
||||||
|
CommandDeps: []string{"$lexCmd", "$m4Cmd"},
|
||||||
|
})
|
||||||
|
|
||||||
sysprop = pctx.AndroidStaticRule("sysprop",
|
sysprop = pctx.AndroidStaticRule("sysprop",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$syspropCmd --header-dir=$headerOutDir --public-header-dir=$publicOutDir " +
|
Command: "$syspropCmd --header-dir=$headerOutDir --public-header-dir=$publicOutDir " +
|
||||||
@@ -59,8 +66,7 @@ type YaccProperties struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile android.Path,
|
func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile android.Path,
|
||||||
outFile android.ModuleGenPath, props *YaccProperties,
|
outFile android.ModuleGenPath, props *YaccProperties) (headerFiles android.Paths) {
|
||||||
tools map[string]android.Path) (headerFiles android.Paths) {
|
|
||||||
|
|
||||||
outDir := android.PathForModuleGen(ctx, "yacc")
|
outDir := android.PathForModuleGen(ctx, "yacc")
|
||||||
headerFile := android.GenPathWithExt(ctx, "yacc", yaccFile, "h")
|
headerFile := android.GenPathWithExt(ctx, "yacc", yaccFile, "h")
|
||||||
@@ -91,17 +97,9 @@ func genYacc(ctx android.ModuleContext, rule *android.RuleBuilder, yaccFile andr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bison, ok := tools["bison"]
|
cmd.Text("BISON_PKGDATADIR=prebuilts/build-tools/common/bison").
|
||||||
if !ok {
|
FlagWithInput("M4=", ctx.Config().PrebuiltBuildTool(ctx, "m4")).
|
||||||
ctx.ModuleErrorf("Unable to find bison")
|
PrebuiltBuildTool(ctx, "bison").
|
||||||
}
|
|
||||||
m4, ok := tools["m4"]
|
|
||||||
if !ok {
|
|
||||||
ctx.ModuleErrorf("Unable to find m4")
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd.FlagWithInput("M4=", m4).
|
|
||||||
Tool(bison).
|
|
||||||
Flag("-d").
|
Flag("-d").
|
||||||
Flags(flags).
|
Flags(flags).
|
||||||
FlagWithOutput("--defines=", headerFile).
|
FlagWithOutput("--defines=", headerFile).
|
||||||
@@ -155,23 +153,13 @@ func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile andr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func genLex(ctx android.ModuleContext, rule *android.RuleBuilder, lexFile android.Path,
|
func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) {
|
||||||
outFile android.ModuleGenPath, tools map[string]android.Path) {
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: lex,
|
||||||
flex, ok := tools["flex"]
|
Description: "lex " + lexFile.Rel(),
|
||||||
if !ok {
|
Output: outFile,
|
||||||
ctx.ModuleErrorf("Unable to find flex")
|
Input: lexFile,
|
||||||
}
|
})
|
||||||
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 genSysprop(ctx android.ModuleContext, syspropFile android.Path) (android.Path, android.Paths) {
|
func genSysprop(ctx android.ModuleContext, syspropFile android.Path) (android.Path, android.Paths) {
|
||||||
@@ -218,22 +206,14 @@ func genWinMsg(ctx android.ModuleContext, srcFile android.Path, flags builderFla
|
|||||||
return rcFile, headerFile
|
return rcFile, headerFile
|
||||||
}
|
}
|
||||||
|
|
||||||
func genSources(ctx android.ModuleContext, srcFiles android.Paths, buildFlags builderFlags,
|
func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||||
tools map[string]android.Path) (android.Paths, android.Paths) {
|
buildFlags builderFlags) (android.Paths, android.Paths) {
|
||||||
|
|
||||||
var deps android.Paths
|
var deps android.Paths
|
||||||
var rsFiles android.Paths
|
var rsFiles android.Paths
|
||||||
|
|
||||||
var aidlRule *android.RuleBuilder
|
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
|
var yaccRule_ *android.RuleBuilder
|
||||||
yaccRule := func() *android.RuleBuilder {
|
yaccRule := func() *android.RuleBuilder {
|
||||||
if yaccRule_ == nil {
|
if yaccRule_ == nil {
|
||||||
@@ -247,19 +227,19 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, buildFlags bu
|
|||||||
case ".y":
|
case ".y":
|
||||||
cFile := android.GenPathWithExt(ctx, "yacc", srcFile, "c")
|
cFile := android.GenPathWithExt(ctx, "yacc", srcFile, "c")
|
||||||
srcFiles[i] = cFile
|
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":
|
case ".yy":
|
||||||
cppFile := android.GenPathWithExt(ctx, "yacc", srcFile, "cpp")
|
cppFile := android.GenPathWithExt(ctx, "yacc", srcFile, "cpp")
|
||||||
srcFiles[i] = cppFile
|
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":
|
case ".l":
|
||||||
cFile := android.GenPathWithExt(ctx, "lex", srcFile, "c")
|
cFile := android.GenPathWithExt(ctx, "lex", srcFile, "c")
|
||||||
srcFiles[i] = cFile
|
srcFiles[i] = cFile
|
||||||
genLex(ctx, lexRule(), srcFile, cFile, tools)
|
genLex(ctx, srcFile, cFile)
|
||||||
case ".ll":
|
case ".ll":
|
||||||
cppFile := android.GenPathWithExt(ctx, "lex", srcFile, "cpp")
|
cppFile := android.GenPathWithExt(ctx, "lex", srcFile, "cpp")
|
||||||
srcFiles[i] = cppFile
|
srcFiles[i] = cppFile
|
||||||
genLex(ctx, lexRule(), srcFile, cppFile, tools)
|
genLex(ctx, srcFile, cppFile)
|
||||||
case ".proto":
|
case ".proto":
|
||||||
ccFile, headerFile := genProto(ctx, srcFile, buildFlags)
|
ccFile, headerFile := genProto(ctx, srcFile, buildFlags)
|
||||||
srcFiles[i] = ccFile
|
srcFiles[i] = ccFile
|
||||||
@@ -291,10 +271,6 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths, buildFlags bu
|
|||||||
aidlRule.Build(pctx, ctx, "aidl", "gen aidl")
|
aidlRule.Build(pctx, ctx, "aidl", "gen aidl")
|
||||||
}
|
}
|
||||||
|
|
||||||
if lexRule_ != nil {
|
|
||||||
lexRule_.Build(pctx, ctx, "lex", "gen lex")
|
|
||||||
}
|
|
||||||
|
|
||||||
if yaccRule_ != nil {
|
if yaccRule_ != nil {
|
||||||
yaccRule_.Build(pctx, ctx, "yacc", "gen yacc")
|
yaccRule_.Build(pctx, ctx, "yacc", "gen yacc")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user