Loading apex/apex_singleton.go +5 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,11 @@ import ( ) func init() { android.RegisterSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory) registerApexDepsInfoComponents(android.InitRegistrationContext) } func registerApexDepsInfoComponents(ctx android.RegistrationContext) { ctx.RegisterSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory) } type apexDepsInfoSingleton struct { Loading apex/apex_test.go +87 −0 Original line number Diff line number Diff line Loading @@ -1980,6 +1980,93 @@ func TestApexMinSdkVersion_InVendorApex(t *testing.T) { android.AssertStringDoesContain(t, "cflags", cflags, "-target aarch64-linux-android29") } func TestTrackAllowedDeps(t *testing.T) { 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/allowed_deps.txt": nil, })) 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_image/depsinfo/flatlist.txt") android.AssertStringListDoesNotContain(t, "non-updatable myapex2 should not generate depsinfo file", inputs, "out/soong/.intermediates/myapex2/android_common_myapex2_image/depsinfo/flatlist.txt") myapex := ctx.ModuleForTests("myapex", "android_common_myapex_image") flatlist := strings.Split(myapex.Output("depsinfo/flatlist.txt").BuildParams.Args["content"], "\\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) { ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", updatable: true, min_sdk_version: "29", } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } `) depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton") if nil != depsinfo.MaybeRule("generateApexDepsInfoFilesRule").Output { t.Error("apex_depsinfo_singleton shouldn't run when allowed_deps.txt doesn't exist") } } func TestPlatformUsesLatestStubsFromApexes(t *testing.T) { ctx := testApex(t, ` apex { Loading apex/testing.go +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import "android/soong/android" var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers( android.FixtureRegisterWithContext(registerApexBuildComponents), android.FixtureRegisterWithContext(registerApexKeyBuildComponents), android.FixtureRegisterWithContext(registerApexDepsInfoComponents), // Additional files needed in tests that disallow non-existent source files. // This includes files that are needed by all, or at least most, instances of an apex module type. android.MockFS{ Loading Loading
apex/apex_singleton.go +5 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,11 @@ import ( ) func init() { android.RegisterSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory) registerApexDepsInfoComponents(android.InitRegistrationContext) } func registerApexDepsInfoComponents(ctx android.RegistrationContext) { ctx.RegisterSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory) } type apexDepsInfoSingleton struct { Loading
apex/apex_test.go +87 −0 Original line number Diff line number Diff line Loading @@ -1980,6 +1980,93 @@ func TestApexMinSdkVersion_InVendorApex(t *testing.T) { android.AssertStringDoesContain(t, "cflags", cflags, "-target aarch64-linux-android29") } func TestTrackAllowedDeps(t *testing.T) { 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/allowed_deps.txt": nil, })) 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_image/depsinfo/flatlist.txt") android.AssertStringListDoesNotContain(t, "non-updatable myapex2 should not generate depsinfo file", inputs, "out/soong/.intermediates/myapex2/android_common_myapex2_image/depsinfo/flatlist.txt") myapex := ctx.ModuleForTests("myapex", "android_common_myapex_image") flatlist := strings.Split(myapex.Output("depsinfo/flatlist.txt").BuildParams.Args["content"], "\\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) { ctx := testApex(t, ` apex { name: "myapex", key: "myapex.key", updatable: true, min_sdk_version: "29", } apex_key { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", } `) depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton") if nil != depsinfo.MaybeRule("generateApexDepsInfoFilesRule").Output { t.Error("apex_depsinfo_singleton shouldn't run when allowed_deps.txt doesn't exist") } } func TestPlatformUsesLatestStubsFromApexes(t *testing.T) { ctx := testApex(t, ` apex { Loading
apex/testing.go +1 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import "android/soong/android" var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers( android.FixtureRegisterWithContext(registerApexBuildComponents), android.FixtureRegisterWithContext(registerApexKeyBuildComponents), android.FixtureRegisterWithContext(registerApexDepsInfoComponents), // Additional files needed in tests that disallow non-existent source files. // This includes files that are needed by all, or at least most, instances of an apex module type. android.MockFS{ Loading