2019-11-18 03:16:27 +01:00
|
|
|
// Copyright (C) 2019 The Android Open Source Project
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package apex
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
"android/soong/cc"
|
2020-03-26 22:01:48 +01:00
|
|
|
"android/soong/java"
|
2023-02-02 03:33:39 +01:00
|
|
|
"android/soong/rust"
|
2023-02-08 11:14:01 +01:00
|
|
|
|
|
|
|
"github.com/google/blueprint/proptools"
|
2019-11-18 03:16:27 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (a *apexBundle) AndroidMk() android.AndroidMkData {
|
|
|
|
if a.properties.HideFromMake {
|
|
|
|
return android.AndroidMkData{
|
|
|
|
Disabled: true,
|
|
|
|
}
|
|
|
|
}
|
2020-06-24 16:26:26 +02:00
|
|
|
return a.androidMkForType()
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
|
|
|
|
2020-11-19 15:00:52 +01:00
|
|
|
// nameInMake converts apexFileClass into the corresponding class name in Make.
|
|
|
|
func (class apexFileClass) nameInMake() string {
|
|
|
|
switch class {
|
|
|
|
case etc:
|
|
|
|
return "ETC"
|
|
|
|
case nativeSharedLib:
|
|
|
|
return "SHARED_LIBRARIES"
|
|
|
|
case nativeExecutable, shBinary, pyBinary, goBinary:
|
|
|
|
return "EXECUTABLES"
|
|
|
|
case javaSharedLib:
|
|
|
|
return "JAVA_LIBRARIES"
|
|
|
|
case nativeTest:
|
|
|
|
return "NATIVE_TESTS"
|
|
|
|
case app, appSet:
|
|
|
|
// b/142537672 Why isn't this APP? We want to have full control over
|
|
|
|
// the paths and file names of the apk file under the flattend APEX.
|
|
|
|
// If this is set to APP, then the paths and file names are modified
|
|
|
|
// by the Make build system. For example, it is installed to
|
|
|
|
// /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
|
|
|
|
// /system/apex/<apexname>/app/<Appname> because the build system automatically
|
|
|
|
// appends module name (which is <apexname>.<Appname> to the path.
|
|
|
|
return "ETC"
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown class %d", class))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-07 04:34:31 +01:00
|
|
|
// Return the full module name for a dependency module, which appends the apex module name unless re-using a system lib.
|
|
|
|
func (a *apexBundle) fullModuleName(apexBundleName string, fi *apexFile) string {
|
|
|
|
linkToSystemLib := a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform()
|
|
|
|
|
|
|
|
if linkToSystemLib {
|
|
|
|
return fi.androidMkModuleName
|
|
|
|
}
|
|
|
|
return fi.androidMkModuleName + "." + apexBundleName + a.suffix
|
|
|
|
}
|
|
|
|
|
2023-02-08 11:14:01 +01:00
|
|
|
func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, moduleDir string,
|
2020-09-11 10:19:20 +02:00
|
|
|
apexAndroidMkData android.AndroidMkData) []string {
|
|
|
|
|
2023-02-08 11:14:01 +01:00
|
|
|
// apexBundleName comes from the 'name' property; apexName comes from 'apex_name' property.
|
2020-02-05 09:19:28 +01:00
|
|
|
// 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.
|
|
|
|
|
2019-11-18 03:16:27 +01:00
|
|
|
moduleNames := []string{}
|
|
|
|
apexType := a.properties.ApexType
|
|
|
|
// To avoid creating duplicate build rules, run this function only when primaryApexType is true
|
|
|
|
// to install symbol files in $(PRODUCT_OUT}/apex.
|
|
|
|
// And if apexType is flattened, run this function to install files in $(PRODUCT_OUT}/system/apex.
|
|
|
|
if !a.primaryApexType && apexType != flattenedApex {
|
|
|
|
return moduleNames
|
|
|
|
}
|
|
|
|
|
2023-02-08 11:14:01 +01:00
|
|
|
// b/162366062. Prevent GKI APEXes to emit make rules to avoid conflicts.
|
|
|
|
if strings.HasPrefix(apexName, "com.android.gki.") && apexType != flattenedApex {
|
|
|
|
return moduleNames
|
|
|
|
}
|
|
|
|
|
2020-05-28 00:15:11 +02:00
|
|
|
seenDataOutPaths := make(map[string]bool)
|
|
|
|
|
2019-11-18 03:16:27 +01:00
|
|
|
for _, fi := range a.filesInfo {
|
2020-11-19 15:00:52 +01:00
|
|
|
linkToSystemLib := a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform()
|
2020-01-14 01:22:18 +01:00
|
|
|
|
2021-01-07 04:34:31 +01:00
|
|
|
moduleName := a.fullModuleName(apexBundleName, &fi)
|
2020-01-14 01:22:18 +01:00
|
|
|
|
2021-01-20 12:33:11 +01:00
|
|
|
// This name will be added to LOCAL_REQUIRED_MODULES of the APEX. We need to be
|
|
|
|
// arch-specific otherwise we will end up installing both ABIs even when only
|
|
|
|
// either of the ABI is requested.
|
|
|
|
aName := moduleName
|
|
|
|
switch fi.multilib {
|
|
|
|
case "lib32":
|
|
|
|
aName = aName + ":32"
|
|
|
|
case "lib64":
|
|
|
|
aName = aName + ":64"
|
|
|
|
}
|
|
|
|
if !android.InList(aName, moduleNames) {
|
|
|
|
moduleNames = append(moduleNames, aName)
|
2020-01-14 01:22:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if linkToSystemLib {
|
|
|
|
// No need to copy the file since it's linked to the system file
|
|
|
|
continue
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
|
|
|
|
2022-12-01 19:49:23 +01:00
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle.files")
|
2019-12-13 05:28:36 +01:00
|
|
|
if fi.moduleDir != "" {
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", fi.moduleDir)
|
|
|
|
} else {
|
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
}
|
2020-01-14 01:22:18 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", moduleName)
|
2020-06-30 12:51:53 +02:00
|
|
|
if fi.module != nil && fi.module.Owner() != "" {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", fi.module.Owner())
|
|
|
|
}
|
2023-02-08 11:14:01 +01:00
|
|
|
// /apex/<apex_name>/{lib|framework|...}
|
|
|
|
pathWhenActivated := filepath.Join("$(PRODUCT_OUT)", "apex", apexName, fi.installDir)
|
2020-07-06 23:15:24 +02:00
|
|
|
var modulePath string
|
2019-11-18 03:16:27 +01:00
|
|
|
if apexType == flattenedApex {
|
2023-02-08 11:14:01 +01:00
|
|
|
// /system/apex/<name>/{lib|framework|...}
|
2021-11-12 03:59:15 +01:00
|
|
|
modulePath = filepath.Join(a.installDir.String(), apexBundleName, fi.installDir)
|
2020-05-28 00:15:11 +02:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", modulePath)
|
2023-02-06 10:29:08 +01:00
|
|
|
if a.primaryApexType {
|
2023-02-08 11:14:01 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated)
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, "LOCAL_MODULE_SYMLINKS", fi.symlinks)
|
2020-07-09 23:12:52 +02:00
|
|
|
newDataPaths := []android.DataPath{}
|
2020-05-28 00:15:11 +02:00
|
|
|
for _, path := range fi.dataPaths {
|
2020-07-09 23:12:52 +02:00
|
|
|
dataOutPath := modulePath + ":" + path.SrcPath.Rel()
|
2020-05-28 00:15:11 +02:00
|
|
|
if ok := seenDataOutPaths[dataOutPath]; !ok {
|
|
|
|
newDataPaths = append(newDataPaths, path)
|
|
|
|
seenDataOutPaths[dataOutPath] = true
|
|
|
|
}
|
|
|
|
}
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, "LOCAL_TEST_DATA", android.AndroidMkDataPaths(newDataPaths))
|
2019-11-18 03:16:27 +01:00
|
|
|
} else {
|
2023-02-08 11:14:01 +01:00
|
|
|
modulePath = pathWhenActivated
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", pathWhenActivated)
|
2020-01-28 12:05:29 +01:00
|
|
|
|
|
|
|
// For non-flattend APEXes, the merged notice file is attached to the APEX itself.
|
|
|
|
// We don't need to have notice file for the individual modules in it. Otherwise,
|
|
|
|
// we will have duplicated notice entries.
|
|
|
|
fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
2021-11-04 20:01:18 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_INSTALLED_MODULE :=", filepath.Join(modulePath, fi.stem()))
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_INSTALL_PAIRS :=", fi.builtFile.String()+":"+filepath.Join(modulePath, fi.stem()))
|
2019-11-18 03:16:27 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
|
2020-11-19 15:00:52 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.nameInMake())
|
2019-11-18 03:16:27 +01:00
|
|
|
if fi.module != nil {
|
|
|
|
archStr := fi.module.Target().Arch.ArchType.String()
|
|
|
|
host := false
|
|
|
|
switch fi.module.Target().Os.Class {
|
|
|
|
case android.Host:
|
2020-09-14 12:43:17 +02:00
|
|
|
if fi.module.Target().HostCross {
|
|
|
|
if fi.module.Target().Arch.ArchType != android.Common {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if fi.module.Target().Arch.ArchType != android.Common {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
|
|
|
|
}
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
|
|
|
host = true
|
|
|
|
case android.Device:
|
|
|
|
if fi.module.Target().Arch.ArchType != android.Common {
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if host {
|
|
|
|
makeOs := fi.module.Target().Os.String()
|
2021-08-16 23:46:46 +02:00
|
|
|
if fi.module.Target().Os == android.Linux || fi.module.Target().Os == android.LinuxBionic || fi.module.Target().Os == android.LinuxMusl {
|
2019-11-18 03:16:27 +01:00
|
|
|
makeOs = "linux"
|
|
|
|
}
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
|
|
|
|
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
|
|
|
|
}
|
|
|
|
}
|
2020-01-08 05:35:43 +01:00
|
|
|
if fi.jacocoReportClassesFile != nil {
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", fi.jacocoReportClassesFile.String())
|
|
|
|
}
|
2020-05-28 01:36:07 +02:00
|
|
|
switch fi.class {
|
|
|
|
case javaSharedLib:
|
2019-11-18 03:16:27 +01:00
|
|
|
// soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
|
|
|
|
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
|
|
|
|
// we will have foo.jar.jar
|
2020-11-19 15:00:52 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.stem(), ".jar"))
|
2020-06-17 17:59:43 +02:00
|
|
|
if javaModule, ok := fi.module.(java.ApexDependency); ok {
|
2020-06-10 17:35:03 +02:00
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
|
|
|
|
} else {
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", fi.builtFile.String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", fi.builtFile.String())
|
|
|
|
}
|
2019-11-18 03:16:27 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
|
2020-05-28 01:36:07 +02:00
|
|
|
case app:
|
2020-01-28 23:00:53 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", fi.certificate.AndroidMkString())
|
2020-01-08 05:35:43 +01:00
|
|
|
// soong_app_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .apk Therefore
|
|
|
|
// we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
|
|
|
|
// we will have foo.apk.apk
|
2020-11-19 15:00:52 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.stem(), ".apk"))
|
2020-07-06 23:15:24 +02:00
|
|
|
if app, ok := fi.module.(*java.AndroidApp); ok {
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.JniCoverageOutputs().Strings())
|
2020-07-06 23:15:24 +02:00
|
|
|
if jniLibSymbols := app.JNISymbolsInstalls(modulePath); len(jniLibSymbols) > 0 {
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_SYMBOLS :=", jniLibSymbols.String())
|
|
|
|
}
|
2020-03-26 22:01:48 +01:00
|
|
|
}
|
2020-01-08 05:35:43 +01:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_app_prebuilt.mk")
|
2020-05-28 01:36:07 +02:00
|
|
|
case appSet:
|
|
|
|
as, ok := fi.module.(*java.AndroidAppSet)
|
|
|
|
if !ok {
|
|
|
|
panic(fmt.Sprintf("Expected %s to be AndroidAppSet", fi.module))
|
|
|
|
}
|
2021-11-12 21:19:42 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_APK_SET_INSTALL_FILE :=", as.PackedAdditionalOutputs().String())
|
2020-07-10 04:05:35 +02:00
|
|
|
fmt.Fprintln(w, "LOCAL_APKCERTS_FILE :=", as.APKCertsFile().String())
|
2020-05-28 01:36:07 +02:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_android_app_set.mk")
|
|
|
|
case nativeSharedLib, nativeExecutable, nativeTest:
|
2020-11-19 15:00:52 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.stem())
|
2020-05-28 01:36:07 +02:00
|
|
|
if ccMod, ok := fi.module.(*cc.Module); ok {
|
|
|
|
if ccMod.UnstrippedOutputFile() != nil {
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", ccMod.UnstrippedOutputFile().String())
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
2020-05-28 01:36:07 +02:00
|
|
|
ccMod.AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
|
|
|
|
if ccMod.CoverageOutputFile().Valid() {
|
|
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", ccMod.CoverageOutputFile().String())
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
2023-02-02 03:33:39 +01:00
|
|
|
} else if rustMod, ok := fi.module.(*rust.Module); ok {
|
|
|
|
if rustMod.UnstrippedOutputFile() != nil {
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", rustMod.UnstrippedOutputFile().String())
|
|
|
|
}
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
2021-11-12 19:27:58 +01:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk")
|
2020-05-28 01:36:07 +02:00
|
|
|
default:
|
2020-11-19 15:00:52 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.stem())
|
2020-01-28 08:51:34 +01:00
|
|
|
if fi.builtFile == a.manifestPbOut && apexType == flattenedApex {
|
2020-01-23 18:02:45 +01:00
|
|
|
if a.primaryApexType {
|
2020-09-11 10:19:20 +02:00
|
|
|
// To install companion files (init_rc, vintf_fragments)
|
|
|
|
// Copy some common properties of apexBundle to apex_manifest
|
|
|
|
commonProperties := []string{
|
2021-04-16 22:41:59 +02:00
|
|
|
"LOCAL_FULL_INIT_RC", "LOCAL_FULL_VINTF_FRAGMENTS",
|
2020-09-11 10:19:20 +02:00
|
|
|
}
|
|
|
|
for _, name := range commonProperties {
|
|
|
|
if value, ok := apexAndroidMkData.Entries.EntryMap[name]; ok {
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, name, value)
|
2020-09-11 10:19:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-23 18:02:45 +01:00
|
|
|
// Make apex_manifest.pb module for this APEX to override all other
|
|
|
|
// modules in the APEXes being overridden by this APEX
|
|
|
|
var patterns []string
|
|
|
|
for _, o := range a.overridableProperties.Overrides {
|
|
|
|
patterns = append(patterns, "%."+o+a.suffix)
|
|
|
|
}
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, "LOCAL_OVERRIDES_MODULES", patterns)
|
2020-01-09 09:43:39 +01:00
|
|
|
}
|
2020-09-23 12:15:55 +02:00
|
|
|
|
|
|
|
// File_contexts of flattened APEXes should be merged into file_contexts.bin
|
|
|
|
fmt.Fprintln(w, "LOCAL_FILE_CONTEXTS :=", a.fileContexts)
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
|
|
|
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
|
|
|
|
}
|
2020-02-11 01:36:25 +01:00
|
|
|
|
|
|
|
// m <module_name> will build <module_name>.<apex_name> as well.
|
2020-07-23 14:09:18 +02:00
|
|
|
if fi.androidMkModuleName != moduleName && a.primaryApexType {
|
|
|
|
fmt.Fprintf(w, ".PHONY: %s\n", fi.androidMkModuleName)
|
|
|
|
fmt.Fprintf(w, "%s: %s\n", fi.androidMkModuleName, moduleName)
|
2020-02-11 01:36:25 +01:00
|
|
|
}
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
|
|
|
return moduleNames
|
|
|
|
}
|
|
|
|
|
2022-02-24 16:06:05 +01:00
|
|
|
func (a *apexBundle) writeRequiredModules(w io.Writer, moduleNames []string) {
|
2019-12-30 08:56:33 +01:00
|
|
|
var required []string
|
|
|
|
var targetRequired []string
|
|
|
|
var hostRequired []string
|
2021-10-28 07:26:03 +02:00
|
|
|
required = append(required, a.RequiredModuleNames()...)
|
|
|
|
targetRequired = append(targetRequired, a.TargetRequiredModuleNames()...)
|
|
|
|
hostRequired = append(hostRequired, a.HostRequiredModuleNames()...)
|
2019-12-30 08:56:33 +01:00
|
|
|
for _, fi := range a.filesInfo {
|
|
|
|
required = append(required, fi.requiredModuleNames...)
|
|
|
|
targetRequired = append(targetRequired, fi.targetRequiredModuleNames...)
|
|
|
|
hostRequired = append(hostRequired, fi.hostRequiredModuleNames...)
|
|
|
|
}
|
2023-01-25 18:49:46 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, "LOCAL_REQUIRED_MODULES", moduleNames, a.makeModulesToInstall, required)
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, "LOCAL_TARGET_REQUIRED_MODULES", targetRequired)
|
|
|
|
android.AndroidMkEmitAssignList(w, "LOCAL_HOST_REQUIRED_MODULES", hostRequired)
|
2019-12-30 08:56:33 +01:00
|
|
|
}
|
|
|
|
|
2019-11-18 03:16:27 +01:00
|
|
|
func (a *apexBundle) androidMkForType() android.AndroidMkData {
|
|
|
|
return android.AndroidMkData{
|
|
|
|
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
|
2023-01-26 19:42:21 +01:00
|
|
|
moduleNames := []string{}
|
2019-11-18 03:16:27 +01:00
|
|
|
apexType := a.properties.ApexType
|
2023-01-26 19:42:21 +01:00
|
|
|
if a.installable() {
|
2023-02-08 11:14:01 +01:00
|
|
|
apexName := proptools.StringDefault(a.properties.Apex_name, name)
|
|
|
|
moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data)
|
2023-01-26 19:42:21 +01:00
|
|
|
}
|
2019-11-18 03:16:27 +01:00
|
|
|
|
|
|
|
if apexType == flattenedApex {
|
|
|
|
// Only image APEXes can be flattened.
|
2022-12-01 19:49:23 +01:00
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle.flat")
|
2019-11-18 03:16:27 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix)
|
2021-01-07 04:34:31 +01:00
|
|
|
data.Entries.WriteLicenseVariables(w)
|
2022-02-24 16:06:05 +01:00
|
|
|
a.writeRequiredModules(w, moduleNames)
|
2019-11-18 03:16:27 +01:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
|
|
|
|
|
|
|
} else {
|
2022-12-01 19:49:23 +01:00
|
|
|
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle")
|
2019-11-18 03:16:27 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix)
|
2021-01-07 04:34:31 +01:00
|
|
|
data.Entries.WriteLicenseVariables(w)
|
2019-11-18 03:16:27 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class?
|
|
|
|
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFile.String())
|
2021-11-12 03:59:15 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.String())
|
2020-11-26 14:32:26 +01:00
|
|
|
stemSuffix := apexType.suffix()
|
|
|
|
if a.isCompressed {
|
2021-09-08 18:48:28 +02:00
|
|
|
stemSuffix = imageCapexSuffix
|
2020-11-26 14:32:26 +01:00
|
|
|
}
|
|
|
|
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+stemSuffix)
|
2019-11-18 03:16:27 +01:00
|
|
|
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
|
2022-03-08 03:38:34 +01:00
|
|
|
if a.installable() {
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_INSTALLED_MODULE :=", a.installedFile.String())
|
|
|
|
fmt.Fprintln(w, "LOCAL_SOONG_INSTALL_PAIRS :=", a.outputFile.String()+":"+a.installedFile.String())
|
|
|
|
}
|
2020-06-24 16:26:26 +02:00
|
|
|
|
|
|
|
// Because apex writes .mk with Custom(), we need to write manually some common properties
|
|
|
|
// which are available via data.Entries
|
|
|
|
commonProperties := []string{
|
2021-04-16 22:41:59 +02:00
|
|
|
"LOCAL_FULL_INIT_RC", "LOCAL_FULL_VINTF_FRAGMENTS",
|
2020-06-24 16:26:26 +02:00
|
|
|
"LOCAL_PROPRIETARY_MODULE", "LOCAL_VENDOR_MODULE", "LOCAL_ODM_MODULE", "LOCAL_PRODUCT_MODULE", "LOCAL_SYSTEM_EXT_MODULE",
|
|
|
|
"LOCAL_MODULE_OWNER",
|
|
|
|
}
|
|
|
|
for _, name := range commonProperties {
|
|
|
|
if value, ok := data.Entries.EntryMap[name]; ok {
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, name, value)
|
2020-06-24 16:26:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, "LOCAL_OVERRIDES_MODULES", a.overridableProperties.Overrides)
|
2023-01-26 19:42:21 +01:00
|
|
|
a.writeRequiredModules(w, moduleNames)
|
2020-01-28 12:05:29 +01:00
|
|
|
|
2019-11-18 03:16:27 +01:00
|
|
|
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
|
|
|
|
|
|
|
|
if apexType == imageApex {
|
2020-05-08 09:38:40 +02:00
|
|
|
fmt.Fprintln(w, "ALL_MODULES.$(my_register_name).BUNDLE :=", a.bundleModuleFile.String())
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
2022-12-08 19:41:33 +01:00
|
|
|
android.AndroidMkEmitAssignList(w, "ALL_MODULES.$(my_register_name).LINT_REPORTS", a.lintReports.Strings())
|
2020-01-14 06:39:19 +01:00
|
|
|
|
|
|
|
if a.installedFilesFile != nil {
|
2020-02-27 01:55:51 +01:00
|
|
|
goal := "checkbuild"
|
2020-01-14 06:39:19 +01:00
|
|
|
distFile := name + "-installed-files.txt"
|
|
|
|
fmt.Fprintln(w, ".PHONY:", goal)
|
|
|
|
fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
|
|
|
|
goal, a.installedFilesFile.String(), distFile)
|
2022-04-13 20:27:19 +02:00
|
|
|
fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", a.installedFilesFile.String())
|
2020-01-14 06:39:19 +01:00
|
|
|
}
|
2020-11-11 13:33:14 +01:00
|
|
|
for _, dist := range data.Entries.GetDistForGoals(a) {
|
|
|
|
fmt.Fprintf(w, dist)
|
|
|
|
}
|
2020-12-04 00:53:15 +01:00
|
|
|
|
2021-11-03 01:58:02 +01:00
|
|
|
distCoverageFiles(w, "ndk_apis_usedby_apex", a.nativeApisUsedByModuleFile.String())
|
2021-11-22 20:49:41 +01:00
|
|
|
distCoverageFiles(w, "ndk_apis_backedby_apex", a.nativeApisBackedByModuleFile.String())
|
2021-11-03 01:58:02 +01:00
|
|
|
distCoverageFiles(w, "java_apis_used_by_apex", a.javaApisUsedByModuleFile.String())
|
2019-11-18 03:16:27 +01:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
}
|
2021-11-03 01:58:02 +01:00
|
|
|
|
|
|
|
func distCoverageFiles(w io.Writer, dir string, distfile string) {
|
|
|
|
if distfile != "" {
|
|
|
|
goal := "apps_only"
|
|
|
|
fmt.Fprintf(w, "ifneq (,$(filter $(my_register_name),$(TARGET_BUILD_APPS)))\n"+
|
|
|
|
" $(call dist-for-goals,%s,%s:%s/$(notdir %s))\n"+
|
|
|
|
"endif\n", goal, distfile, dir, distfile)
|
|
|
|
}
|
|
|
|
}
|