blob: 6747b30b06fa29151ace11ecf8cda7a6d319b9dd [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 {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900214 if !prebuilt.IsForPlatform() {
215 return []android.AndroidMkEntries{{
216 Disabled: true,
217 }}
218 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900219 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800220 Class: "JAVA_LIBRARIES",
221 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
222 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700223 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
224 func(entries *android.AndroidMkEntries) {
225 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
226 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
227 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
228 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
229 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
230 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
231 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
Jiyong Park6a927c42020-01-21 02:03:43 +0900232 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion().raw)
Colin Crossfabb6082018-02-20 17:22:23 -0800233 },
234 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900235 }}
Colin Crossfabb6082018-02-20 17:22:23 -0800236}
237
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900238func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross10a03492017-08-10 17:09:43 -0700239
Colin Cross6b4a32d2017-12-05 13:42:45 -0800240 if !binary.isWrapperVariant {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900241 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800242 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700243 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800244 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700245 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
246 func(entries *android.AndroidMkEntries) {
247 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
248 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Colin Cross12fc2af2019-01-14 12:35:45 -0800249 if binary.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700250 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
Colin Cross12fc2af2019-01-14 12:35:45 -0800251 }
252 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700253 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800254 }
Colin Cross331a1212018-08-15 20:40:52 -0700255 },
256 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700257 ExtraFooters: []android.AndroidMkExtraFootersFunc{
258 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
259 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
260 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800261 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900262 }}
Colin Cross6b4a32d2017-12-05 13:42:45 -0800263 } else {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900264 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800265 Class: "EXECUTABLES",
266 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700267 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
268 func(entries *android.AndroidMkEntries) {
269 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800270 },
271 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700272 ExtraFooters: []android.AndroidMkExtraFootersFunc{
273 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
274 // Ensure that the wrapper script timestamp is always updated when the jar is updated
275 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
276 fmt.Fprintln(w, "jar_installed_module :=")
277 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800278 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900279 }}
Colin Cross10a03492017-08-10 17:09:43 -0700280 }
281}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800282
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900283func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700284 if !app.IsForPlatform() || app.appProperties.HideFromMake {
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900285 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jiyong Park52cd06f2019-11-11 10:14:32 +0900286 Disabled: true,
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900287 }}
Jiyong Park52cd06f2019-11-11 10:14:32 +0900288 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900289 return []android.AndroidMkEntries{android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800290 Class: "APPS",
291 OutputFile: android.OptionalPathForPath(app.outputFile),
292 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700293 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
294 func(entries *android.AndroidMkEntries) {
295 // App module names can be overridden.
296 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700297 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", app.appProperties.PreventInstall)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700298 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800299 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700300 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800301 }
Colin Cross331a1212018-08-15 20:40:52 -0700302 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700303 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800304 }
305 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700306 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800307 }
Colin Crossf6237212018-10-29 23:14:58 -0700308 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700309 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700310 }
Colin Cross70798562017-12-13 22:42:59 -0800311 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700312 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800313 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800314 if app.proguardDictionary != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700315 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800316 }
Colin Cross70798562017-12-13 22:42:59 -0800317
318 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700319 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800320 // Make base_rules.mk not put framework-res in a subdirectory called
321 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700322 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800323 }
324
Anton Hansson53c88442019-03-18 15:53:16 +0000325 filterRRO := func(filter overlayType) android.Paths {
326 var paths android.Paths
327 for _, d := range app.rroDirs {
328 if d.overlayType == filter {
329 paths = append(paths, d.path)
330 }
331 }
Colin Crossa140bb02018-04-17 10:52:26 -0700332 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
333 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000334 return android.ReversePaths(paths)
335 }
336 deviceRRODirs := filterRRO(device)
337 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700338 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000339 }
340 productRRODirs := filterRRO(product)
341 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700342 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800343 }
344
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700345 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800346
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700347 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800348
Jiyong Parkf7487312019-10-17 12:54:30 +0900349 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800350
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800351 entries.SetString("LOCAL_CERTIFICATE", app.certificate.AndroidMkString())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700352 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700353
354 for _, jniLib := range app.installJniLibs {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700355 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Colin Crossa4f08812018-10-02 22:03:40 -0700356 }
Jaewoong Jung87a33e72020-03-26 14:01:48 -0700357 if len(app.jniCoverageOutputs) > 0 {
358 entries.AddStrings("LOCAL_PREBUILT_COVERAGE_ARCHIVE", app.jniCoverageOutputs.Strings()...)
359 }
Colin Cross43f08db2018-11-12 10:13:39 -0800360 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700361 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800362 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800363 for _, extra := range app.extraOutputFiles {
364 install := app.onDeviceDir + "/" + extra.Base()
365 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700366 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700367 },
368 },
369 ExtraFooters: []android.AndroidMkExtraFootersFunc{
370 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700371 if app.noticeOutputs.Merged.Valid() {
372 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
373 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
374 }
375 if app.noticeOutputs.TxtOutput.Valid() {
376 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
377 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
378 }
379 if app.noticeOutputs.HtmlOutput.Valid() {
380 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
381 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
382 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800383 },
384 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900385 }}
Colin Crossa97c5d32018-03-28 14:58:31 -0700386}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800387
Jaewoong Jung9109d722019-01-30 13:13:52 -0800388func (a *AndroidApp) getOverriddenPackages() []string {
389 var overridden []string
390 if len(a.appProperties.Overrides) > 0 {
391 overridden = append(overridden, a.appProperties.Overrides...)
392 }
393 if a.Name() != a.installApkName {
394 overridden = append(overridden, a.Name())
395 }
396 return overridden
397}
398
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900399func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
400 entriesList := a.AndroidApp.AndroidMkEntries()
401 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700402 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
403 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700404 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700405 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700406 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700407 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700408 })
409
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900410 return entriesList
Colin Cross252fc6f2018-10-04 15:22:03 -0700411}
412
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900413func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
414 entriesList := a.AndroidApp.AndroidMkEntries()
415 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700416 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
417 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
418 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700419
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900420 return entriesList
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700421}
422
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900423func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Jooyung Hanacc7bbe2020-05-20 09:06:00 +0900424 if !a.IsForPlatform() {
425 return []android.AndroidMkEntries{{
426 Disabled: true,
427 }}
428 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900429 entriesList := a.Library.AndroidMkEntries()
430 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700431
432 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700433 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700434 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700435 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700436
437 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700438 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700439 // Make base_rules.mk not put framework-res in a subdirectory called
440 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700441 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700442 }
443
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700444 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
445 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
446 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700447 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
448 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700449 })
450
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900451 return entriesList
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800452}
Nan Zhang581fd212018-01-10 16:06:12 -0800453
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900454func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
455 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800456 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800457 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700458 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700459 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
460 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700461 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700462 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800463 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800464 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700465 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800466 }
467 },
468 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900469 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800470}
471
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900472func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
473 return []android.AndroidMkEntries{android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800474 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800475 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700476 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700477 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
478 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700479 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700480 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800481 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800482 if ddoc.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700483 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800484 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700485 },
486 },
487 ExtraFooters: []android.AndroidMkExtraFootersFunc{
488 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang61819ce2018-05-04 18:49:16 -0700489 if ddoc.checkCurrentApiTimestamp != nil {
490 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
491 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
492 ddoc.checkCurrentApiTimestamp.String())
493
494 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900495 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700496 ddoc.checkCurrentApiTimestamp.String())
497
498 fmt.Fprintln(w, ".PHONY: droidcore")
499 fmt.Fprintln(w, "droidcore: checkapi")
500 }
501 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700502 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700503 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
504 ddoc.updateCurrentApiTimestamp.String())
505
506 fmt.Fprintln(w, ".PHONY: update-api")
507 fmt.Fprintln(w, "update-api:",
508 ddoc.updateCurrentApiTimestamp.String())
509 }
510 if ddoc.checkLastReleasedApiTimestamp != nil {
511 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
512 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
513 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100514
Adrian Roos62e34b92019-01-30 19:51:39 +0100515 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100516 fmt.Fprintln(w, ".PHONY: checkapi")
517 fmt.Fprintln(w, "checkapi:",
518 ddoc.checkLastReleasedApiTimestamp.String())
519
520 fmt.Fprintln(w, ".PHONY: droidcore")
521 fmt.Fprintln(w, "droidcore: checkapi")
522 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700523 }
Nan Zhang581fd212018-01-10 16:06:12 -0800524 },
525 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900526 }}
Nan Zhang581fd212018-01-10 16:06:12 -0800527}
Colin Crossd96ca352018-08-10 16:06:24 -0700528
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900529func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin3ae29512020-04-08 18:18:03 +0100530 // If the stubsSrcJar is not generated (because generate_stubs is false) then
531 // use the api file as the output file to ensure the relevant phony targets
532 // are created in make if only the api txt file is being generated. This is
533 // needed because an invalid output file would prevent the make entries from
534 // being written.
535 // TODO(b/146727827): Revert when we do not need to generate stubs and API separately.
536 distFile := android.OptionalPathForPath(dstubs.apiFile)
537 outputFile := android.OptionalPathForPath(dstubs.stubsSrcJar)
538 if !outputFile.Valid() {
539 outputFile = distFile
540 }
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 DistFile: distFile,
544 OutputFile: outputFile,
Nan Zhang1598a9e2018-09-04 17:14:32 -0700545 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700546 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
547 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700548 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700549 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700550 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700551 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700552 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700553 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700554 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700555 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700556 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700557 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700558 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700559 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100560 if dstubs.metadataZip != nil {
561 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
562 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700563 },
564 },
565 ExtraFooters: []android.AndroidMkExtraFootersFunc{
566 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Anton Hansson27d9ec12020-04-17 11:48:24 +0100567 if dstubs.apiFile != 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.apiFile)
570 }
571 if dstubs.removedApiFile != nil {
572 fmt.Fprintf(w, ".PHONY: %s %s.txt\n", dstubs.Name(), dstubs.Name())
573 fmt.Fprintf(w, "%s %s.txt: %s\n", dstubs.Name(), dstubs.Name(), dstubs.removedApiFile)
574 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700575 if dstubs.checkCurrentApiTimestamp != nil {
576 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
577 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
578 dstubs.checkCurrentApiTimestamp.String())
579
580 fmt.Fprintln(w, ".PHONY: checkapi")
581 fmt.Fprintln(w, "checkapi:",
582 dstubs.checkCurrentApiTimestamp.String())
583
584 fmt.Fprintln(w, ".PHONY: droidcore")
585 fmt.Fprintln(w, "droidcore: checkapi")
586 }
587 if dstubs.updateCurrentApiTimestamp != nil {
588 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
589 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
590 dstubs.updateCurrentApiTimestamp.String())
591
592 fmt.Fprintln(w, ".PHONY: update-api")
593 fmt.Fprintln(w, "update-api:",
594 dstubs.updateCurrentApiTimestamp.String())
595 }
596 if dstubs.checkLastReleasedApiTimestamp != nil {
597 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
598 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
599 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100600
Makoto Onukia573f192020-04-21 11:52:39 -0700601 fmt.Fprintln(w, ".PHONY: checkapi")
602 fmt.Fprintln(w, "checkapi:",
603 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100604
Makoto Onukia573f192020-04-21 11:52:39 -0700605 fmt.Fprintln(w, ".PHONY: droidcore")
606 fmt.Fprintln(w, "droidcore: checkapi")
Nan Zhang1598a9e2018-09-04 17:14:32 -0700607 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200608 if dstubs.apiLintTimestamp != nil {
609 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
610 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
611 dstubs.apiLintTimestamp.String())
612
613 fmt.Fprintln(w, ".PHONY: checkapi")
614 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100615 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200616
617 fmt.Fprintln(w, ".PHONY: droidcore")
618 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100619
620 if dstubs.apiLintReport != nil {
621 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
622 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
623 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200624 }
Pete Gillin581d6082018-10-22 15:55:04 +0100625 if dstubs.checkNullabilityWarningsTimestamp != nil {
626 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
627 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
628 dstubs.checkNullabilityWarningsTimestamp.String())
629
630 fmt.Fprintln(w, ".PHONY:", "droidcore")
631 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
632 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700633 },
634 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900635 }}
Nan Zhang1598a9e2018-09-04 17:14:32 -0700636}
637
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900638func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park592a6a42020-04-21 22:34:28 +0900639 if !a.IsForPlatform() {
640 // The non-platform variant is placed inside APEX. No reason to
641 // make it available to Make.
642 return nil
643 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900644 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700645 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700646 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700647 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700648 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
649 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900650 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Colin Cross503c1d02020-01-28 14:00:53 -0800651 entries.SetString("LOCAL_CERTIFICATE", a.certificate.AndroidMkString())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700652 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
653 if len(a.dexpreopter.builtInstalled) > 0 {
654 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
655 }
656 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
657 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700658 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900659 }}
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700660}
661
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900662func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
663 entriesList := a.AndroidAppImport.AndroidMkEntries()
664 entries := &entriesList[0]
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700665 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700666 testSuiteComponent(entries, a.testProperties.Test_suites)
667 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700668 })
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900669 return entriesList
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700670}
671
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700672func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700673 var testFiles []string
674 for _, d := range data {
675 testFiles = append(testFiles, d.String()+":"+d.Rel())
676 }
677 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
678}
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800679
680func (r *RuntimeResourceOverlay) AndroidMkEntries() []android.AndroidMkEntries {
681 return []android.AndroidMkEntries{android.AndroidMkEntries{
682 Class: "ETC",
683 OutputFile: android.OptionalPathForPath(r.outputFile),
684 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
685 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
686 func(entries *android.AndroidMkEntries) {
Jaewoong Jung78ec5d82020-01-31 10:11:47 -0800687 entries.SetString("LOCAL_CERTIFICATE", r.certificate.AndroidMkString())
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800688 entries.SetPath("LOCAL_MODULE_PATH", r.installDir.ToMakePath())
Jaewoong Jungad0177b2020-04-24 15:22:40 -0700689 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", r.properties.Overrides...)
Jaewoong Jung9befb0c2020-01-18 10:33:43 -0800690 },
691 },
692 }}
693}
Sasha Smundaka7856c02020-04-23 09:49:59 -0700694
695func (apkSet *AndroidAppSet) AndroidMkEntries() []android.AndroidMkEntries {
696 return []android.AndroidMkEntries{
697 android.AndroidMkEntries{
698 Class: "APPS",
699 OutputFile: android.OptionalPathForPath(apkSet.packedOutput),
700 Include: "$(BUILD_SYSTEM)/soong_android_app_set.mk",
701 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
702 func(entries *android.AndroidMkEntries) {
703 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", apkSet.Privileged())
704 entries.SetString("LOCAL_APK_SET_MASTER_FILE", apkSet.masterFile)
705 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", apkSet.properties.Overrides...)
706 },
707 },
708 },
709 }
710}