blob: 23e26addc90bec4f977d2b55bb655bb375deda5c [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 Cross331a1212018-08-15 20:40:52 -070028 OutputFile: android.OptionalPathForPath(library.implementationAndResourcesJar),
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 Cross1bd87802017-12-05 15:31:19 -080045 if library.deviceProperties.Dex_preopt.Enabled != nil {
46 fmt.Fprintln(w, "LOCAL_DEX_PREOPT :=", *library.deviceProperties.Dex_preopt.Enabled)
47 }
48 if library.deviceProperties.Dex_preopt.App_image != nil {
49 fmt.Fprintln(w, "LOCAL_DEX_PREOPT_APP_IMAGE :=", *library.deviceProperties.Dex_preopt.App_image)
50 }
51 if library.deviceProperties.Dex_preopt.Profile_guided != nil {
52 fmt.Fprintln(w, "LOCAL_DEX_PREOPT_GENERATE_PROFILE :=", *library.deviceProperties.Dex_preopt.Profile_guided)
53 }
54 if library.deviceProperties.Dex_preopt.Profile != nil {
55 fmt.Fprintln(w, "LOCAL_DEX_PREOPT_GENERATE_PROFILE := true")
56 fmt.Fprintln(w, "LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING := $(LOCAL_PATH)/"+*library.deviceProperties.Dex_preopt.Profile)
Colin Crossa22116e2017-10-19 14:18:58 -070057 }
Colin Cross6ade34f2017-09-15 13:00:47 -070058 }
Colin Cross83bb3162018-06-25 15:48:06 -070059 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion())
Nan Zhanged19fc32017-10-19 13:06:22 -070060 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Crosscb933592017-11-22 13:49:43 -080061
62 if library.jacocoReportClassesFile != nil {
63 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String())
64 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080065
Jiyong Park1be96912018-05-28 18:02:19 +090066 if len(library.exportedSdkLibs) != 0 {
67 fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " "))
68 }
69
Colin Cross5ab4e6d2017-11-22 16:20:45 -080070 // Temporary hack: export sources used to compile framework.jar to Make
71 // to be used for droiddoc
72 // TODO(ccross): remove this once droiddoc is in soong
Mathew Inwoodebe29ce2018-09-04 14:26:19 +010073 if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") {
Colin Cross5ab4e6d2017-11-22 16:20:45 -080074 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " "))
75 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " "))
76 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070077 },
78 },
Colin Cross92430102017-10-09 14:59:32 -070079 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
80 android.WriteAndroidMkData(w, data)
81
Colin Crossff3ae9d2018-04-10 16:15:18 -070082 if Bool(library.deviceProperties.Hostdex) && !library.Host() {
Colin Cross92430102017-10-09 14:59:32 -070083 fmt.Fprintln(w, "include $(CLEAR_VARS)")
84 fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
85 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
86 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
Colin Cross331a1212018-08-15 20:40:52 -070087 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.implementationAndResourcesJar.String())
Colin Cross9ae1b922018-06-26 17:59:05 -070088 if library.installFile == nil {
Colin Cross92430102017-10-09 14:59:32 -070089 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
90 }
91 if library.dexJarFile != nil {
92 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
93 }
Colin Cross331a1212018-08-15 20:40:52 -070094 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Cross92430102017-10-09 14:59:32 -070095 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
96 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
97 }
98 },
Colin Crossa18e9cf2017-08-10 17:00:19 -070099 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700100}
101
Colin Cross05638fc2018-04-09 18:40:24 -0700102func (j *Test) AndroidMk() android.AndroidMkData {
103 data := j.Library.AndroidMk()
104 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
105 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
106 if len(j.testProperties.Test_suites) > 0 {
107 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
108 strings.Join(j.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700109 } else {
110 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Cross05638fc2018-04-09 18:40:24 -0700111 }
Colin Cross303e21f2018-08-07 16:49:25 -0700112 if j.testConfig != nil {
113 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700114 }
Colin Cross05638fc2018-04-09 18:40:24 -0700115 })
116
Colin Crossd96ca352018-08-10 16:06:24 -0700117 androidMkWriteTestData(j.data, &data)
118
Colin Cross05638fc2018-04-09 18:40:24 -0700119 return data
120}
121
Colin Crossa18e9cf2017-08-10 17:00:19 -0700122func (prebuilt *Import) AndroidMk() android.AndroidMkData {
123 return android.AndroidMkData{
124 Class: "JAVA_LIBRARIES",
125 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700126 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700127 Extra: []android.AndroidMkExtraFunc{
128 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700129 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700130 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700131 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700132 },
133 },
134 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700135}
Colin Cross10a03492017-08-10 17:09:43 -0700136
Colin Crossfabb6082018-02-20 17:22:23 -0800137func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
138 return android.AndroidMkData{
139 Class: "JAVA_LIBRARIES",
140 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
141 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
142 Extra: []android.AndroidMkExtraFunc{
143 func(w io.Writer, outputFile android.Path) {
144 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
145 fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
146 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
147 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
148 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
Colin Cross66f78822018-05-02 12:58:28 -0700149 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
Colin Cross10f7c4a2018-05-23 10:59:28 -0700150 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700151 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800152 },
153 },
154 }
155}
156
Colin Cross10a03492017-08-10 17:09:43 -0700157func (binary *Binary) AndroidMk() android.AndroidMkData {
Colin Cross10a03492017-08-10 17:09:43 -0700158
Colin Cross6b4a32d2017-12-05 13:42:45 -0800159 if !binary.isWrapperVariant {
160 return android.AndroidMkData{
161 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700162 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800163 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Cross331a1212018-08-15 20:40:52 -0700164 Extra: []android.AndroidMkExtraFunc{
165 func(w io.Writer, outputFile android.Path) {
166 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
167 },
168 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800169 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
170 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700171
Colin Cross6b4a32d2017-12-05 13:42:45 -0800172 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
173 },
174 }
175 } else {
176 return android.AndroidMkData{
177 Class: "EXECUTABLES",
178 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
179 Extra: []android.AndroidMkExtraFunc{
180 func(w io.Writer, outputFile android.Path) {
181 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
182 },
183 },
184 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
185 android.WriteAndroidMkData(w, data)
186
187 // Ensure that the wrapper script timestamp is always updated when the jar is updated
188 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
189 fmt.Fprintln(w, "jar_installed_module :=")
190 },
191 }
Colin Cross10a03492017-08-10 17:09:43 -0700192 }
193}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800194
195func (app *AndroidApp) AndroidMk() android.AndroidMkData {
196 return android.AndroidMkData{
197 Class: "APPS",
198 OutputFile: android.OptionalPathForPath(app.outputFile),
199 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
200 Extra: []android.AndroidMkExtraFunc{
201 func(w io.Writer, outputFile android.Path) {
Colin Cross70798562017-12-13 22:42:59 -0800202 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
203 if app.dexJarFile != nil {
204 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800205 }
Colin Cross331a1212018-08-15 20:40:52 -0700206 if app.implementationAndResourcesJar != nil {
207 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800208 }
209 if app.headerJarFile != nil {
210 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
211 }
Colin Crossf6237212018-10-29 23:14:58 -0700212 if app.bundleFile != nil {
213 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
214 }
Colin Cross70798562017-12-13 22:42:59 -0800215 if app.jacocoReportClassesFile != nil {
216 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
217 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800218 if app.proguardDictionary != nil {
219 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
220 }
Colin Cross70798562017-12-13 22:42:59 -0800221
222 if app.Name() == "framework-res" {
223 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
224 // Make base_rules.mk not put framework-res in a subdirectory called
225 // framework_res.
226 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
227 }
228
229 if len(app.rroDirs) > 0 {
Colin Crossa140bb02018-04-17 10:52:26 -0700230 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
231 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
232 fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800233 }
234
235 if Bool(app.appProperties.Export_package_resources) {
236 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
237 }
238
239 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
240
Colin Cross16056062017-12-13 22:46:28 -0800241 if Bool(app.appProperties.Privileged) {
242 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
243 }
Colin Crosse1731a52017-12-14 11:22:55 -0800244
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900245 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jason Monkd4122be2018-08-10 09:33:36 -0400246 if len(app.appProperties.Overrides) > 0 {
247 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES := "+strings.Join(app.appProperties.Overrides, " "))
248 }
Colin Crossa4f08812018-10-02 22:03:40 -0700249
250 for _, jniLib := range app.installJniLibs {
251 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
252 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800253 },
254 },
255 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700256}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800257
Colin Crossae5caf52018-05-22 11:11:52 -0700258func (a *AndroidTest) AndroidMk() android.AndroidMkData {
259 data := a.AndroidApp.AndroidMk()
260 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
261 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
262 if len(a.testProperties.Test_suites) > 0 {
263 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
264 strings.Join(a.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700265 } else {
266 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Crossae5caf52018-05-22 11:11:52 -0700267 }
Colin Cross303e21f2018-08-07 16:49:25 -0700268 if a.testConfig != nil {
269 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700270 }
Colin Crossae5caf52018-05-22 11:11:52 -0700271 })
Colin Crossd96ca352018-08-10 16:06:24 -0700272 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700273
274 return data
275}
276
Colin Cross252fc6f2018-10-04 15:22:03 -0700277func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
278 data := a.AndroidApp.AndroidMk()
279 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
280 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
281 if len(a.appTestHelperAppProperties.Test_suites) > 0 {
282 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
283 strings.Join(a.appTestHelperAppProperties.Test_suites, " "))
284 } else {
285 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
286 }
287 })
288
289 return data
290}
291
Colin Crossa97c5d32018-03-28 14:58:31 -0700292func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
293 data := a.Library.AndroidMk()
294
295 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
296 if a.proguardDictionary != nil {
297 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
298 }
299
300 if a.Name() == "framework-res" {
301 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
302 // Make base_rules.mk not put framework-res in a subdirectory called
303 // framework_res.
304 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
305 }
306
307 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700308 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700309 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700310 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
311 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700312 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
313 fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
314 })
315
316 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800317}
Nan Zhang581fd212018-01-10 16:06:12 -0800318
319func (jd *Javadoc) AndroidMk() android.AndroidMkData {
320 return android.AndroidMkData{
321 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800322 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700323 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800324 Extra: []android.AndroidMkExtraFunc{
325 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700326 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800327 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
328 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800329 if jd.stubsSrcJar != nil {
330 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800331 }
332 },
333 },
334 }
335}
336
337func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
338 return android.AndroidMkData{
339 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800340 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700341 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800342 Extra: []android.AndroidMkExtraFunc{
343 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700344 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800345 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
346 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800347 if ddoc.Javadoc.stubsSrcJar != nil {
348 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800349 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700350 if ddoc.checkCurrentApiTimestamp != nil {
351 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
352 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
353 ddoc.checkCurrentApiTimestamp.String())
354
355 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900356 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700357 ddoc.checkCurrentApiTimestamp.String())
358
359 fmt.Fprintln(w, ".PHONY: droidcore")
360 fmt.Fprintln(w, "droidcore: checkapi")
361 }
362 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700363 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700364 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
365 ddoc.updateCurrentApiTimestamp.String())
366
367 fmt.Fprintln(w, ".PHONY: update-api")
368 fmt.Fprintln(w, "update-api:",
369 ddoc.updateCurrentApiTimestamp.String())
370 }
371 if ddoc.checkLastReleasedApiTimestamp != nil {
372 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
373 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
374 ddoc.checkLastReleasedApiTimestamp.String())
375 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700376 apiFilePrefix := "INTERNAL_PLATFORM_"
377 if String(ddoc.properties.Api_tag_name) != "" {
378 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
379 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700380 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700381 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
382 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100383 if ddoc.dexApiFile != nil {
384 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
385 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700386 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700387 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
388 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700389 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700390 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
391 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700392 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700393 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
394 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700395 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100396 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
397 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700398 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700399 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
400 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700401 if ddoc.proguardFile != nil {
402 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
403 }
Nan Zhang581fd212018-01-10 16:06:12 -0800404 },
405 },
406 }
407}
Colin Crossd96ca352018-08-10 16:06:24 -0700408
Nan Zhang1598a9e2018-09-04 17:14:32 -0700409func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
410 return android.AndroidMkData{
411 Class: "JAVA_LIBRARIES",
412 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
413 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
414 Extra: []android.AndroidMkExtraFunc{
415 func(w io.Writer, outputFile android.Path) {
416 if dstubs.Javadoc.stubsSrcJar != nil {
417 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
418 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700419 if dstubs.apiVersionsXml != nil {
420 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
421 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700422 if dstubs.annotationsZip != nil {
423 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
424 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700425 if dstubs.jdiffDocZip != nil {
426 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
427 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700428 if dstubs.checkCurrentApiTimestamp != nil {
429 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
430 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
431 dstubs.checkCurrentApiTimestamp.String())
432
433 fmt.Fprintln(w, ".PHONY: checkapi")
434 fmt.Fprintln(w, "checkapi:",
435 dstubs.checkCurrentApiTimestamp.String())
436
437 fmt.Fprintln(w, ".PHONY: droidcore")
438 fmt.Fprintln(w, "droidcore: checkapi")
439 }
440 if dstubs.updateCurrentApiTimestamp != nil {
441 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
442 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
443 dstubs.updateCurrentApiTimestamp.String())
444
445 fmt.Fprintln(w, ".PHONY: update-api")
446 fmt.Fprintln(w, "update-api:",
447 dstubs.updateCurrentApiTimestamp.String())
448 }
449 if dstubs.checkLastReleasedApiTimestamp != nil {
450 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
451 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
452 dstubs.checkLastReleasedApiTimestamp.String())
453 }
454 apiFilePrefix := "INTERNAL_PLATFORM_"
455 if String(dstubs.properties.Api_tag_name) != "" {
456 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
457 }
458 if dstubs.apiFile != nil {
459 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
460 }
461 if dstubs.dexApiFile != nil {
462 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
463 }
464 if dstubs.privateApiFile != nil {
465 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
466 }
467 if dstubs.privateDexApiFile != nil {
468 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
469 }
470 if dstubs.removedApiFile != nil {
471 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
472 }
473 if dstubs.removedDexApiFile != nil {
474 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
475 }
476 if dstubs.exactApiFile != nil {
477 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
478 }
479 },
480 },
481 }
482}
483
Colin Crossd96ca352018-08-10 16:06:24 -0700484func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
485 var testFiles []string
486 for _, d := range data {
487 testFiles = append(testFiles, d.String()+":"+d.Rel())
488 }
489 if len(testFiles) > 0 {
490 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
491 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
492 })
493 }
494}