blob: 70d0f7f98bd77a97c70e6c7bd419868957404e07 [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
Colin Crossa18e9cf2017-08-10 17:00:19 -070025func (library *Library) AndroidMk() android.AndroidMkData {
26 return android.AndroidMkData{
27 Class: "JAVA_LIBRARIES",
Colin Cross43f08db2018-11-12 10:13:39 -080028 OutputFile: android.OptionalPathForPath(library.outputFile),
Colin Cross53499412017-09-07 13:20:25 -070029 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -070030 Extra: []android.AndroidMkExtraFunc{
31 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080032 if len(library.logtagsSrcs) > 0 {
33 var logtags []string
34 for _, l := range library.logtagsSrcs {
35 logtags = append(logtags, l.Rel())
36 }
37 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
38 }
39
Colin Cross9ae1b922018-06-26 17:59:05 -070040 if library.installFile == nil {
Colin Cross2c429dc2017-08-31 16:45:16 -070041 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
42 }
Colin Cross6ade34f2017-09-15 13:00:47 -070043 if library.dexJarFile != nil {
44 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -080045 }
46 if len(library.dexpreopter.builtInstalled) > 0 {
47 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(library.dexpreopter.builtInstalled, " "))
Colin Cross6ade34f2017-09-15 13:00:47 -070048 }
Colin Cross83bb3162018-06-25 15:48:06 -070049 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion())
Colin Cross43f08db2018-11-12 10:13:39 -080050 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
Nan Zhanged19fc32017-10-19 13:06:22 -070051 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Crosscb933592017-11-22 13:49:43 -080052
53 if library.jacocoReportClassesFile != nil {
54 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String())
55 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080056
Jiyong Park1be96912018-05-28 18:02:19 +090057 if len(library.exportedSdkLibs) != 0 {
58 fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " "))
59 }
60
Colin Cross5ab4e6d2017-11-22 16:20:45 -080061 // Temporary hack: export sources used to compile framework.jar to Make
62 // to be used for droiddoc
63 // TODO(ccross): remove this once droiddoc is in soong
Mathew Inwoodebe29ce2018-09-04 14:26:19 +010064 if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") {
Colin Cross5ab4e6d2017-11-22 16:20:45 -080065 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " "))
66 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " "))
67 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070068 },
69 },
Colin Cross92430102017-10-09 14:59:32 -070070 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
71 android.WriteAndroidMkData(w, data)
72
Colin Crossff3ae9d2018-04-10 16:15:18 -070073 if Bool(library.deviceProperties.Hostdex) && !library.Host() {
Colin Cross92430102017-10-09 14:59:32 -070074 fmt.Fprintln(w, "include $(CLEAR_VARS)")
75 fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
76 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
77 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
Colin Cross9ae1b922018-06-26 17:59:05 -070078 if library.installFile == nil {
Colin Cross92430102017-10-09 14:59:32 -070079 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
80 }
81 if library.dexJarFile != nil {
82 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
83 }
Colin Cross331a1212018-08-15 20:40:52 -070084 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -080085 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
Colin Cross92430102017-10-09 14:59:32 -070086 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
87 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
88 }
89 },
Colin Crossa18e9cf2017-08-10 17:00:19 -070090 }
Dan Willemsen218f6562015-07-08 18:13:11 -070091}
92
Colin Cross05638fc2018-04-09 18:40:24 -070093func (j *Test) AndroidMk() android.AndroidMkData {
94 data := j.Library.AndroidMk()
95 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
96 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
97 if len(j.testProperties.Test_suites) > 0 {
98 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
99 strings.Join(j.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700100 } else {
101 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Cross05638fc2018-04-09 18:40:24 -0700102 }
Colin Cross303e21f2018-08-07 16:49:25 -0700103 if j.testConfig != nil {
104 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700105 }
Colin Cross05638fc2018-04-09 18:40:24 -0700106 })
107
Colin Crossd96ca352018-08-10 16:06:24 -0700108 androidMkWriteTestData(j.data, &data)
109
Colin Cross05638fc2018-04-09 18:40:24 -0700110 return data
111}
112
Colin Crossa18e9cf2017-08-10 17:00:19 -0700113func (prebuilt *Import) AndroidMk() android.AndroidMkData {
114 return android.AndroidMkData{
115 Class: "JAVA_LIBRARIES",
116 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700117 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700118 Extra: []android.AndroidMkExtraFunc{
119 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700120 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700121 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800122 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700123 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700124 },
125 },
126 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700127}
Colin Cross10a03492017-08-10 17:09:43 -0700128
Colin Crossfabb6082018-02-20 17:22:23 -0800129func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
130 return android.AndroidMkData{
131 Class: "JAVA_LIBRARIES",
132 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
133 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
134 Extra: []android.AndroidMkExtraFunc{
135 func(w io.Writer, outputFile android.Path) {
136 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossfabb6082018-02-20 17:22:23 -0800137 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800138 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800139 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
140 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
Colin Cross66f78822018-05-02 12:58:28 -0700141 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
Colin Cross10f7c4a2018-05-23 10:59:28 -0700142 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700143 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800144 },
145 },
146 }
147}
148
Colin Cross10a03492017-08-10 17:09:43 -0700149func (binary *Binary) AndroidMk() android.AndroidMkData {
Colin Cross10a03492017-08-10 17:09:43 -0700150
Colin Cross6b4a32d2017-12-05 13:42:45 -0800151 if !binary.isWrapperVariant {
152 return android.AndroidMkData{
153 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700154 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800155 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Cross331a1212018-08-15 20:40:52 -0700156 Extra: []android.AndroidMkExtraFunc{
157 func(w io.Writer, outputFile android.Path) {
158 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800159 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
Colin Cross331a1212018-08-15 20:40:52 -0700160 },
161 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800162 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
163 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700164
Colin Cross6b4a32d2017-12-05 13:42:45 -0800165 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
166 },
167 }
168 } else {
169 return android.AndroidMkData{
170 Class: "EXECUTABLES",
171 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
172 Extra: []android.AndroidMkExtraFunc{
173 func(w io.Writer, outputFile android.Path) {
174 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
175 },
176 },
177 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
178 android.WriteAndroidMkData(w, data)
179
180 // Ensure that the wrapper script timestamp is always updated when the jar is updated
181 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
182 fmt.Fprintln(w, "jar_installed_module :=")
183 },
184 }
Colin Cross10a03492017-08-10 17:09:43 -0700185 }
186}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800187
188func (app *AndroidApp) AndroidMk() android.AndroidMkData {
189 return android.AndroidMkData{
190 Class: "APPS",
191 OutputFile: android.OptionalPathForPath(app.outputFile),
192 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
193 Extra: []android.AndroidMkExtraFunc{
194 func(w io.Writer, outputFile android.Path) {
Colin Cross70798562017-12-13 22:42:59 -0800195 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
196 if app.dexJarFile != nil {
197 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800198 }
Colin Cross331a1212018-08-15 20:40:52 -0700199 if app.implementationAndResourcesJar != nil {
200 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800201 }
202 if app.headerJarFile != nil {
203 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
204 }
Colin Crossf6237212018-10-29 23:14:58 -0700205 if app.bundleFile != nil {
206 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
207 }
Colin Cross70798562017-12-13 22:42:59 -0800208 if app.jacocoReportClassesFile != nil {
209 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
210 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800211 if app.proguardDictionary != nil {
212 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
213 }
Colin Cross70798562017-12-13 22:42:59 -0800214
215 if app.Name() == "framework-res" {
216 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
217 // Make base_rules.mk not put framework-res in a subdirectory called
218 // framework_res.
219 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
220 }
221
222 if len(app.rroDirs) > 0 {
Colin Crossa140bb02018-04-17 10:52:26 -0700223 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
224 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
225 fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800226 }
227
228 if Bool(app.appProperties.Export_package_resources) {
229 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
230 }
231
232 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
233
Colin Cross16056062017-12-13 22:46:28 -0800234 if Bool(app.appProperties.Privileged) {
235 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
236 }
Colin Crosse1731a52017-12-14 11:22:55 -0800237
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900238 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jason Monkd4122be2018-08-10 09:33:36 -0400239 if len(app.appProperties.Overrides) > 0 {
240 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES := "+strings.Join(app.appProperties.Overrides, " "))
241 }
Colin Crossa4f08812018-10-02 22:03:40 -0700242
243 for _, jniLib := range app.installJniLibs {
244 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
245 }
Colin Cross43f08db2018-11-12 10:13:39 -0800246 if len(app.dexpreopter.builtInstalled) > 0 {
247 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(app.dexpreopter.builtInstalled, " "))
248 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800249 },
250 },
251 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700252}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800253
Colin Crossae5caf52018-05-22 11:11:52 -0700254func (a *AndroidTest) AndroidMk() android.AndroidMkData {
255 data := a.AndroidApp.AndroidMk()
256 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
257 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
258 if len(a.testProperties.Test_suites) > 0 {
259 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
260 strings.Join(a.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700261 } else {
262 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Crossae5caf52018-05-22 11:11:52 -0700263 }
Colin Cross303e21f2018-08-07 16:49:25 -0700264 if a.testConfig != nil {
265 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700266 }
Colin Crossae5caf52018-05-22 11:11:52 -0700267 })
Colin Crossd96ca352018-08-10 16:06:24 -0700268 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700269
270 return data
271}
272
Colin Cross252fc6f2018-10-04 15:22:03 -0700273func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
274 data := a.AndroidApp.AndroidMk()
275 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
276 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
277 if len(a.appTestHelperAppProperties.Test_suites) > 0 {
278 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
279 strings.Join(a.appTestHelperAppProperties.Test_suites, " "))
280 } else {
281 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
282 }
283 })
284
285 return data
286}
287
Colin Crossa97c5d32018-03-28 14:58:31 -0700288func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
289 data := a.Library.AndroidMk()
290
291 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700292 if a.aarFile != nil {
293 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
294 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700295 if a.proguardDictionary != nil {
296 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
297 }
298
299 if a.Name() == "framework-res" {
300 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
301 // Make base_rules.mk not put framework-res in a subdirectory called
302 // framework_res.
303 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
304 }
305
306 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700307 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700308 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700309 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
310 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700311 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700312 })
313
314 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800315}
Nan Zhang581fd212018-01-10 16:06:12 -0800316
317func (jd *Javadoc) AndroidMk() android.AndroidMkData {
318 return android.AndroidMkData{
319 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800320 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700321 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800322 Extra: []android.AndroidMkExtraFunc{
323 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700324 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800325 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
326 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800327 if jd.stubsSrcJar != nil {
328 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800329 }
330 },
331 },
332 }
333}
334
335func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
336 return android.AndroidMkData{
337 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800338 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700339 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800340 Extra: []android.AndroidMkExtraFunc{
341 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700342 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800343 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
344 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800345 if ddoc.Javadoc.stubsSrcJar != nil {
346 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800347 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700348 if ddoc.checkCurrentApiTimestamp != nil {
349 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
350 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
351 ddoc.checkCurrentApiTimestamp.String())
352
353 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900354 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700355 ddoc.checkCurrentApiTimestamp.String())
356
357 fmt.Fprintln(w, ".PHONY: droidcore")
358 fmt.Fprintln(w, "droidcore: checkapi")
359 }
360 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700361 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700362 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
363 ddoc.updateCurrentApiTimestamp.String())
364
365 fmt.Fprintln(w, ".PHONY: update-api")
366 fmt.Fprintln(w, "update-api:",
367 ddoc.updateCurrentApiTimestamp.String())
368 }
369 if ddoc.checkLastReleasedApiTimestamp != nil {
370 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
371 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
372 ddoc.checkLastReleasedApiTimestamp.String())
373 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700374 apiFilePrefix := "INTERNAL_PLATFORM_"
375 if String(ddoc.properties.Api_tag_name) != "" {
376 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
377 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700378 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700379 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
380 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100381 if ddoc.dexApiFile != nil {
382 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
383 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700384 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700385 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
386 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700387 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700388 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
389 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700390 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700391 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
392 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700393 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100394 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
395 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700396 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700397 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
398 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700399 if ddoc.proguardFile != nil {
400 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
401 }
Nan Zhang581fd212018-01-10 16:06:12 -0800402 },
403 },
404 }
405}
Colin Crossd96ca352018-08-10 16:06:24 -0700406
Nan Zhang1598a9e2018-09-04 17:14:32 -0700407func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
408 return android.AndroidMkData{
409 Class: "JAVA_LIBRARIES",
410 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
411 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
412 Extra: []android.AndroidMkExtraFunc{
413 func(w io.Writer, outputFile android.Path) {
414 if dstubs.Javadoc.stubsSrcJar != nil {
415 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
416 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700417 if dstubs.apiVersionsXml != nil {
418 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
419 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700420 if dstubs.annotationsZip != nil {
421 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
422 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700423 if dstubs.jdiffDocZip != nil {
424 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
425 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700426 if dstubs.checkCurrentApiTimestamp != nil {
427 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
428 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
429 dstubs.checkCurrentApiTimestamp.String())
430
431 fmt.Fprintln(w, ".PHONY: checkapi")
432 fmt.Fprintln(w, "checkapi:",
433 dstubs.checkCurrentApiTimestamp.String())
434
435 fmt.Fprintln(w, ".PHONY: droidcore")
436 fmt.Fprintln(w, "droidcore: checkapi")
437 }
438 if dstubs.updateCurrentApiTimestamp != nil {
439 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
440 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
441 dstubs.updateCurrentApiTimestamp.String())
442
443 fmt.Fprintln(w, ".PHONY: update-api")
444 fmt.Fprintln(w, "update-api:",
445 dstubs.updateCurrentApiTimestamp.String())
446 }
447 if dstubs.checkLastReleasedApiTimestamp != nil {
448 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
449 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
450 dstubs.checkLastReleasedApiTimestamp.String())
451 }
Pete Gillin581d6082018-10-22 15:55:04 +0100452 if dstubs.checkNullabilityWarningsTimestamp != nil {
453 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
454 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
455 dstubs.checkNullabilityWarningsTimestamp.String())
456
457 fmt.Fprintln(w, ".PHONY:", "droidcore")
458 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
459 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700460 apiFilePrefix := "INTERNAL_PLATFORM_"
461 if String(dstubs.properties.Api_tag_name) != "" {
462 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
463 }
464 if dstubs.apiFile != nil {
465 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
466 }
467 if dstubs.dexApiFile != nil {
468 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
469 }
470 if dstubs.privateApiFile != nil {
471 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
472 }
473 if dstubs.privateDexApiFile != nil {
474 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
475 }
476 if dstubs.removedApiFile != nil {
477 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
478 }
479 if dstubs.removedDexApiFile != nil {
480 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
481 }
482 if dstubs.exactApiFile != nil {
483 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
484 }
485 },
486 },
487 }
488}
489
Colin Crossd96ca352018-08-10 16:06:24 -0700490func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
491 var testFiles []string
492 for _, d := range data {
493 testFiles = append(testFiles, d.String()+":"+d.Rel())
494 }
495 if len(testFiles) > 0 {
496 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
497 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
498 })
499 }
500}