blob: ed9d5de324a484f233dd53b839185a5f5a1c61a3 [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"
Liz Kammer60772632023-10-05 17:18:44 -040022
23 "github.com/google/blueprint/proptools"
Dan Willemsen218f6562015-07-08 18:13:11 -070024)
25
Jiyong Park55bd98b2019-12-11 17:27:07 +090026func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
27 hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
Colin Cross56a83212020-09-15 18:30:11 -070028 if library.hideApexVariantFromMake {
Jiyong Park55bd98b2019-12-11 17:27:07 +090029 hostDexNeeded = false
Sundong Ahn054b19a2018-10-19 13:46:09 +090030 }
Jiyong Park55bd98b2019-12-11 17:27:07 +090031
32 if hostDexNeeded {
33 var output android.Path
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010034 if library.dexJarFile.IsSet() {
35 output = library.dexJarFile.Path()
Jiyong Park55bd98b2019-12-11 17:27:07 +090036 } else {
37 output = library.implementationAndResourcesJar
38 }
39 return android.AndroidMkEntries{
40 Class: "JAVA_LIBRARIES",
41 SubName: "-hostdex",
42 OutputFile: android.OptionalPathForPath(output),
43 Required: library.deviceProperties.Target.Hostdex.Required,
44 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
45 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070046 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090047 entries.SetBool("LOCAL_IS_HOST_MODULE", true)
48 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010049 if library.dexJarFile.IsSet() {
50 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +090051 }
Colin Cross3108ce12021-11-10 14:38:50 -080052 entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", library.hostdexInstallFile)
Jiyong Park55bd98b2019-12-11 17:27:07 +090053 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
54 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
55 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
56 },
57 },
58 }
59 }
60 return android.AndroidMkEntries{Disabled: true}
Sundong Ahn054b19a2018-10-19 13:46:09 +090061}
62
Jiyong Park0b0e1b92019-12-03 13:24:29 +090063func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park55bd98b2019-12-11 17:27:07 +090064 var entriesList []android.AndroidMkEntries
65
Dan Willemsen9fe14102021-07-13 21:52:04 -070066 if library.Os() == android.Windows {
67 // Make does not support Windows Java modules
68 return nil
69 }
70
Colin Cross56a83212020-09-15 18:30:11 -070071 if library.hideApexVariantFromMake {
Jiakai Zhang519c5c82021-09-16 06:15:39 +000072 // For a java library built for an APEX, we don't need a Make module for itself. Otherwise, it
73 // will conflict with the platform variant because they have the same module name in the
74 // makefile. However, we need to add its dexpreopt outputs as sub-modules, if it is preopted.
75 dexpreoptEntries := library.dexpreopter.AndroidMkEntriesForApex()
76 if len(dexpreoptEntries) > 0 {
77 entriesList = append(entriesList, dexpreoptEntries...)
78 }
Colin Cross56a83212020-09-15 18:30:11 -070079 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +000080 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
81 // Platform variant. If not available for the platform, we don't need Make module.
82 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Liz Kammer60772632023-10-05 17:18:44 -040083 } else if proptools.Bool(library.properties.Headers_only) {
Mark Whitea15790a2023-08-22 21:28:11 +000084 // If generating headers only then don't expose to Make.
85 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000086 } else {
Colin Cross56a83212020-09-15 18:30:11 -070087 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090088 Class: "JAVA_LIBRARIES",
89 OutputFile: android.OptionalPathForPath(library.outputFile),
90 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
91 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070092 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090093 if len(library.logtagsSrcs) > 0 {
94 var logtags []string
95 for _, l := range library.logtagsSrcs {
96 logtags = append(logtags, l.Rel())
97 }
98 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080099 }
Colin Cross5beccee2017-12-07 15:28:59 -0800100
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +0000101 if library.installFile == nil {
Jiyong Park55bd98b2019-12-11 17:27:07 +0900102 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
103 }
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100104 if library.dexJarFile.IsSet() {
105 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900106 }
107 if len(library.dexpreopter.builtInstalled) > 0 {
108 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
109 }
Jiyong Park92315372021-04-02 08:45:46 +0900110 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900111 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
112 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800113
Jiyong Park55bd98b2019-12-11 17:27:07 +0900114 if library.jacocoReportClassesFile != nil {
115 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
116 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800117
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100118 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
119 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
Jiyong Park1be96912018-05-28 18:02:19 +0900120
Colin Crosscb6143a2020-08-14 17:39:29 -0700121 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
122 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900123 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700124
Colin Cross08dca382020-07-21 20:31:17 -0700125 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000126
127 if library.dexpreopter.configPath != nil {
128 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
129 }
LaMont Jonesacae2d72024-01-09 22:53:52 +0000130 android.SetAconfigFileMkEntries(&library.ModuleBase, entries, library.mergedAconfigFiles)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900131 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700132 },
Colin Cross56a83212020-09-15 18:30:11 -0700133 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900134 }
135
Colin Cross56a83212020-09-15 18:30:11 -0700136 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900137
Jiyong Park55bd98b2019-12-11 17:27:07 +0900138 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700139}
140
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000141func (j *JavaFuzzTest) AndroidMkEntries() []android.AndroidMkEntries {
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000142 entriesList := j.Library.AndroidMkEntries()
143 entries := &entriesList[0]
144 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
145 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
Muhammad Haseeb Ahmadeb14ff22022-09-28 17:53:11 +0000146 androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000147 androidMkWriteTestData(j.jniFilePaths, entries)
148 if j.fuzzPackagedModule.Corpus != nil {
149 androidMkWriteTestData(j.fuzzPackagedModule.Corpus, entries)
150 }
151 if j.fuzzPackagedModule.Dictionary != nil {
152 androidMkWriteTestData(android.Paths{j.fuzzPackagedModule.Dictionary}, entries)
153 }
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000154 })
155 return entriesList
156}
157
Paul Duffin42df1442019-03-20 12:45:53 +0000158// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700159func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700160 entries.SetString("LOCAL_MODULE_TAGS", "tests")
161 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800162 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700163 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800164 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700165 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700166 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700167}
168
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900169func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
170 entriesList := j.Library.AndroidMkEntries()
171 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700172 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700173 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700174 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700175 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700176 }
Dan Shi95d19422020-08-15 12:24:26 -0700177 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700178 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800179 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
180 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
181 }
kellyhung74b00522020-08-17 18:46:00 +0800182 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +0800183
184 j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700185 })
186
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900187 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700188}
189
Dan Shi95d19422020-08-15 12:24:26 -0700190func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
191 if len(extraTestConfigs) > 0 {
192 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
193 }
194}
195
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900196func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
197 entriesList := j.Library.AndroidMkEntries()
198 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700199 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700200 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000201 })
202
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900203 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000204}
205
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900206func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000207 if prebuilt.hideApexVariantFromMake {
Spandan Das2069c3f2023-12-06 19:40:24 +0000208 return []android.AndroidMkEntries{}
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000209 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900210 return []android.AndroidMkEntries{android.AndroidMkEntries{
Spandan Das3cf04632024-01-19 00:22:22 +0000211 Class: "JAVA_LIBRARIES",
212 OverrideName: prebuilt.BaseModuleName(),
Colin Crossdad2a362024-03-23 04:43:41 +0000213 OutputFile: android.OptionalPathForPath(prebuilt.combinedImplementationFile),
Spandan Das3cf04632024-01-19 00:22:22 +0000214 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700215 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700216 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700217 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100218 if prebuilt.dexJarFile.IsSet() {
219 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800220 }
Colin Crossdad2a362024-03-23 04:43:41 +0000221 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedHeaderFile)
222 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedImplementationFile)
Jiyong Park92315372021-04-02 08:45:46 +0900223 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900224 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700225 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossa18e9cf2017-08-10 17:00:19 -0700226 },
227 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900228 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700229}
Colin Cross10a03492017-08-10 17:09:43 -0700230
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900231func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700232 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900233 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900234 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900235 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900236 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900237 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800238 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100239 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800240 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700241 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700242 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100243 if prebuilt.dexJarFile.IsSet() {
244 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Colin Cross42be7612019-02-21 18:12:14 -0800245 }
246 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700247 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800248 }
Jiyong Park0b238752019-10-29 11:23:10 +0900249 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700250 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Cross42be7612019-02-21 18:12:14 -0800251 },
252 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900253 }}
Colin Cross42be7612019-02-21 18:12:14 -0800254}
255
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900256func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700257 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900258 return []android.AndroidMkEntries{{
259 Disabled: true,
260 }}
261 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900262 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800263 Class: "JAVA_LIBRARIES",
Colin Cross9055e212024-03-23 04:43:41 +0000264 OutputFile: android.OptionalPathForPath(prebuilt.implementationJarFile),
Colin Crossfabb6082018-02-20 17:22:23 -0800265 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700266 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700267 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700268 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Cross9055e212024-03-23 04:43:41 +0000269 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.headerJarFile)
270 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.implementationJarFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700271 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800272 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", prebuilt.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700273 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
274 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
275 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900276 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700277 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossfabb6082018-02-20 17:22:23 -0800278 },
279 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900280 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800281}
282
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900283func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700284 if binary.Os() == android.Windows {
285 // Make does not support Windows Java modules
286 return nil
287 }
Colin Cross10a03492017-08-10 17:09:43 -0700288
Colin Cross6b4a32d2017-12-05 13:42:45 -0800289 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900290 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800291 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700292 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800293 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700294 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700295 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700296 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
297 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100298 if binary.dexJarFile.IsSet() {
299 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
Colin Cross12fc2af2019-01-14 12:35:45 -0800300 }
301 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700302 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800303 }
LaMont Jonesacae2d72024-01-09 22:53:52 +0000304 android.SetAconfigFileMkEntries(&binary.ModuleBase, entries, binary.mergedAconfigFiles)
Colin Cross331a1212018-08-15 20:40:52 -0700305 },
306 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700307 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800308 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700309 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
310 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800311 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900312 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800313 } else {
Colin Cross44b85d02021-02-19 17:37:04 -0800314 outputFile := binary.wrapperFile
Colin Cross44b85d02021-02-19 17:37:04 -0800315
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900316 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800317 Class: "EXECUTABLES",
Colin Cross44b85d02021-02-19 17:37:04 -0800318 OutputFile: android.OptionalPathForPath(outputFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700319 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700320 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700321 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800322 },
323 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700324 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800325 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700326 // Ensure that the wrapper script timestamp is always updated when the jar is updated
327 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
328 fmt.Fprintln(w, "jar_installed_module :=")
329 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800330 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900331 }}
Colin Cross10a03492017-08-10 17:09:43 -0700332 }
333}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800334
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900335func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Crossaaa0c1f2022-05-16 16:19:54 -0700336 if app.hideApexVariantFromMake || app.IsHideFromMake() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900337 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900338 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900339 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900340 }
Inseob Kim34dc4cd2023-11-07 13:37:14 +0900341 var required []string
342 if proptools.Bool(app.appProperties.Generate_product_characteristics_rro) {
343 required = []string{app.productCharacteristicsRROPackageName()}
344 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900345 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800346 Class: "APPS",
347 OutputFile: android.OptionalPathForPath(app.outputFile),
348 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Inseob Kim34dc4cd2023-11-07 13:37:14 +0900349 Required: required,
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700350 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700351 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700352 // App module names can be overridden.
353 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700354 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Colin Crossf06d8dc2023-07-18 22:11:07 -0700355 if app.headerJarFile != nil {
356 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
357 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700358 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100359 if app.dexJarFile.IsSet() {
360 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800361 }
Colin Cross331a1212018-08-15 20:40:52 -0700362 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700363 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800364 }
365 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700366 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800367 }
Colin Crossf6237212018-10-29 23:14:58 -0700368 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700369 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700370 }
Colin Cross70798562017-12-13 22:42:59 -0800371 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700372 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800373 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700374 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
375 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800376
377 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700378 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800379 // Make base_rules.mk not put framework-res in a subdirectory called
380 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700381 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800382 }
383
Anton Hansson53c88442019-03-18 15:53:16 +0000384 filterRRO := func(filter overlayType) android.Paths {
385 var paths android.Paths
Colin Cross4c90f992023-06-13 16:44:58 -0700386 seen := make(map[android.Path]bool)
387 for _, d := range app.rroDirsDepSet.ToList() {
Anton Hansson53c88442019-03-18 15:53:16 +0000388 if d.overlayType == filter {
Colin Cross4c90f992023-06-13 16:44:58 -0700389 if seen[d.path] {
390 continue
391 }
392 seen[d.path] = true
Anton Hansson53c88442019-03-18 15:53:16 +0000393 paths = append(paths, d.path)
394 }
395 }
Colin Crossa140bb02018-04-17 10:52:26 -0700396 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
397 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000398 return android.ReversePaths(paths)
399 }
400 deviceRRODirs := filterRRO(device)
401 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700402 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000403 }
404 productRRODirs := filterRRO(product)
405 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700406 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800407 }
408
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700409 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800410
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700411 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800412
Jiyong Parkf7487312019-10-17 12:54:30 +0900413 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800414
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800415 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700416 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700417
Colin Cross403cc152020-07-06 14:15:24 -0700418 if app.embeddedJniLibs {
419 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
420 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
Colin Crossa4f08812018-10-02 22:03:40 -0700421 }
Colin Cross403cc152020-07-06 14:15:24 -0700422
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700423 if len(app.jniCoverageOutputs) > 0 {
424 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
425 }
Colin Cross43f08db2018-11-12 10:13:39 -0800426 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700427 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800428 }
Jeongik Chac6246672021-04-08 00:00:19 +0900429 if app.dexpreopter.configPath != nil {
430 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
431 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800432 for _, extra := range app.extraOutputFiles {
433 install := app.onDeviceDir + "/" + extra.Base()
434 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700435 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700436
Colin Cross08dca382020-07-21 20:31:17 -0700437 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700438
439 if app.Name() != "framework-res" {
LaMont Jonesacae2d72024-01-09 22:53:52 +0000440 android.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700441 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700442 },
443 },
Matt Banda8c801262022-04-01 17:48:31 +0000444 ExtraFooters: []android.AndroidMkExtraFootersFunc{
445 func(w io.Writer, name, prefix, moduleDir string) {
446 if app.javaApiUsedByOutputFile.String() != "" {
447 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
448 app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
449 }
450 },
451 }},
452 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700453}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800454
Jaewoong Jung9109d722019-01-30 13:13:52 -0800455func (a *AndroidApp) getOverriddenPackages() []string {
456 var overridden []string
zhidoua2ce78f2022-02-17 02:33:12 +0000457 if len(a.overridableAppProperties.Overrides) > 0 {
458 overridden = append(overridden, a.overridableAppProperties.Overrides...)
Jaewoong Jung9109d722019-01-30 13:13:52 -0800459 }
Jaewoong Jung9109d722019-01-30 13:13:52 -0800460 return overridden
461}
462
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900463func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
464 entriesList := a.AndroidApp.AndroidMkEntries()
465 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700466 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700467 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700468 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700469 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700470 }
Dan Shi95d19422020-08-15 12:24:26 -0700471 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700472 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800473 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700474 })
475
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900476 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700477}
478
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900479func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
480 entriesList := a.AndroidApp.AndroidMkEntries()
481 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700482 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700483 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700484 // introduce a flag variable to control the generation of the .config file
485 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700486 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700487
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900488 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700489}
490
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900491func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700492 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900493 return []android.AndroidMkEntries{{
494 Disabled: true,
495 }}
496 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900497 entriesList := a.Library.AndroidMkEntries()
498 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700499
Colin Crossaa255532020-07-03 13:18:24 -0700500 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700501 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700502 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700503 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700504
505 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700506 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700507 // Make base_rules.mk not put framework-res in a subdirectory called
508 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700509 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700510 }
511
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700512 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800513 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", a.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700514 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
515 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Colin Cross312634e2023-11-21 15:13:56 -0800516 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700517 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
LaMont Jonesacae2d72024-01-09 22:53:52 +0000518 android.SetAconfigFileMkEntries(&a.ModuleBase, entries, a.mergedAconfigFiles)
Colin Crossa97c5d32018-03-28 14:58:31 -0700519 })
520
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900521 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800522}
Nan Zhang581fd212018-01-10 16:06:12 -0800523
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900524func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
525 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800526 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800527 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700528 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700529 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700530 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700531 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700532 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800533 }
Jihoon Kang246690a2024-02-01 21:55:01 +0000534 if jd.exportableStubsSrcJar != nil {
535 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.exportableStubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800536 }
537 },
538 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900539 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800540}
541
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900542func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
543 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800544 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000545 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -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) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000549 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700550 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800551 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000552 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800553 },
554 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900555 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800556}
Colin Crossd96ca352018-08-10 16:06:24 -0700557
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900558func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100559 // If the stubsSrcJar is not generated (because generate_stubs is false) then
560 // use the api file as the output file to ensure the relevant phony targets
561 // are created in make if only the api txt file is being generated. This is
562 // needed because an invalid output file would prevent the make entries from
563 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000564 //
565 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100566 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000567
Paul Duffin3ae29512020-04-08 18:18:03 +0100568 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
569 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000570 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100571 }
Anton Hansson4bf00802022-05-09 10:23:59 +0000572 if !outputFile.Valid() {
Jihoon Kangee113282024-01-23 00:16:41 +0000573 outputFile = android.OptionalPathForPath(dstubs.everythingArtifacts.apiVersionsXml)
Anton Hansson4bf00802022-05-09 10:23:59 +0000574 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900575 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700576 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100577 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700578 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700579 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700580 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jihoon Kang246690a2024-02-01 21:55:01 +0000581 if dstubs.Javadoc.exportableStubsSrcJar != nil {
582 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.exportableStubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700583 }
Jihoon Kangee113282024-01-23 00:16:41 +0000584 if dstubs.everythingArtifacts.apiVersionsXml != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000585 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.exportableArtifacts.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700586 }
Jihoon Kangee113282024-01-23 00:16:41 +0000587 if dstubs.everythingArtifacts.annotationsZip != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000588 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.exportableArtifacts.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700589 }
Jihoon Kangee113282024-01-23 00:16:41 +0000590 if dstubs.everythingArtifacts.metadataZip != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000591 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.exportableArtifacts.metadataZip)
Jerome Gaillard0f599032019-10-10 19:29:11 +0100592 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700593 },
594 },
595 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800596 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100597 if dstubs.apiFile != nil {
598 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
599 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
600 }
601 if dstubs.removedApiFile != nil {
602 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
603 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
604 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700605 if dstubs.checkCurrentApiTimestamp != nil {
606 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
607 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
608 dstubs.checkCurrentApiTimestamp.String())
609
610 fmt.Fprintln(w, ".PHONY: checkapi")
611 fmt.Fprintln(w, "checkapi:",
612 dstubs.checkCurrentApiTimestamp.String())
613
614 fmt.Fprintln(w, ".PHONY: droidcore")
615 fmt.Fprintln(w, "droidcore: checkapi")
616 }
617 if dstubs.updateCurrentApiTimestamp != nil {
618 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
619 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
620 dstubs.updateCurrentApiTimestamp.String())
621
622 fmt.Fprintln(w, ".PHONY: update-api")
623 fmt.Fprintln(w, "update-api:",
624 dstubs.updateCurrentApiTimestamp.String())
625 }
626 if dstubs.checkLastReleasedApiTimestamp != nil {
627 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
628 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
629 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100630
Makoto Onukia573f192020-04-21 11:52:39 -0700631 fmt.Fprintln(w, ".PHONY: checkapi")
632 fmt.Fprintln(w, "checkapi:",
633 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100634
Makoto Onukia573f192020-04-21 11:52:39 -0700635 fmt.Fprintln(w, ".PHONY: droidcore")
636 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700637 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200638 if dstubs.apiLintTimestamp != nil {
639 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
640 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
641 dstubs.apiLintTimestamp.String())
642
643 fmt.Fprintln(w, ".PHONY: checkapi")
644 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100645 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200646
647 fmt.Fprintln(w, ".PHONY: droidcore")
648 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100649
650 if dstubs.apiLintReport != nil {
651 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
652 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
Bob Badour51804382022-04-13 11:27:19 -0700653 fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100654 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200655 }
Pete Gillin581d6082018-10-22 15:55:04 +0100656 if dstubs.checkNullabilityWarningsTimestamp != nil {
657 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
658 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
659 dstubs.checkNullabilityWarningsTimestamp.String())
660
661 fmt.Fprintln(w, ".PHONY:", "droidcore")
662 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
663 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700664 },
665 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900666 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700667}
668
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900669func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700670 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900671 // The non-platform variant is placed inside APEX. No reason to
672 // make it available to Make.
673 return nil
674 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900675 return []android.AndroidMkEntries{android.AndroidMkEntries{
Spandan Das614a6f22024-02-29 19:54:28 +0000676 Class: "APPS",
677 OutputFile: android.OptionalPathForPath(a.outputFile),
678 OverrideName: a.BaseModuleName(), // TODO (spandandas): Add a test
679 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700680 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700681 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900682 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800683 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700684 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
685 if len(a.dexpreopter.builtInstalled) > 0 {
686 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
687 }
688 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800689 if Bool(a.properties.Export_package_resources) {
690 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
691 }
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700692 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700693 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700694 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900695 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700696}
697
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900698func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
699 entriesList := a.AndroidAppImport.AndroidMkEntries()
700 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700701 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700702 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700703 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700704 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900705 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700706}
707
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700708func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700709 var testFiles []string
710 for _, d := range data {
711 testFiles = append(testFiles, d.String()+":"+d.Rel())
712 }
713 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
714}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800715
716func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
717 return []android.AndroidMkEntries{android.AndroidMkEntries{
718 Class: "ETC",
719 OutputFile: android.OptionalPathForPath(r.outputFile),
720 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
721 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700722 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800723 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Colin Crossc68db4b2021-11-11 18:59:15 -0800724 entries.SetPath("LOCAL_MODULE_PATH", r.installDir)
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700725 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700726 // TODO: LOCAL_ACONFIG_FILES -- Might eventually need aconfig flags?
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800727 },
728 },
729 }}
730}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700731
732func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
733 return []android.AndroidMkEntries{
734 android.AndroidMkEntries{
735 Class: "APPS",
Colin Crossffbcd1d2021-11-12 12:19:42 -0800736 OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Sasha Smundaka7856c02020-04-23 09:49:59 -0700737 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
738 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700739 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700740 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Colin Crossffbcd1d2021-11-12 12:19:42 -0800741 entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700742 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700743 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700744 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts -- Both declarations and values
Sasha Smundaka7856c02020-04-23 09:49:59 -0700745 },
746 },
747 },
748 }
749}
Jihoon Kang1bff0342023-01-17 20:40:22 +0000750
751func (al *ApiLibrary) AndroidMkEntries() []android.AndroidMkEntries {
752 var entriesList []android.AndroidMkEntries
753
754 entriesList = append(entriesList, android.AndroidMkEntries{
755 Class: "JAVA_LIBRARIES",
756 OutputFile: android.OptionalPathForPath(al.stubsJar),
757 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
758 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
759 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
760 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
761 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", al.stubsJar)
762 entries.SetPath("LOCAL_SOONG_HEADER_JAR", al.stubsJar)
763 },
764 },
765 })
766
767 return entriesList
768}