blob: c2c24e2d87611846be062ec2528d755c52dc6e94 [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())
Jaewoong Jung9aa3ab12019-04-03 15:47:29 -070041 if len(data.Required) > 0 {
42 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(data.Required, " "))
43 }
44 if len(data.Host_required) > 0 {
45 fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(data.Host_required, " "))
46 }
47 if len(data.Target_required) > 0 {
48 fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(data.Target_required, " "))
49 }
Colin Cross7f87f4f2019-04-24 13:41:45 -070050 if r := library.deviceProperties.Target.Hostdex.Required; len(r) > 0 {
51 fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(r, " "))
52 }
Sundong Ahn054b19a2018-10-19 13:46:09 +090053 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
54 }
55}
56
Colin Crossa18e9cf2017-08-10 17:00:19 -070057func (library *Library) AndroidMk() android.AndroidMkData {
58 return android.AndroidMkData{
59 Class: "JAVA_LIBRARIES",
Colin Cross43f08db2018-11-12 10:13:39 -080060 OutputFile: android.OptionalPathForPath(library.outputFile),
Colin Cross53499412017-09-07 13:20:25 -070061 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -070062 Extra: []android.AndroidMkExtraFunc{
63 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080064 if len(library.logtagsSrcs) > 0 {
65 var logtags []string
66 for _, l := range library.logtagsSrcs {
67 logtags = append(logtags, l.Rel())
68 }
69 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
70 }
71
Colin Cross9ae1b922018-06-26 17:59:05 -070072 if library.installFile == nil {
Colin Cross2c429dc2017-08-31 16:45:16 -070073 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
74 }
Colin Cross6ade34f2017-09-15 13:00:47 -070075 if library.dexJarFile != nil {
76 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -080077 }
78 if len(library.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -080079 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", library.dexpreopter.builtInstalled)
Colin Cross6ade34f2017-09-15 13:00:47 -070080 }
Colin Cross83bb3162018-06-25 15:48:06 -070081 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion())
Colin Cross43f08db2018-11-12 10:13:39 -080082 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
Nan Zhanged19fc32017-10-19 13:06:22 -070083 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Crosscb933592017-11-22 13:49:43 -080084
85 if library.jacocoReportClassesFile != nil {
86 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String())
87 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080088
Jiyong Park1be96912018-05-28 18:02:19 +090089 if len(library.exportedSdkLibs) != 0 {
90 fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " "))
91 }
92
Vladimir Marko0975ee02019-04-02 10:29:55 +010093 if len(library.additionalCheckedModules) != 0 {
94 fmt.Fprintln(w, "LOCAL_ADDITIONAL_CHECKED_MODULE +=", strings.Join(library.additionalCheckedModules.Strings(), " "))
95 }
96
Colin Cross5ab4e6d2017-11-22 16:20:45 -080097 // Temporary hack: export sources used to compile framework.jar to Make
98 // to be used for droiddoc
99 // TODO(ccross): remove this once droiddoc is in soong
Mathew Inwoodebe29ce2018-09-04 14:26:19 +0100100 if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") {
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800101 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " "))
102 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " "))
103 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700104 },
105 },
Colin Cross92430102017-10-09 14:59:32 -0700106 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
107 android.WriteAndroidMkData(w, data)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900108 library.AndroidMkHostDex(w, name, data)
Colin Cross92430102017-10-09 14:59:32 -0700109 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700110 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700111}
112
Paul Duffin42df1442019-03-20 12:45:53 +0000113// Called for modules that are a component of a test suite.
114func testSuiteComponent(w io.Writer, test_suites []string) {
115 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
116 if len(test_suites) > 0 {
117 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
118 strings.Join(test_suites, " "))
119 } else {
120 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
121 }
122}
123
Colin Cross05638fc2018-04-09 18:40:24 -0700124func (j *Test) AndroidMk() android.AndroidMkData {
125 data := j.Library.AndroidMk()
126 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000127 testSuiteComponent(w, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700128 if j.testConfig != nil {
129 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700130 }
Colin Cross05638fc2018-04-09 18:40:24 -0700131 })
132
Colin Crossd96ca352018-08-10 16:06:24 -0700133 androidMkWriteTestData(j.data, &data)
134
Colin Cross05638fc2018-04-09 18:40:24 -0700135 return data
136}
137
Paul Duffin42df1442019-03-20 12:45:53 +0000138func (j *TestHelperLibrary) AndroidMk() android.AndroidMkData {
139 data := j.Library.AndroidMk()
140 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
141 testSuiteComponent(w, j.testHelperLibraryProperties.Test_suites)
142 })
143
144 return data
145}
146
Colin Crossa18e9cf2017-08-10 17:00:19 -0700147func (prebuilt *Import) AndroidMk() android.AndroidMkData {
148 return android.AndroidMkData{
149 Class: "JAVA_LIBRARIES",
150 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700151 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700152 Extra: []android.AndroidMkExtraFunc{
153 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700154 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700155 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800156 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700157 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700158 },
159 },
160 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700161}
Colin Cross10a03492017-08-10 17:09:43 -0700162
Colin Cross42be7612019-02-21 18:12:14 -0800163func (prebuilt *DexImport) AndroidMk() android.AndroidMkData {
164 return android.AndroidMkData{
165 Class: "JAVA_LIBRARIES",
166 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
167 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
168 Extra: []android.AndroidMkExtraFunc{
169 func(w io.Writer, outputFile android.Path) {
170 if prebuilt.dexJarFile != nil {
171 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", prebuilt.dexJarFile.String())
172 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
173 // boot_jars_package_check.mk can check dex jars.
174 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.dexJarFile.String())
175 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.dexJarFile.String())
176 }
177 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
178 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", prebuilt.dexpreopter.builtInstalled)
179 }
180 },
181 },
182 }
183}
184
Colin Crossfabb6082018-02-20 17:22:23 -0800185func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
186 return android.AndroidMkData{
187 Class: "JAVA_LIBRARIES",
188 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
189 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
190 Extra: []android.AndroidMkExtraFunc{
191 func(w io.Writer, outputFile android.Path) {
192 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossfabb6082018-02-20 17:22:23 -0800193 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800194 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800195 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
196 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
Colin Cross66f78822018-05-02 12:58:28 -0700197 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
Colin Cross10f7c4a2018-05-23 10:59:28 -0700198 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700199 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800200 },
201 },
202 }
203}
204
Colin Cross10a03492017-08-10 17:09:43 -0700205func (binary *Binary) AndroidMk() android.AndroidMkData {
Colin Cross10a03492017-08-10 17:09:43 -0700206
Colin Cross6b4a32d2017-12-05 13:42:45 -0800207 if !binary.isWrapperVariant {
208 return android.AndroidMkData{
209 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700210 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800211 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Cross331a1212018-08-15 20:40:52 -0700212 Extra: []android.AndroidMkExtraFunc{
213 func(w io.Writer, outputFile android.Path) {
214 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800215 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
Colin Cross12fc2af2019-01-14 12:35:45 -0800216 if binary.dexJarFile != nil {
217 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
218 }
219 if len(binary.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800220 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800221 }
Colin Cross331a1212018-08-15 20:40:52 -0700222 },
223 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800224 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
225 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700226
Colin Cross6b4a32d2017-12-05 13:42:45 -0800227 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
228 },
229 }
230 } else {
231 return android.AndroidMkData{
232 Class: "EXECUTABLES",
233 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
234 Extra: []android.AndroidMkExtraFunc{
235 func(w io.Writer, outputFile android.Path) {
236 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
237 },
238 },
239 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
240 android.WriteAndroidMkData(w, data)
241
242 // Ensure that the wrapper script timestamp is always updated when the jar is updated
243 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
244 fmt.Fprintln(w, "jar_installed_module :=")
245 },
246 }
Colin Cross10a03492017-08-10 17:09:43 -0700247 }
248}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800249
250func (app *AndroidApp) AndroidMk() android.AndroidMkData {
251 return android.AndroidMkData{
252 Class: "APPS",
253 OutputFile: android.OptionalPathForPath(app.outputFile),
254 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
255 Extra: []android.AndroidMkExtraFunc{
256 func(w io.Writer, outputFile android.Path) {
Jaewoong Jung9109d722019-01-30 13:13:52 -0800257 // TODO(jungjw): This, outputting two LOCAL_MODULE lines, works, but is not ideal. Find a better solution.
258 if app.Name() != app.installApkName {
259 fmt.Fprintln(w, "# Overridden by PRODUCT_PACKAGE_NAME_OVERRIDES")
260 fmt.Fprintln(w, "LOCAL_MODULE :=", app.installApkName)
261 }
Colin Cross70798562017-12-13 22:42:59 -0800262 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
263 if app.dexJarFile != nil {
264 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800265 }
Colin Cross331a1212018-08-15 20:40:52 -0700266 if app.implementationAndResourcesJar != nil {
267 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800268 }
269 if app.headerJarFile != nil {
270 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
271 }
Colin Crossf6237212018-10-29 23:14:58 -0700272 if app.bundleFile != nil {
273 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
274 }
Colin Cross70798562017-12-13 22:42:59 -0800275 if app.jacocoReportClassesFile != nil {
276 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
277 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800278 if app.proguardDictionary != nil {
279 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
280 }
Colin Cross70798562017-12-13 22:42:59 -0800281
282 if app.Name() == "framework-res" {
283 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
284 // Make base_rules.mk not put framework-res in a subdirectory called
285 // framework_res.
286 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
287 }
288
Anton Hansson53c88442019-03-18 15:53:16 +0000289 filterRRO := func(filter overlayType) android.Paths {
290 var paths android.Paths
291 for _, d := range app.rroDirs {
292 if d.overlayType == filter {
293 paths = append(paths, d.path)
294 }
295 }
Colin Crossa140bb02018-04-17 10:52:26 -0700296 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
297 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000298 return android.ReversePaths(paths)
299 }
300 deviceRRODirs := filterRRO(device)
301 if len(deviceRRODirs) > 0 {
302 fmt.Fprintln(w, "LOCAL_SOONG_DEVICE_RRO_DIRS :=", strings.Join(deviceRRODirs.Strings(), " "))
303 }
304 productRRODirs := filterRRO(product)
305 if len(productRRODirs) > 0 {
306 fmt.Fprintln(w, "LOCAL_SOONG_PRODUCT_RRO_DIRS :=", strings.Join(productRRODirs.Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800307 }
308
309 if Bool(app.appProperties.Export_package_resources) {
310 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
311 }
312
313 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
314
Colin Cross16056062017-12-13 22:46:28 -0800315 if Bool(app.appProperties.Privileged) {
316 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
317 }
Colin Crosse1731a52017-12-14 11:22:55 -0800318
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900319 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jaewoong Jung9109d722019-01-30 13:13:52 -0800320 if overriddenPkgs := app.getOverriddenPackages(); len(overriddenPkgs) > 0 {
321 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES :=", strings.Join(overriddenPkgs, " "))
Jason Monkd4122be2018-08-10 09:33:36 -0400322 }
Colin Crossa4f08812018-10-02 22:03:40 -0700323
324 for _, jniLib := range app.installJniLibs {
325 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
326 }
Colin Cross43f08db2018-11-12 10:13:39 -0800327 if len(app.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800328 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800329 }
Colin Crosse560c4a2019-03-19 16:03:11 -0700330 for _, split := range app.aapt.splits {
331 install := "$(LOCAL_MODULE_PATH)/" + strings.TrimSuffix(app.installApkName, ".apk") + split.suffix + ".apk"
332 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED +=", split.path.String()+":"+install)
333 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800334 },
335 },
336 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700337}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800338
Jaewoong Jung9109d722019-01-30 13:13:52 -0800339func (a *AndroidApp) getOverriddenPackages() []string {
340 var overridden []string
341 if len(a.appProperties.Overrides) > 0 {
342 overridden = append(overridden, a.appProperties.Overrides...)
343 }
344 if a.Name() != a.installApkName {
345 overridden = append(overridden, a.Name())
346 }
347 return overridden
348}
349
Colin Crossae5caf52018-05-22 11:11:52 -0700350func (a *AndroidTest) AndroidMk() android.AndroidMkData {
351 data := a.AndroidApp.AndroidMk()
352 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000353 testSuiteComponent(w, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700354 if a.testConfig != nil {
355 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700356 }
Colin Crossae5caf52018-05-22 11:11:52 -0700357 })
Colin Crossd96ca352018-08-10 16:06:24 -0700358 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700359
360 return data
361}
362
Colin Cross252fc6f2018-10-04 15:22:03 -0700363func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
364 data := a.AndroidApp.AndroidMk()
365 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000366 testSuiteComponent(w, a.appTestHelperAppProperties.Test_suites)
Colin Cross252fc6f2018-10-04 15:22:03 -0700367 })
368
369 return data
370}
371
Colin Crossa97c5d32018-03-28 14:58:31 -0700372func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
373 data := a.Library.AndroidMk()
374
375 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700376 if a.aarFile != nil {
377 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
378 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700379 if a.proguardDictionary != nil {
380 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
381 }
382
383 if a.Name() == "framework-res" {
384 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
385 // Make base_rules.mk not put framework-res in a subdirectory called
386 // framework_res.
387 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
388 }
389
390 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700391 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700392 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700393 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
394 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700395 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700396 })
397
398 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800399}
Nan Zhang581fd212018-01-10 16:06:12 -0800400
401func (jd *Javadoc) AndroidMk() android.AndroidMkData {
402 return android.AndroidMkData{
403 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800404 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700405 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800406 Extra: []android.AndroidMkExtraFunc{
407 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700408 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800409 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
410 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800411 if jd.stubsSrcJar != nil {
412 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800413 }
414 },
415 },
416 }
417}
418
419func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
420 return android.AndroidMkData{
421 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800422 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700423 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800424 Extra: []android.AndroidMkExtraFunc{
425 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700426 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800427 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
428 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800429 if ddoc.Javadoc.stubsSrcJar != nil {
430 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800431 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700432 if ddoc.checkCurrentApiTimestamp != nil {
433 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
434 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
435 ddoc.checkCurrentApiTimestamp.String())
436
437 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900438 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700439 ddoc.checkCurrentApiTimestamp.String())
440
441 fmt.Fprintln(w, ".PHONY: droidcore")
442 fmt.Fprintln(w, "droidcore: checkapi")
443 }
444 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700445 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700446 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
447 ddoc.updateCurrentApiTimestamp.String())
448
449 fmt.Fprintln(w, ".PHONY: update-api")
450 fmt.Fprintln(w, "update-api:",
451 ddoc.updateCurrentApiTimestamp.String())
452 }
453 if ddoc.checkLastReleasedApiTimestamp != nil {
454 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
455 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
456 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100457
Adrian Roos62e34b92019-01-30 19:51:39 +0100458 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100459 fmt.Fprintln(w, ".PHONY: checkapi")
460 fmt.Fprintln(w, "checkapi:",
461 ddoc.checkLastReleasedApiTimestamp.String())
462
463 fmt.Fprintln(w, ".PHONY: droidcore")
464 fmt.Fprintln(w, "droidcore: checkapi")
465 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700466 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700467 apiFilePrefix := "INTERNAL_PLATFORM_"
468 if String(ddoc.properties.Api_tag_name) != "" {
469 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
470 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700471 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700472 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
473 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100474 if ddoc.dexApiFile != nil {
475 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
476 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700477 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700478 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
479 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700480 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700481 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
482 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700483 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700484 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
485 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700486 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100487 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
488 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700489 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700490 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
491 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700492 if ddoc.proguardFile != nil {
493 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
494 }
Nan Zhang581fd212018-01-10 16:06:12 -0800495 },
496 },
497 }
498}
Colin Crossd96ca352018-08-10 16:06:24 -0700499
Nan Zhang1598a9e2018-09-04 17:14:32 -0700500func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
501 return android.AndroidMkData{
502 Class: "JAVA_LIBRARIES",
503 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
504 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
505 Extra: []android.AndroidMkExtraFunc{
506 func(w io.Writer, outputFile android.Path) {
507 if dstubs.Javadoc.stubsSrcJar != nil {
508 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
509 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700510 if dstubs.apiVersionsXml != nil {
511 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
512 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700513 if dstubs.annotationsZip != nil {
514 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
515 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700516 if dstubs.jdiffDocZip != nil {
517 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
518 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700519 if dstubs.checkCurrentApiTimestamp != nil {
520 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
521 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
522 dstubs.checkCurrentApiTimestamp.String())
523
524 fmt.Fprintln(w, ".PHONY: checkapi")
525 fmt.Fprintln(w, "checkapi:",
526 dstubs.checkCurrentApiTimestamp.String())
527
528 fmt.Fprintln(w, ".PHONY: droidcore")
529 fmt.Fprintln(w, "droidcore: checkapi")
530 }
531 if dstubs.updateCurrentApiTimestamp != nil {
532 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
533 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
534 dstubs.updateCurrentApiTimestamp.String())
535
536 fmt.Fprintln(w, ".PHONY: update-api")
537 fmt.Fprintln(w, "update-api:",
538 dstubs.updateCurrentApiTimestamp.String())
539 }
540 if dstubs.checkLastReleasedApiTimestamp != nil {
541 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
542 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
543 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100544
Adrian Roos62e34b92019-01-30 19:51:39 +0100545 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100546 fmt.Fprintln(w, ".PHONY: checkapi")
547 fmt.Fprintln(w, "checkapi:",
548 dstubs.checkLastReleasedApiTimestamp.String())
549
550 fmt.Fprintln(w, ".PHONY: droidcore")
551 fmt.Fprintln(w, "droidcore: checkapi")
552 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700553 }
Pete Gillin581d6082018-10-22 15:55:04 +0100554 if dstubs.checkNullabilityWarningsTimestamp != nil {
555 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
556 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
557 dstubs.checkNullabilityWarningsTimestamp.String())
558
559 fmt.Fprintln(w, ".PHONY:", "droidcore")
560 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
561 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700562 apiFilePrefix := "INTERNAL_PLATFORM_"
563 if String(dstubs.properties.Api_tag_name) != "" {
564 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
565 }
566 if dstubs.apiFile != nil {
567 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
568 }
569 if dstubs.dexApiFile != nil {
570 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
571 }
572 if dstubs.privateApiFile != nil {
573 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
574 }
575 if dstubs.privateDexApiFile != nil {
576 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
577 }
578 if dstubs.removedApiFile != nil {
579 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
580 }
581 if dstubs.removedDexApiFile != nil {
582 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
583 }
584 if dstubs.exactApiFile != nil {
585 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
586 }
587 },
588 },
589 }
590}
591
Colin Crossd96ca352018-08-10 16:06:24 -0700592func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
593 var testFiles []string
594 for _, d := range data {
595 testFiles = append(testFiles, d.String()+":"+d.Rel())
596 }
597 if len(testFiles) > 0 {
598 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
599 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
600 })
601 }
602}