Loading android/module.go +14 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,8 @@ type Module interface { SkipInstall() IsSkipInstall() bool MakeUninstallable() ReplacedByPrebuilt() IsReplacedByPrebuilt() bool ExportedToMake() bool InitRc() Paths VintfFragments() Paths Loading Loading @@ -543,6 +545,9 @@ type commonProperties struct { SkipInstall bool `blueprint:"mutated"` // Whether the module has been replaced by a prebuilt ReplacedByPrebuilt bool `blueprint:"mutated"` // Disabled by mutators. If set to true, it overrides Enabled property. ForcedDisabled bool `blueprint:"mutated"` Loading Loading @@ -1068,6 +1073,15 @@ func (m *ModuleBase) MakeUninstallable() { m.SkipInstall() } func (m *ModuleBase) ReplacedByPrebuilt() { m.commonProperties.ReplacedByPrebuilt = true m.SkipInstall() } func (m *ModuleBase) IsReplacedByPrebuilt() bool { return m.commonProperties.ReplacedByPrebuilt } func (m *ModuleBase) ExportedToMake() bool { return m.commonProperties.NamespaceExportedToMake } Loading android/prebuilt.go +1 −1 Original line number Diff line number Diff line Loading @@ -253,7 +253,7 @@ func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) { p := m.(PrebuiltInterface).Prebuilt() if p.usePrebuilt(ctx, s) { p.properties.UsePrebuilt = true s.SkipInstall() s.ReplacedByPrebuilt() } }) } Loading java/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ bootstrap_go_package { "device_host_converter_test.go", "dexpreopt_test.go", "dexpreopt_bootjars_test.go", "hiddenapi_singleton_test.go", "java_test.go", "jdeps_test.go", "kotlin_test.go", Loading java/hiddenapi_singleton.go +1 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ func stubFlagsRule(ctx android.SingletonContext) { return } } bootDexJars = append(bootDexJars, jar) } } Loading java/hiddenapi_singleton_test.go 0 → 100644 +136 −0 Original line number Diff line number Diff line // Copyright 2020 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 java import ( "android/soong/android" "strings" "testing" ) func testConfigWithBootJars(bp string, bootJars []string) android.Config { config := testConfig(nil, bp, nil) config.TestProductVariables.BootJars = bootJars return config } func testContextWithHiddenAPI() *android.TestContext { ctx := testContext() ctx.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory) return ctx } func testHiddenAPI(t *testing.T, bp string, bootJars []string) (*android.TestContext, android.Config) { t.Helper() config := testConfigWithBootJars(bp, bootJars) ctx := testContextWithHiddenAPI() run(t, ctx, config) return ctx, config } func TestHiddenAPISingleton(t *testing.T) { ctx, _ := testHiddenAPI(t, ` java_library { name: "foo", srcs: ["a.java"], compile_dex: true, } `, []string{":foo"}) hiddenAPI := ctx.SingletonForTests("hiddenapi") hiddenapiRule := hiddenAPI.Rule("hiddenapi") want := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/aligned/foo.jar" if !strings.Contains(hiddenapiRule.RuleParams.Command, want) { t.Errorf("Expected %s in hiddenapi command, but it was not present: %s", want, hiddenapiRule.RuleParams.Command) } } func TestHiddenAPISingletonWithPrebuilt(t *testing.T) { ctx, _ := testHiddenAPI(t, ` java_import { name: "foo", jars: ["a.jar"], compile_dex: true, } `, []string{":foo"}) hiddenAPI := ctx.SingletonForTests("hiddenapi") hiddenapiRule := hiddenAPI.Rule("hiddenapi") want := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/dex/foo.jar" if !strings.Contains(hiddenapiRule.RuleParams.Command, want) { t.Errorf("Expected %s in hiddenapi command, but it was not present: %s", want, hiddenapiRule.RuleParams.Command) } } func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) { ctx, _ := testHiddenAPI(t, ` java_library { name: "foo", srcs: ["a.java"], compile_dex: true, } java_import { name: "foo", jars: ["a.jar"], compile_dex: true, prefer: false, } `, []string{":foo"}) hiddenAPI := ctx.SingletonForTests("hiddenapi") hiddenapiRule := hiddenAPI.Rule("hiddenapi") fromSourceJarArg := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/aligned/foo.jar" if !strings.Contains(hiddenapiRule.RuleParams.Command, fromSourceJarArg) { t.Errorf("Expected %s in hiddenapi command, but it was not present: %s", fromSourceJarArg, hiddenapiRule.RuleParams.Command) } prebuiltJarArg := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/dex/foo.jar" if strings.Contains(hiddenapiRule.RuleParams.Command, prebuiltJarArg) { t.Errorf("Did not expect %s in hiddenapi command, but it was present: %s", prebuiltJarArg, hiddenapiRule.RuleParams.Command) } } func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) { ctx, _ := testHiddenAPI(t, ` java_library { name: "foo", srcs: ["a.java"], compile_dex: true, } java_import { name: "foo", jars: ["a.jar"], compile_dex: true, prefer: true, } `, []string{":foo"}) hiddenAPI := ctx.SingletonForTests("hiddenapi") hiddenapiRule := hiddenAPI.Rule("hiddenapi") prebuiltJarArg := "--boot-dex=" + buildDir + "/.intermediates/prebuilt_foo/android_common/dex/foo.jar" if !strings.Contains(hiddenapiRule.RuleParams.Command, prebuiltJarArg) { t.Errorf("Expected %s in hiddenapi command, but it was not present: %s", prebuiltJarArg, hiddenapiRule.RuleParams.Command) } fromSourceJarArg := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/aligned/foo.jar" if strings.Contains(hiddenapiRule.RuleParams.Command, fromSourceJarArg) { t.Errorf("Did not expect %s in hiddenapi command, but it was present: %s", fromSourceJarArg, hiddenapiRule.RuleParams.Command) } } Loading
android/module.go +14 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,8 @@ type Module interface { SkipInstall() IsSkipInstall() bool MakeUninstallable() ReplacedByPrebuilt() IsReplacedByPrebuilt() bool ExportedToMake() bool InitRc() Paths VintfFragments() Paths Loading Loading @@ -543,6 +545,9 @@ type commonProperties struct { SkipInstall bool `blueprint:"mutated"` // Whether the module has been replaced by a prebuilt ReplacedByPrebuilt bool `blueprint:"mutated"` // Disabled by mutators. If set to true, it overrides Enabled property. ForcedDisabled bool `blueprint:"mutated"` Loading Loading @@ -1068,6 +1073,15 @@ func (m *ModuleBase) MakeUninstallable() { m.SkipInstall() } func (m *ModuleBase) ReplacedByPrebuilt() { m.commonProperties.ReplacedByPrebuilt = true m.SkipInstall() } func (m *ModuleBase) IsReplacedByPrebuilt() bool { return m.commonProperties.ReplacedByPrebuilt } func (m *ModuleBase) ExportedToMake() bool { return m.commonProperties.NamespaceExportedToMake } Loading
android/prebuilt.go +1 −1 Original line number Diff line number Diff line Loading @@ -253,7 +253,7 @@ func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) { p := m.(PrebuiltInterface).Prebuilt() if p.usePrebuilt(ctx, s) { p.properties.UsePrebuilt = true s.SkipInstall() s.ReplacedByPrebuilt() } }) } Loading
java/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ bootstrap_go_package { "device_host_converter_test.go", "dexpreopt_test.go", "dexpreopt_bootjars_test.go", "hiddenapi_singleton_test.go", "java_test.go", "jdeps_test.go", "kotlin_test.go", Loading
java/hiddenapi_singleton.go +1 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ func stubFlagsRule(ctx android.SingletonContext) { return } } bootDexJars = append(bootDexJars, jar) } } Loading
java/hiddenapi_singleton_test.go 0 → 100644 +136 −0 Original line number Diff line number Diff line // Copyright 2020 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 java import ( "android/soong/android" "strings" "testing" ) func testConfigWithBootJars(bp string, bootJars []string) android.Config { config := testConfig(nil, bp, nil) config.TestProductVariables.BootJars = bootJars return config } func testContextWithHiddenAPI() *android.TestContext { ctx := testContext() ctx.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory) return ctx } func testHiddenAPI(t *testing.T, bp string, bootJars []string) (*android.TestContext, android.Config) { t.Helper() config := testConfigWithBootJars(bp, bootJars) ctx := testContextWithHiddenAPI() run(t, ctx, config) return ctx, config } func TestHiddenAPISingleton(t *testing.T) { ctx, _ := testHiddenAPI(t, ` java_library { name: "foo", srcs: ["a.java"], compile_dex: true, } `, []string{":foo"}) hiddenAPI := ctx.SingletonForTests("hiddenapi") hiddenapiRule := hiddenAPI.Rule("hiddenapi") want := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/aligned/foo.jar" if !strings.Contains(hiddenapiRule.RuleParams.Command, want) { t.Errorf("Expected %s in hiddenapi command, but it was not present: %s", want, hiddenapiRule.RuleParams.Command) } } func TestHiddenAPISingletonWithPrebuilt(t *testing.T) { ctx, _ := testHiddenAPI(t, ` java_import { name: "foo", jars: ["a.jar"], compile_dex: true, } `, []string{":foo"}) hiddenAPI := ctx.SingletonForTests("hiddenapi") hiddenapiRule := hiddenAPI.Rule("hiddenapi") want := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/dex/foo.jar" if !strings.Contains(hiddenapiRule.RuleParams.Command, want) { t.Errorf("Expected %s in hiddenapi command, but it was not present: %s", want, hiddenapiRule.RuleParams.Command) } } func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) { ctx, _ := testHiddenAPI(t, ` java_library { name: "foo", srcs: ["a.java"], compile_dex: true, } java_import { name: "foo", jars: ["a.jar"], compile_dex: true, prefer: false, } `, []string{":foo"}) hiddenAPI := ctx.SingletonForTests("hiddenapi") hiddenapiRule := hiddenAPI.Rule("hiddenapi") fromSourceJarArg := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/aligned/foo.jar" if !strings.Contains(hiddenapiRule.RuleParams.Command, fromSourceJarArg) { t.Errorf("Expected %s in hiddenapi command, but it was not present: %s", fromSourceJarArg, hiddenapiRule.RuleParams.Command) } prebuiltJarArg := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/dex/foo.jar" if strings.Contains(hiddenapiRule.RuleParams.Command, prebuiltJarArg) { t.Errorf("Did not expect %s in hiddenapi command, but it was present: %s", prebuiltJarArg, hiddenapiRule.RuleParams.Command) } } func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) { ctx, _ := testHiddenAPI(t, ` java_library { name: "foo", srcs: ["a.java"], compile_dex: true, } java_import { name: "foo", jars: ["a.jar"], compile_dex: true, prefer: true, } `, []string{":foo"}) hiddenAPI := ctx.SingletonForTests("hiddenapi") hiddenapiRule := hiddenAPI.Rule("hiddenapi") prebuiltJarArg := "--boot-dex=" + buildDir + "/.intermediates/prebuilt_foo/android_common/dex/foo.jar" if !strings.Contains(hiddenapiRule.RuleParams.Command, prebuiltJarArg) { t.Errorf("Expected %s in hiddenapi command, but it was not present: %s", prebuiltJarArg, hiddenapiRule.RuleParams.Command) } fromSourceJarArg := "--boot-dex=" + buildDir + "/.intermediates/foo/android_common/aligned/foo.jar" if strings.Contains(hiddenapiRule.RuleParams.Command, fromSourceJarArg) { t.Errorf("Did not expect %s in hiddenapi command, but it was present: %s", fromSourceJarArg, hiddenapiRule.RuleParams.Command) } }