diff options
author | 2025-01-10 02:04:10 -0800 | |
---|---|---|
committer | 2025-01-10 13:07:09 +0000 | |
commit | 473f6be94715dbf33d19509b7523de1e03405314 (patch) | |
tree | 2ae87aeeb8e8a7086dcdeff1fa613edc94882029 | |
parent | a2c3bec8d2177c27a6e4cc9fc3454c35a3e53a31 (diff) |
Revert "Added EXTRA_ALLOWED_DEPS_TXT to allow arbitrary allowedlist text files that enforces min_sdk_version for apex dependencies to avoid regression"
This reverts commit 8609a5569c7d93efc983e7c5f091fbdd4f955567.
Reason for revert: Design change - not collecting dependencies of non-AOSP updatable APEX
Bug: 380222284
Bug: 383062486
Test: m nothing --no-skip-soong-tests
Change-Id: I4150848502fc1f172f88dc4f0d1e663ac5a8cfea
-rw-r--r-- | android/config.go | 4 | ||||
-rw-r--r-- | android/variable.go | 2 | ||||
-rw-r--r-- | apex/apex_singleton.go | 39 | ||||
-rw-r--r-- | apex/apex_test.go | 147 |
4 files changed, 14 insertions, 178 deletions
diff --git a/android/config.go b/android/config.go index 87aacd5cb..ec79a7dee 100644 --- a/android/config.go +++ b/android/config.go @@ -2286,10 +2286,6 @@ func (c *config) VendorPropFiles(ctx PathContext) Paths { return PathsForSource(ctx, c.productVariables.VendorPropFiles) } -func (c *config) ExtraAllowedDepsTxt() string { - return String(c.productVariables.ExtraAllowedDepsTxt) -} - func (c *config) EnableUffdGc() string { return String(c.productVariables.EnableUffdGc) } diff --git a/android/variable.go b/android/variable.go index 4b6182781..1de87961d 100644 --- a/android/variable.go +++ b/android/variable.go @@ -543,8 +543,6 @@ type ProductVariables struct { PartitionVarsForSoongMigrationOnlyDoNotUse PartitionVariables - ExtraAllowedDepsTxt *string `json:",omitempty"` - AdbKeys *string `json:",omitempty"` DeviceMatrixFile []string `json:",omitempty"` diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go index d46104e40..7b3acb509 100644 --- a/apex/apex_singleton.go +++ b/apex/apex_singleton.go @@ -18,7 +18,6 @@ package apex import ( "encoding/json" - "strings" "github.com/google/blueprint" @@ -59,9 +58,9 @@ var ( // Diff two given lists while ignoring comments in the allowed deps file. diffAllowedApexDepsInfoRule = pctx.AndroidStaticRule("diffAllowedApexDepsInfoRule", blueprint.RuleParams{ - Description: "Diff ${allowed_deps_list} and ${new_allowed_deps}", + Description: "Diff ${allowed_deps} and ${new_allowed_deps}", Command: ` - if grep -v -h '^#' ${allowed_deps_list} | sort -u -f| diff -B -u - ${new_allowed_deps}; then + if grep -v '^#' ${allowed_deps} | diff -B - ${new_allowed_deps}; then touch ${out}; else echo; @@ -85,15 +84,10 @@ var ( exit 1; fi; `, - }, "allowed_deps_list", "new_allowed_deps") + }, "allowed_deps", "new_allowed_deps") ) func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContext) { - allowedDepsSources := []android.OptionalPath{android.ExistentPathForSource(ctx, "packages/modules/common/build/allowed_deps.txt")} - extraAllowedDepsPath := ctx.Config().ExtraAllowedDepsTxt() - if extraAllowedDepsPath != "" { - allowedDepsSources = append(allowedDepsSources, android.ExistentPathForSource(ctx, extraAllowedDepsPath)) - } updatableFlatLists := android.Paths{} ctx.VisitAllModules(func(module android.Module) { if binaryInfo, ok := module.(android.ApexBundleDepsInfoIntf); ok { @@ -105,42 +99,37 @@ func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContex } } }) + + allowedDepsSource := android.ExistentPathForSource(ctx, "packages/modules/common/build/allowed_deps.txt") newAllowedDeps := android.PathForOutput(ctx, "apex", "depsinfo", "new-allowed-deps.txt") s.allowedApexDepsInfoCheckResult = android.PathForOutput(ctx, newAllowedDeps.Rel()+".check") - hasOneValidDepsPath := false - for _, allowedDepsSource := range allowedDepsSources { - if allowedDepsSource.Valid() { - hasOneValidDepsPath = true - updatableFlatLists = append(updatableFlatLists, allowedDepsSource.Path()) - } - } - allowedDepsStrList := make([]string, len(allowedDepsSources)) - for _, value := range allowedDepsSources { - allowedDepsStrList = append(allowedDepsStrList, value.String()) - } - allowedDepsListString := strings.Join(allowedDepsStrList, " ") - if !hasOneValidDepsPath { + + if !allowedDepsSource.Valid() { // Unbundled projects may not have packages/modules/common/ checked out; ignore those. ctx.Build(pctx, android.BuildParams{ Rule: android.Touch, Output: s.allowedApexDepsInfoCheckResult, }) } else { + allowedDeps := allowedDepsSource.Path() + ctx.Build(pctx, android.BuildParams{ Rule: generateApexDepsInfoFilesRule, - Inputs: updatableFlatLists, + Inputs: append(updatableFlatLists, allowedDeps), Output: newAllowedDeps, }) + ctx.Build(pctx, android.BuildParams{ Rule: diffAllowedApexDepsInfoRule, Input: newAllowedDeps, Output: s.allowedApexDepsInfoCheckResult, Args: map[string]string{ - "allowed_deps_list": allowedDepsListString, - "new_allowed_deps": newAllowedDeps.String(), + "allowed_deps": allowedDeps.String(), + "new_allowed_deps": newAllowedDeps.String(), }, }) } + ctx.Phony("apex-allowed-deps-check", s.allowedApexDepsInfoCheckResult) } diff --git a/apex/apex_test.go b/apex/apex_test.go index e1a958268..0472488c7 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -2197,153 +2197,6 @@ func TestTrackAllowedDeps(t *testing.T) { flatlist, "yourlib(minSdkVersion:29)") } -func TestTrackCustomAllowedDepsInvalidDefaultTxt(t *testing.T) { - t.Parallel() - ctx := testApex(t, ` - apex { - name: "myapex", - key: "myapex.key", - updatable: true, - native_shared_libs: [ - "mylib", - "yourlib", - ], - min_sdk_version: "29", - } - - apex { - name: "myapex2", - key: "myapex.key", - updatable: false, - native_shared_libs: ["yourlib"], - } - - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_library { - name: "mylib", - srcs: ["mylib.cpp"], - shared_libs: ["libbar"], - min_sdk_version: "29", - apex_available: ["myapex"], - } - - cc_library { - name: "libbar", - stubs: { versions: ["29", "30"] }, - } - - cc_library { - name: "yourlib", - srcs: ["mylib.cpp"], - min_sdk_version: "29", - apex_available: ["myapex", "myapex2", "//apex_available:platform"], - } - `, withFiles(android.MockFS{ - "packages/modules/common/build/custom_allowed_deps.txt": nil, - }), - android.FixtureModifyProductVariables( - func(variables android.FixtureProductVariables) { - variables.ExtraAllowedDepsTxt = proptools.StringPtr("packages/modules/common/build/custom_allowed_deps.txt") - }, - )) - - depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton") - inputs := depsinfo.Rule("generateApexDepsInfoFilesRule").BuildParams.Inputs.Strings() - android.AssertStringListContains(t, "updatable myapex should generate depsinfo file", inputs, - "out/soong/.intermediates/myapex/android_common_myapex/depsinfo/flatlist.txt") - android.AssertStringListDoesNotContain(t, "non-updatable myapex2 should not generate depsinfo file", inputs, - "out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt") - - myapex := ctx.ModuleForTests("myapex", "android_common_myapex") - flatlist := strings.Split(android.ContentFromFileRuleForTests(t, ctx, - myapex.Output("depsinfo/flatlist.txt")), "\n") - android.AssertStringListContains(t, "deps with stubs should be tracked in depsinfo as external dep", - flatlist, "libbar(minSdkVersion:(no version)) (external)") - android.AssertStringListDoesNotContain(t, "do not track if not available for platform", - flatlist, "mylib:(minSdkVersion:29)") - android.AssertStringListContains(t, "track platform-available lib", - flatlist, "yourlib(minSdkVersion:29)") -} - -func TestTrackCustomAllowedDepsWithDefaultTxt(t *testing.T) { - t.Parallel() - ctx := testApex(t, ` - apex { - name: "myapex", - key: "myapex.key", - updatable: true, - native_shared_libs: [ - "mylib", - "yourlib", - ], - min_sdk_version: "29", - } - - apex { - name: "myapex2", - key: "myapex.key", - updatable: false, - native_shared_libs: ["yourlib"], - } - - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_library { - name: "mylib", - srcs: ["mylib.cpp"], - shared_libs: ["libbar"], - min_sdk_version: "29", - apex_available: ["myapex"], - } - - cc_library { - name: "libbar", - stubs: { versions: ["29", "30"] }, - } - - cc_library { - name: "yourlib", - srcs: ["mylib.cpp"], - min_sdk_version: "29", - apex_available: ["myapex", "myapex2", "//apex_available:platform"], - } - `, withFiles(android.MockFS{ - "packages/modules/common/build/custom_allowed_deps.txt": nil, - "packages/modules/common/build/allowed_deps.txt": nil, - }), - android.FixtureModifyProductVariables( - func(variables android.FixtureProductVariables) { - variables.ExtraAllowedDepsTxt = proptools.StringPtr("packages/modules/common/build/custom_allowed_deps.txt") - }, - )) - - depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton") - inputs := depsinfo.Rule("generateApexDepsInfoFilesRule").BuildParams.Inputs.Strings() - android.AssertStringListContains(t, "updatable myapex should generate depsinfo file", inputs, - "out/soong/.intermediates/myapex/android_common_myapex/depsinfo/flatlist.txt") - android.AssertStringListDoesNotContain(t, "non-updatable myapex2 should not generate depsinfo file", inputs, - "out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt") - - myapex := ctx.ModuleForTests("myapex", "android_common_myapex") - flatlist := strings.Split(android.ContentFromFileRuleForTests(t, ctx, - myapex.Output("depsinfo/flatlist.txt")), "\n") - android.AssertStringListContains(t, "deps with stubs should be tracked in depsinfo as external dep", - flatlist, "libbar(minSdkVersion:(no version)) (external)") - android.AssertStringListDoesNotContain(t, "do not track if not available for platform", - flatlist, "mylib:(minSdkVersion:29)") - android.AssertStringListContains(t, "track platform-available lib", - flatlist, "yourlib(minSdkVersion:29)") -} - func TestTrackAllowedDeps_SkipWithoutAllowedDepsTxt(t *testing.T) { t.Parallel() ctx := testApex(t, ` |