Handle product config vars in bp2build.
Test: bp2build ci & mixed build libc Bug: 183595873 Change-Id: I2d87434ff4df5a24efc5e3e38f087de035228934
This commit is contained in:
@@ -318,6 +318,21 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
||||
}
|
||||
}
|
||||
|
||||
productVariableProps := android.ProductVariableProperties(ctx)
|
||||
if props, exists := productVariableProps["Cflags"]; exists {
|
||||
for _, prop := range props {
|
||||
flags, ok := prop.Property.([]string)
|
||||
if !ok {
|
||||
ctx.ModuleErrorf("Could not convert product variable cflag property")
|
||||
}
|
||||
newFlags, _ := bazel.TryVariableSubstitutions(flags, prop.ProductConfigVariable)
|
||||
copts.ProductValues = append(copts.ProductValues, bazel.ProductVariableValues{
|
||||
ProductVariable: prop.ProductConfigVariable,
|
||||
Values: newFlags,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return compilerAttributes{
|
||||
srcs: srcs,
|
||||
copts: copts,
|
||||
|
13
cc/object.go
13
cc/object.go
@@ -116,7 +116,7 @@ type bazelObjectAttributes struct {
|
||||
Hdrs bazel.LabelListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Copts bazel.StringListAttribute
|
||||
Asflags []string
|
||||
Asflags bazel.StringListAttribute
|
||||
}
|
||||
|
||||
type bazelObject struct {
|
||||
@@ -157,7 +157,7 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
||||
|
||||
// Set arch-specific configurable attributes
|
||||
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
|
||||
var asFlags []string
|
||||
var asFlags bazel.StringListAttribute
|
||||
|
||||
var deps bazel.LabelListAttribute
|
||||
for _, props := range m.linker.linkerProps() {
|
||||
@@ -176,10 +176,11 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
||||
ctx.ModuleErrorf("Could not convert product variable asflag property")
|
||||
return
|
||||
}
|
||||
// TODO(b/183595873) handle other product variable usages -- as selects?
|
||||
if newFlags, subbed := bazel.TryVariableSubstitutions(flags, prop.ProductConfigVariable); subbed {
|
||||
asFlags = append(asFlags, newFlags...)
|
||||
}
|
||||
newFlags, _ := bazel.TryVariableSubstitutions(flags, prop.ProductConfigVariable)
|
||||
asFlags.ProductValues = append(asFlags.ProductValues, bazel.ProductVariableValues{
|
||||
ProductVariable: prop.ProductConfigVariable,
|
||||
Values: newFlags,
|
||||
})
|
||||
}
|
||||
}
|
||||
// TODO(b/183595872) warn/error if we're not handling product variables
|
||||
|
Reference in New Issue
Block a user