blob: 993260c7ec281ca8579314634e576d6ad4410e8e [file] [log] [blame]
Jiyong Park09d77522019-11-18 11:16:27 +09001// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package apex
16
17import (
18 "fmt"
19 "io"
20 "path/filepath"
21 "strings"
22
23 "android/soong/android"
24 "android/soong/cc"
Jaewoong Jung87a33e72020-03-26 14:01:48 -070025 "android/soong/java"
Jiyong Park09d77522019-11-18 11:16:27 +090026
27 "github.com/google/blueprint/proptools"
28)
29
30func (a *apexBundle) AndroidMk() android.AndroidMkData {
31 if a.properties.HideFromMake {
32 return android.AndroidMkData{
33 Disabled: true,
34 }
35 }
Jooyung Han2ed99d02020-06-24 23:26:26 +090036 return a.androidMkForType()
Jiyong Park09d77522019-11-18 11:16:27 +090037}
38
Jooyung Han07931c72020-09-11 17:19:20 +090039func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, moduleDir string,
40 apexAndroidMkData android.AndroidMkData) []string {
41
Jiyong Parkdb334862020-02-05 17:19:28 +090042 // apexBundleName comes from the 'name' property; apexName comes from 'apex_name' property.
43 // An apex is installed to /system/apex/<apexBundleName> and is activated at /apex/<apexName>
44 // In many cases, the two names are the same, but could be different in general.
45
Jiyong Park09d77522019-11-18 11:16:27 +090046 moduleNames := []string{}
47 apexType := a.properties.ApexType
48 // To avoid creating duplicate build rules, run this function only when primaryApexType is true
49 // to install symbol files in $(PRODUCT_OUT}/apex.
50 // And if apexType is flattened, run this function to install files in $(PRODUCT_OUT}/system/apex.
51 if !a.primaryApexType && apexType != flattenedApex {
52 return moduleNames
53 }
54
Yifan Hong93a90db2020-07-28 17:24:44 -070055 // b/162366062. Prevent GKI APEXes to emit make rules to avoid conflicts.
56 if strings.HasPrefix(apexName, "com.android.gki.") && apexType != flattenedApex {
57 return moduleNames
58 }
59
Jiyong Parkdb334862020-02-05 17:19:28 +090060 // b/140136207. When there are overriding APEXes for a VNDK APEX, the symbols file for the overridden
61 // APEX and the overriding APEX will have the same installation paths at /apex/com.android.vndk.v<ver>
62 // as their apexName will be the same. To avoid the path conflicts, skip installing the symbol files
63 // for the overriding VNDK APEXes.
64 symbolFilesNotNeeded := a.vndkApex && len(a.overridableProperties.Overrides) > 0
65 if symbolFilesNotNeeded && apexType != flattenedApex {
66 return moduleNames
67 }
68
Jiyong Park7cd10e32020-01-14 09:22:18 +090069 var postInstallCommands []string
70 for _, fi := range a.filesInfo {
71 if a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform() {
72 // TODO(jiyong): pathOnDevice should come from fi.module, not being calculated here
73 linkTarget := filepath.Join("/system", fi.Path())
Jiyong Parkdb334862020-02-05 17:19:28 +090074 linkPath := filepath.Join(a.installDir.ToMakePath().String(), apexBundleName, fi.Path())
Jiyong Park7cd10e32020-01-14 09:22:18 +090075 mkdirCmd := "mkdir -p " + filepath.Dir(linkPath)
76 linkCmd := "ln -sfn " + linkTarget + " " + linkPath
77 postInstallCommands = append(postInstallCommands, mkdirCmd, linkCmd)
78 }
79 }
Jiyong Park7cd10e32020-01-14 09:22:18 +090080
Liz Kammer5bd365f2020-05-27 15:15:11 -070081 seenDataOutPaths := make(map[string]bool)
82
Jiyong Park09d77522019-11-18 11:16:27 +090083 for _, fi := range a.filesInfo {
Sasha Smundak18d98bc2020-05-27 16:36:07 -070084 if ccMod, ok := fi.module.(*cc.Module); ok && ccMod.Properties.HideFromMake {
Jiyong Park09d77522019-11-18 11:16:27 +090085 continue
86 }
87
Jiyong Park7cd10e32020-01-14 09:22:18 +090088 linkToSystemLib := a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform()
89
90 var moduleName string
91 if linkToSystemLib {
Yo Chiange8128052020-07-23 20:09:18 +080092 moduleName = fi.androidMkModuleName
Jiyong Park7cd10e32020-01-14 09:22:18 +090093 } else {
Yo Chiange8128052020-07-23 20:09:18 +080094 moduleName = fi.androidMkModuleName + "." + apexBundleName + a.suffix
Jiyong Park7cd10e32020-01-14 09:22:18 +090095 }
96
97 if !android.InList(moduleName, moduleNames) {
98 moduleNames = append(moduleNames, moduleName)
99 }
100
101 if linkToSystemLib {
102 // No need to copy the file since it's linked to the system file
103 continue
Jiyong Park09d77522019-11-18 11:16:27 +0900104 }
105
106 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
Jiyong Park1833cef2019-12-13 13:28:36 +0900107 if fi.moduleDir != "" {
108 fmt.Fprintln(w, "LOCAL_PATH :=", fi.moduleDir)
109 } else {
110 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
111 }
Jiyong Park7cd10e32020-01-14 09:22:18 +0900112 fmt.Fprintln(w, "LOCAL_MODULE :=", moduleName)
Anton Hansson1ee62c02020-06-30 11:51:53 +0100113 if fi.module != nil && fi.module.Owner() != "" {
114 fmt.Fprintln(w, "LOCAL_MODULE_OWNER :=", fi.module.Owner())
115 }
Jiyong Park09d77522019-11-18 11:16:27 +0900116 // /apex/<apex_name>/{lib|framework|...}
117 pathWhenActivated := filepath.Join("$(PRODUCT_OUT)", "apex", apexName, fi.installDir)
Colin Cross403cc152020-07-06 14:15:24 -0700118 var modulePath string
Jiyong Park09d77522019-11-18 11:16:27 +0900119 if apexType == flattenedApex {
120 // /system/apex/<name>/{lib|framework|...}
Colin Cross403cc152020-07-06 14:15:24 -0700121 modulePath = filepath.Join(a.installDir.ToMakePath().String(), apexBundleName, fi.installDir)
Liz Kammer5bd365f2020-05-27 15:15:11 -0700122 fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", modulePath)
Jiyong Parkdb334862020-02-05 17:19:28 +0900123 if a.primaryApexType && !symbolFilesNotNeeded {
Jiyong Park09d77522019-11-18 11:16:27 +0900124 fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated)
125 }
126 if len(fi.symlinks) > 0 {
127 fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS :=", strings.Join(fi.symlinks, " "))
128 }
Chris Parsons216e10a2020-07-09 17:12:52 -0400129 newDataPaths := []android.DataPath{}
Liz Kammer5bd365f2020-05-27 15:15:11 -0700130 for _, path := range fi.dataPaths {
Chris Parsons216e10a2020-07-09 17:12:52 -0400131 dataOutPath := modulePath + ":" + path.SrcPath.Rel()
Liz Kammer5bd365f2020-05-27 15:15:11 -0700132 if ok := seenDataOutPaths[dataOutPath]; !ok {
133 newDataPaths = append(newDataPaths, path)
134 seenDataOutPaths[dataOutPath] = true
135 }
136 }
137 if len(newDataPaths) > 0 {
Dan Shi31949122020-09-21 12:11:02 -0700138 fmt.Fprintln(w, "LOCAL_TEST_DATA :=", strings.Join(android.AndroidMkDataPaths(newDataPaths), " "))
Liz Kammer1c14a212020-05-12 15:26:55 -0700139 }
Jiyong Park09d77522019-11-18 11:16:27 +0900140
Bob Badoura75b0572020-02-18 20:21:55 -0800141 if fi.module != nil && len(fi.module.NoticeFiles()) > 0 {
142 fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", strings.Join(fi.module.NoticeFiles().Strings(), " "))
Jiyong Park09d77522019-11-18 11:16:27 +0900143 }
144 } else {
Colin Cross403cc152020-07-06 14:15:24 -0700145 modulePath = pathWhenActivated
Jiyong Park09d77522019-11-18 11:16:27 +0900146 fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", pathWhenActivated)
Jiyong Park19972c72020-01-28 20:05:29 +0900147
148 // For non-flattend APEXes, the merged notice file is attached to the APEX itself.
149 // We don't need to have notice file for the individual modules in it. Otherwise,
150 // we will have duplicated notice entries.
151 fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
Jiyong Park09d77522019-11-18 11:16:27 +0900152 }
153 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
154 fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
155 if fi.module != nil {
156 archStr := fi.module.Target().Arch.ArchType.String()
157 host := false
158 switch fi.module.Target().Os.Class {
159 case android.Host:
Jiyong Park1613e552020-09-14 19:43:17 +0900160 if fi.module.Target().HostCross {
161 if fi.module.Target().Arch.ArchType != android.Common {
162 fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
163 }
164 } else {
165 if fi.module.Target().Arch.ArchType != android.Common {
166 fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
167 }
Jiyong Park09d77522019-11-18 11:16:27 +0900168 }
169 host = true
170 case android.Device:
171 if fi.module.Target().Arch.ArchType != android.Common {
172 fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
173 }
174 }
175 if host {
176 makeOs := fi.module.Target().Os.String()
177 if fi.module.Target().Os == android.Linux || fi.module.Target().Os == android.LinuxBionic {
178 makeOs = "linux"
179 }
180 fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
181 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
182 }
183 }
Jiyong Park618922e2020-01-08 13:35:43 +0900184 if fi.jacocoReportClassesFile != nil {
185 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", fi.jacocoReportClassesFile.String())
186 }
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700187 switch fi.class {
188 case javaSharedLib:
Jiyong Park09d77522019-11-18 11:16:27 +0900189 // soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
190 // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
191 // we will have foo.jar.jar
Jiyong Parkf1493cc2020-05-29 21:29:20 +0900192 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".jar"))
Paul Duffin44b481b2020-06-17 16:59:43 +0100193 if javaModule, ok := fi.module.(java.ApexDependency); ok {
Jiyong Park9e83f0b2020-06-11 00:35:03 +0900194 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
195 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
196 } else {
197 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", fi.builtFile.String())
198 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", fi.builtFile.String())
199 }
Jiyong Park09d77522019-11-18 11:16:27 +0900200 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
201 fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
202 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700203 case app:
Colin Cross503c1d02020-01-28 14:00:53 -0800204 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", fi.certificate.AndroidMkString())
Jiyong Park618922e2020-01-08 13:35:43 +0900205 // soong_app_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .apk Therefore
206 // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
207 // we will have foo.apk.apk
Jiyong Parkf1493cc2020-05-29 21:29:20 +0900208 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".apk"))
Colin Cross403cc152020-07-06 14:15:24 -0700209 if app, ok := fi.module.(*java.AndroidApp); ok {
210 if jniCoverageOutputs := app.JniCoverageOutputs(); len(jniCoverageOutputs) > 0 {
211 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", strings.Join(jniCoverageOutputs.Strings(), " "))
212 }
213 if jniLibSymbols := app.JNISymbolsInstalls(modulePath); len(jniLibSymbols) > 0 {
214 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_SYMBOLS :=", jniLibSymbols.String())
215 }
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700216 }
Jiyong Park618922e2020-01-08 13:35:43 +0900217 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_app_prebuilt.mk")
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700218 case appSet:
219 as, ok := fi.module.(*java.AndroidAppSet)
220 if !ok {
221 panic(fmt.Sprintf("Expected %s to be AndroidAppSet", fi.module))
222 }
Liz Kammercada8072020-07-28 15:47:38 -0700223 fmt.Fprintln(w, "LOCAL_APK_SET_INSTALL_FILE :=", as.InstallFile())
Colin Cross4fb652d2020-07-09 19:05:35 -0700224 fmt.Fprintln(w, "LOCAL_APKCERTS_FILE :=", as.APKCertsFile().String())
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700225 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_android_app_set.mk")
226 case nativeSharedLib, nativeExecutable, nativeTest:
Jiyong Parkf1493cc2020-05-29 21:29:20 +0900227 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.Stem())
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700228 if ccMod, ok := fi.module.(*cc.Module); ok {
229 if ccMod.UnstrippedOutputFile() != nil {
230 fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", ccMod.UnstrippedOutputFile().String())
Jiyong Park09d77522019-11-18 11:16:27 +0900231 }
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700232 ccMod.AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
233 if ccMod.CoverageOutputFile().Valid() {
234 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", ccMod.CoverageOutputFile().String())
Jiyong Park09d77522019-11-18 11:16:27 +0900235 }
236 }
237 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700238 default:
Jiyong Parkf1493cc2020-05-29 21:29:20 +0900239 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.Stem())
Jiyong Park7aa3f762020-01-28 16:51:34 +0900240 if fi.builtFile == a.manifestPbOut && apexType == flattenedApex {
Jooyung Han75de2612020-01-24 02:02:45 +0900241 if a.primaryApexType {
Jooyung Han07931c72020-09-11 17:19:20 +0900242 // To install companion files (init_rc, vintf_fragments)
243 // Copy some common properties of apexBundle to apex_manifest
244 commonProperties := []string{
245 "LOCAL_INIT_RC", "LOCAL_VINTF_FRAGMENTS",
246 }
247 for _, name := range commonProperties {
248 if value, ok := apexAndroidMkData.Entries.EntryMap[name]; ok {
249 fmt.Fprintln(w, name+" := "+strings.Join(value, " "))
250 }
251 }
252
Jooyung Han75de2612020-01-24 02:02:45 +0900253 // Make apex_manifest.pb module for this APEX to override all other
254 // modules in the APEXes being overridden by this APEX
255 var patterns []string
256 for _, o := range a.overridableProperties.Overrides {
257 patterns = append(patterns, "%."+o+a.suffix)
258 }
Yo Chiang12d9f7a2020-06-16 17:32:19 +0800259 if len(patterns) > 0 {
260 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(patterns, " "))
261 }
Jiyong Park7aa3f762020-01-28 16:51:34 +0900262 if len(a.compatSymlinks) > 0 {
Jooyung Han75de2612020-01-24 02:02:45 +0900263 // For flattened apexes, compat symlinks are attached to apex_manifest.json which is guaranteed for every apex
264 postInstallCommands = append(postInstallCommands, a.compatSymlinks...)
265 }
266 }
Jooyung Han7f146c02020-09-23 19:15:55 +0900267
268 // File_contexts of flattened APEXes should be merged into file_contexts.bin
269 fmt.Fprintln(w, "LOCAL_FILE_CONTEXTS :=", a.fileContexts)
270
Jooyung Han75de2612020-01-24 02:02:45 +0900271 if len(postInstallCommands) > 0 {
Jiyong Park7cd10e32020-01-14 09:22:18 +0900272 fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(postInstallCommands, " && "))
Jiyong Park0abc1b42020-01-09 17:43:39 +0900273 }
Jiyong Park09d77522019-11-18 11:16:27 +0900274 }
275 fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
276 }
Jiyong Park31af2672020-02-11 09:36:25 +0900277
278 // m <module_name> will build <module_name>.<apex_name> as well.
Yo Chiange8128052020-07-23 20:09:18 +0800279 if fi.androidMkModuleName != moduleName && a.primaryApexType {
280 fmt.Fprintf(w, ".PHONY: %s\n", fi.androidMkModuleName)
281 fmt.Fprintf(w, "%s: %s\n", fi.androidMkModuleName, moduleName)
Jiyong Park31af2672020-02-11 09:36:25 +0900282 }
Jiyong Park09d77522019-11-18 11:16:27 +0900283 }
284 return moduleNames
285}
286
Jiyong Park7afd1072019-12-30 16:56:33 +0900287func (a *apexBundle) writeRequiredModules(w io.Writer) {
288 var required []string
289 var targetRequired []string
290 var hostRequired []string
291 for _, fi := range a.filesInfo {
292 required = append(required, fi.requiredModuleNames...)
293 targetRequired = append(targetRequired, fi.targetRequiredModuleNames...)
294 hostRequired = append(hostRequired, fi.hostRequiredModuleNames...)
295 }
296
297 if len(required) > 0 {
298 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(required, " "))
299 }
300 if len(targetRequired) > 0 {
301 fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES +=", strings.Join(targetRequired, " "))
302 }
303 if len(hostRequired) > 0 {
304 fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES +=", strings.Join(hostRequired, " "))
305 }
306}
307
Jiyong Park09d77522019-11-18 11:16:27 +0900308func (a *apexBundle) androidMkForType() android.AndroidMkData {
309 return android.AndroidMkData{
Anton Hansson82d502a2020-11-11 12:33:14 +0000310 DistFiles: a.distFiles,
Jiyong Park09d77522019-11-18 11:16:27 +0900311 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
312 moduleNames := []string{}
313 apexType := a.properties.ApexType
314 if a.installable() {
315 apexName := proptools.StringDefault(a.properties.Apex_name, name)
Jooyung Han07931c72020-09-11 17:19:20 +0900316 moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data)
Jiyong Park09d77522019-11-18 11:16:27 +0900317 }
318
319 if apexType == flattenedApex {
320 // Only image APEXes can be flattened.
321 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
322 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
323 fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix)
324 if len(moduleNames) > 0 {
325 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
326 }
Jiyong Park7afd1072019-12-30 16:56:33 +0900327 a.writeRequiredModules(w)
Jiyong Park09d77522019-11-18 11:16:27 +0900328 fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
Jiyong Park09d77522019-11-18 11:16:27 +0900329
330 } else {
331 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
332 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
333 fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix)
334 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class?
335 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFile.String())
336 fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String())
337 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix())
338 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
Jooyung Han2ed99d02020-06-24 23:26:26 +0900339
340 // Because apex writes .mk with Custom(), we need to write manually some common properties
341 // which are available via data.Entries
342 commonProperties := []string{
343 "LOCAL_INIT_RC", "LOCAL_VINTF_FRAGMENTS",
344 "LOCAL_PROPRIETARY_MODULE", "LOCAL_VENDOR_MODULE", "LOCAL_ODM_MODULE", "LOCAL_PRODUCT_MODULE", "LOCAL_SYSTEM_EXT_MODULE",
345 "LOCAL_MODULE_OWNER",
346 }
347 for _, name := range commonProperties {
348 if value, ok := data.Entries.EntryMap[name]; ok {
349 fmt.Fprintln(w, name+" := "+strings.Join(value, " "))
350 }
351 }
352
Yo Chiang12d9f7a2020-06-16 17:32:19 +0800353 if len(a.overridableProperties.Overrides) > 0 {
354 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(a.overridableProperties.Overrides, " "))
355 }
Jiyong Park09d77522019-11-18 11:16:27 +0900356 if len(moduleNames) > 0 {
357 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
358 }
Jiyong Park956305c2020-01-09 12:32:06 +0900359 if len(a.requiredDeps) > 0 {
360 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.requiredDeps, " "))
Jiyong Park09d77522019-11-18 11:16:27 +0900361 }
Jiyong Park7afd1072019-12-30 16:56:33 +0900362 a.writeRequiredModules(w)
Jiyong Park09d77522019-11-18 11:16:27 +0900363 var postInstallCommands []string
364 if a.prebuiltFileToDelete != "" {
365 postInstallCommands = append(postInstallCommands, "rm -rf "+
366 filepath.Join(a.installDir.ToMakePath().String(), a.prebuiltFileToDelete))
367 }
368 // For unflattened apexes, compat symlinks are attached to apex package itself as LOCAL_POST_INSTALL_CMD
369 postInstallCommands = append(postInstallCommands, a.compatSymlinks...)
370 if len(postInstallCommands) > 0 {
371 fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(postInstallCommands, " && "))
372 }
Jiyong Park19972c72020-01-28 20:05:29 +0900373
374 if a.mergedNotices.Merged.Valid() {
375 fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", a.mergedNotices.Merged.Path().String())
376 }
377
Jiyong Park09d77522019-11-18 11:16:27 +0900378 fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
379
380 if apexType == imageApex {
Yo Chiangef2d4892020-05-08 15:38:40 +0800381 fmt.Fprintln(w, "ALL_MODULES.$(my_register_name).BUNDLE :=", a.bundleModuleFile.String())
Jiyong Park09d77522019-11-18 11:16:27 +0900382 }
Colin Cross08dca382020-07-21 20:31:17 -0700383 if len(a.lintReports) > 0 {
384 fmt.Fprintln(w, "ALL_MODULES.$(my_register_name).LINT_REPORTS :=",
385 strings.Join(a.lintReports.Strings(), " "))
386 }
Jiyong Park3a1602e2020-01-14 14:39:19 +0900387
388 if a.installedFilesFile != nil {
Colin Cross1c85e8e2020-02-26 16:55:51 -0800389 goal := "checkbuild"
Jiyong Park3a1602e2020-01-14 14:39:19 +0900390 distFile := name + "-installed-files.txt"
391 fmt.Fprintln(w, ".PHONY:", goal)
392 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
393 goal, a.installedFilesFile.String(), distFile)
394 }
Anton Hansson82d502a2020-11-11 12:33:14 +0000395 for _, dist := range data.Entries.GetDistForGoals(a) {
396 fmt.Fprintf(w, dist)
397 }
Jiyong Park09d77522019-11-18 11:16:27 +0900398 }
399 }}
400}