blob: 148d7c2769bc5037193f1092efeb08d2af327a72 [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})
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +000079 } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
80 // Platform variant. If not available for the platform, we don't need Make module.
81 entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
Colin Crossb549b772020-06-03 17:14:31 +000082 } else {
Colin Cross56a83212020-09-15 18:30:11 -070083 entriesList = append(entriesList, android.AndroidMkEntries{
Jiyong Park55bd98b2019-12-11 17:27:07 +090084 Class: "JAVA_LIBRARIES",
85 OutputFile: android.OptionalPathForPath(library.outputFile),
86 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
87 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070088 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Park55bd98b2019-12-11 17:27:07 +090089 if len(library.logtagsSrcs) > 0 {
90 var logtags []string
91 for _, l := range library.logtagsSrcs {
92 logtags = append(logtags, l.Rel())
93 }
94 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080095 }
Colin Cross5beccee2017-12-07 15:28:59 -080096
Jingwen Chen8ac7d7d2023-03-20 11:05:16 +000097 if library.installFile == nil {
Jiyong Park55bd98b2019-12-11 17:27:07 +090098 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
99 }
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100100 if library.dexJarFile.IsSet() {
101 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile.Path())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900102 }
103 if len(library.dexpreopter.builtInstalled) > 0 {
104 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
105 }
Jiyong Park92315372021-04-02 08:45:46 +0900106 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion.String())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900107 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
108 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800109
Jiyong Park55bd98b2019-12-11 17:27:07 +0900110 if library.jacocoReportClassesFile != nil {
111 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
112 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800113
Ulya Trafimovichfc0f6e32021-08-12 16:16:11 +0100114 requiredUsesLibs, optionalUsesLibs := library.classLoaderContexts.UsesLibs()
115 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", append(requiredUsesLibs, optionalUsesLibs...)...)
Jiyong Park1be96912018-05-28 18:02:19 +0900116
Colin Crosscb6143a2020-08-14 17:39:29 -0700117 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", library.dexer.proguardDictionary)
118 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", library.dexer.proguardUsageZip)
Jiyong Park55bd98b2019-12-11 17:27:07 +0900119 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossc0efd1d2020-07-03 11:56:24 -0700120
Colin Cross08dca382020-07-21 20:31:17 -0700121 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000122
123 if library.dexpreopter.configPath != nil {
124 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", library.dexpreopter.configPath)
125 }
Jiyong Park55bd98b2019-12-11 17:27:07 +0900126 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700127 },
Colin Cross56a83212020-09-15 18:30:11 -0700128 })
Jiyong Park55bd98b2019-12-11 17:27:07 +0900129 }
130
Colin Cross56a83212020-09-15 18:30:11 -0700131 entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
Jiyong Park55bd98b2019-12-11 17:27:07 +0900132
Jiyong Park55bd98b2019-12-11 17:27:07 +0900133 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700134}
135
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000136func (j *JavaFuzzLibrary) AndroidMkEntries() []android.AndroidMkEntries {
137 entriesList := j.Library.AndroidMkEntries()
138 entries := &entriesList[0]
139 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
140 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
141 androidMkWriteTestData(j.jniFilePaths, entries)
Muhammad Haseeb Ahmadeb14ff22022-09-28 17:53:11 +0000142 androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
Muhammad Haseeb Ahmad7e744052022-03-25 22:50:53 +0000143 })
144 return entriesList
145}
146
Paul Duffin42df1442019-03-20 12:45:53 +0000147// Called for modules that are a component of a test suite.
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700148func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string, perTestcaseDirectory bool) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700149 entries.SetString("LOCAL_MODULE_TAGS", "tests")
150 if len(test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800151 entries.AddCompatibilityTestSuites(test_suites...)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700152 } else {
Liz Kammer57f5b332020-11-24 12:42:58 -0800153 entries.AddCompatibilityTestSuites("null-suite")
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700154 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700155 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", perTestcaseDirectory)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700156}
157
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900158func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
159 entriesList := j.Library.AndroidMkEntries()
160 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700161 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700162 testSuiteComponent(entries, j.testProperties.Test_suites, Bool(j.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700163 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700164 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700165 }
Dan Shi95d19422020-08-15 12:24:26 -0700166 androidMkWriteExtraTestConfigs(j.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700167 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800168 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
169 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
170 }
kellyhung74b00522020-08-17 18:46:00 +0800171 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...)
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +0800172
173 j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700174 })
175
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900176 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700177}
178
Dan Shi95d19422020-08-15 12:24:26 -0700179func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
180 if len(extraTestConfigs) > 0 {
181 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
182 }
183}
184
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900185func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
186 entriesList := j.Library.AndroidMkEntries()
187 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700188 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700189 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites, Bool(j.testHelperLibraryProperties.Per_testcase_directory))
Paul Duffin42df1442019-03-20 12:45:53 +0000190 })
191
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900192 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000193}
194
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900195func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000196 if prebuilt.hideApexVariantFromMake {
197 // For a library imported from a prebuilt APEX, we don't need a Make module for itself, as we
198 // don't need to install it. However, we need to add its dexpreopt outputs as sub-modules, if it
199 // is preopted.
200 dexpreoptEntries := prebuilt.dexpreopter.AndroidMkEntriesForApex()
201 return append(dexpreoptEntries, android.AndroidMkEntries{Disabled: true})
202 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900203 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700204 Class: "JAVA_LIBRARIES",
205 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700206 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700207 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700208 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700209 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100210 if prebuilt.dexJarFile.IsSet() {
211 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Bill Peckhamfb04df42021-01-11 12:27:24 -0800212 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700213 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
214 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park92315372021-04-02 08:45:46 +0900215 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Jiyong Park0b238752019-10-29 11:23:10 +0900216 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700217 },
218 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900219 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700220}
Colin Cross10a03492017-08-10 17:09:43 -0700221
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900222func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700223 if prebuilt.hideApexVariantFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900224 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900225 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900226 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900227 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900228 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800229 Class: "JAVA_LIBRARIES",
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100230 OutputFile: android.OptionalPathForPath(prebuilt.dexJarFile.Path()),
Colin Cross42be7612019-02-21 18:12:14 -0800231 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700232 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700233 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100234 if prebuilt.dexJarFile.IsSet() {
235 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile.Path())
Colin Cross42be7612019-02-21 18:12:14 -0800236 }
237 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700238 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800239 }
Jiyong Park0b238752019-10-29 11:23:10 +0900240 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800241 },
242 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900243 }}
Colin Cross42be7612019-02-21 18:12:14 -0800244}
245
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900246func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700247 if prebuilt.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900248 return []android.AndroidMkEntries{{
249 Disabled: true,
250 }}
251 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900252 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800253 Class: "JAVA_LIBRARIES",
254 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
255 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700256 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700257 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700258 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
259 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
260 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
261 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
262 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
263 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
264 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park92315372021-04-02 08:45:46 +0900265 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800266 },
267 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900268 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800269}
270
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900271func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Dan Willemsen9fe14102021-07-13 21:52:04 -0700272 if binary.Os() == android.Windows {
273 // Make does not support Windows Java modules
274 return nil
275 }
Colin Cross10a03492017-08-10 17:09:43 -0700276
Colin Cross6b4a32d2017-12-05 13:42:45 -0800277 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900278 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800279 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700280 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800281 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700282 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700283 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700284 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
285 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100286 if binary.dexJarFile.IsSet() {
287 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile.Path())
Colin Cross12fc2af2019-01-14 12:35:45 -0800288 }
289 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700290 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800291 }
Colin Cross331a1212018-08-15 20:40:52 -0700292 },
293 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700294 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800295 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700296 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
297 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800298 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900299 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800300 } else {
Colin Cross44b85d02021-02-19 17:37:04 -0800301 outputFile := binary.wrapperFile
Colin Cross44b85d02021-02-19 17:37:04 -0800302
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900303 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800304 Class: "EXECUTABLES",
Colin Cross44b85d02021-02-19 17:37:04 -0800305 OutputFile: android.OptionalPathForPath(outputFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700306 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700307 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700308 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800309 },
310 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700311 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800312 func(w io.Writer, name, prefix, moduleDir string) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700313 // Ensure that the wrapper script timestamp is always updated when the jar is updated
314 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
315 fmt.Fprintln(w, "jar_installed_module :=")
316 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800317 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900318 }}
Colin Cross10a03492017-08-10 17:09:43 -0700319 }
320}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800321
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900322func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Colin Crossaaa0c1f2022-05-16 16:19:54 -0700323 if app.hideApexVariantFromMake || app.IsHideFromMake() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900324 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900325 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900326 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900327 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900328 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800329 Class: "APPS",
330 OutputFile: android.OptionalPathForPath(app.outputFile),
331 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700332 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700333 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700334 // App module names can be overridden.
335 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700336 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700337 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Martin Stjernholm8be1e6d2021-09-15 03:34:04 +0100338 if app.dexJarFile.IsSet() {
339 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile.Path())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800340 }
Colin Cross331a1212018-08-15 20:40:52 -0700341 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700342 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800343 }
344 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700345 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800346 }
Colin Crossf6237212018-10-29 23:14:58 -0700347 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700348 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700349 }
Colin Cross70798562017-12-13 22:42:59 -0800350 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700351 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800352 }
Colin Crosscb6143a2020-08-14 17:39:29 -0700353 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_DICT", app.dexer.proguardDictionary)
354 entries.SetOptionalPath("LOCAL_SOONG_PROGUARD_USAGE_ZIP", app.dexer.proguardUsageZip)
Colin Cross70798562017-12-13 22:42:59 -0800355
356 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700357 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800358 // Make base_rules.mk not put framework-res in a subdirectory called
359 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700360 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800361 }
362
Anton Hansson53c88442019-03-18 15:53:16 +0000363 filterRRO := func(filter overlayType) android.Paths {
364 var paths android.Paths
365 for _, d := range app.rroDirs {
366 if d.overlayType == filter {
367 paths = append(paths, d.path)
368 }
369 }
Colin Crossa140bb02018-04-17 10:52:26 -0700370 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
371 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000372 return android.ReversePaths(paths)
373 }
374 deviceRRODirs := filterRRO(device)
375 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700376 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000377 }
378 productRRODirs := filterRRO(product)
379 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700380 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800381 }
382
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700383 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800384
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700385 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800386
Jiyong Parkf7487312019-10-17 12:54:30 +0900387 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800388
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800389 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700390 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700391
Colin Cross403cc152020-07-06 14:15:24 -0700392 if app.embeddedJniLibs {
393 jniSymbols := app.JNISymbolsInstalls(app.installPathForJNISymbols.String())
394 entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", jniSymbols.String())
395 } else {
396 for _, jniLib := range app.jniLibs {
397 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Jihoon Kangf78a8902022-09-01 22:47:07 +0000398 var partitionTag string
399
400 // Mimic the creation of partition_tag in build/make,
401 // which defaults to an empty string when the partition is system.
402 // Otherwise, capitalize with a leading _
403 if jniLib.partition == "system" {
404 partitionTag = ""
405 } else {
406 split := strings.Split(jniLib.partition, "/")
407 partitionTag = "_" + strings.ToUpper(split[len(split)-1])
408 }
409 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_PARTITION_"+jniLib.target.Arch.ArchType.String(),
410 jniLib.name+":"+partitionTag)
Colin Cross403cc152020-07-06 14:15:24 -0700411 }
Colin Crossa4f08812018-10-02 22:03:40 -0700412 }
Colin Cross403cc152020-07-06 14:15:24 -0700413
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700414 if len(app.jniCoverageOutputs) > 0 {
415 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
416 }
Colin Cross43f08db2018-11-12 10:13:39 -0800417 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700418 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800419 }
Jeongik Chac6246672021-04-08 00:00:19 +0900420 if app.dexpreopter.configPath != nil {
421 entries.SetPath("LOCAL_SOONG_DEXPREOPT_CONFIG", app.dexpreopter.configPath)
422 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800423 for _, extra := range app.extraOutputFiles {
424 install := app.onDeviceDir + "/" + extra.Base()
425 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700426 }
Colin Crossc0efd1d2020-07-03 11:56:24 -0700427
Colin Cross08dca382020-07-21 20:31:17 -0700428 entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700429 },
430 },
Matt Banda8c801262022-04-01 17:48:31 +0000431 ExtraFooters: []android.AndroidMkExtraFootersFunc{
432 func(w io.Writer, name, prefix, moduleDir string) {
433 if app.javaApiUsedByOutputFile.String() != "" {
434 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n",
435 app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String())
436 }
437 },
438 }},
439 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700440}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800441
Jaewoong Jung9109d722019-01-30 13:13:52 -0800442func (a *AndroidApp) getOverriddenPackages() []string {
443 var overridden []string
zhidoua2ce78f2022-02-17 02:33:12 +0000444 if len(a.overridableAppProperties.Overrides) > 0 {
445 overridden = append(overridden, a.overridableAppProperties.Overrides...)
Jaewoong Jung9109d722019-01-30 13:13:52 -0800446 }
Jooyung Han29e2f6d2022-01-08 12:13:59 +0900447 // When APK name is overridden via PRODUCT_PACKAGE_NAME_OVERRIDES
448 // ensure that the original name is overridden.
449 if a.Stem() != a.installApkName {
450 overridden = append(overridden, a.Stem())
Jaewoong Jung9109d722019-01-30 13:13:52 -0800451 }
452 return overridden
453}
454
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900455func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
456 entriesList := a.AndroidApp.AndroidMkEntries()
457 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700458 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700459 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Colin Cross303e21f2018-08-07 16:49:25 -0700460 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700461 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700462 }
Dan Shi95d19422020-08-15 12:24:26 -0700463 androidMkWriteExtraTestConfigs(a.extraTestConfigs, entries)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700464 androidMkWriteTestData(a.data, entries)
kellyhung74b00522020-08-17 18:46:00 +0800465 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", a.testProperties.Test_mainline_modules...)
Colin Cross252fc6f2018-10-04 15:22:03 -0700466 })
467
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900468 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700469}
470
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900471func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
472 entriesList := a.AndroidApp.AndroidMkEntries()
473 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700474 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700475 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites, Bool(a.appTestHelperAppProperties.Per_testcase_directory))
Yuntao Xu7a318552021-05-27 10:30:26 -0700476 // introduce a flag variable to control the generation of the .config file
477 entries.SetString("LOCAL_DISABLE_TEST_CONFIG", "true")
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700478 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700479
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900480 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700481}
482
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900483func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700484 if a.hideApexVariantFromMake {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900485 return []android.AndroidMkEntries{{
486 Disabled: true,
487 }}
488 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900489 entriesList := a.Library.AndroidMkEntries()
490 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700491
Colin Crossaa255532020-07-03 13:18:24 -0700492 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700493 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700494 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700495 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700496
497 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700498 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700499 // Make base_rules.mk not put framework-res in a subdirectory called
500 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700501 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700502 }
503
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700504 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
505 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
506 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700507 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
508 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700509 })
510
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900511 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800512}
Nan Zhang581fd212018-01-10 16:06:12 -0800513
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900514func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
515 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800516 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800517 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700518 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700519 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700520 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700521 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700522 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800523 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800524 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700525 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800526 }
527 },
528 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900529 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800530}
531
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900532func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
533 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800534 Class: "JAVA_LIBRARIES",
Liz Kammere1ab2502020-09-10 15:29:25 +0000535 OutputFile: android.OptionalPathForPath(ddoc.Javadoc.docZip),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700536 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700537 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700538 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Liz Kammere1ab2502020-09-10 15:29:25 +0000539 if ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700540 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800541 }
Liz Kammere1ab2502020-09-10 15:29:25 +0000542 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !BoolDefault(ddoc.Javadoc.properties.Installable, true))
Nan Zhang581fd212018-01-10 16:06:12 -0800543 },
544 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900545 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800546}
Colin Crossd96ca352018-08-10 16:06:24 -0700547
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900548func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100549 // If the stubsSrcJar is not generated (because generate_stubs is false) then
550 // use the api file as the output file to ensure the relevant phony targets
551 // are created in make if only the api txt file is being generated. This is
552 // needed because an invalid output file would prevent the make entries from
553 // being written.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000554 //
555 // Note that dstubs.apiFile can be also be nil if WITHOUT_CHECKS_API is true.
Paul Duffin3ae29512020-04-08 18:18:03 +0100556 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000557
Paul Duffin3ae29512020-04-08 18:18:03 +0100558 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
559 if !outputFile.Valid() {
Jingwen Chen7b27ca72020-07-24 09:13:49 +0000560 outputFile = android.OptionalPathForPath(dstubs.apiFile)
Paul Duffin3ae29512020-04-08 18:18:03 +0100561 }
Anton Hansson4bf00802022-05-09 10:23:59 +0000562 if !outputFile.Valid() {
563 outputFile = android.OptionalPathForPath(dstubs.apiVersionsXml)
564 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900565 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700566 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100567 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700568 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700569 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700570 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700571 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700572 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700573 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700574 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700575 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700576 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700577 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700578 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700579 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100580 if dstubs.metadataZip != nil {
581 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
582 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700583 },
584 },
585 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800586 func(w io.Writer, name, prefix, moduleDir string) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100587 if dstubs.apiFile != nil {
588 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
589 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
590 }
591 if dstubs.removedApiFile != nil {
592 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
593 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
594 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700595 if dstubs.checkCurrentApiTimestamp != nil {
596 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
597 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
598 dstubs.checkCurrentApiTimestamp.String())
599
600 fmt.Fprintln(w, ".PHONY: checkapi")
601 fmt.Fprintln(w, "checkapi:",
602 dstubs.checkCurrentApiTimestamp.String())
603
604 fmt.Fprintln(w, ".PHONY: droidcore")
605 fmt.Fprintln(w, "droidcore: checkapi")
606 }
607 if dstubs.updateCurrentApiTimestamp != nil {
608 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
609 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
610 dstubs.updateCurrentApiTimestamp.String())
611
612 fmt.Fprintln(w, ".PHONY: update-api")
613 fmt.Fprintln(w, "update-api:",
614 dstubs.updateCurrentApiTimestamp.String())
615 }
616 if dstubs.checkLastReleasedApiTimestamp != nil {
617 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
618 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
619 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100620
Makoto Onukia573f192020-04-21 11:52:39 -0700621 fmt.Fprintln(w, ".PHONY: checkapi")
622 fmt.Fprintln(w, "checkapi:",
623 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100624
Makoto Onukia573f192020-04-21 11:52:39 -0700625 fmt.Fprintln(w, ".PHONY: droidcore")
626 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700627 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200628 if dstubs.apiLintTimestamp != nil {
629 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
630 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
631 dstubs.apiLintTimestamp.String())
632
633 fmt.Fprintln(w, ".PHONY: checkapi")
634 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100635 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200636
637 fmt.Fprintln(w, ".PHONY: droidcore")
638 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100639
640 if dstubs.apiLintReport != nil {
641 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
642 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
Bob Badour51804382022-04-13 11:27:19 -0700643 fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100644 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200645 }
Pete Gillin581d6082018-10-22 15:55:04 +0100646 if dstubs.checkNullabilityWarningsTimestamp != nil {
647 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
648 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
649 dstubs.checkNullabilityWarningsTimestamp.String())
650
651 fmt.Fprintln(w, ".PHONY:", "droidcore")
652 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
653 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700654 },
655 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900656 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700657}
658
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900659func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -0700660 if a.hideApexVariantFromMake {
Jiyong Park592a6a42020-04-21 22:34:28 +0900661 // The non-platform variant is placed inside APEX. No reason to
662 // make it available to Make.
663 return nil
664 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900665 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700666 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700667 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700668 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700669 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700670 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900671 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800672 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700673 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
674 if len(a.dexpreopter.builtInstalled) > 0 {
675 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
676 }
677 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
Bill Peckhama036da92021-01-08 16:09:09 -0800678 if Bool(a.properties.Export_package_resources) {
679 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.outputFile)
680 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700681 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700682 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900683 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700684}
685
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900686func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
687 entriesList := a.AndroidAppImport.AndroidMkEntries()
688 entries := &entriesList[0]
Colin Crossaa255532020-07-03 13:18:24 -0700689 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700690 testSuiteComponent(entries, a.testProperties.Test_suites, Bool(a.testProperties.Per_testcase_directory))
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700691 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700692 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900693 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700694}
695
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700696func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700697 var testFiles []string
698 for _, d := range data {
699 testFiles = append(testFiles, d.String()+":"+d.Rel())
700 }
701 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
702}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800703
704func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
705 return []android.AndroidMkEntries{android.AndroidMkEntries{
706 Class: "ETC",
707 OutputFile: android.OptionalPathForPath(r.outputFile),
708 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
709 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700710 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800711 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Colin Crossc68db4b2021-11-11 18:59:15 -0800712 entries.SetPath("LOCAL_MODULE_PATH", r.installDir)
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700713 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800714 },
715 },
716 }}
717}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700718
719func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
720 return []android.AndroidMkEntries{
721 android.AndroidMkEntries{
722 Class: "APPS",
Colin Crossffbcd1d2021-11-12 12:19:42 -0800723 OutputFile: android.OptionalPathForPath(apkSet.primaryOutput),
Sasha Smundaka7856c02020-04-23 09:49:59 -0700724 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
725 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -0700726 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Sasha Smundaka7856c02020-04-23 09:49:59 -0700727 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
Colin Crossffbcd1d2021-11-12 12:19:42 -0800728 entries.SetPath("LOCAL_APK_SET_INSTALL_FILE", apkSet.PackedAdditionalOutputs())
Jaewoong Jung11c1e0f2020-06-29 19:18:44 -0700729 entries.SetPath("LOCAL_APKCERTS_FILE", apkSet.apkcertsFile)
Sasha Smundaka7856c02020-04-23 09:49:59 -0700730 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
731 },
732 },
733 },
734 }
735}
Jihoon Kang1bff0342023-01-17 20:40:22 +0000736
737func (al *ApiLibrary) AndroidMkEntries() []android.AndroidMkEntries {
738 var entriesList []android.AndroidMkEntries
739
740 entriesList = append(entriesList, android.AndroidMkEntries{
741 Class: "JAVA_LIBRARIES",
742 OutputFile: android.OptionalPathForPath(al.stubsJar),
743 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
744 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
745 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
746 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
747 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", al.stubsJar)
748 entries.SetPath("LOCAL_SOONG_HEADER_JAR", al.stubsJar)
749 },
750 },
751 })
752
753 return entriesList
754}