Add makefile_goal.

Only for boot images.

Test: add one makefile_goal
Bug: 158537840
Change-Id: I88a006a1c7bfbf79f10f5360aae27a9bc267e42d
This commit is contained in:
Yifan Hong
2020-07-27 12:59:58 -07:00
parent afdd267ff7
commit 696ed4d54c
4 changed files with 144 additions and 0 deletions

View File

@@ -326,6 +326,20 @@ var neverallowTests = []struct {
"module \"outside_art_libraries\": violates neverallow",
},
},
{
name: "disallowed makefile_goal",
fs: map[string][]byte{
"Android.bp": []byte(`
makefile_goal {
name: "foo",
product_out_path: "boot/trap.img"
}
`),
},
expectedErrors: []string{
"Only boot images may be imported as a makefile goal.",
},
},
}
func TestNeverallow(t *testing.T) {
@@ -350,6 +364,7 @@ func testNeverallow(config Config) (*TestContext, []error) {
ctx.RegisterModuleType("java_library", newMockJavaLibraryModule)
ctx.RegisterModuleType("java_library_host", newMockJavaLibraryModule)
ctx.RegisterModuleType("java_device_for_host", newMockJavaLibraryModule)
ctx.RegisterModuleType("makefile_goal", newMockMakefileGoalModule)
ctx.PostDepsMutators(RegisterNeverallowMutator)
ctx.Register(config)
@@ -438,3 +453,22 @@ func newMockJavaLibraryModule() Module {
func (p *mockJavaLibraryModule) GenerateAndroidBuildActions(ModuleContext) {
}
type mockMakefileGoalProperties struct {
Product_out_path *string
}
type mockMakefileGoalModule struct {
ModuleBase
properties mockMakefileGoalProperties
}
func newMockMakefileGoalModule() Module {
m := &mockMakefileGoalModule{}
m.AddProperties(&m.properties)
InitAndroidModule(m)
return m
}
func (p *mockMakefileGoalModule) GenerateAndroidBuildActions(ModuleContext) {
}