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 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 25 | // TODO(jungjw): We'll probably want AndroidMkEntriesProvider.AndroidMkEntries to return multiple |
| 26 | // entries so that this can be more error-proof. |
| 27 | func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *android.AndroidMkEntries) { |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 28 | if Bool(library.deviceProperties.Hostdex) && !library.Host() { |
| 29 | fmt.Fprintln(w, "include $(CLEAR_VARS)") |
| 30 | fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex") |
| 31 | fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") |
| 32 | fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES") |
Colin Cross | 56abb83 | 2019-01-14 14:13:51 -0800 | [diff] [blame] | 33 | if library.dexJarFile != nil { |
| 34 | fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.dexJarFile.String()) |
| 35 | } else { |
| 36 | fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.implementationAndResourcesJar.String()) |
| 37 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 38 | if library.dexJarFile != nil { |
| 39 | fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String()) |
| 40 | } |
| 41 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", library.headerJarFile.String()) |
| 42 | fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", library.implementationAndResourcesJar.String()) |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 43 | if len(entries.Required) > 0 { |
| 44 | fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(entries.Required, " ")) |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 45 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 46 | if len(entries.Host_required) > 0 { |
| 47 | fmt.Fprintln(w, "LOCAL_HOST_REQUIRED_MODULES :=", strings.Join(entries.Host_required, " ")) |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 48 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 49 | if len(entries.Target_required) > 0 { |
| 50 | fmt.Fprintln(w, "LOCAL_TARGET_REQUIRED_MODULES :=", strings.Join(entries.Target_required, " ")) |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 51 | } |
Colin Cross | 7f87f4f | 2019-04-24 13:41:45 -0700 | [diff] [blame] | 52 | if r := library.deviceProperties.Target.Hostdex.Required; len(r) > 0 { |
| 53 | fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(r, " ")) |
| 54 | } |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 55 | fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk") |
| 56 | } |
| 57 | } |
| 58 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 59 | func (library *Library) AndroidMkEntries() android.AndroidMkEntries { |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 60 | if !library.IsForPlatform() { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 61 | return android.AndroidMkEntries{ |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 62 | Disabled: true, |
| 63 | } |
| 64 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 65 | return android.AndroidMkEntries{ |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 66 | Class: "JAVA_LIBRARIES", |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 67 | OutputFile: android.OptionalPathForPath(library.outputFile), |
Colin Cross | 5349941 | 2017-09-07 13:20:25 -0700 | [diff] [blame] | 68 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 69 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 70 | func(entries *android.AndroidMkEntries) { |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 71 | if len(library.logtagsSrcs) > 0 { |
| 72 | var logtags []string |
| 73 | for _, l := range library.logtagsSrcs { |
| 74 | logtags = append(logtags, l.Rel()) |
| 75 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 76 | entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...) |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 77 | } |
| 78 | |
Colin Cross | 9ae1b92 | 2018-06-26 17:59:05 -0700 | [diff] [blame] | 79 | if library.installFile == nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 80 | entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true) |
Colin Cross | 2c429dc | 2017-08-31 16:45:16 -0700 | [diff] [blame] | 81 | } |
Colin Cross | 6ade34f | 2017-09-15 13:00:47 -0700 | [diff] [blame] | 82 | if library.dexJarFile != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 83 | entries.SetString("LOCAL_SOONG_DEX_JAR", library.dexJarFile.String()) |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 84 | } |
| 85 | if len(library.dexpreopter.builtInstalled) > 0 { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 86 | entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", library.dexpreopter.builtInstalled) |
Colin Cross | 6ade34f | 2017-09-15 13:00:47 -0700 | [diff] [blame] | 87 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 88 | entries.SetString("LOCAL_SDK_VERSION", library.sdkVersion()) |
| 89 | entries.SetString("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar.String()) |
| 90 | entries.SetString("LOCAL_SOONG_HEADER_JAR", library.headerJarFile.String()) |
Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 91 | |
| 92 | if library.jacocoReportClassesFile != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 93 | entries.SetString("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile.String()) |
Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 94 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 95 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 96 | entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...) |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 97 | |
Vladimir Marko | 0975ee0 | 2019-04-02 10:29:55 +0100 | [diff] [blame] | 98 | if len(library.additionalCheckedModules) != 0 { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 99 | entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...) |
Vladimir Marko | 0975ee0 | 2019-04-02 10:29:55 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Colin Cross | e8a7dc9 | 2019-04-23 13:00:09 -0700 | [diff] [blame] | 102 | if library.proguardDictionary != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 103 | entries.SetString("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary.String()) |
Colin Cross | e8a7dc9 | 2019-04-23 13:00:09 -0700 | [diff] [blame] | 104 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 105 | }, |
| 106 | }, |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 107 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 108 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
| 109 | library.AndroidMkHostDex(w, name, entries) |
| 110 | }, |
Colin Cross | 9243010 | 2017-10-09 14:59:32 -0700 | [diff] [blame] | 111 | }, |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 112 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 115 | // Called for modules that are a component of a test suite. |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 116 | func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string) { |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 117 | entries.SetString("LOCAL_MODULE_TAGS", "tests") |
| 118 | if len(test_suites) > 0 { |
| 119 | entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", test_suites...) |
| 120 | } else { |
| 121 | entries.SetString("LOCAL_COMPATIBILITY_SUITE", "null-suite") |
| 122 | } |
| 123 | } |
| 124 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 125 | func (j *Test) AndroidMkEntries() android.AndroidMkEntries { |
| 126 | entries := j.Library.AndroidMkEntries() |
| 127 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 128 | testSuiteComponent(entries, j.testProperties.Test_suites) |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 129 | if j.testConfig != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 130 | entries.SetString("LOCAL_FULL_TEST_CONFIG", j.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 131 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 132 | androidMkWriteTestData(j.data, entries) |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 133 | }) |
| 134 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 135 | return entries |
Colin Cross | 05638fc | 2018-04-09 18:40:24 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 138 | func (j *TestHelperLibrary) AndroidMkEntries() android.AndroidMkEntries { |
| 139 | entries := j.Library.AndroidMkEntries() |
| 140 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 141 | testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites) |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 142 | }) |
| 143 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 144 | return entries |
Paul Duffin | 42df144 | 2019-03-20 12:45:53 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 147 | func (prebuilt *Import) AndroidMk() android.AndroidMkData { |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 148 | if !prebuilt.IsForPlatform() { |
| 149 | return android.AndroidMkData{ |
| 150 | Disabled: true, |
| 151 | } |
| 152 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 153 | return android.AndroidMkData{ |
| 154 | Class: "JAVA_LIBRARIES", |
| 155 | OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile), |
Colin Cross | 5349941 | 2017-09-07 13:20:25 -0700 | [diff] [blame] | 156 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 157 | Extra: []android.AndroidMkExtraFunc{ |
| 158 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | ff3ae9d | 2018-04-10 16:15:18 -0700 | [diff] [blame] | 159 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := ", !Bool(prebuilt.properties.Installable)) |
Nan Zhang | ed19fc3 | 2017-10-19 13:06:22 -0700 | [diff] [blame] | 160 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.combinedClasspathFile.String()) |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 161 | fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.combinedClasspathFile.String()) |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 162 | fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion()) |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 163 | }, |
| 164 | }, |
| 165 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 166 | } |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 167 | |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 168 | func (prebuilt *DexImport) AndroidMk() android.AndroidMkData { |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 169 | if !prebuilt.IsForPlatform() { |
| 170 | return android.AndroidMkData{ |
| 171 | Disabled: true, |
| 172 | } |
| 173 | } |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 174 | return android.AndroidMkData{ |
| 175 | Class: "JAVA_LIBRARIES", |
| 176 | OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile), |
| 177 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
| 178 | Extra: []android.AndroidMkExtraFunc{ |
| 179 | func(w io.Writer, outputFile android.Path) { |
| 180 | if prebuilt.dexJarFile != nil { |
| 181 | fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", prebuilt.dexJarFile.String()) |
| 182 | // TODO(b/125517186): export the dex jar as a classes jar to match some mis-uses in Make until |
| 183 | // boot_jars_package_check.mk can check dex jars. |
| 184 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.dexJarFile.String()) |
| 185 | fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.dexJarFile.String()) |
| 186 | } |
| 187 | if len(prebuilt.dexpreopter.builtInstalled) > 0 { |
| 188 | fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", prebuilt.dexpreopter.builtInstalled) |
| 189 | } |
| 190 | }, |
| 191 | }, |
| 192 | } |
| 193 | } |
| 194 | |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 195 | func (prebuilt *AARImport) AndroidMk() android.AndroidMkData { |
| 196 | return android.AndroidMkData{ |
| 197 | Class: "JAVA_LIBRARIES", |
| 198 | OutputFile: android.OptionalPathForPath(prebuilt.classpathFile), |
| 199 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
| 200 | Extra: []android.AndroidMkExtraFunc{ |
| 201 | func(w io.Writer, outputFile android.Path) { |
| 202 | fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 203 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", prebuilt.classpathFile.String()) |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 204 | fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", prebuilt.classpathFile.String()) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 205 | fmt.Fprintln(w, "LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=", prebuilt.exportPackage.String()) |
| 206 | fmt.Fprintln(w, "LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=", prebuilt.proguardFlags.String()) |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 207 | fmt.Fprintln(w, "LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=", prebuilt.extraAaptPackagesFile.String()) |
Colin Cross | 10f7c4a | 2018-05-23 10:59:28 -0700 | [diff] [blame] | 208 | fmt.Fprintln(w, "LOCAL_FULL_MANIFEST_FILE :=", prebuilt.manifest.String()) |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 209 | fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", prebuilt.sdkVersion()) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 210 | }, |
| 211 | }, |
| 212 | } |
| 213 | } |
| 214 | |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 215 | func (binary *Binary) AndroidMk() android.AndroidMkData { |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 216 | |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 217 | if !binary.isWrapperVariant { |
| 218 | return android.AndroidMkData{ |
| 219 | Class: "JAVA_LIBRARIES", |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 220 | OutputFile: android.OptionalPathForPath(binary.outputFile), |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 221 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 222 | Extra: []android.AndroidMkExtraFunc{ |
| 223 | func(w io.Writer, outputFile android.Path) { |
| 224 | fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", binary.headerJarFile.String()) |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 225 | fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", binary.implementationAndResourcesJar.String()) |
Colin Cross | 12fc2af | 2019-01-14 12:35:45 -0800 | [diff] [blame] | 226 | if binary.dexJarFile != nil { |
| 227 | fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", binary.dexJarFile.String()) |
| 228 | } |
| 229 | if len(binary.dexpreopter.builtInstalled) > 0 { |
Colin Cross | deabb94 | 2019-02-11 14:11:09 -0800 | [diff] [blame] | 230 | fmt.Fprintln(w, "LOCAL_SOONG_BUILT_INSTALLED :=", binary.dexpreopter.builtInstalled) |
Colin Cross | 12fc2af | 2019-01-14 12:35:45 -0800 | [diff] [blame] | 231 | } |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 232 | }, |
| 233 | }, |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 234 | Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
| 235 | android.WriteAndroidMkData(w, data) |
Colin Cross | 1965568 | 2017-09-07 17:00:22 -0700 | [diff] [blame] | 236 | |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 237 | fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)") |
| 238 | }, |
| 239 | } |
| 240 | } else { |
| 241 | return android.AndroidMkData{ |
| 242 | Class: "EXECUTABLES", |
| 243 | OutputFile: android.OptionalPathForPath(binary.wrapperFile), |
| 244 | Extra: []android.AndroidMkExtraFunc{ |
| 245 | func(w io.Writer, outputFile android.Path) { |
| 246 | fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") |
| 247 | }, |
| 248 | }, |
| 249 | Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { |
| 250 | android.WriteAndroidMkData(w, data) |
| 251 | |
| 252 | // Ensure that the wrapper script timestamp is always updated when the jar is updated |
| 253 | fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)") |
| 254 | fmt.Fprintln(w, "jar_installed_module :=") |
| 255 | }, |
| 256 | } |
Colin Cross | 10a0349 | 2017-08-10 17:09:43 -0700 | [diff] [blame] | 257 | } |
| 258 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 259 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 260 | func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries { |
| 261 | return android.AndroidMkEntries{ |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 262 | Class: "APPS", |
| 263 | OutputFile: android.OptionalPathForPath(app.outputFile), |
| 264 | Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 265 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 266 | func(entries *android.AndroidMkEntries) { |
| 267 | // App module names can be overridden. |
| 268 | entries.SetString("LOCAL_MODULE", app.installApkName) |
| 269 | entries.SetString("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage.String()) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 270 | if app.dexJarFile != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 271 | entries.SetString("LOCAL_SOONG_DEX_JAR", app.dexJarFile.String()) |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 272 | } |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 273 | if app.implementationAndResourcesJar != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 274 | entries.SetString("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar.String()) |
Colin Cross | 5dfabfb | 2017-12-14 13:19:01 -0800 | [diff] [blame] | 275 | } |
| 276 | if app.headerJarFile != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 277 | entries.SetString("LOCAL_SOONG_HEADER_JAR", app.headerJarFile.String()) |
Colin Cross | 5dfabfb | 2017-12-14 13:19:01 -0800 | [diff] [blame] | 278 | } |
Colin Cross | f623721 | 2018-10-29 23:14:58 -0700 | [diff] [blame] | 279 | if app.bundleFile != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 280 | entries.SetString("LOCAL_SOONG_BUNDLE", app.bundleFile.String()) |
Colin Cross | f623721 | 2018-10-29 23:14:58 -0700 | [diff] [blame] | 281 | } |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 282 | if app.jacocoReportClassesFile != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 283 | entries.SetString("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile.String()) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 284 | } |
Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 285 | if app.proguardDictionary != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 286 | entries.SetString("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary.String()) |
Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 287 | } |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 288 | |
| 289 | if app.Name() == "framework-res" { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 290 | entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)") |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 291 | // Make base_rules.mk not put framework-res in a subdirectory called |
| 292 | // framework_res. |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 293 | entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 294 | } |
| 295 | |
Anton Hansson | 53c8844 | 2019-03-18 15:53:16 +0000 | [diff] [blame] | 296 | filterRRO := func(filter overlayType) android.Paths { |
| 297 | var paths android.Paths |
| 298 | for _, d := range app.rroDirs { |
| 299 | if d.overlayType == filter { |
| 300 | paths = append(paths, d.path) |
| 301 | } |
| 302 | } |
Colin Cross | a140bb0 | 2018-04-17 10:52:26 -0700 | [diff] [blame] | 303 | // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make |
| 304 | // expects it in LOCAL_RESOURCE_DIRS order (high to low priority). |
Anton Hansson | 53c8844 | 2019-03-18 15:53:16 +0000 | [diff] [blame] | 305 | return android.ReversePaths(paths) |
| 306 | } |
| 307 | deviceRRODirs := filterRRO(device) |
| 308 | if len(deviceRRODirs) > 0 { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 309 | entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...) |
Anton Hansson | 53c8844 | 2019-03-18 15:53:16 +0000 | [diff] [blame] | 310 | } |
| 311 | productRRODirs := filterRRO(product) |
| 312 | if len(productRRODirs) > 0 { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 313 | entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 316 | entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources)) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 317 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 318 | entries.SetString("LOCAL_FULL_MANIFEST_FILE", app.manifestPath.String()) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 319 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 320 | entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(app.appProperties.Privileged)) |
Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 321 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 322 | entries.SetString("LOCAL_CERTIFICATE", app.certificate.Pem.String()) |
| 323 | entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...) |
Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 324 | |
| 325 | for _, jniLib := range app.installJniLibs { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 326 | entries.AddStrings("LOCAL_SOONG_JNI_LIBS_"+jniLib.target.Arch.ArchType.String(), jniLib.name) |
Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 327 | } |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 328 | if len(app.dexpreopter.builtInstalled) > 0 { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 329 | entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled) |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 330 | } |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 331 | for _, split := range app.aapt.splits { |
| 332 | install := "$(LOCAL_MODULE_PATH)/" + strings.TrimSuffix(app.installApkName, ".apk") + split.suffix + ".apk" |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 333 | entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", split.path.String()+":"+install) |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 334 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 335 | }, |
| 336 | }, |
| 337 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 338 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
Jaewoong Jung | 9877279 | 2019-07-01 17:15:13 -0700 | [diff] [blame] | 339 | if app.noticeOutputs.Merged.Valid() { |
| 340 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 341 | app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE") |
| 342 | } |
| 343 | if app.noticeOutputs.TxtOutput.Valid() { |
| 344 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 345 | app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt") |
| 346 | } |
| 347 | if app.noticeOutputs.HtmlOutput.Valid() { |
| 348 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 349 | app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html") |
| 350 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 351 | }, |
| 352 | }, |
| 353 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 354 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 355 | |
Jaewoong Jung | 9109d72 | 2019-01-30 13:13:52 -0800 | [diff] [blame] | 356 | func (a *AndroidApp) getOverriddenPackages() []string { |
| 357 | var overridden []string |
| 358 | if len(a.appProperties.Overrides) > 0 { |
| 359 | overridden = append(overridden, a.appProperties.Overrides...) |
| 360 | } |
| 361 | if a.Name() != a.installApkName { |
| 362 | overridden = append(overridden, a.Name()) |
| 363 | } |
| 364 | return overridden |
| 365 | } |
| 366 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 367 | func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries { |
| 368 | entries := a.AndroidApp.AndroidMkEntries() |
| 369 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 370 | testSuiteComponent(entries, a.testProperties.Test_suites) |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 371 | if a.testConfig != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 372 | entries.SetString("LOCAL_FULL_TEST_CONFIG", a.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 373 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 374 | androidMkWriteTestData(a.data, entries) |
Colin Cross | 252fc6f | 2018-10-04 15:22:03 -0700 | [diff] [blame] | 375 | }) |
| 376 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 377 | return entries |
Colin Cross | 252fc6f | 2018-10-04 15:22:03 -0700 | [diff] [blame] | 378 | } |
| 379 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 380 | func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries { |
| 381 | entries := a.AndroidApp.AndroidMkEntries() |
| 382 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 383 | testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites) |
| 384 | }) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 385 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 386 | return entries |
| 387 | } |
| 388 | |
| 389 | func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries { |
| 390 | entries := a.Library.AndroidMkEntries() |
| 391 | |
| 392 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Colin Cross | a54974c | 2018-10-29 23:15:37 -0700 | [diff] [blame] | 393 | if a.aarFile != nil { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 394 | entries.SetString("LOCAL_SOONG_AAR", a.aarFile.String()) |
Colin Cross | a54974c | 2018-10-29 23:15:37 -0700 | [diff] [blame] | 395 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 396 | |
| 397 | if a.Name() == "framework-res" { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 398 | entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)") |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 399 | // Make base_rules.mk not put framework-res in a subdirectory called |
| 400 | // framework_res. |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 401 | entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 404 | entries.SetString("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage.String()) |
| 405 | entries.SetString("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile.String()) |
| 406 | entries.SetString("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile.String()) |
| 407 | entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...) |
| 408 | entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 409 | }) |
| 410 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 411 | return entries |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 412 | } |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 413 | |
| 414 | func (jd *Javadoc) AndroidMk() android.AndroidMkData { |
| 415 | return android.AndroidMkData{ |
| 416 | Class: "JAVA_LIBRARIES", |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 417 | OutputFile: android.OptionalPathForPath(jd.stubsSrcJar), |
Colin Cross | 5fa9d6f | 2018-08-08 21:44:48 -0700 | [diff] [blame] | 418 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 419 | Extra: []android.AndroidMkExtraFunc{ |
| 420 | func(w io.Writer, outputFile android.Path) { |
Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 421 | if BoolDefault(jd.properties.Installable, true) { |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 422 | fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", jd.docZip.String()) |
| 423 | } |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 424 | if jd.stubsSrcJar != nil { |
| 425 | fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", jd.stubsSrcJar.String()) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 426 | } |
| 427 | }, |
| 428 | }, |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | func (ddoc *Droiddoc) AndroidMk() android.AndroidMkData { |
| 433 | return android.AndroidMkData{ |
| 434 | Class: "JAVA_LIBRARIES", |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 435 | OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar), |
Colin Cross | 5fa9d6f | 2018-08-08 21:44:48 -0700 | [diff] [blame] | 436 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 437 | Extra: []android.AndroidMkExtraFunc{ |
| 438 | func(w io.Writer, outputFile android.Path) { |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 439 | if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil { |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 440 | fmt.Fprintln(w, "LOCAL_DROIDDOC_DOC_ZIP := ", ddoc.Javadoc.docZip.String()) |
| 441 | } |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 442 | if ddoc.Javadoc.stubsSrcJar != nil { |
| 443 | fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", ddoc.Javadoc.stubsSrcJar.String()) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 444 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 445 | if ddoc.checkCurrentApiTimestamp != nil { |
| 446 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api") |
| 447 | fmt.Fprintln(w, ddoc.Name()+"-check-current-api:", |
| 448 | ddoc.checkCurrentApiTimestamp.String()) |
| 449 | |
| 450 | fmt.Fprintln(w, ".PHONY: checkapi") |
Jiyong Park | eeb8a64 | 2018-05-12 22:21:20 +0900 | [diff] [blame] | 451 | fmt.Fprintln(w, "checkapi:", |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 452 | ddoc.checkCurrentApiTimestamp.String()) |
| 453 | |
| 454 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 455 | fmt.Fprintln(w, "droidcore: checkapi") |
| 456 | } |
| 457 | if ddoc.updateCurrentApiTimestamp != nil { |
Dan Willemsen | a03c43a | 2018-07-24 13:00:52 -0700 | [diff] [blame] | 458 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api") |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 459 | fmt.Fprintln(w, ddoc.Name()+"-update-current-api:", |
| 460 | ddoc.updateCurrentApiTimestamp.String()) |
| 461 | |
| 462 | fmt.Fprintln(w, ".PHONY: update-api") |
| 463 | fmt.Fprintln(w, "update-api:", |
| 464 | ddoc.updateCurrentApiTimestamp.String()) |
| 465 | } |
| 466 | if ddoc.checkLastReleasedApiTimestamp != nil { |
| 467 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api") |
| 468 | fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:", |
| 469 | ddoc.checkLastReleasedApiTimestamp.String()) |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 470 | |
Adrian Roos | 62e34b9 | 2019-01-30 19:51:39 +0100 | [diff] [blame] | 471 | if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" { |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 472 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 473 | fmt.Fprintln(w, "checkapi:", |
| 474 | ddoc.checkLastReleasedApiTimestamp.String()) |
| 475 | |
| 476 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 477 | fmt.Fprintln(w, "droidcore: checkapi") |
| 478 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 479 | } |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 480 | apiFilePrefix := "INTERNAL_PLATFORM_" |
| 481 | if String(ddoc.properties.Api_tag_name) != "" { |
| 482 | apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_" |
| 483 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 484 | if ddoc.apiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 485 | fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", ddoc.apiFile.String()) |
| 486 | } |
David Brazdil | fbe4cc3 | 2018-05-31 13:56:46 +0100 | [diff] [blame] | 487 | if ddoc.dexApiFile != nil { |
| 488 | fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", ddoc.dexApiFile.String()) |
| 489 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 490 | if ddoc.privateApiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 491 | fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", ddoc.privateApiFile.String()) |
| 492 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 493 | if ddoc.privateDexApiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 494 | fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", ddoc.privateDexApiFile.String()) |
| 495 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 496 | if ddoc.removedApiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 497 | fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", ddoc.removedApiFile.String()) |
| 498 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 499 | if ddoc.removedDexApiFile != nil { |
David Brazdil | aac0c3c | 2018-04-24 16:23:29 +0100 | [diff] [blame] | 500 | fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", ddoc.removedDexApiFile.String()) |
| 501 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 502 | if ddoc.exactApiFile != nil { |
Nan Zhang | 28c68b9 | 2018-03-13 16:17:01 -0700 | [diff] [blame] | 503 | fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", ddoc.exactApiFile.String()) |
| 504 | } |
Nan Zhang | 66dc236 | 2018-08-14 20:41:04 -0700 | [diff] [blame] | 505 | if ddoc.proguardFile != nil { |
| 506 | fmt.Fprintln(w, apiFilePrefix+"PROGUARD_FILE := ", ddoc.proguardFile.String()) |
| 507 | } |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 508 | }, |
| 509 | }, |
| 510 | } |
| 511 | } |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 512 | |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 513 | func (dstubs *Droidstubs) AndroidMk() android.AndroidMkData { |
| 514 | return android.AndroidMkData{ |
| 515 | Class: "JAVA_LIBRARIES", |
| 516 | OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar), |
| 517 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
| 518 | Extra: []android.AndroidMkExtraFunc{ |
| 519 | func(w io.Writer, outputFile android.Path) { |
| 520 | if dstubs.Javadoc.stubsSrcJar != nil { |
| 521 | fmt.Fprintln(w, "LOCAL_DROIDDOC_STUBS_SRCJAR := ", dstubs.Javadoc.stubsSrcJar.String()) |
| 522 | } |
Nan Zhang | d23ac69 | 2018-09-18 10:41:33 -0700 | [diff] [blame] | 523 | if dstubs.apiVersionsXml != nil { |
| 524 | fmt.Fprintln(w, "LOCAL_DROIDDOC_API_VERSIONS_XML := ", dstubs.apiVersionsXml.String()) |
| 525 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 526 | if dstubs.annotationsZip != nil { |
| 527 | fmt.Fprintln(w, "LOCAL_DROIDDOC_ANNOTATIONS_ZIP := ", dstubs.annotationsZip.String()) |
| 528 | } |
Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 529 | if dstubs.jdiffDocZip != nil { |
| 530 | fmt.Fprintln(w, "LOCAL_DROIDDOC_JDIFF_DOC_ZIP := ", dstubs.jdiffDocZip.String()) |
| 531 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 532 | if dstubs.checkCurrentApiTimestamp != nil { |
| 533 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api") |
| 534 | fmt.Fprintln(w, dstubs.Name()+"-check-current-api:", |
| 535 | dstubs.checkCurrentApiTimestamp.String()) |
| 536 | |
| 537 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 538 | fmt.Fprintln(w, "checkapi:", |
| 539 | dstubs.checkCurrentApiTimestamp.String()) |
| 540 | |
| 541 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 542 | fmt.Fprintln(w, "droidcore: checkapi") |
| 543 | } |
| 544 | if dstubs.updateCurrentApiTimestamp != nil { |
| 545 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api") |
| 546 | fmt.Fprintln(w, dstubs.Name()+"-update-current-api:", |
| 547 | dstubs.updateCurrentApiTimestamp.String()) |
| 548 | |
| 549 | fmt.Fprintln(w, ".PHONY: update-api") |
| 550 | fmt.Fprintln(w, "update-api:", |
| 551 | dstubs.updateCurrentApiTimestamp.String()) |
| 552 | } |
| 553 | if dstubs.checkLastReleasedApiTimestamp != nil { |
| 554 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api") |
| 555 | fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:", |
| 556 | dstubs.checkLastReleasedApiTimestamp.String()) |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 557 | |
Adrian Roos | 62e34b9 | 2019-01-30 19:51:39 +0100 | [diff] [blame] | 558 | if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" { |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 559 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 560 | fmt.Fprintln(w, "checkapi:", |
| 561 | dstubs.checkLastReleasedApiTimestamp.String()) |
| 562 | |
| 563 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 564 | fmt.Fprintln(w, "droidcore: checkapi") |
| 565 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 566 | } |
Pete Gillin | 581d608 | 2018-10-22 15:55:04 +0100 | [diff] [blame] | 567 | if dstubs.checkNullabilityWarningsTimestamp != nil { |
| 568 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings") |
| 569 | fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:", |
| 570 | dstubs.checkNullabilityWarningsTimestamp.String()) |
| 571 | |
| 572 | fmt.Fprintln(w, ".PHONY:", "droidcore") |
| 573 | fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings") |
| 574 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 575 | apiFilePrefix := "INTERNAL_PLATFORM_" |
| 576 | if String(dstubs.properties.Api_tag_name) != "" { |
| 577 | apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_" |
| 578 | } |
| 579 | if dstubs.apiFile != nil { |
| 580 | fmt.Fprintln(w, apiFilePrefix+"API_FILE := ", dstubs.apiFile.String()) |
| 581 | } |
| 582 | if dstubs.dexApiFile != nil { |
| 583 | fmt.Fprintln(w, apiFilePrefix+"DEX_API_FILE := ", dstubs.dexApiFile.String()) |
| 584 | } |
| 585 | if dstubs.privateApiFile != nil { |
| 586 | fmt.Fprintln(w, apiFilePrefix+"PRIVATE_API_FILE := ", dstubs.privateApiFile.String()) |
| 587 | } |
| 588 | if dstubs.privateDexApiFile != nil { |
| 589 | fmt.Fprintln(w, apiFilePrefix+"PRIVATE_DEX_API_FILE := ", dstubs.privateDexApiFile.String()) |
| 590 | } |
| 591 | if dstubs.removedApiFile != nil { |
| 592 | fmt.Fprintln(w, apiFilePrefix+"REMOVED_API_FILE := ", dstubs.removedApiFile.String()) |
| 593 | } |
| 594 | if dstubs.removedDexApiFile != nil { |
| 595 | fmt.Fprintln(w, apiFilePrefix+"REMOVED_DEX_API_FILE := ", dstubs.removedDexApiFile.String()) |
| 596 | } |
| 597 | if dstubs.exactApiFile != nil { |
| 598 | fmt.Fprintln(w, apiFilePrefix+"EXACT_API_FILE := ", dstubs.exactApiFile.String()) |
| 599 | } |
| 600 | }, |
| 601 | }, |
| 602 | } |
| 603 | } |
| 604 | |
Jaewoong Jung | 8aae22e | 2019-07-17 10:21:49 -0700 | [diff] [blame] | 605 | func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries { |
| 606 | return android.AndroidMkEntries{ |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 607 | Class: "APPS", |
Jaewoong Jung | 8aae22e | 2019-07-17 10:21:49 -0700 | [diff] [blame] | 608 | OutputFile: android.OptionalPathForPath(a.outputFile), |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 609 | Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 610 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 611 | func(entries *android.AndroidMkEntries) { |
| 612 | entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(a.properties.Privileged)) |
| 613 | if a.certificate != nil { |
| 614 | entries.SetString("LOCAL_CERTIFICATE", a.certificate.Pem.String()) |
| 615 | } else { |
| 616 | entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED") |
| 617 | } |
| 618 | entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...) |
| 619 | if len(a.dexpreopter.builtInstalled) > 0 { |
| 620 | entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled) |
| 621 | } |
| 622 | entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel()) |
| 623 | }, |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 624 | }, |
| 625 | } |
| 626 | } |
| 627 | |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 628 | func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries { |
| 629 | entries := a.AndroidAppImport.AndroidMkEntries() |
| 630 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 631 | testSuiteComponent(entries, a.testProperties.Test_suites) |
| 632 | androidMkWriteTestData(a.data, entries) |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 633 | }) |
| 634 | return entries |
| 635 | } |
| 636 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame^] | 637 | func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) { |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 638 | var testFiles []string |
| 639 | for _, d := range data { |
| 640 | testFiles = append(testFiles, d.String()+":"+d.Rel()) |
| 641 | } |
| 642 | entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...) |
| 643 | } |