Loading android/variable.go +10 −4 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ type variableProperties struct { Srcs []string Exclude_srcs []string Cmd *string } // eng is true for -eng builds, and can be used to turn on additional heavyweight debugging Loading Loading @@ -677,12 +678,17 @@ func ProductVariableProperties(ctx ArchVariantContext, module Module) ProductCon if moduleBase.variableProperties != nil { productVariablesProperty := proptools.FieldNameForProperty("product_variables") if moduleBase.ArchSpecific() { for /* axis */ _, configToProps := range moduleBase.GetArchVariantProperties(ctx, moduleBase.variableProperties) { for config, props := range configToProps { variableValues := reflect.ValueOf(props).Elem().FieldByName(productVariablesProperty) 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 { Loading bp2build/genrule_conversion_test.go +68 −1 Original line number Diff line number Diff line Loading @@ -773,7 +773,7 @@ func TestGenruleWithExportIncludeDirs(t *testing.T) { } } func TestGenruleWithConfiguredCmd(t *testing.T) { func TestGenruleWithSoongConfigVariableConfiguredCmd(t *testing.T) { testCases := []struct { moduleType string factory android.ModuleFactory Loading Loading @@ -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, }) }) } } Loading
android/variable.go +10 −4 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ type variableProperties struct { Srcs []string Exclude_srcs []string Cmd *string } // eng is true for -eng builds, and can be used to turn on additional heavyweight debugging Loading Loading @@ -677,12 +678,17 @@ func ProductVariableProperties(ctx ArchVariantContext, module Module) ProductCon if moduleBase.variableProperties != nil { productVariablesProperty := proptools.FieldNameForProperty("product_variables") if moduleBase.ArchSpecific() { for /* axis */ _, configToProps := range moduleBase.GetArchVariantProperties(ctx, moduleBase.variableProperties) { for config, props := range configToProps { variableValues := reflect.ValueOf(props).Elem().FieldByName(productVariablesProperty) 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 { Loading
bp2build/genrule_conversion_test.go +68 −1 Original line number Diff line number Diff line Loading @@ -773,7 +773,7 @@ func TestGenruleWithExportIncludeDirs(t *testing.T) { } } func TestGenruleWithConfiguredCmd(t *testing.T) { func TestGenruleWithSoongConfigVariableConfiguredCmd(t *testing.T) { testCases := []struct { moduleType string factory android.ModuleFactory Loading Loading @@ -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, }) }) } }