blob: cd91b46392382377a8ff68274ebef039c9ee288d [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 }
Jiyong Park0b238752019-10-29 11:23:10 +090055 fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", library.Stem()+"-hostdex")
Sundong Ahn054b19a2018-10-19 13:46:09 +090056 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
57 }
58}
59
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070060func (library *Library) AndroidMkEntries() android.AndroidMkEntries {
Jiyong Park7f7766d2019-07-25 22:02:35 +090061 if !library.IsForPlatform() {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070062 return android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +090063 Disabled: true,
64 }
65 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070066 return android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -070067 Class: "JAVA_LIBRARIES",
Colin Cross43f08db2018-11-12 10:13:39 -080068 OutputFile: android.OptionalPathForPath(library.outputFile),
Colin Cross53499412017-09-07 13:20:25 -070069 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070070 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
71 func(entries *android.AndroidMkEntries) {
Colin Cross5beccee2017-12-07 15:28:59 -080072 if len(library.logtagsSrcs) > 0 {
73 var logtags []string
74 for _, l := range library.logtagsSrcs {
75 logtags = append(logtags, l.Rel())
76 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070077 entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080078 }
79
Colin Cross9ae1b922018-06-26 17:59:05 -070080 if library.installFile == nil {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070081 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Cross2c429dc2017-08-31 16:45:16 -070082 }
Colin Cross6ade34f2017-09-15 13:00:47 -070083 if library.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -070084 entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile)
Colin Cross43f08db2018-11-12 10:13:39 -080085 }
86 if len(library.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070087 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled)
Colin Cross6ade34f2017-09-15 13:00:47 -070088 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070089 entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion())
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -070090 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar)
91 entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile)
Colin Crosscb933592017-11-22 13:49:43 -080092
93 if library.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -070094 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile)
Colin Crosscb933592017-11-22 13:49:43 -080095 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080096
Jaewoong Jungb0c127c2019-08-29 14:56:03 -070097 entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...)
Jiyong Park1be96912018-05-28 18:02:19 +090098
Vladimir Marko0975ee02019-04-02 10:29:55 +010099 if len(library.additionalCheckedModules) != 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700100 entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...)
Vladimir Marko0975ee02019-04-02 10:29:55 +0100101 }
102
Colin Crosse8a7dc92019-04-23 13:00:09 -0700103 if library.proguardDictionary != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700104 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
Colin Crosse8a7dc92019-04-23 13:00:09 -0700105 }
Jiyong Park0b238752019-10-29 11:23:10 +0900106 entries.SetString("LOCAL_MODULE_STEM", library.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700107 },
108 },
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700109 ExtraFooters: []android.AndroidMkExtraFootersFunc{
110 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
111 library.AndroidMkHostDex(w, name, entries)
112 },
Colin Cross92430102017-10-09 14:59:32 -0700113 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700114 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700115}
116
Paul Duffin42df1442019-03-20 12:45:53 +0000117// Called for modules that are a component of a test suite.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700118func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700119 entries.SetString("LOCAL_MODULE_TAGS", "tests")
120 if len(test_suites) > 0 {
121 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...)
122 } else {
123 entries.SetString("LOCAL_COMPATIBILITY_SUITE", "null-suite")
124 }
125}
126
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700127func (j *Test) AndroidMkEntries() android.AndroidMkEntries {
128 entries := j.Library.AndroidMkEntries()
129 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
130 testSuiteComponent(entries, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700131 if j.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700132 entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700133 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700134 androidMkWriteTestData(j.data, entries)
Colin Cross05638fc2018-04-09 18:40:24 -0700135 })
136
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700137 return entries
Colin Cross05638fc2018-04-09 18:40:24 -0700138}
139
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700140func (j *TestHelperLibrary) AndroidMkEntries() android.AndroidMkEntries {
141 entries := j.Library.AndroidMkEntries()
142 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
143 testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
Paul Duffin42df1442019-03-20 12:45:53 +0000144 })
145
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700146 return entries
Paul Duffin42df1442019-03-20 12:45:53 +0000147}
148
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700149func (prebuilt *Import) AndroidMkEntries() android.AndroidMkEntries {
Jiyong Park9b409bc2019-10-11 14:59:13 +0900150 if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700151 return android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900152 Disabled: true,
153 }
154 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700155 return android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -0700156 Class: "JAVA_LIBRARIES",
157 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700158 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700159 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
160 func(entries *android.AndroidMkEntries) {
161 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable))
162 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
163 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
164 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
Jiyong Park0b238752019-10-29 11:23:10 +0900165 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700166 },
167 },
168 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700169}
Colin Cross10a03492017-08-10 17:09:43 -0700170
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700171func (prebuilt *DexImport) AndroidMkEntries() android.AndroidMkEntries {
Jiyong Park7f7766d2019-07-25 22:02:35 +0900172 if !prebuilt.IsForPlatform() {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700173 return android.AndroidMkEntries{
Jiyong Park7f7766d2019-07-25 22:02:35 +0900174 Disabled: true,
175 }
176 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700177 return android.AndroidMkEntries{
Colin Cross42be7612019-02-21 18:12:14 -0800178 Class: "JAVA_LIBRARIES",
179 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
180 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700181 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
182 func(entries *android.AndroidMkEntries) {
Colin Cross42be7612019-02-21 18:12:14 -0800183 if prebuilt.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700184 entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800185 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
186 // boot_jars_package_check.mk can check dex jars.
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700187 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.dexJarFile)
188 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.dexJarFile)
Colin Cross42be7612019-02-21 18:12:14 -0800189 }
190 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700191 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
Colin Cross42be7612019-02-21 18:12:14 -0800192 }
Jiyong Park0b238752019-10-29 11:23:10 +0900193 entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
Colin Cross42be7612019-02-21 18:12:14 -0800194 },
195 },
196 }
197}
198
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700199func (prebuilt *AARImport) AndroidMkEntries() android.AndroidMkEntries {
200 return android.AndroidMkEntries{
Colin Crossfabb6082018-02-20 17:22:23 -0800201 Class: "JAVA_LIBRARIES",
202 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
203 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700204 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
205 func(entries *android.AndroidMkEntries) {
206 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
207 entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile)
208 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile)
209 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage)
210 entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags)
211 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile)
212 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest)
213 entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800214 },
215 },
216 }
217}
218
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700219func (binary *Binary) AndroidMkEntries() android.AndroidMkEntries {
Colin Cross10a03492017-08-10 17:09:43 -0700220
Colin Cross6b4a32d2017-12-05 13:42:45 -0800221 if !binary.isWrapperVariant {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700222 return android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800223 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700224 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800225 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700226 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
227 func(entries *android.AndroidMkEntries) {
228 entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile)
229 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar)
Colin Cross12fc2af2019-01-14 12:35:45 -0800230 if binary.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700231 entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile)
Colin Cross12fc2af2019-01-14 12:35:45 -0800232 }
233 if len(binary.dexpreopter.builtInstalled) > 0 {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700234 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800235 }
Colin Cross331a1212018-08-15 20:40:52 -0700236 },
237 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700238 ExtraFooters: []android.AndroidMkExtraFootersFunc{
239 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
240 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
241 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800242 },
243 }
244 } else {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700245 return android.AndroidMkEntries{
Colin Cross6b4a32d2017-12-05 13:42:45 -0800246 Class: "EXECUTABLES",
247 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700248 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
249 func(entries *android.AndroidMkEntries) {
250 entries.SetBool("LOCAL_STRIP_MODULE", false)
Colin Cross6b4a32d2017-12-05 13:42:45 -0800251 },
252 },
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700253 ExtraFooters: []android.AndroidMkExtraFootersFunc{
254 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
255 // Ensure that the wrapper script timestamp is always updated when the jar is updated
256 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
257 fmt.Fprintln(w, "jar_installed_module :=")
258 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800259 },
260 }
Colin Cross10a03492017-08-10 17:09:43 -0700261 }
262}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800263
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700264func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries {
265 return android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800266 Class: "APPS",
267 OutputFile: android.OptionalPathForPath(app.outputFile),
268 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700269 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
270 func(entries *android.AndroidMkEntries) {
271 // App module names can be overridden.
272 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700273 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800274 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700275 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800276 }
Colin Cross331a1212018-08-15 20:40:52 -0700277 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700278 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800279 }
280 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700281 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800282 }
Colin Crossf6237212018-10-29 23:14:58 -0700283 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700284 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700285 }
Colin Cross70798562017-12-13 22:42:59 -0800286 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700287 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800288 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800289 if app.proguardDictionary != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700290 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800291 }
Colin Cross70798562017-12-13 22:42:59 -0800292
293 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700294 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800295 // Make base_rules.mk not put framework-res in a subdirectory called
296 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700297 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800298 }
299
Anton Hansson53c88442019-03-18 15:53:16 +0000300 filterRRO := func(filter overlayType) android.Paths {
301 var paths android.Paths
302 for _, d := range app.rroDirs {
303 if d.overlayType == filter {
304 paths = append(paths, d.path)
305 }
306 }
Colin Crossa140bb02018-04-17 10:52:26 -0700307 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
308 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000309 return android.ReversePaths(paths)
310 }
311 deviceRRODirs := filterRRO(device)
312 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700313 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000314 }
315 productRRODirs := filterRRO(product)
316 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700317 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800318 }
319
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700320 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800321
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700322 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800323
Jiyong Parkf7487312019-10-17 12:54:30 +0900324 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800325
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700326 entries.SetPath("LOCAL_CERTIFICATE", app.certificate.Pem)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700327 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700328
329 for _, jniLib := range app.installJniLibs {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700330 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Colin Crossa4f08812018-10-02 22:03:40 -0700331 }
Colin Cross43f08db2018-11-12 10:13:39 -0800332 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700333 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800334 }
Colin Crosse560c4a2019-03-19 16:03:11 -0700335 for _, split := range app.aapt.splits {
Jaewoong Jung7dd4ae22019-09-27 17:13:15 -0700336 install := app.onDeviceDir + "/" +
337 strings.TrimSuffix(app.installApkName, ".apk") + "_" + split.suffix + ".apk"
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700338 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", split.path.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700339 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700340 },
341 },
342 ExtraFooters: []android.AndroidMkExtraFootersFunc{
343 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700344 if app.noticeOutputs.Merged.Valid() {
345 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
346 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
347 }
348 if app.noticeOutputs.TxtOutput.Valid() {
349 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
350 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
351 }
352 if app.noticeOutputs.HtmlOutput.Valid() {
353 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
354 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
355 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800356 },
357 },
358 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700359}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800360
Jaewoong Jung9109d722019-01-30 13:13:52 -0800361func (a *AndroidApp) getOverriddenPackages() []string {
362 var overridden []string
363 if len(a.appProperties.Overrides) > 0 {
364 overridden = append(overridden, a.appProperties.Overrides...)
365 }
366 if a.Name() != a.installApkName {
367 overridden = append(overridden, a.Name())
368 }
369 return overridden
370}
371
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700372func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries {
373 entries := a.AndroidApp.AndroidMkEntries()
374 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
375 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700376 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700377 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700378 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700379 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700380 })
381
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700382 return entries
Colin Cross252fc6f2018-10-04 15:22:03 -0700383}
384
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700385func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries {
386 entries := a.AndroidApp.AndroidMkEntries()
387 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
388 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
389 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700390
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700391 return entries
392}
393
394func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries {
395 entries := a.Library.AndroidMkEntries()
396
397 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700398 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700399 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700400 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700401
402 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700403 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700404 // Make base_rules.mk not put framework-res in a subdirectory called
405 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700406 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700407 }
408
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700409 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
410 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
411 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700412 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
413 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700414 })
415
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700416 return entries
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800417}
Nan Zhang581fd212018-01-10 16:06:12 -0800418
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700419func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries {
420 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800421 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800422 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700423 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700424 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
425 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700426 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700427 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800428 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800429 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700430 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800431 }
432 },
433 },
434 }
435}
436
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700437func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries {
438 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800439 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800440 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700441 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700442 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
443 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700444 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700445 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800446 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800447 if ddoc.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700448 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800449 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700450 apiFilePrefix := "INTERNAL_PLATFORM_"
451 if String(ddoc.properties.Api_tag_name) != "" {
452 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
453 }
454 if ddoc.apiFile != nil {
455 entries.SetPath(apiFilePrefix+"API_FILE", ddoc.apiFile)
456 }
457 if ddoc.dexApiFile != nil {
458 entries.SetPath(apiFilePrefix+"DEX_API_FILE", ddoc.dexApiFile)
459 }
460 if ddoc.privateApiFile != nil {
461 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", ddoc.privateApiFile)
462 }
463 if ddoc.privateDexApiFile != nil {
464 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", ddoc.privateDexApiFile)
465 }
466 if ddoc.removedApiFile != nil {
467 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", ddoc.removedApiFile)
468 }
469 if ddoc.removedDexApiFile != nil {
470 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", ddoc.removedDexApiFile)
471 }
472 if ddoc.exactApiFile != nil {
473 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", ddoc.exactApiFile)
474 }
475 if ddoc.proguardFile != nil {
476 entries.SetPath(apiFilePrefix+"PROGUARD_FILE", ddoc.proguardFile)
477 }
478 },
479 },
480 ExtraFooters: []android.AndroidMkExtraFootersFunc{
481 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang61819ce2018-05-04 18:49:16 -0700482 if ddoc.checkCurrentApiTimestamp != nil {
483 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
484 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
485 ddoc.checkCurrentApiTimestamp.String())
486
487 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900488 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700489 ddoc.checkCurrentApiTimestamp.String())
490
491 fmt.Fprintln(w, ".PHONY: droidcore")
492 fmt.Fprintln(w, "droidcore: checkapi")
493 }
494 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700495 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700496 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
497 ddoc.updateCurrentApiTimestamp.String())
498
499 fmt.Fprintln(w, ".PHONY: update-api")
500 fmt.Fprintln(w, "update-api:",
501 ddoc.updateCurrentApiTimestamp.String())
502 }
503 if ddoc.checkLastReleasedApiTimestamp != nil {
504 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
505 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
506 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100507
Adrian Roos62e34b92019-01-30 19:51:39 +0100508 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100509 fmt.Fprintln(w, ".PHONY: checkapi")
510 fmt.Fprintln(w, "checkapi:",
511 ddoc.checkLastReleasedApiTimestamp.String())
512
513 fmt.Fprintln(w, ".PHONY: droidcore")
514 fmt.Fprintln(w, "droidcore: checkapi")
515 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700516 }
Nan Zhang581fd212018-01-10 16:06:12 -0800517 },
518 },
519 }
520}
Colin Crossd96ca352018-08-10 16:06:24 -0700521
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700522func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries {
523 return android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700524 Class: "JAVA_LIBRARIES",
525 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
526 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700527 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
528 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700529 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700530 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700531 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700532 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700533 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700534 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700535 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700536 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700537 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700538 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700539 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700540 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100541 if dstubs.metadataZip != nil {
542 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
543 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700544 apiFilePrefix := "INTERNAL_PLATFORM_"
545 if String(dstubs.properties.Api_tag_name) != "" {
546 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
547 }
548 if dstubs.apiFile != nil {
549 entries.SetPath(apiFilePrefix+"API_FILE", dstubs.apiFile)
550 }
551 if dstubs.dexApiFile != nil {
552 entries.SetPath(apiFilePrefix+"DEX_API_FILE", dstubs.dexApiFile)
553 }
554 if dstubs.privateApiFile != nil {
555 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", dstubs.privateApiFile)
556 }
557 if dstubs.privateDexApiFile != nil {
558 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", dstubs.privateDexApiFile)
559 }
560 if dstubs.removedApiFile != nil {
561 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", dstubs.removedApiFile)
562 }
563 if dstubs.removedDexApiFile != nil {
564 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", dstubs.removedDexApiFile)
565 }
566 if dstubs.exactApiFile != nil {
567 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", dstubs.exactApiFile)
568 }
569 },
570 },
571 ExtraFooters: []android.AndroidMkExtraFootersFunc{
572 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700573 if dstubs.checkCurrentApiTimestamp != nil {
574 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
575 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
576 dstubs.checkCurrentApiTimestamp.String())
577
578 fmt.Fprintln(w, ".PHONY: checkapi")
579 fmt.Fprintln(w, "checkapi:",
580 dstubs.checkCurrentApiTimestamp.String())
581
582 fmt.Fprintln(w, ".PHONY: droidcore")
583 fmt.Fprintln(w, "droidcore: checkapi")
584 }
585 if dstubs.updateCurrentApiTimestamp != nil {
586 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
587 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
588 dstubs.updateCurrentApiTimestamp.String())
589
590 fmt.Fprintln(w, ".PHONY: update-api")
591 fmt.Fprintln(w, "update-api:",
592 dstubs.updateCurrentApiTimestamp.String())
593 }
594 if dstubs.checkLastReleasedApiTimestamp != nil {
595 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
596 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
597 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100598
Adrian Roos62e34b92019-01-30 19:51:39 +0100599 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100600 fmt.Fprintln(w, ".PHONY: checkapi")
601 fmt.Fprintln(w, "checkapi:",
602 dstubs.checkLastReleasedApiTimestamp.String())
603
604 fmt.Fprintln(w, ".PHONY: droidcore")
605 fmt.Fprintln(w, "droidcore: checkapi")
606 }
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:",
615 dstubs.apiLintTimestamp.String())
616
617 fmt.Fprintln(w, ".PHONY: droidcore")
618 fmt.Fprintln(w, "droidcore: checkapi")
619 }
Pete Gillin581d6082018-10-22 15:55:04 +0100620 if dstubs.checkNullabilityWarningsTimestamp != nil {
621 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
622 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
623 dstubs.checkNullabilityWarningsTimestamp.String())
624
625 fmt.Fprintln(w, ".PHONY:", "droidcore")
626 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
627 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700628 },
629 },
630 }
631}
632
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700633func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
634 return android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700635 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700636 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700637 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700638 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
639 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900640 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700641 if a.certificate != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700642 entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700643 } else {
644 entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED")
645 }
646 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
647 if len(a.dexpreopter.builtInstalled) > 0 {
648 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
649 }
650 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
651 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700652 },
653 }
654}
655
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700656func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries {
657 entries := a.AndroidAppImport.AndroidMkEntries()
658 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700659 testSuiteComponent(entries, a.testProperties.Test_suites)
660 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700661 })
662 return entries
663}
664
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700665func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700666 var testFiles []string
667 for _, d := range data {
668 testFiles = append(testFiles, d.String()+":"+d.Rel())
669 }
670 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
671}