blob: 2c2919218426709aa384013c7d6cb020496de5ef [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()
26 if !library.IsForPlatform() {
Jiyong Parkb02bb402019-12-03 00:43:57 +090027 // Don't emit hostdex modules from the APEX variants
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
33 if library.dexJarFile != nil {
34 output = library.dexJarFile
35 } 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{
45 func(entries *android.AndroidMkEntries) {
46 entries.SetBool("LOCAL_IS_HOST_MODULE", true)
47 entries.SetPath("LOCAL_PREBUILT_MODULE_FILE", output)
48 if library.dexJarFile != nil {
49 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
50 }
51 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
52 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
53 entries.SetString("LOCAL_MODULE_STEM", library.Stem()+"-hostdex")
54 },
55 },
56 }
57 }
58 return android.AndroidMkEntries{Disabled: true}
Sundong Ahn054b19a2018-10-19 13:46:09 +090059}
60
Jiyong Park0b0e1b92019-12-03 13:24:29 +090061func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park55bd98b2019-12-11 17:27:07 +090062 var entriesList []android.AndroidMkEntries
63
64 mainEntries := android.AndroidMkEntries{Disabled: true}
Jiyong Parkb02bb402019-12-03 00:43:57 +090065
Jiyong Park55bd98b2019-12-11 17:27:07 +090066 // For a java library built for an APEX, we don't need Make module
Jiyong Parkb02bb402019-12-03 00:43:57 +090067 hideFromMake := !library.IsForPlatform()
68 // If not available for platform, don't emit to make.
69 if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
70 hideFromMake = true
71 }
72 if !hideFromMake {
Jiyong Park55bd98b2019-12-11 17:27:07 +090073 mainEntries = android.AndroidMkEntries{
74 Class: "JAVA_LIBRARIES",
Anton Hansson78156ef2020-03-27 19:39:48 +000075 DistFile: android.OptionalPathForPath(library.distFile),
Jiyong Park55bd98b2019-12-11 17:27:07 +090076 OutputFile: android.OptionalPathForPath(library.outputFile),
77 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
78 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
79 func(entries *android.AndroidMkEntries) {
80 if len(library.logtagsSrcs) > 0 {
81 var logtags []string
82 for _, l := range library.logtagsSrcs {
83 logtags = append(logtags, l.Rel())
84 }
85 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080086 }
Colin Cross5beccee2017-12-07 15:28:59 -080087
Jiyong Park55bd98b2019-12-11 17:27:07 +090088 if library.installFile == nil {
89 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
90 }
91 if library.dexJarFile != nil {
92 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
93 }
94 if len(library.dexpreopter.builtInstalled) > 0 {
95 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
96 }
Jiyong Park6a927c42020-01-21 02:03:43 +090097 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion().raw)
Jiyong Park55bd98b2019-12-11 17:27:07 +090098 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
99 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -0800100
Jiyong Park55bd98b2019-12-11 17:27:07 +0900101 if library.jacocoReportClassesFile != nil {
102 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
103 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800104
Jiyong Park55bd98b2019-12-11 17:27:07 +0900105 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
Jiyong Park1be96912018-05-28 18:02:19 +0900106
Jiyong Park55bd98b2019-12-11 17:27:07 +0900107 if len(library.additionalCheckedModules) != 0 {
108 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
109 }
Vladimir Marko0975ee02019-04-02 10:29:55 +0100110
Jiyong Park55bd98b2019-12-11 17:27:07 +0900111 if library.proguardDictionary != nil {
112 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
113 }
114 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
115 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700116 },
Jiyong Park55bd98b2019-12-11 17:27:07 +0900117 }
118 }
119
120 hostDexEntries := library.AndroidMkEntriesHostDex()
121
122 entriesList = append(entriesList, mainEntries, hostDexEntries)
123 return entriesList
Dan Willemsen218f6562015-07-08 18:13:11 -0700124}
125
Paul Duffin42df1442019-03-20 12:45:53 +0000126// Called for modules that are a component of a test suite.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700127func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700128 entries.SetString("LOCAL_MODULE_TAGS", "tests")
129 if len(test_suites) > 0 {
130 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...)
131 } else {
132 entries.SetString("LOCAL_COMPATIBILITY_SUITE", "null-suite")
133 }
134}
135
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900136func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
137 entriesList := j.Library.AndroidMkEntries()
138 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700139 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
140 testSuiteComponent(entries, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700141 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700142 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700143 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700144 androidMkWriteTestData(j.data, entries)
Dan Shi2468d012020-01-06 15:47:57 -0800145 if !BoolDefault(j.testProperties.Auto_gen_config, true) {
146 entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true")
147 }
Colin Cross05638fc2018-04-09 18:40:24 -0700148 })
149
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900150 return entriesList
Colin Cross05638fc2018-04-09 18:40:24 -0700151}
152
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900153func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
154 entriesList := j.Library.AndroidMkEntries()
155 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700156 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
157 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
Paul Duffin42df1442019-03-20 12:45:53 +0000158 })
159
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900160 return entriesList
Paul Duffin42df1442019-03-20 12:45:53 +0000161}
162
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900163func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park9b409bc2019-10-11 14:59:13 +0900164 if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900165 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900166 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900167 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900168 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900169 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700170 Class: "JAVA_LIBRARIES",
171 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700172 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700173 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
174 func(entries *android.AndroidMkEntries) {
175 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
176 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
177 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
Jiyong Park6a927c42020-01-21 02:03:43 +0900178 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion().raw)
Jiyong Park0b238752019-10-29 11:23:10 +0900179 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700180 },
181 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900182 }}
Dan Willemsen218f6562015-07-08 18:13:11 -0700183}
Colin Cross10a03492017-08-10 17:09:43 -0700184
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900185func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park7f7766d2019-07-25 22:02:35 +0900186 if !prebuilt.IsForPlatform() {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900187 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900188 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900189 }}
Jiyong Park7f7766d2019-07-25 22:02:35 +0900190 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900191 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800192 Class: "JAVA_LIBRARIES",
193 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
194 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700195 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
196 func(entries *android.AndroidMkEntries) {
Colin Cross42be7612019-02-21 18:12:14 -0800197 if prebuilt.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700198 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800199 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
200 // boot_jars_package_check.mk can check dex jars.
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700201 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.dexJarFile)
202 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800203 }
204 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700205 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800206 }
Jiyong Park0b238752019-10-29 11:23:10 +0900207 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800208 },
209 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900210 }}
Colin Cross42be7612019-02-21 18:12:14 -0800211}
212
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900213func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
214 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800215 Class: "JAVA_LIBRARIES",
216 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
217 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700218 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
219 func(entries *android.AndroidMkEntries) {
220 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
221 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
222 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
223 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
224 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
225 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
226 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park6a927c42020-01-21 02:03:43 +0900227 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion().raw)
Colin Crossfabb6082018-02-20 17:22:23 -0800228 },
229 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900230 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800231}
232
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900233func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross10a03492017-08-10 17:09:43 -0700234
Colin Cross6b4a32d2017-12-05 13:42:45 -0800235 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900236 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800237 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700238 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800239 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700240 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
241 func(entries *android.AndroidMkEntries) {
242 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
243 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Colin Cross12fc2af2019-01-14 12:35:45 -0800244 if binary.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700245 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
Colin Cross12fc2af2019-01-14 12:35:45 -0800246 }
247 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700248 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800249 }
Colin Cross331a1212018-08-15 20:40:52 -0700250 },
251 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700252 ExtraFooters: []android.AndroidMkExtraFootersFunc{
253 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
254 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
255 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800256 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900257 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800258 } else {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900259 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800260 Class: "EXECUTABLES",
261 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700262 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
263 func(entries *android.AndroidMkEntries) {
264 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800265 },
266 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700267 ExtraFooters: []android.AndroidMkExtraFootersFunc{
268 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
269 // Ensure that the wrapper script timestamp is always updated when the jar is updated
270 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
271 fmt.Fprintln(w, "jar_installed_module :=")
272 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800273 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900274 }}
Colin Cross10a03492017-08-10 17:09:43 -0700275 }
276}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800277
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900278func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700279 if !app.IsForPlatform() || app.appProperties.HideFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900280 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900281 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900282 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900283 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900284 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800285 Class: "APPS",
286 OutputFile: android.OptionalPathForPath(app.outputFile),
287 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700288 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
289 func(entries *android.AndroidMkEntries) {
290 // App module names can be overridden.
291 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700292 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700293 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800294 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700295 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800296 }
Colin Cross331a1212018-08-15 20:40:52 -0700297 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700298 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800299 }
300 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700301 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800302 }
Colin Crossf6237212018-10-29 23:14:58 -0700303 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700304 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700305 }
Colin Cross70798562017-12-13 22:42:59 -0800306 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700307 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800308 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800309 if app.proguardDictionary != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700310 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800311 }
Colin Cross70798562017-12-13 22:42:59 -0800312
313 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700314 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800315 // Make base_rules.mk not put framework-res in a subdirectory called
316 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700317 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800318 }
319
Anton Hansson53c88442019-03-18 15:53:16 +0000320 filterRRO := func(filter overlayType) android.Paths {
321 var paths android.Paths
322 for _, d := range app.rroDirs {
323 if d.overlayType == filter {
324 paths = append(paths, d.path)
325 }
326 }
Colin Crossa140bb02018-04-17 10:52:26 -0700327 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
328 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000329 return android.ReversePaths(paths)
330 }
331 deviceRRODirs := filterRRO(device)
332 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700333 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000334 }
335 productRRODirs := filterRRO(product)
336 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700337 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800338 }
339
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700340 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800341
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700342 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800343
Jiyong Parkf7487312019-10-17 12:54:30 +0900344 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800345
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800346 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700347 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700348
349 for _, jniLib := range app.installJniLibs {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700350 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Colin Crossa4f08812018-10-02 22:03:40 -0700351 }
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700352 if len(app.jniCoverageOutputs) > 0 {
353 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
354 }
Colin Cross43f08db2018-11-12 10:13:39 -0800355 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700356 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800357 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800358 for _, extra := range app.extraOutputFiles {
359 install := app.onDeviceDir + "/" + extra.Base()
360 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700361 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700362 },
363 },
364 ExtraFooters: []android.AndroidMkExtraFootersFunc{
365 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700366 if app.noticeOutputs.Merged.Valid() {
367 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
368 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
369 }
370 if app.noticeOutputs.TxtOutput.Valid() {
371 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
372 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
373 }
374 if app.noticeOutputs.HtmlOutput.Valid() {
375 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
376 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
377 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800378 },
379 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900380 }}
Colin Crossa97c5d32018-03-28 14:58:31 -0700381}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800382
Jaewoong Jung9109d722019-01-30 13:13:52 -0800383func (a *AndroidApp) getOverriddenPackages() []string {
384 var overridden []string
385 if len(a.appProperties.Overrides) > 0 {
386 overridden = append(overridden, a.appProperties.Overrides...)
387 }
388 if a.Name() != a.installApkName {
389 overridden = append(overridden, a.Name())
390 }
391 return overridden
392}
393
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900394func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
395 entriesList := a.AndroidApp.AndroidMkEntries()
396 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700397 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
398 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700399 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700400 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700401 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700402 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700403 })
404
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900405 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700406}
407
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900408func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
409 entriesList := a.AndroidApp.AndroidMkEntries()
410 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700411 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
412 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
413 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700414
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900415 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700416}
417
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900418func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
419 entriesList := a.Library.AndroidMkEntries()
420 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700421
422 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700423 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700424 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700425 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700426
427 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700428 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700429 // Make base_rules.mk not put framework-res in a subdirectory called
430 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700431 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700432 }
433
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700434 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
435 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
436 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700437 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
438 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700439 })
440
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900441 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800442}
Nan Zhang581fd212018-01-10 16:06:12 -0800443
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900444func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
445 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800446 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800447 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700448 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700449 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
450 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700451 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700452 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800453 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800454 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700455 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800456 }
457 },
458 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900459 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800460}
461
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900462func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
463 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800464 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800465 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700466 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700467 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
468 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700469 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700470 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800471 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800472 if ddoc.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700473 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800474 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700475 },
476 },
477 ExtraFooters: []android.AndroidMkExtraFootersFunc{
478 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang61819ce2018-05-04 18:49:16 -0700479 if ddoc.checkCurrentApiTimestamp != nil {
480 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
481 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
482 ddoc.checkCurrentApiTimestamp.String())
483
484 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900485 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700486 ddoc.checkCurrentApiTimestamp.String())
487
488 fmt.Fprintln(w, ".PHONY: droidcore")
489 fmt.Fprintln(w, "droidcore: checkapi")
490 }
491 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700492 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700493 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
494 ddoc.updateCurrentApiTimestamp.String())
495
496 fmt.Fprintln(w, ".PHONY: update-api")
497 fmt.Fprintln(w, "update-api:",
498 ddoc.updateCurrentApiTimestamp.String())
499 }
500 if ddoc.checkLastReleasedApiTimestamp != nil {
501 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
502 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
503 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100504
Adrian Roos62e34b92019-01-30 19:51:39 +0100505 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100506 fmt.Fprintln(w, ".PHONY: checkapi")
507 fmt.Fprintln(w, "checkapi:",
508 ddoc.checkLastReleasedApiTimestamp.String())
509
510 fmt.Fprintln(w, ".PHONY: droidcore")
511 fmt.Fprintln(w, "droidcore: checkapi")
512 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700513 }
Nan Zhang581fd212018-01-10 16:06:12 -0800514 },
515 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900516 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800517}
Colin Crossd96ca352018-08-10 16:06:24 -0700518
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900519func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100520 // If the stubsSrcJar is not generated (because generate_stubs is false) then
521 // use the api file as the output file to ensure the relevant phony targets
522 // are created in make if only the api txt file is being generated. This is
523 // needed because an invalid output file would prevent the make entries from
524 // being written.
525 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
526 distFile := android.OptionalPathForPath(dstubs.apiFile)
527 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
528 if !outputFile.Valid() {
529 outputFile = distFile
530 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900531 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700532 Class: "JAVA_LIBRARIES",
Paul Duffin3ae29512020-04-08 18:18:03 +0100533 DistFile: distFile,
534 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700535 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700536 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
537 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700538 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700539 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700540 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700541 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700542 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700543 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700544 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700545 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700546 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700547 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700548 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700549 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100550 if dstubs.metadataZip != nil {
551 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
552 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700553 },
554 },
555 ExtraFooters: []android.AndroidMkExtraFootersFunc{
556 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100557 if dstubs.apiFile != nil {
558 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
559 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.apiFile)
560 }
561 if dstubs.removedApiFile != nil {
562 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
563 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
564 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700565 if dstubs.checkCurrentApiTimestamp != nil {
566 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
567 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
568 dstubs.checkCurrentApiTimestamp.String())
569
570 fmt.Fprintln(w, ".PHONY: checkapi")
571 fmt.Fprintln(w, "checkapi:",
572 dstubs.checkCurrentApiTimestamp.String())
573
574 fmt.Fprintln(w, ".PHONY: droidcore")
575 fmt.Fprintln(w, "droidcore: checkapi")
576 }
577 if dstubs.updateCurrentApiTimestamp != nil {
578 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
579 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
580 dstubs.updateCurrentApiTimestamp.String())
581
582 fmt.Fprintln(w, ".PHONY: update-api")
583 fmt.Fprintln(w, "update-api:",
584 dstubs.updateCurrentApiTimestamp.String())
585 }
586 if dstubs.checkLastReleasedApiTimestamp != nil {
587 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
588 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
589 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100590
Makoto Onukia573f192020-04-21 11:52:39 -0700591 fmt.Fprintln(w, ".PHONY: checkapi")
592 fmt.Fprintln(w, "checkapi:",
593 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100594
Makoto Onukia573f192020-04-21 11:52:39 -0700595 fmt.Fprintln(w, ".PHONY: droidcore")
596 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700597 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200598 if dstubs.apiLintTimestamp != nil {
599 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
600 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
601 dstubs.apiLintTimestamp.String())
602
603 fmt.Fprintln(w, ".PHONY: checkapi")
604 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100605 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200606
607 fmt.Fprintln(w, ".PHONY: droidcore")
608 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100609
610 if dstubs.apiLintReport != nil {
611 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
612 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
613 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200614 }
Pete Gillin581d6082018-10-22 15:55:04 +0100615 if dstubs.checkNullabilityWarningsTimestamp != nil {
616 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
617 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
618 dstubs.checkNullabilityWarningsTimestamp.String())
619
620 fmt.Fprintln(w, ".PHONY:", "droidcore")
621 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
622 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700623 },
624 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900625 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700626}
627
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900628func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park592a6a42020-04-21 22:34:28 +0900629 if !a.IsForPlatform() {
630 // The non-platform variant is placed inside APEX. No reason to
631 // make it available to Make.
632 return nil
633 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900634 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700635 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700636 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700637 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700638 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
639 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900640 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800641 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700642 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
643 if len(a.dexpreopter.builtInstalled) > 0 {
644 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
645 }
646 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
647 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700648 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900649 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700650}
651
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900652func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
653 entriesList := a.AndroidAppImport.AndroidMkEntries()
654 entries := &entriesList[0]
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700655 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700656 testSuiteComponent(entries, a.testProperties.Test_suites)
657 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700658 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900659 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700660}
661
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700662func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700663 var testFiles []string
664 for _, d := range data {
665 testFiles = append(testFiles, d.String()+":"+d.Rel())
666 }
667 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
668}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800669
670func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
671 return []android.AndroidMkEntries{android.AndroidMkEntries{
672 Class: "ETC",
673 OutputFile: android.OptionalPathForPath(r.outputFile),
674 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
675 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
676 func(entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800677 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800678 entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath())
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700679 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800680 },
681 },
682 }}
683}