blob: d73ff4616df711f6d09b436b680d55447d258bfc [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"
Dan Willemsen218f6562015-07-08 18:13:11 -070023)
24
Jiyong Park55bd98b2019-12-11 17:27:07 +090025func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
26 hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
Colin Cross56a83212020-09-15 18:30:11 -070027 if library.hideApexVariantFromMake {
Jiyong Park55bd98b2019-12-11 17:27:07 +090028 hostDexNeeded = false
Sundong Ahn054b19a2018-10-19 13:46:09 +090029 }
Jiyong Park55bd98b2019-12-11 17:27:07 +090030
31 if hostDexNeeded {
32 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
73 // makefile. However, we need to add its dexpreopt outputs as sub-modules, if it is preopted.
74 dexpreoptEntries := library.dexpreopter.AndroidMkEntriesForApex()
75 if len(dexpreoptEntries) > 0 {
76 entriesList = append(entriesList, dexpreoptEntries...)
77 }
Colin Cross56a83212020-09-15 18:30:11 -070078 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000079 } else {
Colin Cross56a83212020-09-15 18:30:11 -070080 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090081 Class: "JAVA_LIBRARIES",
82 OutputFile: android.OptionalPathForPath(library.outputFile),
83 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
84 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070085 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090086 if len(library.logtagsSrcs) > 0 {
87 var logtags []string
88 for _, l := range library.logtagsSrcs {
89 logtags = append(logtags, l.Rel())
90 }
91 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080092 }
Colin Cross5beccee2017-12-07 15:28:59 -080093
Cole Faust502da392023-02-28 17:54:17 -080094 if library.installFile == nil || !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
95 // If the ApexModule is not available for the platform, it shouldn't be installed.
Jiyong Park55bd98b2019-12-11 17:27:07 +090096 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
97 }
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010098 if library.dexJarFile.IsSet() {
99 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900100 }
101 if len(library.dexpreopter.builtInstalled) > 0 {
102 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
103 }
Jiyong Park92315372021-04-02 08:45:46 +0900104 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900105 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
106 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800107
Jiyong Park55bd98b2019-12-11 17:27:07 +0900108 if library.jacocoReportClassesFile != nil {
109 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
110 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800111
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100112 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
113 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
Jiyong Park1be96912018-05-28 18:02:19 +0900114
Colin Crosscb6143a2020-08-14 17:39:29 -0700115 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
116 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900117 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700118
Colin Cross08dca382020-07-21 20:31:17 -0700119 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000120
121 if library.dexpreopter.configPath != nil {
122 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
123 }
Jiyong Park55bd98b2019-12-11 17:27:07 +0900124 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700125 },
Colin Cross56a83212020-09-15 18:30:11 -0700126 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900127 }
128
Colin Cross56a83212020-09-15 18:30:11 -0700129 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900130
Jiyong Park55bd98b2019-12-11 17:27:07 +0900131 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700132}
133
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000134func (j *JavaFuzzLibrary) AndroidMkEntries() []android.AndroidMkEntries {
135 entriesList := j.Library.AndroidMkEntries()
136 entries := &entriesList[0]
137 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
138 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
139 androidMkWriteTestData(j.jniFilePaths, entries)
Muhammad Haseeb Ahmadeb14ff22022-09-28 17:53:11 +0000140 androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000141 })
142 return entriesList
143}
144
Paul Duffin42df1442019-03-20 12:45:53 +0000145// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700146func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700147 entries.SetString("LOCAL_MODULE_TAGS", "tests")
148 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800149 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700150 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800151 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700152 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700153 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700154}
155
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900156func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
157 entriesList := j.Library.AndroidMkEntries()
158 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700159 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700160 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700161 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700162 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700163 }
Dan Shi95d19422020-08-15 12:24:26 -0700164 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700165 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800166 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
167 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
168 }
kellyhung74b00522020-08-17 18:46:00 +0800169 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +0800170
171 j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700172 })
173
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900174 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700175}
176
Dan Shi95d19422020-08-15 12:24:26 -0700177func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
178 if len(extraTestConfigs) > 0 {
179 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
180 }
181}
182
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900183func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
184 entriesList := j.Library.AndroidMkEntries()
185 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700186 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700187 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000188 })
189
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900190 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000191}
192
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900193func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000194 if prebuilt.hideApexVariantFromMake {
195 // For a library imported from a prebuilt APEX, we don't need a Make module for itself, as we
196 // don't need to install it. However, we need to add its dexpreopt outputs as sub-modules, if it
197 // is preopted.
198 dexpreoptEntries := prebuilt.dexpreopter.AndroidMkEntriesForApex()
199 return append(dexpreoptEntries, android.AndroidMkEntries{Disabled: true})
200 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900201 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700202 Class: "JAVA_LIBRARIES",
203 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700204 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700205 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700206 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700207 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100208 if prebuilt.dexJarFile.IsSet() {
209 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800210 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700211 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
212 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park92315372021-04-02 08:45:46 +0900213 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900214 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700215 },
216 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900217 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700218}
Colin Cross10a03492017-08-10 17:09:43 -0700219
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900220func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700221 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900222 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900223 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900224 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900225 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900226 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800227 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100228 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800229 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700230 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700231 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100232 if prebuilt.dexJarFile.IsSet() {
233 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Colin Cross42be7612019-02-21 18:12:14 -0800234 }
235 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700236 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800237 }
Jiyong Park0b238752019-10-29 11:23:10 +0900238 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800239 },
240 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900241 }}
Colin Cross42be7612019-02-21 18:12:14 -0800242}
243
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900244func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700245 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900246 return []android.AndroidMkEntries{{
247 Disabled: true,
248 }}
249 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900250 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800251 Class: "JAVA_LIBRARIES",
252 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
253 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700254 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700255 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700256 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
257 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
258 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
259 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
260 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
261 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
262 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900263 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800264 },
265 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900266 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800267}
268
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900269func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700270 if binary.Os() == android.Windows {
271 // Make does not support Windows Java modules
272 return nil
273 }
Colin Cross10a03492017-08-10 17:09:43 -0700274
Colin Cross6b4a32d2017-12-05 13:42:45 -0800275 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900276 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800277 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700278 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800279 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700280 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700281 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700282 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
283 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100284 if binary.dexJarFile.IsSet() {
285 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
Colin Cross12fc2af2019-01-14 12:35:45 -0800286 }
287 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700288 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800289 }
Colin Cross331a1212018-08-15 20:40:52 -0700290 },
291 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700292 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800293 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700294 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
295 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800296 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900297 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800298 } else {
Colin Cross44b85d02021-02-19 17:37:04 -0800299 outputFile := binary.wrapperFile
Colin Cross44b85d02021-02-19 17:37:04 -0800300
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900301 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800302 Class: "EXECUTABLES",
Colin Cross44b85d02021-02-19 17:37:04 -0800303 OutputFile: android.OptionalPathForPath(outputFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700304 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700305 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700306 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800307 },
308 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700309 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800310 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700311 // Ensure that the wrapper script timestamp is always updated when the jar is updated
312 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
313 fmt.Fprintln(w, "jar_installed_module :=")
314 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800315 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900316 }}
Colin Cross10a03492017-08-10 17:09:43 -0700317 }
318}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800319
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900320func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Crossaaa0c1f2022-05-16 16:19:54 -0700321 if app.hideApexVariantFromMake || app.IsHideFromMake() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900322 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900323 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900324 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900325 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900326 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800327 Class: "APPS",
328 OutputFile: android.OptionalPathForPath(app.outputFile),
329 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700330 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700331 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700332 // App module names can be overridden.
333 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700334 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700335 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100336 if app.dexJarFile.IsSet() {
337 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800338 }
Colin Cross331a1212018-08-15 20:40:52 -0700339 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700340 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800341 }
342 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700343 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800344 }
Colin Crossf6237212018-10-29 23:14:58 -0700345 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700346 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700347 }
Colin Cross70798562017-12-13 22:42:59 -0800348 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700349 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800350 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700351 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
352 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800353
354 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700355 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800356 // Make base_rules.mk not put framework-res in a subdirectory called
357 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700358 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800359 }
360
Anton Hansson53c88442019-03-18 15:53:16 +0000361 filterRRO := func(filter overlayType) android.Paths {
362 var paths android.Paths
363 for _, d := range app.rroDirs {
364 if d.overlayType == filter {
365 paths = append(paths, d.path)
366 }
367 }
Colin Crossa140bb02018-04-17 10:52:26 -0700368 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
369 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000370 return android.ReversePaths(paths)
371 }
372 deviceRRODirs := filterRRO(device)
373 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700374 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000375 }
376 productRRODirs := filterRRO(product)
377 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700378 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800379 }
380
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700381 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800382
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700383 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800384
Jiyong Parkf7487312019-10-17 12:54:30 +0900385 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800386
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800387 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700388 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700389
Colin Cross403cc152020-07-06 14:15:24 -0700390 if app.embeddedJniLibs {
391 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
392 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
393 } else {
394 for _, jniLib := range app.jniLibs {
395 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Jihoon Kangf78a8902022-09-01 22:47:07 +0000396 var partitionTag string
397
398 // Mimic the creation of partition_tag in build/make,
399 // which defaults to an empty string when the partition is system.
400 // Otherwise, capitalize with a leading _
401 if jniLib.partition == "system" {
402 partitionTag = ""
403 } else {
404 split := strings.Split(jniLib.partition, "/")
405 partitionTag = "_" + strings.ToUpper(split[len(split)-1])
406 }
407 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_PARTITION_"+jniLib.target.Arch.ArchType.String(),
408 jniLib.name+":"+partitionTag)
Colin Cross403cc152020-07-06 14:15:24 -0700409 }
Colin Crossa4f08812018-10-02 22:03:40 -0700410 }
Colin Cross403cc152020-07-06 14:15:24 -0700411
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700412 if len(app.jniCoverageOutputs) > 0 {
413 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
414 }
Colin Cross43f08db2018-11-12 10:13:39 -0800415 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700416 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800417 }
Jeongik Chac6246672021-04-08 00:00:19 +0900418 if app.dexpreopter.configPath != nil {
419 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
420 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800421 for _, extra := range app.extraOutputFiles {
422 install := app.onDeviceDir + "/" + extra.Base()
423 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700424 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700425
Colin Cross08dca382020-07-21 20:31:17 -0700426 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700427 },
428 },
Matt Banda8c801262022-04-01 17:48:31 +0000429 ExtraFooters: []android.AndroidMkExtraFootersFunc{
430 func(w io.Writer, name, prefix, moduleDir string) {
431 if app.javaApiUsedByOutputFile.String() != "" {
432 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
433 app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
434 }
435 },
436 }},
437 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700438}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800439
Jaewoong Jung9109d722019-01-30 13:13:52 -0800440func (a *AndroidApp) getOverriddenPackages() []string {
441 var overridden []string
zhidoua2ce78f2022-02-17 02:33:12 +0000442 if len(a.overridableAppProperties.Overrides) > 0 {
443 overridden = append(overridden, a.overridableAppProperties.Overrides...)
Jaewoong Jung9109d722019-01-30 13:13:52 -0800444 }
Jooyung Han29e2f6d2022-01-08 12:13:59 +0900445 // When APK name is overridden via PRODUCT_PACKAGE_NAME_OVERRIDES
446 // ensure that the original name is overridden.
447 if a.Stem() != a.installApkName {
448 overridden = append(overridden, a.Stem())
Jaewoong Jung9109d722019-01-30 13:13:52 -0800449 }
450 return overridden
451}
452
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900453func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
454 entriesList := a.AndroidApp.AndroidMkEntries()
455 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700456 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700457 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700458 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700459 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700460 }
Dan Shi95d19422020-08-15 12:24:26 -0700461 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700462 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800463 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700464 })
465
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900466 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700467}
468
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900469func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
470 entriesList := a.AndroidApp.AndroidMkEntries()
471 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700472 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700473 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700474 // introduce a flag variable to control the generation of the .config file
475 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700476 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700477
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900478 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700479}
480
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900481func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700482 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900483 return []android.AndroidMkEntries{{
484 Disabled: true,
485 }}
486 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900487 entriesList := a.Library.AndroidMkEntries()
488 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700489
Colin Crossaa255532020-07-03 13:18:24 -0700490 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700491 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700492 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700493 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700494
495 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700496 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700497 // Make base_rules.mk not put framework-res in a subdirectory called
498 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700499 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700500 }
501
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700502 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
503 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
504 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700505 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
506 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700507 })
508
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900509 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800510}
Nan Zhang581fd212018-01-10 16:06:12 -0800511
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900512func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
513 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800514 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800515 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700516 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700517 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700518 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700519 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700520 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800521 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800522 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700523 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800524 }
525 },
526 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900527 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800528}
529
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900530func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
531 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800532 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000533 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700534 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700535 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700536 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000537 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700538 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800539 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000540 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800541 },
542 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900543 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800544}
Colin Crossd96ca352018-08-10 16:06:24 -0700545
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900546func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100547 // If the stubsSrcJar is not generated (because generate_stubs is false) then
548 // use the api file as the output file to ensure the relevant phony targets
549 // are created in make if only the api txt file is being generated. This is
550 // needed because an invalid output file would prevent the make entries from
551 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000552 //
553 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100554 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000555
Paul Duffin3ae29512020-04-08 18:18:03 +0100556 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
557 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000558 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100559 }
Anton Hansson4bf00802022-05-09 10:23:59 +0000560 if !outputFile.Valid() {
561 outputFile = android.OptionalPathForPath(dstubs.apiVersionsXml)
562 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900563 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700564 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100565 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700566 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700567 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700568 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700569 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700570 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700571 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700572 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700573 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700574 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700575 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700576 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700577 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100578 if dstubs.metadataZip != nil {
579 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
580 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700581 },
582 },
583 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800584 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100585 if dstubs.apiFile != nil {
586 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
587 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
588 }
589 if dstubs.removedApiFile != nil {
590 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
591 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
592 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700593 if dstubs.checkCurrentApiTimestamp != nil {
594 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
595 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
596 dstubs.checkCurrentApiTimestamp.String())
597
598 fmt.Fprintln(w, ".PHONY: checkapi")
599 fmt.Fprintln(w, "checkapi:",
600 dstubs.checkCurrentApiTimestamp.String())
601
602 fmt.Fprintln(w, ".PHONY: droidcore")
603 fmt.Fprintln(w, "droidcore: checkapi")
604 }
605 if dstubs.updateCurrentApiTimestamp != nil {
606 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
607 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
608 dstubs.updateCurrentApiTimestamp.String())
609
610 fmt.Fprintln(w, ".PHONY: update-api")
611 fmt.Fprintln(w, "update-api:",
612 dstubs.updateCurrentApiTimestamp.String())
613 }
614 if dstubs.checkLastReleasedApiTimestamp != nil {
615 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
616 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
617 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100618
Makoto Onukia573f192020-04-21 11:52:39 -0700619 fmt.Fprintln(w, ".PHONY: checkapi")
620 fmt.Fprintln(w, "checkapi:",
621 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100622
Makoto Onukia573f192020-04-21 11:52:39 -0700623 fmt.Fprintln(w, ".PHONY: droidcore")
624 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700625 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200626 if dstubs.apiLintTimestamp != nil {
627 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
628 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
629 dstubs.apiLintTimestamp.String())
630
631 fmt.Fprintln(w, ".PHONY: checkapi")
632 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100633 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200634
635 fmt.Fprintln(w, ".PHONY: droidcore")
636 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100637
638 if dstubs.apiLintReport != nil {
639 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
640 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
Bob Badour51804382022-04-13 11:27:19 -0700641 fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100642 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200643 }
Pete Gillin581d6082018-10-22 15:55:04 +0100644 if dstubs.checkNullabilityWarningsTimestamp != nil {
645 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
646 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
647 dstubs.checkNullabilityWarningsTimestamp.String())
648
649 fmt.Fprintln(w, ".PHONY:", "droidcore")
650 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
651 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700652 },
653 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900654 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700655}
656
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900657func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700658 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900659 // The non-platform variant is placed inside APEX. No reason to
660 // make it available to Make.
661 return nil
662 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900663 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700664 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700665 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700666 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700667 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700668 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900669 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800670 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700671 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
672 if len(a.dexpreopter.builtInstalled) > 0 {
673 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
674 }
675 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800676 if Bool(a.properties.Export_package_resources) {
677 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
678 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700679 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700680 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900681 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700682}
683
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900684func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
685 entriesList := a.AndroidAppImport.AndroidMkEntries()
686 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700687 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700688 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700689 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700690 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900691 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700692}
693
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700694func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700695 var testFiles []string
696 for _, d := range data {
697 testFiles = append(testFiles, d.String()+":"+d.Rel())
698 }
699 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
700}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800701
702func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
703 return []android.AndroidMkEntries{android.AndroidMkEntries{
704 Class: "ETC",
705 OutputFile: android.OptionalPathForPath(r.outputFile),
706 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
707 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700708 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800709 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Colin Crossc68db4b2021-11-11 18:59:15 -0800710 entries.SetPath("LOCAL_MODULE_PATH", r.installDir)
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700711 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800712 },
713 },
714 }}
715}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700716
717func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
718 return []android.AndroidMkEntries{
719 android.AndroidMkEntries{
720 Class: "APPS",
Colin Crossffbcd1d2021-11-12 12:19:42 -0800721 OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Sasha Smundaka7856c02020-04-23 09:49:59 -0700722 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
723 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700724 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700725 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Colin Crossffbcd1d2021-11-12 12:19:42 -0800726 entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700727 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700728 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
729 },
730 },
731 },
732 }
733}