blob: 99dd82304278dc87ba93c07ccdb80851fdd10ffb [file] [log] [blame]
Dan Willemsen218f6562015-07-08 18:13:11 -07001// Copyright 2015 Google Inc. All rights reserved.
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 java
16
17import (
Colin Cross74d73e22017-08-02 11:05:49 -070018 "fmt"
19 "io"
20
Colin Cross635c3b02016-05-18 15:37:25 -070021 "android/soong/android"
Dan Willemsen218f6562015-07-08 18:13:11 -070022)
23
Jiyong Park55bd98b2019-12-11 17:27:07 +090024func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
25 hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
26 if !library.IsForPlatform() {
Jiyong Parkb02bb402019-12-03 00:43:57 +090027 // Don't emit hostdex modules from the APEX variants
Jiyong Park55bd98b2019-12-11 17:27:07 +090028 hostDexNeeded = false
Sundong Ahn054b19a2018-10-19 13:46:09 +090029 }
Jiyong Park55bd98b2019-12-11 17:27:07 +090030
31 if hostDexNeeded {
32 var output android.Path
33 if library.dexJarFile != nil {
34 output = library.dexJarFile
35 } else {
36 output = library.implementationAndResourcesJar
37 }
38 return android.AndroidMkEntries{
39 Class: "JAVA_LIBRARIES",
40 SubName: "-hostdex",
41 OutputFile: android.OptionalPathForPath(output),
42 Required: library.deviceProperties.Target.Hostdex.Required,
43 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
44 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
45 func(entries *android.AndroidMkEntries) {
46 entries.SetBool("LOCAL_IS_HOST_MODULE", true)
47 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
48 if library.dexJarFile != nil {
49 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
50 }
51 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
52 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
53 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
54 },
55 },
56 }
57 }
58 return android.AndroidMkEntries{Disabled: true}
Sundong Ahn054b19a2018-10-19 13:46:09 +090059}
60
Jiyong Park0b0e1b92019-12-03 13:24:29 +090061func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park55bd98b2019-12-11 17:27:07 +090062 var entriesList []android.AndroidMkEntries
63
64 mainEntries := android.AndroidMkEntries{Disabled: true}
Jiyong Parkb02bb402019-12-03 00:43:57 +090065
Jiyong Park55bd98b2019-12-11 17:27:07 +090066 // For a java library built for an APEX, we don't need Make module
Jiyong Parkb02bb402019-12-03 00:43:57 +090067 hideFromMake := !library.IsForPlatform()
68 // If not available for platform, don't emit to make.
69 if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
70 hideFromMake = true
71 }
Colin Crossb549b772020-06-03 17:14:31 +000072 if hideFromMake {
73 // May still need to add some additional dependencies. This will be called
74 // once for the platform variant (even if it is not being used) and once each
75 // for the APEX specific variants. In order to avoid adding the dependency
76 // multiple times only add it for the platform variant.
77 checkedModulePaths := library.additionalCheckedModules
78 if library.IsForPlatform() && len(checkedModulePaths) != 0 {
79 mainEntries = android.AndroidMkEntries{
80 Class: "FAKE",
81 // Need at least one output file in order for this to take effect.
82 OutputFile: android.OptionalPathForPath(checkedModulePaths[0]),
83 Include: "$(BUILD_PHONY_PACKAGE)",
84 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
85 func(entries *android.AndroidMkEntries) {
86 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", checkedModulePaths.Strings()...)
87 },
88 },
89 }
90 }
91 } else {
Jiyong Park55bd98b2019-12-11 17:27:07 +090092 mainEntries = android.AndroidMkEntries{
93 Class: "JAVA_LIBRARIES",
Jingwen Chen40fd90a2020-06-15 05:24:19 +000094 DistFiles: library.distFiles,
Jiyong Park55bd98b2019-12-11 17:27:07 +090095 OutputFile: android.OptionalPathForPath(library.outputFile),
96 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
97 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
98 func(entries *android.AndroidMkEntries) {
99 if len(library.logtagsSrcs) > 0 {
100 var logtags []string
101 for _, l := range library.logtagsSrcs {
102 logtags = append(logtags, l.Rel())
103 }
104 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -0800105 }
Colin Cross5beccee2017-12-07 15:28:59 -0800106
Jiyong Park55bd98b2019-12-11 17:27:07 +0900107 if library.installFile == nil {
108 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
109 }
110 if library.dexJarFile != nil {
111 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
112 }
113 if len(library.dexpreopter.builtInstalled) > 0 {
114 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
115 }
Jiyong Park6a927c42020-01-21 02:03:43 +0900116 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion().raw)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900117 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
118 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800119
Jiyong Park55bd98b2019-12-11 17:27:07 +0900120 if library.jacocoReportClassesFile != nil {
121 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
122 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800123
Jiyong Park55bd98b2019-12-11 17:27:07 +0900124 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
Jiyong Park1be96912018-05-28 18:02:19 +0900125
Colin Crossb549b772020-06-03 17:14:31 +0000126 if len(library.additionalCheckedModules) != 0 {
127 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
128 }
129
Jiyong Park55bd98b2019-12-11 17:27:07 +0900130 if library.proguardDictionary != nil {
131 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
132 }
133 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700134
135 entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", library.linter.outputs.transitiveHTMLZip)
136 entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", library.linter.outputs.transitiveTextZip)
137 entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", library.linter.outputs.transitiveXMLZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900138 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700139 },
Jiyong Park55bd98b2019-12-11 17:27:07 +0900140 }
141 }
142
143 hostDexEntries := library.AndroidMkEntriesHostDex()
144
145 entriesList = append(entriesList, mainEntries, hostDexEntries)
146 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700147}
148
Paul Duffin42df1442019-03-20 12:45:53 +0000149// Called for modules that are a component of a test suite.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700150func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700151 entries.SetString("LOCAL_MODULE_TAGS", "tests")
152 if len(test_suites) > 0 {
153 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...)
154 } else {
155 entries.SetString("LOCAL_COMPATIBILITY_SUITE", "null-suite")
156 }
157}
158
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900159func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
160 entriesList := j.Library.AndroidMkEntries()
161 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700162 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
163 testSuiteComponent(entries, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700164 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700165 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700166 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700167 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800168 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
169 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
170 }
Colin Cross05638fc2018-04-09 18:40:24 -0700171 })
172
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900173 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700174}
175
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900176func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
177 entriesList := j.Library.AndroidMkEntries()
178 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700179 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
180 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
Paul Duffin42df1442019-03-20 12:45:53 +0000181 })
182
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900183 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000184}
185
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900186func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park9b409bc2019-10-11 14:59:13 +0900187 if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900188 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900189 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900190 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900191 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900192 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700193 Class: "JAVA_LIBRARIES",
194 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700195 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700196 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
197 func(entries *android.AndroidMkEntries) {
198 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
199 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
200 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park6a927c42020-01-21 02:03:43 +0900201 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion().raw)
Jiyong Park0b238752019-10-29 11:23:10 +0900202 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700203 },
204 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900205 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700206}
Colin Cross10a03492017-08-10 17:09:43 -0700207
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900208func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park7f7766d2019-07-25 22:02:35 +0900209 if !prebuilt.IsForPlatform() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900210 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900211 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900212 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900213 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900214 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800215 Class: "JAVA_LIBRARIES",
216 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
217 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700218 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
219 func(entries *android.AndroidMkEntries) {
Colin Cross42be7612019-02-21 18:12:14 -0800220 if prebuilt.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700221 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800222 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
223 // boot_jars_package_check.mk can check dex jars.
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700224 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.dexJarFile)
225 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800226 }
227 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700228 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800229 }
Jiyong Park0b238752019-10-29 11:23:10 +0900230 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800231 },
232 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900233 }}
Colin Cross42be7612019-02-21 18:12:14 -0800234}
235
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900236func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900237 if !prebuilt.IsForPlatform() {
238 return []android.AndroidMkEntries{{
239 Disabled: true,
240 }}
241 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900242 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800243 Class: "JAVA_LIBRARIES",
244 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
245 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700246 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
247 func(entries *android.AndroidMkEntries) {
248 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
249 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
250 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
251 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
252 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
253 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
254 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park6a927c42020-01-21 02:03:43 +0900255 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion().raw)
Colin Crossfabb6082018-02-20 17:22:23 -0800256 },
257 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900258 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800259}
260
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900261func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross10a03492017-08-10 17:09:43 -0700262
Colin Cross6b4a32d2017-12-05 13:42:45 -0800263 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900264 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800265 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700266 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800267 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700268 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
269 func(entries *android.AndroidMkEntries) {
270 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
271 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Colin Cross12fc2af2019-01-14 12:35:45 -0800272 if binary.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700273 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
Colin Cross12fc2af2019-01-14 12:35:45 -0800274 }
275 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700276 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800277 }
Colin Cross331a1212018-08-15 20:40:52 -0700278 },
279 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700280 ExtraFooters: []android.AndroidMkExtraFootersFunc{
281 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
282 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
283 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800284 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900285 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800286 } else {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900287 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800288 Class: "EXECUTABLES",
289 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700290 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
291 func(entries *android.AndroidMkEntries) {
292 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800293 },
294 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700295 ExtraFooters: []android.AndroidMkExtraFootersFunc{
296 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
297 // Ensure that the wrapper script timestamp is always updated when the jar is updated
298 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
299 fmt.Fprintln(w, "jar_installed_module :=")
300 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800301 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900302 }}
Colin Cross10a03492017-08-10 17:09:43 -0700303 }
304}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800305
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900306func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700307 if !app.IsForPlatform() || app.appProperties.HideFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900308 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900309 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900310 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900311 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900312 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800313 Class: "APPS",
314 OutputFile: android.OptionalPathForPath(app.outputFile),
315 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700316 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
317 func(entries *android.AndroidMkEntries) {
318 // App module names can be overridden.
319 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700320 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700321 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800322 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700323 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800324 }
Colin Cross331a1212018-08-15 20:40:52 -0700325 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700326 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800327 }
328 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700329 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800330 }
Colin Crossf6237212018-10-29 23:14:58 -0700331 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700332 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700333 }
Colin Cross70798562017-12-13 22:42:59 -0800334 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700335 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800336 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800337 if app.proguardDictionary != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700338 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800339 }
Colin Cross70798562017-12-13 22:42:59 -0800340
341 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700342 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800343 // Make base_rules.mk not put framework-res in a subdirectory called
344 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700345 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800346 }
347
Anton Hansson53c88442019-03-18 15:53:16 +0000348 filterRRO := func(filter overlayType) android.Paths {
349 var paths android.Paths
350 for _, d := range app.rroDirs {
351 if d.overlayType == filter {
352 paths = append(paths, d.path)
353 }
354 }
Colin Crossa140bb02018-04-17 10:52:26 -0700355 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
356 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000357 return android.ReversePaths(paths)
358 }
359 deviceRRODirs := filterRRO(device)
360 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700361 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000362 }
363 productRRODirs := filterRRO(product)
364 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700365 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800366 }
367
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700368 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800369
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700370 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800371
Jiyong Parkf7487312019-10-17 12:54:30 +0900372 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800373
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800374 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700375 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700376
377 for _, jniLib := range app.installJniLibs {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700378 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Colin Crossa4f08812018-10-02 22:03:40 -0700379 }
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700380 if len(app.jniCoverageOutputs) > 0 {
381 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
382 }
Colin Cross43f08db2018-11-12 10:13:39 -0800383 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700384 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800385 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800386 for _, extra := range app.extraOutputFiles {
387 install := app.onDeviceDir + "/" + extra.Base()
388 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700389 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700390
391 entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", app.linter.outputs.transitiveHTMLZip)
392 entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", app.linter.outputs.transitiveTextZip)
393 entries.AddOptionalPath("LOCAL_SOONG_LINT_REPORTS", app.linter.outputs.transitiveXMLZip)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700394 },
395 },
396 ExtraFooters: []android.AndroidMkExtraFootersFunc{
397 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700398 if app.noticeOutputs.Merged.Valid() {
399 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
400 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
401 }
402 if app.noticeOutputs.TxtOutput.Valid() {
403 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
404 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
405 }
406 if app.noticeOutputs.HtmlOutput.Valid() {
407 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
408 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
409 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800410 },
411 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900412 }}
Colin Crossa97c5d32018-03-28 14:58:31 -0700413}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800414
Jaewoong Jung9109d722019-01-30 13:13:52 -0800415func (a *AndroidApp) getOverriddenPackages() []string {
416 var overridden []string
417 if len(a.appProperties.Overrides) > 0 {
418 overridden = append(overridden, a.appProperties.Overrides...)
419 }
420 if a.Name() != a.installApkName {
421 overridden = append(overridden, a.Name())
422 }
423 return overridden
424}
425
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900426func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
427 entriesList := a.AndroidApp.AndroidMkEntries()
428 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700429 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
430 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700431 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700432 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700433 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700434 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700435 })
436
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900437 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700438}
439
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900440func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
441 entriesList := a.AndroidApp.AndroidMkEntries()
442 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700443 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
444 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
445 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700446
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900447 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700448}
449
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900450func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900451 if !a.IsForPlatform() {
452 return []android.AndroidMkEntries{{
453 Disabled: true,
454 }}
455 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900456 entriesList := a.Library.AndroidMkEntries()
457 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700458
459 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700460 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700461 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700462 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700463
464 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700465 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700466 // Make base_rules.mk not put framework-res in a subdirectory called
467 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700468 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700469 }
470
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700471 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
472 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
473 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700474 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
475 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700476 })
477
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900478 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800479}
Nan Zhang581fd212018-01-10 16:06:12 -0800480
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900481func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
482 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800483 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800484 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700485 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700486 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
487 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700488 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700489 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800490 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800491 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700492 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800493 }
494 },
495 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900496 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800497}
498
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900499func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
500 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800501 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800502 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700503 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700504 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
505 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700506 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700507 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800508 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800509 if ddoc.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700510 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800511 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700512 },
513 },
514 ExtraFooters: []android.AndroidMkExtraFootersFunc{
515 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang61819ce2018-05-04 18:49:16 -0700516 if ddoc.checkCurrentApiTimestamp != nil {
517 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
518 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
519 ddoc.checkCurrentApiTimestamp.String())
520
521 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900522 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700523 ddoc.checkCurrentApiTimestamp.String())
524
525 fmt.Fprintln(w, ".PHONY: droidcore")
526 fmt.Fprintln(w, "droidcore: checkapi")
527 }
528 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700529 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700530 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
531 ddoc.updateCurrentApiTimestamp.String())
532
533 fmt.Fprintln(w, ".PHONY: update-api")
534 fmt.Fprintln(w, "update-api:",
535 ddoc.updateCurrentApiTimestamp.String())
536 }
537 if ddoc.checkLastReleasedApiTimestamp != nil {
538 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
539 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
540 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100541
Anton Hansson668b8a22020-05-26 18:07:10 +0100542 fmt.Fprintln(w, ".PHONY: checkapi")
543 fmt.Fprintln(w, "checkapi:",
544 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100545
Anton Hansson668b8a22020-05-26 18:07:10 +0100546 fmt.Fprintln(w, ".PHONY: droidcore")
547 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang61819ce2018-05-04 18:49:16 -0700548 }
Nan Zhang581fd212018-01-10 16:06:12 -0800549 },
550 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900551 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800552}
Colin Crossd96ca352018-08-10 16:06:24 -0700553
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900554func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100555 // If the stubsSrcJar is not generated (because generate_stubs is false) then
556 // use the api file as the output file to ensure the relevant phony targets
557 // are created in make if only the api txt file is being generated. This is
558 // needed because an invalid output file would prevent the make entries from
559 // being written.
560 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000561 distFile := dstubs.apiFile
Paul Duffin3ae29512020-04-08 18:18:03 +0100562 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
563 if !outputFile.Valid() {
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000564 outputFile = android.OptionalPathForPath(distFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100565 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900566 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700567 Class: "JAVA_LIBRARIES",
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000568 DistFiles: android.MakeDefaultDistFiles(distFile),
Paul Duffin3ae29512020-04-08 18:18:03 +0100569 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700570 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700571 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
572 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700573 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700574 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700575 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700576 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700577 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700578 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700579 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700580 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700581 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700582 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700583 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700584 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100585 if dstubs.metadataZip != nil {
586 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
587 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700588 },
589 },
590 ExtraFooters: []android.AndroidMkExtraFootersFunc{
591 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100592 if dstubs.apiFile != nil {
593 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
594 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
595 }
596 if dstubs.removedApiFile != nil {
597 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
598 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
599 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700600 if dstubs.checkCurrentApiTimestamp != nil {
601 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
602 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
603 dstubs.checkCurrentApiTimestamp.String())
604
605 fmt.Fprintln(w, ".PHONY: checkapi")
606 fmt.Fprintln(w, "checkapi:",
607 dstubs.checkCurrentApiTimestamp.String())
608
609 fmt.Fprintln(w, ".PHONY: droidcore")
610 fmt.Fprintln(w, "droidcore: checkapi")
611 }
612 if dstubs.updateCurrentApiTimestamp != nil {
613 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
614 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
615 dstubs.updateCurrentApiTimestamp.String())
616
617 fmt.Fprintln(w, ".PHONY: update-api")
618 fmt.Fprintln(w, "update-api:",
619 dstubs.updateCurrentApiTimestamp.String())
620 }
621 if dstubs.checkLastReleasedApiTimestamp != nil {
622 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
623 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
624 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100625
Makoto Onukia573f192020-04-21 11:52:39 -0700626 fmt.Fprintln(w, ".PHONY: checkapi")
627 fmt.Fprintln(w, "checkapi:",
628 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100629
Makoto Onukia573f192020-04-21 11:52:39 -0700630 fmt.Fprintln(w, ".PHONY: droidcore")
631 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700632 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200633 if dstubs.apiLintTimestamp != nil {
634 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
635 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
636 dstubs.apiLintTimestamp.String())
637
638 fmt.Fprintln(w, ".PHONY: checkapi")
639 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100640 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200641
642 fmt.Fprintln(w, ".PHONY: droidcore")
643 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100644
645 if dstubs.apiLintReport != nil {
646 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
647 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
648 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200649 }
Pete Gillin581d6082018-10-22 15:55:04 +0100650 if dstubs.checkNullabilityWarningsTimestamp != nil {
651 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
652 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
653 dstubs.checkNullabilityWarningsTimestamp.String())
654
655 fmt.Fprintln(w, ".PHONY:", "droidcore")
656 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
657 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700658 },
659 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900660 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700661}
662
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900663func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park592a6a42020-04-21 22:34:28 +0900664 if !a.IsForPlatform() {
665 // The non-platform variant is placed inside APEX. No reason to
666 // make it available to Make.
667 return nil
668 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900669 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700670 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700671 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700672 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700673 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
674 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900675 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800676 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700677 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
678 if len(a.dexpreopter.builtInstalled) > 0 {
679 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
680 }
681 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
682 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700683 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900684 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700685}
686
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900687func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
688 entriesList := a.AndroidAppImport.AndroidMkEntries()
689 entries := &entriesList[0]
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700690 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700691 testSuiteComponent(entries, a.testProperties.Test_suites)
692 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700693 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900694 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700695}
696
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700697func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700698 var testFiles []string
699 for _, d := range data {
700 testFiles = append(testFiles, d.String()+":"+d.Rel())
701 }
702 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
703}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800704
705func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
706 return []android.AndroidMkEntries{android.AndroidMkEntries{
707 Class: "ETC",
708 OutputFile: android.OptionalPathForPath(r.outputFile),
709 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
710 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
711 func(entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800712 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800713 entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath())
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700714 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800715 },
716 },
717 }}
718}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700719
720func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
721 return []android.AndroidMkEntries{
722 android.AndroidMkEntries{
723 Class: "APPS",
724 OutputFile: android.OptionalPathForPath(apkSet.packedOutput),
725 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
726 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
727 func(entries *android.AndroidMkEntries) {
728 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
729 entries.SetString("LOCAL_APK_SET_MASTER_FILE", apkSet.masterFile)
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700730 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700731 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
732 },
733 },
734 },
735 }
736}