Loading android/module.go +1 −1 Original line number Diff line number Diff line Loading @@ -1371,7 +1371,7 @@ func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutator for _, axis := range enabledPropertyOverrides.SortedConfigurationAxes() { configToBools := enabledPropertyOverrides.ConfigurableValues[axis] for cfg, val := range configToBools { if axis != bazel.OsConfigurationAxis || osSupport[cfg] { if axis != bazel.OsConfigurationAxis || osSupport[cfg] || val /*If enabled is explicitly requested via overrides */ { enabledProperty.SetSelectValue(axis, cfg, &val) } } Loading android/proto.go +5 −0 Original line number Diff line number Diff line Loading @@ -408,6 +408,11 @@ func createProtoLibraryTargetsForIncludeDirs(ctx Bp2buildMutatorContext, include // As a workarounds, delete `target_compatible_with` alwaysEnabled := bazel.BoolAttribute{} alwaysEnabled.Value = proptools.BoolPtr(true) // Add android and linux explicitly so that fillcommonbp2buildmoduleattrs can override these configs // When we extend b support for other os'es (darwin/windows), we should add those configs here as well alwaysEnabled.SetSelectValue(bazel.OsConfigurationAxis, bazel.OsAndroid, proptools.BoolPtr(true)) alwaysEnabled.SetSelectValue(bazel.OsConfigurationAxis, bazel.OsLinux, proptools.BoolPtr(true)) ctx.CreateBazelTargetModuleWithRestrictions( bazel.BazelTargetModuleProperties{Rule_class: "proto_library"}, CommonAttributes{ Loading bp2build/cc_library_conversion_test.go +38 −0 Original line number Diff line number Diff line Loading @@ -5241,3 +5241,41 @@ func TestProtoLocalIncludeDirs(t *testing.T) { } runCcLibraryTestCase(t, tc) } // `foo_device` and `bar_host` can depend on .proto files of a specific dir, // the dynamically generated proto_library should not have any target_compatible_with func TestProtoLibraryForIncludeDirsIsOsAgnostic(t *testing.T) { tc := Bp2buildTestCase{ Description: "proto_library generated for proto.include_dirs is compatible for all axes", ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTestFactory: cc.LibraryFactory, Blueprint: simpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite") + ` cc_library { name: "foo_device", device_supported: true, // this is the default behavior, but added explicitly here for illustration host_supported: false, proto: {include_dirs: ["dir"]}, } cc_library { name: "bar_host", device_supported: false, host_supported: true, srcs: ["bar.proto"], proto: {include_dirs: ["dir"]}, } `, Filesystem: map[string]string{ "dir/Android.bp": "", "dir/dir.proto": "", }, Dir: "dir", // check for the generated proto_library ExpectedBazelTargets: []string{ MakeBazelTargetNoRestrictions("proto_library", "dir.include_dir_bp2build_generated_proto", AttrNameToString{ "srcs": `["dir.proto"]`, "strip_import_prefix": `""`, "tags": `["manual"]`, }), }, } runCcLibraryTestCase(t, tc) } Loading
android/module.go +1 −1 Original line number Diff line number Diff line Loading @@ -1371,7 +1371,7 @@ func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutator for _, axis := range enabledPropertyOverrides.SortedConfigurationAxes() { configToBools := enabledPropertyOverrides.ConfigurableValues[axis] for cfg, val := range configToBools { if axis != bazel.OsConfigurationAxis || osSupport[cfg] { if axis != bazel.OsConfigurationAxis || osSupport[cfg] || val /*If enabled is explicitly requested via overrides */ { enabledProperty.SetSelectValue(axis, cfg, &val) } } Loading
android/proto.go +5 −0 Original line number Diff line number Diff line Loading @@ -408,6 +408,11 @@ func createProtoLibraryTargetsForIncludeDirs(ctx Bp2buildMutatorContext, include // As a workarounds, delete `target_compatible_with` alwaysEnabled := bazel.BoolAttribute{} alwaysEnabled.Value = proptools.BoolPtr(true) // Add android and linux explicitly so that fillcommonbp2buildmoduleattrs can override these configs // When we extend b support for other os'es (darwin/windows), we should add those configs here as well alwaysEnabled.SetSelectValue(bazel.OsConfigurationAxis, bazel.OsAndroid, proptools.BoolPtr(true)) alwaysEnabled.SetSelectValue(bazel.OsConfigurationAxis, bazel.OsLinux, proptools.BoolPtr(true)) ctx.CreateBazelTargetModuleWithRestrictions( bazel.BazelTargetModuleProperties{Rule_class: "proto_library"}, CommonAttributes{ Loading
bp2build/cc_library_conversion_test.go +38 −0 Original line number Diff line number Diff line Loading @@ -5241,3 +5241,41 @@ func TestProtoLocalIncludeDirs(t *testing.T) { } runCcLibraryTestCase(t, tc) } // `foo_device` and `bar_host` can depend on .proto files of a specific dir, // the dynamically generated proto_library should not have any target_compatible_with func TestProtoLibraryForIncludeDirsIsOsAgnostic(t *testing.T) { tc := Bp2buildTestCase{ Description: "proto_library generated for proto.include_dirs is compatible for all axes", ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTestFactory: cc.LibraryFactory, Blueprint: simpleModuleDoNotConvertBp2build("cc_library", "libprotobuf-cpp-lite") + ` cc_library { name: "foo_device", device_supported: true, // this is the default behavior, but added explicitly here for illustration host_supported: false, proto: {include_dirs: ["dir"]}, } cc_library { name: "bar_host", device_supported: false, host_supported: true, srcs: ["bar.proto"], proto: {include_dirs: ["dir"]}, } `, Filesystem: map[string]string{ "dir/Android.bp": "", "dir/dir.proto": "", }, Dir: "dir", // check for the generated proto_library ExpectedBazelTargets: []string{ MakeBazelTargetNoRestrictions("proto_library", "dir.include_dir_bp2build_generated_proto", AttrNameToString{ "srcs": `["dir.proto"]`, "strip_import_prefix": `""`, "tags": `["manual"]`, }), }, } runCcLibraryTestCase(t, tc) }