Merge "Use module name as the suffix for apex variant" am: 22b08b4af6
am: 113ce97ae2
Change-Id: Ia5215be674f6b88c17b409b3cb61832116ec496c
This commit is contained in:
@@ -42,7 +42,11 @@ func (a *apexBundle) AndroidMk() android.AndroidMkData {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string) []string {
|
func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, moduleDir string) []string {
|
||||||
|
// apexBundleName comes from the 'name' property; apexName comes from 'apex_name' property.
|
||||||
|
// An apex is installed to /system/apex/<apexBundleName> and is activated at /apex/<apexName>
|
||||||
|
// In many cases, the two names are the same, but could be different in general.
|
||||||
|
|
||||||
moduleNames := []string{}
|
moduleNames := []string{}
|
||||||
apexType := a.properties.ApexType
|
apexType := a.properties.ApexType
|
||||||
// To avoid creating duplicate build rules, run this function only when primaryApexType is true
|
// To avoid creating duplicate build rules, run this function only when primaryApexType is true
|
||||||
@@ -52,12 +56,21 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string)
|
|||||||
return moduleNames
|
return moduleNames
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// b/140136207. When there are overriding APEXes for a VNDK APEX, the symbols file for the overridden
|
||||||
|
// APEX and the overriding APEX will have the same installation paths at /apex/com.android.vndk.v<ver>
|
||||||
|
// as their apexName will be the same. To avoid the path conflicts, skip installing the symbol files
|
||||||
|
// for the overriding VNDK APEXes.
|
||||||
|
symbolFilesNotNeeded := a.vndkApex && len(a.overridableProperties.Overrides) > 0
|
||||||
|
if symbolFilesNotNeeded && apexType != flattenedApex {
|
||||||
|
return moduleNames
|
||||||
|
}
|
||||||
|
|
||||||
var postInstallCommands []string
|
var postInstallCommands []string
|
||||||
for _, fi := range a.filesInfo {
|
for _, fi := range a.filesInfo {
|
||||||
if a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform() {
|
if a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform() {
|
||||||
// TODO(jiyong): pathOnDevice should come from fi.module, not being calculated here
|
// TODO(jiyong): pathOnDevice should come from fi.module, not being calculated here
|
||||||
linkTarget := filepath.Join("/system", fi.Path())
|
linkTarget := filepath.Join("/system", fi.Path())
|
||||||
linkPath := filepath.Join(a.installDir.ToMakePath().String(), apexName, fi.Path())
|
linkPath := filepath.Join(a.installDir.ToMakePath().String(), apexBundleName, fi.Path())
|
||||||
mkdirCmd := "mkdir -p " + filepath.Dir(linkPath)
|
mkdirCmd := "mkdir -p " + filepath.Dir(linkPath)
|
||||||
linkCmd := "ln -sfn " + linkTarget + " " + linkPath
|
linkCmd := "ln -sfn " + linkTarget + " " + linkPath
|
||||||
postInstallCommands = append(postInstallCommands, mkdirCmd, linkCmd)
|
postInstallCommands = append(postInstallCommands, mkdirCmd, linkCmd)
|
||||||
@@ -75,7 +88,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string)
|
|||||||
if linkToSystemLib {
|
if linkToSystemLib {
|
||||||
moduleName = fi.moduleName
|
moduleName = fi.moduleName
|
||||||
} else {
|
} else {
|
||||||
moduleName = fi.moduleName + "." + apexName + a.suffix
|
moduleName = fi.moduleName + "." + apexBundleName + a.suffix
|
||||||
}
|
}
|
||||||
|
|
||||||
if !android.InList(moduleName, moduleNames) {
|
if !android.InList(moduleName, moduleNames) {
|
||||||
@@ -99,8 +112,8 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string)
|
|||||||
if apexType == flattenedApex {
|
if apexType == flattenedApex {
|
||||||
// /system/apex/<name>/{lib|framework|...}
|
// /system/apex/<name>/{lib|framework|...}
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join(a.installDir.ToMakePath().String(),
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join(a.installDir.ToMakePath().String(),
|
||||||
apexName, fi.installDir))
|
apexBundleName, fi.installDir))
|
||||||
if a.primaryApexType {
|
if a.primaryApexType && !symbolFilesNotNeeded {
|
||||||
fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated)
|
fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated)
|
||||||
}
|
}
|
||||||
if len(fi.symlinks) > 0 {
|
if len(fi.symlinks) > 0 {
|
||||||
@@ -236,7 +249,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
|
|||||||
apexType := a.properties.ApexType
|
apexType := a.properties.ApexType
|
||||||
if a.installable() {
|
if a.installable() {
|
||||||
apexName := proptools.StringDefault(a.properties.Apex_name, name)
|
apexName := proptools.StringDefault(a.properties.Apex_name, name)
|
||||||
moduleNames = a.androidMkForFiles(w, apexName, moduleDir)
|
moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if apexType == flattenedApex {
|
if apexType == flattenedApex {
|
||||||
|
@@ -2210,11 +2210,12 @@ func TestDependenciesInApexManifest(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestApexName(t *testing.T) {
|
func TestApexName(t *testing.T) {
|
||||||
ctx, _ := testApex(t, `
|
ctx, config := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
name: "myapex",
|
name: "myapex",
|
||||||
key: "myapex.key",
|
key: "myapex.key",
|
||||||
apex_name: "com.android.myapex",
|
apex_name: "com.android.myapex",
|
||||||
|
native_shared_libs: ["mylib"],
|
||||||
}
|
}
|
||||||
|
|
||||||
apex_key {
|
apex_key {
|
||||||
@@ -2222,6 +2223,17 @@ func TestApexName(t *testing.T) {
|
|||||||
public_key: "testkey.avbpubkey",
|
public_key: "testkey.avbpubkey",
|
||||||
private_key: "testkey.pem",
|
private_key: "testkey.pem",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "mylib",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
apex_available: [
|
||||||
|
"//apex_available:platform",
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
|
module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
|
||||||
@@ -2229,6 +2241,16 @@ func TestApexName(t *testing.T) {
|
|||||||
ensureContains(t, apexManifestRule.Args["opt"], "-v name com.android.myapex")
|
ensureContains(t, apexManifestRule.Args["opt"], "-v name com.android.myapex")
|
||||||
apexRule := module.Rule("apexRule")
|
apexRule := module.Rule("apexRule")
|
||||||
ensureContains(t, apexRule.Args["opt_flags"], "--do_not_check_keyname")
|
ensureContains(t, apexRule.Args["opt_flags"], "--do_not_check_keyname")
|
||||||
|
|
||||||
|
apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
|
||||||
|
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
|
||||||
|
name := apexBundle.BaseModuleName()
|
||||||
|
prefix := "TARGET_"
|
||||||
|
var builder strings.Builder
|
||||||
|
data.Custom(&builder, name, prefix, "", data)
|
||||||
|
androidMk := builder.String()
|
||||||
|
ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
|
||||||
|
ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNonTestApex(t *testing.T) {
|
func TestNonTestApex(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user