Use dependency tags for genrules
So that we don't get confused when using :<module> in srcs to depend on a module that could also be a HostBinTool. Test: m -j Change-Id: Ia3b1c26826e70f84c6dc5ff78c95dd11d76901b6
This commit is contained in:
1
cc/cc.go
1
cc/cc.go
@@ -956,6 +956,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
if cc == nil {
|
if cc == nil {
|
||||||
switch tag {
|
switch tag {
|
||||||
case android.DefaultsDepTag, android.SourceDepTag:
|
case android.DefaultsDepTag, android.SourceDepTag:
|
||||||
|
// Nothing to do
|
||||||
case genSourceDepTag:
|
case genSourceDepTag:
|
||||||
if genRule, ok := m.(genrule.SourceFileGenerator); ok {
|
if genRule, ok := m.(genrule.SourceFileGenerator); ok {
|
||||||
depPaths.GeneratedSources = append(depPaths.GeneratedSources,
|
depPaths.GeneratedSources = append(depPaths.GeneratedSources,
|
||||||
|
@@ -48,6 +48,12 @@ type HostToolProvider interface {
|
|||||||
HostToolPath() android.OptionalPath
|
HostToolPath() android.OptionalPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type hostToolDependencyTag struct {
|
||||||
|
blueprint.BaseDependencyTag
|
||||||
|
}
|
||||||
|
|
||||||
|
var hostToolDepTag hostToolDependencyTag
|
||||||
|
|
||||||
type generatorProperties struct {
|
type generatorProperties struct {
|
||||||
// The command to run on one or more input files. Cmd supports substitution of a few variables
|
// The command to run on one or more input files. Cmd supports substitution of a few variables
|
||||||
// (the actual substitution is implemented in GenerateAndroidBuildActions below)
|
// (the actual substitution is implemented in GenerateAndroidBuildActions below)
|
||||||
@@ -123,7 +129,7 @@ func (g *generator) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
if len(g.properties.Tools) > 0 {
|
if len(g.properties.Tools) > 0 {
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
||||||
{"arch", ctx.AConfig().BuildOsVariant},
|
{"arch", ctx.AConfig().BuildOsVariant},
|
||||||
}, nil, g.properties.Tools...)
|
}, hostToolDepTag, g.properties.Tools...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,23 +153,37 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
|
|
||||||
if len(g.properties.Tools) > 0 {
|
if len(g.properties.Tools) > 0 {
|
||||||
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
||||||
if t, ok := module.(HostToolProvider); ok {
|
switch ctx.OtherModuleDependencyTag(module) {
|
||||||
p := t.HostToolPath()
|
case android.SourceDepTag:
|
||||||
if p.Valid() {
|
// Nothing to do
|
||||||
g.deps = append(g.deps, p.Path())
|
case hostToolDepTag:
|
||||||
tool := ctx.OtherModuleName(module)
|
tool := ctx.OtherModuleName(module)
|
||||||
if _, exists := tools[tool]; !exists {
|
|
||||||
tools[tool] = p.Path()
|
if t, ok := module.(HostToolProvider); ok {
|
||||||
|
p := t.HostToolPath()
|
||||||
|
if p.Valid() {
|
||||||
|
g.deps = append(g.deps, p.Path())
|
||||||
|
if _, exists := tools[tool]; !exists {
|
||||||
|
tools[tool] = p.Path()
|
||||||
|
} else {
|
||||||
|
ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool], p.Path().String())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool], p.Path().String())
|
ctx.ModuleErrorf("host tool %q missing output file", tool)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.ModuleErrorf("host tool %q missing output file", ctx.OtherModuleName(module))
|
ctx.ModuleErrorf("%q is not a host tool provider", tool)
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
ctx.ModuleErrorf("unknown dependency on %q", ctx.OtherModuleName(module))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.Failed() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, tool := range g.properties.Tool_files {
|
for _, tool := range g.properties.Tool_files {
|
||||||
toolPath := android.PathForModuleSrc(ctx, tool)
|
toolPath := android.PathForModuleSrc(ctx, tool)
|
||||||
g.deps = append(g.deps, toolPath)
|
g.deps = append(g.deps, toolPath)
|
||||||
|
@@ -249,6 +249,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
if dep == nil {
|
if dep == nil {
|
||||||
switch tag {
|
switch tag {
|
||||||
case android.DefaultsDepTag, android.SourceDepTag:
|
case android.DefaultsDepTag, android.SourceDepTag:
|
||||||
|
// Nothing to do
|
||||||
default:
|
default:
|
||||||
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user