diff options
author | 2023-12-07 12:38:40 -0800 | |
---|---|---|
committer | 2023-12-07 16:56:07 -0800 | |
commit | c6420766f0a5755bd9d1f3701d198e12231dbd67 (patch) | |
tree | da872f16a76b95b3aee60ce2c614a74187bba4fc | |
parent | 82eae7148477a47db1316e6cc3a4717cd2b73773 (diff) |
Remove bp2build from frameworks/base/api/
Bug: 315353489
Test: m blueprint_tests
Change-Id: I50d938017203ad12198d8a6373c9aef80a8535c6
-rw-r--r-- | api/Android.bp | 2 | ||||
-rw-r--r-- | api/api.go | 136 | ||||
-rw-r--r-- | api/api_test.go | 115 | ||||
-rw-r--r-- | api/go.mod | 2 | ||||
-rw-r--r-- | api/go.work | 2 |
5 files changed, 27 insertions, 230 deletions
diff --git a/api/Android.bp b/api/Android.bp index 68babc3660d9..179113f9859d 100644 --- a/api/Android.bp +++ b/api/Android.bp @@ -31,12 +31,10 @@ bootstrap_go_package { "blueprint", "soong", "soong-android", - "soong-bp2build", "soong-genrule", "soong-java", ], srcs: ["api.go"], - testSrcs: ["api_test.go"], pluginFor: ["soong_build"], } diff --git a/api/api.go b/api/api.go index 71b1e10d2f47..2668999c572e 100644 --- a/api/api.go +++ b/api/api.go @@ -22,7 +22,6 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" - "android/soong/bazel" "android/soong/genrule" "android/soong/java" ) @@ -65,7 +64,6 @@ type CombinedApisProperties struct { type CombinedApis struct { android.ModuleBase - android.BazelModuleBase properties CombinedApisProperties } @@ -115,20 +113,6 @@ type defaultsProps struct { Previous_api *string } -type Bazel_module struct { - Label *string - Bp2build_available *bool -} -type bazelProperties struct { - *Bazel_module -} - -var bp2buildNotAvailable = bazelProperties{ - &Bazel_module{ - Bp2build_available: proptools.BoolPtr(false), - }, -} - // Struct to pass parameters for the various merged [current|removed].txt file modules we create. type MergedTxtDefinition struct { // "current.txt" or "removed.txt" @@ -143,8 +127,6 @@ type MergedTxtDefinition struct { ModuleTag string // public, system, module-lib or system-server Scope string - // True if there is a bp2build definition for this module - Bp2buildDefined bool } func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) { @@ -178,20 +160,7 @@ func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) { }, } props.Visibility = []string{"//visibility:public"} - bazelProps := bazelProperties{ - &Bazel_module{ - Bp2build_available: proptools.BoolPtr(false), - }, - } - if txt.Bp2buildDefined { - moduleDir := ctx.ModuleDir() - if moduleDir == android.Bp2BuildTopLevel { - moduleDir = "" - } - label := fmt.Sprintf("//%s:%s", moduleDir, moduleName) - bazelProps.Label = &label - } - ctx.CreateModule(genrule.GenRuleFactory, &props, &bazelProps) + ctx.CreateModule(genrule.GenRuleFactory, &props) } func createMergedAnnotationsFilegroups(ctx android.LoadHookContext, modules, system_server_modules []string) { @@ -221,7 +190,7 @@ func createMergedAnnotationsFilegroups(ctx android.LoadHookContext, modules, sys props := fgProps{} props.Name = proptools.StringPtr(i.name) props.Srcs = createSrcs(i.modules, i.tag) - ctx.CreateModule(android.FileGroupFactory, &props, &bp2buildNotAvailable) + ctx.CreateModule(android.FileGroupFactory, &props) } } @@ -315,7 +284,7 @@ func createPublicStubsSourceFilegroup(ctx android.LoadHookContext, modules []str props.Name = proptools.StringPtr("all-modules-public-stubs-source") props.Srcs = createSrcs(modules, "{.public.stubs.source}") props.Visibility = []string{"//frameworks/base"} - ctx.CreateModule(android.FileGroupFactory, &props, &bp2buildNotAvailable) + ctx.CreateModule(android.FileGroupFactory, &props) } func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_classpath []string) { @@ -323,43 +292,38 @@ func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_ tagSuffix := []string{".api.txt}", ".removed-api.txt}"} distFilename := []string{"android.txt", "android-removed.txt"} - bp2BuildDefined := []bool{true, false} for i, f := range []string{"current.txt", "removed.txt"} { textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - DistFilename: distFilename[i], - BaseTxt: ":non-updatable-" + f, - Modules: bootclasspath, - ModuleTag: "{.public" + tagSuffix[i], - Scope: "public", - Bp2buildDefined: bp2BuildDefined[i], + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-" + f, + Modules: bootclasspath, + ModuleTag: "{.public" + tagSuffix[i], + Scope: "public", }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - DistFilename: distFilename[i], - BaseTxt: ":non-updatable-system-" + f, - Modules: bootclasspath, - ModuleTag: "{.system" + tagSuffix[i], - Scope: "system", - Bp2buildDefined: bp2BuildDefined[i], + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-system-" + f, + Modules: bootclasspath, + ModuleTag: "{.system" + tagSuffix[i], + Scope: "system", }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - DistFilename: distFilename[i], - BaseTxt: ":non-updatable-module-lib-" + f, - Modules: bootclasspath, - ModuleTag: "{.module-lib" + tagSuffix[i], - Scope: "module-lib", - Bp2buildDefined: bp2BuildDefined[i], + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-module-lib-" + f, + Modules: bootclasspath, + ModuleTag: "{.module-lib" + tagSuffix[i], + Scope: "module-lib", }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - DistFilename: distFilename[i], - BaseTxt: ":non-updatable-system-server-" + f, - Modules: system_server_classpath, - ModuleTag: "{.system-server" + tagSuffix[i], - Scope: "system-server", - Bp2buildDefined: bp2BuildDefined[i], + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-system-server-" + f, + Modules: system_server_classpath, + ModuleTag: "{.system-server" + tagSuffix[i], + Scope: "system-server", }) } for _, txt := range textFiles { @@ -446,55 +410,9 @@ func combinedApisModuleFactory() android.Module { module.AddProperties(&module.properties) android.InitAndroidModule(module) android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.createInternalModules(ctx) }) - android.InitBazelModule(module) return module } -type bazelCombinedApisAttributes struct { - Scope bazel.StringAttribute - Base bazel.LabelAttribute - Deps bazel.LabelListAttribute -} - -// combined_apis bp2build converter -func (a *CombinedApis) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { - basePrefix := "non-updatable" - scopeToSuffix := map[string]string{ - "public": "-current.txt", - "system": "-system-current.txt", - "module-lib": "-module-lib-current.txt", - "system-server": "-system-server-current.txt", - } - - for scopeName, suffix := range scopeToSuffix { - name := a.Name() + suffix - - var scope bazel.StringAttribute - scope.SetValue(scopeName) - - var base bazel.LabelAttribute - base.SetValue(android.BazelLabelForModuleDepSingle(ctx, basePrefix+suffix)) - - var deps bazel.LabelListAttribute - classpath := a.properties.Bootclasspath - if scopeName == "system-server" { - classpath = a.properties.System_server_classpath - } - deps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, classpath)) - - attrs := bazelCombinedApisAttributes{ - Scope: scope, - Base: base, - Deps: deps, - } - props := bazel.BazelTargetModuleProperties{ - Rule_class: "merged_txts", - Bzl_load_location: "//build/bazel/rules/java:merged_txts.bzl", - } - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, &attrs) - } -} - // Various utility methods below. // Creates an array of ":<m><tag>" for each m in <modules>. diff --git a/api/api_test.go b/api/api_test.go deleted file mode 100644 index 70f2162348ad..000000000000 --- a/api/api_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2023 The Android Open Source Project -// -// 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 api - -import ( - "testing" - - "android/soong/android" - "android/soong/bp2build" - "android/soong/java" -) - -func runCombinedApisTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2build.Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) { - t.Helper() - (&tc).ModuleTypeUnderTest = "combined_apis" - (&tc).ModuleTypeUnderTestFactory = combinedApisModuleFactory - bp2build.RunBp2BuildTestCase(t, registrationCtxFunc, tc) -} - -func runCombinedApisTestCase(t *testing.T, tc bp2build.Bp2buildTestCase) { - t.Helper() - runCombinedApisTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) { - ctx.RegisterModuleType("java_defaults", java.DefaultsFactory) - ctx.RegisterModuleType("java_sdk_library", java.SdkLibraryFactory) - ctx.RegisterModuleType("filegroup", android.FileGroupFactory) - }) -} - -func TestCombinedApisGeneral(t *testing.T) { - runCombinedApisTestCase(t, bp2build.Bp2buildTestCase{ - Description: "combined_apis, general case", - Blueprint: `combined_apis { - name: "foo", - bootclasspath: ["bcp"], - system_server_classpath: ["ssc"], -} - -java_sdk_library { - name: "bcp", - srcs: ["a.java", "b.java"], - shared_library: false, -} -java_sdk_library { - name: "ssc", - srcs: ["a.java", "b.java"], - shared_library: false, -} -filegroup { - name: "non-updatable-current.txt", - srcs: ["current.txt"], -} -filegroup { - name: "non-updatable-system-current.txt", - srcs: ["system-current.txt"], -} -filegroup { - name: "non-updatable-module-lib-current.txt", - srcs: ["system-removed.txt"], -} -filegroup { - name: "non-updatable-system-server-current.txt", - srcs: ["system-lint-baseline.txt"], -} -`, - Filesystem: map[string]string{ - "a/Android.bp": ` - java_defaults { - name: "android.jar_defaults", - } - `, - "api/current.txt": "", - "api/removed.txt": "", - "api/system-current.txt": "", - "api/system-removed.txt": "", - "api/test-current.txt": "", - "api/test-removed.txt": "", - }, - StubbedBuildDefinitions: []string{"bcp", "ssc", "non-updatable-current.txt", "non-updatable-system-current.txt", "non-updatable-module-lib-current.txt", "non-updatable-system-server-current.txt"}, - ExpectedHandcraftedModules: []string{"foo-current.txt", "foo-system-current.txt", "foo-module-lib-current.txt", "foo-system-server-current.txt"}, - ExpectedBazelTargets: []string{ - bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-current.txt", bp2build.AttrNameToString{ - "scope": `"public"`, - "base": `":non-updatable-current.txt"`, - "deps": `[":bcp"]`, - }), - bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-current.txt", bp2build.AttrNameToString{ - "scope": `"system"`, - "base": `":non-updatable-system-current.txt"`, - "deps": `[":bcp"]`, - }), - bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-module-lib-current.txt", bp2build.AttrNameToString{ - "scope": `"module-lib"`, - "base": `":non-updatable-module-lib-current.txt"`, - "deps": `[":bcp"]`, - }), - bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-server-current.txt", bp2build.AttrNameToString{ - "scope": `"system-server"`, - "base": `":non-updatable-system-server-current.txt"`, - "deps": `[":ssc"]`, - }), - }, - }) -} diff --git a/api/go.mod b/api/go.mod index f8bb1c01cd96..445a6f4a5ec6 100644 --- a/api/go.mod +++ b/api/go.mod @@ -6,7 +6,5 @@ require ( android/soong v0.0.0 github.com/google/blueprint v0.0.0 google.golang.org/protobuf v0.0.0 - prebuilts/bazel/common/proto/analysis_v2 v0.0.0 - prebuilts/bazel/common/proto/build v0.0.0 go.starlark.net v0.0.0 ) diff --git a/api/go.work b/api/go.work index aa2d2b1cb461..edd002e7efba 100644 --- a/api/go.work +++ b/api/go.work @@ -13,7 +13,5 @@ replace ( google.golang.org/protobuf v0.0.0 => ../../../external/golang-protobuf github.com/google/blueprint v0.0.0 => ../../../build/blueprint github.com/google/go-cmp v0.0.0 => ../../../external/go-cmp - prebuilts/bazel/common/proto/analysis_v2 v0.0.0 => ../../../prebuilts/bazel/common/proto/analysis_v2 - prebuilts/bazel/common/proto/build v0.0.0 => ../../../prebuilts/bazel/common/proto/build go.starlark.net v0.0.0 => ../../../external/starlark-go ) |