blob: c973739260db7e5251c9f2dbd19ad5c905060f73 [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 {
Jiyong Park52cd06f2019-11-11 10:14:32 +0900265 if !app.IsForPlatform() {
266 return android.AndroidMkEntries{
267 Disabled: true,
268 }
269 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700270 return android.AndroidMkEntries{
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800271 Class: "APPS",
272 OutputFile: android.OptionalPathForPath(app.outputFile),
273 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700274 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
275 func(entries *android.AndroidMkEntries) {
276 // App module names can be overridden.
277 entries.SetString("LOCAL_MODULE", app.installApkName)
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700278 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage)
Colin Cross70798562017-12-13 22:42:59 -0800279 if app.dexJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700280 entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile)
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800281 }
Colin Cross331a1212018-08-15 20:40:52 -0700282 if app.implementationAndResourcesJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700283 entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800284 }
285 if app.headerJarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700286 entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile)
Colin Cross5dfabfb2017-12-14 13:19:01 -0800287 }
Colin Crossf6237212018-10-29 23:14:58 -0700288 if app.bundleFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700289 entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile)
Colin Crossf6237212018-10-29 23:14:58 -0700290 }
Colin Cross70798562017-12-13 22:42:59 -0800291 if app.jacocoReportClassesFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700292 entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile)
Colin Cross70798562017-12-13 22:42:59 -0800293 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800294 if app.proguardDictionary != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700295 entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800296 }
Colin Cross70798562017-12-13 22:42:59 -0800297
298 if app.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700299 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Cross70798562017-12-13 22:42:59 -0800300 // Make base_rules.mk not put framework-res in a subdirectory called
301 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700302 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Cross70798562017-12-13 22:42:59 -0800303 }
304
Anton Hansson53c88442019-03-18 15:53:16 +0000305 filterRRO := func(filter overlayType) android.Paths {
306 var paths android.Paths
307 for _, d := range app.rroDirs {
308 if d.overlayType == filter {
309 paths = append(paths, d.path)
310 }
311 }
Colin Crossa140bb02018-04-17 10:52:26 -0700312 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
313 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000314 return android.ReversePaths(paths)
315 }
316 deviceRRODirs := filterRRO(device)
317 if len(deviceRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700318 entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...)
Anton Hansson53c88442019-03-18 15:53:16 +0000319 }
320 productRRODirs := filterRRO(product)
321 if len(productRRODirs) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700322 entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...)
Colin Cross70798562017-12-13 22:42:59 -0800323 }
324
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700325 entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources))
Colin Cross70798562017-12-13 22:42:59 -0800326
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700327 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
Colin Cross70798562017-12-13 22:42:59 -0800328
Jiyong Parkf7487312019-10-17 12:54:30 +0900329 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
Colin Crosse1731a52017-12-14 11:22:55 -0800330
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700331 entries.SetPath("LOCAL_CERTIFICATE", app.certificate.Pem)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700332 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
Colin Crossa4f08812018-10-02 22:03:40 -0700333
334 for _, jniLib := range app.installJniLibs {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700335 entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name)
Colin Crossa4f08812018-10-02 22:03:40 -0700336 }
Colin Cross43f08db2018-11-12 10:13:39 -0800337 if len(app.dexpreopter.builtInstalled) > 0 {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700338 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800339 }
Jaewoong Jung5a498812019-11-07 14:14:38 -0800340 for _, extra := range app.extraOutputFiles {
341 install := app.onDeviceDir + "/" + extra.Base()
342 entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
Colin Crosse560c4a2019-03-19 16:03:11 -0700343 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700344 },
345 },
346 ExtraFooters: []android.AndroidMkExtraFootersFunc{
347 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Jaewoong Jung98772792019-07-01 17:15:13 -0700348 if app.noticeOutputs.Merged.Valid() {
349 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
350 app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE")
351 }
352 if app.noticeOutputs.TxtOutput.Valid() {
353 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
354 app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt")
355 }
356 if app.noticeOutputs.HtmlOutput.Valid() {
357 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n",
358 app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html")
359 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800360 },
361 },
362 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700363}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800364
Jaewoong Jung9109d722019-01-30 13:13:52 -0800365func (a *AndroidApp) getOverriddenPackages() []string {
366 var overridden []string
367 if len(a.appProperties.Overrides) > 0 {
368 overridden = append(overridden, a.appProperties.Overrides...)
369 }
370 if a.Name() != a.installApkName {
371 overridden = append(overridden, a.Name())
372 }
373 return overridden
374}
375
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700376func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries {
377 entries := a.AndroidApp.AndroidMkEntries()
378 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
379 testSuiteComponent(entries, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700380 if a.testConfig != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700381 entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig)
Julien Despreze146e392018-08-02 15:00:46 -0700382 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700383 androidMkWriteTestData(a.data, entries)
Colin Cross252fc6f2018-10-04 15:22:03 -0700384 })
385
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700386 return entries
Colin Cross252fc6f2018-10-04 15:22:03 -0700387}
388
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700389func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries {
390 entries := a.AndroidApp.AndroidMkEntries()
391 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
392 testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
393 })
Colin Crossa97c5d32018-03-28 14:58:31 -0700394
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700395 return entries
396}
397
398func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries {
399 entries := a.Library.AndroidMkEntries()
400
401 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa54974c2018-10-29 23:15:37 -0700402 if a.aarFile != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700403 entries.SetPath("LOCAL_SOONG_AAR", a.aarFile)
Colin Crossa54974c2018-10-29 23:15:37 -0700404 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700405
406 if a.Name() == "framework-res" {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700407 entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)")
Colin Crossa97c5d32018-03-28 14:58:31 -0700408 // Make base_rules.mk not put framework-res in a subdirectory called
409 // framework_res.
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700410 entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700411 }
412
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700413 entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage)
414 entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile)
415 entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile)
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700416 entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...)
417 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
Colin Crossa97c5d32018-03-28 14:58:31 -0700418 })
419
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700420 return entries
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800421}
Nan Zhang581fd212018-01-10 16:06:12 -0800422
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700423func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries {
424 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800425 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800426 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700427 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700428 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
429 func(entries *android.AndroidMkEntries) {
Colin Cross38b40df2018-04-10 16:14:46 -0700430 if BoolDefault(jd.properties.Installable, true) {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700431 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800432 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800433 if jd.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700434 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800435 }
436 },
437 },
438 }
439}
440
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700441func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries {
442 return android.AndroidMkEntries{
Nan Zhang581fd212018-01-10 16:06:12 -0800443 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800444 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700445 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700446 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
447 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700448 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700449 entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip)
Nan Zhang581fd212018-01-10 16:06:12 -0800450 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800451 if ddoc.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700452 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar)
Nan Zhang581fd212018-01-10 16:06:12 -0800453 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700454 apiFilePrefix := "INTERNAL_PLATFORM_"
455 if String(ddoc.properties.Api_tag_name) != "" {
456 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
457 }
458 if ddoc.apiFile != nil {
459 entries.SetPath(apiFilePrefix+"API_FILE", ddoc.apiFile)
460 }
461 if ddoc.dexApiFile != nil {
462 entries.SetPath(apiFilePrefix+"DEX_API_FILE", ddoc.dexApiFile)
463 }
464 if ddoc.privateApiFile != nil {
465 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", ddoc.privateApiFile)
466 }
467 if ddoc.privateDexApiFile != nil {
468 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", ddoc.privateDexApiFile)
469 }
470 if ddoc.removedApiFile != nil {
471 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", ddoc.removedApiFile)
472 }
473 if ddoc.removedDexApiFile != nil {
474 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", ddoc.removedDexApiFile)
475 }
476 if ddoc.exactApiFile != nil {
477 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", ddoc.exactApiFile)
478 }
479 if ddoc.proguardFile != nil {
480 entries.SetPath(apiFilePrefix+"PROGUARD_FILE", ddoc.proguardFile)
481 }
482 },
483 },
484 ExtraFooters: []android.AndroidMkExtraFootersFunc{
485 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang61819ce2018-05-04 18:49:16 -0700486 if ddoc.checkCurrentApiTimestamp != nil {
487 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
488 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
489 ddoc.checkCurrentApiTimestamp.String())
490
491 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900492 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700493 ddoc.checkCurrentApiTimestamp.String())
494
495 fmt.Fprintln(w, ".PHONY: droidcore")
496 fmt.Fprintln(w, "droidcore: checkapi")
497 }
498 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700499 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700500 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
501 ddoc.updateCurrentApiTimestamp.String())
502
503 fmt.Fprintln(w, ".PHONY: update-api")
504 fmt.Fprintln(w, "update-api:",
505 ddoc.updateCurrentApiTimestamp.String())
506 }
507 if ddoc.checkLastReleasedApiTimestamp != nil {
508 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
509 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
510 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100511
Adrian Roos62e34b92019-01-30 19:51:39 +0100512 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100513 fmt.Fprintln(w, ".PHONY: checkapi")
514 fmt.Fprintln(w, "checkapi:",
515 ddoc.checkLastReleasedApiTimestamp.String())
516
517 fmt.Fprintln(w, ".PHONY: droidcore")
518 fmt.Fprintln(w, "droidcore: checkapi")
519 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700520 }
Nan Zhang581fd212018-01-10 16:06:12 -0800521 },
522 },
523 }
524}
Colin Crossd96ca352018-08-10 16:06:24 -0700525
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700526func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries {
527 return android.AndroidMkEntries{
Nan Zhang1598a9e2018-09-04 17:14:32 -0700528 Class: "JAVA_LIBRARIES",
529 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
530 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700531 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
532 func(entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700533 if dstubs.Javadoc.stubsSrcJar != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700534 entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700535 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700536 if dstubs.apiVersionsXml != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700537 entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml)
Nan Zhangd23ac692018-09-18 10:41:33 -0700538 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700539 if dstubs.annotationsZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700540 entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip)
Nan Zhang1598a9e2018-09-04 17:14:32 -0700541 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700542 if dstubs.jdiffDocZip != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700543 entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip)
Nan Zhang71bbe632018-09-17 14:32:21 -0700544 }
Jerome Gaillard0f599032019-10-10 19:29:11 +0100545 if dstubs.metadataZip != nil {
546 entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip)
547 }
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700548 apiFilePrefix := "INTERNAL_PLATFORM_"
549 if String(dstubs.properties.Api_tag_name) != "" {
550 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
551 }
552 if dstubs.apiFile != nil {
553 entries.SetPath(apiFilePrefix+"API_FILE", dstubs.apiFile)
554 }
555 if dstubs.dexApiFile != nil {
556 entries.SetPath(apiFilePrefix+"DEX_API_FILE", dstubs.dexApiFile)
557 }
558 if dstubs.privateApiFile != nil {
559 entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", dstubs.privateApiFile)
560 }
561 if dstubs.privateDexApiFile != nil {
562 entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", dstubs.privateDexApiFile)
563 }
564 if dstubs.removedApiFile != nil {
565 entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", dstubs.removedApiFile)
566 }
567 if dstubs.removedDexApiFile != nil {
568 entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", dstubs.removedDexApiFile)
569 }
570 if dstubs.exactApiFile != nil {
571 entries.SetPath(apiFilePrefix+"EXACT_API_FILE", dstubs.exactApiFile)
572 }
573 },
574 },
575 ExtraFooters: []android.AndroidMkExtraFootersFunc{
576 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700577 if dstubs.checkCurrentApiTimestamp != nil {
578 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
579 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
580 dstubs.checkCurrentApiTimestamp.String())
581
582 fmt.Fprintln(w, ".PHONY: checkapi")
583 fmt.Fprintln(w, "checkapi:",
584 dstubs.checkCurrentApiTimestamp.String())
585
586 fmt.Fprintln(w, ".PHONY: droidcore")
587 fmt.Fprintln(w, "droidcore: checkapi")
588 }
589 if dstubs.updateCurrentApiTimestamp != nil {
590 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
591 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
592 dstubs.updateCurrentApiTimestamp.String())
593
594 fmt.Fprintln(w, ".PHONY: update-api")
595 fmt.Fprintln(w, "update-api:",
596 dstubs.updateCurrentApiTimestamp.String())
597 }
598 if dstubs.checkLastReleasedApiTimestamp != nil {
599 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
600 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
601 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100602
Adrian Roos62e34b92019-01-30 19:51:39 +0100603 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100604 fmt.Fprintln(w, ".PHONY: checkapi")
605 fmt.Fprintln(w, "checkapi:",
606 dstubs.checkLastReleasedApiTimestamp.String())
607
608 fmt.Fprintln(w, ".PHONY: droidcore")
609 fmt.Fprintln(w, "droidcore: checkapi")
610 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700611 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200612 if dstubs.apiLintTimestamp != nil {
613 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint")
614 fmt.Fprintln(w, dstubs.Name()+"-api-lint:",
615 dstubs.apiLintTimestamp.String())
616
617 fmt.Fprintln(w, ".PHONY: checkapi")
618 fmt.Fprintln(w, "checkapi:",
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100619 dstubs.Name()+"-api-lint")
Adrian Roos075eedc2019-10-10 12:07:03 +0200620
621 fmt.Fprintln(w, ".PHONY: droidcore")
622 fmt.Fprintln(w, "droidcore: checkapi")
Adrian Roos3b8f1cd2019-11-01 13:42:39 +0100623
624 if dstubs.apiLintReport != nil {
625 fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
626 dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
627 }
Adrian Roos075eedc2019-10-10 12:07:03 +0200628 }
Pete Gillin581d6082018-10-22 15:55:04 +0100629 if dstubs.checkNullabilityWarningsTimestamp != nil {
630 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
631 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
632 dstubs.checkNullabilityWarningsTimestamp.String())
633
634 fmt.Fprintln(w, ".PHONY:", "droidcore")
635 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
636 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700637 },
638 },
639 }
640}
641
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700642func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
643 return android.AndroidMkEntries{
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700644 Class: "APPS",
Jaewoong Jung8aae22e2019-07-17 10:21:49 -0700645 OutputFile: android.OptionalPathForPath(a.outputFile),
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700646 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700647 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
648 func(entries *android.AndroidMkEntries) {
Jiyong Parkf7487312019-10-17 12:54:30 +0900649 entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700650 if a.certificate != nil {
Jaewoong Jung9a1e8bd2019-09-04 20:17:54 -0700651 entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700652 } else {
653 entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED")
654 }
655 entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...)
656 if len(a.dexpreopter.builtInstalled) > 0 {
657 entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled)
658 }
659 entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
660 },
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700661 },
662 }
663}
664
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700665func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries {
666 entries := a.AndroidAppImport.AndroidMkEntries()
667 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700668 testSuiteComponent(entries, a.testProperties.Test_suites)
669 androidMkWriteTestData(a.data, entries)
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700670 })
671 return entries
672}
673
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700674func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {
Jaewoong Jungb28eb5f2019-08-27 15:01:50 -0700675 var testFiles []string
676 for _, d := range data {
677 testFiles = append(testFiles, d.String()+":"+d.Rel())
678 }
679 entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...)
680}