blob: 04b328dc8f248e60975c3cb8d3fa46445d3f4d2a [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 {
Colin Crossdeabb942019-02-11 14:11:09 -080068 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", 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 {
Colin Crossdeabb942019-02-11 14:11:09 -0800169 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800170 }
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) {
Jaewoong Jung9109d722019-01-30 13:13:52 -0800206 // TODO(jungjw): This, outputting two LOCAL_MODULE lines, works, but is not ideal. Find a better solution.
207 if app.Name() != app.installApkName {
208 fmt.Fprintln(w, "# Overridden by PRODUCT_PACKAGE_NAME_OVERRIDES")
209 fmt.Fprintln(w, "LOCAL_MODULE :=", app.installApkName)
210 }
Colin Cross70798562017-12-13 22:42:59 -0800211 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
212 if app.dexJarFile != nil {
213 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800214 }
Colin Cross331a1212018-08-15 20:40:52 -0700215 if app.implementationAndResourcesJar != nil {
216 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800217 }
218 if app.headerJarFile != nil {
219 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
220 }
Colin Crossf6237212018-10-29 23:14:58 -0700221 if app.bundleFile != nil {
222 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
223 }
Colin Cross70798562017-12-13 22:42:59 -0800224 if app.jacocoReportClassesFile != nil {
225 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
226 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800227 if app.proguardDictionary != nil {
228 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
229 }
Colin Cross70798562017-12-13 22:42:59 -0800230
231 if app.Name() == "framework-res" {
232 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
233 // Make base_rules.mk not put framework-res in a subdirectory called
234 // framework_res.
235 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
236 }
237
238 if len(app.rroDirs) > 0 {
Colin Crossa140bb02018-04-17 10:52:26 -0700239 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
240 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
241 fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800242 }
243
244 if Bool(app.appProperties.Export_package_resources) {
245 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
246 }
247
248 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
249
Colin Cross16056062017-12-13 22:46:28 -0800250 if Bool(app.appProperties.Privileged) {
251 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
252 }
Colin Crosse1731a52017-12-14 11:22:55 -0800253
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900254 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jaewoong Jung9109d722019-01-30 13:13:52 -0800255 if overriddenPkgs := app.getOverriddenPackages(); len(overriddenPkgs) > 0 {
256 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES :=", strings.Join(overriddenPkgs, " "))
Jason Monkd4122be2018-08-10 09:33:36 -0400257 }
Colin Crossa4f08812018-10-02 22:03:40 -0700258
259 for _, jniLib := range app.installJniLibs {
260 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
261 }
Colin Cross43f08db2018-11-12 10:13:39 -0800262 if len(app.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800263 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800264 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800265 },
266 },
267 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700268}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800269
Jaewoong Jung9109d722019-01-30 13:13:52 -0800270func (a *AndroidApp) getOverriddenPackages() []string {
271 var overridden []string
272 if len(a.appProperties.Overrides) > 0 {
273 overridden = append(overridden, a.appProperties.Overrides...)
274 }
275 if a.Name() != a.installApkName {
276 overridden = append(overridden, a.Name())
277 }
278 return overridden
279}
280
Colin Crossae5caf52018-05-22 11:11:52 -0700281func (a *AndroidTest) AndroidMk() android.AndroidMkData {
282 data := a.AndroidApp.AndroidMk()
283 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
284 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
285 if len(a.testProperties.Test_suites) > 0 {
286 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
287 strings.Join(a.testProperties.Test_suites, " "))
Colin Cross303e21f2018-08-07 16:49:25 -0700288 } else {
289 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
Colin Crossae5caf52018-05-22 11:11:52 -0700290 }
Colin Cross303e21f2018-08-07 16:49:25 -0700291 if a.testConfig != nil {
292 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700293 }
Colin Crossae5caf52018-05-22 11:11:52 -0700294 })
Colin Crossd96ca352018-08-10 16:06:24 -0700295 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700296
297 return data
298}
299
Colin Cross252fc6f2018-10-04 15:22:03 -0700300func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
301 data := a.AndroidApp.AndroidMk()
302 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
303 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
304 if len(a.appTestHelperAppProperties.Test_suites) > 0 {
305 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
306 strings.Join(a.appTestHelperAppProperties.Test_suites, " "))
307 } else {
308 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
309 }
310 })
311
312 return data
313}
314
Colin Crossa97c5d32018-03-28 14:58:31 -0700315func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
316 data := a.Library.AndroidMk()
317
318 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700319 if a.aarFile != nil {
320 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
321 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700322 if a.proguardDictionary != nil {
323 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
324 }
325
326 if a.Name() == "framework-res" {
327 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
328 // Make base_rules.mk not put framework-res in a subdirectory called
329 // framework_res.
330 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
331 }
332
333 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700334 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700335 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700336 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
337 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700338 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700339 })
340
341 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800342}
Nan Zhang581fd212018-01-10 16:06:12 -0800343
344func (jd *Javadoc) AndroidMk() android.AndroidMkData {
345 return android.AndroidMkData{
346 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800347 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700348 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800349 Extra: []android.AndroidMkExtraFunc{
350 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700351 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800352 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
353 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800354 if jd.stubsSrcJar != nil {
355 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800356 }
357 },
358 },
359 }
360}
361
362func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
363 return android.AndroidMkData{
364 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800365 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700366 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800367 Extra: []android.AndroidMkExtraFunc{
368 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700369 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800370 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
371 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800372 if ddoc.Javadoc.stubsSrcJar != nil {
373 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800374 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700375 if ddoc.checkCurrentApiTimestamp != nil {
376 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
377 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
378 ddoc.checkCurrentApiTimestamp.String())
379
380 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900381 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700382 ddoc.checkCurrentApiTimestamp.String())
383
384 fmt.Fprintln(w, ".PHONY: droidcore")
385 fmt.Fprintln(w, "droidcore: checkapi")
386 }
387 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700388 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700389 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
390 ddoc.updateCurrentApiTimestamp.String())
391
392 fmt.Fprintln(w, ".PHONY: update-api")
393 fmt.Fprintln(w, "update-api:",
394 ddoc.updateCurrentApiTimestamp.String())
395 }
396 if ddoc.checkLastReleasedApiTimestamp != nil {
397 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
398 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
399 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100400
Adrian Roos62e34b92019-01-30 19:51:39 +0100401 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100402 fmt.Fprintln(w, ".PHONY: checkapi")
403 fmt.Fprintln(w, "checkapi:",
404 ddoc.checkLastReleasedApiTimestamp.String())
405
406 fmt.Fprintln(w, ".PHONY: droidcore")
407 fmt.Fprintln(w, "droidcore: checkapi")
408 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700409 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700410 apiFilePrefix := "INTERNAL_PLATFORM_"
411 if String(ddoc.properties.Api_tag_name) != "" {
412 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
413 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700414 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700415 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
416 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100417 if ddoc.dexApiFile != nil {
418 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
419 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700420 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700421 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
422 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700423 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700424 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
425 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700426 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700427 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
428 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700429 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100430 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
431 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700432 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700433 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
434 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700435 if ddoc.proguardFile != nil {
436 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
437 }
Nan Zhang581fd212018-01-10 16:06:12 -0800438 },
439 },
440 }
441}
Colin Crossd96ca352018-08-10 16:06:24 -0700442
Nan Zhang1598a9e2018-09-04 17:14:32 -0700443func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
444 return android.AndroidMkData{
445 Class: "JAVA_LIBRARIES",
446 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
447 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
448 Extra: []android.AndroidMkExtraFunc{
449 func(w io.Writer, outputFile android.Path) {
450 if dstubs.Javadoc.stubsSrcJar != nil {
451 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
452 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700453 if dstubs.apiVersionsXml != nil {
454 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
455 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700456 if dstubs.annotationsZip != nil {
457 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
458 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700459 if dstubs.jdiffDocZip != nil {
460 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
461 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700462 if dstubs.checkCurrentApiTimestamp != nil {
463 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
464 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
465 dstubs.checkCurrentApiTimestamp.String())
466
467 fmt.Fprintln(w, ".PHONY: checkapi")
468 fmt.Fprintln(w, "checkapi:",
469 dstubs.checkCurrentApiTimestamp.String())
470
471 fmt.Fprintln(w, ".PHONY: droidcore")
472 fmt.Fprintln(w, "droidcore: checkapi")
473 }
474 if dstubs.updateCurrentApiTimestamp != nil {
475 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
476 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
477 dstubs.updateCurrentApiTimestamp.String())
478
479 fmt.Fprintln(w, ".PHONY: update-api")
480 fmt.Fprintln(w, "update-api:",
481 dstubs.updateCurrentApiTimestamp.String())
482 }
483 if dstubs.checkLastReleasedApiTimestamp != nil {
484 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
485 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
486 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100487
Adrian Roos62e34b92019-01-30 19:51:39 +0100488 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100489 fmt.Fprintln(w, ".PHONY: checkapi")
490 fmt.Fprintln(w, "checkapi:",
491 dstubs.checkLastReleasedApiTimestamp.String())
492
493 fmt.Fprintln(w, ".PHONY: droidcore")
494 fmt.Fprintln(w, "droidcore: checkapi")
495 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700496 }
Pete Gillin581d6082018-10-22 15:55:04 +0100497 if dstubs.checkNullabilityWarningsTimestamp != nil {
498 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
499 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
500 dstubs.checkNullabilityWarningsTimestamp.String())
501
502 fmt.Fprintln(w, ".PHONY:", "droidcore")
503 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
504 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700505 apiFilePrefix := "INTERNAL_PLATFORM_"
506 if String(dstubs.properties.Api_tag_name) != "" {
507 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
508 }
509 if dstubs.apiFile != nil {
510 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
511 }
512 if dstubs.dexApiFile != nil {
513 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
514 }
515 if dstubs.privateApiFile != nil {
516 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
517 }
518 if dstubs.privateDexApiFile != nil {
519 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
520 }
521 if dstubs.removedApiFile != nil {
522 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
523 }
524 if dstubs.removedDexApiFile != nil {
525 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
526 }
527 if dstubs.exactApiFile != nil {
528 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
529 }
530 },
531 },
532 }
533}
534
Colin Crossd96ca352018-08-10 16:06:24 -0700535func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
536 var testFiles []string
537 for _, d := range data {
538 testFiles = append(testFiles, d.String()+":"+d.Rel())
539 }
540 if len(testFiles) > 0 {
541 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
542 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
543 })
544 }
545}