Merge "Don't allow using framework and SDK at the same time."
This commit is contained in:
@@ -57,6 +57,7 @@ func init() {
|
|||||||
AddNeverAllowRules(createUncompressDexRules()...)
|
AddNeverAllowRules(createUncompressDexRules()...)
|
||||||
AddNeverAllowRules(createMakefileGoalRules()...)
|
AddNeverAllowRules(createMakefileGoalRules()...)
|
||||||
AddNeverAllowRules(createInitFirstStageRules()...)
|
AddNeverAllowRules(createInitFirstStageRules()...)
|
||||||
|
AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a NeverAllow rule to the set of rules to apply.
|
// 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) {
|
func neverallowMutator(ctx BottomUpMutatorContext) {
|
||||||
m, ok := ctx.Module().(Module)
|
m, ok := ctx.Module().(Module)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@@ -327,6 +327,21 @@ var neverallowTests = []struct {
|
|||||||
"Only boot images may be imported as a makefile goal.",
|
"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(
|
var prepareForNeverAllowTest = GroupFixturePreparers(
|
||||||
|
Reference in New Issue
Block a user