Loading android/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ bootstrap_go_package { "api_levels.go", "arch.go", "arch_list.go", "bazel.go", "bazel_handler.go", "config.go", "csuite_config.go", Loading android/bazel.go 0 → 100644 +57 −0 Original line number Diff line number Diff line // Copyright 2021 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package android import "android/soong/bazel" // BazelModuleBase contains the property structs with metadata for modules which can be converted to // Bazel. type BazelModuleBase struct { bazelProperties bazel.Properties } // Bazelable is specifies the interface for modules that can be converted to Bazel. type Bazelable interface { bazelProps() *bazel.Properties GetBazelLabel() string ConvertWithBp2build() bool } // BazelModule is a lightweight wrapper interface around Module for Bazel-convertible modules. type BazelModule interface { Module Bazelable } // InitBazelModule is a wrapper function that decorates a BazelModule with Bazel-conversion // properties. func InitBazelModule(module BazelModule) { module.AddProperties(module.bazelProps()) } // bazelProps returns the Bazel properties for the given BazelModuleBase. func (b *BazelModuleBase) bazelProps() *bazel.Properties { return &b.bazelProperties } // GetBazelLabel returns the Bazel label for the given BazelModuleBase. func (b *BazelModuleBase) GetBazelLabel() string { return b.bazelProperties.Bazel_module.Label } // ConvertWithBp2build returns whether the given BazelModuleBase should be converted with bp2build. func (b *BazelModuleBase) ConvertWithBp2build() bool { return b.bazelProperties.Bazel_module.Bp2build_available } android/filegroup.go +3 −4 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ func (bfg *bazelFilegroup) GenerateAndroidBuildActions(ctx ModuleContext) {} func FilegroupBp2Build(ctx TopDownMutatorContext) { fg, ok := ctx.Module().(*fileGroup) if !ok || !fg.properties.Bazel_module.Bp2build_available { if !ok || !fg.ConvertWithBp2build() { return } Loading Loading @@ -77,13 +77,11 @@ type fileGroupProperties struct { // Create a make variable with the specified name that contains the list of files in the // filegroup, relative to the root of the source tree. Export_to_make_var *string // Properties for Bazel migration purposes. bazel.Properties } type fileGroup struct { ModuleBase BazelModuleBase properties fileGroupProperties srcs Paths } Loading @@ -97,6 +95,7 @@ func FileGroupFactory() Module { module := &fileGroup{} module.AddProperties(&module.properties) InitAndroidModule(module) InitBazelModule(module) return module } Loading bp2build/testing.go +4 −5 Original line number Diff line number Diff line Loading @@ -25,10 +25,9 @@ type customProps struct { type customModule struct { android.ModuleBase android.BazelModuleBase props customProps bazelProps bazel.Properties } // OutputFiles is needed because some instances of this module use dist with a Loading @@ -44,7 +43,7 @@ func (m *customModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { func customModuleFactoryBase() android.Module { module := &customModule{} module.AddProperties(&module.props) module.AddProperties(&module.bazelProps) android.InitBazelModule(module) return module } Loading Loading @@ -127,7 +126,7 @@ func (m *customBazelModule) GenerateAndroidBuildActions(ctx android.ModuleContex func customBp2BuildMutator(ctx android.TopDownMutatorContext) { if m, ok := ctx.Module().(*customModule); ok { if !m.bazelProps.Bazel_module.Bp2build_available { if !m.ConvertWithBp2build() { return } Loading @@ -148,7 +147,7 @@ func customBp2BuildMutator(ctx android.TopDownMutatorContext) { // module to target. func customBp2BuildMutatorFromStarlark(ctx android.TopDownMutatorContext) { if m, ok := ctx.Module().(*customModule); ok { if !m.bazelProps.Bazel_module.Bp2build_available { if !m.ConvertWithBp2build() { return } Loading cc/cc.go +2 −3 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" "android/soong/bazel" "android/soong/cc/config" "android/soong/genrule" ) Loading Loading @@ -365,8 +364,6 @@ type BaseProperties struct { // can depend on libraries that are not exported by the APEXes and use private symbols // from the exported libraries. Test_for []string bazel.Properties } type VendorProperties struct { Loading Loading @@ -765,6 +762,7 @@ type Module struct { android.DefaultableModuleBase android.ApexModuleBase android.SdkBase android.BazelModuleBase Properties BaseProperties VendorProperties VendorProperties Loading Loading @@ -1054,6 +1052,7 @@ func (c *Module) Init() android.Module { } android.InitAndroidArchModule(c, c.hod, c.multilib) android.InitBazelModule(c) android.InitApexModule(c) android.InitSdkAwareModule(c) android.InitDefaultableModule(c) Loading Loading
android/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ bootstrap_go_package { "api_levels.go", "arch.go", "arch_list.go", "bazel.go", "bazel_handler.go", "config.go", "csuite_config.go", Loading
android/bazel.go 0 → 100644 +57 −0 Original line number Diff line number Diff line // Copyright 2021 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package android import "android/soong/bazel" // BazelModuleBase contains the property structs with metadata for modules which can be converted to // Bazel. type BazelModuleBase struct { bazelProperties bazel.Properties } // Bazelable is specifies the interface for modules that can be converted to Bazel. type Bazelable interface { bazelProps() *bazel.Properties GetBazelLabel() string ConvertWithBp2build() bool } // BazelModule is a lightweight wrapper interface around Module for Bazel-convertible modules. type BazelModule interface { Module Bazelable } // InitBazelModule is a wrapper function that decorates a BazelModule with Bazel-conversion // properties. func InitBazelModule(module BazelModule) { module.AddProperties(module.bazelProps()) } // bazelProps returns the Bazel properties for the given BazelModuleBase. func (b *BazelModuleBase) bazelProps() *bazel.Properties { return &b.bazelProperties } // GetBazelLabel returns the Bazel label for the given BazelModuleBase. func (b *BazelModuleBase) GetBazelLabel() string { return b.bazelProperties.Bazel_module.Label } // ConvertWithBp2build returns whether the given BazelModuleBase should be converted with bp2build. func (b *BazelModuleBase) ConvertWithBp2build() bool { return b.bazelProperties.Bazel_module.Bp2build_available }
android/filegroup.go +3 −4 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ func (bfg *bazelFilegroup) GenerateAndroidBuildActions(ctx ModuleContext) {} func FilegroupBp2Build(ctx TopDownMutatorContext) { fg, ok := ctx.Module().(*fileGroup) if !ok || !fg.properties.Bazel_module.Bp2build_available { if !ok || !fg.ConvertWithBp2build() { return } Loading Loading @@ -77,13 +77,11 @@ type fileGroupProperties struct { // Create a make variable with the specified name that contains the list of files in the // filegroup, relative to the root of the source tree. Export_to_make_var *string // Properties for Bazel migration purposes. bazel.Properties } type fileGroup struct { ModuleBase BazelModuleBase properties fileGroupProperties srcs Paths } Loading @@ -97,6 +95,7 @@ func FileGroupFactory() Module { module := &fileGroup{} module.AddProperties(&module.properties) InitAndroidModule(module) InitBazelModule(module) return module } Loading
bp2build/testing.go +4 −5 Original line number Diff line number Diff line Loading @@ -25,10 +25,9 @@ type customProps struct { type customModule struct { android.ModuleBase android.BazelModuleBase props customProps bazelProps bazel.Properties } // OutputFiles is needed because some instances of this module use dist with a Loading @@ -44,7 +43,7 @@ func (m *customModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { func customModuleFactoryBase() android.Module { module := &customModule{} module.AddProperties(&module.props) module.AddProperties(&module.bazelProps) android.InitBazelModule(module) return module } Loading Loading @@ -127,7 +126,7 @@ func (m *customBazelModule) GenerateAndroidBuildActions(ctx android.ModuleContex func customBp2BuildMutator(ctx android.TopDownMutatorContext) { if m, ok := ctx.Module().(*customModule); ok { if !m.bazelProps.Bazel_module.Bp2build_available { if !m.ConvertWithBp2build() { return } Loading @@ -148,7 +147,7 @@ func customBp2BuildMutator(ctx android.TopDownMutatorContext) { // module to target. func customBp2BuildMutatorFromStarlark(ctx android.TopDownMutatorContext) { if m, ok := ctx.Module().(*customModule); ok { if !m.bazelProps.Bazel_module.Bp2build_available { if !m.ConvertWithBp2build() { return } Loading
cc/cc.go +2 −3 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" "android/soong/bazel" "android/soong/cc/config" "android/soong/genrule" ) Loading Loading @@ -365,8 +364,6 @@ type BaseProperties struct { // can depend on libraries that are not exported by the APEXes and use private symbols // from the exported libraries. Test_for []string bazel.Properties } type VendorProperties struct { Loading Loading @@ -765,6 +762,7 @@ type Module struct { android.DefaultableModuleBase android.ApexModuleBase android.SdkBase android.BazelModuleBase Properties BaseProperties VendorProperties VendorProperties Loading Loading @@ -1054,6 +1052,7 @@ func (c *Module) Init() android.Module { } android.InitAndroidArchModule(c, c.hod, c.multilib) android.InitBazelModule(c) android.InitApexModule(c) android.InitSdkAwareModule(c) android.InitDefaultableModule(c) Loading