blob: 1b53a672b94cd91401c0457f046c531001aea2d9 [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 {
138 fmt.Fprintln(w, "LOCAL_TEST_DATA :=", strings.Join(cc.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:
160 if fi.module.Target().Arch.ArchType != android.Common {
161 fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
162 }
163 host = true
164 case android.HostCross:
165 if fi.module.Target().Arch.ArchType != android.Common {
166 fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
167 }
168 host = true
169 case android.Device:
170 if fi.module.Target().Arch.ArchType != android.Common {
171 fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
172 }
173 }
174 if host {
175 makeOs := fi.module.Target().Os.String()
176 if fi.module.Target().Os == android.Linux || fi.module.Target().Os == android.LinuxBionic {
177 makeOs = "linux"
178 }
179 fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs)
180 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
181 }
182 }
Jiyong Park618922e2020-01-08 13:35:43 +0900183 if fi.jacocoReportClassesFile != nil {
184 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", fi.jacocoReportClassesFile.String())
185 }
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700186 switch fi.class {
187 case javaSharedLib:
Jiyong Park09d77522019-11-18 11:16:27 +0900188 // soong_java_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .jar Therefore
189 // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
190 // we will have foo.jar.jar
Jiyong Parkf1493cc2020-05-29 21:29:20 +0900191 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".jar"))
Paul Duffin44b481b2020-06-17 16:59:43 +0100192 if javaModule, ok := fi.module.(java.ApexDependency); ok {
Jiyong Park9e83f0b2020-06-11 00:35:03 +0900193 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", javaModule.ImplementationAndResourcesJars()[0].String())
194 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", javaModule.HeaderJars()[0].String())
195 } else {
196 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", fi.builtFile.String())
197 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", fi.builtFile.String())
198 }
Jiyong Park09d77522019-11-18 11:16:27 +0900199 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", fi.builtFile.String())
200 fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
201 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700202 case app:
Colin Cross503c1d02020-01-28 14:00:53 -0800203 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", fi.certificate.AndroidMkString())
Jiyong Park618922e2020-01-08 13:35:43 +0900204 // soong_app_prebuilt.mk sets LOCAL_MODULE_SUFFIX := .apk Therefore
205 // we need to remove the suffix from LOCAL_MODULE_STEM, otherwise
206 // we will have foo.apk.apk
Jiyong Parkf1493cc2020-05-29 21:29:20 +0900207 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", strings.TrimSuffix(fi.Stem(), ".apk"))
Colin Cross403cc152020-07-06 14:15:24 -0700208 if app, ok := fi.module.(*java.AndroidApp); ok {
209 if jniCoverageOutputs := app.JniCoverageOutputs(); len(jniCoverageOutputs) > 0 {
210 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", strings.Join(jniCoverageOutputs.Strings(), " "))
211 }
212 if jniLibSymbols := app.JNISymbolsInstalls(modulePath); len(jniLibSymbols) > 0 {
213 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_SYMBOLS :=", jniLibSymbols.String())
214 }
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700215 }
Jiyong Park618922e2020-01-08 13:35:43 +0900216 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_app_prebuilt.mk")
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700217 case appSet:
218 as, ok := fi.module.(*java.AndroidAppSet)
219 if !ok {
220 panic(fmt.Sprintf("Expected %s to be AndroidAppSet", fi.module))
221 }
Liz Kammercada8072020-07-28 15:47:38 -0700222 fmt.Fprintln(w, "LOCAL_APK_SET_INSTALL_FILE :=", as.InstallFile())
Colin Cross4fb652d2020-07-09 19:05:35 -0700223 fmt.Fprintln(w, "LOCAL_APKCERTS_FILE :=", as.APKCertsFile().String())
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700224 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_android_app_set.mk")
225 case nativeSharedLib, nativeExecutable, nativeTest:
Jiyong Parkf1493cc2020-05-29 21:29:20 +0900226 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.Stem())
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700227 if ccMod, ok := fi.module.(*cc.Module); ok {
228 if ccMod.UnstrippedOutputFile() != nil {
229 fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", ccMod.UnstrippedOutputFile().String())
Jiyong Park09d77522019-11-18 11:16:27 +0900230 }
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700231 ccMod.AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
232 if ccMod.CoverageOutputFile().Valid() {
233 fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", ccMod.CoverageOutputFile().String())
Jiyong Park09d77522019-11-18 11:16:27 +0900234 }
235 }
236 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_cc_prebuilt.mk")
Sasha Smundak18d98bc2020-05-27 16:36:07 -0700237 default:
Jiyong Parkf1493cc2020-05-29 21:29:20 +0900238 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", fi.Stem())
Jiyong Park7aa3f762020-01-28 16:51:34 +0900239 if fi.builtFile == a.manifestPbOut && apexType == flattenedApex {
Jooyung Han75de2612020-01-24 02:02:45 +0900240 if a.primaryApexType {
Jooyung Han07931c72020-09-11 17:19:20 +0900241 // To install companion files (init_rc, vintf_fragments)
242 // Copy some common properties of apexBundle to apex_manifest
243 commonProperties := []string{
244 "LOCAL_INIT_RC", "LOCAL_VINTF_FRAGMENTS",
245 }
246 for _, name := range commonProperties {
247 if value, ok := apexAndroidMkData.Entries.EntryMap[name]; ok {
248 fmt.Fprintln(w, name+" := "+strings.Join(value, " "))
249 }
250 }
251
Jooyung Han75de2612020-01-24 02:02:45 +0900252 // Make apex_manifest.pb module for this APEX to override all other
253 // modules in the APEXes being overridden by this APEX
254 var patterns []string
255 for _, o := range a.overridableProperties.Overrides {
256 patterns = append(patterns, "%."+o+a.suffix)
257 }
Yo Chiang12d9f7a2020-06-16 17:32:19 +0800258 if len(patterns) > 0 {
259 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(patterns, " "))
260 }
Jiyong Park7aa3f762020-01-28 16:51:34 +0900261 if len(a.compatSymlinks) > 0 {
Jooyung Han75de2612020-01-24 02:02:45 +0900262 // For flattened apexes, compat symlinks are attached to apex_manifest.json which is guaranteed for every apex
263 postInstallCommands = append(postInstallCommands, a.compatSymlinks...)
264 }
265 }
266 if len(postInstallCommands) > 0 {
Jiyong Park7cd10e32020-01-14 09:22:18 +0900267 fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(postInstallCommands, " && "))
Jiyong Park0abc1b42020-01-09 17:43:39 +0900268 }
Jiyong Park09d77522019-11-18 11:16:27 +0900269 }
270 fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
271 }
Jiyong Park31af2672020-02-11 09:36:25 +0900272
273 // m <module_name> will build <module_name>.<apex_name> as well.
Yo Chiange8128052020-07-23 20:09:18 +0800274 if fi.androidMkModuleName != moduleName && a.primaryApexType {
275 fmt.Fprintf(w, ".PHONY: %s\n", fi.androidMkModuleName)
276 fmt.Fprintf(w, "%s: %s\n", fi.androidMkModuleName, moduleName)
Jiyong Park31af2672020-02-11 09:36:25 +0900277 }
Jiyong Park09d77522019-11-18 11:16:27 +0900278 }
279 return moduleNames
280}
281
Jiyong Park7afd1072019-12-30 16:56:33 +0900282func (a *apexBundle) writeRequiredModules(w io.Writer) {
283 var required []string
284 var targetRequired []string
285 var hostRequired []string
286 for _, fi := range a.filesInfo {
287 required = append(required, fi.requiredModuleNames...)
288 targetRequired = append(targetRequired, fi.targetRequiredModuleNames...)
289 hostRequired = append(hostRequired, fi.hostRequiredModuleNames...)
290 }
291
292 if len(required) > 0 {
293 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(required, " "))
294 }
295 if len(targetRequired) > 0 {
296 fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES +=", strings.Join(targetRequired, " "))
297 }
298 if len(hostRequired) > 0 {
299 fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES +=", strings.Join(hostRequired, " "))
300 }
301}
302
Jiyong Park09d77522019-11-18 11:16:27 +0900303func (a *apexBundle) androidMkForType() android.AndroidMkData {
304 return android.AndroidMkData{
305 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
306 moduleNames := []string{}
307 apexType := a.properties.ApexType
308 if a.installable() {
309 apexName := proptools.StringDefault(a.properties.Apex_name, name)
Jooyung Han07931c72020-09-11 17:19:20 +0900310 moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data)
Jiyong Park09d77522019-11-18 11:16:27 +0900311 }
312
313 if apexType == flattenedApex {
314 // Only image APEXes can be flattened.
315 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
316 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
317 fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix)
318 if len(moduleNames) > 0 {
319 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
320 }
Jiyong Park7afd1072019-12-30 16:56:33 +0900321 a.writeRequiredModules(w)
Jiyong Park09d77522019-11-18 11:16:27 +0900322 fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
Jiyong Park09d77522019-11-18 11:16:27 +0900323
324 } else {
325 fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
326 fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
327 fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix)
328 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class?
329 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFile.String())
330 fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String())
331 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix())
332 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
Jooyung Han2ed99d02020-06-24 23:26:26 +0900333
334 // Because apex writes .mk with Custom(), we need to write manually some common properties
335 // which are available via data.Entries
336 commonProperties := []string{
337 "LOCAL_INIT_RC", "LOCAL_VINTF_FRAGMENTS",
338 "LOCAL_PROPRIETARY_MODULE", "LOCAL_VENDOR_MODULE", "LOCAL_ODM_MODULE", "LOCAL_PRODUCT_MODULE", "LOCAL_SYSTEM_EXT_MODULE",
339 "LOCAL_MODULE_OWNER",
340 }
341 for _, name := range commonProperties {
342 if value, ok := data.Entries.EntryMap[name]; ok {
343 fmt.Fprintln(w, name+" := "+strings.Join(value, " "))
344 }
345 }
346
Yo Chiang12d9f7a2020-06-16 17:32:19 +0800347 if len(a.overridableProperties.Overrides) > 0 {
348 fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(a.overridableProperties.Overrides, " "))
349 }
Jiyong Park09d77522019-11-18 11:16:27 +0900350 if len(moduleNames) > 0 {
351 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
352 }
Jiyong Park956305c2020-01-09 12:32:06 +0900353 if len(a.requiredDeps) > 0 {
354 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.requiredDeps, " "))
Jiyong Park09d77522019-11-18 11:16:27 +0900355 }
Jiyong Park7afd1072019-12-30 16:56:33 +0900356 a.writeRequiredModules(w)
Jiyong Park09d77522019-11-18 11:16:27 +0900357 var postInstallCommands []string
358 if a.prebuiltFileToDelete != "" {
359 postInstallCommands = append(postInstallCommands, "rm -rf "+
360 filepath.Join(a.installDir.ToMakePath().String(), a.prebuiltFileToDelete))
361 }
362 // For unflattened apexes, compat symlinks are attached to apex package itself as LOCAL_POST_INSTALL_CMD
363 postInstallCommands = append(postInstallCommands, a.compatSymlinks...)
364 if len(postInstallCommands) > 0 {
365 fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(postInstallCommands, " && "))
366 }
Jiyong Park19972c72020-01-28 20:05:29 +0900367
368 if a.mergedNotices.Merged.Valid() {
369 fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", a.mergedNotices.Merged.Path().String())
370 }
371
Jiyong Park09d77522019-11-18 11:16:27 +0900372 fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
373
374 if apexType == imageApex {
Yo Chiangef2d4892020-05-08 15:38:40 +0800375 fmt.Fprintln(w, "ALL_MODULES.$(my_register_name).BUNDLE :=", a.bundleModuleFile.String())
Jiyong Park09d77522019-11-18 11:16:27 +0900376 }
Colin Cross08dca382020-07-21 20:31:17 -0700377 if len(a.lintReports) > 0 {
378 fmt.Fprintln(w, "ALL_MODULES.$(my_register_name).LINT_REPORTS :=",
379 strings.Join(a.lintReports.Strings(), " "))
380 }
Jiyong Park3a1602e2020-01-14 14:39:19 +0900381
382 if a.installedFilesFile != nil {
Colin Cross1c85e8e2020-02-26 16:55:51 -0800383 goal := "checkbuild"
Jiyong Park3a1602e2020-01-14 14:39:19 +0900384 distFile := name + "-installed-files.txt"
385 fmt.Fprintln(w, ".PHONY:", goal)
386 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
387 goal, a.installedFilesFile.String(), distFile)
388 }
Jiyong Park09d77522019-11-18 11:16:27 +0900389 }
390 }}
391}