blob: d2e0f2e63003d73213967598c47d1f1ba7535ddb [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())
Sasha Smundakb6d23052019-04-01 18:37:36 -070041 android.WriteRequiredModulesSettings(w, data)
Sundong Ahn054b19a2018-10-19 13:46:09 +090042 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
Vladimir Marko0975ee02019-04-02 10:29:55 +010082 if len(library.additionalCheckedModules) != 0 {
83 fmt.Fprintln(w, "LOCAL_ADDITIONAL_CHECKED_MODULE +=", strings.Join(library.additionalCheckedModules.Strings(), " "))
84 }
85
Colin Cross5ab4e6d2017-11-22 16:20:45 -080086 // Temporary hack: export sources used to compile framework.jar to Make
87 // to be used for droiddoc
88 // TODO(ccross): remove this once droiddoc is in soong
Mathew Inwoodebe29ce2018-09-04 14:26:19 +010089 if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") {
Colin Cross5ab4e6d2017-11-22 16:20:45 -080090 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " "))
91 fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " "))
92 }
Colin Crossa18e9cf2017-08-10 17:00:19 -070093 },
94 },
Colin Cross92430102017-10-09 14:59:32 -070095 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
96 android.WriteAndroidMkData(w, data)
Sundong Ahn054b19a2018-10-19 13:46:09 +090097 library.AndroidMkHostDex(w, name, data)
Colin Cross92430102017-10-09 14:59:32 -070098 },
Colin Crossa18e9cf2017-08-10 17:00:19 -070099 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700100}
101
Paul Duffin42df1442019-03-20 12:45:53 +0000102// Called for modules that are a component of a test suite.
103func testSuiteComponent(w io.Writer, test_suites []string) {
104 fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests")
105 if len(test_suites) > 0 {
106 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
107 strings.Join(test_suites, " "))
108 } else {
109 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite")
110 }
111}
112
Colin Cross05638fc2018-04-09 18:40:24 -0700113func (j *Test) AndroidMk() android.AndroidMkData {
114 data := j.Library.AndroidMk()
115 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000116 testSuiteComponent(w, j.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700117 if j.testConfig != nil {
118 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700119 }
Colin Cross05638fc2018-04-09 18:40:24 -0700120 })
121
Colin Crossd96ca352018-08-10 16:06:24 -0700122 androidMkWriteTestData(j.data, &data)
123
Colin Cross05638fc2018-04-09 18:40:24 -0700124 return data
125}
126
Paul Duffin42df1442019-03-20 12:45:53 +0000127func (j *TestHelperLibrary) AndroidMk() android.AndroidMkData {
128 data := j.Library.AndroidMk()
129 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
130 testSuiteComponent(w, j.testHelperLibraryProperties.Test_suites)
131 })
132
133 return data
134}
135
Colin Crossa18e9cf2017-08-10 17:00:19 -0700136func (prebuilt *Import) AndroidMk() android.AndroidMkData {
137 return android.AndroidMkData{
138 Class: "JAVA_LIBRARIES",
139 OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Colin Cross53499412017-09-07 13:20:25 -0700140 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Crossa18e9cf2017-08-10 17:00:19 -0700141 Extra: []android.AndroidMkExtraFunc{
142 func(w io.Writer, outputFile android.Path) {
Colin Crossff3ae9d2018-04-10 16:15:18 -0700143 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable))
Nan Zhanged19fc32017-10-19 13:06:22 -0700144 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800145 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700146 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossa18e9cf2017-08-10 17:00:19 -0700147 },
148 },
149 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700150}
Colin Cross10a03492017-08-10 17:09:43 -0700151
Colin Cross42be7612019-02-21 18:12:14 -0800152func (prebuilt *DexImport) AndroidMk() android.AndroidMkData {
153 return android.AndroidMkData{
154 Class: "JAVA_LIBRARIES",
155 OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
156 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
157 Extra: []android.AndroidMkExtraFunc{
158 func(w io.Writer, outputFile android.Path) {
159 if prebuilt.dexJarFile != nil {
160 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", prebuilt.dexJarFile.String())
161 // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until
162 // boot_jars_package_check.mk can check dex jars.
163 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.dexJarFile.String())
164 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.dexJarFile.String())
165 }
166 if len(prebuilt.dexpreopter.builtInstalled) > 0 {
167 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", prebuilt.dexpreopter.builtInstalled)
168 }
169 },
170 },
171 }
172}
173
Colin Crossfabb6082018-02-20 17:22:23 -0800174func (prebuilt *AARImport) AndroidMk() android.AndroidMkData {
175 return android.AndroidMkData{
176 Class: "JAVA_LIBRARIES",
177 OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
178 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
179 Extra: []android.AndroidMkExtraFunc{
180 func(w io.Writer, outputFile android.Path) {
181 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossfabb6082018-02-20 17:22:23 -0800182 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800183 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String())
Colin Crossfabb6082018-02-20 17:22:23 -0800184 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String())
185 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String())
Colin Cross66f78822018-05-02 12:58:28 -0700186 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String())
Colin Cross10f7c4a2018-05-23 10:59:28 -0700187 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String())
Colin Cross83bb3162018-06-25 15:48:06 -0700188 fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion())
Colin Crossfabb6082018-02-20 17:22:23 -0800189 },
190 },
191 }
192}
193
Colin Cross10a03492017-08-10 17:09:43 -0700194func (binary *Binary) AndroidMk() android.AndroidMkData {
Colin Cross10a03492017-08-10 17:09:43 -0700195
Colin Cross6b4a32d2017-12-05 13:42:45 -0800196 if !binary.isWrapperVariant {
197 return android.AndroidMkData{
198 Class: "JAVA_LIBRARIES",
Colin Cross331a1212018-08-15 20:40:52 -0700199 OutputFile: android.OptionalPathForPath(binary.outputFile),
Colin Cross6b4a32d2017-12-05 13:42:45 -0800200 Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Colin Cross331a1212018-08-15 20:40:52 -0700201 Extra: []android.AndroidMkExtraFunc{
202 func(w io.Writer, outputFile android.Path) {
203 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String())
Colin Cross43f08db2018-11-12 10:13:39 -0800204 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String())
Colin Cross12fc2af2019-01-14 12:35:45 -0800205 if binary.dexJarFile != nil {
206 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String())
207 }
208 if len(binary.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800209 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", binary.dexpreopter.builtInstalled)
Colin Cross12fc2af2019-01-14 12:35:45 -0800210 }
Colin Cross331a1212018-08-15 20:40:52 -0700211 },
212 },
Colin Cross6b4a32d2017-12-05 13:42:45 -0800213 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
214 android.WriteAndroidMkData(w, data)
Colin Cross19655682017-09-07 17:00:22 -0700215
Colin Cross6b4a32d2017-12-05 13:42:45 -0800216 fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
217 },
218 }
219 } else {
220 return android.AndroidMkData{
221 Class: "EXECUTABLES",
222 OutputFile: android.OptionalPathForPath(binary.wrapperFile),
223 Extra: []android.AndroidMkExtraFunc{
224 func(w io.Writer, outputFile android.Path) {
225 fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
226 },
227 },
228 Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
229 android.WriteAndroidMkData(w, data)
230
231 // Ensure that the wrapper script timestamp is always updated when the jar is updated
232 fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)")
233 fmt.Fprintln(w, "jar_installed_module :=")
234 },
235 }
Colin Cross10a03492017-08-10 17:09:43 -0700236 }
237}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800238
239func (app *AndroidApp) AndroidMk() android.AndroidMkData {
240 return android.AndroidMkData{
241 Class: "APPS",
242 OutputFile: android.OptionalPathForPath(app.outputFile),
243 Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
244 Extra: []android.AndroidMkExtraFunc{
245 func(w io.Writer, outputFile android.Path) {
Jaewoong Jung9109d722019-01-30 13:13:52 -0800246 // TODO(jungjw): This, outputting two LOCAL_MODULE lines, works, but is not ideal. Find a better solution.
247 if app.Name() != app.installApkName {
248 fmt.Fprintln(w, "# Overridden by PRODUCT_PACKAGE_NAME_OVERRIDES")
249 fmt.Fprintln(w, "LOCAL_MODULE :=", app.installApkName)
250 }
Colin Cross70798562017-12-13 22:42:59 -0800251 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String())
252 if app.dexJarFile != nil {
253 fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String())
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800254 }
Colin Cross331a1212018-08-15 20:40:52 -0700255 if app.implementationAndResourcesJar != nil {
256 fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String())
Colin Cross5dfabfb2017-12-14 13:19:01 -0800257 }
258 if app.headerJarFile != nil {
259 fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String())
260 }
Colin Crossf6237212018-10-29 23:14:58 -0700261 if app.bundleFile != nil {
262 fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String())
263 }
Colin Cross70798562017-12-13 22:42:59 -0800264 if app.jacocoReportClassesFile != nil {
265 fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String())
266 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800267 if app.proguardDictionary != nil {
268 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String())
269 }
Colin Cross70798562017-12-13 22:42:59 -0800270
271 if app.Name() == "framework-res" {
272 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
273 // Make base_rules.mk not put framework-res in a subdirectory called
274 // framework_res.
275 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
276 }
277
Anton Hansson53c88442019-03-18 15:53:16 +0000278 filterRRO := func(filter overlayType) android.Paths {
279 var paths android.Paths
280 for _, d := range app.rroDirs {
281 if d.overlayType == filter {
282 paths = append(paths, d.path)
283 }
284 }
Colin Crossa140bb02018-04-17 10:52:26 -0700285 // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make
286 // expects it in LOCAL_RESOURCE_DIRS order (high to low priority).
Anton Hansson53c88442019-03-18 15:53:16 +0000287 return android.ReversePaths(paths)
288 }
289 deviceRRODirs := filterRRO(device)
290 if len(deviceRRODirs) > 0 {
291 fmt.Fprintln(w, "LOCAL_SOONG_DEVICE_RRO_DIRS :=", strings.Join(deviceRRODirs.Strings(), " "))
292 }
293 productRRODirs := filterRRO(product)
294 if len(productRRODirs) > 0 {
295 fmt.Fprintln(w, "LOCAL_SOONG_PRODUCT_RRO_DIRS :=", strings.Join(productRRODirs.Strings(), " "))
Colin Cross70798562017-12-13 22:42:59 -0800296 }
297
298 if Bool(app.appProperties.Export_package_resources) {
299 fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true")
300 }
301
302 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String())
303
Colin Cross16056062017-12-13 22:46:28 -0800304 if Bool(app.appProperties.Privileged) {
305 fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true")
306 }
Colin Crosse1731a52017-12-14 11:22:55 -0800307
Jiyong Parkc00cbd92018-10-30 21:20:05 +0900308 fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String())
Jaewoong Jung9109d722019-01-30 13:13:52 -0800309 if overriddenPkgs := app.getOverriddenPackages(); len(overriddenPkgs) > 0 {
310 fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES :=", strings.Join(overriddenPkgs, " "))
Jason Monkd4122be2018-08-10 09:33:36 -0400311 }
Colin Crossa4f08812018-10-02 22:03:40 -0700312
313 for _, jniLib := range app.installJniLibs {
314 fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name)
315 }
Colin Cross43f08db2018-11-12 10:13:39 -0800316 if len(app.dexpreopter.builtInstalled) > 0 {
Colin Crossdeabb942019-02-11 14:11:09 -0800317 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", app.dexpreopter.builtInstalled)
Colin Cross43f08db2018-11-12 10:13:39 -0800318 }
Colin Crosse560c4a2019-03-19 16:03:11 -0700319 for _, split := range app.aapt.splits {
320 install := "$(LOCAL_MODULE_PATH)/" + strings.TrimSuffix(app.installApkName, ".apk") + split.suffix + ".apk"
321 fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED +=", split.path.String()+":"+install)
322 }
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800323 },
324 },
325 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700326}
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800327
Jaewoong Jung9109d722019-01-30 13:13:52 -0800328func (a *AndroidApp) getOverriddenPackages() []string {
329 var overridden []string
330 if len(a.appProperties.Overrides) > 0 {
331 overridden = append(overridden, a.appProperties.Overrides...)
332 }
333 if a.Name() != a.installApkName {
334 overridden = append(overridden, a.Name())
335 }
336 return overridden
337}
338
Colin Crossae5caf52018-05-22 11:11:52 -0700339func (a *AndroidTest) AndroidMk() android.AndroidMkData {
340 data := a.AndroidApp.AndroidMk()
341 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000342 testSuiteComponent(w, a.testProperties.Test_suites)
Colin Cross303e21f2018-08-07 16:49:25 -0700343 if a.testConfig != nil {
344 fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700345 }
Colin Crossae5caf52018-05-22 11:11:52 -0700346 })
Colin Crossd96ca352018-08-10 16:06:24 -0700347 androidMkWriteTestData(a.data, &data)
Colin Crossae5caf52018-05-22 11:11:52 -0700348
349 return data
350}
351
Colin Cross252fc6f2018-10-04 15:22:03 -0700352func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData {
353 data := a.AndroidApp.AndroidMk()
354 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Paul Duffin42df1442019-03-20 12:45:53 +0000355 testSuiteComponent(w, a.appTestHelperAppProperties.Test_suites)
Colin Cross252fc6f2018-10-04 15:22:03 -0700356 })
357
358 return data
359}
360
Colin Crossa97c5d32018-03-28 14:58:31 -0700361func (a *AndroidLibrary) AndroidMk() android.AndroidMkData {
362 data := a.Library.AndroidMk()
363
364 data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) {
Colin Crossa54974c2018-10-29 23:15:37 -0700365 if a.aarFile != nil {
366 fmt.Fprintln(w, "LOCAL_SOONG_AAR :=", a.aarFile.String())
367 }
Colin Crossa97c5d32018-03-28 14:58:31 -0700368 if a.proguardDictionary != nil {
369 fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String())
370 }
371
372 if a.Name() == "framework-res" {
373 fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)")
374 // Make base_rules.mk not put framework-res in a subdirectory called
375 // framework_res.
376 fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true")
377 }
378
379 fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String())
Colin Cross66f78822018-05-02 12:58:28 -0700380 fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String())
Colin Crossa97c5d32018-03-28 14:58:31 -0700381 fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String())
Colin Cross89c31582018-04-30 15:55:11 -0700382 fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=",
383 strings.Join(a.exportedProguardFlagFiles.Strings(), " "))
Colin Crossa97c5d32018-03-28 14:58:31 -0700384 fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
Colin Crossa97c5d32018-03-28 14:58:31 -0700385 })
386
387 return data
Colin Cross5ab4e6d2017-11-22 16:20:45 -0800388}
Nan Zhang581fd212018-01-10 16:06:12 -0800389
390func (jd *Javadoc) AndroidMk() android.AndroidMkData {
391 return android.AndroidMkData{
392 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800393 OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700394 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800395 Extra: []android.AndroidMkExtraFunc{
396 func(w io.Writer, outputFile android.Path) {
Colin Cross38b40df2018-04-10 16:14:46 -0700397 if BoolDefault(jd.properties.Installable, true) {
Nan Zhang581fd212018-01-10 16:06:12 -0800398 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String())
399 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800400 if jd.stubsSrcJar != nil {
401 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800402 }
403 },
404 },
405 }
406}
407
408func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData {
409 return android.AndroidMkData{
410 Class: "JAVA_LIBRARIES",
Nan Zhangccff0f72018-03-08 17:26:16 -0800411 OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Colin Cross5fa9d6f2018-08-08 21:44:48 -0700412 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
Nan Zhang581fd212018-01-10 16:06:12 -0800413 Extra: []android.AndroidMkExtraFunc{
414 func(w io.Writer, outputFile android.Path) {
Nan Zhang1598a9e2018-09-04 17:14:32 -0700415 if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil {
Nan Zhang581fd212018-01-10 16:06:12 -0800416 fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String())
417 }
Nan Zhangccff0f72018-03-08 17:26:16 -0800418 if ddoc.Javadoc.stubsSrcJar != nil {
419 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String())
Nan Zhang581fd212018-01-10 16:06:12 -0800420 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700421 if ddoc.checkCurrentApiTimestamp != nil {
422 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api")
423 fmt.Fprintln(w, ddoc.Name()+"-check-current-api:",
424 ddoc.checkCurrentApiTimestamp.String())
425
426 fmt.Fprintln(w, ".PHONY: checkapi")
Jiyong Parkeeb8a642018-05-12 22:21:20 +0900427 fmt.Fprintln(w, "checkapi:",
Nan Zhang61819ce2018-05-04 18:49:16 -0700428 ddoc.checkCurrentApiTimestamp.String())
429
430 fmt.Fprintln(w, ".PHONY: droidcore")
431 fmt.Fprintln(w, "droidcore: checkapi")
432 }
433 if ddoc.updateCurrentApiTimestamp != nil {
Dan Willemsena03c43a2018-07-24 13:00:52 -0700434 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api")
Nan Zhang61819ce2018-05-04 18:49:16 -0700435 fmt.Fprintln(w, ddoc.Name()+"-update-current-api:",
436 ddoc.updateCurrentApiTimestamp.String())
437
438 fmt.Fprintln(w, ".PHONY: update-api")
439 fmt.Fprintln(w, "update-api:",
440 ddoc.updateCurrentApiTimestamp.String())
441 }
442 if ddoc.checkLastReleasedApiTimestamp != nil {
443 fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api")
444 fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:",
445 ddoc.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100446
Adrian Roos62e34b92019-01-30 19:51:39 +0100447 if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100448 fmt.Fprintln(w, ".PHONY: checkapi")
449 fmt.Fprintln(w, "checkapi:",
450 ddoc.checkLastReleasedApiTimestamp.String())
451
452 fmt.Fprintln(w, ".PHONY: droidcore")
453 fmt.Fprintln(w, "droidcore: checkapi")
454 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700455 }
Nan Zhang28c68b92018-03-13 16:17:01 -0700456 apiFilePrefix := "INTERNAL_PLATFORM_"
457 if String(ddoc.properties.Api_tag_name) != "" {
458 apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_"
459 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700460 if ddoc.apiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700461 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String())
462 }
David Brazdilfbe4cc32018-05-31 13:56:46 +0100463 if ddoc.dexApiFile != nil {
464 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String())
465 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700466 if ddoc.privateApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700467 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String())
468 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700469 if ddoc.privateDexApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700470 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String())
471 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700472 if ddoc.removedApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700473 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String())
474 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700475 if ddoc.removedDexApiFile != nil {
David Brazdilaac0c3c2018-04-24 16:23:29 +0100476 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String())
477 }
Nan Zhang61819ce2018-05-04 18:49:16 -0700478 if ddoc.exactApiFile != nil {
Nan Zhang28c68b92018-03-13 16:17:01 -0700479 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String())
480 }
Nan Zhang66dc2362018-08-14 20:41:04 -0700481 if ddoc.proguardFile != nil {
482 fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String())
483 }
Nan Zhang581fd212018-01-10 16:06:12 -0800484 },
485 },
486 }
487}
Colin Crossd96ca352018-08-10 16:06:24 -0700488
Nan Zhang1598a9e2018-09-04 17:14:32 -0700489func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData {
490 return android.AndroidMkData{
491 Class: "JAVA_LIBRARIES",
492 OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
493 Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
494 Extra: []android.AndroidMkExtraFunc{
495 func(w io.Writer, outputFile android.Path) {
496 if dstubs.Javadoc.stubsSrcJar != nil {
497 fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String())
498 }
Nan Zhangd23ac692018-09-18 10:41:33 -0700499 if dstubs.apiVersionsXml != nil {
500 fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String())
501 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700502 if dstubs.annotationsZip != nil {
503 fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String())
504 }
Nan Zhang71bbe632018-09-17 14:32:21 -0700505 if dstubs.jdiffDocZip != nil {
506 fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String())
507 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700508 if dstubs.checkCurrentApiTimestamp != nil {
509 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api")
510 fmt.Fprintln(w, dstubs.Name()+"-check-current-api:",
511 dstubs.checkCurrentApiTimestamp.String())
512
513 fmt.Fprintln(w, ".PHONY: checkapi")
514 fmt.Fprintln(w, "checkapi:",
515 dstubs.checkCurrentApiTimestamp.String())
516
517 fmt.Fprintln(w, ".PHONY: droidcore")
518 fmt.Fprintln(w, "droidcore: checkapi")
519 }
520 if dstubs.updateCurrentApiTimestamp != nil {
521 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api")
522 fmt.Fprintln(w, dstubs.Name()+"-update-current-api:",
523 dstubs.updateCurrentApiTimestamp.String())
524
525 fmt.Fprintln(w, ".PHONY: update-api")
526 fmt.Fprintln(w, "update-api:",
527 dstubs.updateCurrentApiTimestamp.String())
528 }
529 if dstubs.checkLastReleasedApiTimestamp != nil {
530 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api")
531 fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:",
532 dstubs.checkLastReleasedApiTimestamp.String())
Adrian Roose3fe4812019-01-23 14:51:55 +0100533
Adrian Roos62e34b92019-01-30 19:51:39 +0100534 if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" {
Adrian Roose3fe4812019-01-23 14:51:55 +0100535 fmt.Fprintln(w, ".PHONY: checkapi")
536 fmt.Fprintln(w, "checkapi:",
537 dstubs.checkLastReleasedApiTimestamp.String())
538
539 fmt.Fprintln(w, ".PHONY: droidcore")
540 fmt.Fprintln(w, "droidcore: checkapi")
541 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700542 }
Pete Gillin581d6082018-10-22 15:55:04 +0100543 if dstubs.checkNullabilityWarningsTimestamp != nil {
544 fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings")
545 fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:",
546 dstubs.checkNullabilityWarningsTimestamp.String())
547
548 fmt.Fprintln(w, ".PHONY:", "droidcore")
549 fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings")
550 }
Nan Zhang1598a9e2018-09-04 17:14:32 -0700551 apiFilePrefix := "INTERNAL_PLATFORM_"
552 if String(dstubs.properties.Api_tag_name) != "" {
553 apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_"
554 }
555 if dstubs.apiFile != nil {
556 fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String())
557 }
558 if dstubs.dexApiFile != nil {
559 fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String())
560 }
561 if dstubs.privateApiFile != nil {
562 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String())
563 }
564 if dstubs.privateDexApiFile != nil {
565 fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String())
566 }
567 if dstubs.removedApiFile != nil {
568 fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String())
569 }
570 if dstubs.removedDexApiFile != nil {
571 fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String())
572 }
573 if dstubs.exactApiFile != nil {
574 fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String())
575 }
576 },
577 },
578 }
579}
580
Colin Crossd96ca352018-08-10 16:06:24 -0700581func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) {
582 var testFiles []string
583 for _, d := range data {
584 testFiles = append(testFiles, d.String()+":"+d.Rel())
585 }
586 if len(testFiles) > 0 {
587 ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
588 fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " "))
589 })
590 }
591}