blob: 032dc6ac237f09b9e024e8ba61e5c1273dff2a6b [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"
Colin Cross10a03492017-08-10 17:09:43 -070020 "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
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070025// TODO(jungjw): We'll probably want AndroidMkEntriesProvider.AndroidMkEntries to return multiple
26// entries so that this can be more error-proof.
27func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *android.AndroidMkEntries) {
Sundong Ahn054b19a2018-10-19 13:46:09 +090028 if Bool(library.deviceProperties.Hostdex) && !library.Host() {
29 fmt.Fprintln(w, "include $(CLEAR_VARS)")
30 fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
31 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
32 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
Colin Cross56abb832019-01-14 14:13:51 -080033 if library.dexJarFile != nil {
34 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.dexJarFile.String())
35 } else {
36 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.implementationAndResourcesJar.String())
37 }
Sundong Ahn054b19a2018-10-19 13:46:09 +090038 if library.dexJarFile != nil {
39 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
40 }
41 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
42 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070043 if len(entries.Required) > 0 {
44 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(entries.Required, " "))
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -070045 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070046 if len(entries.Host_required) > 0 {
47 fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(entries.Host_required, " "))
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -070048 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070049 if len(entries.Target_required) > 0 {
50 fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(entries.Target_required, " "))
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -070051 }
Colin Cross7f87f4f2019-04-24 13:41:45 -070052 if r := library.deviceProperties.Target.Hostdex.Required; len(r) > 0 {
53 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(r, " "))
54 }
Sundong Ahn054b19a2018-10-19 13:46:09 +090055 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
56 }
57}
58
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070059func (library *Library) AndroidMkEntries() android.AndroidMkEntries {
Jiyong Park7f7766d2019-07-25 22:02:35 +090060 if !library.IsForPlatform() {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070061 return android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +090062 Disabled: true,
63 }
64 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070065 return android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -070066 Class: "JAVA_LIBRARIES",
Colin Cross43f08db2018-11-12 10:13:39 -080067 OutputFile: android.OptionalPathForPath(library.outputFile),
Colin Cross53499412017-09-07 13:20:25 -070068 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070069 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
70 func(entries *android.AndroidMkEntries) {
Colin Cross5beccee2017-12-07 15:28:59 -080071 if len(library.logtagsSrcs) > 0 {
72 var logtags []string
73 for _, l := range library.logtagsSrcs {
74 logtags = append(logtags, l.Rel())
75 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070076 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080077 }
78
Colin Cross9ae1b922018-06-26 17:59:05 -070079 if library.installFile == nil {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070080 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Cross2c429dc2017-08-31 16:45:16 -070081 }
Colin Cross6ade34f2017-09-15 13:00:47 -070082 if library.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -070083 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
Colin Cross43f08db2018-11-12 10:13:39 -080084 }
85 if len(library.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070086 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
Colin Cross6ade34f2017-09-15 13:00:47 -070087 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070088 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion())
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -070089 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
90 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -080091
92 if library.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -070093 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
Colin Crosscb933592017-11-22 13:49:43 -080094 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080095
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070096 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
Jiyong Park1be96912018-05-28 18:02:19 +090097
Vladimir Marko0975ee02019-04-02 10:29:55 +010098 if len(library.additionalCheckedModules) != 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070099 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
Vladimir Marko0975ee02019-04-02 10:29:55 +0100100 }
101
Colin Crosse8a7dc92019-04-23 13:00:09 -0700102 if library.proguardDictionary != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700103 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
Colin Crosse8a7dc92019-04-23 13:00:09 -0700104 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700105 },
106 },
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700107 ExtraFooters: []android.AndroidMkExtraFootersFunc{
108 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
109 library.AndroidMkHostDex(w, name, entries)
110 },
Colin Cross92430102017-10-09 14:59:32 -0700111 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700112 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700113}
114
Paul Duffin42df1442019-03-20 12:45:53 +0000115// Called for modules that are a component of a test suite.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700116func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700117 entries.SetString("LOCAL_MODULE_TAGS", "tests")
118 if len(test_suites) > 0 {
119 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...)
120 } else {
121 entries.SetString("LOCAL_COMPATIBILITY_SUITE", "null-suite")
122 }
123}
124
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700125func (j *Test) AndroidMkEntries() android.AndroidMkEntries {
126 entries := j.Library.AndroidMkEntries()
127 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
128 testSuiteComponent(entries, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700129 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700130 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700131 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700132 androidMkWriteTestData(j.data, entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700133 })
134
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700135 return entries
Colin Cross05638fc2018-04-09 18:40:24 -0700136}
137
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700138func (j *TestHelperLibrary) AndroidMkEntries() android.AndroidMkEntries {
139 entries := j.Library.AndroidMkEntries()
140 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
141 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
Paul Duffin42df1442019-03-20 12:45:53 +0000142 })
143
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700144 return entries
Paul Duffin42df1442019-03-20 12:45:53 +0000145}
146
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700147func (prebuilt *Import) AndroidMkEntries() android.AndroidMkEntries {
Jiyong Parkd1063c12019-07-17 20:08:41 +0900148 if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().IsCurrentVersion() {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700149 return android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900150 Disabled: true,
151 }
152 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700153 return android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700154 Class: "JAVA_LIBRARIES",
155 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700156 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700157 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
158 func(entries *android.AndroidMkEntries) {
159 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
160 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
161 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
162 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700163 },
164 },
165 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700166}
Colin Cross10a03492017-08-10 17:09:43 -0700167
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700168func (prebuilt *DexImport) AndroidMkEntries() android.AndroidMkEntries {
Jiyong Park7f7766d2019-07-25 22:02:35 +0900169 if !prebuilt.IsForPlatform() {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700170 return android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900171 Disabled: true,
172 }
173 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700174 return android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800175 Class: "JAVA_LIBRARIES",
176 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
177 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700178 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
179 func(entries *android.AndroidMkEntries) {
Colin Cross42be7612019-02-21 18:12:14 -0800180 if prebuilt.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700181 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800182 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
183 // boot_jars_package_check.mk can check dex jars.
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700184 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.dexJarFile)
185 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800186 }
187 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700188 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800189 }
190 },
191 },
192 }
193}
194
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700195func (prebuilt *AARImport) AndroidMkEntries() android.AndroidMkEntries {
196 return android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800197 Class: "JAVA_LIBRARIES",
198 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
199 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700200 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
201 func(entries *android.AndroidMkEntries) {
202 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
203 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
204 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
205 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
206 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
207 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
208 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
209 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800210 },
211 },
212 }
213}
214
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700215func (binary *Binary) AndroidMkEntries() android.AndroidMkEntries {
Colin Cross10a03492017-08-10 17:09:43 -0700216
Colin Cross6b4a32d2017-12-05 13:42:45 -0800217 if !binary.isWrapperVariant {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700218 return android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800219 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700220 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800221 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700222 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
223 func(entries *android.AndroidMkEntries) {
224 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
225 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Colin Cross12fc2af2019-01-14 12:35:45 -0800226 if binary.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700227 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
Colin Cross12fc2af2019-01-14 12:35:45 -0800228 }
229 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700230 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800231 }
Colin Cross331a1212018-08-15 20:40:52 -0700232 },
233 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700234 ExtraFooters: []android.AndroidMkExtraFootersFunc{
235 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
236 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
237 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800238 },
239 }
240 } else {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700241 return android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800242 Class: "EXECUTABLES",
243 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700244 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
245 func(entries *android.AndroidMkEntries) {
246 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800247 },
248 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700249 ExtraFooters: []android.AndroidMkExtraFootersFunc{
250 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
251 // Ensure that the wrapper script timestamp is always updated when the jar is updated
252 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
253 fmt.Fprintln(w, "jar_installed_module :=")
254 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800255 },
256 }
Colin Cross10a03492017-08-10 17:09:43 -0700257 }
258}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800259
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700260func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries {
261 return android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800262 Class: "APPS",
263 OutputFile: android.OptionalPathForPath(app.outputFile),
264 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700265 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
266 func(entries *android.AndroidMkEntries) {
267 // App module names can be overridden.
268 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700269 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800270 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700271 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800272 }
Colin Cross331a1212018-08-15 20:40:52 -0700273 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700274 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800275 }
276 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700277 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800278 }
Colin Crossf6237212018-10-29 23:14:58 -0700279 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700280 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700281 }
Colin Cross70798562017-12-13 22:42:59 -0800282 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700283 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800284 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800285 if app.proguardDictionary != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700286 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800287 }
Colin Cross70798562017-12-13 22:42:59 -0800288
289 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700290 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800291 // Make base_rules.mk not put framework-res in a subdirectory called
292 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700293 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800294 }
295
Anton Hansson53c88442019-03-18 15:53:16 +0000296 filterRRO := func(filter overlayType) android.Paths {
297 var paths android.Paths
298 for _, d := range app.rroDirs {
299 if d.overlayType == filter {
300 paths = append(paths, d.path)
301 }
302 }
Colin Crossa140bb02018-04-17 10:52:26 -0700303 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
304 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000305 return android.ReversePaths(paths)
306 }
307 deviceRRODirs := filterRRO(device)
308 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700309 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000310 }
311 productRRODirs := filterRRO(product)
312 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700313 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800314 }
315
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700316 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800317
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700318 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800319
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700320 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(app.appProperties.Privileged))
Colin Crosse1731a52017-12-14 11:22:55 -0800321
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700322 entries.SetPath("LOCAL_CERTIFICATE", app.certificate.Pem)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700323 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700324
325 for _, jniLib := range app.installJniLibs {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700326 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Colin Crossa4f08812018-10-02 22:03:40 -0700327 }
Colin Cross43f08db2018-11-12 10:13:39 -0800328 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700329 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800330 }
Colin Crosse560c4a2019-03-19 16:03:11 -0700331 for _, split := range app.aapt.splits {
332 install := "$(LOCAL_MODULE_PATH)/" + strings.TrimSuffix(app.installApkName, ".apk") + split.suffix + ".apk"
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700333 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", split.path.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700334 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700335 },
336 },
337 ExtraFooters: []android.AndroidMkExtraFootersFunc{
338 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700339 if app.noticeOutputs.Merged.Valid() {
340 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
341 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
342 }
343 if app.noticeOutputs.TxtOutput.Valid() {
344 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
345 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
346 }
347 if app.noticeOutputs.HtmlOutput.Valid() {
348 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
349 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
350 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800351 },
352 },
353 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700354}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800355
Jaewoong Jung9109d722019-01-30 13:13:52 -0800356func (a *AndroidApp) getOverriddenPackages() []string {
357 var overridden []string
358 if len(a.appProperties.Overrides) > 0 {
359 overridden = append(overridden, a.appProperties.Overrides...)
360 }
361 if a.Name() != a.installApkName {
362 overridden = append(overridden, a.Name())
363 }
364 return overridden
365}
366
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700367func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries {
368 entries := a.AndroidApp.AndroidMkEntries()
369 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
370 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700371 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700372 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700373 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700374 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700375 })
376
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700377 return entries
Colin Cross252fc6f2018-10-04 15:22:03 -0700378}
379
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700380func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries {
381 entries := a.AndroidApp.AndroidMkEntries()
382 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
383 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
384 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700385
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700386 return entries
387}
388
389func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries {
390 entries := a.Library.AndroidMkEntries()
391
392 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700393 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700394 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700395 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700396
397 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700398 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700399 // Make base_rules.mk not put framework-res in a subdirectory called
400 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700401 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700402 }
403
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700404 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
405 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
406 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700407 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
408 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700409 })
410
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700411 return entries
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800412}
Nan Zhang581fd212018-01-10 16:06:12 -0800413
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700414func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries {
415 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800416 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800417 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700418 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700419 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
420 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700421 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700422 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800423 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800424 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700425 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800426 }
427 },
428 },
429 }
430}
431
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700432func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries {
433 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800434 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800435 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700436 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700437 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
438 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700439 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700440 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800441 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800442 if ddoc.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700443 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800444 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700445 apiFilePrefix := "INTERNAL_PLATFORM_"
446 if String(ddoc.properties.Api_tag_name) != "" {
447 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
448 }
449 if ddoc.apiFile != nil {
450 entries.SetPath(apiFilePrefix+"API_FILE", ddoc.apiFile)
451 }
452 if ddoc.dexApiFile != nil {
453 entries.SetPath(apiFilePrefix+"DEX_API_FILE", ddoc.dexApiFile)
454 }
455 if ddoc.privateApiFile != nil {
456 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", ddoc.privateApiFile)
457 }
458 if ddoc.privateDexApiFile != nil {
459 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", ddoc.privateDexApiFile)
460 }
461 if ddoc.removedApiFile != nil {
462 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", ddoc.removedApiFile)
463 }
464 if ddoc.removedDexApiFile != nil {
465 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", ddoc.removedDexApiFile)
466 }
467 if ddoc.exactApiFile != nil {
468 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", ddoc.exactApiFile)
469 }
470 if ddoc.proguardFile != nil {
471 entries.SetPath(apiFilePrefix+"PROGUARD_FILE", ddoc.proguardFile)
472 }
473 },
474 },
475 ExtraFooters: []android.AndroidMkExtraFootersFunc{
476 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang61819ce2018-05-04 18:49:16 -0700477 if ddoc.checkCurrentApiTimestamp != nil {
478 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
479 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
480 ddoc.checkCurrentApiTimestamp.String())
481
482 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900483 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700484 ddoc.checkCurrentApiTimestamp.String())
485
486 fmt.Fprintln(w, ".PHONY: droidcore")
487 fmt.Fprintln(w, "droidcore: checkapi")
488 }
489 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700490 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700491 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
492 ddoc.updateCurrentApiTimestamp.String())
493
494 fmt.Fprintln(w, ".PHONY: update-api")
495 fmt.Fprintln(w, "update-api:",
496 ddoc.updateCurrentApiTimestamp.String())
497 }
498 if ddoc.checkLastReleasedApiTimestamp != nil {
499 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
500 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
501 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100502
Adrian Roos62e34b92019-01-30 19:51:39 +0100503 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100504 fmt.Fprintln(w, ".PHONY: checkapi")
505 fmt.Fprintln(w, "checkapi:",
506 ddoc.checkLastReleasedApiTimestamp.String())
507
508 fmt.Fprintln(w, ".PHONY: droidcore")
509 fmt.Fprintln(w, "droidcore: checkapi")
510 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700511 }
Nan Zhang581fd212018-01-10 16:06:12 -0800512 },
513 },
514 }
515}
Colin Crossd96ca352018-08-10 16:06:24 -0700516
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700517func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries {
518 return android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700519 Class: "JAVA_LIBRARIES",
520 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
521 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700522 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
523 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700524 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700525 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700526 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700527 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700528 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700529 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700530 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700531 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700532 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700533 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700534 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700535 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700536 apiFilePrefix := "INTERNAL_PLATFORM_"
537 if String(dstubs.properties.Api_tag_name) != "" {
538 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
539 }
540 if dstubs.apiFile != nil {
541 entries.SetPath(apiFilePrefix+"API_FILE", dstubs.apiFile)
542 }
543 if dstubs.dexApiFile != nil {
544 entries.SetPath(apiFilePrefix+"DEX_API_FILE", dstubs.dexApiFile)
545 }
546 if dstubs.privateApiFile != nil {
547 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", dstubs.privateApiFile)
548 }
549 if dstubs.privateDexApiFile != nil {
550 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", dstubs.privateDexApiFile)
551 }
552 if dstubs.removedApiFile != nil {
553 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", dstubs.removedApiFile)
554 }
555 if dstubs.removedDexApiFile != nil {
556 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", dstubs.removedDexApiFile)
557 }
558 if dstubs.exactApiFile != nil {
559 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", dstubs.exactApiFile)
560 }
561 },
562 },
563 ExtraFooters: []android.AndroidMkExtraFootersFunc{
564 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
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
Adrian Roos62e34b92019-01-30 19:51:39 +0100591 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100592 fmt.Fprintln(w, ".PHONY: checkapi")
593 fmt.Fprintln(w, "checkapi:",
594 dstubs.checkLastReleasedApiTimestamp.String())
595
596 fmt.Fprintln(w, ".PHONY: droidcore")
597 fmt.Fprintln(w, "droidcore: checkapi")
598 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700599 }
Pete Gillin581d6082018-10-22 15:55:04 +0100600 if dstubs.checkNullabilityWarningsTimestamp != nil {
601 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
602 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
603 dstubs.checkNullabilityWarningsTimestamp.String())
604
605 fmt.Fprintln(w, ".PHONY:", "droidcore")
606 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
607 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700608 },
609 },
610 }
611}
612
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700613func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
614 return android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700615 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700616 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700617 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700618 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
619 func(entries *android.AndroidMkEntries) {
620 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(a.properties.Privileged))
621 if a.certificate != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700622 entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700623 } else {
624 entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED")
625 }
626 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
627 if len(a.dexpreopter.builtInstalled) > 0 {
628 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
629 }
630 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
631 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700632 },
633 }
634}
635
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700636func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries {
637 entries := a.AndroidAppImport.AndroidMkEntries()
638 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700639 testSuiteComponent(entries, a.testProperties.Test_suites)
640 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700641 })
642 return entries
643}
644
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700645func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700646 var testFiles []string
647 for _, d := range data {
648 testFiles = append(testFiles, d.String()+":"+d.Rel())
649 }
650 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
651}