Move compat symlinks from makefile to soong

Two APEXes (i18n, art) requires compat symlinks and these symlinks are
created via ld.config.txt module's POST_INSTALL_CMDS.

  $ m installclean
  $ m ld.config.txt
  $ tree $OUT/system

.../system
├── bin
│   ├── dalvikvm -> /apex/com.android.art/bin/dalvikvm
│   └── dex2oat -> /apex/com.android.art/bin/dex2oat
├── etc
│   └── ld.config.txt
└── usr
    └── icu -> /apex/com.android.i18n/etc/icu

By the way, ld.config.txt is going to removed since linkerconfig
generates it on device.

So, we're moving symlink creation from ld.config.txt(rootdir/Android.mk)
to APEXes' POST_INSTALL_CMDS.

  $ m installclean
  $ m com.android.i18n
  $ tree $OUT/system

.../system
├── apex
│   └── com.android.i18n.apex
└── usr
    └── icu -> /apex/com.android.i18n/etc/icu

  $ m installclean
  $ m com.android.art
  $ tree $OUT/system

.../system
├── apex
│   └── com.android.art.debug.apex
├── bin
│   ├── dalvikvm -> /apex/com.android.art/bin/dalvikvm
│   └── dex2oat -> /apex/com.android.art/bin/dex2oat

Bug: 143192278
Test: m && boot (since these two apexes are bootstrap apexes)
Change-Id: Ib29ea9f9ac40e74f78cd530e7daef8c51292fd24
This commit is contained in:
Jooyung Han 2019-10-25 18:17:23 +09:00
parent e2bc36f12c
commit 4791cb507b
1 changed files with 22 additions and 7 deletions

View File

@ -108,9 +108,8 @@ func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) {
func makeCompatSymlinks(apexName string, ctx android.ModuleContext) (symlinks []string) {
// small helper to add symlink commands
addSymlink := func(target, dir, linkName string) {
outDir := filepath.Join("$(PRODUCT_OUT)", dir)
link := filepath.Join(outDir, linkName)
symlinks = append(symlinks, "mkdir -p "+outDir+" && rm -rf "+link+" && ln -sf "+target+" "+link)
link := filepath.Join(dir, linkName)
symlinks = append(symlinks, "mkdir -p "+dir+" && rm -rf "+link+" && ln -sf "+target+" "+link)
}
// TODO(b/142911355): [VNDK APEX] Fix hard-coded references to /system/lib/vndk
@ -121,12 +120,28 @@ func makeCompatSymlinks(apexName string, ctx android.ModuleContext) (symlinks []
// the name of vndk apex is formatted "com.android.vndk.v" + version
vndkVersion := strings.TrimPrefix(apexName, vndkApexNamePrefix)
if ctx.Config().Android64() {
addSymlink("/apex/"+apexName+"/lib64", "/system/lib64", "vndk-sp-"+vndkVersion)
addSymlink("/apex/"+apexName+"/lib64", "/system/lib64", "vndk-"+vndkVersion)
addSymlink("/apex/"+apexName+"/lib64", "$(TARGET_OUT)/lib64", "vndk-sp-"+vndkVersion)
addSymlink("/apex/"+apexName+"/lib64", "$(TARGET_OUT)/lib64", "vndk-"+vndkVersion)
}
if !ctx.Config().Android64() || ctx.DeviceConfig().DeviceSecondaryArch() != "" {
addSymlink("/apex/"+apexName+"/lib", "/system/lib", "vndk-sp-"+vndkVersion)
addSymlink("/apex/"+apexName+"/lib", "/system/lib", "vndk-"+vndkVersion)
addSymlink("/apex/"+apexName+"/lib", "$(TARGET_OUT)/lib", "vndk-sp-"+vndkVersion)
addSymlink("/apex/"+apexName+"/lib", "$(TARGET_OUT)/lib", "vndk-"+vndkVersion)
}
}
// http://b/121248172 - create a link from /system/usr/icu to
// /apex/com.android.i18n/etc/icu so that apps can find the ICU .dat file.
// A symlink can't overwrite a directory and the /system/usr/icu directory once
// existed so the required structure must be created whatever we find.
if apexName == "com.android.i18n" {
addSymlink("/apex/"+apexName+"/etc/icu", "$(TARGET_OUT)/usr", "icu")
}
// TODO(b/124106384): Clean up compat symlinks for ART binaries.
if strings.HasPrefix(apexName, "com.android.art.") {
artBinaries := []string{"dalvikvm", "dex2oat"}
for _, b := range artBinaries {
addSymlink("/apex/com.android.art/bin/"+b, "$(TARGET_OUT)/bin", b)
}
}
return