blob: bacd925229352c05a330275cbaf033ba364cff17 [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 {
Inseob Kim37e0bb02024-04-29 15:54:44 +090094 entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", library.logtagsSrcs.Strings()...)
Colin Cross5beccee2017-12-07 15:28:59 -080095 }
Colin Cross5beccee2017-12-07 15:28:59 -080096
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +000097 if library.installFile == nil {
Jiyong Park55bd98b2019-12-11 17:27:07 +090098 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
99 }
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100100 if library.dexJarFile.IsSet() {
101 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900102 }
103 if len(library.dexpreopter.builtInstalled) > 0 {
104 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
105 }
Jiyong Park92315372021-04-02 08:45:46 +0900106 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900107 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
108 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800109
Jiyong Park55bd98b2019-12-11 17:27:07 +0900110 if library.jacocoReportClassesFile != nil {
111 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
112 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800113
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100114 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
115 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
Jiyong Park1be96912018-05-28 18:02:19 +0900116
Colin Crosscb6143a2020-08-14 17:39:29 -0700117 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
118 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900119 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700120
Colin Cross08dca382020-07-21 20:31:17 -0700121 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000122
123 if library.dexpreopter.configPath != nil {
124 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
125 }
Jiyong Park55bd98b2019-12-11 17:27:07 +0900126 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700127 },
Colin Cross56a83212020-09-15 18:30:11 -0700128 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900129 }
130
Colin Cross56a83212020-09-15 18:30:11 -0700131 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900132
Jiyong Park55bd98b2019-12-11 17:27:07 +0900133 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700134}
135
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000136func (j *JavaFuzzTest) AndroidMkEntries() []android.AndroidMkEntries {
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000137 entriesList := j.Library.AndroidMkEntries()
138 entries := &entriesList[0]
139 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
140 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
Muhammad Haseeb Ahmadeb14ff22022-09-28 17:53:11 +0000141 androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000142 androidMkWriteTestData(j.jniFilePaths, entries)
143 if j.fuzzPackagedModule.Corpus != nil {
144 androidMkWriteTestData(j.fuzzPackagedModule.Corpus, entries)
145 }
146 if j.fuzzPackagedModule.Dictionary != nil {
147 androidMkWriteTestData(android.Paths{j.fuzzPackagedModule.Dictionary}, entries)
148 }
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000149 })
150 return entriesList
151}
152
Paul Duffin42df1442019-03-20 12:45:53 +0000153// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700154func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700155 entries.SetString("LOCAL_MODULE_TAGS", "tests")
156 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800157 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700158 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800159 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700160 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700161 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700162}
163
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900164func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
165 entriesList := j.Library.AndroidMkEntries()
166 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700167 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700168 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700169 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700170 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700171 }
Dan Shi95d19422020-08-15 12:24:26 -0700172 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700173 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800174 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
175 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
176 }
kellyhung74b00522020-08-17 18:46:00 +0800177 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +0800178
179 j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700180 })
181
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900182 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700183}
184
Dan Shi95d19422020-08-15 12:24:26 -0700185func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
186 if len(extraTestConfigs) > 0 {
187 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
188 }
189}
190
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900191func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
192 entriesList := j.Library.AndroidMkEntries()
193 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700194 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700195 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000196 })
197
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900198 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000199}
200
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900201func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000202 if prebuilt.hideApexVariantFromMake {
Spandan Das2069c3f2023-12-06 19:40:24 +0000203 return []android.AndroidMkEntries{}
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000204 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900205 return []android.AndroidMkEntries{android.AndroidMkEntries{
Spandan Das3cf04632024-01-19 00:22:22 +0000206 Class: "JAVA_LIBRARIES",
207 OverrideName: prebuilt.BaseModuleName(),
Colin Crossdad2a362024-03-23 04:43:41 +0000208 OutputFile: android.OptionalPathForPath(prebuilt.combinedImplementationFile),
Spandan Das3cf04632024-01-19 00:22:22 +0000209 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700210 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700211 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700212 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100213 if prebuilt.dexJarFile.IsSet() {
214 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800215 }
Colin Crossdad2a362024-03-23 04:43:41 +0000216 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedHeaderFile)
217 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedImplementationFile)
Jiyong Park92315372021-04-02 08:45:46 +0900218 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900219 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700220 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossa18e9cf2017-08-10 17:00:19 -0700221 },
222 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900223 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700224}
Colin Cross10a03492017-08-10 17:09:43 -0700225
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900226func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700227 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900228 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900229 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900230 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900231 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900232 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800233 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100234 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800235 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700236 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700237 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100238 if prebuilt.dexJarFile.IsSet() {
239 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Colin Cross42be7612019-02-21 18:12:14 -0800240 }
241 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700242 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800243 }
Jiyong Park0b238752019-10-29 11:23:10 +0900244 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700245 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Cross42be7612019-02-21 18:12:14 -0800246 },
247 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900248 }}
Colin Cross42be7612019-02-21 18:12:14 -0800249}
250
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900251func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700252 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900253 return []android.AndroidMkEntries{{
254 Disabled: true,
255 }}
256 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900257 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800258 Class: "JAVA_LIBRARIES",
Colin Cross9055e212024-03-23 04:43:41 +0000259 OutputFile: android.OptionalPathForPath(prebuilt.implementationJarFile),
Colin Crossfabb6082018-02-20 17:22:23 -0800260 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700261 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700262 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700263 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Cross9055e212024-03-23 04:43:41 +0000264 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.headerJarFile)
265 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.implementationJarFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700266 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800267 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", prebuilt.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700268 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
269 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
270 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900271 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700272 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossfabb6082018-02-20 17:22:23 -0800273 },
274 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900275 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800276}
277
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900278func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700279 if binary.Os() == android.Windows {
280 // Make does not support Windows Java modules
281 return nil
282 }
Colin Cross10a03492017-08-10 17:09:43 -0700283
Cole Faustb9c67e22024-10-08 16:39:56 -0700284 return []android.AndroidMkEntries{{
285 Class: "JAVA_LIBRARIES",
286 OutputFile: android.OptionalPathForPath(binary.outputFile),
287 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
288 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
289 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
290 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
291 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
292 if binary.dexJarFile.IsSet() {
293 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
294 }
295 if len(binary.dexpreopter.builtInstalled) > 0 {
296 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
297 }
298 entries.AddStrings("LOCAL_REQUIRED_MODULES", binary.androidMkNamesOfJniLibs...)
Colin Cross331a1212018-08-15 20:40:52 -0700299 },
Cole Faustb9c67e22024-10-08 16:39:56 -0700300 },
301 }}
Colin Cross10a03492017-08-10 17:09:43 -0700302}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800303
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900304func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Crossaaa0c1f2022-05-16 16:19:54 -0700305 if app.hideApexVariantFromMake || app.IsHideFromMake() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900306 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900307 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900308 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900309 }
Inseob Kim34dc4cd2023-11-07 13:37:14 +0900310 var required []string
311 if proptools.Bool(app.appProperties.Generate_product_characteristics_rro) {
312 required = []string{app.productCharacteristicsRROPackageName()}
313 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900314 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800315 Class: "APPS",
316 OutputFile: android.OptionalPathForPath(app.outputFile),
317 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Inseob Kim34dc4cd2023-11-07 13:37:14 +0900318 Required: required,
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700319 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700320 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700321 // App module names can be overridden.
322 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700323 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Colin Crossf06d8dc2023-07-18 22:11:07 -0700324 if app.headerJarFile != nil {
325 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
326 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700327 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100328 if app.dexJarFile.IsSet() {
329 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800330 }
Colin Cross331a1212018-08-15 20:40:52 -0700331 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700332 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800333 }
334 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700335 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800336 }
Colin Crossf6237212018-10-29 23:14:58 -0700337 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700338 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700339 }
Colin Cross70798562017-12-13 22:42:59 -0800340 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700341 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800342 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700343 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
344 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800345
346 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700347 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800348 // Make base_rules.mk not put framework-res in a subdirectory called
349 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700350 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800351 }
352
Anton Hansson53c88442019-03-18 15:53:16 +0000353 filterRRO := func(filter overlayType) android.Paths {
354 var paths android.Paths
Colin Cross4c90f992023-06-13 16:44:58 -0700355 seen := make(map[android.Path]bool)
356 for _, d := range app.rroDirsDepSet.ToList() {
Anton Hansson53c88442019-03-18 15:53:16 +0000357 if d.overlayType == filter {
Colin Cross4c90f992023-06-13 16:44:58 -0700358 if seen[d.path] {
359 continue
360 }
361 seen[d.path] = true
Anton Hansson53c88442019-03-18 15:53:16 +0000362 paths = append(paths, d.path)
363 }
364 }
Colin Crossa140bb02018-04-17 10:52:26 -0700365 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
366 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000367 return android.ReversePaths(paths)
368 }
369 deviceRRODirs := filterRRO(device)
370 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700371 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000372 }
373 productRRODirs := filterRRO(product)
374 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700375 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800376 }
377
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700378 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800379
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700380 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800381
Jiyong Parkf7487312019-10-17 12:54:30 +0900382 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800383
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800384 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700385 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700386
Colin Cross403cc152020-07-06 14:15:24 -0700387 if app.embeddedJniLibs {
388 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
389 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
Yu Shanb7646e42024-05-17 20:09:23 +0000390 } else {
Jiyong Park25b92222024-05-17 22:58:54 +0000391 var names []string
Yu Shanb7646e42024-05-17 20:09:23 +0000392 for _, jniLib := range app.jniLibs {
Spandan Dasd4530d62024-09-26 00:46:12 +0000393 names = append(names, jniLib.name+":"+jniLib.target.Arch.ArchType.Bitness())
Yu Shanb7646e42024-05-17 20:09:23 +0000394 }
Jiyong Park25b92222024-05-17 22:58:54 +0000395 entries.AddStrings("LOCAL_REQUIRED_MODULES", names...)
Colin Crossa4f08812018-10-02 22:03:40 -0700396 }
Colin Cross403cc152020-07-06 14:15:24 -0700397
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700398 if len(app.jniCoverageOutputs) > 0 {
399 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
400 }
Colin Cross43f08db2018-11-12 10:13:39 -0800401 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700402 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800403 }
Jeongik Chac6246672021-04-08 00:00:19 +0900404 if app.dexpreopter.configPath != nil {
405 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
406 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800407 for _, extra := range app.extraOutputFiles {
408 install := app.onDeviceDir + "/" + extra.Base()
409 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700410 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700411
Colin Cross08dca382020-07-21 20:31:17 -0700412 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700413
Inseob Kim17ce8342024-04-29 16:43:49 +0900414 entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", app.logtagsSrcs.Strings()...)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700415 },
416 },
Matt Banda8c801262022-04-01 17:48:31 +0000417 ExtraFooters: []android.AndroidMkExtraFootersFunc{
418 func(w io.Writer, name, prefix, moduleDir string) {
419 if app.javaApiUsedByOutputFile.String() != "" {
420 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
421 app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
422 }
423 },
424 }},
425 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700426}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800427
Jaewoong Jung9109d722019-01-30 13:13:52 -0800428func (a *AndroidApp) getOverriddenPackages() []string {
429 var overridden []string
zhidoua2ce78f2022-02-17 02:33:12 +0000430 if len(a.overridableAppProperties.Overrides) > 0 {
431 overridden = append(overridden, a.overridableAppProperties.Overrides...)
Jaewoong Jung9109d722019-01-30 13:13:52 -0800432 }
Jaewoong Jung9109d722019-01-30 13:13:52 -0800433 return overridden
434}
435
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900436func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
437 entriesList := a.AndroidApp.AndroidMkEntries()
438 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700439 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700440 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700441 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700442 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700443 }
Dan Shi95d19422020-08-15 12:24:26 -0700444 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700445 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800446 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700447 })
448
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900449 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700450}
451
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900452func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
453 entriesList := a.AndroidApp.AndroidMkEntries()
454 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700455 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700456 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700457 // introduce a flag variable to control the generation of the .config file
458 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700459 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700460
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900461 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700462}
463
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900464func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700465 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900466 return []android.AndroidMkEntries{{
467 Disabled: true,
468 }}
469 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900470 entriesList := a.Library.AndroidMkEntries()
471 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700472
Colin Crossaa255532020-07-03 13:18:24 -0700473 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700474 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700475 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700476 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700477
478 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700479 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700480 // Make base_rules.mk not put framework-res in a subdirectory called
481 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700482 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700483 }
484
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700485 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800486 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", a.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700487 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
488 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Colin Cross312634e2023-11-21 15:13:56 -0800489 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700490 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700491 })
492
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900493 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800494}
Nan Zhang581fd212018-01-10 16:06:12 -0800495
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900496func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
497 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800498 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800499 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700500 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700501 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700502 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700503 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700504 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800505 }
Jihoon Kang246690a2024-02-01 21:55:01 +0000506 if jd.exportableStubsSrcJar != nil {
507 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.exportableStubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800508 }
509 },
510 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900511 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800512}
513
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900514func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
515 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800516 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000517 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700518 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700519 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700520 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000521 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700522 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800523 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000524 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800525 },
526 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900527 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800528}
Colin Crossd96ca352018-08-10 16:06:24 -0700529
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900530func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100531 // If the stubsSrcJar is not generated (because generate_stubs is false) then
532 // use the api file as the output file to ensure the relevant phony targets
533 // are created in make if only the api txt file is being generated. This is
534 // needed because an invalid output file would prevent the make entries from
535 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000536 //
537 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100538 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000539
Paul Duffin3ae29512020-04-08 18:18:03 +0100540 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
541 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000542 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100543 }
Anton Hansson4bf00802022-05-09 10:23:59 +0000544 if !outputFile.Valid() {
Jihoon Kangee113282024-01-23 00:16:41 +0000545 outputFile = android.OptionalPathForPath(dstubs.everythingArtifacts.apiVersionsXml)
Anton Hansson4bf00802022-05-09 10:23:59 +0000546 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900547 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700548 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100549 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700550 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700551 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700552 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jihoon Kang246690a2024-02-01 21:55:01 +0000553 if dstubs.Javadoc.exportableStubsSrcJar != nil {
554 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.exportableStubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700555 }
Jihoon Kangee113282024-01-23 00:16:41 +0000556 if dstubs.everythingArtifacts.apiVersionsXml != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000557 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.exportableArtifacts.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700558 }
Jihoon Kangee113282024-01-23 00:16:41 +0000559 if dstubs.everythingArtifacts.annotationsZip != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000560 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.exportableArtifacts.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700561 }
Jihoon Kangee113282024-01-23 00:16:41 +0000562 if dstubs.everythingArtifacts.metadataZip != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000563 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.exportableArtifacts.metadataZip)
Jerome Gaillard0f599032019-10-10 19:29:11 +0100564 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700565 },
566 },
567 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800568 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100569 if dstubs.apiFile != nil {
570 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
571 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
572 }
573 if dstubs.removedApiFile != nil {
574 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
575 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
576 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700577 if dstubs.checkCurrentApiTimestamp != nil {
578 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
579 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
580 dstubs.checkCurrentApiTimestamp.String())
581
582 fmt.Fprintln(w, ".PHONY: checkapi")
583 fmt.Fprintln(w, "checkapi:",
584 dstubs.checkCurrentApiTimestamp.String())
585
586 fmt.Fprintln(w, ".PHONY: droidcore")
587 fmt.Fprintln(w, "droidcore: checkapi")
588 }
589 if dstubs.updateCurrentApiTimestamp != nil {
590 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
591 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
592 dstubs.updateCurrentApiTimestamp.String())
593
594 fmt.Fprintln(w, ".PHONY: update-api")
595 fmt.Fprintln(w, "update-api:",
596 dstubs.updateCurrentApiTimestamp.String())
597 }
598 if dstubs.checkLastReleasedApiTimestamp != nil {
599 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
600 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
601 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100602
Makoto Onukia573f192020-04-21 11:52:39 -0700603 fmt.Fprintln(w, ".PHONY: checkapi")
604 fmt.Fprintln(w, "checkapi:",
605 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100606
Makoto Onukia573f192020-04-21 11:52:39 -0700607 fmt.Fprintln(w, ".PHONY: droidcore")
608 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700609 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200610 if dstubs.apiLintTimestamp != nil {
611 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
612 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
613 dstubs.apiLintTimestamp.String())
614
615 fmt.Fprintln(w, ".PHONY: checkapi")
616 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100617 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200618
619 fmt.Fprintln(w, ".PHONY: droidcore")
620 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100621
622 if dstubs.apiLintReport != nil {
623 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
624 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
Bob Badour51804382022-04-13 11:27:19 -0700625 fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100626 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200627 }
Pete Gillin581d6082018-10-22 15:55:04 +0100628 if dstubs.checkNullabilityWarningsTimestamp != nil {
629 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
630 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
631 dstubs.checkNullabilityWarningsTimestamp.String())
632
633 fmt.Fprintln(w, ".PHONY:", "droidcore")
634 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
635 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700636 },
637 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900638 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700639}
640
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900641func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700642 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900643 // The non-platform variant is placed inside APEX. No reason to
644 // make it available to Make.
645 return nil
646 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900647 return []android.AndroidMkEntries{android.AndroidMkEntries{
Spandan Das614a6f22024-02-29 19:54:28 +0000648 Class: "APPS",
649 OutputFile: android.OptionalPathForPath(a.outputFile),
650 OverrideName: a.BaseModuleName(), // TODO (spandandas): Add a test
651 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700652 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700653 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900654 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800655 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700656 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
657 if len(a.dexpreopter.builtInstalled) > 0 {
658 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
659 }
660 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800661 if Bool(a.properties.Export_package_resources) {
662 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
663 }
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700664 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700665 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700666 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900667 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700668}
669
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900670func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
671 entriesList := a.AndroidAppImport.AndroidMkEntries()
672 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700673 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700674 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700675 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700676 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900677 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700678}
679
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700680func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700681 var testFiles []string
682 for _, d := range data {
683 testFiles = append(testFiles, d.String()+":"+d.Rel())
684 }
685 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
686}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800687
688func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
689 return []android.AndroidMkEntries{android.AndroidMkEntries{
690 Class: "ETC",
691 OutputFile: android.OptionalPathForPath(r.outputFile),
692 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
693 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700694 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800695 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Colin Crossc68db4b2021-11-11 18:59:15 -0800696 entries.SetPath("LOCAL_MODULE_PATH", r.installDir)
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700697 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700698 // TODO: LOCAL_ACONFIG_FILES -- Might eventually need aconfig flags?
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800699 },
700 },
701 }}
702}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700703
704func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
705 return []android.AndroidMkEntries{
706 android.AndroidMkEntries{
707 Class: "APPS",
Colin Crossffbcd1d2021-11-12 12:19:42 -0800708 OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Sasha Smundaka7856c02020-04-23 09:49:59 -0700709 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
710 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700711 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700712 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Colin Crossffbcd1d2021-11-12 12:19:42 -0800713 entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700714 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700715 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700716 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts -- Both declarations and values
Sasha Smundaka7856c02020-04-23 09:49:59 -0700717 },
718 },
719 },
720 }
721}
Jihoon Kang1bff0342023-01-17 20:40:22 +0000722
723func (al *ApiLibrary) AndroidMkEntries() []android.AndroidMkEntries {
724 var entriesList []android.AndroidMkEntries
725
726 entriesList = append(entriesList, android.AndroidMkEntries{
727 Class: "JAVA_LIBRARIES",
728 OutputFile: android.OptionalPathForPath(al.stubsJar),
729 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
730 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
731 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
732 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
733 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", al.stubsJar)
734 entries.SetPath("LOCAL_SOONG_HEADER_JAR", al.stubsJar)
735 },
736 },
737 })
738
739 return entriesList
740}