blob: 313a144e9b848e82dfb9ce604b4e43dcb09f712e [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 Cross70798562017-12-13 22:42:59 -0800212 if app.jacocoReportClassesFile != nil {
213 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
214 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800215 if app.proguardDictionary != nil {
216 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
217 }
Colin Cross70798562017-12-13 22:42:59 -0800218
219 if app.Name() == "framework-res" {
220 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
221 // Make base_rules.mk not put framework-res in a subdirectory called
222 // framework_res.
223 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
224 }
225
226 if len(app.rroDirs) > 0 {
Colin Crossa140bb02018-04-17 10:52:26 -0700227 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
228 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
229 fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800230 }
231
232 if Bool(app.appProperties.Export_package_resources) {
233 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
234 }
235
236 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
237
Colin Cross16056062017-12-13 22:46:28 -0800238 if Bool(app.appProperties.Privileged) {
239 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
240 }
Colin Crosse1731a52017-12-14 11:22:55 -0800241
242 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.pem.String())
Jason Monkd4122be2018-08-10 09:33:36 -0400243 if len(app.appProperties.Overrides) > 0 {
244 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES := "+strings.Join(app.appProperties.Overrides, " "))
245 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800246 },
247 },
248 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700249}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800250
Colin Crossae5caf52018-05-22 11:11:52 -0700251func (a *AndroidTest) AndroidMk() android.AndroidMkData {
252 data := a.AndroidApp.AndroidMk()
253 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
254 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
255 if len(a.testProperties.Test_suites) > 0 {
256 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
257 strings.Join(a.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700258 } else {
259 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Crossae5caf52018-05-22 11:11:52 -0700260 }
Colin Cross303e21f2018-08-07 16:49:25 -0700261 if a.testConfig != nil {
262 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700263 }
Colin Crossae5caf52018-05-22 11:11:52 -0700264 })
Colin Crossd96ca352018-08-10 16:06:24 -0700265 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700266
267 return data
268}
269
Colin Crossa97c5d32018-03-28 14:58:31 -0700270func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
271 data := a.Library.AndroidMk()
272
273 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
274 if a.proguardDictionary != nil {
275 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
276 }
277
278 if a.Name() == "framework-res" {
279 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
280 // Make base_rules.mk not put framework-res in a subdirectory called
281 // framework_res.
282 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
283 }
284
285 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700286 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700287 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700288 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
289 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700290 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
291 fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false")
292 })
293
294 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800295}
Nan Zhang581fd212018-01-10 16:06:12 -0800296
297func (jd *Javadoc) AndroidMk() android.AndroidMkData {
298 return android.AndroidMkData{
299 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800300 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700301 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800302 Extra: []android.AndroidMkExtraFunc{
303 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700304 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800305 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
306 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800307 if jd.stubsSrcJar != nil {
308 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800309 }
310 },
311 },
312 }
313}
314
315func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
316 return android.AndroidMkData{
317 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800318 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700319 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800320 Extra: []android.AndroidMkExtraFunc{
321 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700322 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800323 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
324 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800325 if ddoc.Javadoc.stubsSrcJar != nil {
326 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800327 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700328 if ddoc.checkCurrentApiTimestamp != nil {
329 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
330 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
331 ddoc.checkCurrentApiTimestamp.String())
332
333 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900334 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700335 ddoc.checkCurrentApiTimestamp.String())
336
337 fmt.Fprintln(w, ".PHONY: droidcore")
338 fmt.Fprintln(w, "droidcore: checkapi")
339 }
340 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700341 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700342 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
343 ddoc.updateCurrentApiTimestamp.String())
344
345 fmt.Fprintln(w, ".PHONY: update-api")
346 fmt.Fprintln(w, "update-api:",
347 ddoc.updateCurrentApiTimestamp.String())
348 }
349 if ddoc.checkLastReleasedApiTimestamp != nil {
350 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
351 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
352 ddoc.checkLastReleasedApiTimestamp.String())
353 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700354 apiFilePrefix := "INTERNAL_PLATFORM_"
355 if String(ddoc.properties.Api_tag_name) != "" {
356 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
357 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700358 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700359 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
360 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100361 if ddoc.dexApiFile != nil {
362 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
363 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700364 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700365 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
366 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700367 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700368 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
369 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700370 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700371 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
372 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700373 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100374 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
375 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700376 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700377 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
378 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700379 if ddoc.proguardFile != nil {
380 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
381 }
Nan Zhang581fd212018-01-10 16:06:12 -0800382 },
383 },
384 }
385}
Colin Crossd96ca352018-08-10 16:06:24 -0700386
Nan Zhang1598a9e2018-09-04 17:14:32 -0700387func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
388 return android.AndroidMkData{
389 Class: "JAVA_LIBRARIES",
390 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
391 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
392 Extra: []android.AndroidMkExtraFunc{
393 func(w io.Writer, outputFile android.Path) {
394 if dstubs.Javadoc.stubsSrcJar != nil {
395 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
396 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700397 if dstubs.apiVersionsXml != nil {
398 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
399 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700400 if dstubs.annotationsZip != nil {
401 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
402 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700403 if dstubs.jdiffDocZip != nil {
404 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
405 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700406 if dstubs.checkCurrentApiTimestamp != nil {
407 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
408 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
409 dstubs.checkCurrentApiTimestamp.String())
410
411 fmt.Fprintln(w, ".PHONY: checkapi")
412 fmt.Fprintln(w, "checkapi:",
413 dstubs.checkCurrentApiTimestamp.String())
414
415 fmt.Fprintln(w, ".PHONY: droidcore")
416 fmt.Fprintln(w, "droidcore: checkapi")
417 }
418 if dstubs.updateCurrentApiTimestamp != nil {
419 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
420 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
421 dstubs.updateCurrentApiTimestamp.String())
422
423 fmt.Fprintln(w, ".PHONY: update-api")
424 fmt.Fprintln(w, "update-api:",
425 dstubs.updateCurrentApiTimestamp.String())
426 }
427 if dstubs.checkLastReleasedApiTimestamp != nil {
428 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
429 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
430 dstubs.checkLastReleasedApiTimestamp.String())
431 }
432 apiFilePrefix := "INTERNAL_PLATFORM_"
433 if String(dstubs.properties.Api_tag_name) != "" {
434 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
435 }
436 if dstubs.apiFile != nil {
437 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
438 }
439 if dstubs.dexApiFile != nil {
440 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
441 }
442 if dstubs.privateApiFile != nil {
443 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
444 }
445 if dstubs.privateDexApiFile != nil {
446 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
447 }
448 if dstubs.removedApiFile != nil {
449 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
450 }
451 if dstubs.removedDexApiFile != nil {
452 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
453 }
454 if dstubs.exactApiFile != nil {
455 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
456 }
457 },
458 },
459 }
460}
461
Colin Crossd96ca352018-08-10 16:06:24 -0700462func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
463 var testFiles []string
464 for _, d := range data {
465 testFiles = append(testFiles, d.String()+":"+d.Rel())
466 }
467 if len(testFiles) > 0 {
468 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
469 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
470 })
471 }
472}