blob: 9d5885fb138a711955c3c7305e4ecff0d30ea052 [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
Ulya Trafimovichb8063c62020-08-20 11:33:12 +0100124 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", android.SortedStringKeys(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
Colin Crosscb6143a2020-08-14 17:39:29 -0700130 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
131 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900132 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700133
Colin Cross08dca382020-07-21 20:31:17 -0700134 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900135 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700136 },
Jiyong Park55bd98b2019-12-11 17:27:07 +0900137 }
138 }
139
140 hostDexEntries := library.AndroidMkEntriesHostDex()
141
142 entriesList = append(entriesList, mainEntries, hostDexEntries)
143 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700144}
145
Paul Duffin42df1442019-03-20 12:45:53 +0000146// Called for modules that are a component of a test suite.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700147func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700148 entries.SetString("LOCAL_MODULE_TAGS", "tests")
149 if len(test_suites) > 0 {
150 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...)
151 } else {
152 entries.SetString("LOCAL_COMPATIBILITY_SUITE", "null-suite")
153 }
154}
155
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900156func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
157 entriesList := j.Library.AndroidMkEntries()
158 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700159 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
160 testSuiteComponent(entries, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700161 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700162 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700163 }
Dan Shi95d19422020-08-15 12:24:26 -0700164 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700165 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800166 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
167 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
168 }
Colin Cross05638fc2018-04-09 18:40:24 -0700169 })
170
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900171 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700172}
173
Dan Shi95d19422020-08-15 12:24:26 -0700174func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
175 if len(extraTestConfigs) > 0 {
176 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
177 }
178}
179
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900180func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
181 entriesList := j.Library.AndroidMkEntries()
182 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700183 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
184 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
Paul Duffin42df1442019-03-20 12:45:53 +0000185 })
186
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900187 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000188}
189
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900190func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park9b409bc2019-10-11 14:59:13 +0900191 if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900192 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900193 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900194 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900195 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900196 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700197 Class: "JAVA_LIBRARIES",
198 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700199 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700200 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
201 func(entries *android.AndroidMkEntries) {
202 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
203 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
204 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Liz Kammer2d2fd852020-08-12 14:42:30 -0700205 entries.SetString("LOCAL_SDK_VERSION", prebuilt.makeSdkVersion())
Jiyong Park0b238752019-10-29 11:23:10 +0900206 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700207 },
208 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900209 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700210}
Colin Cross10a03492017-08-10 17:09:43 -0700211
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900212func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park7f7766d2019-07-25 22:02:35 +0900213 if !prebuilt.IsForPlatform() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900214 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900215 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900216 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900217 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900218 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800219 Class: "JAVA_LIBRARIES",
220 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
221 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700222 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
223 func(entries *android.AndroidMkEntries) {
Colin Cross42be7612019-02-21 18:12:14 -0800224 if prebuilt.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700225 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800226 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
227 // boot_jars_package_check.mk can check dex jars.
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700228 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.dexJarFile)
229 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800230 }
231 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700232 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800233 }
Jiyong Park0b238752019-10-29 11:23:10 +0900234 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800235 },
236 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900237 }}
Colin Cross42be7612019-02-21 18:12:14 -0800238}
239
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900240func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900241 if !prebuilt.IsForPlatform() {
242 return []android.AndroidMkEntries{{
243 Disabled: true,
244 }}
245 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900246 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800247 Class: "JAVA_LIBRARIES",
248 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
249 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700250 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
251 func(entries *android.AndroidMkEntries) {
252 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
253 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
254 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
255 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
256 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
257 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
258 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park6a927c42020-01-21 02:03:43 +0900259 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion().raw)
Colin Crossfabb6082018-02-20 17:22:23 -0800260 },
261 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900262 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800263}
264
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900265func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross10a03492017-08-10 17:09:43 -0700266
Colin Cross6b4a32d2017-12-05 13:42:45 -0800267 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900268 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800269 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700270 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800271 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700272 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
273 func(entries *android.AndroidMkEntries) {
274 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
275 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Colin Cross12fc2af2019-01-14 12:35:45 -0800276 if binary.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700277 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
Colin Cross12fc2af2019-01-14 12:35:45 -0800278 }
279 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700280 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800281 }
Colin Cross331a1212018-08-15 20:40:52 -0700282 },
283 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700284 ExtraFooters: []android.AndroidMkExtraFootersFunc{
285 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
286 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
287 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800288 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900289 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800290 } else {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900291 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800292 Class: "EXECUTABLES",
293 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700294 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
295 func(entries *android.AndroidMkEntries) {
296 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800297 },
298 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700299 ExtraFooters: []android.AndroidMkExtraFootersFunc{
300 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
301 // Ensure that the wrapper script timestamp is always updated when the jar is updated
302 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
303 fmt.Fprintln(w, "jar_installed_module :=")
304 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800305 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900306 }}
Colin Cross10a03492017-08-10 17:09:43 -0700307 }
308}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800309
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900310func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700311 if !app.IsForPlatform() || app.appProperties.HideFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900312 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900313 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900314 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900315 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900316 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800317 Class: "APPS",
318 OutputFile: android.OptionalPathForPath(app.outputFile),
319 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700320 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
321 func(entries *android.AndroidMkEntries) {
322 // App module names can be overridden.
323 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700324 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700325 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800326 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700327 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800328 }
Colin Cross331a1212018-08-15 20:40:52 -0700329 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700330 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800331 }
332 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700333 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800334 }
Colin Crossf6237212018-10-29 23:14:58 -0700335 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700336 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700337 }
Colin Cross70798562017-12-13 22:42:59 -0800338 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700339 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800340 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700341 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
342 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800343
344 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700345 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800346 // Make base_rules.mk not put framework-res in a subdirectory called
347 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700348 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800349 }
350
Anton Hansson53c88442019-03-18 15:53:16 +0000351 filterRRO := func(filter overlayType) android.Paths {
352 var paths android.Paths
353 for _, d := range app.rroDirs {
354 if d.overlayType == filter {
355 paths = append(paths, d.path)
356 }
357 }
Colin Crossa140bb02018-04-17 10:52:26 -0700358 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
359 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000360 return android.ReversePaths(paths)
361 }
362 deviceRRODirs := filterRRO(device)
363 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700364 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000365 }
366 productRRODirs := filterRRO(product)
367 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700368 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800369 }
370
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700371 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800372
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700373 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800374
Jiyong Parkf7487312019-10-17 12:54:30 +0900375 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800376
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800377 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700378 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700379
Colin Cross403cc152020-07-06 14:15:24 -0700380 if app.embeddedJniLibs {
381 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
382 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
383 } else {
384 for _, jniLib := range app.jniLibs {
385 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
386 }
Colin Crossa4f08812018-10-02 22:03:40 -0700387 }
Colin Cross403cc152020-07-06 14:15:24 -0700388
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700389 if len(app.jniCoverageOutputs) > 0 {
390 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
391 }
Colin Cross43f08db2018-11-12 10:13:39 -0800392 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700393 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800394 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800395 for _, extra := range app.extraOutputFiles {
396 install := app.onDeviceDir + "/" + extra.Base()
397 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700398 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700399
Colin Cross08dca382020-07-21 20:31:17 -0700400 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700401 },
402 },
403 ExtraFooters: []android.AndroidMkExtraFootersFunc{
404 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700405 if app.noticeOutputs.Merged.Valid() {
406 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
407 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
408 }
409 if app.noticeOutputs.TxtOutput.Valid() {
410 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
411 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
412 }
413 if app.noticeOutputs.HtmlOutput.Valid() {
414 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
415 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
416 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800417 },
418 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900419 }}
Colin Crossa97c5d32018-03-28 14:58:31 -0700420}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800421
Jaewoong Jung9109d722019-01-30 13:13:52 -0800422func (a *AndroidApp) getOverriddenPackages() []string {
423 var overridden []string
424 if len(a.appProperties.Overrides) > 0 {
425 overridden = append(overridden, a.appProperties.Overrides...)
426 }
427 if a.Name() != a.installApkName {
428 overridden = append(overridden, a.Name())
429 }
430 return overridden
431}
432
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900433func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
434 entriesList := a.AndroidApp.AndroidMkEntries()
435 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700436 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
437 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700438 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700439 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700440 }
Dan Shi95d19422020-08-15 12:24:26 -0700441 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700442 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700443 })
444
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900445 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700446}
447
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900448func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
449 entriesList := a.AndroidApp.AndroidMkEntries()
450 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700451 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
452 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
453 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700454
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900455 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700456}
457
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900458func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900459 if !a.IsForPlatform() {
460 return []android.AndroidMkEntries{{
461 Disabled: true,
462 }}
463 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900464 entriesList := a.Library.AndroidMkEntries()
465 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700466
467 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700468 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700469 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700470 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700471
472 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700473 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700474 // Make base_rules.mk not put framework-res in a subdirectory called
475 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700476 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700477 }
478
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700479 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
480 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
481 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700482 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
483 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700484 })
485
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900486 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800487}
Nan Zhang581fd212018-01-10 16:06:12 -0800488
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900489func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
490 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800491 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800492 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700493 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700494 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
495 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700496 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700497 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800498 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800499 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700500 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800501 }
502 },
503 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900504 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800505}
506
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900507func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
508 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800509 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000510 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700511 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700512 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
513 func(entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000514 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700515 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800516 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000517 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800518 },
519 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900520 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800521}
Colin Crossd96ca352018-08-10 16:06:24 -0700522
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900523func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100524 // If the stubsSrcJar is not generated (because generate_stubs is false) then
525 // use the api file as the output file to ensure the relevant phony targets
526 // are created in make if only the api txt file is being generated. This is
527 // needed because an invalid output file would prevent the make entries from
528 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000529 //
530 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100531 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000532
533 var distFiles android.TaggedDistFiles
534 if dstubs.apiFile != nil {
535 distFiles = android.MakeDefaultDistFiles(dstubs.apiFile)
536 }
Paul Duffin3ae29512020-04-08 18:18:03 +0100537 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
538 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000539 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100540 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900541 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700542 Class: "JAVA_LIBRARIES",
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000543 DistFiles: distFiles,
Paul Duffin3ae29512020-04-08 18:18:03 +0100544 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700545 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700546 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
547 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700548 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700549 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700550 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700551 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700552 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700553 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700554 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700555 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700556 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700557 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700558 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700559 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100560 if dstubs.metadataZip != nil {
561 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
562 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700563 },
564 },
565 ExtraFooters: []android.AndroidMkExtraFootersFunc{
566 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100567 if dstubs.apiFile != nil {
568 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
569 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
570 }
571 if dstubs.removedApiFile != nil {
572 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
573 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
574 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700575 if dstubs.checkCurrentApiTimestamp != nil {
576 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
577 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
578 dstubs.checkCurrentApiTimestamp.String())
579
580 fmt.Fprintln(w, ".PHONY: checkapi")
581 fmt.Fprintln(w, "checkapi:",
582 dstubs.checkCurrentApiTimestamp.String())
583
584 fmt.Fprintln(w, ".PHONY: droidcore")
585 fmt.Fprintln(w, "droidcore: checkapi")
586 }
587 if dstubs.updateCurrentApiTimestamp != nil {
588 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
589 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
590 dstubs.updateCurrentApiTimestamp.String())
591
592 fmt.Fprintln(w, ".PHONY: update-api")
593 fmt.Fprintln(w, "update-api:",
594 dstubs.updateCurrentApiTimestamp.String())
595 }
596 if dstubs.checkLastReleasedApiTimestamp != nil {
597 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
598 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
599 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100600
Makoto Onukia573f192020-04-21 11:52:39 -0700601 fmt.Fprintln(w, ".PHONY: checkapi")
602 fmt.Fprintln(w, "checkapi:",
603 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100604
Makoto Onukia573f192020-04-21 11:52:39 -0700605 fmt.Fprintln(w, ".PHONY: droidcore")
606 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700607 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200608 if dstubs.apiLintTimestamp != nil {
609 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
610 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
611 dstubs.apiLintTimestamp.String())
612
613 fmt.Fprintln(w, ".PHONY: checkapi")
614 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100615 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200616
617 fmt.Fprintln(w, ".PHONY: droidcore")
618 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100619
620 if dstubs.apiLintReport != nil {
621 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
622 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
623 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200624 }
Pete Gillin581d6082018-10-22 15:55:04 +0100625 if dstubs.checkNullabilityWarningsTimestamp != nil {
626 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
627 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
628 dstubs.checkNullabilityWarningsTimestamp.String())
629
630 fmt.Fprintln(w, ".PHONY:", "droidcore")
631 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
632 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700633 },
634 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900635 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700636}
637
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900638func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park592a6a42020-04-21 22:34:28 +0900639 if !a.IsForPlatform() {
640 // The non-platform variant is placed inside APEX. No reason to
641 // make it available to Make.
642 return nil
643 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900644 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700645 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700646 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700647 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700648 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
649 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900650 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800651 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700652 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
653 if len(a.dexpreopter.builtInstalled) > 0 {
654 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
655 }
656 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
657 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700658 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900659 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700660}
661
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900662func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
663 entriesList := a.AndroidAppImport.AndroidMkEntries()
664 entries := &entriesList[0]
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700665 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700666 testSuiteComponent(entries, a.testProperties.Test_suites)
667 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700668 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900669 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700670}
671
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700672func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700673 var testFiles []string
674 for _, d := range data {
675 testFiles = append(testFiles, d.String()+":"+d.Rel())
676 }
677 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
678}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800679
680func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
681 return []android.AndroidMkEntries{android.AndroidMkEntries{
682 Class: "ETC",
683 OutputFile: android.OptionalPathForPath(r.outputFile),
684 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
685 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
686 func(entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800687 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800688 entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath())
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700689 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800690 },
691 },
692 }}
693}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700694
695func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
696 return []android.AndroidMkEntries{
697 android.AndroidMkEntries{
698 Class: "APPS",
699 OutputFile: android.OptionalPathForPath(apkSet.packedOutput),
700 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
701 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
702 func(entries *android.AndroidMkEntries) {
703 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Liz Kammercada8072020-07-28 15:47:38 -0700704 entries.SetString("LOCAL_APK_SET_INSTALL_FILE", apkSet.InstallFile())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700705 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700706 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
707 },
708 },
709 },
710 }
711}