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 | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 83 | entries.SetPath("LOCAL_SOONG_DEX_JAR", library.dexJarFile) |
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()) |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 89 | entries.SetPath("LOCAL_SOONG_CLASSES_JAR", library.implementationAndResourcesJar) |
| 90 | entries.SetPath("LOCAL_SOONG_HEADER_JAR", library.headerJarFile) |
Colin Cross | cb93359 | 2017-11-22 13:49:43 -0800 | [diff] [blame] | 91 | |
| 92 | if library.jacocoReportClassesFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 93 | entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", library.jacocoReportClassesFile) |
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 | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 103 | entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary) |
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 | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 130 | entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig) |
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 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 147 | func (prebuilt *Import) AndroidMkEntries() android.AndroidMkEntries { |
Jiyong Park | 9b409bc | 2019-10-11 14:59:13 +0900 | [diff] [blame] | 148 | if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 149 | return android.AndroidMkEntries{ |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 150 | Disabled: true, |
| 151 | } |
| 152 | } |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 153 | return android.AndroidMkEntries{ |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 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", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 157 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 158 | func(entries *android.AndroidMkEntries) { |
| 159 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", !Bool(prebuilt.properties.Installable)) |
| 160 | entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile) |
| 161 | entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile) |
| 162 | entries.SetString("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 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 168 | func (prebuilt *DexImport) AndroidMkEntries() android.AndroidMkEntries { |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 169 | if !prebuilt.IsForPlatform() { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 170 | return android.AndroidMkEntries{ |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 171 | Disabled: true, |
| 172 | } |
| 173 | } |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 174 | return android.AndroidMkEntries{ |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 175 | Class: "JAVA_LIBRARIES", |
| 176 | OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile), |
| 177 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 178 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 179 | func(entries *android.AndroidMkEntries) { |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 180 | if prebuilt.dexJarFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 181 | entries.SetPath("LOCAL_SOONG_DEX_JAR", prebuilt.dexJarFile) |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 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. |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 184 | entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.dexJarFile) |
| 185 | entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.dexJarFile) |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 186 | } |
| 187 | if len(prebuilt.dexpreopter.builtInstalled) > 0 { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 188 | entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled) |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 189 | } |
| 190 | }, |
| 191 | }, |
| 192 | } |
| 193 | } |
| 194 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 195 | func (prebuilt *AARImport) AndroidMkEntries() android.AndroidMkEntries { |
| 196 | return android.AndroidMkEntries{ |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 197 | Class: "JAVA_LIBRARIES", |
| 198 | OutputFile: android.OptionalPathForPath(prebuilt.classpathFile), |
| 199 | Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 200 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 201 | func(entries *android.AndroidMkEntries) { |
| 202 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
| 203 | entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.classpathFile) |
| 204 | entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.classpathFile) |
| 205 | entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", prebuilt.exportPackage) |
| 206 | entries.SetPath("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", prebuilt.proguardFlags) |
| 207 | entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", prebuilt.extraAaptPackagesFile) |
| 208 | entries.SetPath("LOCAL_FULL_MANIFEST_FILE", prebuilt.manifest) |
| 209 | entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion()) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 210 | }, |
| 211 | }, |
| 212 | } |
| 213 | } |
| 214 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 215 | func (binary *Binary) AndroidMkEntries() android.AndroidMkEntries { |
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 { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 218 | return android.AndroidMkEntries{ |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 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", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 222 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 223 | func(entries *android.AndroidMkEntries) { |
| 224 | entries.SetPath("LOCAL_SOONG_HEADER_JAR", binary.headerJarFile) |
| 225 | entries.SetPath("LOCAL_SOONG_CLASSES_JAR", binary.implementationAndResourcesJar) |
Colin Cross | 12fc2af | 2019-01-14 12:35:45 -0800 | [diff] [blame] | 226 | if binary.dexJarFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 227 | entries.SetPath("LOCAL_SOONG_DEX_JAR", binary.dexJarFile) |
Colin Cross | 12fc2af | 2019-01-14 12:35:45 -0800 | [diff] [blame] | 228 | } |
| 229 | if len(binary.dexpreopter.builtInstalled) > 0 { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 230 | entries.SetString("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 | }, |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 234 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 235 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
| 236 | fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)") |
| 237 | }, |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 238 | }, |
| 239 | } |
| 240 | } else { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 241 | return android.AndroidMkEntries{ |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 242 | Class: "EXECUTABLES", |
| 243 | OutputFile: android.OptionalPathForPath(binary.wrapperFile), |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 244 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 245 | func(entries *android.AndroidMkEntries) { |
| 246 | entries.SetBool("LOCAL_STRIP_MODULE", false) |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 247 | }, |
| 248 | }, |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 249 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 250 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
| 251 | // Ensure that the wrapper script timestamp is always updated when the jar is updated |
| 252 | fmt.Fprintln(w, "$(LOCAL_INSTALLED_MODULE): $(jar_installed_module)") |
| 253 | fmt.Fprintln(w, "jar_installed_module :=") |
| 254 | }, |
Colin Cross | 6b4a32d | 2017-12-05 13:42:45 -0800 | [diff] [blame] | 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) |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 269 | entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 270 | if app.dexJarFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 271 | entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile) |
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 | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 274 | entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar) |
Colin Cross | 5dfabfb | 2017-12-14 13:19:01 -0800 | [diff] [blame] | 275 | } |
| 276 | if app.headerJarFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 277 | entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile) |
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 | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 280 | entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile) |
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 | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 283 | entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile) |
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 | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 286 | entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary) |
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 | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 318 | entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 319 | |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame^] | 320 | entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged()) |
Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 321 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 322 | entries.SetPath("LOCAL_CERTIFICATE", app.certificate.Pem) |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 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 { |
Jaewoong Jung | 7dd4ae2 | 2019-09-27 17:13:15 -0700 | [diff] [blame] | 332 | install := app.onDeviceDir + "/" + |
| 333 | strings.TrimSuffix(app.installApkName, ".apk") + "_" + split.suffix + ".apk" |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 334 | entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", split.path.String()+":"+install) |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 335 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 336 | }, |
| 337 | }, |
| 338 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 339 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
Jaewoong Jung | 9877279 | 2019-07-01 17:15:13 -0700 | [diff] [blame] | 340 | if app.noticeOutputs.Merged.Valid() { |
| 341 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 342 | app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE") |
| 343 | } |
| 344 | if app.noticeOutputs.TxtOutput.Valid() { |
| 345 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 346 | app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt") |
| 347 | } |
| 348 | if app.noticeOutputs.HtmlOutput.Valid() { |
| 349 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 350 | app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html") |
| 351 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 352 | }, |
| 353 | }, |
| 354 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 355 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 356 | |
Jaewoong Jung | 9109d72 | 2019-01-30 13:13:52 -0800 | [diff] [blame] | 357 | func (a *AndroidApp) getOverriddenPackages() []string { |
| 358 | var overridden []string |
| 359 | if len(a.appProperties.Overrides) > 0 { |
| 360 | overridden = append(overridden, a.appProperties.Overrides...) |
| 361 | } |
| 362 | if a.Name() != a.installApkName { |
| 363 | overridden = append(overridden, a.Name()) |
| 364 | } |
| 365 | return overridden |
| 366 | } |
| 367 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 368 | func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries { |
| 369 | entries := a.AndroidApp.AndroidMkEntries() |
| 370 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 371 | testSuiteComponent(entries, a.testProperties.Test_suites) |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 372 | if a.testConfig != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 373 | entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 374 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 375 | androidMkWriteTestData(a.data, entries) |
Colin Cross | 252fc6f | 2018-10-04 15:22:03 -0700 | [diff] [blame] | 376 | }) |
| 377 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 378 | return entries |
Colin Cross | 252fc6f | 2018-10-04 15:22:03 -0700 | [diff] [blame] | 379 | } |
| 380 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 381 | func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries { |
| 382 | entries := a.AndroidApp.AndroidMkEntries() |
| 383 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 384 | testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites) |
| 385 | }) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 386 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 387 | return entries |
| 388 | } |
| 389 | |
| 390 | func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries { |
| 391 | entries := a.Library.AndroidMkEntries() |
| 392 | |
| 393 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Colin Cross | a54974c | 2018-10-29 23:15:37 -0700 | [diff] [blame] | 394 | if a.aarFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 395 | entries.SetPath("LOCAL_SOONG_AAR", a.aarFile) |
Colin Cross | a54974c | 2018-10-29 23:15:37 -0700 | [diff] [blame] | 396 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 397 | |
| 398 | if a.Name() == "framework-res" { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 399 | entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)") |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 400 | // Make base_rules.mk not put framework-res in a subdirectory called |
| 401 | // framework_res. |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 402 | entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 403 | } |
| 404 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 405 | entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage) |
| 406 | entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile) |
| 407 | entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile) |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 408 | entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...) |
| 409 | entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 410 | }) |
| 411 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 412 | return entries |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 413 | } |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 414 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 415 | func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries { |
| 416 | return android.AndroidMkEntries{ |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 417 | Class: "JAVA_LIBRARIES", |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 418 | OutputFile: android.OptionalPathForPath(jd.stubsSrcJar), |
Colin Cross | 5fa9d6f | 2018-08-08 21:44:48 -0700 | [diff] [blame] | 419 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 420 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 421 | func(entries *android.AndroidMkEntries) { |
Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 422 | if BoolDefault(jd.properties.Installable, true) { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 423 | entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 424 | } |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 425 | if jd.stubsSrcJar != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 426 | entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 427 | } |
| 428 | }, |
| 429 | }, |
| 430 | } |
| 431 | } |
| 432 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 433 | func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries { |
| 434 | return android.AndroidMkEntries{ |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 435 | Class: "JAVA_LIBRARIES", |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 436 | OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar), |
Colin Cross | 5fa9d6f | 2018-08-08 21:44:48 -0700 | [diff] [blame] | 437 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 438 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 439 | func(entries *android.AndroidMkEntries) { |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 440 | if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 441 | entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 442 | } |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 443 | if ddoc.Javadoc.stubsSrcJar != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 444 | entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 445 | } |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 446 | apiFilePrefix := "INTERNAL_PLATFORM_" |
| 447 | if String(ddoc.properties.Api_tag_name) != "" { |
| 448 | apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_" |
| 449 | } |
| 450 | if ddoc.apiFile != nil { |
| 451 | entries.SetPath(apiFilePrefix+"API_FILE", ddoc.apiFile) |
| 452 | } |
| 453 | if ddoc.dexApiFile != nil { |
| 454 | entries.SetPath(apiFilePrefix+"DEX_API_FILE", ddoc.dexApiFile) |
| 455 | } |
| 456 | if ddoc.privateApiFile != nil { |
| 457 | entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", ddoc.privateApiFile) |
| 458 | } |
| 459 | if ddoc.privateDexApiFile != nil { |
| 460 | entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", ddoc.privateDexApiFile) |
| 461 | } |
| 462 | if ddoc.removedApiFile != nil { |
| 463 | entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", ddoc.removedApiFile) |
| 464 | } |
| 465 | if ddoc.removedDexApiFile != nil { |
| 466 | entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", ddoc.removedDexApiFile) |
| 467 | } |
| 468 | if ddoc.exactApiFile != nil { |
| 469 | entries.SetPath(apiFilePrefix+"EXACT_API_FILE", ddoc.exactApiFile) |
| 470 | } |
| 471 | if ddoc.proguardFile != nil { |
| 472 | entries.SetPath(apiFilePrefix+"PROGUARD_FILE", ddoc.proguardFile) |
| 473 | } |
| 474 | }, |
| 475 | }, |
| 476 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 477 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 478 | if ddoc.checkCurrentApiTimestamp != nil { |
| 479 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api") |
| 480 | fmt.Fprintln(w, ddoc.Name()+"-check-current-api:", |
| 481 | ddoc.checkCurrentApiTimestamp.String()) |
| 482 | |
| 483 | fmt.Fprintln(w, ".PHONY: checkapi") |
Jiyong Park | eeb8a64 | 2018-05-12 22:21:20 +0900 | [diff] [blame] | 484 | fmt.Fprintln(w, "checkapi:", |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 485 | ddoc.checkCurrentApiTimestamp.String()) |
| 486 | |
| 487 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 488 | fmt.Fprintln(w, "droidcore: checkapi") |
| 489 | } |
| 490 | if ddoc.updateCurrentApiTimestamp != nil { |
Dan Willemsen | a03c43a | 2018-07-24 13:00:52 -0700 | [diff] [blame] | 491 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api") |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 492 | fmt.Fprintln(w, ddoc.Name()+"-update-current-api:", |
| 493 | ddoc.updateCurrentApiTimestamp.String()) |
| 494 | |
| 495 | fmt.Fprintln(w, ".PHONY: update-api") |
| 496 | fmt.Fprintln(w, "update-api:", |
| 497 | ddoc.updateCurrentApiTimestamp.String()) |
| 498 | } |
| 499 | if ddoc.checkLastReleasedApiTimestamp != nil { |
| 500 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api") |
| 501 | fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:", |
| 502 | ddoc.checkLastReleasedApiTimestamp.String()) |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 503 | |
Adrian Roos | 62e34b9 | 2019-01-30 19:51:39 +0100 | [diff] [blame] | 504 | if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" { |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 505 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 506 | fmt.Fprintln(w, "checkapi:", |
| 507 | ddoc.checkLastReleasedApiTimestamp.String()) |
| 508 | |
| 509 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 510 | fmt.Fprintln(w, "droidcore: checkapi") |
| 511 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 512 | } |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 513 | }, |
| 514 | }, |
| 515 | } |
| 516 | } |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 517 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 518 | func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries { |
| 519 | return android.AndroidMkEntries{ |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 520 | Class: "JAVA_LIBRARIES", |
| 521 | OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar), |
| 522 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 523 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 524 | func(entries *android.AndroidMkEntries) { |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 525 | if dstubs.Javadoc.stubsSrcJar != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 526 | entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar) |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 527 | } |
Nan Zhang | d23ac69 | 2018-09-18 10:41:33 -0700 | [diff] [blame] | 528 | if dstubs.apiVersionsXml != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 529 | entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml) |
Nan Zhang | d23ac69 | 2018-09-18 10:41:33 -0700 | [diff] [blame] | 530 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 531 | if dstubs.annotationsZip != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 532 | entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip) |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 533 | } |
Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 534 | if dstubs.jdiffDocZip != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 535 | entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip) |
Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 536 | } |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 537 | apiFilePrefix := "INTERNAL_PLATFORM_" |
| 538 | if String(dstubs.properties.Api_tag_name) != "" { |
| 539 | apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_" |
| 540 | } |
| 541 | if dstubs.apiFile != nil { |
| 542 | entries.SetPath(apiFilePrefix+"API_FILE", dstubs.apiFile) |
| 543 | } |
| 544 | if dstubs.dexApiFile != nil { |
| 545 | entries.SetPath(apiFilePrefix+"DEX_API_FILE", dstubs.dexApiFile) |
| 546 | } |
| 547 | if dstubs.privateApiFile != nil { |
| 548 | entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", dstubs.privateApiFile) |
| 549 | } |
| 550 | if dstubs.privateDexApiFile != nil { |
| 551 | entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", dstubs.privateDexApiFile) |
| 552 | } |
| 553 | if dstubs.removedApiFile != nil { |
| 554 | entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", dstubs.removedApiFile) |
| 555 | } |
| 556 | if dstubs.removedDexApiFile != nil { |
| 557 | entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", dstubs.removedDexApiFile) |
| 558 | } |
| 559 | if dstubs.exactApiFile != nil { |
| 560 | entries.SetPath(apiFilePrefix+"EXACT_API_FILE", dstubs.exactApiFile) |
| 561 | } |
| 562 | }, |
| 563 | }, |
| 564 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 565 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 566 | if dstubs.checkCurrentApiTimestamp != nil { |
| 567 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api") |
| 568 | fmt.Fprintln(w, dstubs.Name()+"-check-current-api:", |
| 569 | dstubs.checkCurrentApiTimestamp.String()) |
| 570 | |
| 571 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 572 | fmt.Fprintln(w, "checkapi:", |
| 573 | dstubs.checkCurrentApiTimestamp.String()) |
| 574 | |
| 575 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 576 | fmt.Fprintln(w, "droidcore: checkapi") |
| 577 | } |
| 578 | if dstubs.updateCurrentApiTimestamp != nil { |
| 579 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api") |
| 580 | fmt.Fprintln(w, dstubs.Name()+"-update-current-api:", |
| 581 | dstubs.updateCurrentApiTimestamp.String()) |
| 582 | |
| 583 | fmt.Fprintln(w, ".PHONY: update-api") |
| 584 | fmt.Fprintln(w, "update-api:", |
| 585 | dstubs.updateCurrentApiTimestamp.String()) |
| 586 | } |
| 587 | if dstubs.checkLastReleasedApiTimestamp != nil { |
| 588 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api") |
| 589 | fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:", |
| 590 | dstubs.checkLastReleasedApiTimestamp.String()) |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 591 | |
Adrian Roos | 62e34b9 | 2019-01-30 19:51:39 +0100 | [diff] [blame] | 592 | if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" { |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 593 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 594 | fmt.Fprintln(w, "checkapi:", |
| 595 | dstubs.checkLastReleasedApiTimestamp.String()) |
| 596 | |
| 597 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 598 | fmt.Fprintln(w, "droidcore: checkapi") |
| 599 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 600 | } |
Adrian Roos | 075eedc | 2019-10-10 12:07:03 +0200 | [diff] [blame] | 601 | if dstubs.apiLintTimestamp != nil { |
| 602 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint") |
| 603 | fmt.Fprintln(w, dstubs.Name()+"-api-lint:", |
| 604 | dstubs.apiLintTimestamp.String()) |
| 605 | |
| 606 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 607 | fmt.Fprintln(w, "checkapi:", |
| 608 | dstubs.apiLintTimestamp.String()) |
| 609 | |
| 610 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 611 | fmt.Fprintln(w, "droidcore: checkapi") |
| 612 | } |
Pete Gillin | 581d608 | 2018-10-22 15:55:04 +0100 | [diff] [blame] | 613 | if dstubs.checkNullabilityWarningsTimestamp != nil { |
| 614 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings") |
| 615 | fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:", |
| 616 | dstubs.checkNullabilityWarningsTimestamp.String()) |
| 617 | |
| 618 | fmt.Fprintln(w, ".PHONY:", "droidcore") |
| 619 | fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings") |
| 620 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 621 | }, |
| 622 | }, |
| 623 | } |
| 624 | } |
| 625 | |
Jaewoong Jung | 8aae22e | 2019-07-17 10:21:49 -0700 | [diff] [blame] | 626 | func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries { |
| 627 | return android.AndroidMkEntries{ |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 628 | Class: "APPS", |
Jaewoong Jung | 8aae22e | 2019-07-17 10:21:49 -0700 | [diff] [blame] | 629 | OutputFile: android.OptionalPathForPath(a.outputFile), |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 630 | Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 631 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 632 | func(entries *android.AndroidMkEntries) { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame^] | 633 | entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged()) |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 634 | if a.certificate != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 635 | entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem) |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 636 | } else { |
| 637 | entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED") |
| 638 | } |
| 639 | entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...) |
| 640 | if len(a.dexpreopter.builtInstalled) > 0 { |
| 641 | entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled) |
| 642 | } |
| 643 | entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel()) |
| 644 | }, |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 645 | }, |
| 646 | } |
| 647 | } |
| 648 | |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 649 | func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries { |
| 650 | entries := a.AndroidAppImport.AndroidMkEntries() |
| 651 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 652 | testSuiteComponent(entries, a.testProperties.Test_suites) |
| 653 | androidMkWriteTestData(a.data, entries) |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 654 | }) |
| 655 | return entries |
| 656 | } |
| 657 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 658 | func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) { |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 659 | var testFiles []string |
| 660 | for _, d := range data { |
| 661 | testFiles = append(testFiles, d.String()+":"+d.Rel()) |
| 662 | } |
| 663 | entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...) |
| 664 | } |