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 cc |
| 16 | |
| 17 | import ( |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 18 | "fmt" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 19 | "io" |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 20 | "path/filepath" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 21 | "strings" |
| 22 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 23 | "android/soong/android" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 24 | ) |
| 25 | |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 26 | var ( |
dimitry | 4320449 | 2019-05-23 13:24:38 +0200 | [diff] [blame] | 27 | nativeBridgeSuffix = ".native_bridge" |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 28 | productSuffix = ".product" |
dimitry | 4320449 | 2019-05-23 13:24:38 +0200 | [diff] [blame] | 29 | vendorSuffix = ".vendor" |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 30 | ramdiskSuffix = ".ramdisk" |
dimitry | 4320449 | 2019-05-23 13:24:38 +0200 | [diff] [blame] | 31 | recoverySuffix = ".recovery" |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 32 | sdkSuffix = ".sdk" |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 33 | ) |
| 34 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 35 | type AndroidMkContext interface { |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 36 | Name() string |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 37 | Target() android.Target |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 38 | subAndroidMk(*android.AndroidMkEntries, interface{}) |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 39 | Arch() android.Arch |
| 40 | Os() android.OsType |
| 41 | Host() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 42 | UseVndk() bool |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 43 | VndkVersion() string |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 44 | static() bool |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 45 | InRamdisk() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 46 | InRecovery() bool |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | type subAndroidMkProvider interface { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 50 | AndroidMkEntries(AndroidMkContext, *android.AndroidMkEntries) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 53 | func (c *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 54 | if c.subAndroidMkOnce == nil { |
| 55 | c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool) |
| 56 | } |
| 57 | if androidmk, ok := obj.(subAndroidMkProvider); ok { |
| 58 | if !c.subAndroidMkOnce[androidmk] { |
| 59 | c.subAndroidMkOnce[androidmk] = true |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 60 | androidmk.AndroidMkEntries(c, entries) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 61 | } |
| 62 | } |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 65 | func (c *Module) AndroidMkEntries() []android.AndroidMkEntries { |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 66 | if c.Properties.HideFromMake || !c.IsForPlatform() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 67 | return []android.AndroidMkEntries{{ |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 68 | Disabled: true, |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 69 | }} |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 72 | entries := android.AndroidMkEntries{ |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 73 | OutputFile: c.outputFile, |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 74 | // TODO(jiyong): add the APEXes providing shared libs to the required modules |
| 75 | // Currently, adding c.Properties.ApexesProvidingSharedLibs is causing multiple |
Martin Stjernholm | cc4b0ad | 2019-07-05 22:38:25 +0100 | [diff] [blame] | 76 | // ART APEXes (com.android.art.debug|release) to be installed. And this |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 77 | // is breaking some older devices (like marlin) where system.img is small. |
| 78 | Required: c.Properties.AndroidMkRuntimeLibs, |
| 79 | Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk", |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 80 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 81 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
| 82 | func(entries *android.AndroidMkEntries) { |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 83 | if len(c.Properties.Logtags) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 84 | entries.AddStrings("LOCAL_LOGTAGS_FILES", c.Properties.Logtags...) |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 85 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 86 | if len(c.Properties.AndroidMkSharedLibs) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 87 | entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...) |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 88 | } |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 89 | if len(c.Properties.AndroidMkStaticLibs) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 90 | entries.AddStrings("LOCAL_STATIC_LIBRARIES", c.Properties.AndroidMkStaticLibs...) |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 91 | } |
| 92 | if len(c.Properties.AndroidMkWholeStaticLibs) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 93 | entries.AddStrings("LOCAL_WHOLE_STATIC_LIBRARIES", c.Properties.AndroidMkWholeStaticLibs...) |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 94 | } |
Bill Peckham | a46de70 | 2020-04-21 17:23:37 -0700 | [diff] [blame] | 95 | if len(c.Properties.AndroidMkHeaderLibs) > 0 { |
| 96 | entries.AddStrings("LOCAL_HEADER_LIBRARIES", c.Properties.AndroidMkHeaderLibs...) |
| 97 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 98 | entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 99 | if c.UseVndk() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 100 | entries.SetBool("LOCAL_USE_VNDK", true) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 101 | if c.IsVndk() && !c.static() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 102 | entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion()) |
Jooyung Han | b01c114 | 2019-10-29 05:24:42 +0900 | [diff] [blame] | 103 | // VNDK libraries available to vendor are not installed because |
| 104 | // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go) |
| 105 | if !c.isVndkExt() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 106 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
Jooyung Han | b01c114 | 2019-10-29 05:24:42 +0900 | [diff] [blame] | 107 | } |
Jooyung Han | 76106d9 | 2019-05-20 18:49:10 +0900 | [diff] [blame] | 108 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 109 | } |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 110 | if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake { |
| 111 | // Make the SDK variant uninstallable so that there are not two rules to install |
| 112 | // to the same location. |
| 113 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
| 114 | // Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite |
| 115 | // dependencies to the .sdk suffix when building a module that uses the SDK. |
| 116 | entries.SetString("SOONG_SDK_VARIANT_MODULES", |
| 117 | "$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))") |
| 118 | } |
| 119 | }, |
| 120 | }, |
| 121 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
| 122 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
| 123 | if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake && |
| 124 | c.CcLibraryInterface() && c.Shared() { |
| 125 | // Using the SDK variant as a JNI library needs a copy of the .so that |
| 126 | // is not named .sdk.so so that it can be packaged into the APK with |
| 127 | // the right name. |
| 128 | fmt.Fprintln(w, "$(eval $(call copy-one-file,", |
| 129 | "$(LOCAL_BUILT_MODULE),", |
| 130 | "$(patsubst %.sdk.so,%.so,$(LOCAL_BUILT_MODULE))))") |
| 131 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 132 | }, |
| 133 | }, |
| 134 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 135 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 136 | for _, feature := range c.features { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 137 | c.subAndroidMk(&entries, feature) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 138 | } |
| 139 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 140 | c.subAndroidMk(&entries, c.compiler) |
| 141 | c.subAndroidMk(&entries, c.linker) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 142 | if c.sanitize != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 143 | c.subAndroidMk(&entries, c.sanitize) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 144 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 145 | c.subAndroidMk(&entries, c.installer) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 146 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 147 | entries.SubName += c.Properties.SubName |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 148 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 149 | return []android.AndroidMkEntries{entries} |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 150 | } |
| 151 | |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 152 | func AndroidMkDataPaths(data android.Paths) []string { |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 153 | var testFiles []string |
| 154 | for _, d := range data { |
| 155 | rel := d.Rel() |
| 156 | path := d.String() |
| 157 | if !strings.HasSuffix(path, rel) { |
| 158 | panic(fmt.Errorf("path %q does not end with %q", path, rel)) |
| 159 | } |
| 160 | path = strings.TrimSuffix(path, rel) |
| 161 | testFiles = append(testFiles, path+":"+rel) |
| 162 | } |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 163 | return testFiles |
| 164 | } |
| 165 | |
| 166 | func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 167 | testFiles := AndroidMkDataPaths(data) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 168 | if len(testFiles) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 169 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 170 | entries.AddStrings("LOCAL_TEST_DATA", testFiles...) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 171 | }) |
| 172 | } |
| 173 | } |
| 174 | |
dimitry | db41747 | 2019-05-20 16:16:47 +0200 | [diff] [blame] | 175 | func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string { |
| 176 | if ctx.Target().NativeBridge == android.NativeBridgeEnabled { |
| 177 | var result []string |
| 178 | for _, override := range overrides { |
| 179 | result = append(result, override+nativeBridgeSuffix) |
| 180 | } |
| 181 | return result |
| 182 | } |
| 183 | |
| 184 | return overrides |
| 185 | } |
| 186 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 187 | func (library *libraryDecorator) androidMkWriteExportedFlags(entries *android.AndroidMkEntries) { |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 188 | exportedFlags := library.exportedFlags() |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 189 | for _, dir := range library.exportedDirs() { |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 190 | exportedFlags = append(exportedFlags, "-I"+dir.String()) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 191 | } |
| 192 | for _, dir := range library.exportedSystemDirs() { |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 193 | exportedFlags = append(exportedFlags, "-isystem "+dir.String()) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 194 | } |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 195 | if len(exportedFlags) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 196 | entries.AddStrings("LOCAL_EXPORT_CFLAGS", exportedFlags...) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 197 | } |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 198 | exportedDeps := library.exportedDeps() |
| 199 | if len(exportedDeps) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 200 | entries.AddStrings("LOCAL_EXPORT_C_INCLUDE_DEPS", exportedDeps.Strings()...) |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 201 | } |
| 202 | } |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 203 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 204 | func (library *libraryDecorator) androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries *android.AndroidMkEntries) { |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 205 | if library.sAbiOutputFile.Valid() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 206 | entries.SetString("LOCAL_ADDITIONAL_DEPENDENCIES", |
| 207 | "$(LOCAL_ADDITIONAL_DEPENDENCIES) "+library.sAbiOutputFile.String()) |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 208 | if library.sAbiDiff.Valid() && !library.static() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 209 | entries.SetString("LOCAL_ADDITIONAL_DEPENDENCIES", |
| 210 | "$(LOCAL_ADDITIONAL_DEPENDENCIES) "+library.sAbiDiff.String()) |
| 211 | entries.SetString("HEADER_ABI_DIFFS", |
| 212 | "$(HEADER_ABI_DIFFS) "+library.sAbiDiff.String()) |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 217 | // TODO(ccross): remove this once apex/androidmk.go is converted to AndroidMkEntries |
| 218 | func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) { |
| 219 | if library.sAbiOutputFile.Valid() { |
| 220 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_ADDITIONAL_DEPENDENCIES) ", |
| 221 | library.sAbiOutputFile.String()) |
| 222 | if library.sAbiDiff.Valid() && !library.static() { |
| 223 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_ADDITIONAL_DEPENDENCIES) ", |
| 224 | library.sAbiDiff.String()) |
| 225 | fmt.Fprintln(w, "HEADER_ABI_DIFFS := $(HEADER_ABI_DIFFS) ", |
| 226 | library.sAbiDiff.String()) |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 232 | if library.static() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 233 | entries.Class = "STATIC_LIBRARIES" |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 234 | } else if library.shared() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 235 | entries.Class = "SHARED_LIBRARIES" |
| 236 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 237 | entries.SetString("LOCAL_SOONG_TOC", library.toc().String()) |
Jiyong Park | 47e4fcb | 2019-02-05 22:33:10 +0900 | [diff] [blame] | 238 | if !library.buildStubs() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 239 | entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", library.unstrippedOutputFile.String()) |
Jiyong Park | 47e4fcb | 2019-02-05 22:33:10 +0900 | [diff] [blame] | 240 | } |
dimitry | d95964a | 2018-11-07 13:43:34 +0100 | [diff] [blame] | 241 | if len(library.Properties.Overrides) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 242 | entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " ")) |
dimitry | d95964a | 2018-11-07 13:43:34 +0100 | [diff] [blame] | 243 | } |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 244 | if len(library.post_install_cmds) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 245 | entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(library.post_install_cmds, "&& ")) |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 246 | } |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 247 | }) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 248 | } else if library.header() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 249 | entries.Class = "HEADER_LIBRARIES" |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 250 | } |
| 251 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 252 | entries.DistFile = library.distFile |
| 253 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 254 | library.androidMkWriteExportedFlags(entries) |
| 255 | library.androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 256 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 257 | _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base()) |
Logan Chien | 031d2b3 | 2018-07-26 00:19:50 +0800 | [diff] [blame] | 258 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 259 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 260 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 261 | if library.coverageOutputFile.Valid() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 262 | entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", library.coverageOutputFile.String()) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 263 | } |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 264 | |
| 265 | if library.useCoreVariant { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 266 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
| 267 | entries.SetBool("LOCAL_NO_NOTICE_FILE", true) |
| 268 | entries.SetBool("LOCAL_VNDK_DEPEND_ON_CORE_VARIANT", true) |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 269 | } |
Vic Yang | d92090f | 2020-01-08 14:32:28 -0800 | [diff] [blame] | 270 | if library.checkSameCoreVariant { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 271 | entries.SetBool("LOCAL_CHECK_SAME_VNDK_VARIANTS", true) |
Vic Yang | d92090f | 2020-01-08 14:32:28 -0800 | [diff] [blame] | 272 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 273 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 274 | |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 275 | if library.shared() && !library.buildStubs() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 276 | ctx.subAndroidMk(entries, library.baseInstaller) |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 277 | } else { |
Jooyung Han | ad4c187 | 2020-02-27 17:56:44 +0900 | [diff] [blame] | 278 | if library.buildStubs() { |
| 279 | entries.SubName = "." + library.stubsVersion() |
| 280 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 281 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Martin Stjernholm | bf37d16 | 2020-03-31 16:05:34 +0100 | [diff] [blame] | 282 | // Note library.skipInstall() has a special case to get here for static |
| 283 | // libraries that otherwise would have skipped installation and hence not |
| 284 | // have executed AndroidMkEntries at all. The reason is to ensure they get |
| 285 | // a NOTICE file make target which other libraries might depend on. |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 286 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 287 | if library.buildStubs() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 288 | entries.SetBool("LOCAL_NO_NOTICE_FILE", true) |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 289 | } |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 290 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 291 | } |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 292 | if len(library.Properties.Stubs.Versions) > 0 && |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 293 | android.DirectlyInAnyApex(ctx, ctx.Name()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 294 | !ctx.static() { |
Jooyung Han | ad4c187 | 2020-02-27 17:56:44 +0900 | [diff] [blame] | 295 | if library.buildStubs() && library.isLatestStubVersion() { |
| 296 | // reference the latest version via its name without suffix when it is provided by apex |
| 297 | entries.SubName = "" |
| 298 | } |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 299 | if !library.buildStubs() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 300 | entries.SubName = ".bootstrap" |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 301 | } |
| 302 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 305 | func (object *objectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 306 | entries.Class = "STATIC_LIBRARIES" |
| 307 | entries.ExtraFooters = append(entries.ExtraFooters, |
| 308 | func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { |
| 309 | out := entries.OutputFile.Path() |
| 310 | varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 311 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 312 | fmt.Fprintf(w, "\n%s := %s\n", varname, out.String()) |
| 313 | fmt.Fprintln(w, ".KATI_READONLY: "+varname) |
| 314 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 317 | func (binary *binaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 318 | ctx.subAndroidMk(entries, binary.baseInstaller) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 319 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 320 | entries.Class = "EXECUTABLES" |
| 321 | entries.DistFile = binary.distFile |
| 322 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 323 | entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", binary.unstrippedOutputFile.String()) |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 324 | if len(binary.symlinks) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 325 | entries.AddStrings("LOCAL_MODULE_SYMLINKS", binary.symlinks...) |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 326 | } |
| 327 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 328 | if binary.coverageOutputFile.Valid() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 329 | entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", binary.coverageOutputFile.String()) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 330 | } |
Yifan Hong | 946e32e | 2018-04-03 13:22:50 -0700 | [diff] [blame] | 331 | |
| 332 | if len(binary.Properties.Overrides) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 333 | entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " ")) |
Yifan Hong | 946e32e | 2018-04-03 13:22:50 -0700 | [diff] [blame] | 334 | } |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 335 | if len(binary.post_install_cmds) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 336 | entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(binary.post_install_cmds, "&& ")) |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 337 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 338 | }) |
| 339 | } |
| 340 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 341 | func (benchmark *benchmarkDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 342 | ctx.subAndroidMk(entries, benchmark.binaryDecorator) |
| 343 | entries.Class = "NATIVE_TESTS" |
| 344 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 345 | if len(benchmark.Properties.Test_suites) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 346 | entries.SetString("LOCAL_COMPATIBILITY_SUITE", |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 347 | strings.Join(benchmark.Properties.Test_suites, " ")) |
| 348 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 349 | if benchmark.testConfig != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 350 | entries.SetString("LOCAL_FULL_TEST_CONFIG", benchmark.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 351 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 352 | entries.SetBool("LOCAL_NATIVE_BENCHMARK", true) |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 353 | if !BoolDefault(benchmark.Properties.Auto_gen_config, true) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 354 | entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true) |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 355 | } |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 356 | }) |
Anders Lewis | b97e818 | 2017-07-14 15:20:13 -0700 | [diff] [blame] | 357 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 358 | androidMkWriteTestData(benchmark.data, ctx, entries) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 361 | func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 362 | ctx.subAndroidMk(entries, test.binaryDecorator) |
| 363 | entries.Class = "NATIVE_TESTS" |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 364 | if Bool(test.Properties.Test_per_src) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 365 | entries.SubName = "_" + String(test.binaryDecorator.Properties.Stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 366 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 367 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 368 | if len(test.Properties.Test_suites) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 369 | entries.SetString("LOCAL_COMPATIBILITY_SUITE", |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 370 | strings.Join(test.Properties.Test_suites, " ")) |
| 371 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 372 | if test.testConfig != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 373 | entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 374 | } |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 375 | if !BoolDefault(test.Properties.Auto_gen_config, true) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 376 | entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true) |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 377 | } |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 378 | }) |
| 379 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 380 | androidMkWriteTestData(test.data, ctx, entries) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 383 | func (fuzz *fuzzBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 384 | ctx.subAndroidMk(entries, fuzz.binaryDecorator) |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 385 | |
| 386 | var fuzzFiles []string |
| 387 | for _, d := range fuzz.corpus { |
Mitch Phillips | 8a2bc0b | 2019-10-17 15:04:01 -0700 | [diff] [blame] | 388 | fuzzFiles = append(fuzzFiles, |
| 389 | filepath.Dir(fuzz.corpusIntermediateDir.String())+":corpus/"+d.Base()) |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Tri Vo | ad172d8 | 2019-11-27 13:45:45 -0800 | [diff] [blame] | 392 | for _, d := range fuzz.data { |
| 393 | fuzzFiles = append(fuzzFiles, |
| 394 | filepath.Dir(fuzz.dataIntermediateDir.String())+":data/"+d.Rel()) |
| 395 | } |
| 396 | |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 397 | if fuzz.dictionary != nil { |
Mitch Phillips | 8a2bc0b | 2019-10-17 15:04:01 -0700 | [diff] [blame] | 398 | fuzzFiles = append(fuzzFiles, |
| 399 | filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base()) |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 400 | } |
| 401 | |
Kris Alder | f979ee3 | 2019-10-22 10:52:01 -0700 | [diff] [blame] | 402 | if fuzz.config != nil { |
| 403 | fuzzFiles = append(fuzzFiles, |
| 404 | filepath.Dir(fuzz.config.String())+":config.json") |
| 405 | } |
| 406 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 407 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 408 | entries.SetBool("LOCAL_IS_FUZZ_TARGET", true) |
Mitch Phillips | e1ee1a1 | 2019-10-17 19:20:41 -0700 | [diff] [blame] | 409 | if len(fuzzFiles) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 410 | entries.AddStrings("LOCAL_TEST_DATA", fuzzFiles...) |
Mitch Phillips | e1ee1a1 | 2019-10-17 19:20:41 -0700 | [diff] [blame] | 411 | } |
| 412 | if fuzz.installedSharedDeps != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 413 | entries.AddStrings("LOCAL_FUZZ_INSTALLED_SHARED_DEPS", fuzz.installedSharedDeps...) |
Mitch Phillips | e1ee1a1 | 2019-10-17 19:20:41 -0700 | [diff] [blame] | 414 | } |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 415 | }) |
| 416 | } |
| 417 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 418 | func (test *testLibrary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 419 | ctx.subAndroidMk(entries, test.libraryDecorator) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 420 | } |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 421 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 422 | func (library *toolchainLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 423 | entries.Class = "STATIC_LIBRARIES" |
| 424 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 425 | _, suffix, _ := android.SplitFileExt(entries.OutputFile.Path().Base()) |
| 426 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 427 | }) |
| 428 | } |
| 429 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 430 | func (installer *baseInstaller) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 431 | if installer.path == (android.InstallPath{}) { |
| 432 | return |
| 433 | } |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 434 | // Soong installation is only supported for host modules. Have Make |
| 435 | // installation trigger Soong installation. |
| 436 | if ctx.Target().Os.Class == android.Host { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 437 | entries.OutputFile = android.OptionalPathForPath(installer.path) |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 440 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 441 | path, file := filepath.Split(installer.path.ToMakePath().String()) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 442 | stem, suffix, _ := android.SplitFileExt(file) |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 443 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 444 | entries.SetString("LOCAL_MODULE_PATH", path) |
| 445 | entries.SetString("LOCAL_MODULE_STEM", stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 446 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 447 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 448 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 449 | func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 450 | entries.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel |
| 451 | entries.Class = "SHARED_LIBRARIES" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 452 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 453 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 454 | path, file := filepath.Split(c.installPath.String()) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 455 | stem, suffix, _ := android.SplitFileExt(file) |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 456 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 457 | entries.SetString("LOCAL_MODULE_PATH", path) |
| 458 | entries.SetString("LOCAL_MODULE_STEM", stem) |
| 459 | entries.SetBool("LOCAL_NO_NOTICE_FILE", true) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 460 | }) |
| 461 | } |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 462 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 463 | func (c *llndkStubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 464 | entries.Class = "SHARED_LIBRARIES" |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 465 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 466 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 467 | c.libraryDecorator.androidMkWriteExportedFlags(entries) |
| 468 | _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base()) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 469 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 470 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
| 471 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
| 472 | entries.SetBool("LOCAL_NO_NOTICE_FILE", true) |
| 473 | entries.SetString("LOCAL_SOONG_TOC", c.toc().String()) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 474 | }) |
| 475 | } |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 476 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 477 | func (c *vndkPrebuiltLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 478 | entries.Class = "SHARED_LIBRARIES" |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 479 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 480 | entries.SubName = c.androidMkSuffix |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 481 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 482 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 483 | c.libraryDecorator.androidMkWriteExportedFlags(entries) |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 484 | |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 485 | path, file := filepath.Split(c.path.ToMakePath().String()) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 486 | stem, suffix, ext := android.SplitFileExt(file) |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 487 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
| 488 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 489 | entries.SetString("LOCAL_MODULE_PATH", path) |
| 490 | entries.SetString("LOCAL_MODULE_STEM", stem) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 491 | if c.tocFile.Valid() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 492 | entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String()) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 493 | } |
| 494 | }) |
| 495 | } |
| 496 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 497 | func (c *vendorSnapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 498 | // Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current |
| 499 | // and the version of the prebuilt is same as BOARD_VNDK_VERSION. |
| 500 | if c.shared() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 501 | entries.Class = "SHARED_LIBRARIES" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 502 | } else if c.static() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 503 | entries.Class = "STATIC_LIBRARIES" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 504 | } else if c.header() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 505 | entries.Class = "HEADER_LIBRARIES" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | if c.androidMkVendorSuffix { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 509 | entries.SubName = vendorSuffix |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 510 | } else { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 511 | entries.SubName = "" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 512 | } |
| 513 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 514 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 515 | c.libraryDecorator.androidMkWriteExportedFlags(entries) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 516 | |
Inseob Kim | c3b1a16 | 2020-02-18 12:42:54 +0900 | [diff] [blame] | 517 | if c.shared() || c.static() { |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 518 | path, file := filepath.Split(c.path.ToMakePath().String()) |
| 519 | stem, suffix, ext := android.SplitFileExt(file) |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 520 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
| 521 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 522 | entries.SetString("LOCAL_MODULE_STEM", stem) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 523 | if c.shared() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 524 | entries.SetString("LOCAL_MODULE_PATH", path) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 525 | } |
| 526 | if c.tocFile.Valid() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 527 | entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String()) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 528 | } |
Inseob Kim | c3b1a16 | 2020-02-18 12:42:54 +0900 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | if !c.shared() { // static or header |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 532 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 533 | } |
| 534 | }) |
| 535 | } |
| 536 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 537 | func (c *vendorSnapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 538 | entries.Class = "EXECUTABLES" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 539 | |
| 540 | if c.androidMkVendorSuffix { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 541 | entries.SubName = vendorSuffix |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 542 | } else { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 543 | entries.SubName = "" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 544 | } |
| 545 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 546 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 547 | entries.AddStrings("LOCAL_MODULE_SYMLINKS", c.Properties.Symlinks...) |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 548 | }) |
Colin Cross | 7a6fcbe | 2017-12-06 13:08:00 -0800 | [diff] [blame] | 549 | } |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame] | 550 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 551 | func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 552 | entries.Class = "SHARED_LIBRARIES" |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame] | 553 | } |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 554 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 555 | func (c *vendorPublicLibraryStubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 556 | entries.Class = "SHARED_LIBRARIES" |
| 557 | entries.SubName = vendorPublicLibrarySuffix |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 558 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 559 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 560 | c.libraryDecorator.androidMkWriteExportedFlags(entries) |
| 561 | _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base()) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 562 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 563 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
| 564 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
| 565 | entries.SetBool("LOCAL_NO_NOTICE_FILE", true) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 566 | }) |
| 567 | } |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 568 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 569 | func (p *prebuiltLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 570 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 571 | if p.properties.Check_elf_files != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 572 | entries.SetBool("LOCAL_CHECK_ELF_FILES", *p.properties.Check_elf_files) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 573 | } else { |
| 574 | // soong_cc_prebuilt.mk does not include check_elf_file.mk by default |
| 575 | // because cc_library_shared and cc_binary use soong_cc_prebuilt.mk as well. |
| 576 | // In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to |
| 577 | // true if `p.properties.Check_elf_files` is not specified. |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 578 | entries.SetBool("LOCAL_CHECK_ELF_FILES", true) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 579 | } |
| 580 | }) |
| 581 | } |
| 582 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 583 | func (p *prebuiltLibraryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 584 | ctx.subAndroidMk(entries, p.libraryDecorator) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 585 | if p.shared() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 586 | ctx.subAndroidMk(entries, &p.prebuiltLinker) |
| 587 | androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 588 | } |
| 589 | } |
| 590 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 591 | func (p *prebuiltBinaryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 592 | ctx.subAndroidMk(entries, p.binaryDecorator) |
| 593 | ctx.subAndroidMk(entries, &p.prebuiltLinker) |
| 594 | androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 595 | } |
| 596 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 597 | func androidMkWriteAllowUndefinedSymbols(linker *baseLinker, entries *android.AndroidMkEntries) { |
| 598 | allow := linker.Properties.Allow_undefined_symbols |
| 599 | if allow != nil { |
| 600 | entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { |
| 601 | entries.SetBool("LOCAL_ALLOW_UNDEFINED_SYMBOLS", *allow) |
| 602 | }) |
| 603 | } |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 604 | } |