blob: 71370c9b1c725fda1f22e676ebacbba69ba039d0 [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{
Colin Crossaa255532020-07-03 13:18:24 -070044 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090045 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 {
Jiakai Zhang519c5c82021-09-16 06:15:39 +000064 // For a java library built for an APEX, we don't need a Make module for itself. Otherwise, it
65 // will conflict with the platform variant because they have the same module name in the
66 // makefile. However, we need to add its dexpreopt outputs as sub-modules, if it is preopted.
67 dexpreoptEntries := library.dexpreopter.AndroidMkEntriesForApex()
68 if len(dexpreoptEntries) > 0 {
69 entriesList = append(entriesList, dexpreoptEntries...)
70 }
Colin Cross56a83212020-09-15 18:30:11 -070071 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
72 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
73 // Platform variant. If not available for the platform, we don't need Make module.
74 // May still need to add some additional dependencies.
Colin Crossb549b772020-06-03 17:14:31 +000075 checkedModulePaths := library.additionalCheckedModules
Colin Cross56a83212020-09-15 18:30:11 -070076 if len(checkedModulePaths) != 0 {
77 entriesList = append(entriesList, android.AndroidMkEntries{
Colin Crossb549b772020-06-03 17:14:31 +000078 Class: "FAKE",
79 // Need at least one output file in order for this to take effect.
80 OutputFile: android.OptionalPathForPath(checkedModulePaths[0]),
81 Include: "$(BUILD_PHONY_PACKAGE)",
82 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070083 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossb549b772020-06-03 17:14:31 +000084 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", checkedModulePaths.Strings()...)
85 },
86 },
Colin Cross56a83212020-09-15 18:30:11 -070087 })
88 } else {
89 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000090 }
91 } else {
Colin Cross56a83212020-09-15 18:30:11 -070092 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090093 Class: "JAVA_LIBRARIES",
94 OutputFile: android.OptionalPathForPath(library.outputFile),
95 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
96 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070097 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090098 if len(library.logtagsSrcs) > 0 {
99 var logtags []string
100 for _, l := range library.logtagsSrcs {
101 logtags = append(logtags, l.Rel())
102 }
103 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -0800104 }
Colin Cross5beccee2017-12-07 15:28:59 -0800105
Jiyong Park55bd98b2019-12-11 17:27:07 +0900106 if library.installFile == nil {
107 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
108 }
109 if library.dexJarFile != nil {
110 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
111 }
112 if len(library.dexpreopter.builtInstalled) > 0 {
113 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
114 }
Jiyong Park92315372021-04-02 08:45:46 +0900115 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900116 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
117 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800118
Jiyong Park55bd98b2019-12-11 17:27:07 +0900119 if library.jacocoReportClassesFile != nil {
120 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
121 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800122
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100123 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
124 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
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)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000135
136 if library.dexpreopter.configPath != nil {
137 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
138 }
Jiyong Park55bd98b2019-12-11 17:27:07 +0900139 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700140 },
Colin Cross56a83212020-09-15 18:30:11 -0700141 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900142 }
143
Colin Cross56a83212020-09-15 18:30:11 -0700144 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900145
Jiyong Park55bd98b2019-12-11 17:27:07 +0900146 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 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800153 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700154 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800155 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700156 }
157}
158
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900159func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
160 entriesList := j.Library.AndroidMkEntries()
161 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700162 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700163 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 }
Dan Shi95d19422020-08-15 12:24:26 -0700167 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700168 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800169 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
170 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
171 }
kellyhung74b00522020-08-17 18:46:00 +0800172 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Dan Shid79572f2020-11-13 14:33:46 -0800173 if Bool(j.testProperties.Test_options.Unit_test) {
174 entries.SetBool("LOCAL_IS_UNIT_TEST", true)
175 }
Colin Cross05638fc2018-04-09 18:40:24 -0700176 })
177
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900178 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700179}
180
Dan Shi95d19422020-08-15 12:24:26 -0700181func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
182 if len(extraTestConfigs) > 0 {
183 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
184 }
185}
186
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900187func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
188 entriesList := j.Library.AndroidMkEntries()
189 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700190 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700191 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
Paul Duffin42df1442019-03-20 12:45:53 +0000192 })
193
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900194 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000195}
196
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900197func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700198 if prebuilt.hideApexVariantFromMake || !prebuilt.ContainingSdk().Unversioned() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900199 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900200 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900201 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900202 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900203 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700204 Class: "JAVA_LIBRARIES",
205 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700206 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700207 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700208 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700209 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Bill Peckhamfb04df42021-01-11 12:27:24 -0800210 if prebuilt.dexJarFile != nil {
211 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
212 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700213 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
214 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park92315372021-04-02 08:45:46 +0900215 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900216 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700217 },
218 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900219 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700220}
Colin Cross10a03492017-08-10 17:09:43 -0700221
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900222func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700223 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900224 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900225 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900226 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900227 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900228 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800229 Class: "JAVA_LIBRARIES",
Colin Crossb014f072021-02-26 14:54:36 -0800230 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile),
Colin Cross42be7612019-02-21 18:12:14 -0800231 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700232 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700233 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross42be7612019-02-21 18:12:14 -0800234 if prebuilt.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700235 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800236 }
237 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700238 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800239 }
Jiyong Park0b238752019-10-29 11:23:10 +0900240 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800241 },
242 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900243 }}
Colin Cross42be7612019-02-21 18:12:14 -0800244}
245
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900246func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700247 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900248 return []android.AndroidMkEntries{{
249 Disabled: true,
250 }}
251 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900252 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800253 Class: "JAVA_LIBRARIES",
254 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
255 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700256 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700257 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700258 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
259 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
260 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
261 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
262 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
263 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
264 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900265 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800266 },
267 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900268 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800269}
270
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900271func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross10a03492017-08-10 17:09:43 -0700272
Colin Cross6b4a32d2017-12-05 13:42:45 -0800273 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900274 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800275 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700276 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800277 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700278 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700279 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700280 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
281 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Colin Cross12fc2af2019-01-14 12:35:45 -0800282 if binary.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700283 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
Colin Cross12fc2af2019-01-14 12:35:45 -0800284 }
285 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700286 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800287 }
Colin Cross331a1212018-08-15 20:40:52 -0700288 },
289 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700290 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800291 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700292 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
293 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800294 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900295 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800296 } else {
Colin Cross44b85d02021-02-19 17:37:04 -0800297 outputFile := binary.wrapperFile
298 // Have Make installation trigger Soong installation by using Soong's install path as
299 // the output file.
300 if binary.Host() {
301 outputFile = binary.binaryFile
302 }
303
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900304 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800305 Class: "EXECUTABLES",
Colin Cross44b85d02021-02-19 17:37:04 -0800306 OutputFile: android.OptionalPathForPath(outputFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700307 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700308 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700309 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800310 },
311 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700312 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800313 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700314 // Ensure that the wrapper script timestamp is always updated when the jar is updated
315 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
316 fmt.Fprintln(w, "jar_installed_module :=")
317 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800318 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900319 }}
Colin Cross10a03492017-08-10 17:09:43 -0700320 }
321}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800322
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900323func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700324 if app.hideApexVariantFromMake || app.appProperties.HideFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900325 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900326 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900327 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900328 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900329 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800330 Class: "APPS",
331 OutputFile: android.OptionalPathForPath(app.outputFile),
332 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700333 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700334 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700335 // App module names can be overridden.
336 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700337 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700338 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800339 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700340 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800341 }
Colin Cross331a1212018-08-15 20:40:52 -0700342 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700343 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800344 }
345 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700346 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800347 }
Colin Crossf6237212018-10-29 23:14:58 -0700348 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700349 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700350 }
Colin Cross70798562017-12-13 22:42:59 -0800351 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700352 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800353 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700354 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
355 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800356
357 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700358 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800359 // Make base_rules.mk not put framework-res in a subdirectory called
360 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700361 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800362 }
363
Anton Hansson53c88442019-03-18 15:53:16 +0000364 filterRRO := func(filter overlayType) android.Paths {
365 var paths android.Paths
366 for _, d := range app.rroDirs {
367 if d.overlayType == filter {
368 paths = append(paths, d.path)
369 }
370 }
Colin Crossa140bb02018-04-17 10:52:26 -0700371 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
372 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000373 return android.ReversePaths(paths)
374 }
375 deviceRRODirs := filterRRO(device)
376 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700377 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000378 }
379 productRRODirs := filterRRO(product)
380 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700381 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800382 }
383
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700384 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800385
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700386 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800387
Jiyong Parkf7487312019-10-17 12:54:30 +0900388 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800389
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800390 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700391 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700392
Colin Cross403cc152020-07-06 14:15:24 -0700393 if app.embeddedJniLibs {
394 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
395 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
396 } else {
397 for _, jniLib := range app.jniLibs {
398 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
399 }
Colin Crossa4f08812018-10-02 22:03:40 -0700400 }
Colin Cross403cc152020-07-06 14:15:24 -0700401
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700402 if len(app.jniCoverageOutputs) > 0 {
403 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
404 }
Colin Cross43f08db2018-11-12 10:13:39 -0800405 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700406 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800407 }
Jeongik Chac6246672021-04-08 00:00:19 +0900408 if app.dexpreopter.configPath != nil {
409 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
410 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800411 for _, extra := range app.extraOutputFiles {
412 install := app.onDeviceDir + "/" + extra.Base()
413 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700414 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700415
Colin Cross08dca382020-07-21 20:31:17 -0700416 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700417 },
418 },
419 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800420 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700421 if app.noticeOutputs.Merged.Valid() {
422 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
423 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
424 }
425 if app.noticeOutputs.TxtOutput.Valid() {
426 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
427 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
428 }
429 if app.noticeOutputs.HtmlOutput.Valid() {
430 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
431 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
432 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800433 },
434 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900435 }}
Colin Crossa97c5d32018-03-28 14:58:31 -0700436}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800437
Jaewoong Jung9109d722019-01-30 13:13:52 -0800438func (a *AndroidApp) getOverriddenPackages() []string {
439 var overridden []string
440 if len(a.appProperties.Overrides) > 0 {
441 overridden = append(overridden, a.appProperties.Overrides...)
442 }
443 if a.Name() != a.installApkName {
444 overridden = append(overridden, a.Name())
445 }
446 return overridden
447}
448
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900449func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
450 entriesList := a.AndroidApp.AndroidMkEntries()
451 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700452 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700453 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700454 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700455 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700456 }
Dan Shi95d19422020-08-15 12:24:26 -0700457 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700458 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800459 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700460 })
461
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900462 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700463}
464
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900465func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
466 entriesList := a.AndroidApp.AndroidMkEntries()
467 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700468 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700469 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
Yuntao Xu7a318552021-05-27 10:30:26 -0700470 // introduce a flag variable to control the generation of the .config file
471 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700472 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700473
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900474 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700475}
476
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900477func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700478 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900479 return []android.AndroidMkEntries{{
480 Disabled: true,
481 }}
482 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900483 entriesList := a.Library.AndroidMkEntries()
484 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700485
Colin Crossaa255532020-07-03 13:18:24 -0700486 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700487 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700488 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700489 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700490
491 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700492 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700493 // Make base_rules.mk not put framework-res in a subdirectory called
494 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700495 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700496 }
497
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700498 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
499 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
500 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700501 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
502 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700503 })
504
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900505 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800506}
Nan Zhang581fd212018-01-10 16:06:12 -0800507
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900508func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
509 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800510 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800511 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700512 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700513 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700514 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700515 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700516 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800517 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800518 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700519 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800520 }
521 },
522 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900523 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800524}
525
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900526func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
527 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800528 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000529 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700530 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700531 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700532 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000533 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700534 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800535 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000536 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800537 },
538 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900539 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800540}
Colin Crossd96ca352018-08-10 16:06:24 -0700541
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900542func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100543 // If the stubsSrcJar is not generated (because generate_stubs is false) then
544 // use the api file as the output file to ensure the relevant phony targets
545 // are created in make if only the api txt file is being generated. This is
546 // needed because an invalid output file would prevent the make entries from
547 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000548 //
549 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100550 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000551
Paul Duffin3ae29512020-04-08 18:18:03 +0100552 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
553 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000554 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100555 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900556 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700557 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100558 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700559 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700560 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700561 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700562 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700563 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700564 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700565 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700566 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700567 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700568 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700569 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700570 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100571 if dstubs.metadataZip != nil {
572 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
573 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700574 },
575 },
576 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800577 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100578 if dstubs.apiFile != nil {
579 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
580 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
581 }
582 if dstubs.removedApiFile != nil {
583 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
584 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
585 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700586 if dstubs.checkCurrentApiTimestamp != nil {
587 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
588 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
589 dstubs.checkCurrentApiTimestamp.String())
590
591 fmt.Fprintln(w, ".PHONY: checkapi")
592 fmt.Fprintln(w, "checkapi:",
593 dstubs.checkCurrentApiTimestamp.String())
594
595 fmt.Fprintln(w, ".PHONY: droidcore")
596 fmt.Fprintln(w, "droidcore: checkapi")
597 }
598 if dstubs.updateCurrentApiTimestamp != nil {
599 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
600 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
601 dstubs.updateCurrentApiTimestamp.String())
602
603 fmt.Fprintln(w, ".PHONY: update-api")
604 fmt.Fprintln(w, "update-api:",
605 dstubs.updateCurrentApiTimestamp.String())
606 }
607 if dstubs.checkLastReleasedApiTimestamp != nil {
608 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
609 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
610 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100611
Makoto Onukia573f192020-04-21 11:52:39 -0700612 fmt.Fprintln(w, ".PHONY: checkapi")
613 fmt.Fprintln(w, "checkapi:",
614 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100615
Makoto Onukia573f192020-04-21 11:52:39 -0700616 fmt.Fprintln(w, ".PHONY: droidcore")
617 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700618 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200619 if dstubs.apiLintTimestamp != nil {
620 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
621 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
622 dstubs.apiLintTimestamp.String())
623
624 fmt.Fprintln(w, ".PHONY: checkapi")
625 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100626 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200627
628 fmt.Fprintln(w, ".PHONY: droidcore")
629 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100630
631 if dstubs.apiLintReport != nil {
632 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
633 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
634 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200635 }
Pete Gillin581d6082018-10-22 15:55:04 +0100636 if dstubs.checkNullabilityWarningsTimestamp != nil {
637 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
638 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
639 dstubs.checkNullabilityWarningsTimestamp.String())
640
641 fmt.Fprintln(w, ".PHONY:", "droidcore")
642 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
643 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700644 },
645 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900646 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700647}
648
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900649func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700650 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900651 // The non-platform variant is placed inside APEX. No reason to
652 // make it available to Make.
653 return nil
654 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900655 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700656 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700657 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700658 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700659 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700660 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900661 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800662 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700663 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
664 if len(a.dexpreopter.builtInstalled) > 0 {
665 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
666 }
667 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800668 if Bool(a.properties.Export_package_resources) {
669 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
670 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700671 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700672 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900673 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700674}
675
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900676func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
677 entriesList := a.AndroidAppImport.AndroidMkEntries()
678 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700679 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700680 testSuiteComponent(entries, a.testProperties.Test_suites)
681 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700682 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900683 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700684}
685
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700686func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700687 var testFiles []string
688 for _, d := range data {
689 testFiles = append(testFiles, d.String()+":"+d.Rel())
690 }
691 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
692}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800693
694func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
695 return []android.AndroidMkEntries{android.AndroidMkEntries{
696 Class: "ETC",
697 OutputFile: android.OptionalPathForPath(r.outputFile),
698 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
699 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700700 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800701 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800702 entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath())
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700703 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800704 },
705 },
706 }}
707}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700708
709func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
710 return []android.AndroidMkEntries{
711 android.AndroidMkEntries{
712 Class: "APPS",
713 OutputFile: android.OptionalPathForPath(apkSet.packedOutput),
714 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
715 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700716 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700717 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Liz Kammercada8072020-07-28 15:47:38 -0700718 entries.SetString("LOCAL_APK_SET_INSTALL_FILE", apkSet.InstallFile())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700719 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700720 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
721 },
722 },
723 },
724 }
725}