diff options
| -rw-r--r-- | android/allowlists/allowlists.go | 3 | ||||
| -rw-r--r-- | android/bazel_handler.go | 34 | ||||
| -rw-r--r-- | apex/apex_test.go | 25 | ||||
| -rw-r--r-- | apex/builder.go | 21 | ||||
| -rw-r--r-- | bazel/cquery/request_type.go | 49 | ||||
| -rw-r--r-- | bp2build/Android.bp | 1 | ||||
| -rw-r--r-- | bp2build/apex_conversion_test.go | 14 | ||||
| -rw-r--r-- | bp2build/platform_compat_config_conversion_test.go | 53 | ||||
| -rw-r--r-- | cc/cc.go | 17 | ||||
| -rw-r--r-- | etc/prebuilt_etc.go | 74 | ||||
| -rw-r--r-- | etc/prebuilt_etc_test.go | 39 | ||||
| -rw-r--r-- | java/platform_compat_config.go | 23 | ||||
| -rwxr-xr-x | tests/run_integration_tests.sh | 3 | ||||
| -rw-r--r-- | ui/build/config.go | 3 |
14 files changed, 313 insertions, 46 deletions
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go index a5fcee414..5da50cd58 100644 --- a/android/allowlists/allowlists.go +++ b/android/allowlists/allowlists.go @@ -788,6 +788,9 @@ var ( "binderUtilsHostTest", "run_dex2oat_test", "bluetooth-address-unit-tests", + + // for platform_compat_config + "process-compat-config", } Bp2buildModuleTypeAlwaysConvertList = []string{ diff --git a/android/bazel_handler.go b/android/bazel_handler.go index d71eca2fa..28bcaced5 100644 --- a/android/bazel_handler.go +++ b/android/bazel_handler.go @@ -187,6 +187,9 @@ type BazelContext interface { // Returns the results of the GetCcUnstrippedInfo query GetCcUnstrippedInfo(label string, cfgkey configKey) (cquery.CcUnstrippedInfo, error) + // Returns the results of the GetPrebuiltFileInfo query + GetPrebuiltFileInfo(label string, cfgKey configKey) (cquery.PrebuiltFileInfo, error) + // ** end Cquery Results Retrieval Functions // Issues commands to Bazel to receive results for all cquery requests @@ -272,11 +275,12 @@ var _ BazelContext = noopBazelContext{} type MockBazelContext struct { OutputBaseDir string - LabelToOutputFiles map[string][]string - LabelToCcInfo map[string]cquery.CcInfo - LabelToPythonBinary map[string]string - LabelToApexInfo map[string]cquery.ApexInfo - LabelToCcBinary map[string]cquery.CcUnstrippedInfo + LabelToOutputFiles map[string][]string + LabelToCcInfo map[string]cquery.CcInfo + LabelToPythonBinary map[string]string + LabelToApexInfo map[string]cquery.ApexInfo + LabelToCcBinary map[string]cquery.CcUnstrippedInfo + LabelToPrebuiltFileInfo map[string]cquery.PrebuiltFileInfo BazelRequests map[string]bool } @@ -325,6 +329,14 @@ func (m MockBazelContext) GetCcUnstrippedInfo(label string, _ configKey) (cquery return result, nil } +func (m MockBazelContext) GetPrebuiltFileInfo(label string, _ configKey) (cquery.PrebuiltFileInfo, error) { + result, ok := m.LabelToPrebuiltFileInfo[label] + if !ok { + return cquery.PrebuiltFileInfo{}, fmt.Errorf("no target with label %q in LabelToPrebuiltFileInfo", label) + } + return result, nil +} + func (m MockBazelContext) InvokeBazel(_ Config, _ invokeBazelContext) error { panic("unimplemented") } @@ -433,6 +445,14 @@ func (bazelCtx *mixedBuildBazelContext) GetCcUnstrippedInfo(label string, cfgKey return cquery.CcUnstrippedInfo{}, fmt.Errorf("no bazel response for %s", key) } +func (bazelCtx *mixedBuildBazelContext) GetPrebuiltFileInfo(label string, cfgKey configKey) (cquery.PrebuiltFileInfo, error) { + key := makeCqueryKey(label, cquery.GetPrebuiltFileInfo, cfgKey) + if rawString, ok := bazelCtx.results[key]; ok { + return cquery.GetPrebuiltFileInfo.ParseResult(strings.TrimSpace(rawString)) + } + return cquery.PrebuiltFileInfo{}, fmt.Errorf("no bazel response for %s", key) +} + func (n noopBazelContext) QueueBazelRequest(_ string, _ cqueryRequest, _ configKey) { panic("unimplemented") } @@ -454,6 +474,10 @@ func (n noopBazelContext) GetCcUnstrippedInfo(_ string, _ configKey) (cquery.CcU panic("implement me") } +func (n noopBazelContext) GetPrebuiltFileInfo(_ string, _ configKey) (cquery.PrebuiltFileInfo, error) { + panic("implement me") +} + func (n noopBazelContext) InvokeBazel(_ Config, _ invokeBazelContext) error { panic("unimplemented") } diff --git a/apex/apex_test.go b/apex/apex_test.go index c781be4ef..149b1770a 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -786,18 +786,16 @@ func TestApexManifestMinSdkVersion(t *testing.T) { } func TestFileContexts(t *testing.T) { - for _, useFileContextsAsIs := range []bool{true, false} { + for _, vendor := range []bool{true, false} { prop := "" - if useFileContextsAsIs { - prop = "use_file_contexts_as_is: true,\n" + if vendor { + prop = "vendor: true,\n" } ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", - file_contexts: "file_contexts", updatable: false, - vendor: true, `+prop+` } @@ -806,18 +804,17 @@ func TestFileContexts(t *testing.T) { public_key: "testkey.avbpubkey", private_key: "testkey.pem", } - `, withFiles(map[string][]byte{ - "file_contexts": nil, - })) + `) rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("file_contexts") - forceLabellingCommand := "apex_manifest\\\\.pb u:object_r:system_file:s0" - if useFileContextsAsIs { - android.AssertStringDoesNotContain(t, "should force-label", - rule.RuleParams.Command, forceLabellingCommand) + if vendor { + android.AssertStringDoesContain(t, "should force-label as vendor_apex_metadata_file", + rule.RuleParams.Command, + "apex_manifest\\\\.pb u:object_r:vendor_apex_metadata_file:s0") } else { - android.AssertStringDoesContain(t, "shouldn't force-label", - rule.RuleParams.Command, forceLabellingCommand) + android.AssertStringDoesContain(t, "should force-label as system_file", + rule.RuleParams.Command, + "apex_manifest\\\\.pb u:object_r:system_file:s0") } } } diff --git a/apex/builder.go b/apex/builder.go index c691a3341..a2fe2a0d2 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -330,7 +330,7 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, // buildFileContexts create build rules to append an entry for apex_manifest.pb to the file_contexts // file for this APEX which is either from /systme/sepolicy/apex/<apexname>-file_contexts or from // the file_contexts property of this APEX. This is to make sure that the manifest file is correctly -// labeled as system_file. +// labeled as system_file or vendor_apex_metadata_file. func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.OutputPath { var fileContexts android.Path var fileContextsDir string @@ -362,6 +362,13 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Output output := android.PathForModuleOut(ctx, "file_contexts") rule := android.NewRuleBuilder(pctx, ctx) + forceLabel := "u:object_r:system_file:s0" + if a.SocSpecific() && !a.vndkApex { + // APEX on /vendor should label ./ and ./apex_manifest.pb as vendor_apex_metadata_file. + // The reason why we skip VNDK APEX is that aosp_{pixel device} targets install VNDK APEX on /vendor + // even though VNDK APEX is supposed to be installed on /system. (See com.android.vndk.current.on_vendor) + forceLabel = "u:object_r:vendor_apex_metadata_file:s0" + } switch a.properties.ApexType { case imageApex: // remove old file @@ -371,9 +378,9 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Output // new line rule.Command().Text("echo").Text(">>").Output(output) if !useFileContextsAsIs { - // force-label /apex_manifest.pb and / as system_file so that apexd can read them - rule.Command().Text("echo").Flag("/apex_manifest\\\\.pb u:object_r:system_file:s0").Text(">>").Output(output) - rule.Command().Text("echo").Flag("/ u:object_r:system_file:s0").Text(">>").Output(output) + // force-label /apex_manifest.pb and / + rule.Command().Text("echo").Text("/apex_manifest\\\\.pb").Text(forceLabel).Text(">>").Output(output) + rule.Command().Text("echo").Text("/").Text(forceLabel).Text(">>").Output(output) } case flattenedApex: // For flattened apexes, install path should be prepended. @@ -388,9 +395,9 @@ func (a *apexBundle) buildFileContexts(ctx android.ModuleContext) android.Output // new line rule.Command().Text("echo").Text(">>").Output(output) if !useFileContextsAsIs { - // force-label /apex_manifest.pb and / as system_file so that apexd can read them - rule.Command().Text("echo").Flag(apexPath + `/apex_manifest\\.pb u:object_r:system_file:s0`).Text(">>").Output(output) - rule.Command().Text("echo").Flag(apexPath + "/ u:object_r:system_file:s0").Text(">>").Output(output) + // force-label /apex_manifest.pb and / + rule.Command().Text("echo").Text(apexPath + "/apex_manifest\\\\.pb").Text(forceLabel).Text(">>").Output(output) + rule.Command().Text("echo").Text(apexPath + "/").Text(forceLabel).Text(">>").Output(output) } default: panic(fmt.Errorf("unsupported type %v", a.properties.ApexType)) diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go index ca96f2339..791c6bc23 100644 --- a/bazel/cquery/request_type.go +++ b/bazel/cquery/request_type.go @@ -11,6 +11,7 @@ var ( GetCcInfo = &getCcInfoType{} GetApexInfo = &getApexInfoType{} GetCcUnstrippedInfo = &getCcUnstrippedInfoType{} + GetPrebuiltFileInfo = &getPrebuiltFileInfo{} ) type CcAndroidMkInfo struct { @@ -375,3 +376,51 @@ func parseJson(jsonString string, info interface{}) error { } return nil } + +type getPrebuiltFileInfo struct{} + +// Name returns a string name for this request type. Such request type names must be unique, +// and must only consist of alphanumeric characters. +func (g getPrebuiltFileInfo) Name() string { + return "getPrebuiltFileInfo" +} + +// StarlarkFunctionBody returns a starlark function body to process this request type. +// The returned string is the body of a Starlark function which obtains +// all request-relevant information about a target and returns a string containing +// this information. +// The function should have the following properties: +// - The arguments are `target` (a configured target) and `id_string` (the label + configuration). +// - The return value must be a string. +// - The function body should not be indented outside of its own scope. +func (g getPrebuiltFileInfo) StarlarkFunctionBody() string { + return ` +p = providers(target) +prebuilt_file_info = p.get("//build/bazel/rules:prebuilt_file.bzl%PrebuiltFileInfo") +if not prebuilt_file_info: + fail("%s did not provide PrebuiltFileInfo" % id_string) + +return json.encode({ + "Src": prebuilt_file_info.src.path, + "Dir": prebuilt_file_info.dir, + "Filename": prebuilt_file_info.filename, + "Installable": prebuilt_file_info.installable, +})` +} + +type PrebuiltFileInfo struct { + // TODO: b/207489266 - Fully support all properties in prebuilt_file + Src string + Dir string + Filename string + Installable bool +} + +// ParseResult returns a value obtained by parsing the result of the request's Starlark function. +// The given rawString must correspond to the string output which was created by evaluating the +// Starlark given in StarlarkFunctionBody. +func (g getPrebuiltFileInfo) ParseResult(rawString string) (PrebuiltFileInfo, error) { + var info PrebuiltFileInfo + err := parseJson(rawString, &info) + return info, err +} diff --git a/bp2build/Android.bp b/bp2build/Android.bp index 4ecd05de7..782a88c72 100644 --- a/bp2build/Android.bp +++ b/bp2build/Android.bp @@ -74,6 +74,7 @@ bootstrap_go_package { "linker_config_conversion_test.go", "package_conversion_test.go", "performance_test.go", + "platform_compat_config_conversion_test.go", "prebuilt_etc_conversion_test.go", "python_binary_conversion_test.go", "python_library_conversion_test.go", diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go index 390cabe1f..84c7ea2e3 100644 --- a/bp2build/apex_conversion_test.go +++ b/bp2build/apex_conversion_test.go @@ -123,6 +123,7 @@ apex { name: "com.android.apogee", manifest: "apogee_manifest.json", androidManifest: "ApogeeAndroidManifest.xml", + apex_available_name: "apogee_apex_name", file_contexts: ":com.android.apogee-file_contexts", min_sdk_version: "29", key: "com.android.apogee.key", @@ -144,11 +145,13 @@ apex { ], package_name: "com.android.apogee.test.package", logging_parent: "logging.parent", + variant_version: "3", } `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.android.apogee", AttrNameToString{ - "android_manifest": `"ApogeeAndroidManifest.xml"`, + "android_manifest": `"ApogeeAndroidManifest.xml"`, + "apex_available_name": `"apogee_apex_name"`, "binaries": `[ ":cc_binary_1", ":sh_binary_2", @@ -185,10 +188,11 @@ apex { ":prebuilt_1", ":prebuilt_2", ]`, - "updatable": "False", - "compressible": "False", - "package_name": `"com.android.apogee.test.package"`, - "logging_parent": `"logging.parent"`, + "updatable": "False", + "compressible": "False", + "package_name": `"com.android.apogee.test.package"`, + "logging_parent": `"logging.parent"`, + "variant_version": `"3"`, }), }}) } diff --git a/bp2build/platform_compat_config_conversion_test.go b/bp2build/platform_compat_config_conversion_test.go new file mode 100644 index 000000000..4dfcce3a3 --- /dev/null +++ b/bp2build/platform_compat_config_conversion_test.go @@ -0,0 +1,53 @@ +// Copyright 2023 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 bp2build + +import ( + "testing" + + "android/soong/android" + "android/soong/java" +) + +func runPlatformCompatConfigTestCase(t *testing.T, tc Bp2buildTestCase) { + t.Helper() + RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { + ctx.RegisterModuleType("java_library", java.LibraryFactory) + ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory) + }, tc) +} + +func TestPlatformCompatConfig(t *testing.T) { + runPlatformCompatConfigTestCase(t, Bp2buildTestCase{ + Description: "platform_compat_config - conversion test", + Blueprint: ` + platform_compat_config { + name: "foo", + src: ":lib", + }`, + Filesystem: map[string]string{ + "a/b/Android.bp": ` + java_library { + name: "lib", + srcs: ["a.java"], + }`, + }, + ExpectedBazelTargets: []string{ + MakeBazelTarget("platform_compat_config", "foo", AttrNameToString{ + "src": `"//a/b:lib"`, + }), + }, + }) +} @@ -1913,14 +1913,14 @@ func (c *Module) QueueBazelCall(ctx android.BaseModuleContext) { // IsMixedBuildSupported returns true if the module should be analyzed by Bazel // in any of the --bazel-mode(s). func (c *Module) IsMixedBuildSupported(ctx android.BaseModuleContext) bool { - if !allEnabledSanitizersSupportedByBazel(c) { + if !allEnabledSanitizersSupportedByBazel(ctx, c) { //TODO(b/278772861) support sanitizers in Bazel rules return false } return c.bazelHandler != nil } -func allEnabledSanitizersSupportedByBazel(c *Module) bool { +func allEnabledSanitizersSupportedByBazel(ctx android.BaseModuleContext, c *Module) bool { if c.sanitize == nil { return true } @@ -1943,12 +1943,17 @@ func allEnabledSanitizersSupportedByBazel(c *Module) bool { // TODO(b/261058727): enable mixed builds for all modules with UBSan // Currently we can only support ubsan when minimum runtime is used. ubsanEnabled := Bool(sanitizeProps.Integer_overflow) || len(sanitizeProps.Misc_undefined) > 0 - if ubsanEnabled && !c.MinimalRuntimeNeeded() { - return false + if !ubsanEnabled || c.MinimalRuntimeNeeded() { + continue } } else if san == cfi { - continue - } else if c.sanitize.isSanitizerEnabled(san) { + apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) + // Only allow cfi if this is an apex variant + if !apexInfo.IsForPlatform() { + continue + } + } + if c.sanitize.isSanitizerEnabled(san) { return false } } diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go index 3e1bbded6..370a4235b 100644 --- a/etc/prebuilt_etc.go +++ b/etc/prebuilt_etc.go @@ -38,6 +38,7 @@ import ( "android/soong/android" "android/soong/bazel" + "android/soong/bazel/cquery" "android/soong/snapshot" ) @@ -329,7 +330,6 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.PropertyErrorf("src", "missing prebuilt source file") return } - p.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath if strings.Contains(filename, "/") { ctx.PropertyErrorf("filename", "filename cannot contain separator '/'") @@ -349,21 +349,42 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) { } p.installDirPath = android.PathForModuleInstall(ctx, installBaseDir, p.SubDir()) + // Call InstallFile even when uninstallable to make the module included in the package + ip := installProperties{ + installable: p.Installable(), + filename: filename, + sourceFilePath: p.sourceFilePath, + symlinks: p.properties.Symlinks, + } + p.addInstallRules(ctx, ip) +} + +type installProperties struct { + installable bool + filename string + sourceFilePath android.Path + symlinks []string +} + +// utility function to add install rules to the build graph. +// Reduces code duplication between Soong and Mixed build analysis +func (p *PrebuiltEtc) addInstallRules(ctx android.ModuleContext, ip installProperties) { + if !ip.installable { + p.SkipInstall() + } + + // Copy the file from src to a location in out/ with the correct `filename` // This ensures that outputFilePath has the correct name for others to // use, as the source file may have a different name. + p.outputFilePath = android.PathForModuleOut(ctx, ip.filename).OutputPath ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, Output: p.outputFilePath, - Input: p.sourceFilePath, + Input: ip.sourceFilePath, }) - if !p.Installable() { - p.SkipInstall() - } - - // Call InstallFile even when uninstallable to make the module included in the package - installPath := ctx.InstallFile(p.installDirPath, p.outputFilePath.Base(), p.outputFilePath) - for _, sl := range p.properties.Symlinks { + installPath := ctx.InstallFile(p.installDirPath, ip.filename, p.outputFilePath) + for _, sl := range ip.symlinks { ctx.InstallSymlink(p.installDirPath, sl, installPath) } } @@ -781,3 +802,38 @@ func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.TopDownMutatorContext ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs) } + +var _ android.MixedBuildBuildable = (*PrebuiltEtc)(nil) + +func (pe *PrebuiltEtc) IsMixedBuildSupported(ctx android.BaseModuleContext) bool { + return true +} + +func (pe *PrebuiltEtc) QueueBazelCall(ctx android.BaseModuleContext) { + ctx.Config().BazelContext.QueueBazelRequest( + pe.GetBazelLabel(ctx, pe), + cquery.GetPrebuiltFileInfo, + android.GetConfigKey(ctx), + ) +} + +func (pe *PrebuiltEtc) ProcessBazelQueryResponse(ctx android.ModuleContext) { + bazelCtx := ctx.Config().BazelContext + pfi, err := bazelCtx.GetPrebuiltFileInfo(pe.GetBazelLabel(ctx, pe), android.GetConfigKey(ctx)) + if err != nil { + ctx.ModuleErrorf(err.Error()) + return + } + + // Set properties for androidmk + pe.installDirPath = android.PathForModuleInstall(ctx, pfi.Dir) + + // Installation rules + ip := installProperties{ + installable: pfi.Installable, + filename: pfi.Filename, + sourceFilePath: android.PathForSource(ctx, pfi.Src), + // symlinks: pe.properties.Symlinks, // TODO: b/207489266 - Fully support all properties in prebuilt_file + } + pe.addInstallRules(ctx, ip) +} diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go index 0d44c31ef..df7664d7d 100644 --- a/etc/prebuilt_etc_test.go +++ b/etc/prebuilt_etc_test.go @@ -23,6 +23,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/bazel/cquery" "android/soong/snapshot" ) @@ -494,3 +495,41 @@ func TestPrebuiltTakeSnapshot(t *testing.T) { checkIfSnapshotNotTaken(t, result, "recovery", "prebuilt_recovery_indirect") }) } + +func TestPrebuiltEtcAndroidMkEntriesWithBazel(t *testing.T) { + t.Parallel() + bp := ` +prebuilt_etc { + name: "myetc", + src: "prebuilt_etc.rc", // filename in src tree + filename: "init.rc", // target filename on device + sub_dir: "subdir", // relative subdir for installation + bazel_module: { label: "//foo/bar:myetc" }, +} +` + res := android.GroupFixturePreparers( + prepareForPrebuiltEtcTest, + android.FixtureModifyConfig(func(cfg android.Config) { + cfg.BazelContext = android.MockBazelContext{ + LabelToPrebuiltFileInfo: map[string]cquery.PrebuiltFileInfo{ + "//foo/bar:myetc": cquery.PrebuiltFileInfo{ + Src: "foo/bar/prebuilt_etc.rc", + Dir: "etc/subdir", + Filename: "init.rc", + Installable: true, + }, + }, + } + }), + ).RunTestWithBp(t, bp) + ctx := res.ModuleForTests("myetc", "android_arm64_armv8-a") + mod := ctx.Module() + entries := android.AndroidMkEntriesForTest(t, res.TestContext, mod)[0] + // verify androidmk entries + android.AssertStringDoesContain(t, "LOCAL_MODULE_PATH should contain", entries.EntryMap["LOCAL_MODULE_PATH"][0], "etc/subdir") + android.AssertStringEquals(t, "LOCAL_INSTALLED_MODULE_STEM is incorrect", "init.rc", entries.EntryMap["LOCAL_INSTALLED_MODULE_STEM"][0]) + // verify installation rules + install := ctx.Description("install") + android.AssertStringEquals(t, "Source location of prebuilt_etc installation", "out/soong/.intermediates/myetc/android_arm64_armv8-a/init.rc", install.Input.String()) + android.AssertStringEquals(t, "Target location of prebuilt_etc installation", "out/soong/target/product/test_device/system/etc/subdir/init.rc", install.Output.String()) +} diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 2197304a5..124827523 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -19,7 +19,10 @@ import ( "path/filepath" "android/soong/android" + "android/soong/bazel" + "github.com/google/blueprint" + "github.com/google/blueprint/proptools" ) func init() { @@ -54,6 +57,7 @@ type platformCompatConfigProperties struct { type platformCompatConfig struct { android.ModuleBase + android.BazelModuleBase properties platformCompatConfigProperties installDirPath android.InstallPath @@ -122,10 +126,29 @@ func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries { }} } +type bazelPlatformCompatConfigAttributes struct { + Src bazel.LabelAttribute +} + +func (p *platformCompatConfig) ConvertWithBp2build(ctx android.TopDownMutatorContext) { + props := bazel.BazelTargetModuleProperties{ + Rule_class: "platform_compat_config", + Bzl_load_location: "//build/bazel/rules/java:platform_compat_config.bzl", + } + attr := &bazelPlatformCompatConfigAttributes{ + Src: *bazel.MakeLabelAttribute( + android.BazelLabelForModuleSrcSingle(ctx, proptools.String(p.properties.Src)).Label), + } + ctx.CreateBazelTargetModule(props, android.CommonAttributes{ + Name: p.Name(), + }, attr) +} + func PlatformCompatConfigFactory() android.Module { module := &platformCompatConfig{} module.AddProperties(&module.properties) android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) + android.InitBazelModule(module) return module } diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh index db14bd442..c77b9030a 100755 --- a/tests/run_integration_tests.sh +++ b/tests/run_integration_tests.sh @@ -22,3 +22,6 @@ TEST_BAZEL=true extra_build_params=--bazel-mode-staging "$TOP/build/soong/tests/ "$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_cf_arm64_phone" "armv8-a" "cortex-a53" "$TOP/build/soong/tests/sbom_test.sh" + +"$TOP/build/bazel/ci/b_test.sh" + diff --git a/ui/build/config.go b/ui/build/config.go index bc0ab33d9..c991777f9 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -1124,6 +1124,9 @@ func (c *configImpl) NamedGlobFile(name string) string { } func (c *configImpl) UsedEnvFile(tag string) string { + if v, ok := c.environ.Get("TARGET_PRODUCT"); ok { + return shared.JoinPath(c.SoongOutDir(), usedEnvFile+"."+v+"."+tag) + } return shared.JoinPath(c.SoongOutDir(), usedEnvFile+"."+tag) } |