blob: a3f94cd8c2f160b8dfa87d4c8041f0449cb898fb [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"
Jihoon Kangf78a8902022-09-01 22:47:07 +000020 "strings"
Colin Cross74d73e22017-08-02 11:05:49 -070021
Colin Cross635c3b02016-05-18 15:37:25 -070022 "android/soong/android"
Liz Kammer60772632023-10-05 17:18:44 -040023
24 "github.com/google/blueprint/proptools"
Dan Willemsen218f6562015-07-08 18:13:11 -070025)
26
Jiyong Park55bd98b2019-12-11 17:27:07 +090027func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
28 hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
Colin Cross56a83212020-09-15 18:30:11 -070029 if library.hideApexVariantFromMake {
Jiyong Park55bd98b2019-12-11 17:27:07 +090030 hostDexNeeded = false
Sundong Ahn054b19a2018-10-19 13:46:09 +090031 }
Jiyong Park55bd98b2019-12-11 17:27:07 +090032
33 if hostDexNeeded {
34 var output android.Path
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010035 if library.dexJarFile.IsSet() {
36 output = library.dexJarFile.Path()
Jiyong Park55bd98b2019-12-11 17:27:07 +090037 } else {
38 output = library.implementationAndResourcesJar
39 }
40 return android.AndroidMkEntries{
41 Class: "JAVA_LIBRARIES",
42 SubName: "-hostdex",
43 OutputFile: android.OptionalPathForPath(output),
44 Required: library.deviceProperties.Target.Hostdex.Required,
45 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
46 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070047 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090048 entries.SetBool("LOCAL_IS_HOST_MODULE", true)
49 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010050 if library.dexJarFile.IsSet() {
51 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +090052 }
Colin Cross3108ce12021-11-10 14:38:50 -080053 entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", library.hostdexInstallFile)
Jiyong Park55bd98b2019-12-11 17:27:07 +090054 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
55 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
56 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
57 },
58 },
59 }
60 }
61 return android.AndroidMkEntries{Disabled: true}
Sundong Ahn054b19a2018-10-19 13:46:09 +090062}
63
Jiyong Park0b0e1b92019-12-03 13:24:29 +090064func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park55bd98b2019-12-11 17:27:07 +090065 var entriesList []android.AndroidMkEntries
66
Dan Willemsen9fe14102021-07-13 21:52:04 -070067 if library.Os() == android.Windows {
68 // Make does not support Windows Java modules
69 return nil
70 }
71
Colin Cross56a83212020-09-15 18:30:11 -070072 if library.hideApexVariantFromMake {
Jiakai Zhang519c5c82021-09-16 06:15:39 +000073 // For a java library built for an APEX, we don't need a Make module for itself. Otherwise, it
74 // will conflict with the platform variant because they have the same module name in the
75 // makefile. However, we need to add its dexpreopt outputs as sub-modules, if it is preopted.
76 dexpreoptEntries := library.dexpreopter.AndroidMkEntriesForApex()
77 if len(dexpreoptEntries) > 0 {
78 entriesList = append(entriesList, dexpreoptEntries...)
79 }
Colin Cross56a83212020-09-15 18:30:11 -070080 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +000081 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
82 // Platform variant. If not available for the platform, we don't need Make module.
83 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Liz Kammer60772632023-10-05 17:18:44 -040084 } else if proptools.Bool(library.properties.Headers_only) {
Mark Whitea15790a2023-08-22 21:28:11 +000085 // If generating headers only then don't expose to Make.
86 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000087 } else {
Colin Cross56a83212020-09-15 18:30:11 -070088 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090089 Class: "JAVA_LIBRARIES",
90 OutputFile: android.OptionalPathForPath(library.outputFile),
91 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
92 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070093 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090094 if len(library.logtagsSrcs) > 0 {
95 var logtags []string
96 for _, l := range library.logtagsSrcs {
97 logtags = append(logtags, l.Rel())
98 }
99 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -0800100 }
Colin Cross5beccee2017-12-07 15:28:59 -0800101
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +0000102 if library.installFile == nil {
Jiyong Park55bd98b2019-12-11 17:27:07 +0900103 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
104 }
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100105 if library.dexJarFile.IsSet() {
106 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900107 }
108 if len(library.dexpreopter.builtInstalled) > 0 {
109 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
110 }
Jiyong Park92315372021-04-02 08:45:46 +0900111 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900112 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
113 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800114
Jiyong Park55bd98b2019-12-11 17:27:07 +0900115 if library.jacocoReportClassesFile != nil {
116 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
117 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800118
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100119 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
120 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
Jiyong Park1be96912018-05-28 18:02:19 +0900121
Colin Crosscb6143a2020-08-14 17:39:29 -0700122 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
123 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900124 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700125
Colin Cross08dca382020-07-21 20:31:17 -0700126 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000127
128 if library.dexpreopter.configPath != nil {
129 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
130 }
Yu Liueae7b362023-11-16 17:05:47 -0800131 // TODO(b/311155208): The container here should be system.
Colin Crossd788b3e2023-11-28 13:14:56 -0800132
133 entries.SetPaths("LOCAL_ACONFIG_FILES", library.mergedAconfigFiles[""])
Jiyong Park55bd98b2019-12-11 17:27:07 +0900134 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700135 },
Colin Cross56a83212020-09-15 18:30:11 -0700136 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900137 }
138
Colin Cross56a83212020-09-15 18:30:11 -0700139 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900140
Jiyong Park55bd98b2019-12-11 17:27:07 +0900141 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700142}
143
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000144func (j *JavaFuzzTest) AndroidMkEntries() []android.AndroidMkEntries {
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000145 entriesList := j.Library.AndroidMkEntries()
146 entries := &entriesList[0]
147 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
148 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
Muhammad Haseeb Ahmadeb14ff22022-09-28 17:53:11 +0000149 androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000150 androidMkWriteTestData(j.jniFilePaths, entries)
151 if j.fuzzPackagedModule.Corpus != nil {
152 androidMkWriteTestData(j.fuzzPackagedModule.Corpus, entries)
153 }
154 if j.fuzzPackagedModule.Dictionary != nil {
155 androidMkWriteTestData(android.Paths{j.fuzzPackagedModule.Dictionary}, entries)
156 }
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000157 })
158 return entriesList
159}
160
Paul Duffin42df1442019-03-20 12:45:53 +0000161// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700162func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700163 entries.SetString("LOCAL_MODULE_TAGS", "tests")
164 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800165 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700166 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800167 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700168 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700169 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700170}
171
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900172func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
173 entriesList := j.Library.AndroidMkEntries()
174 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700175 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700176 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700177 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700178 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700179 }
Dan Shi95d19422020-08-15 12:24:26 -0700180 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700181 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800182 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
183 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
184 }
kellyhung74b00522020-08-17 18:46:00 +0800185 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +0800186
187 j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700188 })
189
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900190 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700191}
192
Dan Shi95d19422020-08-15 12:24:26 -0700193func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
194 if len(extraTestConfigs) > 0 {
195 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
196 }
197}
198
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900199func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
200 entriesList := j.Library.AndroidMkEntries()
201 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700202 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700203 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000204 })
205
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900206 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000207}
208
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900209func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000210 if prebuilt.hideApexVariantFromMake {
211 // For a library imported from a prebuilt APEX, we don't need a Make module for itself, as we
212 // don't need to install it. However, we need to add its dexpreopt outputs as sub-modules, if it
213 // is preopted.
214 dexpreoptEntries := prebuilt.dexpreopter.AndroidMkEntriesForApex()
215 return append(dexpreoptEntries, android.AndroidMkEntries{Disabled: true})
216 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900217 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700218 Class: "JAVA_LIBRARIES",
219 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700220 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700221 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700222 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700223 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100224 if prebuilt.dexJarFile.IsSet() {
225 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800226 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700227 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
228 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park92315372021-04-02 08:45:46 +0900229 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900230 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700231 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossa18e9cf2017-08-10 17:00:19 -0700232 },
233 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900234 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700235}
Colin Cross10a03492017-08-10 17:09:43 -0700236
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900237func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700238 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900239 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900240 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900241 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900242 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900243 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800244 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100245 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800246 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700247 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700248 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100249 if prebuilt.dexJarFile.IsSet() {
250 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Colin Cross42be7612019-02-21 18:12:14 -0800251 }
252 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700253 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800254 }
Jiyong Park0b238752019-10-29 11:23:10 +0900255 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700256 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Cross42be7612019-02-21 18:12:14 -0800257 },
258 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900259 }}
Colin Cross42be7612019-02-21 18:12:14 -0800260}
261
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900262func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700263 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900264 return []android.AndroidMkEntries{{
265 Disabled: true,
266 }}
267 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900268 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800269 Class: "JAVA_LIBRARIES",
270 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
271 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700272 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700273 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700274 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
275 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
276 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
277 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800278 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", prebuilt.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700279 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
280 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
281 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900282 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700283 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossfabb6082018-02-20 17:22:23 -0800284 },
285 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900286 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800287}
288
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900289func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700290 if binary.Os() == android.Windows {
291 // Make does not support Windows Java modules
292 return nil
293 }
Colin Cross10a03492017-08-10 17:09:43 -0700294
Colin Cross6b4a32d2017-12-05 13:42:45 -0800295 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900296 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800297 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700298 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800299 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
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.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
303 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100304 if binary.dexJarFile.IsSet() {
305 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
Colin Cross12fc2af2019-01-14 12:35:45 -0800306 }
307 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700308 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800309 }
Yu Liueae7b362023-11-16 17:05:47 -0800310 // TODO(b/311155208): The container here should be system.
Colin Crossd788b3e2023-11-28 13:14:56 -0800311 entries.SetPaths("LOCAL_ACONFIG_FILES", binary.mergedAconfigFiles[""])
Colin Cross331a1212018-08-15 20:40:52 -0700312 },
313 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700314 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800315 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700316 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
317 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800318 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900319 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800320 } else {
Colin Cross44b85d02021-02-19 17:37:04 -0800321 outputFile := binary.wrapperFile
Colin Cross44b85d02021-02-19 17:37:04 -0800322
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900323 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800324 Class: "EXECUTABLES",
Colin Cross44b85d02021-02-19 17:37:04 -0800325 OutputFile: android.OptionalPathForPath(outputFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700326 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700327 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700328 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800329 },
330 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700331 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800332 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700333 // Ensure that the wrapper script timestamp is always updated when the jar is updated
334 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
335 fmt.Fprintln(w, "jar_installed_module :=")
336 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800337 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900338 }}
Colin Cross10a03492017-08-10 17:09:43 -0700339 }
340}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800341
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900342func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Crossaaa0c1f2022-05-16 16:19:54 -0700343 if app.hideApexVariantFromMake || app.IsHideFromMake() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900344 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900345 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900346 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900347 }
Inseob Kim34dc4cd2023-11-07 13:37:14 +0900348 var required []string
349 if proptools.Bool(app.appProperties.Generate_product_characteristics_rro) {
350 required = []string{app.productCharacteristicsRROPackageName()}
351 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900352 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800353 Class: "APPS",
354 OutputFile: android.OptionalPathForPath(app.outputFile),
355 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Inseob Kim34dc4cd2023-11-07 13:37:14 +0900356 Required: required,
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700357 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700358 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700359 // App module names can be overridden.
360 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700361 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Colin Crossf06d8dc2023-07-18 22:11:07 -0700362 if app.headerJarFile != nil {
363 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
364 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700365 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100366 if app.dexJarFile.IsSet() {
367 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800368 }
Colin Cross331a1212018-08-15 20:40:52 -0700369 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700370 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800371 }
372 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700373 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800374 }
Colin Crossf6237212018-10-29 23:14:58 -0700375 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700376 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700377 }
Colin Cross70798562017-12-13 22:42:59 -0800378 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700379 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800380 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700381 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
382 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800383
384 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700385 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800386 // Make base_rules.mk not put framework-res in a subdirectory called
387 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700388 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800389 }
390
Anton Hansson53c88442019-03-18 15:53:16 +0000391 filterRRO := func(filter overlayType) android.Paths {
392 var paths android.Paths
Colin Cross4c90f992023-06-13 16:44:58 -0700393 seen := make(map[android.Path]bool)
394 for _, d := range app.rroDirsDepSet.ToList() {
Anton Hansson53c88442019-03-18 15:53:16 +0000395 if d.overlayType == filter {
Colin Cross4c90f992023-06-13 16:44:58 -0700396 if seen[d.path] {
397 continue
398 }
399 seen[d.path] = true
Anton Hansson53c88442019-03-18 15:53:16 +0000400 paths = append(paths, d.path)
401 }
402 }
Colin Crossa140bb02018-04-17 10:52:26 -0700403 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
404 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000405 return android.ReversePaths(paths)
406 }
407 deviceRRODirs := filterRRO(device)
408 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700409 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000410 }
411 productRRODirs := filterRRO(product)
412 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700413 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800414 }
415
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700416 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800417
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700418 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800419
Jiyong Parkf7487312019-10-17 12:54:30 +0900420 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800421
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800422 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700423 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700424
Colin Cross403cc152020-07-06 14:15:24 -0700425 if app.embeddedJniLibs {
426 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
427 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
428 } else {
429 for _, jniLib := range app.jniLibs {
430 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Jihoon Kangf78a8902022-09-01 22:47:07 +0000431 var partitionTag string
432
433 // Mimic the creation of partition_tag in build/make,
434 // which defaults to an empty string when the partition is system.
435 // Otherwise, capitalize with a leading _
436 if jniLib.partition == "system" {
437 partitionTag = ""
438 } else {
439 split := strings.Split(jniLib.partition, "/")
440 partitionTag = "_" + strings.ToUpper(split[len(split)-1])
441 }
442 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_PARTITION_"+jniLib.target.Arch.ArchType.String(),
443 jniLib.name+":"+partitionTag)
Colin Cross403cc152020-07-06 14:15:24 -0700444 }
Colin Crossa4f08812018-10-02 22:03:40 -0700445 }
Colin Cross403cc152020-07-06 14:15:24 -0700446
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700447 if len(app.jniCoverageOutputs) > 0 {
448 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
449 }
Colin Cross43f08db2018-11-12 10:13:39 -0800450 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700451 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800452 }
Jeongik Chac6246672021-04-08 00:00:19 +0900453 if app.dexpreopter.configPath != nil {
454 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
455 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800456 for _, extra := range app.extraOutputFiles {
457 install := app.onDeviceDir + "/" + extra.Base()
458 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700459 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700460
Colin Cross08dca382020-07-21 20:31:17 -0700461 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700462
463 if app.Name() != "framework-res" {
Yu Liueae7b362023-11-16 17:05:47 -0800464 // TODO(b/311155208): The container here should be system.
Colin Crossd788b3e2023-11-28 13:14:56 -0800465 entries.SetPaths("LOCAL_ACONFIG_FILES", app.mergedAconfigFiles[""])
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700466 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700467 },
468 },
Matt Banda8c801262022-04-01 17:48:31 +0000469 ExtraFooters: []android.AndroidMkExtraFootersFunc{
470 func(w io.Writer, name, prefix, moduleDir string) {
471 if app.javaApiUsedByOutputFile.String() != "" {
472 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
473 app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
474 }
475 },
476 }},
477 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700478}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800479
Jaewoong Jung9109d722019-01-30 13:13:52 -0800480func (a *AndroidApp) getOverriddenPackages() []string {
481 var overridden []string
zhidoua2ce78f2022-02-17 02:33:12 +0000482 if len(a.overridableAppProperties.Overrides) > 0 {
483 overridden = append(overridden, a.overridableAppProperties.Overrides...)
Jaewoong Jung9109d722019-01-30 13:13:52 -0800484 }
Jaewoong Jung9109d722019-01-30 13:13:52 -0800485 return overridden
486}
487
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900488func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
489 entriesList := a.AndroidApp.AndroidMkEntries()
490 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700491 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700492 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700493 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700494 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700495 }
Dan Shi95d19422020-08-15 12:24:26 -0700496 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700497 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800498 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700499 })
500
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900501 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700502}
503
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900504func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
505 entriesList := a.AndroidApp.AndroidMkEntries()
506 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700507 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700508 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700509 // introduce a flag variable to control the generation of the .config file
510 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700511 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700512
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900513 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700514}
515
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900516func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700517 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900518 return []android.AndroidMkEntries{{
519 Disabled: true,
520 }}
521 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900522 entriesList := a.Library.AndroidMkEntries()
523 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700524
Colin Crossaa255532020-07-03 13:18:24 -0700525 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700526 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700527 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700528 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700529
530 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700531 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700532 // Make base_rules.mk not put framework-res in a subdirectory called
533 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700534 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700535 }
536
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700537 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800538 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", a.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700539 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
540 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Colin Cross312634e2023-11-21 15:13:56 -0800541 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700542 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Yu Liueae7b362023-11-16 17:05:47 -0800543 // TODO(b/311155208): The container here should be system.
Colin Crossd788b3e2023-11-28 13:14:56 -0800544 entries.SetPaths("LOCAL_ACONFIG_FILES", a.mergedAconfigFiles[""])
Colin Crossa97c5d32018-03-28 14:58:31 -0700545 })
546
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900547 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800548}
Nan Zhang581fd212018-01-10 16:06:12 -0800549
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900550func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
551 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800552 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800553 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700554 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700555 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700556 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700557 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700558 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800559 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800560 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700561 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800562 }
563 },
564 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900565 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800566}
567
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900568func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
569 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800570 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000571 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700572 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700573 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700574 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000575 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700576 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800577 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000578 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800579 },
580 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900581 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800582}
Colin Crossd96ca352018-08-10 16:06:24 -0700583
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900584func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100585 // If the stubsSrcJar is not generated (because generate_stubs is false) then
586 // use the api file as the output file to ensure the relevant phony targets
587 // are created in make if only the api txt file is being generated. This is
588 // needed because an invalid output file would prevent the make entries from
589 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000590 //
591 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100592 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000593
Paul Duffin3ae29512020-04-08 18:18:03 +0100594 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
595 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000596 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100597 }
Anton Hansson4bf00802022-05-09 10:23:59 +0000598 if !outputFile.Valid() {
599 outputFile = android.OptionalPathForPath(dstubs.apiVersionsXml)
600 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900601 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700602 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100603 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700604 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700605 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700606 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700607 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700608 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700609 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700610 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700611 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700612 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700613 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700614 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700615 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100616 if dstubs.metadataZip != nil {
617 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
618 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700619 },
620 },
621 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800622 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100623 if dstubs.apiFile != nil {
624 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
625 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
626 }
627 if dstubs.removedApiFile != nil {
628 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
629 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
630 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700631 if dstubs.checkCurrentApiTimestamp != nil {
632 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
633 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
634 dstubs.checkCurrentApiTimestamp.String())
635
636 fmt.Fprintln(w, ".PHONY: checkapi")
637 fmt.Fprintln(w, "checkapi:",
638 dstubs.checkCurrentApiTimestamp.String())
639
640 fmt.Fprintln(w, ".PHONY: droidcore")
641 fmt.Fprintln(w, "droidcore: checkapi")
642 }
643 if dstubs.updateCurrentApiTimestamp != nil {
644 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
645 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
646 dstubs.updateCurrentApiTimestamp.String())
647
648 fmt.Fprintln(w, ".PHONY: update-api")
649 fmt.Fprintln(w, "update-api:",
650 dstubs.updateCurrentApiTimestamp.String())
651 }
652 if dstubs.checkLastReleasedApiTimestamp != nil {
653 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
654 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
655 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100656
Makoto Onukia573f192020-04-21 11:52:39 -0700657 fmt.Fprintln(w, ".PHONY: checkapi")
658 fmt.Fprintln(w, "checkapi:",
659 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100660
Makoto Onukia573f192020-04-21 11:52:39 -0700661 fmt.Fprintln(w, ".PHONY: droidcore")
662 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700663 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200664 if dstubs.apiLintTimestamp != nil {
665 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
666 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
667 dstubs.apiLintTimestamp.String())
668
669 fmt.Fprintln(w, ".PHONY: checkapi")
670 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100671 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200672
673 fmt.Fprintln(w, ".PHONY: droidcore")
674 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100675
676 if dstubs.apiLintReport != nil {
677 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
678 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
Bob Badour51804382022-04-13 11:27:19 -0700679 fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100680 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200681 }
Pete Gillin581d6082018-10-22 15:55:04 +0100682 if dstubs.checkNullabilityWarningsTimestamp != nil {
683 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
684 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
685 dstubs.checkNullabilityWarningsTimestamp.String())
686
687 fmt.Fprintln(w, ".PHONY:", "droidcore")
688 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
689 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700690 },
691 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900692 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700693}
694
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900695func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700696 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900697 // The non-platform variant is placed inside APEX. No reason to
698 // make it available to Make.
699 return nil
700 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900701 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700702 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700703 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700704 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700705 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700706 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900707 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800708 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700709 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
710 if len(a.dexpreopter.builtInstalled) > 0 {
711 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
712 }
713 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800714 if Bool(a.properties.Export_package_resources) {
715 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
716 }
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700717 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700718 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700719 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900720 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700721}
722
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900723func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
724 entriesList := a.AndroidAppImport.AndroidMkEntries()
725 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700726 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700727 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700728 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700729 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900730 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700731}
732
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700733func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700734 var testFiles []string
735 for _, d := range data {
736 testFiles = append(testFiles, d.String()+":"+d.Rel())
737 }
738 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
739}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800740
741func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
742 return []android.AndroidMkEntries{android.AndroidMkEntries{
743 Class: "ETC",
744 OutputFile: android.OptionalPathForPath(r.outputFile),
745 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
746 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700747 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800748 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Colin Crossc68db4b2021-11-11 18:59:15 -0800749 entries.SetPath("LOCAL_MODULE_PATH", r.installDir)
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700750 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700751 // TODO: LOCAL_ACONFIG_FILES -- Might eventually need aconfig flags?
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800752 },
753 },
754 }}
755}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700756
757func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
758 return []android.AndroidMkEntries{
759 android.AndroidMkEntries{
760 Class: "APPS",
Colin Crossffbcd1d2021-11-12 12:19:42 -0800761 OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Sasha Smundaka7856c02020-04-23 09:49:59 -0700762 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
763 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700764 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700765 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Colin Crossffbcd1d2021-11-12 12:19:42 -0800766 entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700767 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700768 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700769 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts -- Both declarations and values
Sasha Smundaka7856c02020-04-23 09:49:59 -0700770 },
771 },
772 },
773 }
774}
Jihoon Kang1bff0342023-01-17 20:40:22 +0000775
776func (al *ApiLibrary) AndroidMkEntries() []android.AndroidMkEntries {
777 var entriesList []android.AndroidMkEntries
778
779 entriesList = append(entriesList, android.AndroidMkEntries{
780 Class: "JAVA_LIBRARIES",
781 OutputFile: android.OptionalPathForPath(al.stubsJar),
782 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
783 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
784 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
785 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
786 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", al.stubsJar)
787 entries.SetPath("LOCAL_SOONG_HEADER_JAR", al.stubsJar)
788 },
789 },
790 })
791
792 return entriesList
793}