blob: 7927acff7cde79bee520dd0f07fa91b76b547ccd [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 Park9b409bc2019-10-11 14:59:13 +0900148 if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() {
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
Jiyong Parkf7487312019-10-17 12:54:30 +0900320 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.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 {
Jaewoong Jung7dd4ae22019-09-27 17:13:15 -0700332 install := app.onDeviceDir + "/" +
333 strings.TrimSuffix(app.installApkName, ".apk") + "_" + split.suffix + ".apk"
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700334 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", split.path.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700335 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700336 },
337 },
338 ExtraFooters: []android.AndroidMkExtraFootersFunc{
339 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700340 if app.noticeOutputs.Merged.Valid() {
341 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
342 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
343 }
344 if app.noticeOutputs.TxtOutput.Valid() {
345 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
346 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
347 }
348 if app.noticeOutputs.HtmlOutput.Valid() {
349 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
350 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
351 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800352 },
353 },
354 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700355}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800356
Jaewoong Jung9109d722019-01-30 13:13:52 -0800357func (a *AndroidApp) getOverriddenPackages() []string {
358 var overridden []string
359 if len(a.appProperties.Overrides) > 0 {
360 overridden = append(overridden, a.appProperties.Overrides...)
361 }
362 if a.Name() != a.installApkName {
363 overridden = append(overridden, a.Name())
364 }
365 return overridden
366}
367
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700368func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries {
369 entries := a.AndroidApp.AndroidMkEntries()
370 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
371 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700372 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700373 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700374 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700375 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700376 })
377
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700378 return entries
Colin Cross252fc6f2018-10-04 15:22:03 -0700379}
380
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700381func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries {
382 entries := a.AndroidApp.AndroidMkEntries()
383 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
384 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
385 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700386
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700387 return entries
388}
389
390func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries {
391 entries := a.Library.AndroidMkEntries()
392
393 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700394 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700395 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700396 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700397
398 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700399 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700400 // Make base_rules.mk not put framework-res in a subdirectory called
401 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700402 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700403 }
404
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700405 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
406 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
407 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700408 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
409 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700410 })
411
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700412 return entries
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800413}
Nan Zhang581fd212018-01-10 16:06:12 -0800414
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700415func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries {
416 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800417 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800418 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700419 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700420 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
421 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700422 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700423 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800424 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800425 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700426 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800427 }
428 },
429 },
430 }
431}
432
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700433func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries {
434 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800435 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800436 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700437 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700438 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
439 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700440 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700441 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800442 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800443 if ddoc.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700444 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800445 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700446 apiFilePrefix := "INTERNAL_PLATFORM_"
447 if String(ddoc.properties.Api_tag_name) != "" {
448 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
449 }
450 if ddoc.apiFile != nil {
451 entries.SetPath(apiFilePrefix+"API_FILE", ddoc.apiFile)
452 }
453 if ddoc.dexApiFile != nil {
454 entries.SetPath(apiFilePrefix+"DEX_API_FILE", ddoc.dexApiFile)
455 }
456 if ddoc.privateApiFile != nil {
457 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", ddoc.privateApiFile)
458 }
459 if ddoc.privateDexApiFile != nil {
460 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", ddoc.privateDexApiFile)
461 }
462 if ddoc.removedApiFile != nil {
463 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", ddoc.removedApiFile)
464 }
465 if ddoc.removedDexApiFile != nil {
466 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", ddoc.removedDexApiFile)
467 }
468 if ddoc.exactApiFile != nil {
469 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", ddoc.exactApiFile)
470 }
471 if ddoc.proguardFile != nil {
472 entries.SetPath(apiFilePrefix+"PROGUARD_FILE", ddoc.proguardFile)
473 }
474 },
475 },
476 ExtraFooters: []android.AndroidMkExtraFootersFunc{
477 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang61819ce2018-05-04 18:49:16 -0700478 if ddoc.checkCurrentApiTimestamp != nil {
479 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
480 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
481 ddoc.checkCurrentApiTimestamp.String())
482
483 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900484 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700485 ddoc.checkCurrentApiTimestamp.String())
486
487 fmt.Fprintln(w, ".PHONY: droidcore")
488 fmt.Fprintln(w, "droidcore: checkapi")
489 }
490 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700491 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700492 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
493 ddoc.updateCurrentApiTimestamp.String())
494
495 fmt.Fprintln(w, ".PHONY: update-api")
496 fmt.Fprintln(w, "update-api:",
497 ddoc.updateCurrentApiTimestamp.String())
498 }
499 if ddoc.checkLastReleasedApiTimestamp != nil {
500 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
501 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
502 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100503
Adrian Roos62e34b92019-01-30 19:51:39 +0100504 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100505 fmt.Fprintln(w, ".PHONY: checkapi")
506 fmt.Fprintln(w, "checkapi:",
507 ddoc.checkLastReleasedApiTimestamp.String())
508
509 fmt.Fprintln(w, ".PHONY: droidcore")
510 fmt.Fprintln(w, "droidcore: checkapi")
511 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700512 }
Nan Zhang581fd212018-01-10 16:06:12 -0800513 },
514 },
515 }
516}
Colin Crossd96ca352018-08-10 16:06:24 -0700517
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700518func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries {
519 return android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700520 Class: "JAVA_LIBRARIES",
521 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
522 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700523 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
524 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700525 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700526 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700527 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700528 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700529 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700530 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700531 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700532 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700533 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700534 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700535 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700536 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700537 apiFilePrefix := "INTERNAL_PLATFORM_"
538 if String(dstubs.properties.Api_tag_name) != "" {
539 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
540 }
541 if dstubs.apiFile != nil {
542 entries.SetPath(apiFilePrefix+"API_FILE", dstubs.apiFile)
543 }
544 if dstubs.dexApiFile != nil {
545 entries.SetPath(apiFilePrefix+"DEX_API_FILE", dstubs.dexApiFile)
546 }
547 if dstubs.privateApiFile != nil {
548 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", dstubs.privateApiFile)
549 }
550 if dstubs.privateDexApiFile != nil {
551 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", dstubs.privateDexApiFile)
552 }
553 if dstubs.removedApiFile != nil {
554 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", dstubs.removedApiFile)
555 }
556 if dstubs.removedDexApiFile != nil {
557 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", dstubs.removedDexApiFile)
558 }
559 if dstubs.exactApiFile != nil {
560 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", dstubs.exactApiFile)
561 }
562 },
563 },
564 ExtraFooters: []android.AndroidMkExtraFootersFunc{
565 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700566 if dstubs.checkCurrentApiTimestamp != nil {
567 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
568 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
569 dstubs.checkCurrentApiTimestamp.String())
570
571 fmt.Fprintln(w, ".PHONY: checkapi")
572 fmt.Fprintln(w, "checkapi:",
573 dstubs.checkCurrentApiTimestamp.String())
574
575 fmt.Fprintln(w, ".PHONY: droidcore")
576 fmt.Fprintln(w, "droidcore: checkapi")
577 }
578 if dstubs.updateCurrentApiTimestamp != nil {
579 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
580 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
581 dstubs.updateCurrentApiTimestamp.String())
582
583 fmt.Fprintln(w, ".PHONY: update-api")
584 fmt.Fprintln(w, "update-api:",
585 dstubs.updateCurrentApiTimestamp.String())
586 }
587 if dstubs.checkLastReleasedApiTimestamp != nil {
588 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
589 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
590 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100591
Adrian Roos62e34b92019-01-30 19:51:39 +0100592 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100593 fmt.Fprintln(w, ".PHONY: checkapi")
594 fmt.Fprintln(w, "checkapi:",
595 dstubs.checkLastReleasedApiTimestamp.String())
596
597 fmt.Fprintln(w, ".PHONY: droidcore")
598 fmt.Fprintln(w, "droidcore: checkapi")
599 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700600 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200601 if dstubs.apiLintTimestamp != nil {
602 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
603 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
604 dstubs.apiLintTimestamp.String())
605
606 fmt.Fprintln(w, ".PHONY: checkapi")
607 fmt.Fprintln(w, "checkapi:",
608 dstubs.apiLintTimestamp.String())
609
610 fmt.Fprintln(w, ".PHONY: droidcore")
611 fmt.Fprintln(w, "droidcore: checkapi")
612 }
Pete Gillin581d6082018-10-22 15:55:04 +0100613 if dstubs.checkNullabilityWarningsTimestamp != nil {
614 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
615 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
616 dstubs.checkNullabilityWarningsTimestamp.String())
617
618 fmt.Fprintln(w, ".PHONY:", "droidcore")
619 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
620 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700621 },
622 },
623 }
624}
625
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700626func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
627 return android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700628 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700629 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700630 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700631 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
632 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900633 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700634 if a.certificate != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700635 entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700636 } else {
637 entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED")
638 }
639 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
640 if len(a.dexpreopter.builtInstalled) > 0 {
641 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
642 }
643 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
644 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700645 },
646 }
647}
648
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700649func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries {
650 entries := a.AndroidAppImport.AndroidMkEntries()
651 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700652 testSuiteComponent(entries, a.testProperties.Test_suites)
653 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700654 })
655 return entries
656}
657
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700658func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700659 var testFiles []string
660 for _, d := range data {
661 testFiles = append(testFiles, d.String()+":"+d.Rel())
662 }
663 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
664}