APEX respects relative_install_path

relative_install_path for cc_library is respected by APEX.

relative_install_path for cc_binary is not yet respected because doing
it will break the path to the dynamic linker in the runtime APEX.
That change should be done along with changes in init, bionic, etc.

Bug: 123721777
Test: m (apex_test.go amended)
Change-Id: I855f8eda0d4255d563861ac96d0d3e2c669e9a2a
This commit is contained in:
Jiyong Park
2019-02-01 12:03:59 +09:00
parent dcac078c91
commit b7c24df220
4 changed files with 48 additions and 2 deletions

View File

@@ -540,6 +540,7 @@ func getCopyManifestForNativeLibrary(cc *cc.Module, handleSpecialLibs bool) (fil
case "lib64": case "lib64":
dirInApex = "lib64" dirInApex = "lib64"
} }
dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
if !cc.Arch().Native { if !cc.Arch().Native {
dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String()) dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
} }
@@ -564,6 +565,8 @@ func getCopyManifestForNativeLibrary(cc *cc.Module, handleSpecialLibs bool) (fil
} }
func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) { func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
// TODO(b/123721777) respect relative_install_path also for binaries
// dirInApex = filepath.Join("bin", cc.RelativeInstallPath())
dirInApex = "bin" dirInApex = "bin"
fileToCopy = cc.OutputFile().Path() fileToCopy = cc.OutputFile().Path()
return return

View File

@@ -615,7 +615,10 @@ func TestFilesInSubDir(t *testing.T) {
apex { apex {
name: "myapex", name: "myapex",
key: "myapex.key", key: "myapex.key",
native_shared_libs: ["mylib"],
binaries: ["mybin"],
prebuilts: ["myetc"], prebuilts: ["myetc"],
compile_multilib: "both",
} }
apex_key { apex_key {
@@ -629,15 +632,43 @@ func TestFilesInSubDir(t *testing.T) {
src: "myprebuilt", src: "myprebuilt",
sub_dir: "foo/bar", sub_dir: "foo/bar",
} }
cc_library {
name: "mylib",
srcs: ["mylib.cpp"],
relative_install_path: "foo/bar",
system_shared_libs: [],
stl: "none",
}
cc_binary {
name: "mybin",
srcs: ["mylib.cpp"],
relative_install_path: "foo/bar",
system_shared_libs: [],
static_executable: true,
stl: "none",
}
`) `)
generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig") generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig")
dirs := strings.Split(generateFsRule.Args["exec_paths"], " ") dirs := strings.Split(generateFsRule.Args["exec_paths"], " ")
// Ensure that etc, etc/foo, and etc/foo/bar are all listed // Ensure that the subdirectories are all listed
ensureListContains(t, dirs, "etc") ensureListContains(t, dirs, "etc")
ensureListContains(t, dirs, "etc/foo") ensureListContains(t, dirs, "etc/foo")
ensureListContains(t, dirs, "etc/foo/bar") ensureListContains(t, dirs, "etc/foo/bar")
ensureListContains(t, dirs, "lib64")
ensureListContains(t, dirs, "lib64/foo")
ensureListContains(t, dirs, "lib64/foo/bar")
ensureListContains(t, dirs, "lib")
ensureListContains(t, dirs, "lib/foo")
ensureListContains(t, dirs, "lib/foo/bar")
// TODO(b/123721777) respect relative path for binaries
// ensureListContains(t, dirs, "bin")
// ensureListContains(t, dirs, "bin/foo")
// ensureListContains(t, dirs, "bin/foo/bar")
} }
func TestUseVendor(t *testing.T) { func TestUseVendor(t *testing.T) {

View File

@@ -315,6 +315,7 @@ type installer interface {
inData() bool inData() bool
inSanitizerDir() bool inSanitizerDir() bool
hostToolPath() android.OptionalPath hostToolPath() android.OptionalPath
relativeInstallPath() string
} }
type dependencyTag struct { type dependencyTag struct {
@@ -413,6 +414,13 @@ func (c *Module) UnstrippedOutputFile() android.Path {
return nil return nil
} }
func (c *Module) RelativeInstallPath() string {
if c.installer != nil {
return c.installer.relativeInstallPath()
}
return ""
}
func (c *Module) Init() android.Module { func (c *Module) Init() android.Module {
c.AddProperties(&c.Properties, &c.VendorProperties) c.AddProperties(&c.Properties, &c.VendorProperties)
if c.compiler != nil { if c.compiler != nil {

View File

@@ -73,7 +73,7 @@ func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath
dir = filepath.Join(dir, "vendor") dir = filepath.Join(dir, "vendor")
} }
return android.PathForModuleInstall(ctx, dir, installer.subDir, return android.PathForModuleInstall(ctx, dir, installer.subDir,
String(installer.Properties.Relative_install_path), installer.relative) installer.relativeInstallPath(), installer.relative)
} }
func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) { func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
@@ -91,3 +91,7 @@ func (installer *baseInstaller) inSanitizerDir() bool {
func (installer *baseInstaller) hostToolPath() android.OptionalPath { func (installer *baseInstaller) hostToolPath() android.OptionalPath {
return android.OptionalPath{} return android.OptionalPath{}
} }
func (installer *baseInstaller) relativeInstallPath() string {
return String(installer.Properties.Relative_install_path)
}