blob: ff5ba457692423bc26bd7dbe547609a8c6b54b33 [file] [log] [blame]
Dan Willemsen218f6562015-07-08 18:13:11 -07001// 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
15package cc
16
17import (
Inseob Kimbf1b63f2022-01-21 18:12:48 +090018 "github.com/google/blueprint/proptools"
19
Dan Willemsen97750522016-02-09 17:43:51 -080020 "fmt"
Dan Willemsen218f6562015-07-08 18:13:11 -070021 "io"
Colin Crossa2344662016-03-24 13:14:12 -070022 "path/filepath"
Dan Willemsen218f6562015-07-08 18:13:11 -070023 "strings"
24
Colin Cross635c3b02016-05-18 15:37:25 -070025 "android/soong/android"
Dan Willemsen218f6562015-07-08 18:13:11 -070026)
27
Jiyong Park27b188b2017-07-18 13:23:39 +090028var (
Matthew Maurera61e31f2021-05-27 11:09:11 -070029 NativeBridgeSuffix = ".native_bridge"
Matthew Maurer52af5b02021-05-27 10:01:36 -070030 ProductSuffix = ".product"
Ivan Lozanoe6d30982021-02-05 10:57:43 -050031 VendorSuffix = ".vendor"
Matthew Maurerc6868382021-07-13 14:12:37 -070032 RamdiskSuffix = ".ramdisk"
Ivan Lozanoe6d30982021-02-05 10:57:43 -050033 VendorRamdiskSuffix = ".vendor_ramdisk"
Matthew Maurer460ee942021-02-11 12:31:46 -080034 RecoverySuffix = ".recovery"
Yifan Hong60e0cfb2020-10-21 15:17:56 -070035 sdkSuffix = ".sdk"
Jiyong Park27b188b2017-07-18 13:23:39 +090036)
37
Dan Willemsenf2c27d72016-07-13 16:50:22 -070038type AndroidMkContext interface {
Colin Cross0477b422020-10-13 18:43:54 -070039 BaseModuleName() string
Dan Willemsenf2c27d72016-07-13 16:50:22 -070040 Target() android.Target
Colin Crossd80cbca2020-02-24 12:01:37 -080041 subAndroidMk(*android.AndroidMkEntries, interface{})
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +000042 Arch() android.Arch
43 Os() android.OsType
44 Host() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070045 UseVndk() bool
Justin Yun5f7f7e82019-11-18 19:52:14 +090046 VndkVersion() string
Jiyong Parkb0788572018-12-20 22:10:17 +090047 static() bool
Yifan Hong1b3348d2020-01-21 15:53:22 -080048 InRamdisk() bool
Yifan Hong60e0cfb2020-10-21 15:17:56 -070049 InVendorRamdisk() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070050 InRecovery() bool
Jiyong Parkf7c3bbe2020-12-09 21:18:56 +090051 NotInPlatform() bool
Colin Crossb916a382016-07-29 17:28:03 -070052}
53
54type subAndroidMkProvider interface {
Colin Crossd80cbca2020-02-24 12:01:37 -080055 AndroidMkEntries(AndroidMkContext, *android.AndroidMkEntries)
Colin Crossb916a382016-07-29 17:28:03 -070056}
57
Colin Crossd80cbca2020-02-24 12:01:37 -080058func (c *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) {
Colin Crossb916a382016-07-29 17:28:03 -070059 if c.subAndroidMkOnce == nil {
60 c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
61 }
62 if androidmk, ok := obj.(subAndroidMkProvider); ok {
63 if !c.subAndroidMkOnce[androidmk] {
64 c.subAndroidMkOnce[androidmk] = true
Colin Crossd80cbca2020-02-24 12:01:37 -080065 androidmk.AndroidMkEntries(c, entries)
Colin Crossb916a382016-07-29 17:28:03 -070066 }
67 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070068}
69
Colin Crossd80cbca2020-02-24 12:01:37 -080070func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -070071 if c.hideApexVariantFromMake || c.Properties.HideFromMake {
Colin Crossd80cbca2020-02-24 12:01:37 -080072 return []android.AndroidMkEntries{{
Colin Crossa18e9cf2017-08-10 17:00:19 -070073 Disabled: true,
Colin Crossd80cbca2020-02-24 12:01:37 -080074 }}
Colin Crossbc6fb162016-05-24 15:39:04 -070075 }
76
Colin Crossd80cbca2020-02-24 12:01:37 -080077 entries := android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -070078 OutputFile: c.outputFile,
Martin Stjernholm7f511072020-10-12 15:10:36 +010079 // TODO(jiyong): add the APEXes providing shared libs to the required
80 // modules Currently, adding c.Properties.ApexesProvidingSharedLibs is
81 // causing multiple ART APEXes (com.android.art and com.android.art.debug)
82 // to be installed. And this is breaking some older devices (like marlin)
83 // where system.img is small.
Jiyong Parkb0788572018-12-20 22:10:17 +090084 Required: c.Properties.AndroidMkRuntimeLibs,
Ivan Lozanod06cc742021-11-12 13:27:58 -050085 Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
Logan Chien43d34c32017-12-20 01:17:32 +080086
Colin Crossd80cbca2020-02-24 12:01:37 -080087 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
Colin Crossaa255532020-07-03 13:18:24 -070088 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross5beccee2017-12-07 15:28:59 -080089 if len(c.Properties.Logtags) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -080090 entries.AddStrings("LOCAL_LOGTAGS_FILES", c.Properties.Logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080091 }
Yo Chiang219968c2020-09-22 18:45:04 +080092 // Note: Pass the exact value of AndroidMkSystemSharedLibs to the Make
93 // world, even if it is an empty list. In the Make world,
94 // LOCAL_SYSTEM_SHARED_LIBRARIES defaults to "none", which is expanded
95 // to the default list of system shared libs by the build system.
96 // Soong computes the exact list of system shared libs, so we have to
97 // override the default value when the list of libs is actually empty.
98 entries.SetString("LOCAL_SYSTEM_SHARED_LIBRARIES", strings.Join(c.Properties.AndroidMkSystemSharedLibs, " "))
Colin Crossa18e9cf2017-08-10 17:00:19 -070099 if len(c.Properties.AndroidMkSharedLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800100 entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...)
Colin Crossa18e9cf2017-08-10 17:00:19 -0700101 }
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +0000102 if len(c.Properties.AndroidMkStaticLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800103 entries.AddStrings("LOCAL_STATIC_LIBRARIES", c.Properties.AndroidMkStaticLibs...)
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +0000104 }
105 if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800106 entries.AddStrings("LOCAL_WHOLE_STATIC_LIBRARIES", c.Properties.AndroidMkWholeStaticLibs...)
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +0000107 }
Bill Peckhama46de702020-04-21 17:23:37 -0700108 if len(c.Properties.AndroidMkHeaderLibs) > 0 {
109 entries.AddStrings("LOCAL_HEADER_LIBRARIES", c.Properties.AndroidMkHeaderLibs...)
110 }
yangbill6db86e52022-02-08 16:14:25 +0800111 if len(c.Properties.AndroidMkRuntimeLibs) > 0 {
112 entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
113 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800114 entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType)
Ivan Lozano52767be2019-10-18 14:49:46 -0700115 if c.UseVndk() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800116 entries.SetBool("LOCAL_USE_VNDK", true)
Ivan Lozano52767be2019-10-18 14:49:46 -0700117 if c.IsVndk() && !c.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800118 entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion())
Jooyung Hanb01c1142019-10-29 05:24:42 +0900119 // VNDK libraries available to vendor are not installed because
120 // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
Ivan Lozanof9e21722020-12-02 09:00:51 -0500121 if !c.IsVndkExt() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800122 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Jooyung Hanb01c1142019-10-29 05:24:42 +0900123 }
Jooyung Han76106d92019-05-20 18:49:10 +0900124 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700125 }
Colin Crossc511bc52020-04-07 16:50:32 +0000126 if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
127 // Make the SDK variant uninstallable so that there are not two rules to install
128 // to the same location.
129 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
130 // Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite
131 // dependencies to the .sdk suffix when building a module that uses the SDK.
132 entries.SetString("SOONG_SDK_VARIANT_MODULES",
133 "$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
134 }
135 },
136 },
137 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800138 func(w io.Writer, name, prefix, moduleDir string) {
Colin Crossc511bc52020-04-07 16:50:32 +0000139 if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake &&
140 c.CcLibraryInterface() && c.Shared() {
141 // Using the SDK variant as a JNI library needs a copy of the .so that
142 // is not named .sdk.so so that it can be packaged into the APK with
143 // the right name.
144 fmt.Fprintln(w, "$(eval $(call copy-one-file,",
145 "$(LOCAL_BUILT_MODULE),",
146 "$(patsubst %.sdk.so,%.so,$(LOCAL_BUILT_MODULE))))")
147 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700148 },
149 },
150 }
Colin Crossca860ac2016-01-04 14:34:37 -0800151
Colin Crossca860ac2016-01-04 14:34:37 -0800152 for _, feature := range c.features {
Colin Crossd80cbca2020-02-24 12:01:37 -0800153 c.subAndroidMk(&entries, feature)
Colin Crossca860ac2016-01-04 14:34:37 -0800154 }
155
Colin Crossd80cbca2020-02-24 12:01:37 -0800156 c.subAndroidMk(&entries, c.compiler)
157 c.subAndroidMk(&entries, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700158 if c.sanitize != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800159 c.subAndroidMk(&entries, c.sanitize)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700160 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800161 c.subAndroidMk(&entries, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -0800162
Colin Crossd80cbca2020-02-24 12:01:37 -0800163 entries.SubName += c.Properties.SubName
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700164
Colin Crossd80cbca2020-02-24 12:01:37 -0800165 return []android.AndroidMkEntries{entries}
Colin Crossca860ac2016-01-04 14:34:37 -0800166}
167
Dan Shi95d19422020-08-15 12:24:26 -0700168func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
169 if len(extraTestConfigs) > 0 {
Colin Crossaa255532020-07-03 13:18:24 -0700170 entries.ExtraEntries = append(entries.ExtraEntries,
171 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
172 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
173 })
Dan Shi95d19422020-08-15 12:24:26 -0700174 }
175}
176
Ivan Lozano9da4aa82021-01-29 12:48:05 -0500177func AndroidMkWriteTestData(data []android.DataPath, entries *android.AndroidMkEntries) {
Dan Shi31949122020-09-21 12:11:02 -0700178 testFiles := android.AndroidMkDataPaths(data)
Anders Lewisb97e8182017-07-14 15:20:13 -0700179 if len(testFiles) > 0 {
Colin Crossaa255532020-07-03 13:18:24 -0700180 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800181 entries.AddStrings("LOCAL_TEST_DATA", testFiles...)
Anders Lewisb97e8182017-07-14 15:20:13 -0700182 })
183 }
184}
185
dimitrydb417472019-05-20 16:16:47 +0200186func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string {
187 if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
188 var result []string
189 for _, override := range overrides {
Matthew Maurera61e31f2021-05-27 11:09:11 -0700190 result = append(result, override+NativeBridgeSuffix)
dimitrydb417472019-05-20 16:16:47 +0200191 }
192 return result
193 }
194
195 return overrides
196}
197
Colin Crossd80cbca2020-02-24 12:01:37 -0800198func (library *libraryDecorator) androidMkWriteExportedFlags(entries *android.AndroidMkEntries) {
Liz Kammerb6a55bf2021-04-12 15:42:51 -0400199 var exportedFlags []string
200 var includeDirs android.Paths
201 var systemIncludeDirs android.Paths
202 var exportedDeps android.Paths
203
204 if library.flagExporterInfo != nil {
205 exportedFlags = library.flagExporterInfo.Flags
206 includeDirs = library.flagExporterInfo.IncludeDirs
207 systemIncludeDirs = library.flagExporterInfo.SystemIncludeDirs
208 exportedDeps = library.flagExporterInfo.Deps
209 } else {
210 exportedFlags = library.flagExporter.flags
211 includeDirs = library.flagExporter.dirs
212 systemIncludeDirs = library.flagExporter.systemDirs
213 exportedDeps = library.flagExporter.deps
214 }
215 for _, dir := range includeDirs {
Jiyong Park74955042019-10-22 20:19:51 +0900216 exportedFlags = append(exportedFlags, "-I"+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900217 }
Liz Kammerb6a55bf2021-04-12 15:42:51 -0400218 for _, dir := range systemIncludeDirs {
Jiyong Park74955042019-10-22 20:19:51 +0900219 exportedFlags = append(exportedFlags, "-isystem "+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900220 }
Dan Willemsen58539402017-03-19 13:44:32 -0700221 if len(exportedFlags) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800222 entries.AddStrings("LOCAL_EXPORT_CFLAGS", exportedFlags...)
Dan Willemsend5781342017-02-15 16:15:21 -0800223 }
Inseob Kim69378442019-06-03 19:10:47 +0900224 if len(exportedDeps) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800225 entries.AddStrings("LOCAL_EXPORT_C_INCLUDE_DEPS", exportedDeps.Strings()...)
Dan Willemsen58539402017-03-19 13:44:32 -0700226 }
227}
Dan Willemsend5781342017-02-15 16:15:21 -0800228
Colin Crossd80cbca2020-02-24 12:01:37 -0800229func (library *libraryDecorator) androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries *android.AndroidMkEntries) {
Yo Chiangeb912dc2020-07-28 20:01:31 +0800230 if library.sAbiDiff.Valid() && !library.static() {
231 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", library.sAbiDiff.String())
Logan Chien41eabe62019-04-10 13:33:58 +0800232 }
233}
234
Colin Crossd80cbca2020-02-24 12:01:37 -0800235// TODO(ccross): remove this once apex/androidmk.go is converted to AndroidMkEntries
236func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
Yo Chiangeb912dc2020-07-28 20:01:31 +0800237 if library.sAbiDiff.Valid() && !library.static() {
238 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiDiff.String())
Colin Crossd80cbca2020-02-24 12:01:37 -0800239 }
240}
241
242func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Dan Willemsend5781342017-02-15 16:15:21 -0800243 if library.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800244 entries.Class = "STATIC_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800245 } else if library.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800246 entries.Class = "SHARED_LIBRARIES"
Colin Crossaa255532020-07-03 13:18:24 -0700247 entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800248 entries.SetString("LOCAL_SOONG_TOC", library.toc().String())
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxc3b97c32021-10-05 13:43:23 -0400249 if !library.buildStubs() && library.unstrippedOutputFile != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800250 entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", library.unstrippedOutputFile.String())
Jiyong Park47e4fcb2019-02-05 22:33:10 +0900251 }
dimitryd95964a2018-11-07 13:43:34 +0100252 if len(library.Properties.Overrides) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800253 entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " "))
dimitryd95964a2018-11-07 13:43:34 +0100254 }
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800255 if len(library.postInstallCmds) > 0 {
256 entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(library.postInstallCmds, "&& "))
Jiyong Parkf1194352019-02-25 11:05:47 +0900257 }
Colin Crossb60190a2018-09-04 16:28:17 -0700258 })
Dan Willemsend5781342017-02-15 16:15:21 -0800259 } else if library.header() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800260 entries.Class = "HEADER_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800261 }
262
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000263 if library.distFile != nil {
264 entries.DistFiles = android.MakeDefaultDistFiles(library.distFile)
265 }
266
Colin Crossaa255532020-07-03 13:18:24 -0700267 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800268 library.androidMkWriteExportedFlags(entries)
269 library.androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries)
Dan Willemsen218f6562015-07-08 18:13:11 -0700270
Martin Stjernholme65c3ae2021-11-23 01:24:06 +0000271 if entries.OutputFile.Valid() {
272 _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base())
273 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
274 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700275
Dan Willemsen581341d2017-02-09 16:16:31 -0800276 if library.coverageOutputFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800277 entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", library.coverageOutputFile.String())
Dan Willemsen581341d2017-02-09 16:16:31 -0800278 }
Vic Yangefd249e2018-11-12 20:19:56 -0800279
280 if library.useCoreVariant {
Colin Crossd80cbca2020-02-24 12:01:37 -0800281 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
282 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
283 entries.SetBool("LOCAL_VNDK_DEPEND_ON_CORE_VARIANT", true)
Vic Yangefd249e2018-11-12 20:19:56 -0800284 }
Vic Yangd92090f2020-01-08 14:32:28 -0800285 if library.checkSameCoreVariant {
Colin Crossd80cbca2020-02-24 12:01:37 -0800286 entries.SetBool("LOCAL_CHECK_SAME_VNDK_VARIANTS", true)
Vic Yangd92090f2020-01-08 14:32:28 -0800287 }
Colin Crossca860ac2016-01-04 14:34:37 -0800288 })
Colin Crossb916a382016-07-29 17:28:03 -0700289
Jiyong Parkb0788572018-12-20 22:10:17 +0900290 if library.shared() && !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800291 ctx.subAndroidMk(entries, library.baseInstaller)
Colin Crossb60190a2018-09-04 16:28:17 -0700292 } else {
Colin Cross127bb8b2020-12-16 16:46:01 -0800293 if library.buildStubs() && library.stubsVersion() != "" {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900294 entries.SubName = "." + library.stubsVersion()
295 }
Colin Crossaa255532020-07-03 13:18:24 -0700296 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossa9c8c9f2020-12-16 10:20:23 -0800297 // library.makeUninstallable() depends on this to bypass HideFromMake() for
Martin Stjernholm9e9bb7f2020-08-06 22:34:42 +0100298 // static libraries.
Colin Crossd80cbca2020-02-24 12:01:37 -0800299 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Jiyong Parkb0788572018-12-20 22:10:17 +0900300 if library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800301 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
Jiyong Parkb0788572018-12-20 22:10:17 +0900302 }
Colin Crossb60190a2018-09-04 16:28:17 -0700303 })
Colin Crossb916a382016-07-29 17:28:03 -0700304 }
Jiyong Parkf7c3bbe2020-12-09 21:18:56 +0900305 // If a library providing a stub is included in an APEX, the private APIs of the library
306 // is accessible only inside the APEX. From outside of the APEX, clients can only use the
307 // public APIs via the stub. To enforce this, the (latest version of the) stub gets the
308 // name of the library. The impl library instead gets the `.bootstrap` suffix to so that
309 // they can be exceptionally used directly when APEXes are not available (e.g. during the
310 // very early stage in the boot process).
311 if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.NotInPlatform() &&
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700312 !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900313 if library.buildStubs() && library.isLatestStubVersion() {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900314 entries.SubName = ""
315 }
Jiyong Parkb0788572018-12-20 22:10:17 +0900316 if !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800317 entries.SubName = ".bootstrap"
Jiyong Parkb0788572018-12-20 22:10:17 +0900318 }
319 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700320}
321
Colin Crossd80cbca2020-02-24 12:01:37 -0800322func (object *objectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
323 entries.Class = "STATIC_LIBRARIES"
324 entries.ExtraFooters = append(entries.ExtraFooters,
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800325 func(w io.Writer, name, prefix, moduleDir string) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800326 out := entries.OutputFile.Path()
327 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
Dan Willemsen218f6562015-07-08 18:13:11 -0700328
Colin Crossd80cbca2020-02-24 12:01:37 -0800329 fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
330 fmt.Fprintln(w, ".KATI_READONLY: "+varname)
331 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700332}
333
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000334func (test *testDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
335 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
336 if len(test.InstallerProperties.Test_suites) > 0 {
337 entries.AddCompatibilityTestSuites(test.InstallerProperties.Test_suites...)
338 }
339 })
340}
341
Colin Crossd80cbca2020-02-24 12:01:37 -0800342func (binary *binaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
343 ctx.subAndroidMk(entries, binary.baseInstaller)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700344
Colin Crossd80cbca2020-02-24 12:01:37 -0800345 entries.Class = "EXECUTABLES"
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000346 entries.DistFiles = binary.distFiles
Colin Crossaa255532020-07-03 13:18:24 -0700347 entries.ExtraEntries = append(entries.ExtraEntries, func(_ android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800348 entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", binary.unstrippedOutputFile.String())
Colin Cross9b09f242016-12-07 13:37:42 -0800349 if len(binary.symlinks) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800350 entries.AddStrings("LOCAL_MODULE_SYMLINKS", binary.symlinks...)
Colin Cross9b09f242016-12-07 13:37:42 -0800351 }
352
Dan Willemsen581341d2017-02-09 16:16:31 -0800353 if binary.coverageOutputFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800354 entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", binary.coverageOutputFile.String())
Dan Willemsen581341d2017-02-09 16:16:31 -0800355 }
Yifan Hong946e32e2018-04-03 13:22:50 -0700356
357 if len(binary.Properties.Overrides) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800358 entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " "))
Yifan Hong946e32e2018-04-03 13:22:50 -0700359 }
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800360 if len(binary.postInstallCmds) > 0 {
361 entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(binary.postInstallCmds, "&& "))
Jiyong Parkf1194352019-02-25 11:05:47 +0900362 }
Colin Crossca860ac2016-01-04 14:34:37 -0800363 })
364}
365
Colin Crossd80cbca2020-02-24 12:01:37 -0800366func (benchmark *benchmarkDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
367 ctx.subAndroidMk(entries, benchmark.binaryDecorator)
368 entries.Class = "NATIVE_TESTS"
Colin Crossaa255532020-07-03 13:18:24 -0700369 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700370 if len(benchmark.Properties.Test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800371 entries.AddCompatibilityTestSuites(benchmark.Properties.Test_suites...)
Colin Crosse28f4e22017-04-24 18:10:29 -0700372 }
Colin Cross303e21f2018-08-07 16:49:25 -0700373 if benchmark.testConfig != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800374 entries.SetString("LOCAL_FULL_TEST_CONFIG", benchmark.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700375 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800376 entries.SetBool("LOCAL_NATIVE_BENCHMARK", true)
Dan Shi2468d012020-01-06 15:47:57 -0800377 if !BoolDefault(benchmark.Properties.Auto_gen_config, true) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800378 entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
Dan Shi2468d012020-01-06 15:47:57 -0800379 }
Colin Crosse28f4e22017-04-24 18:10:29 -0700380 })
Chris Parsons216e10a2020-07-09 17:12:52 -0400381 dataPaths := []android.DataPath{}
382 for _, srcPath := range benchmark.data {
383 dataPaths = append(dataPaths, android.DataPath{SrcPath: srcPath})
384 }
Ivan Lozano9da4aa82021-01-29 12:48:05 -0500385 AndroidMkWriteTestData(dataPaths, entries)
Colin Crossb916a382016-07-29 17:28:03 -0700386}
387
Colin Crossd80cbca2020-02-24 12:01:37 -0800388func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
389 ctx.subAndroidMk(entries, test.binaryDecorator)
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000390 ctx.subAndroidMk(entries, test.testDecorator)
391
Colin Crossd80cbca2020-02-24 12:01:37 -0800392 entries.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700393 if Bool(test.Properties.Test_per_src) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800394 entries.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700395 }
Colin Crossaa255532020-07-03 13:18:24 -0700396 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross303e21f2018-08-07 16:49:25 -0700397 if test.testConfig != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800398 entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700399 }
Dan Shi2468d012020-01-06 15:47:57 -0800400 if !BoolDefault(test.Properties.Auto_gen_config, true) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800401 entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
Dan Shi2468d012020-01-06 15:47:57 -0800402 }
kellyhung74b00522020-08-17 18:46:00 +0800403 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...)
Dan Shid79572f2020-11-13 14:33:46 -0800404 if Bool(test.Properties.Test_options.Unit_test) {
405 entries.SetBool("LOCAL_IS_UNIT_TEST", true)
406 }
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700407
408 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(test.Properties.Per_testcase_directory))
yangbill22bafec2022-02-11 18:06:07 +0800409 if len(test.Properties.Data_bins) > 0 {
410 entries.AddStrings("LOCAL_TEST_DATA_BINS", test.Properties.Data_bins...)
411 }
Colin Crossa929db02017-03-27 16:27:50 -0700412 })
413
Ivan Lozano9da4aa82021-01-29 12:48:05 -0500414 AndroidMkWriteTestData(test.data, entries)
Dan Shi95d19422020-08-15 12:24:26 -0700415 androidMkWriteExtraTestConfigs(test.extraTestConfigs, entries)
Colin Crossa2344662016-03-24 13:14:12 -0700416}
417
Colin Crossd80cbca2020-02-24 12:01:37 -0800418func (fuzz *fuzzBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
419 ctx.subAndroidMk(entries, fuzz.binaryDecorator)
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700420
421 var fuzzFiles []string
hamzeh41ad8812021-07-07 14:00:07 -0700422 for _, d := range fuzz.fuzzPackagedModule.Corpus {
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700423 fuzzFiles = append(fuzzFiles,
hamzeh41ad8812021-07-07 14:00:07 -0700424 filepath.Dir(fuzz.fuzzPackagedModule.CorpusIntermediateDir.String())+":corpus/"+d.Base())
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700425 }
426
hamzeh41ad8812021-07-07 14:00:07 -0700427 for _, d := range fuzz.fuzzPackagedModule.Data {
Tri Voad172d82019-11-27 13:45:45 -0800428 fuzzFiles = append(fuzzFiles,
hamzeh41ad8812021-07-07 14:00:07 -0700429 filepath.Dir(fuzz.fuzzPackagedModule.DataIntermediateDir.String())+":data/"+d.Rel())
Tri Voad172d82019-11-27 13:45:45 -0800430 }
431
hamzeh41ad8812021-07-07 14:00:07 -0700432 if fuzz.fuzzPackagedModule.Dictionary != nil {
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700433 fuzzFiles = append(fuzzFiles,
hamzeh41ad8812021-07-07 14:00:07 -0700434 filepath.Dir(fuzz.fuzzPackagedModule.Dictionary.String())+":"+fuzz.fuzzPackagedModule.Dictionary.Base())
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700435 }
436
hamzeh41ad8812021-07-07 14:00:07 -0700437 if fuzz.fuzzPackagedModule.Config != nil {
Kris Alderf979ee32019-10-22 10:52:01 -0700438 fuzzFiles = append(fuzzFiles,
hamzeh41ad8812021-07-07 14:00:07 -0700439 filepath.Dir(fuzz.fuzzPackagedModule.Config.String())+":config.json")
Kris Alderf979ee32019-10-22 10:52:01 -0700440 }
441
Colin Crossaa255532020-07-03 13:18:24 -0700442 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800443 entries.SetBool("LOCAL_IS_FUZZ_TARGET", true)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700444 if len(fuzzFiles) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800445 entries.AddStrings("LOCAL_TEST_DATA", fuzzFiles...)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700446 }
447 if fuzz.installedSharedDeps != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800448 entries.AddStrings("LOCAL_FUZZ_INSTALLED_SHARED_DEPS", fuzz.installedSharedDeps...)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700449 }
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700450 })
451}
452
Colin Crossd80cbca2020-02-24 12:01:37 -0800453func (test *testLibrary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
454 ctx.subAndroidMk(entries, test.libraryDecorator)
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000455 ctx.subAndroidMk(entries, test.testDecorator)
Colin Crossb916a382016-07-29 17:28:03 -0700456}
Dan Willemsene7932e82016-05-16 15:56:53 -0700457
Colin Crossd80cbca2020-02-24 12:01:37 -0800458func (installer *baseInstaller) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Colin Crossc511bc52020-04-07 16:50:32 +0000459 if installer.path == (android.InstallPath{}) {
460 return
461 }
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700462
Colin Crossaa255532020-07-03 13:18:24 -0700463 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossc68db4b2021-11-11 18:59:15 -0800464 path, file := filepath.Split(installer.path.String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700465 stem, suffix, _ := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800466 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
467 entries.SetString("LOCAL_MODULE_PATH", path)
468 entries.SetString("LOCAL_MODULE_STEM", stem)
Colin Crossa2344662016-03-24 13:14:12 -0700469 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700470}
Dan Albert914449f2016-06-17 16:45:24 -0700471
Colin Crossd80cbca2020-02-24 12:01:37 -0800472func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Dan Albert1a246272020-07-06 14:49:35 -0700473 entries.SubName = ndkLibrarySuffix + "." + c.apiLevel.String()
Colin Crossd80cbca2020-02-24 12:01:37 -0800474 entries.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700475
Colin Cross5ec407b2020-09-30 11:41:33 -0700476 if !c.buildStubs() {
477 entries.Disabled = true
478 return
479 }
480
Colin Crossaa255532020-07-03 13:18:24 -0700481 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Cross0875c522017-11-28 17:34:01 -0800482 path, file := filepath.Split(c.installPath.String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700483 stem, suffix, _ := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800484 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
485 entries.SetString("LOCAL_MODULE_PATH", path)
486 entries.SetString("LOCAL_MODULE_STEM", stem)
487 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
sophiez58cabb72020-05-29 13:37:12 -0700488 if c.parsedCoverageXmlPath.String() != "" {
489 entries.SetString("SOONG_NDK_API_XML", "$(SOONG_NDK_API_XML) "+c.parsedCoverageXmlPath.String())
490 }
Dan Albert914449f2016-06-17 16:45:24 -0700491 })
492}
Dan Willemsenb916b802017-03-19 13:44:32 -0700493
Colin Crossd80cbca2020-02-24 12:01:37 -0800494func (c *vndkPrebuiltLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
495 entries.Class = "SHARED_LIBRARIES"
Justin Yun71549282017-11-17 12:10:28 +0900496
Colin Crossd80cbca2020-02-24 12:01:37 -0800497 entries.SubName = c.androidMkSuffix
Justin Yun71549282017-11-17 12:10:28 +0900498
Colin Crossaa255532020-07-03 13:18:24 -0700499 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800500 c.libraryDecorator.androidMkWriteExportedFlags(entries)
Justin Yun71549282017-11-17 12:10:28 +0900501
Inseob Kim81235ff2020-10-23 14:36:11 +0900502 // Specifying stem is to pass check_elf_files when vendor modules link against vndk prebuilt.
503 // We can't use install path because VNDKs are not installed. Instead, Srcs is directly used.
504 _, file := filepath.Split(c.properties.Srcs[0])
505 stem, suffix, ext := android.SplitFileExt(file)
506 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
507 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
508 entries.SetString("LOCAL_MODULE_STEM", stem)
509
Inseob Kimeec88e12020-01-22 11:11:29 +0900510 if c.tocFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800511 entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String())
Inseob Kimeec88e12020-01-22 11:11:29 +0900512 }
Inseob Kim81235ff2020-10-23 14:36:11 +0900513
514 // VNDK libraries available to vendor are not installed because
515 // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
516 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Inseob Kimeec88e12020-01-22 11:11:29 +0900517 })
518}
519
Jose Galmesf7294582020-11-13 12:07:36 -0800520func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Inseob Kimeec88e12020-01-22 11:11:29 +0900521 // Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current
522 // and the version of the prebuilt is same as BOARD_VNDK_VERSION.
523 if c.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800524 entries.Class = "SHARED_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900525 } else if c.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800526 entries.Class = "STATIC_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900527 } else if c.header() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800528 entries.Class = "HEADER_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900529 }
530
Inseob Kimc42f2f22020-07-29 20:32:10 +0900531 entries.SubName = ""
532
533 if c.sanitizerProperties.CfiEnabled {
534 entries.SubName += ".cfi"
535 }
536
Colin Crossa8890802021-01-22 14:06:33 -0800537 entries.SubName += c.baseProperties.Androidmk_suffix
Inseob Kimeec88e12020-01-22 11:11:29 +0900538
Colin Crossaa255532020-07-03 13:18:24 -0700539 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800540 c.libraryDecorator.androidMkWriteExportedFlags(entries)
Inseob Kimeec88e12020-01-22 11:11:29 +0900541
Inseob Kimc3b1a162020-02-18 12:42:54 +0900542 if c.shared() || c.static() {
Inseob Kimbf1b63f2022-01-21 18:12:48 +0900543 src := c.path.String()
544 // For static libraries which aren't installed, directly use Src to extract filename.
545 // This is safe: generated snapshot modules have a real path as Src, not a module
546 if c.static() {
547 src = proptools.String(c.properties.Src)
548 }
549 path, file := filepath.Split(src)
Inseob Kimeec88e12020-01-22 11:11:29 +0900550 stem, suffix, ext := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800551 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
552 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
553 entries.SetString("LOCAL_MODULE_STEM", stem)
Inseob Kimeec88e12020-01-22 11:11:29 +0900554 if c.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800555 entries.SetString("LOCAL_MODULE_PATH", path)
Inseob Kimeec88e12020-01-22 11:11:29 +0900556 }
557 if c.tocFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800558 entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String())
Inseob Kimeec88e12020-01-22 11:11:29 +0900559 }
Inseob Kimc3b1a162020-02-18 12:42:54 +0900560 }
561
562 if !c.shared() { // static or header
Colin Crossd80cbca2020-02-24 12:01:37 -0800563 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Inseob Kimeec88e12020-01-22 11:11:29 +0900564 }
565 })
566}
567
Jose Galmesf7294582020-11-13 12:07:36 -0800568func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800569 entries.Class = "EXECUTABLES"
Colin Crossa8890802021-01-22 14:06:33 -0800570 entries.SubName = c.baseProperties.Androidmk_suffix
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800571}
Dan Albert8ba131b2017-12-14 13:23:15 -0800572
Jose Galmesf7294582020-11-13 12:07:36 -0800573func (c *snapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Inseob Kim1042d292020-06-01 23:23:05 +0900574 entries.Class = "STATIC_LIBRARIES"
Colin Crossa8890802021-01-22 14:06:33 -0800575 entries.SubName = c.baseProperties.Androidmk_suffix
Inseob Kim1042d292020-06-01 23:23:05 +0900576
577 entries.ExtraFooters = append(entries.ExtraFooters,
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800578 func(w io.Writer, name, prefix, moduleDir string) {
Inseob Kim1042d292020-06-01 23:23:05 +0900579 out := entries.OutputFile.Path()
580 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
581
582 fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
583 fmt.Fprintln(w, ".KATI_READONLY: "+varname)
584 })
585}
586
Colin Crossd80cbca2020-02-24 12:01:37 -0800587func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
588 entries.Class = "SHARED_LIBRARIES"
Dan Albert8ba131b2017-12-14 13:23:15 -0800589}
Jiyong Park374510b2018-03-19 18:23:01 +0900590
Colin Crossd80cbca2020-02-24 12:01:37 -0800591func (p *prebuiltLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Colin Crossaa255532020-07-03 13:18:24 -0700592 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Logan Chien4fcea3d2018-11-20 11:59:08 +0800593 if p.properties.Check_elf_files != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800594 entries.SetBool("LOCAL_CHECK_ELF_FILES", *p.properties.Check_elf_files)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800595 } else {
Ivan Lozanod06cc742021-11-12 13:27:58 -0500596 // soong_cc_rust_prebuilt.mk does not include check_elf_file.mk by default
597 // because cc_library_shared and cc_binary use soong_cc_rust_prebuilt.mk as well.
Logan Chien4fcea3d2018-11-20 11:59:08 +0800598 // In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to
599 // true if `p.properties.Check_elf_files` is not specified.
Colin Crossd80cbca2020-02-24 12:01:37 -0800600 entries.SetBool("LOCAL_CHECK_ELF_FILES", true)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800601 }
602 })
603}
604
Colin Crossd80cbca2020-02-24 12:01:37 -0800605func (p *prebuiltLibraryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
606 ctx.subAndroidMk(entries, p.libraryDecorator)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800607 if p.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800608 ctx.subAndroidMk(entries, &p.prebuiltLinker)
609 androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800610 }
611}
612
Colin Crossd80cbca2020-02-24 12:01:37 -0800613func (p *prebuiltBinaryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
614 ctx.subAndroidMk(entries, p.binaryDecorator)
615 ctx.subAndroidMk(entries, &p.prebuiltLinker)
616 androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800617}
618
Colin Crossd80cbca2020-02-24 12:01:37 -0800619func androidMkWriteAllowUndefinedSymbols(linker *baseLinker, entries *android.AndroidMkEntries) {
620 allow := linker.Properties.Allow_undefined_symbols
621 if allow != nil {
Colin Crossaa255532020-07-03 13:18:24 -0700622 entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800623 entries.SetBool("LOCAL_ALLOW_UNDEFINED_SYMBOLS", *allow)
624 })
625 }
Logan Chien4fcea3d2018-11-20 11:59:08 +0800626}