Use BaseModuleName() + SubName as apexFile.moduleName

This change fixes this error:
```
TARGET module com.android.adbd.flattened requires non-existent TARGET
module: prebuilt_libclang_rt.ubsan_standalone-arm-android
```

apexFile.moduleName is used as Make dependency name, so it should use
m.BaseModuleName() instead of m.Name(), because soong may prepend
"prebuilt_" to or mutate the output of m.Name() in other ways.

android/androidmk.go emits Android.mk modules with
`LOCAL_MODULE := module.BaseModuleName() + <SubName>`, so replace
apexFile.moduleName with BaseModuleName() + <SubName> as much as
possible.

Bug: 7456955
Test: Add unit test in apex/apex_test.go
Test: lunch blueline_hwasan && SANITIZE_TARGET='hwaddress fuzzer' m nothing
Test: Verify out/soong/Android-blueline_hwasan.mk
Change-Id: If8537fc1bedbe6c3405de3662a5df210a073c43f
This commit is contained in:
Yo Chiang
2020-07-23 20:09:18 +08:00
parent 13aa44fc15
commit e812805e75
3 changed files with 94 additions and 38 deletions

View File

@@ -82,9 +82,9 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
var moduleName string
if linkToSystemLib {
moduleName = fi.moduleName
moduleName = fi.androidMkModuleName
} else {
moduleName = fi.moduleName + "." + apexBundleName + a.suffix
moduleName = fi.androidMkModuleName + "." + apexBundleName + a.suffix
}
if !android.InList(moduleName, moduleNames) {
@@ -250,9 +250,9 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
}
// m <module_name> will build <module_name>.<apex_name> as well.
if fi.moduleName != moduleName && a.primaryApexType {
fmt.Fprintln(w, ".PHONY: "+fi.moduleName)
fmt.Fprintln(w, fi.moduleName+": "+moduleName)
if fi.androidMkModuleName != moduleName && a.primaryApexType {
fmt.Fprintf(w, ".PHONY: %s\n", fi.androidMkModuleName)
fmt.Fprintf(w, "%s: %s\n", fi.androidMkModuleName, moduleName)
}
}
return moduleNames