blob: 05106806a638b49684e15c6d71917c22f4b08d89 [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 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800335 for _, extra := range app.extraOutputFiles {
336 install := app.onDeviceDir + "/" + extra.Base()
337 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700338 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700339 },
340 },
341 ExtraFooters: []android.AndroidMkExtraFootersFunc{
342 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700343 if app.noticeOutputs.Merged.Valid() {
344 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
345 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
346 }
347 if app.noticeOutputs.TxtOutput.Valid() {
348 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
349 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
350 }
351 if app.noticeOutputs.HtmlOutput.Valid() {
352 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
353 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
354 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800355 },
356 },
357 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700358}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800359
Jaewoong Jung9109d722019-01-30 13:13:52 -0800360func (a *AndroidApp) getOverriddenPackages() []string {
361 var overridden []string
362 if len(a.appProperties.Overrides) > 0 {
363 overridden = append(overridden, a.appProperties.Overrides...)
364 }
365 if a.Name() != a.installApkName {
366 overridden = append(overridden, a.Name())
367 }
368 return overridden
369}
370
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700371func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries {
372 entries := a.AndroidApp.AndroidMkEntries()
373 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
374 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700375 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700376 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700377 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700378 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700379 })
380
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700381 return entries
Colin Cross252fc6f2018-10-04 15:22:03 -0700382}
383
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700384func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries {
385 entries := a.AndroidApp.AndroidMkEntries()
386 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
387 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
388 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700389
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700390 return entries
391}
392
393func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries {
394 entries := a.Library.AndroidMkEntries()
395
396 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700397 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700398 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700399 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700400
401 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700402 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700403 // Make base_rules.mk not put framework-res in a subdirectory called
404 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700405 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700406 }
407
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700408 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
409 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
410 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700411 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
412 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700413 })
414
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700415 return entries
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800416}
Nan Zhang581fd212018-01-10 16:06:12 -0800417
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700418func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries {
419 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800420 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800421 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700422 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700423 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
424 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700425 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700426 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800427 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800428 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700429 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800430 }
431 },
432 },
433 }
434}
435
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700436func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries {
437 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800438 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800439 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700440 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700441 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
442 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700443 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700444 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800445 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800446 if ddoc.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700447 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800448 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700449 apiFilePrefix := "INTERNAL_PLATFORM_"
450 if String(ddoc.properties.Api_tag_name) != "" {
451 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
452 }
453 if ddoc.apiFile != nil {
454 entries.SetPath(apiFilePrefix+"API_FILE", ddoc.apiFile)
455 }
456 if ddoc.dexApiFile != nil {
457 entries.SetPath(apiFilePrefix+"DEX_API_FILE", ddoc.dexApiFile)
458 }
459 if ddoc.privateApiFile != nil {
460 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", ddoc.privateApiFile)
461 }
462 if ddoc.privateDexApiFile != nil {
463 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", ddoc.privateDexApiFile)
464 }
465 if ddoc.removedApiFile != nil {
466 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", ddoc.removedApiFile)
467 }
468 if ddoc.removedDexApiFile != nil {
469 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", ddoc.removedDexApiFile)
470 }
471 if ddoc.exactApiFile != nil {
472 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", ddoc.exactApiFile)
473 }
474 if ddoc.proguardFile != nil {
475 entries.SetPath(apiFilePrefix+"PROGUARD_FILE", ddoc.proguardFile)
476 }
477 },
478 },
479 ExtraFooters: []android.AndroidMkExtraFootersFunc{
480 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang61819ce2018-05-04 18:49:16 -0700481 if ddoc.checkCurrentApiTimestamp != nil {
482 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
483 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
484 ddoc.checkCurrentApiTimestamp.String())
485
486 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900487 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700488 ddoc.checkCurrentApiTimestamp.String())
489
490 fmt.Fprintln(w, ".PHONY: droidcore")
491 fmt.Fprintln(w, "droidcore: checkapi")
492 }
493 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700494 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700495 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
496 ddoc.updateCurrentApiTimestamp.String())
497
498 fmt.Fprintln(w, ".PHONY: update-api")
499 fmt.Fprintln(w, "update-api:",
500 ddoc.updateCurrentApiTimestamp.String())
501 }
502 if ddoc.checkLastReleasedApiTimestamp != nil {
503 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
504 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
505 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100506
Adrian Roos62e34b92019-01-30 19:51:39 +0100507 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100508 fmt.Fprintln(w, ".PHONY: checkapi")
509 fmt.Fprintln(w, "checkapi:",
510 ddoc.checkLastReleasedApiTimestamp.String())
511
512 fmt.Fprintln(w, ".PHONY: droidcore")
513 fmt.Fprintln(w, "droidcore: checkapi")
514 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700515 }
Nan Zhang581fd212018-01-10 16:06:12 -0800516 },
517 },
518 }
519}
Colin Crossd96ca352018-08-10 16:06:24 -0700520
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700521func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries {
522 return android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700523 Class: "JAVA_LIBRARIES",
524 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
525 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700526 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
527 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700528 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700529 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700530 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700531 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700532 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700533 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700534 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700535 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700536 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700537 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700538 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700539 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100540 if dstubs.metadataZip != nil {
541 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
542 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700543 apiFilePrefix := "INTERNAL_PLATFORM_"
544 if String(dstubs.properties.Api_tag_name) != "" {
545 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
546 }
547 if dstubs.apiFile != nil {
548 entries.SetPath(apiFilePrefix+"API_FILE", dstubs.apiFile)
549 }
550 if dstubs.dexApiFile != nil {
551 entries.SetPath(apiFilePrefix+"DEX_API_FILE", dstubs.dexApiFile)
552 }
553 if dstubs.privateApiFile != nil {
554 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", dstubs.privateApiFile)
555 }
556 if dstubs.privateDexApiFile != nil {
557 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", dstubs.privateDexApiFile)
558 }
559 if dstubs.removedApiFile != nil {
560 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", dstubs.removedApiFile)
561 }
562 if dstubs.removedDexApiFile != nil {
563 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", dstubs.removedDexApiFile)
564 }
565 if dstubs.exactApiFile != nil {
566 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", dstubs.exactApiFile)
567 }
568 },
569 },
570 ExtraFooters: []android.AndroidMkExtraFootersFunc{
571 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700572 if dstubs.checkCurrentApiTimestamp != nil {
573 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
574 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
575 dstubs.checkCurrentApiTimestamp.String())
576
577 fmt.Fprintln(w, ".PHONY: checkapi")
578 fmt.Fprintln(w, "checkapi:",
579 dstubs.checkCurrentApiTimestamp.String())
580
581 fmt.Fprintln(w, ".PHONY: droidcore")
582 fmt.Fprintln(w, "droidcore: checkapi")
583 }
584 if dstubs.updateCurrentApiTimestamp != nil {
585 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
586 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
587 dstubs.updateCurrentApiTimestamp.String())
588
589 fmt.Fprintln(w, ".PHONY: update-api")
590 fmt.Fprintln(w, "update-api:",
591 dstubs.updateCurrentApiTimestamp.String())
592 }
593 if dstubs.checkLastReleasedApiTimestamp != nil {
594 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
595 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
596 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100597
Adrian Roos62e34b92019-01-30 19:51:39 +0100598 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100599 fmt.Fprintln(w, ".PHONY: checkapi")
600 fmt.Fprintln(w, "checkapi:",
601 dstubs.checkLastReleasedApiTimestamp.String())
602
603 fmt.Fprintln(w, ".PHONY: droidcore")
604 fmt.Fprintln(w, "droidcore: checkapi")
605 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700606 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200607 if dstubs.apiLintTimestamp != nil {
608 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
609 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
610 dstubs.apiLintTimestamp.String())
611
612 fmt.Fprintln(w, ".PHONY: checkapi")
613 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100614 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200615
616 fmt.Fprintln(w, ".PHONY: droidcore")
617 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100618
619 if dstubs.apiLintReport != nil {
620 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
621 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
622 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200623 }
Pete Gillin581d6082018-10-22 15:55:04 +0100624 if dstubs.checkNullabilityWarningsTimestamp != nil {
625 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
626 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
627 dstubs.checkNullabilityWarningsTimestamp.String())
628
629 fmt.Fprintln(w, ".PHONY:", "droidcore")
630 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
631 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700632 },
633 },
634 }
635}
636
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700637func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
638 return android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700639 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700640 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700641 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700642 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
643 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900644 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700645 if a.certificate != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700646 entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700647 } else {
648 entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED")
649 }
650 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
651 if len(a.dexpreopter.builtInstalled) > 0 {
652 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
653 }
654 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
655 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700656 },
657 }
658}
659
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700660func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries {
661 entries := a.AndroidAppImport.AndroidMkEntries()
662 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700663 testSuiteComponent(entries, a.testProperties.Test_suites)
664 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700665 })
666 return entries
667}
668
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700669func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700670 var testFiles []string
671 for _, d := range data {
672 testFiles = append(testFiles, d.String()+":"+d.Rel())
673 }
674 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
675}