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