blob: b9e429894c332a3d98786e1d4e212c39feabb69a [file] [log] [blame]
Dan Willemsen218f6562015-07-08 18:13:11 -07001// Copyright 2015 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package java
16
17import (
Colin Cross74d73e22017-08-02 11:05:49 -070018 "fmt"
19 "io"
Colin Cross10a03492017-08-10 17:09:43 -070020 "strings"
Colin Cross74d73e22017-08-02 11:05:49 -070021
Colin Cross635c3b02016-05-18 15:37:25 -070022 "android/soong/android"
Dan Willemsen218f6562015-07-08 18:13:11 -070023)
24
Sundong Ahn054b19a2018-10-19 13:46:09 +090025func (library *Library) AndroidMkHostDex(w io.Writer, name string, data android.AndroidMkData) {
26 if Bool(library.deviceProperties.Hostdex) && !library.Host() {
27 fmt.Fprintln(w, "include $(CLEAR_VARS)")
28 fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
29 fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
30 fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
Colin Cross56abb832019-01-14 14:13:51 -080031 if library.dexJarFile != nil {
32 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.dexJarFile.String())
33 } else {
34 fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.implementationAndResourcesJar.String())
35 }
Sundong Ahn054b19a2018-10-19 13:46:09 +090036 if library.installFile == nil {
37 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
38 }
39 if library.dexJarFile != nil {
40 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
41 }
42 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
43 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
44 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
45 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
46 }
47}
48
Colin Crossa18e9cf2017-08-10 17:00:19 -070049func (library *Library) AndroidMk() android.AndroidMkData {
50 return android.AndroidMkData{
51 Class: "JAVA_LIBRARIES",
Colin Cross43f08db2018-11-12 10:13:39 -080052 OutputFile: android.OptionalPathForPath(library.outputFile),
Colin Cross53499412017-09-07 13:20:25 -070053 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -070054 Extra: []android.AndroidMkExtraFunc{
55 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080056 if len(library.logtagsSrcs) > 0 {
57 var logtags []string
58 for _, l := range library.logtagsSrcs {
59 logtags = append(logtags, l.Rel())
60 }
61 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
62 }
63
Colin Cross9ae1b922018-06-26 17:59:05 -070064 if library.installFile == nil {
Colin Cross2c429dc2017-08-31 16:45:16 -070065 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
66 }
Colin Cross6ade34f2017-09-15 13:00:47 -070067 if library.dexJarFile != nil {
68 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -080069 }
70 if len(library.dexpreopter.builtInstalled) > 0 {
71 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(library.dexpreopter.builtInstalled, " "))
Colin Cross6ade34f2017-09-15 13:00:47 -070072 }
Colin Cross83bb3162018-06-25 15:48:06 -070073 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion())
Colin Cross43f08db2018-11-12 10:13:39 -080074 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
Nan Zhanged19fc32017-10-19 13:06:22 -070075 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Crosscb933592017-11-22 13:49:43 -080076
77 if library.jacocoReportClassesFile != nil {
78 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String())
79 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080080
Jiyong Park1be96912018-05-28 18:02:19 +090081 if len(library.exportedSdkLibs) != 0 {
82 fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " "))
83 }
84
Colin Cross5ab4e6d2017-11-22 16:20:45 -080085 // Temporary hack: export sources used to compile framework.jar to Make
86 // to be used for droiddoc
87 // TODO(ccross): remove this once droiddoc is in soong
Mathew Inwoodebe29ce2018-09-04 14:26:19 +010088 if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") {
Colin Cross5ab4e6d2017-11-22 16:20:45 -080089 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " "))
90 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " "))
91 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070092 },
93 },
Colin Cross92430102017-10-09 14:59:32 -070094 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
95 android.WriteAndroidMkData(w, data)
Sundong Ahn054b19a2018-10-19 13:46:09 +090096 library.AndroidMkHostDex(w, name, data)
Colin Cross92430102017-10-09 14:59:32 -070097 },
Colin Crossa18e9cf2017-08-10 17:00:19 -070098 }
Dan Willemsen218f6562015-07-08 18:13:11 -070099}
100
Colin Cross05638fc2018-04-09 18:40:24 -0700101func (j *Test) AndroidMk() android.AndroidMkData {
102 data := j.Library.AndroidMk()
103 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
104 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
105 if len(j.testProperties.Test_suites) > 0 {
106 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
107 strings.Join(j.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700108 } else {
109 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Cross05638fc2018-04-09 18:40:24 -0700110 }
Colin Cross303e21f2018-08-07 16:49:25 -0700111 if j.testConfig != nil {
112 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700113 }
Colin Cross05638fc2018-04-09 18:40:24 -0700114 })
115
Colin Crossd96ca352018-08-10 16:06:24 -0700116 androidMkWriteTestData(j.data, &data)
117
Colin Cross05638fc2018-04-09 18:40:24 -0700118 return data
119}
120
Colin Crossa18e9cf2017-08-10 17:00:19 -0700121func (prebuilt *Import) AndroidMk() android.AndroidMkData {
122 return android.AndroidMkData{
123 Class: "JAVA_LIBRARIES",
124 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700125 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700126 Extra: []android.AndroidMkExtraFunc{
127 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700128 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700129 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800130 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_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")
Colin Crossfabb6082018-02-20 17:22:23 -0800145 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800146 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800147 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())
Colin Cross43f08db2018-11-12 10:13:39 -0800167 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
Colin Cross12fc2af2019-01-14 12:35:45 -0800168 if binary.dexJarFile != nil {
169 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
170 }
171 if len(binary.dexpreopter.builtInstalled) > 0 {
172 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(binary.dexpreopter.builtInstalled, " "))
173 }
Colin Cross331a1212018-08-15 20:40:52 -0700174 },
175 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800176 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
177 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700178
Colin Cross6b4a32d2017-12-05 13:42:45 -0800179 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
180 },
181 }
182 } else {
183 return android.AndroidMkData{
184 Class: "EXECUTABLES",
185 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
186 Extra: []android.AndroidMkExtraFunc{
187 func(w io.Writer, outputFile android.Path) {
188 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
189 },
190 },
191 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
192 android.WriteAndroidMkData(w, data)
193
194 // Ensure that the wrapper script timestamp is always updated when the jar is updated
195 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
196 fmt.Fprintln(w, "jar_installed_module :=")
197 },
198 }
Colin Cross10a03492017-08-10 17:09:43 -0700199 }
200}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800201
202func (app *AndroidApp) AndroidMk() android.AndroidMkData {
203 return android.AndroidMkData{
204 Class: "APPS",
205 OutputFile: android.OptionalPathForPath(app.outputFile),
206 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
207 Extra: []android.AndroidMkExtraFunc{
208 func(w io.Writer, outputFile android.Path) {
Colin Cross70798562017-12-13 22:42:59 -0800209 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
210 if app.dexJarFile != nil {
211 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800212 }
Colin Cross331a1212018-08-15 20:40:52 -0700213 if app.implementationAndResourcesJar != nil {
214 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800215 }
216 if app.headerJarFile != nil {
217 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
218 }
Colin Crossf6237212018-10-29 23:14:58 -0700219 if app.bundleFile != nil {
220 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
221 }
Colin Cross70798562017-12-13 22:42:59 -0800222 if app.jacocoReportClassesFile != nil {
223 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
224 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800225 if app.proguardDictionary != nil {
226 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
227 }
Colin Cross70798562017-12-13 22:42:59 -0800228
229 if app.Name() == "framework-res" {
230 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
231 // Make base_rules.mk not put framework-res in a subdirectory called
232 // framework_res.
233 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
234 }
235
236 if len(app.rroDirs) > 0 {
Colin Crossa140bb02018-04-17 10:52:26 -0700237 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
238 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
239 fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800240 }
241
242 if Bool(app.appProperties.Export_package_resources) {
243 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
244 }
245
246 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
247
Colin Cross16056062017-12-13 22:46:28 -0800248 if Bool(app.appProperties.Privileged) {
249 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
250 }
Colin Crosse1731a52017-12-14 11:22:55 -0800251
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900252 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jason Monkd4122be2018-08-10 09:33:36 -0400253 if len(app.appProperties.Overrides) > 0 {
254 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES := "+strings.Join(app.appProperties.Overrides, " "))
255 }
Colin Crossa4f08812018-10-02 22:03:40 -0700256
257 for _, jniLib := range app.installJniLibs {
258 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
259 }
Colin Cross43f08db2018-11-12 10:13:39 -0800260 if len(app.dexpreopter.builtInstalled) > 0 {
261 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(app.dexpreopter.builtInstalled, " "))
262 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800263 },
264 },
265 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700266}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800267
Colin Crossae5caf52018-05-22 11:11:52 -0700268func (a *AndroidTest) AndroidMk() android.AndroidMkData {
269 data := a.AndroidApp.AndroidMk()
270 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
271 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
272 if len(a.testProperties.Test_suites) > 0 {
273 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
274 strings.Join(a.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700275 } else {
276 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Crossae5caf52018-05-22 11:11:52 -0700277 }
Colin Cross303e21f2018-08-07 16:49:25 -0700278 if a.testConfig != nil {
279 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700280 }
Colin Crossae5caf52018-05-22 11:11:52 -0700281 })
Colin Crossd96ca352018-08-10 16:06:24 -0700282 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700283
284 return data
285}
286
Colin Cross252fc6f2018-10-04 15:22:03 -0700287func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
288 data := a.AndroidApp.AndroidMk()
289 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
290 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
291 if len(a.appTestHelperAppProperties.Test_suites) > 0 {
292 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
293 strings.Join(a.appTestHelperAppProperties.Test_suites, " "))
294 } else {
295 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
296 }
297 })
298
299 return data
300}
301
Colin Crossa97c5d32018-03-28 14:58:31 -0700302func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
303 data := a.Library.AndroidMk()
304
305 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700306 if a.aarFile != nil {
307 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
308 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700309 if a.proguardDictionary != nil {
310 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
311 }
312
313 if a.Name() == "framework-res" {
314 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
315 // Make base_rules.mk not put framework-res in a subdirectory called
316 // framework_res.
317 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
318 }
319
320 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700321 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700322 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700323 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
324 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700325 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700326 })
327
328 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800329}
Nan Zhang581fd212018-01-10 16:06:12 -0800330
331func (jd *Javadoc) AndroidMk() android.AndroidMkData {
332 return android.AndroidMkData{
333 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800334 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700335 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800336 Extra: []android.AndroidMkExtraFunc{
337 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700338 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800339 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
340 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800341 if jd.stubsSrcJar != nil {
342 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800343 }
344 },
345 },
346 }
347}
348
349func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
350 return android.AndroidMkData{
351 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800352 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700353 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800354 Extra: []android.AndroidMkExtraFunc{
355 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700356 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800357 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
358 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800359 if ddoc.Javadoc.stubsSrcJar != nil {
360 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800361 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700362 if ddoc.checkCurrentApiTimestamp != nil {
363 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
364 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
365 ddoc.checkCurrentApiTimestamp.String())
366
367 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900368 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700369 ddoc.checkCurrentApiTimestamp.String())
370
371 fmt.Fprintln(w, ".PHONY: droidcore")
372 fmt.Fprintln(w, "droidcore: checkapi")
373 }
374 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700375 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700376 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
377 ddoc.updateCurrentApiTimestamp.String())
378
379 fmt.Fprintln(w, ".PHONY: update-api")
380 fmt.Fprintln(w, "update-api:",
381 ddoc.updateCurrentApiTimestamp.String())
382 }
383 if ddoc.checkLastReleasedApiTimestamp != nil {
384 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
385 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
386 ddoc.checkLastReleasedApiTimestamp.String())
387 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700388 apiFilePrefix := "INTERNAL_PLATFORM_"
389 if String(ddoc.properties.Api_tag_name) != "" {
390 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
391 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700392 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700393 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
394 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100395 if ddoc.dexApiFile != nil {
396 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
397 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700398 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700399 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
400 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700401 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700402 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
403 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700404 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700405 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
406 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700407 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100408 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
409 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700410 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700411 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
412 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700413 if ddoc.proguardFile != nil {
414 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
415 }
Nan Zhang581fd212018-01-10 16:06:12 -0800416 },
417 },
418 }
419}
Colin Crossd96ca352018-08-10 16:06:24 -0700420
Nan Zhang1598a9e2018-09-04 17:14:32 -0700421func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
422 return android.AndroidMkData{
423 Class: "JAVA_LIBRARIES",
424 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
425 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
426 Extra: []android.AndroidMkExtraFunc{
427 func(w io.Writer, outputFile android.Path) {
428 if dstubs.Javadoc.stubsSrcJar != nil {
429 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
430 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700431 if dstubs.apiVersionsXml != nil {
432 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
433 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700434 if dstubs.annotationsZip != nil {
435 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
436 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700437 if dstubs.jdiffDocZip != nil {
438 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
439 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700440 if dstubs.checkCurrentApiTimestamp != nil {
441 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
442 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
443 dstubs.checkCurrentApiTimestamp.String())
444
445 fmt.Fprintln(w, ".PHONY: checkapi")
446 fmt.Fprintln(w, "checkapi:",
447 dstubs.checkCurrentApiTimestamp.String())
448
449 fmt.Fprintln(w, ".PHONY: droidcore")
450 fmt.Fprintln(w, "droidcore: checkapi")
451 }
452 if dstubs.updateCurrentApiTimestamp != nil {
453 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
454 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
455 dstubs.updateCurrentApiTimestamp.String())
456
457 fmt.Fprintln(w, ".PHONY: update-api")
458 fmt.Fprintln(w, "update-api:",
459 dstubs.updateCurrentApiTimestamp.String())
460 }
461 if dstubs.checkLastReleasedApiTimestamp != nil {
462 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
463 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
464 dstubs.checkLastReleasedApiTimestamp.String())
465 }
Pete Gillin581d6082018-10-22 15:55:04 +0100466 if dstubs.checkNullabilityWarningsTimestamp != nil {
467 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
468 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
469 dstubs.checkNullabilityWarningsTimestamp.String())
470
471 fmt.Fprintln(w, ".PHONY:", "droidcore")
472 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
473 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700474 apiFilePrefix := "INTERNAL_PLATFORM_"
475 if String(dstubs.properties.Api_tag_name) != "" {
476 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
477 }
478 if dstubs.apiFile != nil {
479 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
480 }
481 if dstubs.dexApiFile != nil {
482 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
483 }
484 if dstubs.privateApiFile != nil {
485 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
486 }
487 if dstubs.privateDexApiFile != nil {
488 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
489 }
490 if dstubs.removedApiFile != nil {
491 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
492 }
493 if dstubs.removedDexApiFile != nil {
494 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
495 }
496 if dstubs.exactApiFile != nil {
497 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
498 }
499 },
500 },
501 }
502}
503
Colin Crossd96ca352018-08-10 16:06:24 -0700504func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
505 var testFiles []string
506 for _, d := range data {
507 testFiles = append(testFiles, d.String()+":"+d.Rel())
508 }
509 if len(testFiles) > 0 {
510 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
511 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
512 })
513 }
514}