Loading android/allowlists/allowlists.go +1 −0 Original line number Diff line number Diff line Loading @@ -451,6 +451,7 @@ var ( "linker_config", "java_import", "java_import_host", "sysprop_library", "aidl_interface_headers", } Loading sysprop/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ bootstrap_go_package { "blueprint", "soong", "soong-android", "soong-bp2build", "soong-cc", "soong-java", ], Loading @@ -18,6 +19,7 @@ bootstrap_go_package { ], testSrcs: [ "sysprop_test.go", "sysprop_library_conversion_test.go", ], pluginFor: ["soong_build"], } sysprop/sysprop_library.go +53 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import ( "path" "sync" "android/soong/bazel" "github.com/google/blueprint" "github.com/google/blueprint/proptools" Loading Loading @@ -125,6 +126,7 @@ func syspropJavaGenFactory() android.Module { type syspropLibrary struct { android.ModuleBase android.ApexModuleBase android.BazelModuleBase properties syspropLibraryProperties Loading Loading @@ -372,6 +374,7 @@ func syspropLibraryFactory() android.Module { ) android.InitAndroidModule(m) android.InitApexModule(m) android.InitBazelModule(m) android.AddLoadHook(m, func(ctx android.LoadHookContext) { syspropLibraryHook(ctx, m) }) return m } Loading Loading @@ -403,6 +406,9 @@ type ccLibraryProperties struct { Host_supported *bool Apex_available []string Min_sdk_version *string Bazel_module struct { Bp2build_available *bool } } type javaLibraryProperties struct { Loading Loading @@ -483,6 +489,11 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { ccProps.Host_supported = m.properties.Host_supported ccProps.Apex_available = m.ApexProperties.Apex_available ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version // A Bazel macro handles this, so this module does not need to be handled // in bp2build // TODO(b/237810289) perhaps do something different here so that we aren't // also disabling these modules in mixed builds ccProps.Bazel_module.Bp2build_available = proptools.BoolPtr(false) ctx.CreateModule(cc.LibraryFactory, &ccProps) scope := "internal" Loading Loading @@ -557,3 +568,45 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { *libraries = append(*libraries, "//"+ctx.ModuleDir()+":"+ctx.ModuleName()) } } // TODO(b/240463568): Additional properties will be added for API validation type bazelSyspropLibraryAttributes struct { Srcs bazel.LabelListAttribute } type bazelCcSyspropLibraryAttributes struct { Dep bazel.LabelAttribute Min_sdk_version *string } func (m *syspropLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "sysprop_library", Bzl_load_location: "//build/bazel/rules/sysprop:sysprop_library.bzl", }, android.CommonAttributes{Name: m.Name()}, &bazelSyspropLibraryAttributes{ Srcs: bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Srcs)), }) attrs := &bazelCcSyspropLibraryAttributes{ Dep: *bazel.MakeLabelAttribute(":" + m.Name()), Min_sdk_version: m.properties.Cpp.Min_sdk_version, } ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "cc_sysprop_library_shared", Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl", }, android.CommonAttributes{Name: m.CcImplementationModuleName()}, attrs) ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "cc_sysprop_library_static", Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl", }, android.CommonAttributes{Name: m.CcImplementationModuleName() + "_bp2build_cc_library_static"}, attrs) } sysprop/sysprop_library_conversion_test.go 0 → 100644 +110 −0 Original line number Diff line number Diff line // Copyright 2022 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 sysprop import ( "testing" "android/soong/bp2build" ) func TestSyspropLibrarySimple(t *testing.T) { bp2build.RunBp2BuildTestCaseSimple(t, bp2build.Bp2buildTestCase{ Description: "sysprop_library simple", ModuleTypeUnderTest: "sysprop_library", ModuleTypeUnderTestFactory: syspropLibraryFactory, Filesystem: map[string]string{ "foo.sysprop": "", "bar.sysprop": "", }, Blueprint: ` sysprop_library { name: "sysprop_foo", srcs: [ "foo.sysprop", "bar.sysprop", ], property_owner: "Platform", } `, ExpectedBazelTargets: []string{ bp2build.MakeBazelTargetNoRestrictions("sysprop_library", "sysprop_foo_sysprop_library", bp2build.AttrNameToString{ "srcs": `[ "foo.sysprop", "bar.sysprop", ]`, }), bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_shared", "libsysprop_foo", bp2build.AttrNameToString{ "dep": `":sysprop_foo_sysprop_library"`, }), bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static", "libsysprop_foo_bp2build_cc_library_static", bp2build.AttrNameToString{ "dep": `":sysprop_foo_sysprop_library"`, }), }, }) } func TestSyspropLibraryCppMinSdkVersion(t *testing.T) { bp2build.RunBp2BuildTestCaseSimple(t, bp2build.Bp2buildTestCase{ Description: "sysprop_library with min_sdk_version", ModuleTypeUnderTest: "sysprop_library", ModuleTypeUnderTestFactory: syspropLibraryFactory, Filesystem: map[string]string{ "foo.sysprop": "", "bar.sysprop": "", }, Blueprint: ` sysprop_library { name: "sysprop_foo", srcs: [ "foo.sysprop", "bar.sysprop", ], cpp: { min_sdk_version: "5", }, property_owner: "Platform", } `, ExpectedBazelTargets: []string{ bp2build.MakeBazelTargetNoRestrictions("sysprop_library", "sysprop_foo_sysprop_library", bp2build.AttrNameToString{ "srcs": `[ "foo.sysprop", "bar.sysprop", ]`, }), bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_shared", "libsysprop_foo", bp2build.AttrNameToString{ "dep": `":sysprop_foo_sysprop_library"`, "min_sdk_version": `"5"`, }), bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static", "libsysprop_foo_bp2build_cc_library_static", bp2build.AttrNameToString{ "dep": `":sysprop_foo_sysprop_library"`, "min_sdk_version": `"5"`, }), }, }) } Loading
android/allowlists/allowlists.go +1 −0 Original line number Diff line number Diff line Loading @@ -451,6 +451,7 @@ var ( "linker_config", "java_import", "java_import_host", "sysprop_library", "aidl_interface_headers", } Loading
sysprop/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ bootstrap_go_package { "blueprint", "soong", "soong-android", "soong-bp2build", "soong-cc", "soong-java", ], Loading @@ -18,6 +19,7 @@ bootstrap_go_package { ], testSrcs: [ "sysprop_test.go", "sysprop_library_conversion_test.go", ], pluginFor: ["soong_build"], }
sysprop/sysprop_library.go +53 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import ( "path" "sync" "android/soong/bazel" "github.com/google/blueprint" "github.com/google/blueprint/proptools" Loading Loading @@ -125,6 +126,7 @@ func syspropJavaGenFactory() android.Module { type syspropLibrary struct { android.ModuleBase android.ApexModuleBase android.BazelModuleBase properties syspropLibraryProperties Loading Loading @@ -372,6 +374,7 @@ func syspropLibraryFactory() android.Module { ) android.InitAndroidModule(m) android.InitApexModule(m) android.InitBazelModule(m) android.AddLoadHook(m, func(ctx android.LoadHookContext) { syspropLibraryHook(ctx, m) }) return m } Loading Loading @@ -403,6 +406,9 @@ type ccLibraryProperties struct { Host_supported *bool Apex_available []string Min_sdk_version *string Bazel_module struct { Bp2build_available *bool } } type javaLibraryProperties struct { Loading Loading @@ -483,6 +489,11 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { ccProps.Host_supported = m.properties.Host_supported ccProps.Apex_available = m.ApexProperties.Apex_available ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version // A Bazel macro handles this, so this module does not need to be handled // in bp2build // TODO(b/237810289) perhaps do something different here so that we aren't // also disabling these modules in mixed builds ccProps.Bazel_module.Bp2build_available = proptools.BoolPtr(false) ctx.CreateModule(cc.LibraryFactory, &ccProps) scope := "internal" Loading Loading @@ -557,3 +568,45 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { *libraries = append(*libraries, "//"+ctx.ModuleDir()+":"+ctx.ModuleName()) } } // TODO(b/240463568): Additional properties will be added for API validation type bazelSyspropLibraryAttributes struct { Srcs bazel.LabelListAttribute } type bazelCcSyspropLibraryAttributes struct { Dep bazel.LabelAttribute Min_sdk_version *string } func (m *syspropLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "sysprop_library", Bzl_load_location: "//build/bazel/rules/sysprop:sysprop_library.bzl", }, android.CommonAttributes{Name: m.Name()}, &bazelSyspropLibraryAttributes{ Srcs: bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Srcs)), }) attrs := &bazelCcSyspropLibraryAttributes{ Dep: *bazel.MakeLabelAttribute(":" + m.Name()), Min_sdk_version: m.properties.Cpp.Min_sdk_version, } ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "cc_sysprop_library_shared", Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl", }, android.CommonAttributes{Name: m.CcImplementationModuleName()}, attrs) ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "cc_sysprop_library_static", Bzl_load_location: "//build/bazel/rules/cc:cc_sysprop_library.bzl", }, android.CommonAttributes{Name: m.CcImplementationModuleName() + "_bp2build_cc_library_static"}, attrs) }
sysprop/sysprop_library_conversion_test.go 0 → 100644 +110 −0 Original line number Diff line number Diff line // Copyright 2022 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 sysprop import ( "testing" "android/soong/bp2build" ) func TestSyspropLibrarySimple(t *testing.T) { bp2build.RunBp2BuildTestCaseSimple(t, bp2build.Bp2buildTestCase{ Description: "sysprop_library simple", ModuleTypeUnderTest: "sysprop_library", ModuleTypeUnderTestFactory: syspropLibraryFactory, Filesystem: map[string]string{ "foo.sysprop": "", "bar.sysprop": "", }, Blueprint: ` sysprop_library { name: "sysprop_foo", srcs: [ "foo.sysprop", "bar.sysprop", ], property_owner: "Platform", } `, ExpectedBazelTargets: []string{ bp2build.MakeBazelTargetNoRestrictions("sysprop_library", "sysprop_foo_sysprop_library", bp2build.AttrNameToString{ "srcs": `[ "foo.sysprop", "bar.sysprop", ]`, }), bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_shared", "libsysprop_foo", bp2build.AttrNameToString{ "dep": `":sysprop_foo_sysprop_library"`, }), bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static", "libsysprop_foo_bp2build_cc_library_static", bp2build.AttrNameToString{ "dep": `":sysprop_foo_sysprop_library"`, }), }, }) } func TestSyspropLibraryCppMinSdkVersion(t *testing.T) { bp2build.RunBp2BuildTestCaseSimple(t, bp2build.Bp2buildTestCase{ Description: "sysprop_library with min_sdk_version", ModuleTypeUnderTest: "sysprop_library", ModuleTypeUnderTestFactory: syspropLibraryFactory, Filesystem: map[string]string{ "foo.sysprop": "", "bar.sysprop": "", }, Blueprint: ` sysprop_library { name: "sysprop_foo", srcs: [ "foo.sysprop", "bar.sysprop", ], cpp: { min_sdk_version: "5", }, property_owner: "Platform", } `, ExpectedBazelTargets: []string{ bp2build.MakeBazelTargetNoRestrictions("sysprop_library", "sysprop_foo_sysprop_library", bp2build.AttrNameToString{ "srcs": `[ "foo.sysprop", "bar.sysprop", ]`, }), bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_shared", "libsysprop_foo", bp2build.AttrNameToString{ "dep": `":sysprop_foo_sysprop_library"`, "min_sdk_version": `"5"`, }), bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static", "libsysprop_foo_bp2build_cc_library_static", bp2build.AttrNameToString{ "dep": `":sysprop_foo_sysprop_library"`, "min_sdk_version": `"5"`, }), }, }) }