Touch up manifest if there's no source code.

The new package manager behavior requires packages without source code
to have an application element with hasCode attribute set to false in
their manifest. With this change, Soong can now automatically insert one
for codeless apps.

Test: app_test.go, manifest_fixer_test.py
Fixes: 124375490
Change-Id: Ied89a8d07c63805ab910859a4f7c45fc1c60bb73
This commit is contained in:
Jaewoong Jung
2019-05-30 15:51:14 -07:00
parent 06b2c69cfe
commit c27ab6678b
7 changed files with 156 additions and 9 deletions

View File

@@ -1319,3 +1319,73 @@ func TestUsesLibraries(t *testing.T) {
t.Errorf("wanted %q in %q", w, cmd)
}
}
func TestCodelessApp(t *testing.T) {
testCases := []struct {
name string
bp string
noCode bool
}{
{
name: "normal",
bp: `
android_app {
name: "foo",
srcs: ["a.java"],
}
`,
noCode: false,
},
{
name: "app without sources",
bp: `
android_app {
name: "foo",
}
`,
noCode: true,
},
{
name: "app with libraries",
bp: `
android_app {
name: "foo",
static_libs: ["lib"],
}
java_library {
name: "lib",
srcs: ["a.java"],
}
`,
noCode: false,
},
{
name: "app with sourceless libraries",
bp: `
android_app {
name: "foo",
static_libs: ["lib"],
}
java_library {
name: "lib",
}
`,
// TODO(jungjw): this should probably be true
noCode: false,
},
}
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
ctx := testApp(t, test.bp)
foo := ctx.ModuleForTests("foo", "android_common")
manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
if strings.Contains(manifestFixerArgs, "--has-no-code") != test.noCode {
t.Errorf("unexpected manifest_fixer args: %q", manifestFixerArgs)
}
})
}
}