blob: 4d3af12f55536ece62232751bc139cbe474fe02d [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 Cross12fc2af2019-01-14 12:35:45 -0800160 if binary.dexJarFile != nil {
161 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
162 }
163 if len(binary.dexpreopter.builtInstalled) > 0 {
164 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(binary.dexpreopter.builtInstalled, " "))
165 }
Colin Cross331a1212018-08-15 20:40:52 -0700166 },
167 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800168 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
169 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700170
Colin Cross6b4a32d2017-12-05 13:42:45 -0800171 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
172 },
173 }
174 } else {
175 return android.AndroidMkData{
176 Class: "EXECUTABLES",
177 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
178 Extra: []android.AndroidMkExtraFunc{
179 func(w io.Writer, outputFile android.Path) {
180 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
181 },
182 },
183 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
184 android.WriteAndroidMkData(w, data)
185
186 // Ensure that the wrapper script timestamp is always updated when the jar is updated
187 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
188 fmt.Fprintln(w, "jar_installed_module :=")
189 },
190 }
Colin Cross10a03492017-08-10 17:09:43 -0700191 }
192}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800193
194func (app *AndroidApp) AndroidMk() android.AndroidMkData {
195 return android.AndroidMkData{
196 Class: "APPS",
197 OutputFile: android.OptionalPathForPath(app.outputFile),
198 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
199 Extra: []android.AndroidMkExtraFunc{
200 func(w io.Writer, outputFile android.Path) {
Colin Cross70798562017-12-13 22:42:59 -0800201 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
202 if app.dexJarFile != nil {
203 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800204 }
Colin Cross331a1212018-08-15 20:40:52 -0700205 if app.implementationAndResourcesJar != nil {
206 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800207 }
208 if app.headerJarFile != nil {
209 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
210 }
Colin Crossf6237212018-10-29 23:14:58 -0700211 if app.bundleFile != nil {
212 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
213 }
Colin Cross70798562017-12-13 22:42:59 -0800214 if app.jacocoReportClassesFile != nil {
215 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
216 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800217 if app.proguardDictionary != nil {
218 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
219 }
Colin Cross70798562017-12-13 22:42:59 -0800220
221 if app.Name() == "framework-res" {
222 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
223 // Make base_rules.mk not put framework-res in a subdirectory called
224 // framework_res.
225 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
226 }
227
228 if len(app.rroDirs) > 0 {
Colin Crossa140bb02018-04-17 10:52:26 -0700229 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
230 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
231 fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800232 }
233
234 if Bool(app.appProperties.Export_package_resources) {
235 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
236 }
237
238 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
239
Colin Cross16056062017-12-13 22:46:28 -0800240 if Bool(app.appProperties.Privileged) {
241 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
242 }
Colin Crosse1731a52017-12-14 11:22:55 -0800243
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900244 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jason Monkd4122be2018-08-10 09:33:36 -0400245 if len(app.appProperties.Overrides) > 0 {
246 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES := "+strings.Join(app.appProperties.Overrides, " "))
247 }
Colin Crossa4f08812018-10-02 22:03:40 -0700248
249 for _, jniLib := range app.installJniLibs {
250 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
251 }
Colin Cross43f08db2018-11-12 10:13:39 -0800252 if len(app.dexpreopter.builtInstalled) > 0 {
253 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(app.dexpreopter.builtInstalled, " "))
254 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800255 },
256 },
257 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700258}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800259
Colin Crossae5caf52018-05-22 11:11:52 -0700260func (a *AndroidTest) AndroidMk() android.AndroidMkData {
261 data := a.AndroidApp.AndroidMk()
262 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
263 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
264 if len(a.testProperties.Test_suites) > 0 {
265 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
266 strings.Join(a.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700267 } else {
268 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Crossae5caf52018-05-22 11:11:52 -0700269 }
Colin Cross303e21f2018-08-07 16:49:25 -0700270 if a.testConfig != nil {
271 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700272 }
Colin Crossae5caf52018-05-22 11:11:52 -0700273 })
Colin Crossd96ca352018-08-10 16:06:24 -0700274 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700275
276 return data
277}
278
Colin Cross252fc6f2018-10-04 15:22:03 -0700279func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
280 data := a.AndroidApp.AndroidMk()
281 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
282 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
283 if len(a.appTestHelperAppProperties.Test_suites) > 0 {
284 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
285 strings.Join(a.appTestHelperAppProperties.Test_suites, " "))
286 } else {
287 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
288 }
289 })
290
291 return data
292}
293
Colin Crossa97c5d32018-03-28 14:58:31 -0700294func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
295 data := a.Library.AndroidMk()
296
297 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700298 if a.aarFile != nil {
299 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
300 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700301 if a.proguardDictionary != nil {
302 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
303 }
304
305 if a.Name() == "framework-res" {
306 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
307 // Make base_rules.mk not put framework-res in a subdirectory called
308 // framework_res.
309 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
310 }
311
312 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700313 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700314 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700315 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
316 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700317 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700318 })
319
320 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800321}
Nan Zhang581fd212018-01-10 16:06:12 -0800322
323func (jd *Javadoc) AndroidMk() android.AndroidMkData {
324 return android.AndroidMkData{
325 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800326 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700327 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800328 Extra: []android.AndroidMkExtraFunc{
329 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700330 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800331 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
332 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800333 if jd.stubsSrcJar != nil {
334 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800335 }
336 },
337 },
338 }
339}
340
341func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
342 return android.AndroidMkData{
343 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800344 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700345 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800346 Extra: []android.AndroidMkExtraFunc{
347 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700348 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800349 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
350 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800351 if ddoc.Javadoc.stubsSrcJar != nil {
352 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800353 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700354 if ddoc.checkCurrentApiTimestamp != nil {
355 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
356 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
357 ddoc.checkCurrentApiTimestamp.String())
358
359 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900360 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700361 ddoc.checkCurrentApiTimestamp.String())
362
363 fmt.Fprintln(w, ".PHONY: droidcore")
364 fmt.Fprintln(w, "droidcore: checkapi")
365 }
366 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700367 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700368 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
369 ddoc.updateCurrentApiTimestamp.String())
370
371 fmt.Fprintln(w, ".PHONY: update-api")
372 fmt.Fprintln(w, "update-api:",
373 ddoc.updateCurrentApiTimestamp.String())
374 }
375 if ddoc.checkLastReleasedApiTimestamp != nil {
376 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
377 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
378 ddoc.checkLastReleasedApiTimestamp.String())
379 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700380 apiFilePrefix := "INTERNAL_PLATFORM_"
381 if String(ddoc.properties.Api_tag_name) != "" {
382 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
383 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700384 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700385 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
386 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100387 if ddoc.dexApiFile != nil {
388 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
389 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700390 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700391 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
392 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700393 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700394 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
395 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700396 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700397 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
398 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700399 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100400 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
401 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700402 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700403 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
404 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700405 if ddoc.proguardFile != nil {
406 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
407 }
Nan Zhang581fd212018-01-10 16:06:12 -0800408 },
409 },
410 }
411}
Colin Crossd96ca352018-08-10 16:06:24 -0700412
Nan Zhang1598a9e2018-09-04 17:14:32 -0700413func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
414 return android.AndroidMkData{
415 Class: "JAVA_LIBRARIES",
416 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
417 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
418 Extra: []android.AndroidMkExtraFunc{
419 func(w io.Writer, outputFile android.Path) {
420 if dstubs.Javadoc.stubsSrcJar != nil {
421 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
422 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700423 if dstubs.apiVersionsXml != nil {
424 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
425 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700426 if dstubs.annotationsZip != nil {
427 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
428 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700429 if dstubs.jdiffDocZip != nil {
430 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
431 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700432 if dstubs.checkCurrentApiTimestamp != nil {
433 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
434 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
435 dstubs.checkCurrentApiTimestamp.String())
436
437 fmt.Fprintln(w, ".PHONY: checkapi")
438 fmt.Fprintln(w, "checkapi:",
439 dstubs.checkCurrentApiTimestamp.String())
440
441 fmt.Fprintln(w, ".PHONY: droidcore")
442 fmt.Fprintln(w, "droidcore: checkapi")
443 }
444 if dstubs.updateCurrentApiTimestamp != nil {
445 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
446 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
447 dstubs.updateCurrentApiTimestamp.String())
448
449 fmt.Fprintln(w, ".PHONY: update-api")
450 fmt.Fprintln(w, "update-api:",
451 dstubs.updateCurrentApiTimestamp.String())
452 }
453 if dstubs.checkLastReleasedApiTimestamp != nil {
454 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
455 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
456 dstubs.checkLastReleasedApiTimestamp.String())
457 }
Pete Gillin581d6082018-10-22 15:55:04 +0100458 if dstubs.checkNullabilityWarningsTimestamp != nil {
459 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
460 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
461 dstubs.checkNullabilityWarningsTimestamp.String())
462
463 fmt.Fprintln(w, ".PHONY:", "droidcore")
464 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
465 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700466 apiFilePrefix := "INTERNAL_PLATFORM_"
467 if String(dstubs.properties.Api_tag_name) != "" {
468 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
469 }
470 if dstubs.apiFile != nil {
471 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
472 }
473 if dstubs.dexApiFile != nil {
474 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
475 }
476 if dstubs.privateApiFile != nil {
477 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
478 }
479 if dstubs.privateDexApiFile != nil {
480 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
481 }
482 if dstubs.removedApiFile != nil {
483 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
484 }
485 if dstubs.removedDexApiFile != nil {
486 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
487 }
488 if dstubs.exactApiFile != nil {
489 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
490 }
491 },
492 },
493 }
494}
495
Colin Crossd96ca352018-08-10 16:06:24 -0700496func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
497 var testFiles []string
498 for _, d := range data {
499 testFiles = append(testFiles, d.String()+":"+d.Rel())
500 }
501 if len(testFiles) > 0 {
502 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
503 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
504 })
505 }
506}