blob: 49ca176689f0393b2b1667548550abe7ce3eb80d [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
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010032 if library.dexJarFile.IsSet() {
33 output = library.dexJarFile.Path()
Jiyong Park55bd98b2019-12-11 17:27:07 +090034 } 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)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010047 if library.dexJarFile.IsSet() {
48 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +090049 }
Colin Cross3108ce12021-11-10 14:38:50 -080050 entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", library.hostdexInstallFile)
Jiyong Park55bd98b2019-12-11 17:27:07 +090051 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
Dan Willemsen9fe14102021-07-13 21:52:04 -070064 if library.Os() == android.Windows {
65 // Make does not support Windows Java modules
66 return nil
67 }
68
Colin Cross56a83212020-09-15 18:30:11 -070069 if library.hideApexVariantFromMake {
Jiakai Zhang519c5c82021-09-16 06:15:39 +000070 // For a java library built for an APEX, we don't need a Make module for itself. Otherwise, it
71 // will conflict with the platform variant because they have the same module name in the
72 // makefile. However, we need to add its dexpreopt outputs as sub-modules, if it is preopted.
73 dexpreoptEntries := library.dexpreopter.AndroidMkEntriesForApex()
74 if len(dexpreoptEntries) > 0 {
75 entriesList = append(entriesList, dexpreoptEntries...)
76 }
Colin Cross56a83212020-09-15 18:30:11 -070077 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
78 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
79 // Platform variant. If not available for the platform, we don't need Make module.
Paul Duffin0b58fdb2021-10-02 10:37:58 +010080 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000081 } else {
Colin Cross56a83212020-09-15 18:30:11 -070082 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090083 Class: "JAVA_LIBRARIES",
84 OutputFile: android.OptionalPathForPath(library.outputFile),
85 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
86 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070087 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090088 if len(library.logtagsSrcs) > 0 {
89 var logtags []string
90 for _, l := range library.logtagsSrcs {
91 logtags = append(logtags, l.Rel())
92 }
93 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080094 }
Colin Cross5beccee2017-12-07 15:28:59 -080095
Jiyong Park55bd98b2019-12-11 17:27:07 +090096 if library.installFile == nil {
97 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
98 }
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010099 if library.dexJarFile.IsSet() {
100 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900101 }
102 if len(library.dexpreopter.builtInstalled) > 0 {
103 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
104 }
Jiyong Park92315372021-04-02 08:45:46 +0900105 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900106 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
107 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800108
Jiyong Park55bd98b2019-12-11 17:27:07 +0900109 if library.jacocoReportClassesFile != nil {
110 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
111 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800112
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100113 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
114 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
Jiyong Park1be96912018-05-28 18:02:19 +0900115
Colin Crosscb6143a2020-08-14 17:39:29 -0700116 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
117 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900118 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700119
Colin Cross08dca382020-07-21 20:31:17 -0700120 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000121
122 if library.dexpreopter.configPath != nil {
123 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
124 }
Jiyong Park55bd98b2019-12-11 17:27:07 +0900125 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700126 },
Colin Cross56a83212020-09-15 18:30:11 -0700127 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900128 }
129
Colin Cross56a83212020-09-15 18:30:11 -0700130 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900131
Jiyong Park55bd98b2019-12-11 17:27:07 +0900132 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700133}
134
Paul Duffin42df1442019-03-20 12:45:53 +0000135// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700136func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700137 entries.SetString("LOCAL_MODULE_TAGS", "tests")
138 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800139 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700140 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800141 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700142 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700143 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700144}
145
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900146func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
147 entriesList := j.Library.AndroidMkEntries()
148 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700149 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700150 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700151 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700152 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700153 }
Dan Shi95d19422020-08-15 12:24:26 -0700154 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700155 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800156 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
157 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
158 }
kellyhung74b00522020-08-17 18:46:00 +0800159 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Dan Shid79572f2020-11-13 14:33:46 -0800160 if Bool(j.testProperties.Test_options.Unit_test) {
161 entries.SetBool("LOCAL_IS_UNIT_TEST", true)
162 }
Colin Cross05638fc2018-04-09 18:40:24 -0700163 })
164
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900165 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700166}
167
Dan Shi95d19422020-08-15 12:24:26 -0700168func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
169 if len(extraTestConfigs) > 0 {
170 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
171 }
172}
173
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900174func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
175 entriesList := j.Library.AndroidMkEntries()
176 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700177 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700178 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000179 })
180
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900181 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000182}
183
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900184func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000185 if prebuilt.hideApexVariantFromMake {
186 // For a library imported from a prebuilt APEX, we don't need a Make module for itself, as we
187 // don't need to install it. However, we need to add its dexpreopt outputs as sub-modules, if it
188 // is preopted.
189 dexpreoptEntries := prebuilt.dexpreopter.AndroidMkEntriesForApex()
190 return append(dexpreoptEntries, android.AndroidMkEntries{Disabled: true})
191 }
192 if !prebuilt.ContainingSdk().Unversioned() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900193 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900194 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900195 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900196 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900197 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700198 Class: "JAVA_LIBRARIES",
199 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700200 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700201 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700202 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700203 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100204 if prebuilt.dexJarFile.IsSet() {
205 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800206 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700207 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
208 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park92315372021-04-02 08:45:46 +0900209 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900210 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700211 },
212 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900213 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700214}
Colin Cross10a03492017-08-10 17:09:43 -0700215
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900216func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700217 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900218 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900219 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900220 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900221 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900222 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800223 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100224 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800225 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700226 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700227 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100228 if prebuilt.dexJarFile.IsSet() {
229 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
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 {
Colin Cross56a83212020-09-15 18:30:11 -0700241 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900242 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{
Colin Crossaa255532020-07-03 13:18:24 -0700251 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700252 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 Park92315372021-04-02 08:45:46 +0900259 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
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 {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700266 if binary.Os() == android.Windows {
267 // Make does not support Windows Java modules
268 return nil
269 }
Colin Cross10a03492017-08-10 17:09:43 -0700270
Colin Cross6b4a32d2017-12-05 13:42:45 -0800271 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900272 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800273 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700274 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800275 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700276 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700277 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700278 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
279 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100280 if binary.dexJarFile.IsSet() {
281 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
Colin Cross12fc2af2019-01-14 12:35:45 -0800282 }
283 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700284 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800285 }
Colin Cross331a1212018-08-15 20:40:52 -0700286 },
287 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700288 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800289 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700290 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
291 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800292 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900293 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800294 } else {
Colin Cross44b85d02021-02-19 17:37:04 -0800295 outputFile := binary.wrapperFile
Colin Cross44b85d02021-02-19 17:37:04 -0800296
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900297 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800298 Class: "EXECUTABLES",
Colin Cross44b85d02021-02-19 17:37:04 -0800299 OutputFile: android.OptionalPathForPath(outputFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700300 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700301 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700302 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800303 },
304 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700305 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800306 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700307 // Ensure that the wrapper script timestamp is always updated when the jar is updated
308 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
309 fmt.Fprintln(w, "jar_installed_module :=")
310 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800311 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900312 }}
Colin Cross10a03492017-08-10 17:09:43 -0700313 }
314}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800315
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900316func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross50885442022-05-16 16:19:54 -0700317 if app.hideApexVariantFromMake || app.IsHideFromMake() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900318 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900319 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900320 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900321 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900322 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800323 Class: "APPS",
324 OutputFile: android.OptionalPathForPath(app.outputFile),
325 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700326 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700327 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700328 // App module names can be overridden.
329 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700330 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700331 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100332 if app.dexJarFile.IsSet() {
333 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800334 }
Colin Cross331a1212018-08-15 20:40:52 -0700335 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700336 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800337 }
338 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700339 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800340 }
Colin Crossf6237212018-10-29 23:14:58 -0700341 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700342 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700343 }
Colin Cross70798562017-12-13 22:42:59 -0800344 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700345 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800346 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700347 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
348 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800349
Rashed Abdel-Tawab8782f152018-08-09 14:08:53 -0700350 if app.Name() == "framework-res" || app.Name() == "org.lineageos.platform-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700351 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800352 // Make base_rules.mk not put framework-res in a subdirectory called
353 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700354 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800355 }
356
Anton Hansson53c88442019-03-18 15:53:16 +0000357 filterRRO := func(filter overlayType) android.Paths {
358 var paths android.Paths
359 for _, d := range app.rroDirs {
360 if d.overlayType == filter {
361 paths = append(paths, d.path)
362 }
363 }
Colin Crossa140bb02018-04-17 10:52:26 -0700364 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
365 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000366 return android.ReversePaths(paths)
367 }
368 deviceRRODirs := filterRRO(device)
369 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700370 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000371 }
372 productRRODirs := filterRRO(product)
373 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700374 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800375 }
376
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700377 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800378
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700379 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800380
Jiyong Parkf7487312019-10-17 12:54:30 +0900381 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800382
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800383 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700384 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700385
Colin Cross403cc152020-07-06 14:15:24 -0700386 if app.embeddedJniLibs {
387 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
388 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
389 } else {
390 for _, jniLib := range app.jniLibs {
391 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
392 }
Colin Crossa4f08812018-10-02 22:03:40 -0700393 }
Colin Cross403cc152020-07-06 14:15:24 -0700394
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700395 if len(app.jniCoverageOutputs) > 0 {
396 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
397 }
Colin Cross43f08db2018-11-12 10:13:39 -0800398 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700399 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800400 }
Jeongik Chac6246672021-04-08 00:00:19 +0900401 if app.dexpreopter.configPath != nil {
402 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
403 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800404 for _, extra := range app.extraOutputFiles {
405 install := app.onDeviceDir + "/" + extra.Base()
406 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700407 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700408
Colin Cross08dca382020-07-21 20:31:17 -0700409 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700410 },
411 },
Matt Banda8c801262022-04-01 17:48:31 +0000412 ExtraFooters: []android.AndroidMkExtraFootersFunc{
413 func(w io.Writer, name, prefix, moduleDir string) {
414 if app.javaApiUsedByOutputFile.String() != "" {
415 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
416 app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
417 }
418 },
419 }},
420 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700421}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800422
Jaewoong Jung9109d722019-01-30 13:13:52 -0800423func (a *AndroidApp) getOverriddenPackages() []string {
424 var overridden []string
zhidoua2ce78f2022-02-17 02:33:12 +0000425 if len(a.overridableAppProperties.Overrides) > 0 {
426 overridden = append(overridden, a.overridableAppProperties.Overrides...)
Jaewoong Jung9109d722019-01-30 13:13:52 -0800427 }
Jooyung Han29e2f6d2022-01-08 12:13:59 +0900428 // When APK name is overridden via PRODUCT_PACKAGE_NAME_OVERRIDES
429 // ensure that the original name is overridden.
430 if a.Stem() != a.installApkName {
431 overridden = append(overridden, a.Stem())
Jaewoong Jung9109d722019-01-30 13:13:52 -0800432 }
433 return overridden
434}
435
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900436func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
437 entriesList := a.AndroidApp.AndroidMkEntries()
438 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700439 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700440 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700441 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700442 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700443 }
Dan Shi95d19422020-08-15 12:24:26 -0700444 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700445 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800446 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700447 })
448
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900449 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700450}
451
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900452func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
453 entriesList := a.AndroidApp.AndroidMkEntries()
454 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700455 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700456 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700457 // introduce a flag variable to control the generation of the .config file
458 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700459 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700460
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900461 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700462}
463
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900464func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700465 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900466 return []android.AndroidMkEntries{{
467 Disabled: true,
468 }}
469 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900470 entriesList := a.Library.AndroidMkEntries()
471 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700472
Colin Crossaa255532020-07-03 13:18:24 -0700473 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700474 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700475 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700476 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700477
Rashed Abdel-Tawab8782f152018-08-09 14:08:53 -0700478 if a.Name() == "framework-res" || a.Name() == "org.lineageos.platform-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700479 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700480 // Make base_rules.mk not put framework-res in a subdirectory called
481 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700482 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700483 }
484
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700485 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
486 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
487 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700488 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
489 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700490 })
491
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900492 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800493}
Nan Zhang581fd212018-01-10 16:06:12 -0800494
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900495func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
496 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800497 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800498 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700499 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700500 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700501 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700502 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700503 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800504 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800505 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700506 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800507 }
508 },
509 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900510 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800511}
512
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900513func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
514 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800515 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000516 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700517 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700518 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700519 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000520 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700521 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800522 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000523 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800524 },
525 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900526 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800527}
Colin Crossd96ca352018-08-10 16:06:24 -0700528
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900529func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100530 // If the stubsSrcJar is not generated (because generate_stubs is false) then
531 // use the api file as the output file to ensure the relevant phony targets
532 // are created in make if only the api txt file is being generated. This is
533 // needed because an invalid output file would prevent the make entries from
534 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000535 //
536 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100537 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000538
Paul Duffin3ae29512020-04-08 18:18:03 +0100539 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
540 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000541 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100542 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900543 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700544 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100545 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700546 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700547 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700548 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700549 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700550 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700551 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700552 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700553 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700554 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700555 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700556 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700557 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100558 if dstubs.metadataZip != nil {
559 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
560 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700561 },
562 },
563 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800564 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100565 if dstubs.apiFile != nil {
566 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
567 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
568 }
569 if dstubs.removedApiFile != nil {
570 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
571 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
572 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700573 if dstubs.checkCurrentApiTimestamp != nil {
574 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
575 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
576 dstubs.checkCurrentApiTimestamp.String())
577
578 fmt.Fprintln(w, ".PHONY: checkapi")
579 fmt.Fprintln(w, "checkapi:",
580 dstubs.checkCurrentApiTimestamp.String())
581
582 fmt.Fprintln(w, ".PHONY: droidcore")
583 fmt.Fprintln(w, "droidcore: checkapi")
584 }
585 if dstubs.updateCurrentApiTimestamp != nil {
586 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
587 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
588 dstubs.updateCurrentApiTimestamp.String())
589
590 fmt.Fprintln(w, ".PHONY: update-api")
591 fmt.Fprintln(w, "update-api:",
592 dstubs.updateCurrentApiTimestamp.String())
593 }
594 if dstubs.checkLastReleasedApiTimestamp != nil {
595 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
596 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
597 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100598
Makoto Onukia573f192020-04-21 11:52:39 -0700599 fmt.Fprintln(w, ".PHONY: checkapi")
600 fmt.Fprintln(w, "checkapi:",
601 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100602
Makoto Onukia573f192020-04-21 11:52:39 -0700603 fmt.Fprintln(w, ".PHONY: droidcore")
604 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700605 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200606 if dstubs.apiLintTimestamp != nil {
607 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
608 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
609 dstubs.apiLintTimestamp.String())
610
611 fmt.Fprintln(w, ".PHONY: checkapi")
612 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100613 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200614
615 fmt.Fprintln(w, ".PHONY: droidcore")
616 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100617
618 if dstubs.apiLintReport != nil {
619 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
620 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
621 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200622 }
Pete Gillin581d6082018-10-22 15:55:04 +0100623 if dstubs.checkNullabilityWarningsTimestamp != nil {
624 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
625 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
626 dstubs.checkNullabilityWarningsTimestamp.String())
627
628 fmt.Fprintln(w, ".PHONY:", "droidcore")
629 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
630 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700631 },
632 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900633 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700634}
635
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900636func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700637 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900638 // The non-platform variant is placed inside APEX. No reason to
639 // make it available to Make.
640 return nil
641 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900642 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700643 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700644 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700645 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700646 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700647 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900648 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800649 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700650 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
651 if len(a.dexpreopter.builtInstalled) > 0 {
652 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
653 }
654 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800655 if Bool(a.properties.Export_package_resources) {
656 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
657 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700658 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700659 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900660 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700661}
662
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900663func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
664 entriesList := a.AndroidAppImport.AndroidMkEntries()
665 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700666 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700667 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700668 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700669 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900670 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700671}
672
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700673func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700674 var testFiles []string
675 for _, d := range data {
676 testFiles = append(testFiles, d.String()+":"+d.Rel())
677 }
678 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
679}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800680
681func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
682 return []android.AndroidMkEntries{android.AndroidMkEntries{
683 Class: "ETC",
684 OutputFile: android.OptionalPathForPath(r.outputFile),
685 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
686 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700687 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800688 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Colin Crossc68db4b2021-11-11 18:59:15 -0800689 entries.SetPath("LOCAL_MODULE_PATH", r.installDir)
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700690 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800691 },
692 },
693 }}
694}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700695
696func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
697 return []android.AndroidMkEntries{
698 android.AndroidMkEntries{
699 Class: "APPS",
Colin Crossffbcd1d2021-11-12 12:19:42 -0800700 OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Sasha Smundaka7856c02020-04-23 09:49:59 -0700701 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
702 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700703 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700704 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Colin Crossffbcd1d2021-11-12 12:19:42 -0800705 entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700706 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700707 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
708 },
709 },
710 },
711 }
712}