Migrate java/androidmk.go to new system #1

This change migrates some of AndroidMk()s in java/androidmk.go to
AndroidMkEntries(), mainly focusing on deduping test-related helper
funcs.

Test: Soong tests
Test: Built a system image
Test: Manual inspection of diffs
Change-Id: I7810085521600d9ea2df078837688ade41c04825
This commit is contained in:
Jaewoong Jung
2019-08-29 14:56:03 -07:00
parent f59007cf23
commit b0c127cfd7
5 changed files with 242 additions and 313 deletions

View File

@@ -177,32 +177,32 @@ func (r *robolectricTest) generateRoboSrcJar(ctx android.ModuleContext, outputFi
TransformResourcesToJar(ctx, outputFile, srcJarArgs, srcJarDeps)
}
func (r *robolectricTest) AndroidMk() android.AndroidMkData {
data := r.Library.AndroidMk()
func (r *robolectricTest) AndroidMkEntries() android.AndroidMkEntries {
entries := r.Library.AndroidMkEntries()
data.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
android.WriteAndroidMkData(w, data)
entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
if s := r.robolectricProperties.Test_options.Shards; s != nil && *s > 1 {
shards := shardTests(r.tests, int(*s))
for i, shard := range shards {
r.writeTestRunner(w, name, "Run"+name+strconv.Itoa(i), shard)
}
if s := r.robolectricProperties.Test_options.Shards; s != nil && *s > 1 {
shards := shardTests(r.tests, int(*s))
for i, shard := range shards {
r.writeTestRunner(w, name, "Run"+name+strconv.Itoa(i), shard)
// TODO: add rules to dist the outputs of the individual tests, or combine them together?
fmt.Fprintln(w, "")
fmt.Fprintln(w, ".PHONY:", "Run"+name)
fmt.Fprintln(w, "Run"+name, ": \\")
for i := range shards {
fmt.Fprintln(w, " ", "Run"+name+strconv.Itoa(i), "\\")
}
fmt.Fprintln(w, "")
} else {
r.writeTestRunner(w, name, "Run"+name, r.tests)
}
// TODO: add rules to dist the outputs of the individual tests, or combine them together?
fmt.Fprintln(w, "")
fmt.Fprintln(w, ".PHONY:", "Run"+name)
fmt.Fprintln(w, "Run"+name, ": \\")
for i := range shards {
fmt.Fprintln(w, " ", "Run"+name+strconv.Itoa(i), "\\")
}
fmt.Fprintln(w, "")
} else {
r.writeTestRunner(w, name, "Run"+name, r.tests)
}
},
}
return data
return entries
}
func (r *robolectricTest) writeTestRunner(w io.Writer, module, name string, tests []string) {