blob: c9de7e6d2c467c68ed9bd2515f5a8b9739dd7bfa [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
Jihoon Kangd4063812025-01-24 00:25:30 +000026func (library *Library) hostDexNeeded() bool {
27 return Bool(library.deviceProperties.Hostdex) && !library.Host() && !library.hideApexVariantFromMake
28}
Jiyong Park55bd98b2019-12-11 17:27:07 +090029
Jihoon Kangd4063812025-01-24 00:25:30 +000030func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
31 if library.hostDexNeeded() {
Jiyong Park55bd98b2019-12-11 17:27:07 +090032 var output android.Path
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010033 if library.dexJarFile.IsSet() {
34 output = library.dexJarFile.Path()
Jiyong Park55bd98b2019-12-11 17:27:07 +090035 } else {
36 output = library.implementationAndResourcesJar
37 }
38 return android.AndroidMkEntries{
39 Class: "JAVA_LIBRARIES",
40 SubName: "-hostdex",
41 OutputFile: android.OptionalPathForPath(output),
42 Required: library.deviceProperties.Target.Hostdex.Required,
43 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
44 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070045 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090046 entries.SetBool("LOCAL_IS_HOST_MODULE", true)
47 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010048 if library.dexJarFile.IsSet() {
49 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +090050 }
Colin Cross3108ce12021-11-10 14:38:50 -080051 entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", library.hostdexInstallFile)
Jiyong Park55bd98b2019-12-11 17:27:07 +090052 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
53 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
54 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
55 },
56 },
57 }
58 }
59 return android.AndroidMkEntries{Disabled: true}
Sundong Ahn054b19a2018-10-19 13:46:09 +090060}
61
Jiyong Park0b0e1b92019-12-03 13:24:29 +090062func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park55bd98b2019-12-11 17:27:07 +090063 var entriesList []android.AndroidMkEntries
64
Dan Willemsen9fe14102021-07-13 21:52:04 -070065 if library.Os() == android.Windows {
66 // Make does not support Windows Java modules
67 return nil
68 }
69
Colin Cross56a83212020-09-15 18:30:11 -070070 if library.hideApexVariantFromMake {
Jiakai Zhang519c5c82021-09-16 06:15:39 +000071 // For a java library built for an APEX, we don't need a Make module for itself. Otherwise, it
72 // will conflict with the platform variant because they have the same module name in the
Colin Cross388c6612025-01-28 14:00:12 -080073 // makefile.
Colin Cross56a83212020-09-15 18:30:11 -070074 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +000075 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
76 // Platform variant. If not available for the platform, we don't need Make module.
77 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Liz Kammer60772632023-10-05 17:18:44 -040078 } else if proptools.Bool(library.properties.Headers_only) {
Mark Whitea15790a2023-08-22 21:28:11 +000079 // If generating headers only then don't expose to Make.
80 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000081 } else {
Colin Cross56a83212020-09-15 18:30:11 -070082 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090083 Class: "JAVA_LIBRARIES",
84 OutputFile: android.OptionalPathForPath(library.outputFile),
85 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
86 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070087 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090088 if len(library.logtagsSrcs) > 0 {
Inseob Kim37e0bb02024-04-29 15:54:44 +090089 entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", library.logtagsSrcs.Strings()...)
Colin Cross5beccee2017-12-07 15:28:59 -080090 }
Colin Cross5beccee2017-12-07 15:28:59 -080091
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +000092 if library.installFile == nil {
Jiyong Park55bd98b2019-12-11 17:27:07 +090093 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
94 }
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010095 if library.dexJarFile.IsSet() {
96 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +090097 }
98 if len(library.dexpreopter.builtInstalled) > 0 {
99 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
100 }
Jiyong Park92315372021-04-02 08:45:46 +0900101 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900102 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
103 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800104
Jiyong Park55bd98b2019-12-11 17:27:07 +0900105 if library.jacocoReportClassesFile != nil {
106 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
107 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800108
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100109 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
110 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
Jiyong Park1be96912018-05-28 18:02:19 +0900111
Colin Crosscb6143a2020-08-14 17:39:29 -0700112 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
113 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900114 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700115
Colin Cross08dca382020-07-21 20:31:17 -0700116 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000117
118 if library.dexpreopter.configPath != nil {
119 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
120 }
Jiyong Park55bd98b2019-12-11 17:27:07 +0900121 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700122 },
Jihoon Kang1262e202025-02-07 22:46:09 +0000123 ExtraFooters: []android.AndroidMkExtraFootersFunc{
124 func(w io.Writer, name, prefix, moduleDir string) {
125 if library.apiXmlFile != nil {
126 fmt.Fprintf(w, "$(call declare-1p-target,%s,)\n", library.apiXmlFile.String())
127 fmt.Fprintf(w, "$(eval $(call copy-one-file,%s,$(TARGET_OUT_COMMON_INTERMEDIATES)/%s))\n", library.apiXmlFile.String(), library.apiXmlFile.Base())
128 }
129 },
130 },
Colin Cross56a83212020-09-15 18:30:11 -0700131 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900132 }
133
Colin Cross56a83212020-09-15 18:30:11 -0700134 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900135
Jiyong Park55bd98b2019-12-11 17:27:07 +0900136 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700137}
138
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000139func (j *JavaFuzzTest) AndroidMkEntries() []android.AndroidMkEntries {
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000140 entriesList := j.Library.AndroidMkEntries()
141 entries := &entriesList[0]
142 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
143 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
Muhammad Haseeb Ahmadeb14ff22022-09-28 17:53:11 +0000144 androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
Cory Barkereaf7f5e2023-02-03 00:20:52 +0000145 androidMkWriteTestData(j.jniFilePaths, entries)
146 if j.fuzzPackagedModule.Corpus != nil {
147 androidMkWriteTestData(j.fuzzPackagedModule.Corpus, entries)
148 }
149 if j.fuzzPackagedModule.Dictionary != nil {
150 androidMkWriteTestData(android.Paths{j.fuzzPackagedModule.Dictionary}, entries)
151 }
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000152 })
153 return entriesList
154}
155
Paul Duffin42df1442019-03-20 12:45:53 +0000156// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700157func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700158 entries.SetString("LOCAL_MODULE_TAGS", "tests")
159 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800160 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700161 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800162 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700163 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700164 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700165}
166
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900167func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
168 entriesList := j.Library.AndroidMkEntries()
169 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700170 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700171 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700172 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700173 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700174 }
Dan Shi95d19422020-08-15 12:24:26 -0700175 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700176 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800177 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
178 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
179 }
kellyhung74b00522020-08-17 18:46:00 +0800180 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +0800181
182 j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700183 })
184
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900185 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700186}
187
Dan Shi95d19422020-08-15 12:24:26 -0700188func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
189 if len(extraTestConfigs) > 0 {
190 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
191 }
192}
193
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900194func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
195 entriesList := j.Library.AndroidMkEntries()
196 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700197 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700198 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000199 })
200
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900201 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000202}
203
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900204func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000205 if prebuilt.hideApexVariantFromMake {
Spandan Das2069c3f2023-12-06 19:40:24 +0000206 return []android.AndroidMkEntries{}
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000207 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900208 return []android.AndroidMkEntries{android.AndroidMkEntries{
Spandan Das3cf04632024-01-19 00:22:22 +0000209 Class: "JAVA_LIBRARIES",
210 OverrideName: prebuilt.BaseModuleName(),
Colin Crossdad2a362024-03-23 04:43:41 +0000211 OutputFile: android.OptionalPathForPath(prebuilt.combinedImplementationFile),
Spandan Das3cf04632024-01-19 00:22:22 +0000212 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700213 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700214 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700215 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100216 if prebuilt.dexJarFile.IsSet() {
217 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800218 }
Colin Crossdad2a362024-03-23 04:43:41 +0000219 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedHeaderFile)
220 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedImplementationFile)
Jiyong Park92315372021-04-02 08:45:46 +0900221 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900222 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700223 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossa18e9cf2017-08-10 17:00:19 -0700224 },
225 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900226 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700227}
Colin Cross10a03492017-08-10 17:09:43 -0700228
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900229func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700230 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900231 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900232 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900233 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900234 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900235 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800236 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100237 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800238 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700239 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700240 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100241 if prebuilt.dexJarFile.IsSet() {
242 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Colin Cross42be7612019-02-21 18:12:14 -0800243 }
244 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700245 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800246 }
Jiyong Park0b238752019-10-29 11:23:10 +0900247 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700248 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Cross42be7612019-02-21 18:12:14 -0800249 },
250 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900251 }}
Colin Cross42be7612019-02-21 18:12:14 -0800252}
253
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900254func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700255 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900256 return []android.AndroidMkEntries{{
257 Disabled: true,
258 }}
259 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900260 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800261 Class: "JAVA_LIBRARIES",
Colin Cross9055e212024-03-23 04:43:41 +0000262 OutputFile: android.OptionalPathForPath(prebuilt.implementationJarFile),
Colin Crossfabb6082018-02-20 17:22:23 -0800263 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700264 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700265 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700266 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Cross9055e212024-03-23 04:43:41 +0000267 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.headerJarFile)
268 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.implementationJarFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700269 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800270 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", prebuilt.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700271 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
272 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
273 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900274 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700275 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Colin Crossfabb6082018-02-20 17:22:23 -0800276 },
277 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900278 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800279}
280
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900281func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700282 if binary.Os() == android.Windows {
283 // Make does not support Windows Java modules
284 return nil
285 }
Colin Cross10a03492017-08-10 17:09:43 -0700286
Cole Faustb9c67e22024-10-08 16:39:56 -0700287 return []android.AndroidMkEntries{{
288 Class: "JAVA_LIBRARIES",
289 OutputFile: android.OptionalPathForPath(binary.outputFile),
290 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
291 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
292 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
293 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
294 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
295 if binary.dexJarFile.IsSet() {
296 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
297 }
298 if len(binary.dexpreopter.builtInstalled) > 0 {
299 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
300 }
301 entries.AddStrings("LOCAL_REQUIRED_MODULES", binary.androidMkNamesOfJniLibs...)
Colin Cross331a1212018-08-15 20:40:52 -0700302 },
Cole Faustb9c67e22024-10-08 16:39:56 -0700303 },
304 }}
Colin Cross10a03492017-08-10 17:09:43 -0700305}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800306
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900307func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Crossaaa0c1f2022-05-16 16:19:54 -0700308 if app.hideApexVariantFromMake || app.IsHideFromMake() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900309 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900310 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900311 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900312 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900313 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800314 Class: "APPS",
315 OutputFile: android.OptionalPathForPath(app.outputFile),
316 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Spandan Dasde588a32024-12-03 22:52:24 +0000317 Required: app.requiredModuleNames,
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700318 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700319 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700320 // App module names can be overridden.
321 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700322 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Colin Crossf06d8dc2023-07-18 22:11:07 -0700323 if app.headerJarFile != nil {
324 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
325 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700326 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100327 if app.dexJarFile.IsSet() {
328 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800329 }
Colin Cross331a1212018-08-15 20:40:52 -0700330 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700331 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800332 }
333 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700334 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800335 }
Colin Crossf6237212018-10-29 23:14:58 -0700336 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700337 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700338 }
Colin Cross70798562017-12-13 22:42:59 -0800339 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700340 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800341 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700342 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
343 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800344
345 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700346 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800347 // Make base_rules.mk not put framework-res in a subdirectory called
348 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700349 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800350 }
351
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700352 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800353
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700354 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800355
Jiyong Parkf7487312019-10-17 12:54:30 +0900356 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800357
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800358 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700359 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700360
Colin Cross403cc152020-07-06 14:15:24 -0700361 if app.embeddedJniLibs {
362 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
363 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
Yu Shanb7646e42024-05-17 20:09:23 +0000364 } else {
Jiyong Park25b92222024-05-17 22:58:54 +0000365 var names []string
Yu Shanb7646e42024-05-17 20:09:23 +0000366 for _, jniLib := range app.jniLibs {
Spandan Dasd4530d62024-09-26 00:46:12 +0000367 names = append(names, jniLib.name+":"+jniLib.target.Arch.ArchType.Bitness())
Yu Shanb7646e42024-05-17 20:09:23 +0000368 }
Jiyong Park25b92222024-05-17 22:58:54 +0000369 entries.AddStrings("LOCAL_REQUIRED_MODULES", names...)
Colin Crossa4f08812018-10-02 22:03:40 -0700370 }
Colin Cross403cc152020-07-06 14:15:24 -0700371
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700372 if len(app.jniCoverageOutputs) > 0 {
373 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
374 }
Colin Cross43f08db2018-11-12 10:13:39 -0800375 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700376 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800377 }
Jeongik Chac6246672021-04-08 00:00:19 +0900378 if app.dexpreopter.configPath != nil {
379 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
380 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800381 for _, extra := range app.extraOutputFiles {
382 install := app.onDeviceDir + "/" + extra.Base()
383 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700384 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700385
Colin Cross08dca382020-07-21 20:31:17 -0700386 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700387
Inseob Kim17ce8342024-04-29 16:43:49 +0900388 entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", app.logtagsSrcs.Strings()...)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700389 },
390 },
Matt Banda8c801262022-04-01 17:48:31 +0000391 ExtraFooters: []android.AndroidMkExtraFootersFunc{
392 func(w io.Writer, name, prefix, moduleDir string) {
393 if app.javaApiUsedByOutputFile.String() != "" {
394 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
395 app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
396 }
397 },
398 }},
399 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700400}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800401
Spandan Dase2f98da2024-11-18 19:22:39 +0000402func (a *AutogenRuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
403 if a.IsHideFromMake() || a.outputFile == nil {
404 return []android.AndroidMkEntries{android.AndroidMkEntries{
405 Disabled: true,
406 }}
407 }
408 return []android.AndroidMkEntries{android.AndroidMkEntries{
409 Class: "APPS",
410 OutputFile: android.OptionalPathForPath(a.outputFile),
411 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
412 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
413 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Spandan Dasaf8a3f52024-12-08 18:22:45 +0000414 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Spandan Dase2f98da2024-11-18 19:22:39 +0000415 },
416 },
417 }}
418}
419
Jaewoong Jung9109d722019-01-30 13:13:52 -0800420func (a *AndroidApp) getOverriddenPackages() []string {
421 var overridden []string
zhidoua2ce78f2022-02-17 02:33:12 +0000422 if len(a.overridableAppProperties.Overrides) > 0 {
423 overridden = append(overridden, a.overridableAppProperties.Overrides...)
Jaewoong Jung9109d722019-01-30 13:13:52 -0800424 }
Jaewoong Jung9109d722019-01-30 13:13:52 -0800425 return overridden
426}
427
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900428func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
429 entriesList := a.AndroidApp.AndroidMkEntries()
430 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700431 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700432 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700433 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700434 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700435 }
Dan Shi95d19422020-08-15 12:24:26 -0700436 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700437 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800438 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700439 })
440
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900441 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700442}
443
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900444func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
445 entriesList := a.AndroidApp.AndroidMkEntries()
446 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700447 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700448 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700449 // introduce a flag variable to control the generation of the .config file
450 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700451 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700452
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900453 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700454}
455
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900456func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700457 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900458 return []android.AndroidMkEntries{{
459 Disabled: true,
460 }}
461 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900462 entriesList := a.Library.AndroidMkEntries()
463 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700464
Colin Crossaa255532020-07-03 13:18:24 -0700465 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700466 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700467 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700468 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700469
470 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700471 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700472 // Make base_rules.mk not put framework-res in a subdirectory called
473 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700474 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700475 }
476
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700477 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
Colin Cross312634e2023-11-21 15:13:56 -0800478 entries.SetPath("LOCAL_SOONG_TRANSITIVE_RES_PACKAGES", a.transitiveAaptResourcePackagesFile)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700479 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
480 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Colin Cross312634e2023-11-21 15:13:56 -0800481 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.combinedExportedProguardFlagsFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700482 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700483 })
484
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900485 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800486}
Nan Zhang581fd212018-01-10 16:06:12 -0800487
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900488func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
489 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800490 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800491 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700492 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700493 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700494 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700495 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700496 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800497 }
Jihoon Kang246690a2024-02-01 21:55:01 +0000498 if jd.exportableStubsSrcJar != nil {
499 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.exportableStubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800500 }
501 },
502 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900503 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800504}
505
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900506func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
507 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800508 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000509 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700510 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700511 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700512 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000513 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700514 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800515 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000516 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800517 },
518 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900519 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800520}
Colin Crossd96ca352018-08-10 16:06:24 -0700521
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900522func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100523 // If the stubsSrcJar is not generated (because generate_stubs is false) then
524 // use the api file as the output file to ensure the relevant phony targets
525 // are created in make if only the api txt file is being generated. This is
526 // needed because an invalid output file would prevent the make entries from
527 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000528 //
529 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100530 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000531
Paul Duffin3ae29512020-04-08 18:18:03 +0100532 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
533 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000534 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100535 }
Anton Hansson4bf00802022-05-09 10:23:59 +0000536 if !outputFile.Valid() {
Jihoon Kangee113282024-01-23 00:16:41 +0000537 outputFile = android.OptionalPathForPath(dstubs.everythingArtifacts.apiVersionsXml)
Anton Hansson4bf00802022-05-09 10:23:59 +0000538 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900539 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700540 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100541 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700542 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700543 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700544 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jihoon Kang246690a2024-02-01 21:55:01 +0000545 if dstubs.Javadoc.exportableStubsSrcJar != nil {
546 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.exportableStubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700547 }
Jihoon Kangee113282024-01-23 00:16:41 +0000548 if dstubs.everythingArtifacts.apiVersionsXml != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000549 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.exportableArtifacts.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700550 }
Jihoon Kangee113282024-01-23 00:16:41 +0000551 if dstubs.everythingArtifacts.annotationsZip != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000552 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.exportableArtifacts.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700553 }
Jihoon Kangee113282024-01-23 00:16:41 +0000554 if dstubs.everythingArtifacts.metadataZip != nil {
Jihoon Kang246690a2024-02-01 21:55:01 +0000555 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.exportableArtifacts.metadataZip)
Jerome Gaillard0f599032019-10-10 19:29:11 +0100556 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700557 },
558 },
559 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800560 func(w io.Writer, name, prefix, moduleDir string) {
Adrian Roos075eedc2019-10-10 12:07:03 +0200561 if dstubs.apiLintTimestamp != nil {
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100562 if dstubs.apiLintReport != nil {
Bob Badour51804382022-04-13 11:27:19 -0700563 fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100564 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200565 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700566 },
567 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900568 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700569}
570
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900571func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700572 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900573 // The non-platform variant is placed inside APEX. No reason to
574 // make it available to Make.
575 return nil
576 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900577 return []android.AndroidMkEntries{android.AndroidMkEntries{
Spandan Das614a6f22024-02-29 19:54:28 +0000578 Class: "APPS",
579 OutputFile: android.OptionalPathForPath(a.outputFile),
580 OverrideName: a.BaseModuleName(), // TODO (spandandas): Add a test
581 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700582 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700583 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900584 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800585 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700586 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
587 if len(a.dexpreopter.builtInstalled) > 0 {
588 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
589 }
590 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800591 if Bool(a.properties.Export_package_resources) {
592 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
593 }
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700594 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700595 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700596 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900597 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700598}
599
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900600func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
601 entriesList := a.AndroidAppImport.AndroidMkEntries()
602 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700603 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700604 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700605 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700606 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900607 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700608}
609
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700610func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700611 var testFiles []string
612 for _, d := range data {
613 testFiles = append(testFiles, d.String()+":"+d.Rel())
614 }
615 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
616}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800617
618func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
619 return []android.AndroidMkEntries{android.AndroidMkEntries{
620 Class: "ETC",
621 OutputFile: android.OptionalPathForPath(r.outputFile),
622 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
623 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700624 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800625 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Colin Crossc68db4b2021-11-11 18:59:15 -0800626 entries.SetPath("LOCAL_MODULE_PATH", r.installDir)
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700627 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700628 // TODO: LOCAL_ACONFIG_FILES -- Might eventually need aconfig flags?
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800629 },
630 },
631 }}
632}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700633
634func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
635 return []android.AndroidMkEntries{
636 android.AndroidMkEntries{
637 Class: "APPS",
Colin Crossffbcd1d2021-11-12 12:19:42 -0800638 OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Sasha Smundaka7856c02020-04-23 09:49:59 -0700639 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
640 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700641 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700642 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Colin Crossffbcd1d2021-11-12 12:19:42 -0800643 entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700644 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700645 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
Joe Onorato6fe59eb2023-07-16 13:20:33 -0700646 // TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts -- Both declarations and values
Sasha Smundaka7856c02020-04-23 09:49:59 -0700647 },
648 },
649 },
650 }
651}
Jihoon Kang1bff0342023-01-17 20:40:22 +0000652
653func (al *ApiLibrary) AndroidMkEntries() []android.AndroidMkEntries {
654 var entriesList []android.AndroidMkEntries
655
656 entriesList = append(entriesList, android.AndroidMkEntries{
657 Class: "JAVA_LIBRARIES",
658 OutputFile: android.OptionalPathForPath(al.stubsJar),
659 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
660 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
661 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
662 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
663 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", al.stubsJar)
664 entries.SetPath("LOCAL_SOONG_HEADER_JAR", al.stubsJar)
665 },
666 },
667 })
668
669 return entriesList
670}