Merge "Bp2build product variables on non-arch-variant module types" into main
This commit is contained in:
@@ -138,6 +138,7 @@ type variableProperties struct {
|
|||||||
|
|
||||||
Srcs []string
|
Srcs []string
|
||||||
Exclude_srcs []string
|
Exclude_srcs []string
|
||||||
|
Cmd *string
|
||||||
}
|
}
|
||||||
|
|
||||||
// eng is true for -eng builds, and can be used to turn on additional heavyweight debugging
|
// eng is true for -eng builds, and can be used to turn on additional heavyweight debugging
|
||||||
@@ -677,12 +678,17 @@ func ProductVariableProperties(ctx ArchVariantContext, module Module) ProductCon
|
|||||||
|
|
||||||
if moduleBase.variableProperties != nil {
|
if moduleBase.variableProperties != nil {
|
||||||
productVariablesProperty := proptools.FieldNameForProperty("product_variables")
|
productVariablesProperty := proptools.FieldNameForProperty("product_variables")
|
||||||
|
if moduleBase.ArchSpecific() {
|
||||||
for /* axis */ _, configToProps := range moduleBase.GetArchVariantProperties(ctx, moduleBase.variableProperties) {
|
for /* axis */ _, configToProps := range moduleBase.GetArchVariantProperties(ctx, moduleBase.variableProperties) {
|
||||||
for config, props := range configToProps {
|
for config, props := range configToProps {
|
||||||
variableValues := reflect.ValueOf(props).Elem().FieldByName(productVariablesProperty)
|
variableValues := reflect.ValueOf(props).Elem().FieldByName(productVariablesProperty)
|
||||||
productConfigProperties.AddProductConfigProperties(variableValues, config)
|
productConfigProperties.AddProductConfigProperties(variableValues, config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
variableValues := reflect.ValueOf(moduleBase.variableProperties).Elem().FieldByName(productVariablesProperty)
|
||||||
|
productConfigProperties.AddProductConfigProperties(variableValues, "")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if m, ok := module.(Bazelable); ok && m.namespacedVariableProps() != nil {
|
if m, ok := module.(Bazelable); ok && m.namespacedVariableProps() != nil {
|
||||||
|
@@ -773,7 +773,7 @@ func TestGenruleWithExportIncludeDirs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenruleWithConfiguredCmd(t *testing.T) {
|
func TestGenruleWithSoongConfigVariableConfiguredCmd(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
moduleType string
|
moduleType string
|
||||||
factory android.ModuleFactory
|
factory android.ModuleFactory
|
||||||
@@ -846,3 +846,70 @@ my_genrule {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGenruleWithProductVariableConfiguredCmd(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
moduleType string
|
||||||
|
factory android.ModuleFactory
|
||||||
|
hod android.HostOrDeviceSupported
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
moduleType: "genrule",
|
||||||
|
factory: genrule.GenRuleFactory,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
moduleType: "cc_genrule",
|
||||||
|
factory: cc.GenRuleFactory,
|
||||||
|
hod: android.DeviceSupported,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
moduleType: "java_genrule",
|
||||||
|
factory: java.GenRuleFactory,
|
||||||
|
hod: android.DeviceSupported,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
moduleType: "java_genrule_host",
|
||||||
|
factory: java.GenRuleFactoryHost,
|
||||||
|
hod: android.HostSupported,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
bp := `
|
||||||
|
|
||||||
|
%s {
|
||||||
|
name: "foo",
|
||||||
|
out: ["foo.txt"],
|
||||||
|
cmd: "echo 'no variable' > $(out)",
|
||||||
|
product_variables: {
|
||||||
|
debuggable: {
|
||||||
|
cmd: "echo 'with variable' > $(out)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
bazel_module: { bp2build_available: true },
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
moduleAttrs := AttrNameToString{
|
||||||
|
"cmd": `select({
|
||||||
|
"//build/bazel/product_config/config_settings:debuggable": "echo 'with variable' > $(OUTS)",
|
||||||
|
"//conditions:default": "echo 'no variable' > $(OUTS)",
|
||||||
|
})`,
|
||||||
|
"outs": `["foo.txt"]`,
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedBazelTargets := []string{
|
||||||
|
makeBazelTargetHostOrDevice("genrule", "foo", moduleAttrs, tc.hod),
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run(tc.moduleType, func(t *testing.T) {
|
||||||
|
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { android.RegisterSoongConfigModuleBuildComponents(ctx) },
|
||||||
|
Bp2buildTestCase{
|
||||||
|
Blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||||
|
ModuleTypeUnderTest: tc.moduleType,
|
||||||
|
ModuleTypeUnderTestFactory: tc.factory,
|
||||||
|
ExpectedBazelTargets: expectedBazelTargets,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user