blob: e1b4efd7a0d62109e01e1348e7a4145ebf86b35b [file] [log] [blame]
Dan Willemsen218f6562015-07-08 18:13:11 -07001// Copyright 2015 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package java
16
17import (
Colin Cross74d73e22017-08-02 11:05:49 -070018 "fmt"
19 "io"
Jihoon Kangf78a8902022-09-01 22:47:07 +000020 "strings"
Colin Cross74d73e22017-08-02 11:05:49 -070021
Colin Cross635c3b02016-05-18 15:37:25 -070022 "android/soong/android"
Liz Kammer60772632023-10-05 17:18:44 -040023
24 "github.com/google/blueprint/proptools"
Dan Willemsen218f6562015-07-08 18:13:11 -070025)
26
Jiyong Park55bd98b2019-12-11 17:27:07 +090027func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
28 hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
Colin Cross56a83212020-09-15 18:30:11 -070029 if library.hideApexVariantFromMake {
Jiyong Park55bd98b2019-12-11 17:27:07 +090030 hostDexNeeded = false
Sundong Ahn054b19a2018-10-19 13:46:09 +090031 }
Jiyong Park55bd98b2019-12-11 17:27:07 +090032
33 if hostDexNeeded {
34 var output android.Path
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010035 if library.dexJarFile.IsSet() {
36 output = library.dexJarFile.Path()
Jiyong Park55bd98b2019-12-11 17:27:07 +090037 } else {
38 output = library.implementationAndResourcesJar
39 }
40 return android.AndroidMkEntries{
41 Class: "JAVA_LIBRARIES",
42 SubName: "-hostdex",
43 OutputFile: android.OptionalPathForPath(output),
44 Required: library.deviceProperties.Target.Hostdex.Required,
45 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
46 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070047 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090048 entries.SetBool("LOCAL_IS_HOST_MODULE", true)
49 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010050 if library.dexJarFile.IsSet() {
51 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +090052 }
Colin Cross3108ce12021-11-10 14:38:50 -080053 entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", library.hostdexInstallFile)
Jiyong Park55bd98b2019-12-11 17:27:07 +090054 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
55 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
56 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
57 },
58 },
59 }
60 }
61 return android.AndroidMkEntries{Disabled: true}
Sundong Ahn054b19a2018-10-19 13:46:09 +090062}
63
Jiyong Park0b0e1b92019-12-03 13:24:29 +090064func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park55bd98b2019-12-11 17:27:07 +090065 var entriesList []android.AndroidMkEntries
66
Dan Willemsen9fe14102021-07-13 21:52:04 -070067 if library.Os() == android.Windows {
68 // Make does not support Windows Java modules
69 return nil
70 }
71
Colin Cross56a83212020-09-15 18:30:11 -070072 if library.hideApexVariantFromMake {
Jiakai Zhang519c5c82021-09-16 06:15:39 +000073 // For a java library built for an APEX, we don't need a Make module for itself. Otherwise, it
74 // will conflict with the platform variant because they have the same module name in the
75 // makefile. However, we need to add its dexpreopt outputs as sub-modules, if it is preopted.
76 dexpreoptEntries := library.dexpreopter.AndroidMkEntriesForApex()
77 if len(dexpreoptEntries) > 0 {
78 entriesList = append(entriesList, dexpreoptEntries...)
79 }
Colin Cross56a83212020-09-15 18:30:11 -070080 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +000081 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
82 // Platform variant. If not available for the platform, we don't need Make module.
83 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Liz Kammer60772632023-10-05 17:18:44 -040084 } else if proptools.Bool(library.properties.Headers_only) {
Mark Whitea15790a2023-08-22 21:28:11 +000085 // If generating headers only then don't expose to Make.
86 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000087 } else {
Colin Cross56a83212020-09-15 18:30:11 -070088 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090089 Class: "JAVA_LIBRARIES",
90 OutputFile: android.OptionalPathForPath(library.outputFile),
91 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
92 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070093 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090094 if len(library.logtagsSrcs) > 0 {
95 var logtags []string
96 for _, l := range library.logtagsSrcs {
97 logtags = append(logtags, l.Rel())
98 }
99 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -0800100 }
Colin Cross5beccee2017-12-07 15:28:59 -0800101
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +0000102 if library.installFile == nil {
Jiyong Park55bd98b2019-12-11 17:27:07 +0900103 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
104 }
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100105 if library.dexJarFile.IsSet() {
106 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900107 }
108 if len(library.dexpreopter.builtInstalled) > 0 {
109 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
110 }
Jiyong Park92315372021-04-02 08:45:46 +0900111 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900112 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
113 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800114
Jiyong Park55bd98b2019-12-11 17:27:07 +0900115 if library.jacocoReportClassesFile != nil {
116 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
117 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800118
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100119 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
120 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
Jiyong Park1be96912018-05-28 18:02:19 +0900121
Colin Crosscb6143a2020-08-14 17:39:29 -0700122 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
123 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900124 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700125
Colin Cross08dca382020-07-21 20:31:17 -0700126 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000127
128 if library.dexpreopter.configPath != nil {
129 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
130 }
LaMont Jonesacae2d72024-01-09 22:53:52 +0000131 android.SetAconfigFileMkEntries(&library.ModuleBase, entries, library.mergedAconfigFiles)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900132 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700133 },
Colin Cross56a83212020-09-15 18:30:11 -0700134 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900135 }
136
Colin Cross56a83212020-09-15 18:30:11 -0700137 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900138
Jiyong Park55bd98b2019-12-11 17:27:07 +0900139 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700140}
141
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000142func (j *JavaFuzzTest) AndroidMkEntries() []android.AndroidMkEntries {
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000143 entriesList := j.Library.AndroidMkEntries()
144 entries := &entriesList[0]
145 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
146 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
Muhammad Haseeb Ahmadeb14ff22022-09-28 17:53:11 +0000147 androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000148 androidMkWriteTestData(j.jniFilePaths, entries)
149 if j.fuzzPackagedModule.Corpus != nil {
150 androidMkWriteTestData(j.fuzzPackagedModule.Corpus, entries)
151 }
152 if j.fuzzPackagedModule.Dictionary != nil {
153 androidMkWriteTestData(android.Paths{j.fuzzPackagedModule.Dictionary}, entries)
154 }
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000155 })
156 return entriesList
157}
158
Paul Duffin42df1442019-03-20 12:45:53 +0000159// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700160func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700161 entries.SetString("LOCAL_MODULE_TAGS", "tests")
162 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800163 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700164 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800165 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700166 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700167 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700168}
169
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900170func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
171 entriesList := j.Library.AndroidMkEntries()
172 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700173 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700174 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700175 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700176 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700177 }
Dan Shi95d19422020-08-15 12:24:26 -0700178 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700179 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800180 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
181 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
182 }
kellyhung74b00522020-08-17 18:46:00 +0800183 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +0800184
185 j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700186 })
187
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900188 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700189}
190
Dan Shi95d19422020-08-15 12:24:26 -0700191func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
192 if len(extraTestConfigs) > 0 {
193 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
194 }
195}
196
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900197func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
198 entriesList := j.Library.AndroidMkEntries()
199 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700200 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700201 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000202 })
203
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900204 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000205}
206
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900207func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000208 if prebuilt.hideApexVariantFromMake {
Spandan Das2069c3f2023-12-06 19:40:24 +0000209 return []android.AndroidMkEntries{}
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000210 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900211 return []android.AndroidMkEntries{android.AndroidMkEntries{
Spandan Das3cf04632024-01-19 00:22:22 +0000212 Class: "JAVA_LIBRARIES",
213 OverrideName: prebuilt.BaseModuleName(),
Colin Crossc6c9c732024-03-22 18:16:57 +0000214 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Spandan Das3cf04632024-01-19 00:22:22 +0000215 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700216 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700217 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700218 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100219 if prebuilt.dexJarFile.IsSet() {
220 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800221 }
Colin Crossc6c9c732024-03-22 18:16:57 +0000222 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
223 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park92315372021-04-02 08:45:46 +0900224 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900225 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700226 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossa18e9cf2017-08-10 17:00:19 -0700227 },
228 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900229 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700230}
Colin Cross10a03492017-08-10 17:09:43 -0700231
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900232func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700233 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900234 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900235 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900236 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900237 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900238 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800239 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100240 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800241 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700242 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700243 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100244 if prebuilt.dexJarFile.IsSet() {
245 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Colin Cross42be7612019-02-21 18:12:14 -0800246 }
247 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700248 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800249 }
Jiyong Park0b238752019-10-29 11:23:10 +0900250 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700251 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Cross42be7612019-02-21 18:12:14 -0800252 },
253 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900254 }}
Colin Cross42be7612019-02-21 18:12:14 -0800255}
256
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900257func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700258 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900259 return []android.AndroidMkEntries{{
260 Disabled: true,
261 }}
262 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900263 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800264 Class: "JAVA_LIBRARIES",
Colin Cross9055e212024-03-23 04:43:41 +0000265 OutputFile: android.OptionalPathForPath(prebuilt.implementationJarFile),
Colin Crossfabb6082018-02-20 17:22:23 -0800266 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700267 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700268 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700269 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Cross9055e212024-03-23 04:43:41 +0000270 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.headerJarFile)
271 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.implementationJarFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700272 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800273 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", prebuilt.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700274 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
275 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
276 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900277 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700278 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossfabb6082018-02-20 17:22:23 -0800279 },
280 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900281 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800282}
283
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900284func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700285 if binary.Os() == android.Windows {
286 // Make does not support Windows Java modules
287 return nil
288 }
Colin Cross10a03492017-08-10 17:09:43 -0700289
Colin Cross6b4a32d2017-12-05 13:42:45 -0800290 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900291 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800292 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700293 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800294 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700295 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700296 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700297 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
298 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100299 if binary.dexJarFile.IsSet() {
300 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
Colin Cross12fc2af2019-01-14 12:35:45 -0800301 }
302 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700303 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800304 }
LaMont Jonesacae2d72024-01-09 22:53:52 +0000305 android.SetAconfigFileMkEntries(&binary.ModuleBase, entries, binary.mergedAconfigFiles)
Colin Cross331a1212018-08-15 20:40:52 -0700306 },
307 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700308 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800309 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700310 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
311 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800312 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900313 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800314 } else {
Colin Cross44b85d02021-02-19 17:37:04 -0800315 outputFile := binary.wrapperFile
Colin Cross44b85d02021-02-19 17:37:04 -0800316
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900317 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800318 Class: "EXECUTABLES",
Colin Cross44b85d02021-02-19 17:37:04 -0800319 OutputFile: android.OptionalPathForPath(outputFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700320 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700321 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700322 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800323 },
324 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700325 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800326 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700327 // Ensure that the wrapper script timestamp is always updated when the jar is updated
328 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
329 fmt.Fprintln(w, "jar_installed_module :=")
330 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800331 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900332 }}
Colin Cross10a03492017-08-10 17:09:43 -0700333 }
334}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800335
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900336func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Crossaaa0c1f2022-05-16 16:19:54 -0700337 if app.hideApexVariantFromMake || app.IsHideFromMake() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900338 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900339 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900340 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900341 }
Inseob Kim34dc4cd2023-11-07 13:37:14 +0900342 var required []string
343 if proptools.Bool(app.appProperties.Generate_product_characteristics_rro) {
344 required = []string{app.productCharacteristicsRROPackageName()}
345 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900346 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800347 Class: "APPS",
348 OutputFile: android.OptionalPathForPath(app.outputFile),
349 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Inseob Kim34dc4cd2023-11-07 13:37:14 +0900350 Required: required,
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700351 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700352 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700353 // App module names can be overridden.
354 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700355 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Colin Crossf06d8dc2023-07-18 22:11:07 -0700356 if app.headerJarFile != nil {
357 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
358 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700359 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100360 if app.dexJarFile.IsSet() {
361 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800362 }
Colin Cross331a1212018-08-15 20:40:52 -0700363 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700364 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800365 }
366 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700367 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800368 }
Colin Crossf6237212018-10-29 23:14:58 -0700369 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700370 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700371 }
Colin Cross70798562017-12-13 22:42:59 -0800372 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700373 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800374 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700375 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
376 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800377
378 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700379 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800380 // Make base_rules.mk not put framework-res in a subdirectory called
381 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700382 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800383 }
384
Anton Hansson53c88442019-03-18 15:53:16 +0000385 filterRRO := func(filter overlayType) android.Paths {
386 var paths android.Paths
Colin Cross4c90f992023-06-13 16:44:58 -0700387 seen := make(map[android.Path]bool)
388 for _, d := range app.rroDirsDepSet.ToList() {
Anton Hansson53c88442019-03-18 15:53:16 +0000389 if d.overlayType == filter {
Colin Cross4c90f992023-06-13 16:44:58 -0700390 if seen[d.path] {
391 continue
392 }
393 seen[d.path] = true
Anton Hansson53c88442019-03-18 15:53:16 +0000394 paths = append(paths, d.path)
395 }
396 }
Colin Crossa140bb02018-04-17 10:52:26 -0700397 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
398 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000399 return android.ReversePaths(paths)
400 }
401 deviceRRODirs := filterRRO(device)
402 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700403 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000404 }
405 productRRODirs := filterRRO(product)
406 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700407 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800408 }
409
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700410 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800411
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700412 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800413
Jiyong Parkf7487312019-10-17 12:54:30 +0900414 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800415
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800416 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700417 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700418
Colin Cross403cc152020-07-06 14:15:24 -0700419 if app.embeddedJniLibs {
420 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
421 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
422 } else {
423 for _, jniLib := range app.jniLibs {
424 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Jihoon Kangf78a8902022-09-01 22:47:07 +0000425 var partitionTag string
426
427 // Mimic the creation of partition_tag in build/make,
428 // which defaults to an empty string when the partition is system.
429 // Otherwise, capitalize with a leading _
430 if jniLib.partition == "system" {
431 partitionTag = ""
432 } else {
433 split := strings.Split(jniLib.partition, "/")
434 partitionTag = "_" + strings.ToUpper(split[len(split)-1])
435 }
436 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_PARTITION_"+jniLib.target.Arch.ArchType.String(),
437 jniLib.name+":"+partitionTag)
Colin Cross403cc152020-07-06 14:15:24 -0700438 }
Colin Crossa4f08812018-10-02 22:03:40 -0700439 }
Colin Cross403cc152020-07-06 14:15:24 -0700440
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700441 if len(app.jniCoverageOutputs) > 0 {
442 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
443 }
Colin Cross43f08db2018-11-12 10:13:39 -0800444 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700445 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800446 }
Jeongik Chac6246672021-04-08 00:00:19 +0900447 if app.dexpreopter.configPath != nil {
448 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
449 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800450 for _, extra := range app.extraOutputFiles {
451 install := app.onDeviceDir + "/" + extra.Base()
452 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700453 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700454
Colin Cross08dca382020-07-21 20:31:17 -0700455 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700456
457 if app.Name() != "framework-res" {
LaMont Jonesacae2d72024-01-09 22:53:52 +0000458 android.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700459 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700460 },
461 },
Matt Banda8c801262022-04-01 17:48:31 +0000462 ExtraFooters: []android.AndroidMkExtraFootersFunc{
463 func(w io.Writer, name, prefix, moduleDir string) {
464 if app.javaApiUsedByOutputFile.String() != "" {
465 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
466 app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
467 }
468 },
469 }},
470 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700471}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800472
Jaewoong Jung9109d722019-01-30 13:13:52 -0800473func (a *AndroidApp) getOverriddenPackages() []string {
474 var overridden []string
zhidoua2ce78f2022-02-17 02:33:12 +0000475 if len(a.overridableAppProperties.Overrides) > 0 {
476 overridden = append(overridden, a.overridableAppProperties.Overrides...)
Jaewoong Jung9109d722019-01-30 13:13:52 -0800477 }
Jaewoong Jung9109d722019-01-30 13:13:52 -0800478 return overridden
479}
480
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900481func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
482 entriesList := a.AndroidApp.AndroidMkEntries()
483 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700484 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700485 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700486 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700487 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700488 }
Dan Shi95d19422020-08-15 12:24:26 -0700489 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700490 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800491 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700492 })
493
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900494 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700495}
496
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900497func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
498 entriesList := a.AndroidApp.AndroidMkEntries()
499 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700500 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700501 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700502 // introduce a flag variable to control the generation of the .config file
503 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700504 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700505
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900506 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700507}
508
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900509func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700510 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900511 return []android.AndroidMkEntries{{
512 Disabled: true,
513 }}
514 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900515 entriesList := a.Library.AndroidMkEntries()
516 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700517
Colin Crossaa255532020-07-03 13:18:24 -0700518 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700519 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700520 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700521 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700522
523 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700524 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700525 // Make base_rules.mk not put framework-res in a subdirectory called
526 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700527 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700528 }
529
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700530 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800531 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", a.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700532 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
533 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Colin Cross312634e2023-11-21 15:13:56 -0800534 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700535 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
LaMont Jonesacae2d72024-01-09 22:53:52 +0000536 android.SetAconfigFileMkEntries(&a.ModuleBase, entries, a.mergedAconfigFiles)
Colin Crossa97c5d32018-03-28 14:58:31 -0700537 })
538
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900539 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800540}
Nan Zhang581fd212018-01-10 16:06:12 -0800541
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900542func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
543 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800544 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800545 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
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) {
Colin Cross38b40df2018-04-10 16:14:46 -0700549 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700550 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800551 }
Jihoon Kang246690a2024-02-01 21:55:01 +0000552 if jd.exportableStubsSrcJar != nil {
553 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.exportableStubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800554 }
555 },
556 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900557 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800558}
559
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900560func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
561 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800562 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000563 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700564 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700565 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700566 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000567 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700568 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800569 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000570 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800571 },
572 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900573 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800574}
Colin Crossd96ca352018-08-10 16:06:24 -0700575
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900576func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100577 // If the stubsSrcJar is not generated (because generate_stubs is false) then
578 // use the api file as the output file to ensure the relevant phony targets
579 // are created in make if only the api txt file is being generated. This is
580 // needed because an invalid output file would prevent the make entries from
581 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000582 //
583 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100584 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000585
Paul Duffin3ae29512020-04-08 18:18:03 +0100586 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
587 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000588 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100589 }
Anton Hansson4bf00802022-05-09 10:23:59 +0000590 if !outputFile.Valid() {
Jihoon Kangee113282024-01-23 00:16:41 +0000591 outputFile = android.OptionalPathForPath(dstubs.everythingArtifacts.apiVersionsXml)
Anton Hansson4bf00802022-05-09 10:23:59 +0000592 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900593 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700594 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100595 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700596 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700597 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700598 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jihoon Kang246690a2024-02-01 21:55:01 +0000599 if dstubs.Javadoc.exportableStubsSrcJar != nil {
600 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.exportableStubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700601 }
Jihoon Kangee113282024-01-23 00:16:41 +0000602 if dstubs.everythingArtifacts.apiVersionsXml != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000603 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.exportableArtifacts.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700604 }
Jihoon Kangee113282024-01-23 00:16:41 +0000605 if dstubs.everythingArtifacts.annotationsZip != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000606 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.exportableArtifacts.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700607 }
Jihoon Kangee113282024-01-23 00:16:41 +0000608 if dstubs.everythingArtifacts.metadataZip != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000609 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.exportableArtifacts.metadataZip)
Jerome Gaillard0f599032019-10-10 19:29:11 +0100610 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700611 },
612 },
613 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800614 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100615 if dstubs.apiFile != nil {
616 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
617 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
618 }
619 if dstubs.removedApiFile != nil {
620 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
621 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
622 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700623 if dstubs.checkCurrentApiTimestamp != nil {
624 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
625 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
626 dstubs.checkCurrentApiTimestamp.String())
627
628 fmt.Fprintln(w, ".PHONY: checkapi")
629 fmt.Fprintln(w, "checkapi:",
630 dstubs.checkCurrentApiTimestamp.String())
631
632 fmt.Fprintln(w, ".PHONY: droidcore")
633 fmt.Fprintln(w, "droidcore: checkapi")
634 }
635 if dstubs.updateCurrentApiTimestamp != nil {
636 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
637 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
638 dstubs.updateCurrentApiTimestamp.String())
639
640 fmt.Fprintln(w, ".PHONY: update-api")
641 fmt.Fprintln(w, "update-api:",
642 dstubs.updateCurrentApiTimestamp.String())
643 }
644 if dstubs.checkLastReleasedApiTimestamp != nil {
645 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
646 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
647 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100648
Makoto Onukia573f192020-04-21 11:52:39 -0700649 fmt.Fprintln(w, ".PHONY: checkapi")
650 fmt.Fprintln(w, "checkapi:",
651 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100652
Makoto Onukia573f192020-04-21 11:52:39 -0700653 fmt.Fprintln(w, ".PHONY: droidcore")
654 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700655 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200656 if dstubs.apiLintTimestamp != nil {
657 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
658 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
659 dstubs.apiLintTimestamp.String())
660
661 fmt.Fprintln(w, ".PHONY: checkapi")
662 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100663 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200664
665 fmt.Fprintln(w, ".PHONY: droidcore")
666 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100667
668 if dstubs.apiLintReport != nil {
669 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
670 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
Bob Badour51804382022-04-13 11:27:19 -0700671 fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100672 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200673 }
Pete Gillin581d6082018-10-22 15:55:04 +0100674 if dstubs.checkNullabilityWarningsTimestamp != nil {
675 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
676 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
677 dstubs.checkNullabilityWarningsTimestamp.String())
678
679 fmt.Fprintln(w, ".PHONY:", "droidcore")
680 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
681 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700682 },
683 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900684 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700685}
686
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900687func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700688 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900689 // The non-platform variant is placed inside APEX. No reason to
690 // make it available to Make.
691 return nil
692 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900693 return []android.AndroidMkEntries{android.AndroidMkEntries{
Spandan Das614a6f22024-02-29 19:54:28 +0000694 Class: "APPS",
695 OutputFile: android.OptionalPathForPath(a.outputFile),
696 OverrideName: a.BaseModuleName(), // TODO (spandandas): Add a test
697 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700698 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700699 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900700 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800701 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700702 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
703 if len(a.dexpreopter.builtInstalled) > 0 {
704 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
705 }
706 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800707 if Bool(a.properties.Export_package_resources) {
708 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
709 }
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700710 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700711 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700712 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900713 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700714}
715
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900716func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
717 entriesList := a.AndroidAppImport.AndroidMkEntries()
718 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700719 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700720 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700721 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700722 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900723 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700724}
725
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700726func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700727 var testFiles []string
728 for _, d := range data {
729 testFiles = append(testFiles, d.String()+":"+d.Rel())
730 }
731 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
732}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800733
734func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
735 return []android.AndroidMkEntries{android.AndroidMkEntries{
736 Class: "ETC",
737 OutputFile: android.OptionalPathForPath(r.outputFile),
738 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
739 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700740 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800741 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Colin Crossc68db4b2021-11-11 18:59:15 -0800742 entries.SetPath("LOCAL_MODULE_PATH", r.installDir)
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700743 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700744 // TODO: LOCAL_ACONFIG_FILES -- Might eventually need aconfig flags?
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800745 },
746 },
747 }}
748}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700749
750func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
751 return []android.AndroidMkEntries{
752 android.AndroidMkEntries{
753 Class: "APPS",
Colin Crossffbcd1d2021-11-12 12:19:42 -0800754 OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Sasha Smundaka7856c02020-04-23 09:49:59 -0700755 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
756 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700757 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700758 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Colin Crossffbcd1d2021-11-12 12:19:42 -0800759 entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700760 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700761 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700762 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts -- Both declarations and values
Sasha Smundaka7856c02020-04-23 09:49:59 -0700763 },
764 },
765 },
766 }
767}
Jihoon Kang1bff0342023-01-17 20:40:22 +0000768
769func (al *ApiLibrary) AndroidMkEntries() []android.AndroidMkEntries {
770 var entriesList []android.AndroidMkEntries
771
772 entriesList = append(entriesList, android.AndroidMkEntries{
773 Class: "JAVA_LIBRARIES",
774 OutputFile: android.OptionalPathForPath(al.stubsJar),
775 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
776 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
777 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
778 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
779 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", al.stubsJar)
780 entries.SetPath("LOCAL_SOONG_HEADER_JAR", al.stubsJar)
781 },
782 },
783 })
784
785 return entriesList
786}