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 ( |
Yu Liu | 6dc93f9 | 2023-12-14 01:19:35 +0000 | [diff] [blame] | 18 | "android/soong/aconfig" |
Inseob Kim | bf1b63f | 2022-01-21 18:12:48 +0900 | [diff] [blame] | 19 | "github.com/google/blueprint/proptools" |
| 20 | |
Dan Willemsen | 9775052 | 2016-02-09 17:43:51 -0800 | [diff] [blame] | 21 | "fmt" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 22 | "io" |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 23 | "path/filepath" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 24 | "strings" |
| 25 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 26 | "android/soong/android" |
Kiyoung Kim | 835c589 | 2022-08-17 16:40:16 +0900 | [diff] [blame] | 27 | "android/soong/multitree" |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 28 | ) |
| 29 | |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 30 | var ( |
Matthew Maurer | a61e31f | 2021-05-27 11:09:11 -0700 | [diff] [blame] | 31 | NativeBridgeSuffix = ".native_bridge" |
Matthew Maurer | 52af5b0 | 2021-05-27 10:01:36 -0700 | [diff] [blame] | 32 | ProductSuffix = ".product" |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 33 | VendorSuffix = ".vendor" |
Matthew Maurer | c686838 | 2021-07-13 14:12:37 -0700 | [diff] [blame] | 34 | RamdiskSuffix = ".ramdisk" |
Ivan Lozano | e6d3098 | 2021-02-05 10:57:43 -0500 | [diff] [blame] | 35 | VendorRamdiskSuffix = ".vendor_ramdisk" |
Matthew Maurer | 460ee94 | 2021-02-11 12:31:46 -0800 | [diff] [blame] | 36 | RecoverySuffix = ".recovery" |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 37 | sdkSuffix = ".sdk" |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 38 | ) |
| 39 | |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 40 | type AndroidMkContext interface { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 41 | BaseModuleName() string |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 42 | Target() android.Target |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 43 | subAndroidMk(*android.AndroidMkEntries, interface{}) |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 44 | Arch() android.Arch |
| 45 | Os() android.OsType |
| 46 | Host() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 47 | UseVndk() bool |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 48 | VndkVersion() string |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 49 | static() bool |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 50 | InRamdisk() bool |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 51 | InVendorRamdisk() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 52 | InRecovery() bool |
Jiyong Park | f7c3bbe | 2020-12-09 21:18:56 +0900 | [diff] [blame] | 53 | NotInPlatform() bool |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | type subAndroidMkProvider interface { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 57 | AndroidMkEntries(AndroidMkContext, *android.AndroidMkEntries) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 60 | func (c *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 61 | if c.subAndroidMkOnce == nil { |
| 62 | c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool) |
| 63 | } |
| 64 | if androidmk, ok := obj.(subAndroidMkProvider); ok { |
| 65 | if !c.subAndroidMkOnce[androidmk] { |
| 66 | c.subAndroidMkOnce[androidmk] = true |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 67 | androidmk.AndroidMkEntries(c, entries) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 68 | } |
| 69 | } |
Dan Willemsen | f2c27d7 | 2016-07-13 16:50:22 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 72 | func (c *Module) AndroidMkEntries() []android.AndroidMkEntries { |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 73 | if c.hideApexVariantFromMake || c.Properties.HideFromMake { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 74 | return []android.AndroidMkEntries{{ |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 75 | Disabled: true, |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 76 | }} |
Colin Cross | bc6fb16 | 2016-05-24 15:39:04 -0700 | [diff] [blame] | 77 | } |
| 78 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 79 | entries := android.AndroidMkEntries{ |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 80 | OutputFile: c.outputFile, |
Martin Stjernholm | 7f51107 | 2020-10-12 15:10:36 +0100 | [diff] [blame] | 81 | // TODO(jiyong): add the APEXes providing shared libs to the required |
| 82 | // modules Currently, adding c.Properties.ApexesProvidingSharedLibs is |
| 83 | // causing multiple ART APEXes (com.android.art and com.android.art.debug) |
| 84 | // to be installed. And this is breaking some older devices (like marlin) |
| 85 | // where system.img is small. |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 86 | Required: c.Properties.AndroidMkRuntimeLibs, |
Ivan Lozano | d06cc74 | 2021-11-12 13:27:58 -0500 | [diff] [blame] | 87 | Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk", |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 88 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 89 | ExtraEntries: []android.AndroidMkExtraEntriesFunc{ |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 90 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 91 | if len(c.Properties.Logtags) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 92 | entries.AddStrings("LOCAL_LOGTAGS_FILES", c.Properties.Logtags...) |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 93 | } |
Yo Chiang | 219968c | 2020-09-22 18:45:04 +0800 | [diff] [blame] | 94 | // Note: Pass the exact value of AndroidMkSystemSharedLibs to the Make |
| 95 | // world, even if it is an empty list. In the Make world, |
| 96 | // LOCAL_SYSTEM_SHARED_LIBRARIES defaults to "none", which is expanded |
| 97 | // to the default list of system shared libs by the build system. |
| 98 | // Soong computes the exact list of system shared libs, so we have to |
| 99 | // override the default value when the list of libs is actually empty. |
| 100 | entries.SetString("LOCAL_SYSTEM_SHARED_LIBRARIES", strings.Join(c.Properties.AndroidMkSystemSharedLibs, " ")) |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 101 | if len(c.Properties.AndroidMkSharedLibs) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 102 | entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...) |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 103 | } |
yangbill | 6db86e5 | 2022-02-08 16:14:25 +0800 | [diff] [blame] | 104 | if len(c.Properties.AndroidMkRuntimeLibs) > 0 { |
| 105 | entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...) |
| 106 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 107 | entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 108 | if c.UseVndk() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 109 | entries.SetBool("LOCAL_USE_VNDK", true) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 110 | if c.IsVndk() && !c.static() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 111 | entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion()) |
Jooyung Han | b01c114 | 2019-10-29 05:24:42 +0900 | [diff] [blame] | 112 | // VNDK libraries available to vendor are not installed because |
| 113 | // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go) |
Ivan Lozano | f9e2172 | 2020-12-02 09:00:51 -0500 | [diff] [blame] | 114 | if !c.IsVndkExt() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 115 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
Jooyung Han | b01c114 | 2019-10-29 05:24:42 +0900 | [diff] [blame] | 116 | } |
Jooyung Han | 76106d9 | 2019-05-20 18:49:10 +0900 | [diff] [blame] | 117 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 118 | } |
Colin Cross | bd3a16b | 2023-04-25 11:30:51 -0700 | [diff] [blame] | 119 | if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 120 | // Make the SDK variant uninstallable so that there are not two rules to install |
| 121 | // to the same location. |
| 122 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
Colin Cross | bd3a16b | 2023-04-25 11:30:51 -0700 | [diff] [blame] | 123 | // Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite |
| 124 | // dependencies to the .sdk suffix when building a module that uses the SDK. |
| 125 | entries.SetString("SOONG_SDK_VARIANT_MODULES", |
| 126 | "$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))") |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 127 | } |
Yu Liu | 6dc93f9 | 2023-12-14 01:19:35 +0000 | [diff] [blame] | 128 | aconfig.SetAconfigFileMkEntries(c.AndroidModuleBase(), entries, c.mergedAconfigFiles) |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 129 | }, |
| 130 | }, |
| 131 | ExtraFooters: []android.AndroidMkExtraFootersFunc{ |
Jaewoong Jung | 02b11a6 | 2020-12-07 10:23:54 -0800 | [diff] [blame] | 132 | func(w io.Writer, name, prefix, moduleDir string) { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 133 | if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake && |
| 134 | c.CcLibraryInterface() && c.Shared() { |
| 135 | // Using the SDK variant as a JNI library needs a copy of the .so that |
| 136 | // is not named .sdk.so so that it can be packaged into the APK with |
| 137 | // the right name. |
| 138 | fmt.Fprintln(w, "$(eval $(call copy-one-file,", |
| 139 | "$(LOCAL_BUILT_MODULE),", |
| 140 | "$(patsubst %.sdk.so,%.so,$(LOCAL_BUILT_MODULE))))") |
| 141 | } |
Colin Cross | a18e9cf | 2017-08-10 17:00:19 -0700 | [diff] [blame] | 142 | }, |
| 143 | }, |
| 144 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 145 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 146 | for _, feature := range c.features { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 147 | c.subAndroidMk(&entries, feature) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 148 | } |
| 149 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 150 | c.subAndroidMk(&entries, c.compiler) |
| 151 | c.subAndroidMk(&entries, c.linker) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 152 | if c.sanitize != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 153 | c.subAndroidMk(&entries, c.sanitize) |
Colin Cross | 8ff9ef4 | 2017-05-08 13:44:11 -0700 | [diff] [blame] | 154 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 155 | c.subAndroidMk(&entries, c.installer) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 156 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 157 | entries.SubName += c.Properties.SubName |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 158 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 159 | return []android.AndroidMkEntries{entries} |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 160 | } |
| 161 | |
Dan Shi | 95d1942 | 2020-08-15 12:24:26 -0700 | [diff] [blame] | 162 | func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) { |
| 163 | if len(extraTestConfigs) > 0 { |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 164 | entries.ExtraEntries = append(entries.ExtraEntries, |
| 165 | func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
| 166 | entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...) |
| 167 | }) |
Dan Shi | 95d1942 | 2020-08-15 12:24:26 -0700 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
dimitry | db41747 | 2019-05-20 16:16:47 +0200 | [diff] [blame] | 171 | func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string { |
| 172 | if ctx.Target().NativeBridge == android.NativeBridgeEnabled { |
| 173 | var result []string |
| 174 | for _, override := range overrides { |
Matthew Maurer | a61e31f | 2021-05-27 11:09:11 -0700 | [diff] [blame] | 175 | result = append(result, override+NativeBridgeSuffix) |
dimitry | db41747 | 2019-05-20 16:16:47 +0200 | [diff] [blame] | 176 | } |
| 177 | return result |
| 178 | } |
| 179 | |
| 180 | return overrides |
| 181 | } |
| 182 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 183 | func (library *libraryDecorator) androidMkWriteExportedFlags(entries *android.AndroidMkEntries) { |
Liz Kammer | b6a55bf | 2021-04-12 15:42:51 -0400 | [diff] [blame] | 184 | var exportedFlags []string |
| 185 | var includeDirs android.Paths |
| 186 | var systemIncludeDirs android.Paths |
| 187 | var exportedDeps android.Paths |
| 188 | |
| 189 | if library.flagExporterInfo != nil { |
| 190 | exportedFlags = library.flagExporterInfo.Flags |
| 191 | includeDirs = library.flagExporterInfo.IncludeDirs |
| 192 | systemIncludeDirs = library.flagExporterInfo.SystemIncludeDirs |
| 193 | exportedDeps = library.flagExporterInfo.Deps |
| 194 | } else { |
| 195 | exportedFlags = library.flagExporter.flags |
| 196 | includeDirs = library.flagExporter.dirs |
| 197 | systemIncludeDirs = library.flagExporter.systemDirs |
| 198 | exportedDeps = library.flagExporter.deps |
| 199 | } |
| 200 | for _, dir := range includeDirs { |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 201 | exportedFlags = append(exportedFlags, "-I"+dir.String()) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 202 | } |
Liz Kammer | b6a55bf | 2021-04-12 15:42:51 -0400 | [diff] [blame] | 203 | for _, dir := range systemIncludeDirs { |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 204 | exportedFlags = append(exportedFlags, "-isystem "+dir.String()) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 205 | } |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 206 | if len(exportedFlags) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 207 | entries.AddStrings("LOCAL_EXPORT_CFLAGS", exportedFlags...) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 208 | } |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 209 | if len(exportedDeps) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 210 | entries.AddStrings("LOCAL_EXPORT_C_INCLUDE_DEPS", exportedDeps.Strings()...) |
Dan Willemsen | 5853940 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 211 | } |
| 212 | } |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 213 | |
Mu-Le Lee | 0a9005e | 2022-07-05 09:49:50 +0000 | [diff] [blame] | 214 | func (library *libraryDecorator) androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries *android.AndroidMkEntries) { |
Hsin-Yi Chen | a6ddb14 | 2022-10-27 14:55:42 +0800 | [diff] [blame] | 215 | if !library.static() { |
| 216 | entries.AddPaths("LOCAL_ADDITIONAL_DEPENDENCIES", library.sAbiDiff) |
| 217 | } |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 218 | } |
| 219 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 220 | // TODO(ccross): remove this once apex/androidmk.go is converted to AndroidMkEntries |
| 221 | func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) { |
Hsin-Yi Chen | a6ddb14 | 2022-10-27 14:55:42 +0800 | [diff] [blame] | 222 | if !library.static() { |
| 223 | fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", strings.Join(library.sAbiDiff.Strings(), " ")) |
| 224 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 228 | if library.static() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 229 | entries.Class = "STATIC_LIBRARIES" |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 230 | } else if library.shared() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 231 | entries.Class = "SHARED_LIBRARIES" |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 232 | entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 233 | entries.SetString("LOCAL_SOONG_TOC", library.toc().String()) |
Alex Márquez Pérez MuñÃz DÃaz Púras Thaureaux | c3b97c3 | 2021-10-05 13:43:23 -0400 | [diff] [blame] | 234 | if !library.buildStubs() && library.unstrippedOutputFile != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 235 | entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", library.unstrippedOutputFile.String()) |
Jiyong Park | 47e4fcb | 2019-02-05 22:33:10 +0900 | [diff] [blame] | 236 | } |
dimitry | d95964a | 2018-11-07 13:43:34 +0100 | [diff] [blame] | 237 | if len(library.Properties.Overrides) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 238 | entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " ")) |
dimitry | d95964a | 2018-11-07 13:43:34 +0100 | [diff] [blame] | 239 | } |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 240 | if len(library.postInstallCmds) > 0 { |
| 241 | entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(library.postInstallCmds, "&& ")) |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 242 | } |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 243 | }) |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 244 | } else if library.header() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 245 | entries.Class = "HEADER_LIBRARIES" |
Dan Willemsen | d578134 | 2017-02-15 16:15:21 -0800 | [diff] [blame] | 246 | } |
| 247 | |
Jingwen Chen | 40fd90a | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 248 | if library.distFile != nil { |
| 249 | entries.DistFiles = android.MakeDefaultDistFiles(library.distFile) |
| 250 | } |
| 251 | |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 252 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 253 | library.androidMkWriteExportedFlags(entries) |
| 254 | library.androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 255 | |
Martin Stjernholm | e65c3ae | 2021-11-23 01:24:06 +0000 | [diff] [blame] | 256 | if entries.OutputFile.Valid() { |
| 257 | _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base()) |
| 258 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
| 259 | } |
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 { |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 278 | if library.buildStubs() && library.stubsVersion() != "" { |
Jooyung Han | ad4c187 | 2020-02-27 17:56:44 +0900 | [diff] [blame] | 279 | entries.SubName = "." + library.stubsVersion() |
| 280 | } |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 281 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | a9c8c9f | 2020-12-16 10:20:23 -0800 | [diff] [blame] | 282 | // library.makeUninstallable() depends on this to bypass HideFromMake() for |
Martin Stjernholm | 9e9bb7f | 2020-08-06 22:34:42 +0100 | [diff] [blame] | 283 | // static libraries. |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 284 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 285 | if library.buildStubs() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 286 | entries.SetBool("LOCAL_NO_NOTICE_FILE", true) |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 287 | } |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 288 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 289 | } |
Jiyong Park | f7c3bbe | 2020-12-09 21:18:56 +0900 | [diff] [blame] | 290 | // If a library providing a stub is included in an APEX, the private APIs of the library |
| 291 | // is accessible only inside the APEX. From outside of the APEX, clients can only use the |
| 292 | // public APIs via the stub. To enforce this, the (latest version of the) stub gets the |
| 293 | // name of the library. The impl library instead gets the `.bootstrap` suffix to so that |
| 294 | // they can be exceptionally used directly when APEXes are not available (e.g. during the |
| 295 | // very early stage in the boot process). |
| 296 | if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.NotInPlatform() && |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 297 | !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() { |
Jooyung Han | ad4c187 | 2020-02-27 17:56:44 +0900 | [diff] [blame] | 298 | if library.buildStubs() && library.isLatestStubVersion() { |
Jooyung Han | ad4c187 | 2020-02-27 17:56:44 +0900 | [diff] [blame] | 299 | entries.SubName = "" |
| 300 | } |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 301 | if !library.buildStubs() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 302 | entries.SubName = ".bootstrap" |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 303 | } |
| 304 | } |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 305 | } |
| 306 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 307 | func (object *objectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 308 | entries.Class = "STATIC_LIBRARIES" |
| 309 | entries.ExtraFooters = append(entries.ExtraFooters, |
Jaewoong Jung | 02b11a6 | 2020-12-07 10:23:54 -0800 | [diff] [blame] | 310 | func(w io.Writer, name, prefix, moduleDir string) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 311 | out := entries.OutputFile.Path() |
| 312 | varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 313 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 314 | fmt.Fprintf(w, "\n%s := %s\n", varname, out.String()) |
| 315 | fmt.Fprintln(w, ".KATI_READONLY: "+varname) |
| 316 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Trevor Radcliffe | f389cb4 | 2022-03-24 21:06:14 +0000 | [diff] [blame] | 319 | func (test *testDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 320 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
| 321 | if len(test.InstallerProperties.Test_suites) > 0 { |
| 322 | entries.AddCompatibilityTestSuites(test.InstallerProperties.Test_suites...) |
| 323 | } |
| 324 | }) |
| 325 | } |
| 326 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 327 | func (binary *binaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 328 | ctx.subAndroidMk(entries, binary.baseInstaller) |
Dan Willemsen | 7517ed0 | 2016-06-10 17:20:30 -0700 | [diff] [blame] | 329 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 330 | entries.Class = "EXECUTABLES" |
Jingwen Chen | 40fd90a | 2020-06-15 05:24:19 +0000 | [diff] [blame] | 331 | entries.DistFiles = binary.distFiles |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 332 | entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 333 | entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", binary.unstrippedOutputFile.String()) |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 334 | if len(binary.symlinks) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 335 | entries.AddStrings("LOCAL_MODULE_SYMLINKS", binary.symlinks...) |
Colin Cross | 9b09f24 | 2016-12-07 13:37:42 -0800 | [diff] [blame] | 336 | } |
| 337 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 338 | if binary.coverageOutputFile.Valid() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 339 | entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", binary.coverageOutputFile.String()) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 340 | } |
Yifan Hong | 946e32e | 2018-04-03 13:22:50 -0700 | [diff] [blame] | 341 | |
| 342 | if len(binary.Properties.Overrides) > 0 { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 343 | entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " ")) |
Yifan Hong | 946e32e | 2018-04-03 13:22:50 -0700 | [diff] [blame] | 344 | } |
Jaewoong Jung | 18aefc1 | 2020-12-21 09:11:10 -0800 | [diff] [blame] | 345 | if len(binary.postInstallCmds) > 0 { |
| 346 | entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(binary.postInstallCmds, "&& ")) |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 347 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 348 | }) |
| 349 | } |
| 350 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 351 | func (benchmark *benchmarkDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 352 | ctx.subAndroidMk(entries, benchmark.binaryDecorator) |
| 353 | entries.Class = "NATIVE_TESTS" |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 354 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 355 | if len(benchmark.Properties.Test_suites) > 0 { |
Liz Kammer | 57f5b33 | 2020-11-24 12:42:58 -0800 | [diff] [blame] | 356 | entries.AddCompatibilityTestSuites(benchmark.Properties.Test_suites...) |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 357 | } |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 358 | if benchmark.testConfig != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 359 | entries.SetString("LOCAL_FULL_TEST_CONFIG", benchmark.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 360 | } |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 361 | entries.SetBool("LOCAL_NATIVE_BENCHMARK", true) |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 362 | if !BoolDefault(benchmark.Properties.Auto_gen_config, true) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 363 | entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true) |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 364 | } |
Colin Cross | e28f4e2 | 2017-04-24 18:10:29 -0700 | [diff] [blame] | 365 | }) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 366 | } |
| 367 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 368 | func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 369 | ctx.subAndroidMk(entries, test.binaryDecorator) |
Trevor Radcliffe | f389cb4 | 2022-03-24 21:06:14 +0000 | [diff] [blame] | 370 | ctx.subAndroidMk(entries, test.testDecorator) |
| 371 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 372 | entries.Class = "NATIVE_TESTS" |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 373 | if Bool(test.Properties.Test_per_src) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 374 | entries.SubName = "_" + String(test.binaryDecorator.Properties.Stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 375 | } |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 376 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | 303e21f | 2018-08-07 16:49:25 -0700 | [diff] [blame] | 377 | if test.testConfig != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 378 | entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String()) |
Julien Desprez | e146e39 | 2018-08-02 15:00:46 -0700 | [diff] [blame] | 379 | } |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 380 | if !BoolDefault(test.Properties.Auto_gen_config, true) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 381 | entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true) |
Dan Shi | 2468d01 | 2020-01-06 15:47:57 -0800 | [diff] [blame] | 382 | } |
kellyhung | 74b0052 | 2020-08-17 18:46:00 +0800 | [diff] [blame] | 383 | entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...) |
Colin Cross | cfb0f5e | 2021-09-24 15:47:17 -0700 | [diff] [blame] | 384 | |
| 385 | entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(test.Properties.Per_testcase_directory)) |
yangbill | 22bafec | 2022-02-11 18:06:07 +0800 | [diff] [blame] | 386 | if len(test.Properties.Data_bins) > 0 { |
| 387 | entries.AddStrings("LOCAL_TEST_DATA_BINS", test.Properties.Data_bins...) |
| 388 | } |
Zhenhuang Wang | 0ac5a43 | 2022-08-12 18:49:20 +0800 | [diff] [blame] | 389 | |
| 390 | test.Properties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries) |
Colin Cross | a929db0 | 2017-03-27 16:27:50 -0700 | [diff] [blame] | 391 | }) |
| 392 | |
Dan Shi | 95d1942 | 2020-08-15 12:24:26 -0700 | [diff] [blame] | 393 | androidMkWriteExtraTestConfigs(test.extraTestConfigs, entries) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 394 | } |
| 395 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 396 | func (fuzz *fuzzBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 397 | ctx.subAndroidMk(entries, fuzz.binaryDecorator) |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 398 | |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 399 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 400 | entries.SetBool("LOCAL_IS_FUZZ_TARGET", true) |
Mitch Phillips | e1ee1a1 | 2019-10-17 19:20:41 -0700 | [diff] [blame] | 401 | if fuzz.installedSharedDeps != nil { |
Colin Cross | 5c1d5fb | 2023-11-15 12:39:40 -0800 | [diff] [blame] | 402 | // TOOD: move to install dep |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 403 | entries.AddStrings("LOCAL_FUZZ_INSTALLED_SHARED_DEPS", fuzz.installedSharedDeps...) |
Mitch Phillips | e1ee1a1 | 2019-10-17 19:20:41 -0700 | [diff] [blame] | 404 | } |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 405 | }) |
| 406 | } |
| 407 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 408 | func (test *testLibrary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 409 | ctx.subAndroidMk(entries, test.libraryDecorator) |
Trevor Radcliffe | f389cb4 | 2022-03-24 21:06:14 +0000 | [diff] [blame] | 410 | ctx.subAndroidMk(entries, test.testDecorator) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 411 | } |
Dan Willemsen | e7932e8 | 2016-05-16 15:56:53 -0700 | [diff] [blame] | 412 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 413 | func (installer *baseInstaller) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 414 | if installer.path == (android.InstallPath{}) { |
| 415 | return |
| 416 | } |
Dan Willemsen | 03ce63e | 2016-09-29 12:17:49 -0700 | [diff] [blame] | 417 | |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 418 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | c68db4b | 2021-11-11 18:59:15 -0800 | [diff] [blame] | 419 | path, file := filepath.Split(installer.path.String()) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 420 | stem, suffix, _ := android.SplitFileExt(file) |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 421 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 422 | entries.SetString("LOCAL_MODULE_PATH", path) |
| 423 | entries.SetString("LOCAL_MODULE_STEM", stem) |
Colin Cross | a234466 | 2016-03-24 13:14:12 -0700 | [diff] [blame] | 424 | }) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 425 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 426 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 427 | func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 428 | entries.SubName = ndkLibrarySuffix + "." + c.apiLevel.String() |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 429 | entries.Class = "SHARED_LIBRARIES" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 430 | |
Colin Cross | 5ec407b | 2020-09-30 11:41:33 -0700 | [diff] [blame] | 431 | if !c.buildStubs() { |
| 432 | entries.Disabled = true |
| 433 | return |
| 434 | } |
| 435 | |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 436 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 437 | path, file := filepath.Split(c.installPath.String()) |
Ivan Lozano | 022a73b | 2019-09-09 20:29:31 -0700 | [diff] [blame] | 438 | stem, suffix, _ := android.SplitFileExt(file) |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 439 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 440 | entries.SetString("LOCAL_MODULE_PATH", path) |
| 441 | entries.SetString("LOCAL_MODULE_STEM", stem) |
| 442 | entries.SetBool("LOCAL_NO_NOTICE_FILE", true) |
sophiez | 58cabb7 | 2020-05-29 13:37:12 -0700 | [diff] [blame] | 443 | if c.parsedCoverageXmlPath.String() != "" { |
| 444 | entries.SetString("SOONG_NDK_API_XML", "$(SOONG_NDK_API_XML) "+c.parsedCoverageXmlPath.String()) |
| 445 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 446 | }) |
| 447 | } |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 448 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 449 | func (c *vndkPrebuiltLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 450 | entries.Class = "SHARED_LIBRARIES" |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 451 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 452 | entries.SubName = c.androidMkSuffix |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 453 | |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 454 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 455 | c.libraryDecorator.androidMkWriteExportedFlags(entries) |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 456 | |
Inseob Kim | 81235ff | 2020-10-23 14:36:11 +0900 | [diff] [blame] | 457 | // Specifying stem is to pass check_elf_files when vendor modules link against vndk prebuilt. |
| 458 | // We can't use install path because VNDKs are not installed. Instead, Srcs is directly used. |
| 459 | _, file := filepath.Split(c.properties.Srcs[0]) |
| 460 | stem, suffix, ext := android.SplitFileExt(file) |
| 461 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
| 462 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 463 | entries.SetString("LOCAL_MODULE_STEM", stem) |
| 464 | |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 465 | if c.tocFile.Valid() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 466 | entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String()) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 467 | } |
Inseob Kim | 81235ff | 2020-10-23 14:36:11 +0900 | [diff] [blame] | 468 | |
| 469 | // VNDK libraries available to vendor are not installed because |
| 470 | // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go) |
| 471 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 472 | }) |
| 473 | } |
| 474 | |
Jose Galmes | f729458 | 2020-11-13 12:07:36 -0800 | [diff] [blame] | 475 | func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 476 | // Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current |
| 477 | // and the version of the prebuilt is same as BOARD_VNDK_VERSION. |
| 478 | if c.shared() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 479 | entries.Class = "SHARED_LIBRARIES" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 480 | } else if c.static() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 481 | entries.Class = "STATIC_LIBRARIES" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 482 | } else if c.header() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 483 | entries.Class = "HEADER_LIBRARIES" |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 484 | } |
| 485 | |
Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 486 | entries.SubName = "" |
| 487 | |
Ivan Lozano | 5467a39 | 2023-08-23 14:20:25 -0400 | [diff] [blame] | 488 | if c.IsSanitizerEnabled(cfi) { |
Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 489 | entries.SubName += ".cfi" |
Ivan Lozano | 5467a39 | 2023-08-23 14:20:25 -0400 | [diff] [blame] | 490 | } else if c.IsSanitizerEnabled(Hwasan) { |
Justin Yun | 39c3031 | 2022-11-23 16:20:12 +0900 | [diff] [blame] | 491 | entries.SubName += ".hwasan" |
Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 492 | } |
| 493 | |
Colin Cross | a889080 | 2021-01-22 14:06:33 -0800 | [diff] [blame] | 494 | entries.SubName += c.baseProperties.Androidmk_suffix |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 495 | |
Inseob Kim | a1888ce | 2022-10-04 14:42:02 +0900 | [diff] [blame] | 496 | entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 497 | c.libraryDecorator.androidMkWriteExportedFlags(entries) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 498 | |
Inseob Kim | c3b1a16 | 2020-02-18 12:42:54 +0900 | [diff] [blame] | 499 | if c.shared() || c.static() { |
Inseob Kim | bf1b63f | 2022-01-21 18:12:48 +0900 | [diff] [blame] | 500 | src := c.path.String() |
| 501 | // For static libraries which aren't installed, directly use Src to extract filename. |
| 502 | // This is safe: generated snapshot modules have a real path as Src, not a module |
| 503 | if c.static() { |
| 504 | src = proptools.String(c.properties.Src) |
| 505 | } |
| 506 | path, file := filepath.Split(src) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 507 | stem, suffix, ext := android.SplitFileExt(file) |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 508 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
| 509 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 510 | entries.SetString("LOCAL_MODULE_STEM", stem) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 511 | if c.shared() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 512 | entries.SetString("LOCAL_MODULE_PATH", path) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 513 | } |
| 514 | if c.tocFile.Valid() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 515 | entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String()) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 516 | } |
Inseob Kim | a1888ce | 2022-10-04 14:42:02 +0900 | [diff] [blame] | 517 | |
| 518 | if c.shared() && len(c.Properties.Overrides) > 0 { |
| 519 | entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, c.Properties.Overrides), " ")) |
| 520 | } |
Inseob Kim | c3b1a16 | 2020-02-18 12:42:54 +0900 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | if !c.shared() { // static or header |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 524 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 525 | } |
| 526 | }) |
| 527 | } |
| 528 | |
Jose Galmes | f729458 | 2020-11-13 12:07:36 -0800 | [diff] [blame] | 529 | func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 530 | entries.Class = "EXECUTABLES" |
Colin Cross | a889080 | 2021-01-22 14:06:33 -0800 | [diff] [blame] | 531 | entries.SubName = c.baseProperties.Androidmk_suffix |
Colin Cross | 7a6fcbe | 2017-12-06 13:08:00 -0800 | [diff] [blame] | 532 | } |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame] | 533 | |
Jose Galmes | f729458 | 2020-11-13 12:07:36 -0800 | [diff] [blame] | 534 | func (c *snapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 535 | entries.Class = "STATIC_LIBRARIES" |
Colin Cross | a889080 | 2021-01-22 14:06:33 -0800 | [diff] [blame] | 536 | entries.SubName = c.baseProperties.Androidmk_suffix |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 537 | |
| 538 | entries.ExtraFooters = append(entries.ExtraFooters, |
Jaewoong Jung | 02b11a6 | 2020-12-07 10:23:54 -0800 | [diff] [blame] | 539 | func(w io.Writer, name, prefix, moduleDir string) { |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 540 | out := entries.OutputFile.Path() |
| 541 | varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName) |
| 542 | |
| 543 | fmt.Fprintf(w, "\n%s := %s\n", varname, out.String()) |
| 544 | fmt.Fprintln(w, ".KATI_READONLY: "+varname) |
| 545 | }) |
| 546 | } |
| 547 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 548 | func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 549 | entries.Class = "SHARED_LIBRARIES" |
Dan Albert | 8ba131b | 2017-12-14 13:23:15 -0800 | [diff] [blame] | 550 | } |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 551 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 552 | func (p *prebuiltLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 553 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 554 | if p.properties.Check_elf_files != nil { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 555 | entries.SetBool("LOCAL_CHECK_ELF_FILES", *p.properties.Check_elf_files) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 556 | } else { |
Ivan Lozano | d06cc74 | 2021-11-12 13:27:58 -0500 | [diff] [blame] | 557 | // soong_cc_rust_prebuilt.mk does not include check_elf_file.mk by default |
| 558 | // because cc_library_shared and cc_binary use soong_cc_rust_prebuilt.mk as well. |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 559 | // In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to |
| 560 | // true if `p.properties.Check_elf_files` is not specified. |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 561 | entries.SetBool("LOCAL_CHECK_ELF_FILES", true) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 562 | } |
| 563 | }) |
| 564 | } |
| 565 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 566 | func (p *prebuiltLibraryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 567 | ctx.subAndroidMk(entries, p.libraryDecorator) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 568 | if p.shared() { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 569 | ctx.subAndroidMk(entries, &p.prebuiltLinker) |
| 570 | androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 571 | } |
| 572 | } |
| 573 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 574 | func (p *prebuiltBinaryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 575 | ctx.subAndroidMk(entries, p.binaryDecorator) |
| 576 | ctx.subAndroidMk(entries, &p.prebuiltLinker) |
| 577 | androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries) |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 578 | } |
| 579 | |
Kiyoung Kim | 835c589 | 2022-08-17 16:40:16 +0900 | [diff] [blame] | 580 | func (a *apiLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 581 | entries.Class = "SHARED_LIBRARIES" |
| 582 | entries.SubName += multitree.GetApiImportSuffix() |
| 583 | |
| 584 | entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
| 585 | a.libraryDecorator.androidMkWriteExportedFlags(entries) |
| 586 | src := *a.properties.Src |
| 587 | path, file := filepath.Split(src) |
| 588 | stem, suffix, ext := android.SplitFileExt(file) |
| 589 | entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) |
| 590 | entries.SetString("LOCAL_MODULE_SUFFIX", suffix) |
| 591 | entries.SetString("LOCAL_MODULE_STEM", stem) |
| 592 | entries.SetString("LOCAL_MODULE_PATH", path) |
| 593 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
| 594 | entries.SetString("LOCAL_SOONG_TOC", a.toc().String()) |
| 595 | }) |
| 596 | } |
| 597 | |
Kiyoung Kim | 51279d3 | 2022-08-24 14:10:46 +0900 | [diff] [blame] | 598 | func (a *apiHeadersDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) { |
| 599 | entries.Class = "HEADER_LIBRARIES" |
| 600 | entries.SubName += multitree.GetApiImportSuffix() |
| 601 | |
| 602 | entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
| 603 | a.libraryDecorator.androidMkWriteExportedFlags(entries) |
| 604 | entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) |
| 605 | }) |
| 606 | } |
| 607 | |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 608 | func androidMkWriteAllowUndefinedSymbols(linker *baseLinker, entries *android.AndroidMkEntries) { |
| 609 | allow := linker.Properties.Allow_undefined_symbols |
| 610 | if allow != nil { |
Colin Cross | aa25553 | 2020-07-03 13:18:24 -0700 | [diff] [blame] | 611 | entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { |
Colin Cross | d80cbca | 2020-02-24 12:01:37 -0800 | [diff] [blame] | 612 | entries.SetBool("LOCAL_ALLOW_UNDEFINED_SYMBOLS", *allow) |
| 613 | }) |
| 614 | } |
Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 615 | } |