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 { |
Jiyong Park | 52cd06f | 2019-11-11 10:14:32 +0900 | [diff] [blame^] | 265 | if !app.IsForPlatform() { |
| 266 | return android.AndroidMkEntries{ |
| 267 | Disabled: true, |
| 268 | } |
| 269 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 270 | return android.AndroidMkEntries{ |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 271 | Class: "APPS", |
| 272 | OutputFile: android.OptionalPathForPath(app.outputFile), |
| 273 | Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 274 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 275 | func(entries *android.AndroidMkEntries) { |
| 276 | // App module names can be overridden. |
| 277 | entries.SetString("LOCAL_MODULE", app.installApkName) |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 278 | entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", app.exportPackage) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 279 | if app.dexJarFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 280 | entries.SetPath("LOCAL_SOONG_DEX_JAR", app.dexJarFile) |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 281 | } |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 282 | if app.implementationAndResourcesJar != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 283 | entries.SetPath("LOCAL_SOONG_CLASSES_JAR", app.implementationAndResourcesJar) |
Colin Cross | 5dfabfb | 2017-12-14 13:19:01 -0800 | [diff] [blame] | 284 | } |
| 285 | if app.headerJarFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 286 | entries.SetPath("LOCAL_SOONG_HEADER_JAR", app.headerJarFile) |
Colin Cross | 5dfabfb | 2017-12-14 13:19:01 -0800 | [diff] [blame] | 287 | } |
Colin Cross | f623721 | 2018-10-29 23:14:58 -0700 | [diff] [blame] | 288 | if app.bundleFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 289 | entries.SetPath("LOCAL_SOONG_BUNDLE", app.bundleFile) |
Colin Cross | f623721 | 2018-10-29 23:14:58 -0700 | [diff] [blame] | 290 | } |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 291 | if app.jacocoReportClassesFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 292 | entries.SetPath("LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR", app.jacocoReportClassesFile) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 293 | } |
Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 294 | if app.proguardDictionary != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 295 | entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", app.proguardDictionary) |
Colin Cross | 66dbc0b | 2017-12-28 12:23:20 -0800 | [diff] [blame] | 296 | } |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 297 | |
| 298 | if app.Name() == "framework-res" { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 299 | entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)") |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 300 | // Make base_rules.mk not put framework-res in a subdirectory called |
| 301 | // framework_res. |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 302 | entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 303 | } |
| 304 | |
Anton Hansson | 53c8844 | 2019-03-18 15:53:16 +0000 | [diff] [blame] | 305 | filterRRO := func(filter overlayType) android.Paths { |
| 306 | var paths android.Paths |
| 307 | for _, d := range app.rroDirs { |
| 308 | if d.overlayType == filter { |
| 309 | paths = append(paths, d.path) |
| 310 | } |
| 311 | } |
Colin Cross | a140bb0 | 2018-04-17 10:52:26 -0700 | [diff] [blame] | 312 | // Reverse the order, Soong stores rroDirs in aapt2 order (low to high priority), but Make |
| 313 | // expects it in LOCAL_RESOURCE_DIRS order (high to low priority). |
Anton Hansson | 53c8844 | 2019-03-18 15:53:16 +0000 | [diff] [blame] | 314 | return android.ReversePaths(paths) |
| 315 | } |
| 316 | deviceRRODirs := filterRRO(device) |
| 317 | if len(deviceRRODirs) > 0 { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 318 | entries.AddStrings("LOCAL_SOONG_DEVICE_RRO_DIRS", deviceRRODirs.Strings()...) |
Anton Hansson | 53c8844 | 2019-03-18 15:53:16 +0000 | [diff] [blame] | 319 | } |
| 320 | productRRODirs := filterRRO(product) |
| 321 | if len(productRRODirs) > 0 { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 322 | entries.AddStrings("LOCAL_SOONG_PRODUCT_RRO_DIRS", productRRODirs.Strings()...) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 323 | } |
| 324 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 325 | entries.SetBoolIfTrue("LOCAL_EXPORT_PACKAGE_RESOURCES", Bool(app.appProperties.Export_package_resources)) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 326 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 327 | entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath) |
Colin Cross | 7079856 | 2017-12-13 22:42:59 -0800 | [diff] [blame] | 328 | |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 329 | entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged()) |
Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 330 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 331 | entries.SetPath("LOCAL_CERTIFICATE", app.certificate.Pem) |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 332 | entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...) |
Colin Cross | a4f0881 | 2018-10-02 22:03:40 -0700 | [diff] [blame] | 333 | |
| 334 | for _, jniLib := range app.installJniLibs { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 335 | 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] | 336 | } |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 337 | if len(app.dexpreopter.builtInstalled) > 0 { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 338 | entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled) |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 339 | } |
Jaewoong Jung | 5a49881 | 2019-11-07 14:14:38 -0800 | [diff] [blame] | 340 | for _, extra := range app.extraOutputFiles { |
| 341 | install := app.onDeviceDir + "/" + extra.Base() |
| 342 | entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install) |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 343 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 344 | }, |
| 345 | }, |
| 346 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 347 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
Jaewoong Jung | 9877279 | 2019-07-01 17:15:13 -0700 | [diff] [blame] | 348 | if app.noticeOutputs.Merged.Valid() { |
| 349 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 350 | app.installApkName, app.noticeOutputs.Merged.String(), app.installApkName+"_NOTICE") |
| 351 | } |
| 352 | if app.noticeOutputs.TxtOutput.Valid() { |
| 353 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 354 | app.installApkName, app.noticeOutputs.TxtOutput.String(), app.installApkName+"_NOTICE.txt") |
| 355 | } |
| 356 | if app.noticeOutputs.HtmlOutput.Valid() { |
| 357 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", |
| 358 | app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html") |
| 359 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 360 | }, |
| 361 | }, |
| 362 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 363 | } |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 364 | |
Jaewoong Jung | 9109d72 | 2019-01-30 13:13:52 -0800 | [diff] [blame] | 365 | func (a *AndroidApp) getOverriddenPackages() []string { |
| 366 | var overridden []string |
| 367 | if len(a.appProperties.Overrides) > 0 { |
| 368 | overridden = append(overridden, a.appProperties.Overrides...) |
| 369 | } |
| 370 | if a.Name() != a.installApkName { |
| 371 | overridden = append(overridden, a.Name()) |
| 372 | } |
| 373 | return overridden |
| 374 | } |
| 375 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 376 | func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries { |
| 377 | entries := a.AndroidApp.AndroidMkEntries() |
| 378 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 379 | testSuiteComponent(entries, a.testProperties.Test_suites) |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 380 | if a.testConfig != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 381 | entries.SetPath("LOCAL_FULL_TEST_CONFIG", a.testConfig) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 382 | } |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 383 | androidMkWriteTestData(a.data, entries) |
Colin Cross | 252fc6f | 2018-10-04 15:22:03 -0700 | [diff] [blame] | 384 | }) |
| 385 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 386 | return entries |
Colin Cross | 252fc6f | 2018-10-04 15:22:03 -0700 | [diff] [blame] | 387 | } |
| 388 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 389 | func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries { |
| 390 | entries := a.AndroidApp.AndroidMkEntries() |
| 391 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 392 | testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites) |
| 393 | }) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 394 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 395 | return entries |
| 396 | } |
| 397 | |
| 398 | func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries { |
| 399 | entries := a.Library.AndroidMkEntries() |
| 400 | |
| 401 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Colin Cross | a54974c | 2018-10-29 23:15:37 -0700 | [diff] [blame] | 402 | if a.aarFile != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 403 | entries.SetPath("LOCAL_SOONG_AAR", a.aarFile) |
Colin Cross | a54974c | 2018-10-29 23:15:37 -0700 | [diff] [blame] | 404 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 405 | |
| 406 | if a.Name() == "framework-res" { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 407 | entries.SetString("LOCAL_MODULE_PATH", "$(TARGET_OUT_JAVA_LIBRARIES)") |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 408 | // Make base_rules.mk not put framework-res in a subdirectory called |
| 409 | // framework_res. |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 410 | entries.SetBoolIfTrue("LOCAL_NO_STANDARD_LIBRARIES", true) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 411 | } |
| 412 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 413 | entries.SetPath("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE", a.exportPackage) |
| 414 | entries.SetPath("LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES", a.extraAaptPackagesFile) |
| 415 | entries.SetPath("LOCAL_FULL_MANIFEST_FILE", a.mergedManifestFile) |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 416 | entries.AddStrings("LOCAL_SOONG_EXPORT_PROGUARD_FLAGS", a.exportedProguardFlagFiles.Strings()...) |
| 417 | entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 418 | }) |
| 419 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 420 | return entries |
Colin Cross | 5ab4e6d | 2017-11-22 16:20:45 -0800 | [diff] [blame] | 421 | } |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 422 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 423 | func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries { |
| 424 | return android.AndroidMkEntries{ |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 425 | Class: "JAVA_LIBRARIES", |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 426 | OutputFile: android.OptionalPathForPath(jd.stubsSrcJar), |
Colin Cross | 5fa9d6f | 2018-08-08 21:44:48 -0700 | [diff] [blame] | 427 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 428 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 429 | func(entries *android.AndroidMkEntries) { |
Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 430 | if BoolDefault(jd.properties.Installable, true) { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 431 | entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 432 | } |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 433 | if jd.stubsSrcJar != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 434 | entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 435 | } |
| 436 | }, |
| 437 | }, |
| 438 | } |
| 439 | } |
| 440 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 441 | func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries { |
| 442 | return android.AndroidMkEntries{ |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 443 | Class: "JAVA_LIBRARIES", |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 444 | OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar), |
Colin Cross | 5fa9d6f | 2018-08-08 21:44:48 -0700 | [diff] [blame] | 445 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 446 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 447 | func(entries *android.AndroidMkEntries) { |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 448 | if BoolDefault(ddoc.Javadoc.properties.Installable, true) && ddoc.Javadoc.docZip != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 449 | entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", ddoc.Javadoc.docZip) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 450 | } |
Nan Zhang | ccff0f7 | 2018-03-08 17:26:16 -0800 | [diff] [blame] | 451 | if ddoc.Javadoc.stubsSrcJar != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 452 | entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", ddoc.Javadoc.stubsSrcJar) |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 453 | } |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 454 | apiFilePrefix := "INTERNAL_PLATFORM_" |
| 455 | if String(ddoc.properties.Api_tag_name) != "" { |
| 456 | apiFilePrefix += String(ddoc.properties.Api_tag_name) + "_" |
| 457 | } |
| 458 | if ddoc.apiFile != nil { |
| 459 | entries.SetPath(apiFilePrefix+"API_FILE", ddoc.apiFile) |
| 460 | } |
| 461 | if ddoc.dexApiFile != nil { |
| 462 | entries.SetPath(apiFilePrefix+"DEX_API_FILE", ddoc.dexApiFile) |
| 463 | } |
| 464 | if ddoc.privateApiFile != nil { |
| 465 | entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", ddoc.privateApiFile) |
| 466 | } |
| 467 | if ddoc.privateDexApiFile != nil { |
| 468 | entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", ddoc.privateDexApiFile) |
| 469 | } |
| 470 | if ddoc.removedApiFile != nil { |
| 471 | entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", ddoc.removedApiFile) |
| 472 | } |
| 473 | if ddoc.removedDexApiFile != nil { |
| 474 | entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", ddoc.removedDexApiFile) |
| 475 | } |
| 476 | if ddoc.exactApiFile != nil { |
| 477 | entries.SetPath(apiFilePrefix+"EXACT_API_FILE", ddoc.exactApiFile) |
| 478 | } |
| 479 | if ddoc.proguardFile != nil { |
| 480 | entries.SetPath(apiFilePrefix+"PROGUARD_FILE", ddoc.proguardFile) |
| 481 | } |
| 482 | }, |
| 483 | }, |
| 484 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 485 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 486 | if ddoc.checkCurrentApiTimestamp != nil { |
| 487 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-current-api") |
| 488 | fmt.Fprintln(w, ddoc.Name()+"-check-current-api:", |
| 489 | ddoc.checkCurrentApiTimestamp.String()) |
| 490 | |
| 491 | fmt.Fprintln(w, ".PHONY: checkapi") |
Jiyong Park | eeb8a64 | 2018-05-12 22:21:20 +0900 | [diff] [blame] | 492 | fmt.Fprintln(w, "checkapi:", |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 493 | ddoc.checkCurrentApiTimestamp.String()) |
| 494 | |
| 495 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 496 | fmt.Fprintln(w, "droidcore: checkapi") |
| 497 | } |
| 498 | if ddoc.updateCurrentApiTimestamp != nil { |
Dan Willemsen | a03c43a | 2018-07-24 13:00:52 -0700 | [diff] [blame] | 499 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-update-current-api") |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 500 | fmt.Fprintln(w, ddoc.Name()+"-update-current-api:", |
| 501 | ddoc.updateCurrentApiTimestamp.String()) |
| 502 | |
| 503 | fmt.Fprintln(w, ".PHONY: update-api") |
| 504 | fmt.Fprintln(w, "update-api:", |
| 505 | ddoc.updateCurrentApiTimestamp.String()) |
| 506 | } |
| 507 | if ddoc.checkLastReleasedApiTimestamp != nil { |
| 508 | fmt.Fprintln(w, ".PHONY:", ddoc.Name()+"-check-last-released-api") |
| 509 | fmt.Fprintln(w, ddoc.Name()+"-check-last-released-api:", |
| 510 | ddoc.checkLastReleasedApiTimestamp.String()) |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 511 | |
Adrian Roos | 62e34b9 | 2019-01-30 19:51:39 +0100 | [diff] [blame] | 512 | if ddoc.Name() == "api-stubs-docs" || ddoc.Name() == "system-api-stubs-docs" { |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 513 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 514 | fmt.Fprintln(w, "checkapi:", |
| 515 | ddoc.checkLastReleasedApiTimestamp.String()) |
| 516 | |
| 517 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 518 | fmt.Fprintln(w, "droidcore: checkapi") |
| 519 | } |
Nan Zhang | 61819ce | 2018-05-04 18:49:16 -0700 | [diff] [blame] | 520 | } |
Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 521 | }, |
| 522 | }, |
| 523 | } |
| 524 | } |
Colin Cross | d96ca35 | 2018-08-10 16:06:24 -0700 | [diff] [blame] | 525 | |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 526 | func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries { |
| 527 | return android.AndroidMkEntries{ |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 528 | Class: "JAVA_LIBRARIES", |
| 529 | OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar), |
| 530 | Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 531 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 532 | func(entries *android.AndroidMkEntries) { |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 533 | if dstubs.Javadoc.stubsSrcJar != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 534 | entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar) |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 535 | } |
Nan Zhang | d23ac69 | 2018-09-18 10:41:33 -0700 | [diff] [blame] | 536 | if dstubs.apiVersionsXml != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 537 | entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.apiVersionsXml) |
Nan Zhang | d23ac69 | 2018-09-18 10:41:33 -0700 | [diff] [blame] | 538 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 539 | if dstubs.annotationsZip != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 540 | entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.annotationsZip) |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 541 | } |
Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 542 | if dstubs.jdiffDocZip != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 543 | entries.SetPath("LOCAL_DROIDDOC_JDIFF_DOC_ZIP", dstubs.jdiffDocZip) |
Nan Zhang | 71bbe63 | 2018-09-17 14:32:21 -0700 | [diff] [blame] | 544 | } |
Jerome Gaillard | 0f59903 | 2019-10-10 19:29:11 +0100 | [diff] [blame] | 545 | if dstubs.metadataZip != nil { |
| 546 | entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.metadataZip) |
| 547 | } |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 548 | apiFilePrefix := "INTERNAL_PLATFORM_" |
| 549 | if String(dstubs.properties.Api_tag_name) != "" { |
| 550 | apiFilePrefix += String(dstubs.properties.Api_tag_name) + "_" |
| 551 | } |
| 552 | if dstubs.apiFile != nil { |
| 553 | entries.SetPath(apiFilePrefix+"API_FILE", dstubs.apiFile) |
| 554 | } |
| 555 | if dstubs.dexApiFile != nil { |
| 556 | entries.SetPath(apiFilePrefix+"DEX_API_FILE", dstubs.dexApiFile) |
| 557 | } |
| 558 | if dstubs.privateApiFile != nil { |
| 559 | entries.SetPath(apiFilePrefix+"PRIVATE_API_FILE", dstubs.privateApiFile) |
| 560 | } |
| 561 | if dstubs.privateDexApiFile != nil { |
| 562 | entries.SetPath(apiFilePrefix+"PRIVATE_DEX_API_FILE", dstubs.privateDexApiFile) |
| 563 | } |
| 564 | if dstubs.removedApiFile != nil { |
| 565 | entries.SetPath(apiFilePrefix+"REMOVED_API_FILE", dstubs.removedApiFile) |
| 566 | } |
| 567 | if dstubs.removedDexApiFile != nil { |
| 568 | entries.SetPath(apiFilePrefix+"REMOVED_DEX_API_FILE", dstubs.removedDexApiFile) |
| 569 | } |
| 570 | if dstubs.exactApiFile != nil { |
| 571 | entries.SetPath(apiFilePrefix+"EXACT_API_FILE", dstubs.exactApiFile) |
| 572 | } |
| 573 | }, |
| 574 | }, |
| 575 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 576 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 577 | if dstubs.checkCurrentApiTimestamp != nil { |
| 578 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-current-api") |
| 579 | fmt.Fprintln(w, dstubs.Name()+"-check-current-api:", |
| 580 | dstubs.checkCurrentApiTimestamp.String()) |
| 581 | |
| 582 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 583 | fmt.Fprintln(w, "checkapi:", |
| 584 | dstubs.checkCurrentApiTimestamp.String()) |
| 585 | |
| 586 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 587 | fmt.Fprintln(w, "droidcore: checkapi") |
| 588 | } |
| 589 | if dstubs.updateCurrentApiTimestamp != nil { |
| 590 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-update-current-api") |
| 591 | fmt.Fprintln(w, dstubs.Name()+"-update-current-api:", |
| 592 | dstubs.updateCurrentApiTimestamp.String()) |
| 593 | |
| 594 | fmt.Fprintln(w, ".PHONY: update-api") |
| 595 | fmt.Fprintln(w, "update-api:", |
| 596 | dstubs.updateCurrentApiTimestamp.String()) |
| 597 | } |
| 598 | if dstubs.checkLastReleasedApiTimestamp != nil { |
| 599 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-last-released-api") |
| 600 | fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:", |
| 601 | dstubs.checkLastReleasedApiTimestamp.String()) |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 602 | |
Adrian Roos | 62e34b9 | 2019-01-30 19:51:39 +0100 | [diff] [blame] | 603 | if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" { |
Adrian Roos | e3fe481 | 2019-01-23 14:51:55 +0100 | [diff] [blame] | 604 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 605 | fmt.Fprintln(w, "checkapi:", |
| 606 | dstubs.checkLastReleasedApiTimestamp.String()) |
| 607 | |
| 608 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 609 | fmt.Fprintln(w, "droidcore: checkapi") |
| 610 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 611 | } |
Adrian Roos | 075eedc | 2019-10-10 12:07:03 +0200 | [diff] [blame] | 612 | if dstubs.apiLintTimestamp != nil { |
| 613 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-api-lint") |
| 614 | fmt.Fprintln(w, dstubs.Name()+"-api-lint:", |
| 615 | dstubs.apiLintTimestamp.String()) |
| 616 | |
| 617 | fmt.Fprintln(w, ".PHONY: checkapi") |
| 618 | fmt.Fprintln(w, "checkapi:", |
Adrian Roos | 3b8f1cd | 2019-11-01 13:42:39 +0100 | [diff] [blame] | 619 | dstubs.Name()+"-api-lint") |
Adrian Roos | 075eedc | 2019-10-10 12:07:03 +0200 | [diff] [blame] | 620 | |
| 621 | fmt.Fprintln(w, ".PHONY: droidcore") |
| 622 | fmt.Fprintln(w, "droidcore: checkapi") |
Adrian Roos | 3b8f1cd | 2019-11-01 13:42:39 +0100 | [diff] [blame] | 623 | |
| 624 | if dstubs.apiLintReport != nil { |
| 625 | fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint", |
| 626 | dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt") |
| 627 | } |
Adrian Roos | 075eedc | 2019-10-10 12:07:03 +0200 | [diff] [blame] | 628 | } |
Pete Gillin | 581d608 | 2018-10-22 15:55:04 +0100 | [diff] [blame] | 629 | if dstubs.checkNullabilityWarningsTimestamp != nil { |
| 630 | fmt.Fprintln(w, ".PHONY:", dstubs.Name()+"-check-nullability-warnings") |
| 631 | fmt.Fprintln(w, dstubs.Name()+"-check-nullability-warnings:", |
| 632 | dstubs.checkNullabilityWarningsTimestamp.String()) |
| 633 | |
| 634 | fmt.Fprintln(w, ".PHONY:", "droidcore") |
| 635 | fmt.Fprintln(w, "droidcore: ", dstubs.Name()+"-check-nullability-warnings") |
| 636 | } |
Nan Zhang | 1598a9e | 2018-09-04 17:14:32 -0700 | [diff] [blame] | 637 | }, |
| 638 | }, |
| 639 | } |
| 640 | } |
| 641 | |
Jaewoong Jung | 8aae22e | 2019-07-17 10:21:49 -0700 | [diff] [blame] | 642 | func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries { |
| 643 | return android.AndroidMkEntries{ |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 644 | Class: "APPS", |
Jaewoong Jung | 8aae22e | 2019-07-17 10:21:49 -0700 | [diff] [blame] | 645 | OutputFile: android.OptionalPathForPath(a.outputFile), |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 646 | Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 647 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 648 | func(entries *android.AndroidMkEntries) { |
Jiyong Park | f748731 | 2019-10-17 12:54:30 +0900 | [diff] [blame] | 649 | entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged()) |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 650 | if a.certificate != nil { |
Jaewoong Jung | 9a1e8bd | 2019-09-04 20:17:54 -0700 | [diff] [blame] | 651 | entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem) |
Jaewoong Jung | e0dc8df | 2019-08-27 17:33:16 -0700 | [diff] [blame] | 652 | } else { |
| 653 | entries.SetString("LOCAL_CERTIFICATE", "PRESIGNED") |
| 654 | } |
| 655 | entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", a.properties.Overrides...) |
| 656 | if len(a.dexpreopter.builtInstalled) > 0 { |
| 657 | entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", a.dexpreopter.builtInstalled) |
| 658 | } |
| 659 | entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel()) |
| 660 | }, |
Jaewoong Jung | ccbb393 | 2019-04-15 09:48:31 -0700 | [diff] [blame] | 661 | }, |
| 662 | } |
| 663 | } |
| 664 | |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 665 | func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries { |
| 666 | entries := a.AndroidAppImport.AndroidMkEntries() |
| 667 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 668 | testSuiteComponent(entries, a.testProperties.Test_suites) |
| 669 | androidMkWriteTestData(a.data, entries) |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 670 | }) |
| 671 | return entries |
| 672 | } |
| 673 | |
Jaewoong Jung | b0c127c | 2019-08-29 14:56:03 -0700 | [diff] [blame] | 674 | func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) { |
Jaewoong Jung | b28eb5f | 2019-08-27 15:01:50 -0700 | [diff] [blame] | 675 | var testFiles []string |
| 676 | for _, d := range data { |
| 677 | testFiles = append(testFiles, d.String()+":"+d.Rel()) |
| 678 | } |
| 679 | entries.AddStrings("LOCAL_COMPATIBILITY_SUPPORT_FILES", testFiles...) |
| 680 | } |