Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package java |
| 16 | |
| 17 | import ( |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 18 | "fmt" |
| 19 | "io" |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 20 | "strings" |
Colin Cross | 74d73e2 | 2017-08-02 11:05:49 -0700 | [diff] [blame] | 21 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 22 | "android/soong/android" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 23 | ) |
| 24 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 25 | func (library *Library) AndroidMk() android.AndroidMkData { |
| 26 | return android.AndroidMkData{ |
| 27 | Class: "JAVA_LIBRARIES", |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 28 | OutputFile: android.OptionalPathForPath(library.implementationAndResourcesJar), |
Colin Cross | 5349941 | 2017-09-07 13:20:25 -0700 | [diff] [blame] | 29 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 30 | Extra: []android.AndroidMkExtraFunc{ |
| 31 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 32 | if len(library.logtagsSrcs) > 0 { |
| 33 | var logtags []string |
| 34 | for _, l := range library.logtagsSrcs { |
| 35 | logtags = append(logtags, l.Rel()) |
| 36 | } |
| 37 | fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " ")) |
| 38 | } |
| 39 | |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 40 | if library.installFile == nil { |
Colin Cross | 2c429dc | 2017-08-31 16:45:16 -0700 | [diff] [blame] | 41 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 42 | } |
Colin Cross | 6ade34f | 2017-09-15 13:00:47 -0700 | [diff] [blame] | 43 | if library.dexJarFile != nil { |
| 44 | fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String()) |
Colin Cross | 1bd8780 | 2017-12-05 15:31:19 -0800 | [diff] [blame] | 45 | if library.deviceProperties.Dex_preopt.Enabled != nil { |
| 46 | fmt.Fprintln(w, "LOCAL_DEX_PREOPT :=", *library.deviceProperties.Dex_preopt.Enabled) |
| 47 | } |
| 48 | if library.deviceProperties.Dex_preopt.App_image != nil { |
| 49 | fmt.Fprintln(w, "LOCAL_DEX_PREOPT_APP_IMAGE :=", *library.deviceProperties.Dex_preopt.App_image) |
| 50 | } |
| 51 | if library.deviceProperties.Dex_preopt.Profile_guided != nil { |
| 52 | fmt.Fprintln(w, "LOCAL_DEX_PREOPT_GENERATE_PROFILE :=", *library.deviceProperties.Dex_preopt.Profile_guided) |
| 53 | } |
| 54 | if library.deviceProperties.Dex_preopt.Profile != nil { |
| 55 | fmt.Fprintln(w, "LOCAL_DEX_PREOPT_GENERATE_PROFILE := true") |
| 56 | fmt.Fprintln(w, "LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING := $(LOCAL_PATH)/"+*library.deviceProperties.Dex_preopt.Profile) |
Colin Cross | a22116e | 2017-10-19 14:18:58 -0700 | [diff] [blame] | 57 | } |
Colin Cross | 6ade34f | 2017-09-15 13:00:47 -0700 | [diff] [blame] | 58 | } |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 59 | fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.sdkVersion()) |
Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 60 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String()) |
Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 61 | |
| 62 | if library.jacocoReportClassesFile != nil { |
| 63 | fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", library.jacocoReportClassesFile.String()) |
| 64 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 65 | |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 66 | if len(library.exportedSdkLibs) != 0 { |
| 67 | fmt.Fprintln(w, "LOCAL_EXPORT_SDK_LIBRARIES :=", strings.Join(library.exportedSdkLibs, " ")) |
| 68 | } |
| 69 | |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 70 | // Temporary hack: export sources used to compile framework.jar to Make |
| 71 | // to be used for droiddoc |
| 72 | // TODO(ccross): remove this once droiddoc is in soong |
Mathew Inwood | ebe29ce | 2018-09-04 14:26:19 +0100 | [diff] [blame] | 73 | if (library.Name() == "framework") || (library.Name() == "framework-annotation-proc") { |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 74 | fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCS :=", strings.Join(library.compiledJavaSrcs.Strings(), " ")) |
| 75 | fmt.Fprintln(w, "SOONG_FRAMEWORK_SRCJARS :=", strings.Join(library.compiledSrcJars.Strings(), " ")) |
| 76 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 77 | }, |
| 78 | }, |
Colin Cross | 9243010 | 2017-10-09 14:59:32 -0700 | [diff] [blame] | 79 | Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
| 80 | android.WriteAndroidMkData(w, data) |
| 81 | |
Colin Cross | ff3ae9d | 2018-04-10 16:15:18 -0700 | [diff] [blame] | 82 | if Bool(library.deviceProperties.Hostdex) && !library.Host() { |
Colin Cross | 9243010 | 2017-10-09 14:59:32 -0700 | [diff] [blame] | 83 | fmt.Fprintln(w, "include $(CLEAR_VARS)") |
| 84 | fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex") |
| 85 | fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") |
| 86 | fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES") |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 87 | fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.implementationAndResourcesJar.String()) |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 88 | if library.installFile == nil { |
Colin Cross | 9243010 | 2017-10-09 14:59:32 -0700 | [diff] [blame] | 89 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 90 | } |
| 91 | if library.dexJarFile != nil { |
| 92 | fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String()) |
| 93 | } |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 94 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String()) |
Colin Cross | 9243010 | 2017-10-09 14:59:32 -0700 | [diff] [blame] | 95 | fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " ")) |
| 96 | fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk") |
| 97 | } |
| 98 | }, |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 99 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 102 | func (j *Test) AndroidMk() android.AndroidMkData { |
| 103 | data := j.Library.AndroidMk() |
| 104 | data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) { |
| 105 | fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests") |
| 106 | if len(j.testProperties.Test_suites) > 0 { |
| 107 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
| 108 | strings.Join(j.testProperties.Test_suites, " ")) |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 109 | } else { |
| 110 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite") |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 111 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 112 | if j.testConfig != nil { |
| 113 | fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", j.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 114 | } |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 115 | }) |
| 116 | |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 117 | androidMkWriteTestData(j.data, &data) |
| 118 | |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 119 | return data |
| 120 | } |
| 121 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 122 | func (prebuilt *Import) AndroidMk() android.AndroidMkData { |
| 123 | return android.AndroidMkData{ |
| 124 | Class: "JAVA_LIBRARIES", |
| 125 | OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile), |
Colin Cross | 5349941 | 2017-09-07 13:20:25 -0700 | [diff] [blame] | 126 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 127 | Extra: []android.AndroidMkExtraFunc{ |
| 128 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | ff3ae9d | 2018-04-10 16:15:18 -0700 | [diff] [blame] | 129 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable)) |
Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 130 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String()) |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 131 | fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion()) |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 132 | }, |
| 133 | }, |
| 134 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 135 | } |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 136 | |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 137 | func (prebuilt *AARImport) AndroidMk() android.AndroidMkData { |
| 138 | return android.AndroidMkData{ |
| 139 | Class: "JAVA_LIBRARIES", |
| 140 | OutputFile: android.OptionalPathForPath(prebuilt.classpathFile), |
| 141 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
| 142 | Extra: []android.AndroidMkExtraFunc{ |
| 143 | func(w io.Writer, outputFile android.Path) { |
| 144 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 145 | fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false") |
| 146 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String()) |
| 147 | fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String()) |
| 148 | fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String()) |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 149 | fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String()) |
Colin Cross | 10f7c4a | 2018-05-23 10:59:28 -0700 | [diff] [blame] | 150 | fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String()) |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 151 | fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion()) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 152 | }, |
| 153 | }, |
| 154 | } |
| 155 | } |
| 156 | |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 157 | func (binary *Binary) AndroidMk() android.AndroidMkData { |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 158 | |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 159 | if !binary.isWrapperVariant { |
| 160 | return android.AndroidMkData{ |
| 161 | Class: "JAVA_LIBRARIES", |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 162 | OutputFile: android.OptionalPathForPath(binary.outputFile), |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 163 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 164 | Extra: []android.AndroidMkExtraFunc{ |
| 165 | func(w io.Writer, outputFile android.Path) { |
| 166 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String()) |
| 167 | }, |
| 168 | }, |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 169 | Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
| 170 | android.WriteAndroidMkData(w, data) |
Colin Cross | 1965568 | 2017-09-07 17:00:22 -0700 | [diff] [blame] | 171 | |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 172 | fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)") |
| 173 | }, |
| 174 | } |
| 175 | } else { |
| 176 | return android.AndroidMkData{ |
| 177 | Class: "EXECUTABLES", |
| 178 | OutputFile: android.OptionalPathForPath(binary.wrapperFile), |
| 179 | Extra: []android.AndroidMkExtraFunc{ |
| 180 | func(w io.Writer, outputFile android.Path) { |
| 181 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") |
| 182 | }, |
| 183 | }, |
| 184 | Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
| 185 | android.WriteAndroidMkData(w, data) |
| 186 | |
| 187 | // Ensure that the wrapper script timestamp is always updated when the jar is updated |
| 188 | fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)") |
| 189 | fmt.Fprintln(w, "jar_installed_module :=") |
| 190 | }, |
| 191 | } |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 192 | } |
| 193 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 194 | |
| 195 | func (app *AndroidApp) AndroidMk() android.AndroidMkData { |
| 196 | return android.AndroidMkData{ |
| 197 | Class: "APPS", |
| 198 | OutputFile: android.OptionalPathForPath(app.outputFile), |
| 199 | Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", |
| 200 | Extra: []android.AndroidMkExtraFunc{ |
| 201 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 202 | fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", app.exportPackage.String()) |
| 203 | if app.dexJarFile != nil { |
| 204 | fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", app.dexJarFile.String()) |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 205 | } |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 206 | if app.implementationAndResourcesJar != nil { |
| 207 | fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", app.implementationAndResourcesJar.String()) |
Colin Cross | 5dfabfb | 2017-12-14 13:19:01 -0800 | [diff] [blame] | 208 | } |
| 209 | if app.headerJarFile != nil { |
| 210 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", app.headerJarFile.String()) |
| 211 | } |
Colin Cross | f623721 | 2018-10-29 23:14:58 -0700 | [diff] [blame^] | 212 | if app.bundleFile != nil { |
| 213 | fmt.Fprintln(w, "LOCAL_SOONG_BUNDLE :=", app.bundleFile.String()) |
| 214 | } |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 215 | if app.jacocoReportClassesFile != nil { |
| 216 | fmt.Fprintln(w, "LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=", app.jacocoReportClassesFile.String()) |
| 217 | } |
Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 218 | if app.proguardDictionary != nil { |
| 219 | fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", app.proguardDictionary.String()) |
| 220 | } |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 221 | |
| 222 | if app.Name() == "framework-res" { |
| 223 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)") |
| 224 | // Make base_rules.mk not put framework-res in a subdirectory called |
| 225 | // framework_res. |
| 226 | fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true") |
| 227 | } |
| 228 | |
| 229 | if len(app.rroDirs) > 0 { |
Colin Cross | a140bb0 | 2018-04-17 10:52:26 -0700 | [diff] [blame] | 230 | // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make |
| 231 | // expects it in LOCAL_RESOURCE_DIRS order (high to low priority). |
| 232 | fmt.Fprintln(w, "LOCAL_SOONG_RRO_DIRS :=", strings.Join(android.ReversePaths(app.rroDirs).Strings(), " ")) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | if Bool(app.appProperties.Export_package_resources) { |
| 236 | fmt.Fprintln(w, "LOCAL_EXPORT_PACKAGE_RESOURCES := true") |
| 237 | } |
| 238 | |
| 239 | fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", app.manifestPath.String()) |
| 240 | |
Colin Cross | 1605606 | 2017-12-13 22:46:28 -0800 | [diff] [blame] | 241 | if Bool(app.appProperties.Privileged) { |
| 242 | fmt.Fprintln(w, "LOCAL_PRIVILEGED_MODULE := true") |
| 243 | } |
Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 244 | |
Jiyong Park | c00cbd9 | 2018-10-30 21:20:05 +0900 | [diff] [blame] | 245 | fmt.Fprintln(w, "LOCAL_CERTIFICATE :=", app.certificate.Pem.String()) |
Jason Monk | d4122be | 2018-08-10 09:33:36 -0400 | [diff] [blame] | 246 | if len(app.appProperties.Overrides) > 0 { |
| 247 | fmt.Fprintln(w, "LOCAL_OVERRIDES_PACKAGES := "+strings.Join(app.appProperties.Overrides, " ")) |
| 248 | } |
Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 249 | |
| 250 | for _, jniLib := range app.installJniLibs { |
| 251 | fmt.Fprintln(w, "LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), "+=", jniLib.name) |
| 252 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 253 | }, |
| 254 | }, |
| 255 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 256 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 257 | |
Colin Cross | ae5caf5 | 2018-05-22 11:11:52 -0700 | [diff] [blame] | 258 | func (a *AndroidTest) AndroidMk() android.AndroidMkData { |
| 259 | data := a.AndroidApp.AndroidMk() |
| 260 | data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) { |
| 261 | fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests") |
| 262 | if len(a.testProperties.Test_suites) > 0 { |
| 263 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
| 264 | strings.Join(a.testProperties.Test_suites, " ")) |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 265 | } else { |
| 266 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite") |
Colin Cross | ae5caf5 | 2018-05-22 11:11:52 -0700 | [diff] [blame] | 267 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 268 | if a.testConfig != nil { |
| 269 | fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=", a.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 270 | } |
Colin Cross | ae5caf5 | 2018-05-22 11:11:52 -0700 | [diff] [blame] | 271 | }) |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 272 | androidMkWriteTestData(a.data, &data) |
Colin Cross | ae5caf5 | 2018-05-22 11:11:52 -0700 | [diff] [blame] | 273 | |
| 274 | return data |
| 275 | } |
| 276 | |
Colin Cross | 252fc6f | 2018-10-04 15:22:03 -0700 | [diff] [blame] | 277 | func (a *AndroidTestHelperApp) AndroidMk() android.AndroidMkData { |
| 278 | data := a.AndroidApp.AndroidMk() |
| 279 | data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) { |
| 280 | fmt.Fprintln(w, "LOCAL_MODULE_TAGS := tests") |
| 281 | if len(a.appTestHelperAppProperties.Test_suites) > 0 { |
| 282 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", |
| 283 | strings.Join(a.appTestHelperAppProperties.Test_suites, " ")) |
| 284 | } else { |
| 285 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE := null-suite") |
| 286 | } |
| 287 | }) |
| 288 | |
| 289 | return data |
| 290 | } |
| 291 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 292 | func (a *AndroidLibrary) AndroidMk() android.AndroidMkData { |
| 293 | data := a.Library.AndroidMk() |
| 294 | |
| 295 | data.Extra = append(data.Extra, func(w io.Writer, outputFile android.Path) { |
| 296 | if a.proguardDictionary != nil { |
| 297 | fmt.Fprintln(w, "LOCAL_SOONG_PROGUARD_DICT :=", a.proguardDictionary.String()) |
| 298 | } |
| 299 | |
| 300 | if a.Name() == "framework-res" { |
| 301 | fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_JAVA_LIBRARIES)") |
| 302 | // Make base_rules.mk not put framework-res in a subdirectory called |
| 303 | // framework_res. |
| 304 | fmt.Fprintln(w, "LOCAL_NO_STANDARD_LIBRARIES := true") |
| 305 | } |
| 306 | |
| 307 | fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", a.exportPackage.String()) |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 308 | fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", a.extraAaptPackagesFile.String()) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 309 | fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", a.manifestPath.String()) |
Colin Cross | 89c3158 | 2018-04-30 15:55:11 -0700 | [diff] [blame] | 310 | fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", |
| 311 | strings.Join(a.exportedProguardFlagFiles.Strings(), " ")) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 312 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
| 313 | fmt.Fprintln(w, "LOCAL_DEX_PREOPT := false") |
| 314 | }) |
| 315 | |
| 316 | return data |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 317 | } |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 318 | |
| 319 | func (jd *Javadoc) AndroidMk() android.AndroidMkData { |
| 320 | return android.AndroidMkData{ |
| 321 | Class: "JAVA_LIBRARIES", |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 322 | OutputFile: android.OptionalPathForPath(jd.stubsSrcJar), |
Colin Cross | 5fa9d6f | 2018-08-08 21:44:48 -0700 | [diff] [blame] | 323 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 324 | Extra: []android.AndroidMkExtraFunc{ |
| 325 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 326 | if BoolDefault(jd.properties.Installable, true) { |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 327 | fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String()) |
| 328 | } |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 329 | if jd.stubsSrcJar != nil { |
| 330 | fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String()) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 331 | } |
| 332 | }, |
| 333 | }, |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData { |
| 338 | return android.AndroidMkData{ |
| 339 | Class: "JAVA_LIBRARIES", |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 340 | OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar), |
Colin Cross | 5fa9d6f | 2018-08-08 21:44:48 -0700 | [diff] [blame] | 341 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 342 | Extra: []android.AndroidMkExtraFunc{ |
| 343 | func(w io.Writer, outputFile android.Path) { |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 344 | if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil { |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 345 | fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String()) |
| 346 | } |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 347 | if ddoc.Javadoc.stubsSrcJar != nil { |
| 348 | fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String()) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 349 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 350 | if ddoc.checkCurrentApiTimestamp != nil { |
| 351 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api") |
| 352 | fmt.Fprintln(w, ddoc.Name()+"-check-current-api:", |
| 353 | ddoc.checkCurrentApiTimestamp.String()) |
| 354 | |
| 355 | fmt.Fprintln(w, ".PHONY: checkapi") |
Jiyong Park | eeb8a64 | 2018-05-12 22:21:20 +0900 | [diff] [blame] | 356 | fmt.Fprintln(w, "checkapi:", |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 357 | ddoc.checkCurrentApiTimestamp.String()) |
| 358 | |
| 359 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 360 | fmt.Fprintln(w, "droidcore: checkapi") |
| 361 | } |
| 362 | if ddoc.updateCurrentApiTimestamp != nil { |
Dan Willemsen | a03c43a | 2018-07-24 13:00:52 -0700 | [diff] [blame] | 363 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api") |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 364 | fmt.Fprintln(w, ddoc.Name()+"-update-current-api:", |
| 365 | ddoc.updateCurrentApiTimestamp.String()) |
| 366 | |
| 367 | fmt.Fprintln(w, ".PHONY: update-api") |
| 368 | fmt.Fprintln(w, "update-api:", |
| 369 | ddoc.updateCurrentApiTimestamp.String()) |
| 370 | } |
| 371 | if ddoc.checkLastReleasedApiTimestamp != nil { |
| 372 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api") |
| 373 | fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:", |
| 374 | ddoc.checkLastReleasedApiTimestamp.String()) |
| 375 | } |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 376 | apiFilePrefix := "INTERNAL_PLATFORM_" |
| 377 | if String(ddoc.properties.Api_tag_name) != "" { |
| 378 | apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_" |
| 379 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 380 | if ddoc.apiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 381 | fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String()) |
| 382 | } |
David Brazdil | fbe4cc3 | 2018-05-31 13:56:46 +0100 | [diff] [blame] | 383 | if ddoc.dexApiFile != nil { |
| 384 | fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String()) |
| 385 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 386 | if ddoc.privateApiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 387 | fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String()) |
| 388 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 389 | if ddoc.privateDexApiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 390 | fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String()) |
| 391 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 392 | if ddoc.removedApiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 393 | fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String()) |
| 394 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 395 | if ddoc.removedDexApiFile != nil { |
David Brazdil | aac0c3c | 2018-04-24 16:23:29 +0100 | [diff] [blame] | 396 | fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String()) |
| 397 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 398 | if ddoc.exactApiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 399 | fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String()) |
| 400 | } |
Nan Zhang | 66dc236 | 2018-08-14 20:41:04 -0700 | [diff] [blame] | 401 | if ddoc.proguardFile != nil { |
| 402 | fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String()) |
| 403 | } |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 404 | }, |
| 405 | }, |
| 406 | } |
| 407 | } |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 408 | |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 409 | func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData { |
| 410 | return android.AndroidMkData{ |
| 411 | Class: "JAVA_LIBRARIES", |
| 412 | OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar), |
| 413 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
| 414 | Extra: []android.AndroidMkExtraFunc{ |
| 415 | func(w io.Writer, outputFile android.Path) { |
| 416 | if dstubs.Javadoc.stubsSrcJar != nil { |
| 417 | fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String()) |
| 418 | } |
Nan Zhang | d23ac69 | 2018-09-18 10:41:33 -0700 | [diff] [blame] | 419 | if dstubs.apiVersionsXml != nil { |
| 420 | fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String()) |
| 421 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 422 | if dstubs.annotationsZip != nil { |
| 423 | fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String()) |
| 424 | } |
Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 425 | if dstubs.jdiffDocZip != nil { |
| 426 | fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String()) |
| 427 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 428 | if dstubs.checkCurrentApiTimestamp != nil { |
| 429 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api") |
| 430 | fmt.Fprintln(w, dstubs.Name()+"-check-current-api:", |
| 431 | dstubs.checkCurrentApiTimestamp.String()) |
| 432 | |
| 433 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 434 | fmt.Fprintln(w, "checkapi:", |
| 435 | dstubs.checkCurrentApiTimestamp.String()) |
| 436 | |
| 437 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 438 | fmt.Fprintln(w, "droidcore: checkapi") |
| 439 | } |
| 440 | if dstubs.updateCurrentApiTimestamp != nil { |
| 441 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api") |
| 442 | fmt.Fprintln(w, dstubs.Name()+"-update-current-api:", |
| 443 | dstubs.updateCurrentApiTimestamp.String()) |
| 444 | |
| 445 | fmt.Fprintln(w, ".PHONY: update-api") |
| 446 | fmt.Fprintln(w, "update-api:", |
| 447 | dstubs.updateCurrentApiTimestamp.String()) |
| 448 | } |
| 449 | if dstubs.checkLastReleasedApiTimestamp != nil { |
| 450 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api") |
| 451 | fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:", |
| 452 | dstubs.checkLastReleasedApiTimestamp.String()) |
| 453 | } |
| 454 | apiFilePrefix := "INTERNAL_PLATFORM_" |
| 455 | if String(dstubs.properties.Api_tag_name) != "" { |
| 456 | apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_" |
| 457 | } |
| 458 | if dstubs.apiFile != nil { |
| 459 | fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String()) |
| 460 | } |
| 461 | if dstubs.dexApiFile != nil { |
| 462 | fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String()) |
| 463 | } |
| 464 | if dstubs.privateApiFile != nil { |
| 465 | fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String()) |
| 466 | } |
| 467 | if dstubs.privateDexApiFile != nil { |
| 468 | fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String()) |
| 469 | } |
| 470 | if dstubs.removedApiFile != nil { |
| 471 | fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String()) |
| 472 | } |
| 473 | if dstubs.removedDexApiFile != nil { |
| 474 | fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String()) |
| 475 | } |
| 476 | if dstubs.exactApiFile != nil { |
| 477 | fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String()) |
| 478 | } |
| 479 | }, |
| 480 | }, |
| 481 | } |
| 482 | } |
| 483 | |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 484 | func androidMkWriteTestData(data android.Paths, ret *android.AndroidMkData) { |
| 485 | var testFiles []string |
| 486 | for _, d := range data { |
| 487 | testFiles = append(testFiles, d.String()+":"+d.Rel()) |
| 488 | } |
| 489 | if len(testFiles) > 0 { |
| 490 | ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { |
| 491 | fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUPPORT_FILES := "+strings.Join(testFiles, " ")) |
| 492 | }) |
| 493 | } |
| 494 | } |