blob: 908286a7478bfd7455b4f3a7fc0e360b3226266e [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
Paul Duffin42df1442019-03-20 12:45:53 +000098// Called for modules that are a component of a test suite.
99func testSuiteComponent(w io.Writer, test_suites []string) {
100 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
101 if len(test_suites) > 0 {
102 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
103 strings.Join(test_suites, " "))
104 } else {
105 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
106 }
107}
108
Colin Cross05638fc2018-04-09 18:40:24 -0700109func (j *Test) AndroidMk() android.AndroidMkData {
110 data := j.Library.AndroidMk()
111 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000112 testSuiteComponent(w, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700113 if j.testConfig != nil {
114 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700115 }
Colin Cross05638fc2018-04-09 18:40:24 -0700116 })
117
Colin Crossd96ca352018-08-10 16:06:24 -0700118 androidMkWriteTestData(j.data, &data)
119
Colin Cross05638fc2018-04-09 18:40:24 -0700120 return data
121}
122
Paul Duffin42df1442019-03-20 12:45:53 +0000123func (j *TestHelperLibrary) AndroidMk() android.AndroidMkData {
124 data := j.Library.AndroidMk()
125 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
126 testSuiteComponent(w, j.testHelperLibraryProperties.Test_suites)
127 })
128
129 return data
130}
131
Colin Crossa18e9cf2017-08-10 17:00:19 -0700132func (prebuilt *Import) AndroidMk() android.AndroidMkData {
133 return android.AndroidMkData{
134 Class: "JAVA_LIBRARIES",
135 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700136 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700137 Extra: []android.AndroidMkExtraFunc{
138 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700139 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700140 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800141 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700142 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700143 },
144 },
145 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700146}
Colin Cross10a03492017-08-10 17:09:43 -0700147
Colin Cross42be7612019-02-21 18:12:14 -0800148func (prebuilt *DexImport) AndroidMk() android.AndroidMkData {
149 return android.AndroidMkData{
150 Class: "JAVA_LIBRARIES",
151 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
152 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
153 Extra: []android.AndroidMkExtraFunc{
154 func(w io.Writer, outputFile android.Path) {
155 if prebuilt.dexJarFile != nil {
156 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", prebuilt.dexJarFile.String())
157 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
158 // boot_jars_package_check.mk can check dex jars.
159 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.dexJarFile.String())
160 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.dexJarFile.String())
161 }
162 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
163 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", prebuilt.dexpreopter.builtInstalled)
164 }
165 },
166 },
167 }
168}
169
Colin Crossfabb6082018-02-20 17:22:23 -0800170func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
171 return android.AndroidMkData{
172 Class: "JAVA_LIBRARIES",
173 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
174 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
175 Extra: []android.AndroidMkExtraFunc{
176 func(w io.Writer, outputFile android.Path) {
177 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossfabb6082018-02-20 17:22:23 -0800178 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800179 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800180 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
181 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
Colin Cross66f78822018-05-02 12:58:28 -0700182 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
Colin Cross10f7c4a2018-05-23 10:59:28 -0700183 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700184 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800185 },
186 },
187 }
188}
189
Colin Cross10a03492017-08-10 17:09:43 -0700190func (binary *Binary) AndroidMk() android.AndroidMkData {
Colin Cross10a03492017-08-10 17:09:43 -0700191
Colin Cross6b4a32d2017-12-05 13:42:45 -0800192 if !binary.isWrapperVariant {
193 return android.AndroidMkData{
194 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700195 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800196 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Cross331a1212018-08-15 20:40:52 -0700197 Extra: []android.AndroidMkExtraFunc{
198 func(w io.Writer, outputFile android.Path) {
199 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800200 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
Colin Cross12fc2af2019-01-14 12:35:45 -0800201 if binary.dexJarFile != nil {
202 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
203 }
204 if len(binary.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800205 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800206 }
Colin Cross331a1212018-08-15 20:40:52 -0700207 },
208 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800209 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
210 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700211
Colin Cross6b4a32d2017-12-05 13:42:45 -0800212 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
213 },
214 }
215 } else {
216 return android.AndroidMkData{
217 Class: "EXECUTABLES",
218 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
219 Extra: []android.AndroidMkExtraFunc{
220 func(w io.Writer, outputFile android.Path) {
221 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
222 },
223 },
224 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
225 android.WriteAndroidMkData(w, data)
226
227 // Ensure that the wrapper script timestamp is always updated when the jar is updated
228 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
229 fmt.Fprintln(w, "jar_installed_module :=")
230 },
231 }
Colin Cross10a03492017-08-10 17:09:43 -0700232 }
233}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800234
235func (app *AndroidApp) AndroidMk() android.AndroidMkData {
236 return android.AndroidMkData{
237 Class: "APPS",
238 OutputFile: android.OptionalPathForPath(app.outputFile),
239 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
240 Extra: []android.AndroidMkExtraFunc{
241 func(w io.Writer, outputFile android.Path) {
Jaewoong Jung9109d722019-01-30 13:13:52 -0800242 // TODO(jungjw): This, outputting two LOCAL_MODULE lines, works, but is not ideal. Find a better solution.
243 if app.Name() != app.installApkName {
244 fmt.Fprintln(w, "# Overridden by PRODUCT_PACKAGE_NAME_OVERRIDES")
245 fmt.Fprintln(w, "LOCAL_MODULE :=", app.installApkName)
246 }
Colin Cross70798562017-12-13 22:42:59 -0800247 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
248 if app.dexJarFile != nil {
249 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800250 }
Colin Cross331a1212018-08-15 20:40:52 -0700251 if app.implementationAndResourcesJar != nil {
252 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800253 }
254 if app.headerJarFile != nil {
255 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
256 }
Colin Crossf6237212018-10-29 23:14:58 -0700257 if app.bundleFile != nil {
258 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
259 }
Colin Cross70798562017-12-13 22:42:59 -0800260 if app.jacocoReportClassesFile != nil {
261 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
262 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800263 if app.proguardDictionary != nil {
264 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
265 }
Colin Cross70798562017-12-13 22:42:59 -0800266
267 if app.Name() == "framework-res" {
268 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
269 // Make base_rules.mk not put framework-res in a subdirectory called
270 // framework_res.
271 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
272 }
273
Anton Hansson53c88442019-03-18 15:53:16 +0000274 filterRRO := func(filter overlayType) android.Paths {
275 var paths android.Paths
276 for _, d := range app.rroDirs {
277 if d.overlayType == filter {
278 paths = append(paths, d.path)
279 }
280 }
Colin Crossa140bb02018-04-17 10:52:26 -0700281 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
282 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000283 return android.ReversePaths(paths)
284 }
285 deviceRRODirs := filterRRO(device)
286 if len(deviceRRODirs) > 0 {
287 fmt.Fprintln(w, "LOCAL_SOONG_DEVICE_RRO_DIRS :=", strings.Join(deviceRRODirs.Strings(), " "))
288 }
289 productRRODirs := filterRRO(product)
290 if len(productRRODirs) > 0 {
291 fmt.Fprintln(w, "LOCAL_SOONG_PRODUCT_RRO_DIRS :=", strings.Join(productRRODirs.Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800292 }
293
294 if Bool(app.appProperties.Export_package_resources) {
295 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
296 }
297
298 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
299
Colin Cross16056062017-12-13 22:46:28 -0800300 if Bool(app.appProperties.Privileged) {
301 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
302 }
Colin Crosse1731a52017-12-14 11:22:55 -0800303
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900304 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jaewoong Jung9109d722019-01-30 13:13:52 -0800305 if overriddenPkgs := app.getOverriddenPackages(); len(overriddenPkgs) > 0 {
306 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES :=", strings.Join(overriddenPkgs, " "))
Jason Monkd4122be2018-08-10 09:33:36 -0400307 }
Colin Crossa4f08812018-10-02 22:03:40 -0700308
309 for _, jniLib := range app.installJniLibs {
310 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
311 }
Colin Cross43f08db2018-11-12 10:13:39 -0800312 if len(app.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800313 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800314 }
Colin Crosse560c4a2019-03-19 16:03:11 -0700315 for _, split := range app.aapt.splits {
316 install := "$(LOCAL_MODULE_PATH)/" + strings.TrimSuffix(app.installApkName, ".apk") + split.suffix + ".apk"
317 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED +=", split.path.String()+":"+install)
318 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800319 },
320 },
321 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700322}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800323
Jaewoong Jung9109d722019-01-30 13:13:52 -0800324func (a *AndroidApp) getOverriddenPackages() []string {
325 var overridden []string
326 if len(a.appProperties.Overrides) > 0 {
327 overridden = append(overridden, a.appProperties.Overrides...)
328 }
329 if a.Name() != a.installApkName {
330 overridden = append(overridden, a.Name())
331 }
332 return overridden
333}
334
Colin Crossae5caf52018-05-22 11:11:52 -0700335func (a *AndroidTest) AndroidMk() android.AndroidMkData {
336 data := a.AndroidApp.AndroidMk()
337 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000338 testSuiteComponent(w, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700339 if a.testConfig != nil {
340 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700341 }
Colin Crossae5caf52018-05-22 11:11:52 -0700342 })
Colin Crossd96ca352018-08-10 16:06:24 -0700343 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700344
345 return data
346}
347
Colin Cross252fc6f2018-10-04 15:22:03 -0700348func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
349 data := a.AndroidApp.AndroidMk()
350 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000351 testSuiteComponent(w, a.appTestHelperAppProperties.Test_suites)
Colin Cross252fc6f2018-10-04 15:22:03 -0700352 })
353
354 return data
355}
356
Colin Crossa97c5d32018-03-28 14:58:31 -0700357func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
358 data := a.Library.AndroidMk()
359
360 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700361 if a.aarFile != nil {
362 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
363 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700364 if a.proguardDictionary != nil {
365 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
366 }
367
368 if a.Name() == "framework-res" {
369 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
370 // Make base_rules.mk not put framework-res in a subdirectory called
371 // framework_res.
372 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
373 }
374
375 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700376 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700377 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700378 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
379 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700380 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700381 })
382
383 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800384}
Nan Zhang581fd212018-01-10 16:06:12 -0800385
386func (jd *Javadoc) AndroidMk() android.AndroidMkData {
387 return android.AndroidMkData{
388 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800389 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700390 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800391 Extra: []android.AndroidMkExtraFunc{
392 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700393 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800394 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
395 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800396 if jd.stubsSrcJar != nil {
397 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800398 }
399 },
400 },
401 }
402}
403
404func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
405 return android.AndroidMkData{
406 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800407 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700408 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800409 Extra: []android.AndroidMkExtraFunc{
410 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700411 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800412 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
413 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800414 if ddoc.Javadoc.stubsSrcJar != nil {
415 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800416 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700417 if ddoc.checkCurrentApiTimestamp != nil {
418 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
419 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
420 ddoc.checkCurrentApiTimestamp.String())
421
422 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900423 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700424 ddoc.checkCurrentApiTimestamp.String())
425
426 fmt.Fprintln(w, ".PHONY: droidcore")
427 fmt.Fprintln(w, "droidcore: checkapi")
428 }
429 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700430 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700431 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
432 ddoc.updateCurrentApiTimestamp.String())
433
434 fmt.Fprintln(w, ".PHONY: update-api")
435 fmt.Fprintln(w, "update-api:",
436 ddoc.updateCurrentApiTimestamp.String())
437 }
438 if ddoc.checkLastReleasedApiTimestamp != nil {
439 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
440 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
441 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100442
Adrian Roos62e34b92019-01-30 19:51:39 +0100443 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100444 fmt.Fprintln(w, ".PHONY: checkapi")
445 fmt.Fprintln(w, "checkapi:",
446 ddoc.checkLastReleasedApiTimestamp.String())
447
448 fmt.Fprintln(w, ".PHONY: droidcore")
449 fmt.Fprintln(w, "droidcore: checkapi")
450 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700451 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700452 apiFilePrefix := "INTERNAL_PLATFORM_"
453 if String(ddoc.properties.Api_tag_name) != "" {
454 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
455 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700456 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700457 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
458 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100459 if ddoc.dexApiFile != nil {
460 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
461 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700462 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700463 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
464 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700465 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700466 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
467 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700468 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700469 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
470 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700471 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100472 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
473 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700474 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700475 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
476 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700477 if ddoc.proguardFile != nil {
478 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
479 }
Nan Zhang581fd212018-01-10 16:06:12 -0800480 },
481 },
482 }
483}
Colin Crossd96ca352018-08-10 16:06:24 -0700484
Nan Zhang1598a9e2018-09-04 17:14:32 -0700485func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
486 return android.AndroidMkData{
487 Class: "JAVA_LIBRARIES",
488 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
489 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
490 Extra: []android.AndroidMkExtraFunc{
491 func(w io.Writer, outputFile android.Path) {
492 if dstubs.Javadoc.stubsSrcJar != nil {
493 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
494 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700495 if dstubs.apiVersionsXml != nil {
496 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
497 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700498 if dstubs.annotationsZip != nil {
499 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
500 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700501 if dstubs.jdiffDocZip != nil {
502 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
503 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700504 if dstubs.checkCurrentApiTimestamp != nil {
505 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
506 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
507 dstubs.checkCurrentApiTimestamp.String())
508
509 fmt.Fprintln(w, ".PHONY: checkapi")
510 fmt.Fprintln(w, "checkapi:",
511 dstubs.checkCurrentApiTimestamp.String())
512
513 fmt.Fprintln(w, ".PHONY: droidcore")
514 fmt.Fprintln(w, "droidcore: checkapi")
515 }
516 if dstubs.updateCurrentApiTimestamp != nil {
517 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
518 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
519 dstubs.updateCurrentApiTimestamp.String())
520
521 fmt.Fprintln(w, ".PHONY: update-api")
522 fmt.Fprintln(w, "update-api:",
523 dstubs.updateCurrentApiTimestamp.String())
524 }
525 if dstubs.checkLastReleasedApiTimestamp != nil {
526 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
527 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
528 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100529
Adrian Roos62e34b92019-01-30 19:51:39 +0100530 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100531 fmt.Fprintln(w, ".PHONY: checkapi")
532 fmt.Fprintln(w, "checkapi:",
533 dstubs.checkLastReleasedApiTimestamp.String())
534
535 fmt.Fprintln(w, ".PHONY: droidcore")
536 fmt.Fprintln(w, "droidcore: checkapi")
537 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700538 }
Pete Gillin581d6082018-10-22 15:55:04 +0100539 if dstubs.checkNullabilityWarningsTimestamp != nil {
540 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
541 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
542 dstubs.checkNullabilityWarningsTimestamp.String())
543
544 fmt.Fprintln(w, ".PHONY:", "droidcore")
545 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
546 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700547 apiFilePrefix := "INTERNAL_PLATFORM_"
548 if String(dstubs.properties.Api_tag_name) != "" {
549 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
550 }
551 if dstubs.apiFile != nil {
552 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
553 }
554 if dstubs.dexApiFile != nil {
555 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
556 }
557 if dstubs.privateApiFile != nil {
558 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
559 }
560 if dstubs.privateDexApiFile != nil {
561 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
562 }
563 if dstubs.removedApiFile != nil {
564 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
565 }
566 if dstubs.removedDexApiFile != nil {
567 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
568 }
569 if dstubs.exactApiFile != nil {
570 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
571 }
572 },
573 },
574 }
575}
576
Colin Crossd96ca352018-08-10 16:06:24 -0700577func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
578 var testFiles []string
579 for _, d := range data {
580 testFiles = append(testFiles, d.String()+":"+d.Rel())
581 }
582 if len(testFiles) > 0 {
583 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
584 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
585 })
586 }
587}