blob: 7aa9a6198a1fd5a1652a7cc36c2759acf64bcacb [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 }
Sundong Ahn054b19a2018-10-19 13:46:09 +090050 fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
51 }
52}
53
Colin Crossa18e9cf2017-08-10 17:00:19 -070054func (library *Library) AndroidMk() android.AndroidMkData {
55 return android.AndroidMkData{
56 Class: "JAVA_LIBRARIES",
Colin Cross43f08db2018-11-12 10:13:39 -080057 OutputFile: android.OptionalPathForPath(library.outputFile),
Colin Cross53499412017-09-07 13:20:25 -070058 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -070059 Extra: []android.AndroidMkExtraFunc{
60 func(w io.Writer, outputFile android.Path) {
Colin Cross5beccee2017-12-07 15:28:59 -080061 if len(library.logtagsSrcs) > 0 {
62 var logtags []string
63 for _, l := range library.logtagsSrcs {
64 logtags = append(logtags, l.Rel())
65 }
66 fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
67 }
68
Colin Cross9ae1b922018-06-26 17:59:05 -070069 if library.installFile == nil {
Colin Cross2c429dc2017-08-31 16:45:16 -070070 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
71 }
Colin Cross6ade34f2017-09-15 13:00:47 -070072 if library.dexJarFile != nil {
73 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -080074 }
75 if len(library.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -080076 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", library.dexpreopter.builtInstalled)
Colin Cross6ade34f2017-09-15 13:00:47 -070077 }
Colin Cross83bb3162018-06-25 15:48:06 -070078 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion())
Colin Cross43f08db2018-11-12 10:13:39 -080079 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String())
Nan Zhanged19fc32017-10-19 13:06:22 -070080 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String())
Colin Crosscb933592017-11-22 13:49:43 -080081
82 if library.jacocoReportClassesFile != nil {
83 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String())
84 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -080085
Jiyong Park1be96912018-05-28 18:02:19 +090086 if len(library.exportedSdkLibs) != 0 {
87 fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " "))
88 }
89
Vladimir Marko0975ee02019-04-02 10:29:55 +010090 if len(library.additionalCheckedModules) != 0 {
91 fmt.Fprintln(w, "LOCAL_ADDITIONAL_CHECKED_MODULE +=", strings.Join(library.additionalCheckedModules.Strings(), " "))
92 }
93
Colin Cross5ab4e6d2017-11-22 16:20:45 -080094 // Temporary hack: export sources used to compile framework.jar to Make
95 // to be used for droiddoc
96 // TODO(ccross): remove this once droiddoc is in soong
Mathew Inwoodebe29ce2018-09-04 14:26:19 +010097 if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") {
Colin Cross5ab4e6d2017-11-22 16:20:45 -080098 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " "))
99 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " "))
100 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700101 },
102 },
Colin Cross92430102017-10-09 14:59:32 -0700103 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
104 android.WriteAndroidMkData(w, data)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900105 library.AndroidMkHostDex(w, name, data)
Colin Cross92430102017-10-09 14:59:32 -0700106 },
Colin Crossa18e9cf2017-08-10 17:00:19 -0700107 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700108}
109
Paul Duffin42df1442019-03-20 12:45:53 +0000110// Called for modules that are a component of a test suite.
111func testSuiteComponent(w io.Writer, test_suites []string) {
112 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
113 if len(test_suites) > 0 {
114 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
115 strings.Join(test_suites, " "))
116 } else {
117 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
118 }
119}
120
Colin Cross05638fc2018-04-09 18:40:24 -0700121func (j *Test) AndroidMk() android.AndroidMkData {
122 data := j.Library.AndroidMk()
123 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000124 testSuiteComponent(w, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700125 if j.testConfig != nil {
126 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700127 }
Colin Cross05638fc2018-04-09 18:40:24 -0700128 })
129
Colin Crossd96ca352018-08-10 16:06:24 -0700130 androidMkWriteTestData(j.data, &data)
131
Colin Cross05638fc2018-04-09 18:40:24 -0700132 return data
133}
134
Paul Duffin42df1442019-03-20 12:45:53 +0000135func (j *TestHelperLibrary) AndroidMk() android.AndroidMkData {
136 data := j.Library.AndroidMk()
137 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
138 testSuiteComponent(w, j.testHelperLibraryProperties.Test_suites)
139 })
140
141 return data
142}
143
Colin Crossa18e9cf2017-08-10 17:00:19 -0700144func (prebuilt *Import) AndroidMk() android.AndroidMkData {
145 return android.AndroidMkData{
146 Class: "JAVA_LIBRARIES",
147 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700148 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700149 Extra: []android.AndroidMkExtraFunc{
150 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700151 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700152 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800153 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700154 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700155 },
156 },
157 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700158}
Colin Cross10a03492017-08-10 17:09:43 -0700159
Colin Cross42be7612019-02-21 18:12:14 -0800160func (prebuilt *DexImport) AndroidMk() android.AndroidMkData {
161 return android.AndroidMkData{
162 Class: "JAVA_LIBRARIES",
163 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
164 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
165 Extra: []android.AndroidMkExtraFunc{
166 func(w io.Writer, outputFile android.Path) {
167 if prebuilt.dexJarFile != nil {
168 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", prebuilt.dexJarFile.String())
169 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
170 // boot_jars_package_check.mk can check dex jars.
171 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.dexJarFile.String())
172 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.dexJarFile.String())
173 }
174 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
175 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", prebuilt.dexpreopter.builtInstalled)
176 }
177 },
178 },
179 }
180}
181
Colin Crossfabb6082018-02-20 17:22:23 -0800182func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
183 return android.AndroidMkData{
184 Class: "JAVA_LIBRARIES",
185 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
186 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
187 Extra: []android.AndroidMkExtraFunc{
188 func(w io.Writer, outputFile android.Path) {
189 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossfabb6082018-02-20 17:22:23 -0800190 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800191 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800192 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
193 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
Colin Cross66f78822018-05-02 12:58:28 -0700194 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
Colin Cross10f7c4a2018-05-23 10:59:28 -0700195 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700196 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800197 },
198 },
199 }
200}
201
Colin Cross10a03492017-08-10 17:09:43 -0700202func (binary *Binary) AndroidMk() android.AndroidMkData {
Colin Cross10a03492017-08-10 17:09:43 -0700203
Colin Cross6b4a32d2017-12-05 13:42:45 -0800204 if !binary.isWrapperVariant {
205 return android.AndroidMkData{
206 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700207 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800208 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Cross331a1212018-08-15 20:40:52 -0700209 Extra: []android.AndroidMkExtraFunc{
210 func(w io.Writer, outputFile android.Path) {
211 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800212 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
Colin Cross12fc2af2019-01-14 12:35:45 -0800213 if binary.dexJarFile != nil {
214 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
215 }
216 if len(binary.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800217 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800218 }
Colin Cross331a1212018-08-15 20:40:52 -0700219 },
220 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800221 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
222 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700223
Colin Cross6b4a32d2017-12-05 13:42:45 -0800224 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
225 },
226 }
227 } else {
228 return android.AndroidMkData{
229 Class: "EXECUTABLES",
230 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
231 Extra: []android.AndroidMkExtraFunc{
232 func(w io.Writer, outputFile android.Path) {
233 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
234 },
235 },
236 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
237 android.WriteAndroidMkData(w, data)
238
239 // Ensure that the wrapper script timestamp is always updated when the jar is updated
240 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
241 fmt.Fprintln(w, "jar_installed_module :=")
242 },
243 }
Colin Cross10a03492017-08-10 17:09:43 -0700244 }
245}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800246
247func (app *AndroidApp) AndroidMk() android.AndroidMkData {
248 return android.AndroidMkData{
249 Class: "APPS",
250 OutputFile: android.OptionalPathForPath(app.outputFile),
251 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
252 Extra: []android.AndroidMkExtraFunc{
253 func(w io.Writer, outputFile android.Path) {
Jaewoong Jung9109d722019-01-30 13:13:52 -0800254 // TODO(jungjw): This, outputting two LOCAL_MODULE lines, works, but is not ideal. Find a better solution.
255 if app.Name() != app.installApkName {
256 fmt.Fprintln(w, "# Overridden by PRODUCT_PACKAGE_NAME_OVERRIDES")
257 fmt.Fprintln(w, "LOCAL_MODULE :=", app.installApkName)
258 }
Colin Cross70798562017-12-13 22:42:59 -0800259 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
260 if app.dexJarFile != nil {
261 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800262 }
Colin Cross331a1212018-08-15 20:40:52 -0700263 if app.implementationAndResourcesJar != nil {
264 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800265 }
266 if app.headerJarFile != nil {
267 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
268 }
Colin Crossf6237212018-10-29 23:14:58 -0700269 if app.bundleFile != nil {
270 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
271 }
Colin Cross70798562017-12-13 22:42:59 -0800272 if app.jacocoReportClassesFile != nil {
273 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
274 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800275 if app.proguardDictionary != nil {
276 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
277 }
Colin Cross70798562017-12-13 22:42:59 -0800278
279 if app.Name() == "framework-res" {
280 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
281 // Make base_rules.mk not put framework-res in a subdirectory called
282 // framework_res.
283 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
284 }
285
Anton Hansson53c88442019-03-18 15:53:16 +0000286 filterRRO := func(filter overlayType) android.Paths {
287 var paths android.Paths
288 for _, d := range app.rroDirs {
289 if d.overlayType == filter {
290 paths = append(paths, d.path)
291 }
292 }
Colin Crossa140bb02018-04-17 10:52:26 -0700293 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
294 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000295 return android.ReversePaths(paths)
296 }
297 deviceRRODirs := filterRRO(device)
298 if len(deviceRRODirs) > 0 {
299 fmt.Fprintln(w, "LOCAL_SOONG_DEVICE_RRO_DIRS :=", strings.Join(deviceRRODirs.Strings(), " "))
300 }
301 productRRODirs := filterRRO(product)
302 if len(productRRODirs) > 0 {
303 fmt.Fprintln(w, "LOCAL_SOONG_PRODUCT_RRO_DIRS :=", strings.Join(productRRODirs.Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800304 }
305
306 if Bool(app.appProperties.Export_package_resources) {
307 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
308 }
309
310 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
311
Colin Cross16056062017-12-13 22:46:28 -0800312 if Bool(app.appProperties.Privileged) {
313 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
314 }
Colin Crosse1731a52017-12-14 11:22:55 -0800315
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900316 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jaewoong Jung9109d722019-01-30 13:13:52 -0800317 if overriddenPkgs := app.getOverriddenPackages(); len(overriddenPkgs) > 0 {
318 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES :=", strings.Join(overriddenPkgs, " "))
Jason Monkd4122be2018-08-10 09:33:36 -0400319 }
Colin Crossa4f08812018-10-02 22:03:40 -0700320
321 for _, jniLib := range app.installJniLibs {
322 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
323 }
Colin Cross43f08db2018-11-12 10:13:39 -0800324 if len(app.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800325 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800326 }
Colin Crosse560c4a2019-03-19 16:03:11 -0700327 for _, split := range app.aapt.splits {
328 install := "$(LOCAL_MODULE_PATH)/" + strings.TrimSuffix(app.installApkName, ".apk") + split.suffix + ".apk"
329 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED +=", split.path.String()+":"+install)
330 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800331 },
332 },
333 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700334}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800335
Jaewoong Jung9109d722019-01-30 13:13:52 -0800336func (a *AndroidApp) getOverriddenPackages() []string {
337 var overridden []string
338 if len(a.appProperties.Overrides) > 0 {
339 overridden = append(overridden, a.appProperties.Overrides...)
340 }
341 if a.Name() != a.installApkName {
342 overridden = append(overridden, a.Name())
343 }
344 return overridden
345}
346
Colin Crossae5caf52018-05-22 11:11:52 -0700347func (a *AndroidTest) AndroidMk() android.AndroidMkData {
348 data := a.AndroidApp.AndroidMk()
349 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000350 testSuiteComponent(w, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700351 if a.testConfig != nil {
352 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700353 }
Colin Crossae5caf52018-05-22 11:11:52 -0700354 })
Colin Crossd96ca352018-08-10 16:06:24 -0700355 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700356
357 return data
358}
359
Colin Cross252fc6f2018-10-04 15:22:03 -0700360func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
361 data := a.AndroidApp.AndroidMk()
362 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000363 testSuiteComponent(w, a.appTestHelperAppProperties.Test_suites)
Colin Cross252fc6f2018-10-04 15:22:03 -0700364 })
365
366 return data
367}
368
Colin Crossa97c5d32018-03-28 14:58:31 -0700369func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
370 data := a.Library.AndroidMk()
371
372 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700373 if a.aarFile != nil {
374 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
375 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700376 if a.proguardDictionary != nil {
377 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
378 }
379
380 if a.Name() == "framework-res" {
381 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
382 // Make base_rules.mk not put framework-res in a subdirectory called
383 // framework_res.
384 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
385 }
386
387 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700388 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Cross90c25c62019-04-19 16:22:57 -0700389 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.mergedManifestFile.String())
Colin Cross89c31582018-04-30 15:55:11 -0700390 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
391 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700392 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700393 })
394
395 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800396}
Nan Zhang581fd212018-01-10 16:06:12 -0800397
398func (jd *Javadoc) AndroidMk() android.AndroidMkData {
399 return android.AndroidMkData{
400 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800401 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700402 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800403 Extra: []android.AndroidMkExtraFunc{
404 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700405 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800406 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
407 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800408 if jd.stubsSrcJar != nil {
409 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800410 }
411 },
412 },
413 }
414}
415
416func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
417 return android.AndroidMkData{
418 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800419 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700420 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800421 Extra: []android.AndroidMkExtraFunc{
422 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700423 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800424 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
425 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800426 if ddoc.Javadoc.stubsSrcJar != nil {
427 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800428 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700429 if ddoc.checkCurrentApiTimestamp != nil {
430 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
431 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
432 ddoc.checkCurrentApiTimestamp.String())
433
434 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900435 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700436 ddoc.checkCurrentApiTimestamp.String())
437
438 fmt.Fprintln(w, ".PHONY: droidcore")
439 fmt.Fprintln(w, "droidcore: checkapi")
440 }
441 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700442 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700443 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
444 ddoc.updateCurrentApiTimestamp.String())
445
446 fmt.Fprintln(w, ".PHONY: update-api")
447 fmt.Fprintln(w, "update-api:",
448 ddoc.updateCurrentApiTimestamp.String())
449 }
450 if ddoc.checkLastReleasedApiTimestamp != nil {
451 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
452 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
453 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100454
Adrian Roos62e34b92019-01-30 19:51:39 +0100455 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100456 fmt.Fprintln(w, ".PHONY: checkapi")
457 fmt.Fprintln(w, "checkapi:",
458 ddoc.checkLastReleasedApiTimestamp.String())
459
460 fmt.Fprintln(w, ".PHONY: droidcore")
461 fmt.Fprintln(w, "droidcore: checkapi")
462 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700463 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700464 apiFilePrefix := "INTERNAL_PLATFORM_"
465 if String(ddoc.properties.Api_tag_name) != "" {
466 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
467 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700468 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700469 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
470 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100471 if ddoc.dexApiFile != nil {
472 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
473 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700474 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700475 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
476 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700477 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700478 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
479 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700480 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700481 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
482 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700483 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100484 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
485 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700486 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700487 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
488 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700489 if ddoc.proguardFile != nil {
490 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
491 }
Nan Zhang581fd212018-01-10 16:06:12 -0800492 },
493 },
494 }
495}
Colin Crossd96ca352018-08-10 16:06:24 -0700496
Nan Zhang1598a9e2018-09-04 17:14:32 -0700497func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
498 return android.AndroidMkData{
499 Class: "JAVA_LIBRARIES",
500 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
501 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
502 Extra: []android.AndroidMkExtraFunc{
503 func(w io.Writer, outputFile android.Path) {
504 if dstubs.Javadoc.stubsSrcJar != nil {
505 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
506 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700507 if dstubs.apiVersionsXml != nil {
508 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
509 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700510 if dstubs.annotationsZip != nil {
511 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
512 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700513 if dstubs.jdiffDocZip != nil {
514 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
515 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700516 if dstubs.checkCurrentApiTimestamp != nil {
517 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
518 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
519 dstubs.checkCurrentApiTimestamp.String())
520
521 fmt.Fprintln(w, ".PHONY: checkapi")
522 fmt.Fprintln(w, "checkapi:",
523 dstubs.checkCurrentApiTimestamp.String())
524
525 fmt.Fprintln(w, ".PHONY: droidcore")
526 fmt.Fprintln(w, "droidcore: checkapi")
527 }
528 if dstubs.updateCurrentApiTimestamp != nil {
529 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
530 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
531 dstubs.updateCurrentApiTimestamp.String())
532
533 fmt.Fprintln(w, ".PHONY: update-api")
534 fmt.Fprintln(w, "update-api:",
535 dstubs.updateCurrentApiTimestamp.String())
536 }
537 if dstubs.checkLastReleasedApiTimestamp != nil {
538 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
539 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
540 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100541
Adrian Roos62e34b92019-01-30 19:51:39 +0100542 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100543 fmt.Fprintln(w, ".PHONY: checkapi")
544 fmt.Fprintln(w, "checkapi:",
545 dstubs.checkLastReleasedApiTimestamp.String())
546
547 fmt.Fprintln(w, ".PHONY: droidcore")
548 fmt.Fprintln(w, "droidcore: checkapi")
549 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700550 }
Pete Gillin581d6082018-10-22 15:55:04 +0100551 if dstubs.checkNullabilityWarningsTimestamp != nil {
552 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
553 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
554 dstubs.checkNullabilityWarningsTimestamp.String())
555
556 fmt.Fprintln(w, ".PHONY:", "droidcore")
557 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
558 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700559 apiFilePrefix := "INTERNAL_PLATFORM_"
560 if String(dstubs.properties.Api_tag_name) != "" {
561 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
562 }
563 if dstubs.apiFile != nil {
564 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
565 }
566 if dstubs.dexApiFile != nil {
567 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
568 }
569 if dstubs.privateApiFile != nil {
570 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
571 }
572 if dstubs.privateDexApiFile != nil {
573 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
574 }
575 if dstubs.removedApiFile != nil {
576 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
577 }
578 if dstubs.removedDexApiFile != nil {
579 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
580 }
581 if dstubs.exactApiFile != nil {
582 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
583 }
584 },
585 },
586 }
587}
588
Colin Crossd96ca352018-08-10 16:06:24 -0700589func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
590 var testFiles []string
591 for _, d := range data {
592 testFiles = append(testFiles, d.String()+":"+d.Rel())
593 }
594 if len(testFiles) > 0 {
595 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
596 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
597 })
598 }
599}