Merge "Don't allow using framework and SDK at the same time." am: 661edbb331 am: e03c336641

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2054168

Change-Id: I92aeb973677a3888b5b989515c1a4194c915929c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jiyong Park 2022-04-06 00:12:39 +00:00 committed by Automerger Merge Worker
commit 21fa6561c3
2 changed files with 25 additions and 0 deletions

View file

@ -57,6 +57,7 @@ func init() {
AddNeverAllowRules(createUncompressDexRules()...)
AddNeverAllowRules(createMakefileGoalRules()...)
AddNeverAllowRules(createInitFirstStageRules()...)
AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
}
// Add a NeverAllow rule to the set of rules to apply.
@ -228,6 +229,15 @@ func createInitFirstStageRules() []Rule {
}
}
func createProhibitFrameworkAccessRules() []Rule {
return []Rule{
NeverAllow().
With("libs", "framework").
WithoutMatcher("sdk_version", Regexp("(core_.*|^$)")).
Because("framework can't be used when building against SDK"),
}
}
func neverallowMutator(ctx BottomUpMutatorContext) {
m, ok := ctx.Module().(Module)
if !ok {

View file

@ -327,6 +327,21 @@ var neverallowTests = []struct {
"Only boot images may be imported as a makefile goal.",
},
},
// Tests for the rule prohibiting the use of framework
{
name: "prohibit framework",
fs: map[string][]byte{
"Android.bp": []byte(`
java_library {
name: "foo",
libs: ["framework"],
sdk_version: "current",
}`),
},
expectedErrors: []string{
"framework can't be used when building against SDK",
},
},
}
var prepareForNeverAllowTest = GroupFixturePreparers(