Loading java/androidmk.go +1 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { if !hideFromMake { mainEntries = android.AndroidMkEntries{ Class: "JAVA_LIBRARIES", DistFile: android.OptionalPathForPath(library.distFile), OutputFile: android.OptionalPathForPath(library.outputFile), Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", ExtraEntries: []android.AndroidMkExtraEntriesFunc{ Loading java/androidmk_test.go +36 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package java import ( "reflect" "strings" "testing" "android/soong/android" Loading Loading @@ -133,3 +134,38 @@ func TestHostdexSpecificRequired(t *testing.T) { t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual) } } func TestDistWithTag(t *testing.T) { ctx, config := testJava(t, ` java_library { name: "foo_without_tag", srcs: ["a.java"], compile_dex: true, dist: { targets: ["hi"], }, } java_library { name: "foo_with_tag", srcs: ["a.java"], compile_dex: true, dist: { targets: ["hi"], tag: ".jar", }, } `) without_tag_entries := android.AndroidMkEntriesForTest(t, config, "", ctx.ModuleForTests("foo_without_tag", "android_common").Module()) with_tag_entries := android.AndroidMkEntriesForTest(t, config, "", ctx.ModuleForTests("foo_with_tag", "android_common").Module()) if len(without_tag_entries) != 2 || len(with_tag_entries) != 2 { t.Errorf("two mk entries per module expected, got %d and %d", len(without_tag_entries), len(with_tag_entries)) } if !with_tag_entries[0].DistFile.Valid() || !strings.Contains(with_tag_entries[0].DistFile.String(), "/javac/foo_with_tag.jar") { t.Errorf("expected classes.jar DistFile, got %v", with_tag_entries[0].DistFile) } if without_tag_entries[0].DistFile.Valid() { t.Errorf("did not expect explicit DistFile, got %v", without_tag_entries[0].DistFile) } } java/java.go +22 −1 Original line number Diff line number Diff line Loading @@ -421,6 +421,8 @@ type Module struct { // list of the xref extraction files kytheFiles android.Paths distFile android.Path } func (j *Module) OutputFiles(tag string) (android.Paths, error) { Loading Loading @@ -1778,9 +1780,18 @@ func (j *Module) IsInstallable() bool { // Java libraries (.jar file) // type LibraryProperties struct { Dist struct { // The tag of the output of this module that should be output. Tag *string `android:"arch_variant"` } `android:"arch_variant"` } type Library struct { Module libraryProperties LibraryProperties InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths) } Loading Loading @@ -1824,6 +1835,15 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile, extraInstallDeps...) } // Verify Dist.Tag is set to a supported output if j.libraryProperties.Dist.Tag != nil { distFiles, err := j.OutputFiles(*j.libraryProperties.Dist.Tag) if err != nil { ctx.PropertyErrorf("dist.tag", "%s", err.Error()) } j.distFile = distFiles[0] } } func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) { Loading Loading @@ -1944,7 +1964,8 @@ func LibraryFactory() android.Module { &module.Module.properties, &module.Module.deviceProperties, &module.Module.dexpreoptProperties, &module.Module.protoProperties) &module.Module.protoProperties, &module.libraryProperties) android.InitApexModule(module) android.InitSdkAwareModule(module) Loading Loading
java/androidmk.go +1 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { if !hideFromMake { mainEntries = android.AndroidMkEntries{ Class: "JAVA_LIBRARIES", DistFile: android.OptionalPathForPath(library.distFile), OutputFile: android.OptionalPathForPath(library.outputFile), Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", ExtraEntries: []android.AndroidMkExtraEntriesFunc{ Loading
java/androidmk_test.go +36 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package java import ( "reflect" "strings" "testing" "android/soong/android" Loading Loading @@ -133,3 +134,38 @@ func TestHostdexSpecificRequired(t *testing.T) { t.Errorf("Unexpected required modules - expected: %q, actual: %q", expected, actual) } } func TestDistWithTag(t *testing.T) { ctx, config := testJava(t, ` java_library { name: "foo_without_tag", srcs: ["a.java"], compile_dex: true, dist: { targets: ["hi"], }, } java_library { name: "foo_with_tag", srcs: ["a.java"], compile_dex: true, dist: { targets: ["hi"], tag: ".jar", }, } `) without_tag_entries := android.AndroidMkEntriesForTest(t, config, "", ctx.ModuleForTests("foo_without_tag", "android_common").Module()) with_tag_entries := android.AndroidMkEntriesForTest(t, config, "", ctx.ModuleForTests("foo_with_tag", "android_common").Module()) if len(without_tag_entries) != 2 || len(with_tag_entries) != 2 { t.Errorf("two mk entries per module expected, got %d and %d", len(without_tag_entries), len(with_tag_entries)) } if !with_tag_entries[0].DistFile.Valid() || !strings.Contains(with_tag_entries[0].DistFile.String(), "/javac/foo_with_tag.jar") { t.Errorf("expected classes.jar DistFile, got %v", with_tag_entries[0].DistFile) } if without_tag_entries[0].DistFile.Valid() { t.Errorf("did not expect explicit DistFile, got %v", without_tag_entries[0].DistFile) } }
java/java.go +22 −1 Original line number Diff line number Diff line Loading @@ -421,6 +421,8 @@ type Module struct { // list of the xref extraction files kytheFiles android.Paths distFile android.Path } func (j *Module) OutputFiles(tag string) (android.Paths, error) { Loading Loading @@ -1778,9 +1780,18 @@ func (j *Module) IsInstallable() bool { // Java libraries (.jar file) // type LibraryProperties struct { Dist struct { // The tag of the output of this module that should be output. Tag *string `android:"arch_variant"` } `android:"arch_variant"` } type Library struct { Module libraryProperties LibraryProperties InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths) } Loading Loading @@ -1824,6 +1835,15 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile, extraInstallDeps...) } // Verify Dist.Tag is set to a supported output if j.libraryProperties.Dist.Tag != nil { distFiles, err := j.OutputFiles(*j.libraryProperties.Dist.Tag) if err != nil { ctx.PropertyErrorf("dist.tag", "%s", err.Error()) } j.distFile = distFiles[0] } } func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) { Loading Loading @@ -1944,7 +1964,8 @@ func LibraryFactory() android.Module { &module.Module.properties, &module.Module.deviceProperties, &module.Module.dexpreoptProperties, &module.Module.protoProperties) &module.Module.protoProperties, &module.libraryProperties) android.InitApexModule(module) android.InitSdkAwareModule(module) Loading