blob: 35b4c8e19cdc876bc09cdff2fa76301a46b577ea [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"
Dan Willemsen218f6562015-07-08 18:13:11 -070022)
23
Jiyong Park55bd98b2019-12-11 17:27:07 +090024func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
25 hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
Colin Cross56a83212020-09-15 18:30:11 -070026 if library.hideApexVariantFromMake {
Jiyong Park55bd98b2019-12-11 17:27:07 +090027 hostDexNeeded = false
Sundong Ahn054b19a2018-10-19 13:46:09 +090028 }
Jiyong Park55bd98b2019-12-11 17:27:07 +090029
30 if hostDexNeeded {
31 var output android.Path
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010032 if library.dexJarFile.IsSet() {
33 output = library.dexJarFile.Path()
Jiyong Park55bd98b2019-12-11 17:27:07 +090034 } else {
35 output = library.implementationAndResourcesJar
36 }
37 return android.AndroidMkEntries{
38 Class: "JAVA_LIBRARIES",
39 SubName: "-hostdex",
40 OutputFile: android.OptionalPathForPath(output),
41 Required: library.deviceProperties.Target.Hostdex.Required,
42 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
43 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070044 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090045 entries.SetBool("LOCAL_IS_HOST_MODULE", true)
46 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +010047 if library.dexJarFile.IsSet() {
48 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +090049 }
50 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
51 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
52 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
53 },
54 },
55 }
56 }
57 return android.AndroidMkEntries{Disabled: true}
Sundong Ahn054b19a2018-10-19 13:46:09 +090058}
59
Jiyong Park0b0e1b92019-12-03 13:24:29 +090060func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park55bd98b2019-12-11 17:27:07 +090061 var entriesList []android.AndroidMkEntries
62
Dan Willemsen9fe14102021-07-13 21:52:04 -070063 if library.Os() == android.Windows {
64 // Make does not support Windows Java modules
65 return nil
66 }
67
Colin Cross56a83212020-09-15 18:30:11 -070068 if library.hideApexVariantFromMake {
Jiakai Zhang519c5c82021-09-16 06:15:39 +000069 // For a java library built for an APEX, we don't need a Make module for itself. Otherwise, it
70 // will conflict with the platform variant because they have the same module name in the
71 // makefile. However, we need to add its dexpreopt outputs as sub-modules, if it is preopted.
72 dexpreoptEntries := library.dexpreopter.AndroidMkEntriesForApex()
73 if len(dexpreoptEntries) > 0 {
74 entriesList = append(entriesList, dexpreoptEntries...)
75 }
Colin Cross56a83212020-09-15 18:30:11 -070076 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
77 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
78 // Platform variant. If not available for the platform, we don't need Make module.
Paul Duffin0b58fdb2021-10-02 10:37:58 +010079 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000080 } else {
Colin Cross56a83212020-09-15 18:30:11 -070081 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090082 Class: "JAVA_LIBRARIES",
83 OutputFile: android.OptionalPathForPath(library.outputFile),
84 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
85 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070086 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090087 if len(library.logtagsSrcs) > 0 {
88 var logtags []string
89 for _, l := range library.logtagsSrcs {
90 logtags = append(logtags, l.Rel())
91 }
92 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080093 }
Colin Cross5beccee2017-12-07 15:28:59 -080094
Jiyong Park55bd98b2019-12-11 17:27:07 +090095 if library.installFile == nil {
96 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
Paul Duffin42df1442019-03-20 12:45:53 +0000134// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700135func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700136 entries.SetString("LOCAL_MODULE_TAGS", "tests")
137 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800138 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700139 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800140 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700141 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700142 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700143}
144
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900145func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
146 entriesList := j.Library.AndroidMkEntries()
147 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700148 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700149 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700150 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700151 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700152 }
Dan Shi95d19422020-08-15 12:24:26 -0700153 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700154 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800155 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
156 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
157 }
kellyhung74b00522020-08-17 18:46:00 +0800158 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Dan Shid79572f2020-11-13 14:33:46 -0800159 if Bool(j.testProperties.Test_options.Unit_test) {
160 entries.SetBool("LOCAL_IS_UNIT_TEST", true)
161 }
Colin Cross05638fc2018-04-09 18:40:24 -0700162 })
163
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900164 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700165}
166
Dan Shi95d19422020-08-15 12:24:26 -0700167func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
168 if len(extraTestConfigs) > 0 {
169 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
170 }
171}
172
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900173func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
174 entriesList := j.Library.AndroidMkEntries()
175 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700176 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700177 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000178 })
179
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900180 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000181}
182
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900183func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700184 if prebuilt.hideApexVariantFromMake || !prebuilt.ContainingSdk().Unversioned() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900185 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900186 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900187 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900188 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900189 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700190 Class: "JAVA_LIBRARIES",
191 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700192 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700193 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700194 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700195 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100196 if prebuilt.dexJarFile.IsSet() {
197 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800198 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700199 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
200 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park92315372021-04-02 08:45:46 +0900201 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900202 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700203 },
204 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900205 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700206}
Colin Cross10a03492017-08-10 17:09:43 -0700207
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900208func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700209 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900210 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900211 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900212 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900213 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900214 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800215 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100216 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800217 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700218 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700219 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100220 if prebuilt.dexJarFile.IsSet() {
221 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Colin Cross42be7612019-02-21 18:12:14 -0800222 }
223 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700224 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800225 }
Jiyong Park0b238752019-10-29 11:23:10 +0900226 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800227 },
228 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900229 }}
Colin Cross42be7612019-02-21 18:12:14 -0800230}
231
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900232func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700233 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900234 return []android.AndroidMkEntries{{
235 Disabled: true,
236 }}
237 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900238 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800239 Class: "JAVA_LIBRARIES",
240 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
241 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700242 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700243 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700244 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
245 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
246 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
247 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
248 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
249 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
250 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900251 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800252 },
253 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900254 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800255}
256
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900257func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700258 if binary.Os() == android.Windows {
259 // Make does not support Windows Java modules
260 return nil
261 }
Colin Cross10a03492017-08-10 17:09:43 -0700262
Colin Cross6b4a32d2017-12-05 13:42:45 -0800263 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900264 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800265 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700266 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800267 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700268 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700269 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700270 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
271 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100272 if binary.dexJarFile.IsSet() {
273 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
Colin Cross12fc2af2019-01-14 12:35:45 -0800274 }
275 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700276 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800277 }
Colin Cross331a1212018-08-15 20:40:52 -0700278 },
279 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700280 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800281 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700282 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
283 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800284 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900285 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800286 } else {
Colin Cross44b85d02021-02-19 17:37:04 -0800287 outputFile := binary.wrapperFile
Colin Cross44b85d02021-02-19 17:37:04 -0800288
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900289 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800290 Class: "EXECUTABLES",
Colin Cross44b85d02021-02-19 17:37:04 -0800291 OutputFile: android.OptionalPathForPath(outputFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700292 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700293 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700294 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800295 },
296 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700297 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800298 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700299 // Ensure that the wrapper script timestamp is always updated when the jar is updated
300 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
301 fmt.Fprintln(w, "jar_installed_module :=")
302 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800303 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900304 }}
Colin Cross10a03492017-08-10 17:09:43 -0700305 }
306}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800307
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900308func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700309 if app.hideApexVariantFromMake || app.appProperties.HideFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900310 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900311 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900312 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900313 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900314 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800315 Class: "APPS",
316 OutputFile: android.OptionalPathForPath(app.outputFile),
317 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
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)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700323 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100324 if app.dexJarFile.IsSet() {
325 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800326 }
Colin Cross331a1212018-08-15 20:40:52 -0700327 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700328 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800329 }
330 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700331 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800332 }
Colin Crossf6237212018-10-29 23:14:58 -0700333 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700334 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700335 }
Colin Cross70798562017-12-13 22:42:59 -0800336 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700337 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800338 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700339 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
340 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800341
342 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700343 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800344 // Make base_rules.mk not put framework-res in a subdirectory called
345 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700346 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800347 }
348
Anton Hansson53c88442019-03-18 15:53:16 +0000349 filterRRO := func(filter overlayType) android.Paths {
350 var paths android.Paths
351 for _, d := range app.rroDirs {
352 if d.overlayType == filter {
353 paths = append(paths, d.path)
354 }
355 }
Colin Crossa140bb02018-04-17 10:52:26 -0700356 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
357 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000358 return android.ReversePaths(paths)
359 }
360 deviceRRODirs := filterRRO(device)
361 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700362 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000363 }
364 productRRODirs := filterRRO(product)
365 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700366 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800367 }
368
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700369 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800370
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700371 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800372
Jiyong Parkf7487312019-10-17 12:54:30 +0900373 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800374
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800375 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700376 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700377
Colin Cross403cc152020-07-06 14:15:24 -0700378 if app.embeddedJniLibs {
379 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
380 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
381 } else {
382 for _, jniLib := range app.jniLibs {
383 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
384 }
Colin Crossa4f08812018-10-02 22:03:40 -0700385 }
Colin Cross403cc152020-07-06 14:15:24 -0700386
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700387 if len(app.jniCoverageOutputs) > 0 {
388 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
389 }
Colin Cross43f08db2018-11-12 10:13:39 -0800390 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700391 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800392 }
Jeongik Chac6246672021-04-08 00:00:19 +0900393 if app.dexpreopter.configPath != nil {
394 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
395 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800396 for _, extra := range app.extraOutputFiles {
397 install := app.onDeviceDir + "/" + extra.Base()
398 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700399 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700400
Colin Cross08dca382020-07-21 20:31:17 -0700401 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700402 },
403 },
404 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800405 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700406 if app.noticeOutputs.Merged.Valid() {
407 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
408 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
409 }
410 if app.noticeOutputs.TxtOutput.Valid() {
411 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
412 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
413 }
414 if app.noticeOutputs.HtmlOutput.Valid() {
415 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
416 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
417 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800418 },
419 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900420 }}
Colin Crossa97c5d32018-03-28 14:58:31 -0700421}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800422
Jaewoong Jung9109d722019-01-30 13:13:52 -0800423func (a *AndroidApp) getOverriddenPackages() []string {
424 var overridden []string
425 if len(a.appProperties.Overrides) > 0 {
426 overridden = append(overridden, a.appProperties.Overrides...)
427 }
428 if a.Name() != a.installApkName {
429 overridden = append(overridden, a.Name())
430 }
431 return overridden
432}
433
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900434func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
435 entriesList := a.AndroidApp.AndroidMkEntries()
436 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700437 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700438 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700439 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700440 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700441 }
Dan Shi95d19422020-08-15 12:24:26 -0700442 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700443 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800444 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700445 })
446
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900447 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700448}
449
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900450func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
451 entriesList := a.AndroidApp.AndroidMkEntries()
452 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700453 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700454 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700455 // introduce a flag variable to control the generation of the .config file
456 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700457 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700458
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900459 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700460}
461
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900462func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700463 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900464 return []android.AndroidMkEntries{{
465 Disabled: true,
466 }}
467 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900468 entriesList := a.Library.AndroidMkEntries()
469 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700470
Colin Crossaa255532020-07-03 13:18:24 -0700471 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700472 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700473 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700474 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700475
476 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700477 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700478 // Make base_rules.mk not put framework-res in a subdirectory called
479 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700480 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700481 }
482
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700483 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
484 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
485 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700486 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
487 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700488 })
489
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900490 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800491}
Nan Zhang581fd212018-01-10 16:06:12 -0800492
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900493func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
494 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800495 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800496 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700497 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700498 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700499 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700500 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700501 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800502 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800503 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700504 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800505 }
506 },
507 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900508 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800509}
510
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900511func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
512 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800513 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000514 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700515 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700516 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700517 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000518 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700519 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800520 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000521 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800522 },
523 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900524 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800525}
Colin Crossd96ca352018-08-10 16:06:24 -0700526
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900527func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100528 // If the stubsSrcJar is not generated (because generate_stubs is false) then
529 // use the api file as the output file to ensure the relevant phony targets
530 // are created in make if only the api txt file is being generated. This is
531 // needed because an invalid output file would prevent the make entries from
532 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000533 //
534 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100535 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000536
Paul Duffin3ae29512020-04-08 18:18:03 +0100537 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
538 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000539 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100540 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900541 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700542 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100543 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700544 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700545 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700546 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700547 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700548 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700549 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700550 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700551 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700552 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700553 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700554 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700555 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100556 if dstubs.metadataZip != nil {
557 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
558 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700559 },
560 },
561 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800562 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100563 if dstubs.apiFile != nil {
564 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
565 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
566 }
567 if dstubs.removedApiFile != nil {
568 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
569 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
570 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700571 if dstubs.checkCurrentApiTimestamp != nil {
572 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
573 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
574 dstubs.checkCurrentApiTimestamp.String())
575
576 fmt.Fprintln(w, ".PHONY: checkapi")
577 fmt.Fprintln(w, "checkapi:",
578 dstubs.checkCurrentApiTimestamp.String())
579
580 fmt.Fprintln(w, ".PHONY: droidcore")
581 fmt.Fprintln(w, "droidcore: checkapi")
582 }
583 if dstubs.updateCurrentApiTimestamp != nil {
584 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
585 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
586 dstubs.updateCurrentApiTimestamp.String())
587
588 fmt.Fprintln(w, ".PHONY: update-api")
589 fmt.Fprintln(w, "update-api:",
590 dstubs.updateCurrentApiTimestamp.String())
591 }
592 if dstubs.checkLastReleasedApiTimestamp != nil {
593 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
594 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
595 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100596
Makoto Onukia573f192020-04-21 11:52:39 -0700597 fmt.Fprintln(w, ".PHONY: checkapi")
598 fmt.Fprintln(w, "checkapi:",
599 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100600
Makoto Onukia573f192020-04-21 11:52:39 -0700601 fmt.Fprintln(w, ".PHONY: droidcore")
602 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700603 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200604 if dstubs.apiLintTimestamp != nil {
605 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
606 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
607 dstubs.apiLintTimestamp.String())
608
609 fmt.Fprintln(w, ".PHONY: checkapi")
610 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100611 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200612
613 fmt.Fprintln(w, ".PHONY: droidcore")
614 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100615
616 if dstubs.apiLintReport != nil {
617 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
618 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
619 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200620 }
Pete Gillin581d6082018-10-22 15:55:04 +0100621 if dstubs.checkNullabilityWarningsTimestamp != nil {
622 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
623 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
624 dstubs.checkNullabilityWarningsTimestamp.String())
625
626 fmt.Fprintln(w, ".PHONY:", "droidcore")
627 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
628 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700629 },
630 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900631 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700632}
633
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900634func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700635 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900636 // The non-platform variant is placed inside APEX. No reason to
637 // make it available to Make.
638 return nil
639 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900640 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700641 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700642 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700643 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700644 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700645 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900646 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800647 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700648 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
649 if len(a.dexpreopter.builtInstalled) > 0 {
650 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
651 }
652 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800653 if Bool(a.properties.Export_package_resources) {
654 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
655 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700656 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700657 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900658 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700659}
660
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900661func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
662 entriesList := a.AndroidAppImport.AndroidMkEntries()
663 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700664 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700665 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700666 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700667 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900668 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700669}
670
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700671func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700672 var testFiles []string
673 for _, d := range data {
674 testFiles = append(testFiles, d.String()+":"+d.Rel())
675 }
676 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
677}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800678
679func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
680 return []android.AndroidMkEntries{android.AndroidMkEntries{
681 Class: "ETC",
682 OutputFile: android.OptionalPathForPath(r.outputFile),
683 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
684 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700685 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800686 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800687 entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath())
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700688 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800689 },
690 },
691 }}
692}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700693
694func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
695 return []android.AndroidMkEntries{
696 android.AndroidMkEntries{
697 Class: "APPS",
698 OutputFile: android.OptionalPathForPath(apkSet.packedOutput),
699 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
700 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700701 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700702 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Liz Kammercada8072020-07-28 15:47:38 -0700703 entries.SetString("LOCAL_APK_SET_INSTALL_FILE", apkSet.InstallFile())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700704 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700705 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
706 },
707 },
708 },
709 }
710}