blob: 7b8127384cecb87c8dffd22923e523778cb7cd3f [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
Sundong Ahn054b19a2018-10-19 13:46:09 +090025func (library *Library) AndroidMkHostDex(w io.Writer, name string, data android.AndroidMkData) {
26 if Bool(library.deviceProperties.Hostdex) && !library.Host() {
27 fmt.Fprintln(w, "include $(CLEAR_VARS)")
28 fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
29 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
30 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
31 if library.installFile == nil {
32 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
33 }
34 if library.dexJarFile != nil {
35 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
36 }
37 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
38 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
39 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
40 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
41 }
42}
43
Colin Crossa18e9cf2017-08-10 17:00:19 -070044func (library *Library) AndroidMk() android.AndroidMkData {
45 return android.AndroidMkData{
46 Class: "JAVA_LIBRARIES",
Colin Cross43f08db2018-11-12 10:13:39 -080047 OutputFile: android.OptionalPathForPath(library.outputFile),
Colin Cross53499412017-09-07 13:20:25 -070048 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -070049 Extra: []android.AndroidMkExtraFunc{
50 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080051 if len(library.logtagsSrcs) > 0 {
52 var logtags []string
53 for _, l := range library.logtagsSrcs {
54 logtags = append(logtags, l.Rel())
55 }
56 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
57 }
58
Colin Cross9ae1b922018-06-26 17:59:05 -070059 if library.installFile == nil {
Colin Cross2c429dc2017-08-31 16:45:16 -070060 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
61 }
Colin Cross6ade34f2017-09-15 13:00:47 -070062 if library.dexJarFile != nil {
63 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -080064 }
65 if len(library.dexpreopter.builtInstalled) > 0 {
66 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(library.dexpreopter.builtInstalled, " "))
Colin Cross6ade34f2017-09-15 13:00:47 -070067 }
Colin Cross83bb3162018-06-25 15:48:06 -070068 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion())
Colin Cross43f08db2018-11-12 10:13:39 -080069 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
Nan Zhanged19fc32017-10-19 13:06:22 -070070 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Crosscb933592017-11-22 13:49:43 -080071
72 if library.jacocoReportClassesFile != nil {
73 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String())
74 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080075
Jiyong Park1be96912018-05-28 18:02:19 +090076 if len(library.exportedSdkLibs) != 0 {
77 fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " "))
78 }
79
Colin Cross5ab4e6d2017-11-22 16:20:45 -080080 // Temporary hack: export sources used to compile framework.jar to Make
81 // to be used for droiddoc
82 // TODO(ccross): remove this once droiddoc is in soong
Mathew Inwoodebe29ce2018-09-04 14:26:19 +010083 if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") {
Colin Cross5ab4e6d2017-11-22 16:20:45 -080084 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " "))
85 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " "))
86 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070087 },
88 },
Colin Cross92430102017-10-09 14:59:32 -070089 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
90 android.WriteAndroidMkData(w, data)
Sundong Ahn054b19a2018-10-19 13:46:09 +090091 library.AndroidMkHostDex(w, name, data)
Colin Cross92430102017-10-09 14:59:32 -070092 },
Colin Crossa18e9cf2017-08-10 17:00:19 -070093 }
Dan Willemsen218f6562015-07-08 18:13:11 -070094}
95
Colin Cross05638fc2018-04-09 18:40:24 -070096func (j *Test) AndroidMk() android.AndroidMkData {
97 data := j.Library.AndroidMk()
98 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
99 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
100 if len(j.testProperties.Test_suites) > 0 {
101 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
102 strings.Join(j.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700103 } else {
104 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Cross05638fc2018-04-09 18:40:24 -0700105 }
Colin Cross303e21f2018-08-07 16:49:25 -0700106 if j.testConfig != nil {
107 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700108 }
Colin Cross05638fc2018-04-09 18:40:24 -0700109 })
110
Colin Crossd96ca352018-08-10 16:06:24 -0700111 androidMkWriteTestData(j.data, &data)
112
Colin Cross05638fc2018-04-09 18:40:24 -0700113 return data
114}
115
Colin Crossa18e9cf2017-08-10 17:00:19 -0700116func (prebuilt *Import) AndroidMk() android.AndroidMkData {
117 return android.AndroidMkData{
118 Class: "JAVA_LIBRARIES",
119 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700120 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700121 Extra: []android.AndroidMkExtraFunc{
122 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700123 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700124 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800125 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700126 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700127 },
128 },
129 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700130}
Colin Cross10a03492017-08-10 17:09:43 -0700131
Colin Crossfabb6082018-02-20 17:22:23 -0800132func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
133 return android.AndroidMkData{
134 Class: "JAVA_LIBRARIES",
135 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
136 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
137 Extra: []android.AndroidMkExtraFunc{
138 func(w io.Writer, outputFile android.Path) {
139 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossfabb6082018-02-20 17:22:23 -0800140 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800141 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800142 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
143 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
Colin Cross66f78822018-05-02 12:58:28 -0700144 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
Colin Cross10f7c4a2018-05-23 10:59:28 -0700145 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700146 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800147 },
148 },
149 }
150}
151
Colin Cross10a03492017-08-10 17:09:43 -0700152func (binary *Binary) AndroidMk() android.AndroidMkData {
Colin Cross10a03492017-08-10 17:09:43 -0700153
Colin Cross6b4a32d2017-12-05 13:42:45 -0800154 if !binary.isWrapperVariant {
155 return android.AndroidMkData{
156 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700157 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800158 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Cross331a1212018-08-15 20:40:52 -0700159 Extra: []android.AndroidMkExtraFunc{
160 func(w io.Writer, outputFile android.Path) {
161 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800162 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
Colin Cross12fc2af2019-01-14 12:35:45 -0800163 if binary.dexJarFile != nil {
164 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
165 }
166 if len(binary.dexpreopter.builtInstalled) > 0 {
167 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(binary.dexpreopter.builtInstalled, " "))
168 }
Colin Cross331a1212018-08-15 20:40:52 -0700169 },
170 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800171 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
172 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700173
Colin Cross6b4a32d2017-12-05 13:42:45 -0800174 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
175 },
176 }
177 } else {
178 return android.AndroidMkData{
179 Class: "EXECUTABLES",
180 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
181 Extra: []android.AndroidMkExtraFunc{
182 func(w io.Writer, outputFile android.Path) {
183 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
184 },
185 },
186 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
187 android.WriteAndroidMkData(w, data)
188
189 // Ensure that the wrapper script timestamp is always updated when the jar is updated
190 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
191 fmt.Fprintln(w, "jar_installed_module :=")
192 },
193 }
Colin Cross10a03492017-08-10 17:09:43 -0700194 }
195}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800196
197func (app *AndroidApp) AndroidMk() android.AndroidMkData {
198 return android.AndroidMkData{
199 Class: "APPS",
200 OutputFile: android.OptionalPathForPath(app.outputFile),
201 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
202 Extra: []android.AndroidMkExtraFunc{
203 func(w io.Writer, outputFile android.Path) {
Colin Cross70798562017-12-13 22:42:59 -0800204 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
205 if app.dexJarFile != nil {
206 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800207 }
Colin Cross331a1212018-08-15 20:40:52 -0700208 if app.implementationAndResourcesJar != nil {
209 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800210 }
211 if app.headerJarFile != nil {
212 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
213 }
Colin Crossf6237212018-10-29 23:14:58 -0700214 if app.bundleFile != nil {
215 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
216 }
Colin Cross70798562017-12-13 22:42:59 -0800217 if app.jacocoReportClassesFile != nil {
218 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
219 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800220 if app.proguardDictionary != nil {
221 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
222 }
Colin Cross70798562017-12-13 22:42:59 -0800223
224 if app.Name() == "framework-res" {
225 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
226 // Make base_rules.mk not put framework-res in a subdirectory called
227 // framework_res.
228 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
229 }
230
231 if len(app.rroDirs) > 0 {
Colin Crossa140bb02018-04-17 10:52:26 -0700232 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
233 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
234 fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800235 }
236
237 if Bool(app.appProperties.Export_package_resources) {
238 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
239 }
240
241 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
242
Colin Cross16056062017-12-13 22:46:28 -0800243 if Bool(app.appProperties.Privileged) {
244 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
245 }
Colin Crosse1731a52017-12-14 11:22:55 -0800246
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900247 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jason Monkd4122be2018-08-10 09:33:36 -0400248 if len(app.appProperties.Overrides) > 0 {
249 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES := "+strings.Join(app.appProperties.Overrides, " "))
250 }
Colin Crossa4f08812018-10-02 22:03:40 -0700251
252 for _, jniLib := range app.installJniLibs {
253 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
254 }
Colin Cross43f08db2018-11-12 10:13:39 -0800255 if len(app.dexpreopter.builtInstalled) > 0 {
256 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(app.dexpreopter.builtInstalled, " "))
257 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800258 },
259 },
260 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700261}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800262
Colin Crossae5caf52018-05-22 11:11:52 -0700263func (a *AndroidTest) AndroidMk() android.AndroidMkData {
264 data := a.AndroidApp.AndroidMk()
265 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
266 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
267 if len(a.testProperties.Test_suites) > 0 {
268 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
269 strings.Join(a.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700270 } else {
271 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Crossae5caf52018-05-22 11:11:52 -0700272 }
Colin Cross303e21f2018-08-07 16:49:25 -0700273 if a.testConfig != nil {
274 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700275 }
Colin Crossae5caf52018-05-22 11:11:52 -0700276 })
Colin Crossd96ca352018-08-10 16:06:24 -0700277 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700278
279 return data
280}
281
Colin Cross252fc6f2018-10-04 15:22:03 -0700282func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
283 data := a.AndroidApp.AndroidMk()
284 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
285 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
286 if len(a.appTestHelperAppProperties.Test_suites) > 0 {
287 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
288 strings.Join(a.appTestHelperAppProperties.Test_suites, " "))
289 } else {
290 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
291 }
292 })
293
294 return data
295}
296
Colin Crossa97c5d32018-03-28 14:58:31 -0700297func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
298 data := a.Library.AndroidMk()
299
300 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700301 if a.aarFile != nil {
302 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
303 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700304 if a.proguardDictionary != nil {
305 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
306 }
307
308 if a.Name() == "framework-res" {
309 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
310 // Make base_rules.mk not put framework-res in a subdirectory called
311 // framework_res.
312 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
313 }
314
315 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700316 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700317 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700318 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
319 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700320 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700321 })
322
323 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800324}
Nan Zhang581fd212018-01-10 16:06:12 -0800325
326func (jd *Javadoc) AndroidMk() android.AndroidMkData {
327 return android.AndroidMkData{
328 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800329 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700330 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800331 Extra: []android.AndroidMkExtraFunc{
332 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700333 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800334 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
335 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800336 if jd.stubsSrcJar != nil {
337 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800338 }
339 },
340 },
341 }
342}
343
344func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
345 return android.AndroidMkData{
346 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800347 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700348 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800349 Extra: []android.AndroidMkExtraFunc{
350 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700351 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800352 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
353 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800354 if ddoc.Javadoc.stubsSrcJar != nil {
355 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800356 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700357 if ddoc.checkCurrentApiTimestamp != nil {
358 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
359 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
360 ddoc.checkCurrentApiTimestamp.String())
361
362 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900363 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700364 ddoc.checkCurrentApiTimestamp.String())
365
366 fmt.Fprintln(w, ".PHONY: droidcore")
367 fmt.Fprintln(w, "droidcore: checkapi")
368 }
369 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700370 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700371 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
372 ddoc.updateCurrentApiTimestamp.String())
373
374 fmt.Fprintln(w, ".PHONY: update-api")
375 fmt.Fprintln(w, "update-api:",
376 ddoc.updateCurrentApiTimestamp.String())
377 }
378 if ddoc.checkLastReleasedApiTimestamp != nil {
379 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
380 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
381 ddoc.checkLastReleasedApiTimestamp.String())
382 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700383 apiFilePrefix := "INTERNAL_PLATFORM_"
384 if String(ddoc.properties.Api_tag_name) != "" {
385 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
386 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700387 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700388 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
389 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100390 if ddoc.dexApiFile != nil {
391 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
392 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700393 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700394 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
395 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700396 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700397 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
398 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700399 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700400 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
401 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700402 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100403 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
404 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700405 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700406 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
407 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700408 if ddoc.proguardFile != nil {
409 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
410 }
Nan Zhang581fd212018-01-10 16:06:12 -0800411 },
412 },
413 }
414}
Colin Crossd96ca352018-08-10 16:06:24 -0700415
Nan Zhang1598a9e2018-09-04 17:14:32 -0700416func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
417 return android.AndroidMkData{
418 Class: "JAVA_LIBRARIES",
419 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
420 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
421 Extra: []android.AndroidMkExtraFunc{
422 func(w io.Writer, outputFile android.Path) {
423 if dstubs.Javadoc.stubsSrcJar != nil {
424 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
425 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700426 if dstubs.apiVersionsXml != nil {
427 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
428 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700429 if dstubs.annotationsZip != nil {
430 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
431 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700432 if dstubs.jdiffDocZip != nil {
433 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
434 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700435 if dstubs.checkCurrentApiTimestamp != nil {
436 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
437 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
438 dstubs.checkCurrentApiTimestamp.String())
439
440 fmt.Fprintln(w, ".PHONY: checkapi")
441 fmt.Fprintln(w, "checkapi:",
442 dstubs.checkCurrentApiTimestamp.String())
443
444 fmt.Fprintln(w, ".PHONY: droidcore")
445 fmt.Fprintln(w, "droidcore: checkapi")
446 }
447 if dstubs.updateCurrentApiTimestamp != nil {
448 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
449 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
450 dstubs.updateCurrentApiTimestamp.String())
451
452 fmt.Fprintln(w, ".PHONY: update-api")
453 fmt.Fprintln(w, "update-api:",
454 dstubs.updateCurrentApiTimestamp.String())
455 }
456 if dstubs.checkLastReleasedApiTimestamp != nil {
457 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
458 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
459 dstubs.checkLastReleasedApiTimestamp.String())
460 }
Pete Gillin581d6082018-10-22 15:55:04 +0100461 if dstubs.checkNullabilityWarningsTimestamp != nil {
462 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
463 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
464 dstubs.checkNullabilityWarningsTimestamp.String())
465
466 fmt.Fprintln(w, ".PHONY:", "droidcore")
467 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
468 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700469 apiFilePrefix := "INTERNAL_PLATFORM_"
470 if String(dstubs.properties.Api_tag_name) != "" {
471 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
472 }
473 if dstubs.apiFile != nil {
474 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
475 }
476 if dstubs.dexApiFile != nil {
477 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
478 }
479 if dstubs.privateApiFile != nil {
480 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
481 }
482 if dstubs.privateDexApiFile != nil {
483 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
484 }
485 if dstubs.removedApiFile != nil {
486 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
487 }
488 if dstubs.removedDexApiFile != nil {
489 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
490 }
491 if dstubs.exactApiFile != nil {
492 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
493 }
494 },
495 },
496 }
497}
498
Colin Crossd96ca352018-08-10 16:06:24 -0700499func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
500 var testFiles []string
501 for _, d := range data {
502 testFiles = append(testFiles, d.String()+":"+d.Rel())
503 }
504 if len(testFiles) > 0 {
505 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
506 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
507 })
508 }
509}