blob: d428abdb1b6cd30f3fc1e47b9567568280e1338b [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()
Colin Cross56a83212020-09-15 18:30:11 -070026 if library.hideApexVariantFromMake {
Jiyong Park55bd98b2019-12-11 17:27:07 +090027 hostDexNeeded = false
Sundong Ahn054b19a2018-10-19 13:46:09 +090028 }
Jiyong Park55bd98b2019-12-11 17:27:07 +090029
30 if hostDexNeeded {
31 var output android.Path
32 if library.dexJarFile != nil {
33 output = library.dexJarFile
34 } else {
35 output = library.implementationAndResourcesJar
36 }
37 return android.AndroidMkEntries{
38 Class: "JAVA_LIBRARIES",
39 SubName: "-hostdex",
40 OutputFile: android.OptionalPathForPath(output),
41 Required: library.deviceProperties.Target.Hostdex.Required,
42 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
43 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
44 func(entries *android.AndroidMkEntries) {
45 entries.SetBool("LOCAL_IS_HOST_MODULE", true)
46 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
47 if library.dexJarFile != nil {
48 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
49 }
50 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
51 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
52 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
53 },
54 },
55 }
56 }
57 return android.AndroidMkEntries{Disabled: true}
Sundong Ahn054b19a2018-10-19 13:46:09 +090058}
59
Jiyong Park0b0e1b92019-12-03 13:24:29 +090060func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park55bd98b2019-12-11 17:27:07 +090061 var entriesList []android.AndroidMkEntries
62
Colin Cross56a83212020-09-15 18:30:11 -070063 if library.hideApexVariantFromMake {
64 // For a java library built for an APEX we don't need Make module
65 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
66 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
67 // Platform variant. If not available for the platform, we don't need Make module.
68 // May still need to add some additional dependencies.
Colin Crossb549b772020-06-03 17:14:31 +000069 checkedModulePaths := library.additionalCheckedModules
Colin Cross56a83212020-09-15 18:30:11 -070070 if len(checkedModulePaths) != 0 {
71 entriesList = append(entriesList, android.AndroidMkEntries{
Colin Crossb549b772020-06-03 17:14:31 +000072 Class: "FAKE",
73 // Need at least one output file in order for this to take effect.
74 OutputFile: android.OptionalPathForPath(checkedModulePaths[0]),
75 Include: "$(BUILD_PHONY_PACKAGE)",
76 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
77 func(entries *android.AndroidMkEntries) {
78 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", checkedModulePaths.Strings()...)
79 },
80 },
Colin Cross56a83212020-09-15 18:30:11 -070081 })
82 } else {
83 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000084 }
85 } else {
Colin Cross56a83212020-09-15 18:30:11 -070086 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090087 Class: "JAVA_LIBRARIES",
Jingwen Chen40fd90a2020-06-15 05:24:19 +000088 DistFiles: library.distFiles,
Jiyong Park55bd98b2019-12-11 17:27:07 +090089 OutputFile: android.OptionalPathForPath(library.outputFile),
90 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
91 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
92 func(entries *android.AndroidMkEntries) {
93 if len(library.logtagsSrcs) > 0 {
94 var logtags []string
95 for _, l := range library.logtagsSrcs {
96 logtags = append(logtags, l.Rel())
97 }
98 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080099 }
Colin Cross5beccee2017-12-07 15:28:59 -0800100
Jiyong Park55bd98b2019-12-11 17:27:07 +0900101 if library.installFile == nil {
102 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
103 }
104 if library.dexJarFile != nil {
105 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
106 }
107 if len(library.dexpreopter.builtInstalled) > 0 {
108 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
109 }
Jiyong Park6a927c42020-01-21 02:03:43 +0900110 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion().raw)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900111 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
112 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800113
Jiyong Park55bd98b2019-12-11 17:27:07 +0900114 if library.jacocoReportClassesFile != nil {
115 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
116 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800117
Ulya Trafimovich8cbc5d22020-11-03 15:15:46 +0000118 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs.UsesLibs()...)
Jiyong Park1be96912018-05-28 18:02:19 +0900119
Colin Crossb549b772020-06-03 17:14:31 +0000120 if len(library.additionalCheckedModules) != 0 {
121 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
122 }
123
Colin Crosscb6143a2020-08-14 17:39:29 -0700124 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
125 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900126 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700127
Colin Cross08dca382020-07-21 20:31:17 -0700128 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900129 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700130 },
Colin Cross56a83212020-09-15 18:30:11 -0700131 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900132 }
133
Colin Cross56a83212020-09-15 18:30:11 -0700134 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900135
Jiyong Park55bd98b2019-12-11 17:27:07 +0900136 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700137}
138
Paul Duffin42df1442019-03-20 12:45:53 +0000139// Called for modules that are a component of a test suite.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700140func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700141 entries.SetString("LOCAL_MODULE_TAGS", "tests")
142 if len(test_suites) > 0 {
143 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...)
144 } else {
145 entries.SetString("LOCAL_COMPATIBILITY_SUITE", "null-suite")
146 }
147}
148
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900149func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
150 entriesList := j.Library.AndroidMkEntries()
151 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700152 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
153 testSuiteComponent(entries, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700154 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700155 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700156 }
Dan Shi95d19422020-08-15 12:24:26 -0700157 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700158 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800159 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
160 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
161 }
kellyhung74b00522020-08-17 18:46:00 +0800162 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Dan Shid79572f2020-11-13 14:33:46 -0800163 if Bool(j.testProperties.Test_options.Unit_test) {
164 entries.SetBool("LOCAL_IS_UNIT_TEST", true)
165 }
Colin Cross05638fc2018-04-09 18:40:24 -0700166 })
167
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900168 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700169}
170
Dan Shi95d19422020-08-15 12:24:26 -0700171func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
172 if len(extraTestConfigs) > 0 {
173 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
174 }
175}
176
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900177func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
178 entriesList := j.Library.AndroidMkEntries()
179 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700180 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
181 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
Paul Duffin42df1442019-03-20 12:45:53 +0000182 })
183
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900184 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000185}
186
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900187func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700188 if prebuilt.hideApexVariantFromMake || !prebuilt.ContainingSdk().Unversioned() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900189 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900190 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900191 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900192 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900193 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700194 Class: "JAVA_LIBRARIES",
195 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700196 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700197 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
198 func(entries *android.AndroidMkEntries) {
199 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
200 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
201 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Liz Kammer2d2fd852020-08-12 14:42:30 -0700202 entries.SetString("LOCAL_SDK_VERSION", prebuilt.makeSdkVersion())
Jiyong Park0b238752019-10-29 11:23:10 +0900203 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700204 },
205 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900206 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700207}
Colin Cross10a03492017-08-10 17:09:43 -0700208
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900209func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700210 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900211 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900212 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900213 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900214 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900215 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800216 Class: "JAVA_LIBRARIES",
217 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
218 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700219 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
220 func(entries *android.AndroidMkEntries) {
Colin Cross42be7612019-02-21 18:12:14 -0800221 if prebuilt.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700222 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800223 }
224 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700225 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800226 }
Jiyong Park0b238752019-10-29 11:23:10 +0900227 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800228 },
229 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900230 }}
Colin Cross42be7612019-02-21 18:12:14 -0800231}
232
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900233func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700234 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900235 return []android.AndroidMkEntries{{
236 Disabled: true,
237 }}
238 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900239 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800240 Class: "JAVA_LIBRARIES",
241 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
242 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700243 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
244 func(entries *android.AndroidMkEntries) {
245 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
246 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
247 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
248 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
249 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
250 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
251 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park6a927c42020-01-21 02:03:43 +0900252 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion().raw)
Colin Crossfabb6082018-02-20 17:22:23 -0800253 },
254 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900255 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800256}
257
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900258func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross10a03492017-08-10 17:09:43 -0700259
Colin Cross6b4a32d2017-12-05 13:42:45 -0800260 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900261 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800262 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700263 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800264 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700265 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
266 func(entries *android.AndroidMkEntries) {
267 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
268 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Colin Cross12fc2af2019-01-14 12:35:45 -0800269 if binary.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700270 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
Colin Cross12fc2af2019-01-14 12:35:45 -0800271 }
272 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700273 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800274 }
Colin Cross331a1212018-08-15 20:40:52 -0700275 },
276 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700277 ExtraFooters: []android.AndroidMkExtraFootersFunc{
278 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
279 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
280 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800281 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900282 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800283 } else {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900284 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800285 Class: "EXECUTABLES",
286 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700287 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
288 func(entries *android.AndroidMkEntries) {
289 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800290 },
291 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700292 ExtraFooters: []android.AndroidMkExtraFootersFunc{
293 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
294 // Ensure that the wrapper script timestamp is always updated when the jar is updated
295 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
296 fmt.Fprintln(w, "jar_installed_module :=")
297 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800298 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900299 }}
Colin Cross10a03492017-08-10 17:09:43 -0700300 }
301}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800302
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900303func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700304 if app.hideApexVariantFromMake || app.appProperties.HideFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900305 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900306 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900307 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900308 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900309 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800310 Class: "APPS",
311 OutputFile: android.OptionalPathForPath(app.outputFile),
312 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700313 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
314 func(entries *android.AndroidMkEntries) {
315 // App module names can be overridden.
316 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700317 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700318 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800319 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700320 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800321 }
Colin Cross331a1212018-08-15 20:40:52 -0700322 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700323 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800324 }
325 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700326 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800327 }
Colin Crossf6237212018-10-29 23:14:58 -0700328 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700329 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700330 }
Colin Cross70798562017-12-13 22:42:59 -0800331 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700332 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800333 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700334 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
335 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800336
337 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700338 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800339 // Make base_rules.mk not put framework-res in a subdirectory called
340 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700341 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800342 }
343
Anton Hansson53c88442019-03-18 15:53:16 +0000344 filterRRO := func(filter overlayType) android.Paths {
345 var paths android.Paths
346 for _, d := range app.rroDirs {
347 if d.overlayType == filter {
348 paths = append(paths, d.path)
349 }
350 }
Colin Crossa140bb02018-04-17 10:52:26 -0700351 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
352 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000353 return android.ReversePaths(paths)
354 }
355 deviceRRODirs := filterRRO(device)
356 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700357 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000358 }
359 productRRODirs := filterRRO(product)
360 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700361 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800362 }
363
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700364 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800365
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700366 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800367
Jiyong Parkf7487312019-10-17 12:54:30 +0900368 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800369
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800370 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700371 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700372
Colin Cross403cc152020-07-06 14:15:24 -0700373 if app.embeddedJniLibs {
374 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
375 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
376 } else {
377 for _, jniLib := range app.jniLibs {
378 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
379 }
Colin Crossa4f08812018-10-02 22:03:40 -0700380 }
Colin Cross403cc152020-07-06 14:15:24 -0700381
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700382 if len(app.jniCoverageOutputs) > 0 {
383 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
384 }
Colin Cross43f08db2018-11-12 10:13:39 -0800385 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700386 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800387 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800388 for _, extra := range app.extraOutputFiles {
389 install := app.onDeviceDir + "/" + extra.Base()
390 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700391 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700392
Colin Cross08dca382020-07-21 20:31:17 -0700393 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
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 }
Dan Shi95d19422020-08-15 12:24:26 -0700434 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700435 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800436 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700437 })
438
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900439 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700440}
441
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900442func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
443 entriesList := a.AndroidApp.AndroidMkEntries()
444 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700445 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
446 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
447 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700448
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900449 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700450}
451
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900452func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700453 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900454 return []android.AndroidMkEntries{{
455 Disabled: true,
456 }}
457 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900458 entriesList := a.Library.AndroidMkEntries()
459 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700460
461 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700462 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700463 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700464 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700465
466 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700467 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700468 // Make base_rules.mk not put framework-res in a subdirectory called
469 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700470 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700471 }
472
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700473 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
474 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
475 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700476 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
477 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700478 })
479
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900480 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800481}
Nan Zhang581fd212018-01-10 16:06:12 -0800482
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900483func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
484 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800485 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800486 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700487 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700488 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
489 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700490 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700491 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800492 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800493 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700494 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800495 }
496 },
497 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900498 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800499}
500
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900501func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
502 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800503 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000504 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700505 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700506 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
507 func(entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000508 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700509 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800510 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000511 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800512 },
513 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900514 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800515}
Colin Crossd96ca352018-08-10 16:06:24 -0700516
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900517func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100518 // If the stubsSrcJar is not generated (because generate_stubs is false) then
519 // use the api file as the output file to ensure the relevant phony targets
520 // are created in make if only the api txt file is being generated. This is
521 // needed because an invalid output file would prevent the make entries from
522 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000523 //
524 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100525 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000526
527 var distFiles android.TaggedDistFiles
528 if dstubs.apiFile != nil {
529 distFiles = android.MakeDefaultDistFiles(dstubs.apiFile)
530 }
Paul Duffin3ae29512020-04-08 18:18:03 +0100531 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
532 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000533 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100534 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900535 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700536 Class: "JAVA_LIBRARIES",
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000537 DistFiles: distFiles,
Paul Duffin3ae29512020-04-08 18:18:03 +0100538 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700539 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700540 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
541 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700542 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700543 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700544 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700545 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700546 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700547 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700548 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700549 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700550 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100551 if dstubs.metadataZip != nil {
552 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
553 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700554 },
555 },
556 ExtraFooters: []android.AndroidMkExtraFootersFunc{
557 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100558 if dstubs.apiFile != nil {
559 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
560 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
561 }
562 if dstubs.removedApiFile != nil {
563 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
564 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
565 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700566 if dstubs.checkCurrentApiTimestamp != nil {
567 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
568 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
569 dstubs.checkCurrentApiTimestamp.String())
570
571 fmt.Fprintln(w, ".PHONY: checkapi")
572 fmt.Fprintln(w, "checkapi:",
573 dstubs.checkCurrentApiTimestamp.String())
574
575 fmt.Fprintln(w, ".PHONY: droidcore")
576 fmt.Fprintln(w, "droidcore: checkapi")
577 }
578 if dstubs.updateCurrentApiTimestamp != nil {
579 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
580 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
581 dstubs.updateCurrentApiTimestamp.String())
582
583 fmt.Fprintln(w, ".PHONY: update-api")
584 fmt.Fprintln(w, "update-api:",
585 dstubs.updateCurrentApiTimestamp.String())
586 }
587 if dstubs.checkLastReleasedApiTimestamp != nil {
588 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
589 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
590 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100591
Makoto Onukia573f192020-04-21 11:52:39 -0700592 fmt.Fprintln(w, ".PHONY: checkapi")
593 fmt.Fprintln(w, "checkapi:",
594 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100595
Makoto Onukia573f192020-04-21 11:52:39 -0700596 fmt.Fprintln(w, ".PHONY: droidcore")
597 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700598 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200599 if dstubs.apiLintTimestamp != nil {
600 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
601 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
602 dstubs.apiLintTimestamp.String())
603
604 fmt.Fprintln(w, ".PHONY: checkapi")
605 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100606 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200607
608 fmt.Fprintln(w, ".PHONY: droidcore")
609 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100610
611 if dstubs.apiLintReport != nil {
612 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
613 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
614 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200615 }
Pete Gillin581d6082018-10-22 15:55:04 +0100616 if dstubs.checkNullabilityWarningsTimestamp != nil {
617 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
618 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
619 dstubs.checkNullabilityWarningsTimestamp.String())
620
621 fmt.Fprintln(w, ".PHONY:", "droidcore")
622 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
623 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700624 },
625 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900626 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700627}
628
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900629func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700630 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900631 // The non-platform variant is placed inside APEX. No reason to
632 // make it available to Make.
633 return nil
634 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900635 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700636 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700637 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700638 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700639 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
640 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900641 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800642 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700643 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
644 if len(a.dexpreopter.builtInstalled) > 0 {
645 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
646 }
647 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
648 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700649 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900650 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700651}
652
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900653func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
654 entriesList := a.AndroidAppImport.AndroidMkEntries()
655 entries := &entriesList[0]
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700656 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700657 testSuiteComponent(entries, a.testProperties.Test_suites)
658 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700659 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900660 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700661}
662
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700663func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700664 var testFiles []string
665 for _, d := range data {
666 testFiles = append(testFiles, d.String()+":"+d.Rel())
667 }
668 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
669}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800670
671func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
672 return []android.AndroidMkEntries{android.AndroidMkEntries{
673 Class: "ETC",
674 OutputFile: android.OptionalPathForPath(r.outputFile),
675 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
676 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
677 func(entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800678 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800679 entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath())
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700680 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800681 },
682 },
683 }}
684}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700685
686func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
687 return []android.AndroidMkEntries{
688 android.AndroidMkEntries{
689 Class: "APPS",
690 OutputFile: android.OptionalPathForPath(apkSet.packedOutput),
691 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
692 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
693 func(entries *android.AndroidMkEntries) {
694 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Liz Kammercada8072020-07-28 15:47:38 -0700695 entries.SetString("LOCAL_APK_SET_INSTALL_FILE", apkSet.InstallFile())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700696 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700697 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
698 },
699 },
700 },
701 }
702}