Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 053c6f43 authored by Jiyong Park's avatar Jiyong Park Committed by Automerger Merge Worker
Browse files

apex respects stem of java_library modules am: ed50ca8d

Change-Id: I428e8c4edfd06dbf0b712033bd50db74d41ce7d1
parents e717ba0e ed50ca8d
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -1179,6 +1179,7 @@ func (class apexFileClass) NameInMake() string {
// apexFile represents a file in an APEX bundle
type apexFile struct {
	builtFile  android.Path
	stem       string
	moduleName string
	installDir string
	class      apexFileClass
@@ -1218,9 +1219,17 @@ func (af *apexFile) Ok() bool {
	return af.builtFile != nil && af.builtFile.String() != ""
}

func (af *apexFile) apexRelativePath(path string) string {
	return filepath.Join(af.installDir, path)
}

// Path() returns path of this apex file relative to the APEX root
func (af *apexFile) Path() string {
	return filepath.Join(af.installDir, af.builtFile.Base())
	stem := af.builtFile.Base()
	if af.stem != "" {
		stem = af.stem
	}
	return af.apexRelativePath(stem)
}

// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
@@ -1660,11 +1669,17 @@ func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) ap
	return af
}

func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib java.Dependency, module android.Module) apexFile {
type javaDependency interface {
	java.Dependency
	Stem() string
}

func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, module android.Module) apexFile {
	dirInApex := "javalib"
	fileToCopy := lib.DexJar()
	af := newApexFile(ctx, fileToCopy, module.Name(), dirInApex, javaSharedLib, module)
	af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
	af.stem = lib.Stem() + ".jar"
	return af
}

+2 −1
Original line number Diff line number Diff line
@@ -386,6 +386,7 @@ func TestBasicApex(t *testing.T) {
		java_library {
			name: "myjar",
			srcs: ["foo/bar/MyClass.java"],
			stem: "myjar_stem",
			sdk_version: "none",
			system_modules: "none",
			static_libs: ["myotherjar"],
@@ -440,7 +441,7 @@ func TestBasicApex(t *testing.T) {
	// Ensure that both direct and indirect deps are copied into apex
	ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
	ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so")
	ensureContains(t, copyCmds, "image.apex/javalib/myjar.jar")
	ensureContains(t, copyCmds, "image.apex/javalib/myjar_stem.jar")
	// .. but not for java libs
	ensureNotContains(t, copyCmds, "image.apex/javalib/myotherjar.jar")
	ensureNotContains(t, copyCmds, "image.apex/javalib/msharedjar.jar")
+2 −2
Original line number Diff line number Diff line
@@ -1880,7 +1880,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
			extraInstallDeps = j.InstallMixin(ctx, j.outputFile)
		}
		j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
			ctx.ModuleName()+".jar", j.outputFile, extraInstallDeps...)
			j.Stem()+".jar", j.outputFile, extraInstallDeps...)
	}

	// Verify Dist.Tag is set to a supported output
@@ -2721,7 +2721,7 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	j.maybeStrippedDexJarFile = dexOutputFile

	ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
		ctx.ModuleName()+".jar", dexOutputFile)
		j.Stem()+".jar", dexOutputFile)
}

func (j *DexImport) DexJar() android.Path {