blob: 62d754a4cae9ecbe40eacc1cdc154a03ff2b5781 [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.dexJarFile != nil {
37 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
38 }
39 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
40 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
41 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
42 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
43 }
44}
45
Colin Crossa18e9cf2017-08-10 17:00:19 -070046func (library *Library) AndroidMk() android.AndroidMkData {
47 return android.AndroidMkData{
48 Class: "JAVA_LIBRARIES",
Colin Cross43f08db2018-11-12 10:13:39 -080049 OutputFile: android.OptionalPathForPath(library.outputFile),
Colin Cross53499412017-09-07 13:20:25 -070050 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -070051 Extra: []android.AndroidMkExtraFunc{
52 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080053 if len(library.logtagsSrcs) > 0 {
54 var logtags []string
55 for _, l := range library.logtagsSrcs {
56 logtags = append(logtags, l.Rel())
57 }
58 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
59 }
60
Colin Cross9ae1b922018-06-26 17:59:05 -070061 if library.installFile == nil {
Colin Cross2c429dc2017-08-31 16:45:16 -070062 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
63 }
Colin Cross6ade34f2017-09-15 13:00:47 -070064 if library.dexJarFile != nil {
65 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -080066 }
67 if len(library.dexpreopter.builtInstalled) > 0 {
68 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(library.dexpreopter.builtInstalled, " "))
Colin Cross6ade34f2017-09-15 13:00:47 -070069 }
Colin Cross83bb3162018-06-25 15:48:06 -070070 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion())
Colin Cross43f08db2018-11-12 10:13:39 -080071 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
Nan Zhanged19fc32017-10-19 13:06:22 -070072 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Crosscb933592017-11-22 13:49:43 -080073
74 if library.jacocoReportClassesFile != nil {
75 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String())
76 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080077
Jiyong Park1be96912018-05-28 18:02:19 +090078 if len(library.exportedSdkLibs) != 0 {
79 fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " "))
80 }
81
Colin Cross5ab4e6d2017-11-22 16:20:45 -080082 // Temporary hack: export sources used to compile framework.jar to Make
83 // to be used for droiddoc
84 // TODO(ccross): remove this once droiddoc is in soong
Mathew Inwoodebe29ce2018-09-04 14:26:19 +010085 if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") {
Colin Cross5ab4e6d2017-11-22 16:20:45 -080086 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " "))
87 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " "))
88 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070089 },
90 },
Colin Cross92430102017-10-09 14:59:32 -070091 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
92 android.WriteAndroidMkData(w, data)
Sundong Ahn054b19a2018-10-19 13:46:09 +090093 library.AndroidMkHostDex(w, name, data)
Colin Cross92430102017-10-09 14:59:32 -070094 },
Colin Crossa18e9cf2017-08-10 17:00:19 -070095 }
Dan Willemsen218f6562015-07-08 18:13:11 -070096}
97
Colin Cross05638fc2018-04-09 18:40:24 -070098func (j *Test) AndroidMk() android.AndroidMkData {
99 data := j.Library.AndroidMk()
100 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
101 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
102 if len(j.testProperties.Test_suites) > 0 {
103 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
104 strings.Join(j.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700105 } else {
106 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Cross05638fc2018-04-09 18:40:24 -0700107 }
Colin Cross303e21f2018-08-07 16:49:25 -0700108 if j.testConfig != nil {
109 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700110 }
Colin Cross05638fc2018-04-09 18:40:24 -0700111 })
112
Colin Crossd96ca352018-08-10 16:06:24 -0700113 androidMkWriteTestData(j.data, &data)
114
Colin Cross05638fc2018-04-09 18:40:24 -0700115 return data
116}
117
Colin Crossa18e9cf2017-08-10 17:00:19 -0700118func (prebuilt *Import) AndroidMk() android.AndroidMkData {
119 return android.AndroidMkData{
120 Class: "JAVA_LIBRARIES",
121 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700122 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700123 Extra: []android.AndroidMkExtraFunc{
124 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700125 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700126 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800127 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700128 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700129 },
130 },
131 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700132}
Colin Cross10a03492017-08-10 17:09:43 -0700133
Colin Crossfabb6082018-02-20 17:22:23 -0800134func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
135 return android.AndroidMkData{
136 Class: "JAVA_LIBRARIES",
137 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
138 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
139 Extra: []android.AndroidMkExtraFunc{
140 func(w io.Writer, outputFile android.Path) {
141 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossfabb6082018-02-20 17:22:23 -0800142 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800143 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800144 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
145 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
Colin Cross66f78822018-05-02 12:58:28 -0700146 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
Colin Cross10f7c4a2018-05-23 10:59:28 -0700147 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700148 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800149 },
150 },
151 }
152}
153
Colin Cross10a03492017-08-10 17:09:43 -0700154func (binary *Binary) AndroidMk() android.AndroidMkData {
Colin Cross10a03492017-08-10 17:09:43 -0700155
Colin Cross6b4a32d2017-12-05 13:42:45 -0800156 if !binary.isWrapperVariant {
157 return android.AndroidMkData{
158 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700159 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800160 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Cross331a1212018-08-15 20:40:52 -0700161 Extra: []android.AndroidMkExtraFunc{
162 func(w io.Writer, outputFile android.Path) {
163 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800164 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
Colin Cross12fc2af2019-01-14 12:35:45 -0800165 if binary.dexJarFile != nil {
166 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
167 }
168 if len(binary.dexpreopter.builtInstalled) > 0 {
169 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(binary.dexpreopter.builtInstalled, " "))
170 }
Colin Cross331a1212018-08-15 20:40:52 -0700171 },
172 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800173 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
174 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700175
Colin Cross6b4a32d2017-12-05 13:42:45 -0800176 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
177 },
178 }
179 } else {
180 return android.AndroidMkData{
181 Class: "EXECUTABLES",
182 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
183 Extra: []android.AndroidMkExtraFunc{
184 func(w io.Writer, outputFile android.Path) {
185 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
186 },
187 },
188 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
189 android.WriteAndroidMkData(w, data)
190
191 // Ensure that the wrapper script timestamp is always updated when the jar is updated
192 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
193 fmt.Fprintln(w, "jar_installed_module :=")
194 },
195 }
Colin Cross10a03492017-08-10 17:09:43 -0700196 }
197}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800198
199func (app *AndroidApp) AndroidMk() android.AndroidMkData {
200 return android.AndroidMkData{
201 Class: "APPS",
202 OutputFile: android.OptionalPathForPath(app.outputFile),
203 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
204 Extra: []android.AndroidMkExtraFunc{
205 func(w io.Writer, outputFile android.Path) {
Colin Cross70798562017-12-13 22:42:59 -0800206 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
207 if app.dexJarFile != nil {
208 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800209 }
Colin Cross331a1212018-08-15 20:40:52 -0700210 if app.implementationAndResourcesJar != nil {
211 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800212 }
213 if app.headerJarFile != nil {
214 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
215 }
Colin Crossf6237212018-10-29 23:14:58 -0700216 if app.bundleFile != nil {
217 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
218 }
Colin Cross70798562017-12-13 22:42:59 -0800219 if app.jacocoReportClassesFile != nil {
220 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
221 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800222 if app.proguardDictionary != nil {
223 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
224 }
Colin Cross70798562017-12-13 22:42:59 -0800225
226 if app.Name() == "framework-res" {
227 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
228 // Make base_rules.mk not put framework-res in a subdirectory called
229 // framework_res.
230 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
231 }
232
233 if len(app.rroDirs) > 0 {
Colin Crossa140bb02018-04-17 10:52:26 -0700234 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
235 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
236 fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800237 }
238
239 if Bool(app.appProperties.Export_package_resources) {
240 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
241 }
242
243 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
244
Colin Cross16056062017-12-13 22:46:28 -0800245 if Bool(app.appProperties.Privileged) {
246 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
247 }
Colin Crosse1731a52017-12-14 11:22:55 -0800248
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900249 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jason Monkd4122be2018-08-10 09:33:36 -0400250 if len(app.appProperties.Overrides) > 0 {
251 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES := "+strings.Join(app.appProperties.Overrides, " "))
252 }
Colin Crossa4f08812018-10-02 22:03:40 -0700253
254 for _, jniLib := range app.installJniLibs {
255 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
256 }
Colin Cross43f08db2018-11-12 10:13:39 -0800257 if len(app.dexpreopter.builtInstalled) > 0 {
258 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", strings.Join(app.dexpreopter.builtInstalled, " "))
259 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800260 },
261 },
262 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700263}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800264
Colin Crossae5caf52018-05-22 11:11:52 -0700265func (a *AndroidTest) AndroidMk() android.AndroidMkData {
266 data := a.AndroidApp.AndroidMk()
267 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
268 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
269 if len(a.testProperties.Test_suites) > 0 {
270 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
271 strings.Join(a.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700272 } else {
273 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Crossae5caf52018-05-22 11:11:52 -0700274 }
Colin Cross303e21f2018-08-07 16:49:25 -0700275 if a.testConfig != nil {
276 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700277 }
Colin Crossae5caf52018-05-22 11:11:52 -0700278 })
Colin Crossd96ca352018-08-10 16:06:24 -0700279 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700280
281 return data
282}
283
Colin Cross252fc6f2018-10-04 15:22:03 -0700284func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
285 data := a.AndroidApp.AndroidMk()
286 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
287 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
288 if len(a.appTestHelperAppProperties.Test_suites) > 0 {
289 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
290 strings.Join(a.appTestHelperAppProperties.Test_suites, " "))
291 } else {
292 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
293 }
294 })
295
296 return data
297}
298
Colin Crossa97c5d32018-03-28 14:58:31 -0700299func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
300 data := a.Library.AndroidMk()
301
302 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700303 if a.aarFile != nil {
304 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
305 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700306 if a.proguardDictionary != nil {
307 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
308 }
309
310 if a.Name() == "framework-res" {
311 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
312 // Make base_rules.mk not put framework-res in a subdirectory called
313 // framework_res.
314 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
315 }
316
317 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700318 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700319 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700320 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
321 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700322 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700323 })
324
325 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800326}
Nan Zhang581fd212018-01-10 16:06:12 -0800327
328func (jd *Javadoc) AndroidMk() android.AndroidMkData {
329 return android.AndroidMkData{
330 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800331 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700332 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800333 Extra: []android.AndroidMkExtraFunc{
334 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700335 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800336 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
337 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800338 if jd.stubsSrcJar != nil {
339 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800340 }
341 },
342 },
343 }
344}
345
346func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
347 return android.AndroidMkData{
348 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800349 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700350 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800351 Extra: []android.AndroidMkExtraFunc{
352 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700353 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800354 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
355 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800356 if ddoc.Javadoc.stubsSrcJar != nil {
357 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800358 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700359 if ddoc.checkCurrentApiTimestamp != nil {
360 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
361 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
362 ddoc.checkCurrentApiTimestamp.String())
363
364 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900365 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700366 ddoc.checkCurrentApiTimestamp.String())
367
368 fmt.Fprintln(w, ".PHONY: droidcore")
369 fmt.Fprintln(w, "droidcore: checkapi")
370 }
371 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700372 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700373 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
374 ddoc.updateCurrentApiTimestamp.String())
375
376 fmt.Fprintln(w, ".PHONY: update-api")
377 fmt.Fprintln(w, "update-api:",
378 ddoc.updateCurrentApiTimestamp.String())
379 }
380 if ddoc.checkLastReleasedApiTimestamp != nil {
381 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
382 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
383 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100384
385 if ddoc.Name() == "api-stubs-docs" {
386 fmt.Fprintln(w, ".PHONY: checkapi")
387 fmt.Fprintln(w, "checkapi:",
388 ddoc.checkLastReleasedApiTimestamp.String())
389
390 fmt.Fprintln(w, ".PHONY: droidcore")
391 fmt.Fprintln(w, "droidcore: checkapi")
392 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700393 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700394 apiFilePrefix := "INTERNAL_PLATFORM_"
395 if String(ddoc.properties.Api_tag_name) != "" {
396 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
397 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700398 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700399 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
400 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100401 if ddoc.dexApiFile != nil {
402 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
403 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700404 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700405 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
406 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700407 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700408 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
409 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700410 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700411 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
412 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700413 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100414 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
415 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700416 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700417 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
418 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700419 if ddoc.proguardFile != nil {
420 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
421 }
Nan Zhang581fd212018-01-10 16:06:12 -0800422 },
423 },
424 }
425}
Colin Crossd96ca352018-08-10 16:06:24 -0700426
Nan Zhang1598a9e2018-09-04 17:14:32 -0700427func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
428 return android.AndroidMkData{
429 Class: "JAVA_LIBRARIES",
430 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
431 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
432 Extra: []android.AndroidMkExtraFunc{
433 func(w io.Writer, outputFile android.Path) {
434 if dstubs.Javadoc.stubsSrcJar != nil {
435 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
436 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700437 if dstubs.apiVersionsXml != nil {
438 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
439 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700440 if dstubs.annotationsZip != nil {
441 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
442 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700443 if dstubs.jdiffDocZip != nil {
444 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
445 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700446 if dstubs.checkCurrentApiTimestamp != nil {
447 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
448 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
449 dstubs.checkCurrentApiTimestamp.String())
450
451 fmt.Fprintln(w, ".PHONY: checkapi")
452 fmt.Fprintln(w, "checkapi:",
453 dstubs.checkCurrentApiTimestamp.String())
454
455 fmt.Fprintln(w, ".PHONY: droidcore")
456 fmt.Fprintln(w, "droidcore: checkapi")
457 }
458 if dstubs.updateCurrentApiTimestamp != nil {
459 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
460 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
461 dstubs.updateCurrentApiTimestamp.String())
462
463 fmt.Fprintln(w, ".PHONY: update-api")
464 fmt.Fprintln(w, "update-api:",
465 dstubs.updateCurrentApiTimestamp.String())
466 }
467 if dstubs.checkLastReleasedApiTimestamp != nil {
468 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
469 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
470 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100471
472 if dstubs.Name() == "api-stubs-docs" {
473 fmt.Fprintln(w, ".PHONY: checkapi")
474 fmt.Fprintln(w, "checkapi:",
475 dstubs.checkLastReleasedApiTimestamp.String())
476
477 fmt.Fprintln(w, ".PHONY: droidcore")
478 fmt.Fprintln(w, "droidcore: checkapi")
479 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700480 }
Pete Gillin581d6082018-10-22 15:55:04 +0100481 if dstubs.checkNullabilityWarningsTimestamp != nil {
482 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
483 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
484 dstubs.checkNullabilityWarningsTimestamp.String())
485
486 fmt.Fprintln(w, ".PHONY:", "droidcore")
487 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
488 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700489 apiFilePrefix := "INTERNAL_PLATFORM_"
490 if String(dstubs.properties.Api_tag_name) != "" {
491 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
492 }
493 if dstubs.apiFile != nil {
494 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
495 }
496 if dstubs.dexApiFile != nil {
497 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
498 }
499 if dstubs.privateApiFile != nil {
500 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
501 }
502 if dstubs.privateDexApiFile != nil {
503 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
504 }
505 if dstubs.removedApiFile != nil {
506 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
507 }
508 if dstubs.removedDexApiFile != nil {
509 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
510 }
511 if dstubs.exactApiFile != nil {
512 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
513 }
514 },
515 },
516 }
517}
518
Colin Crossd96ca352018-08-10 16:06:24 -0700519func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
520 var testFiles []string
521 for _, d := range data {
522 testFiles = append(testFiles, d.String()+":"+d.Rel())
523 }
524 if len(testFiles) > 0 {
525 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
526 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
527 })
528 }
529}