blob: 187a2ff16ae925293d569dc8434d23ea5de0a6f5 [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 (
Dan Willemsen97750522016-02-09 17:43:51 -080018 "fmt"
Dan Willemsen218f6562015-07-08 18:13:11 -070019 "io"
Colin Crossa2344662016-03-24 13:14:12 -070020 "path/filepath"
Dan Willemsen218f6562015-07-08 18:13:11 -070021 "strings"
22
Colin Cross635c3b02016-05-18 15:37:25 -070023 "android/soong/android"
Dan Willemsen218f6562015-07-08 18:13:11 -070024)
25
Jiyong Park27b188b2017-07-18 13:23:39 +090026var (
Yifan Hong60e0cfb2020-10-21 15:17:56 -070027 nativeBridgeSuffix = ".native_bridge"
28 productSuffix = ".product"
29 vendorSuffix = ".vendor"
30 ramdiskSuffix = ".ramdisk"
31 vendorRamdiskSuffix = ".vendor_ramdisk"
32 recoverySuffix = ".recovery"
33 sdkSuffix = ".sdk"
Jiyong Park27b188b2017-07-18 13:23:39 +090034)
35
Dan Willemsenf2c27d72016-07-13 16:50:22 -070036type AndroidMkContext interface {
Colin Cross0477b422020-10-13 18:43:54 -070037 BaseModuleName() string
Dan Willemsenf2c27d72016-07-13 16:50:22 -070038 Target() android.Target
Colin Crossd80cbca2020-02-24 12:01:37 -080039 subAndroidMk(*android.AndroidMkEntries, interface{})
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +000040 Arch() android.Arch
41 Os() android.OsType
42 Host() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070043 UseVndk() bool
Justin Yun5f7f7e82019-11-18 19:52:14 +090044 VndkVersion() string
Jiyong Parkb0788572018-12-20 22:10:17 +090045 static() bool
Yifan Hong1b3348d2020-01-21 15:53:22 -080046 InRamdisk() bool
Yifan Hong60e0cfb2020-10-21 15:17:56 -070047 InVendorRamdisk() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070048 InRecovery() bool
Jiyong Parkf7c3bbe2020-12-09 21:18:56 +090049 NotInPlatform() bool
Colin Crossb916a382016-07-29 17:28:03 -070050}
51
52type subAndroidMkProvider interface {
Colin Crossd80cbca2020-02-24 12:01:37 -080053 AndroidMkEntries(AndroidMkContext, *android.AndroidMkEntries)
Colin Crossb916a382016-07-29 17:28:03 -070054}
55
Colin Crossd80cbca2020-02-24 12:01:37 -080056func (c *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) {
Colin Crossb916a382016-07-29 17:28:03 -070057 if c.subAndroidMkOnce == nil {
58 c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
59 }
60 if androidmk, ok := obj.(subAndroidMkProvider); ok {
61 if !c.subAndroidMkOnce[androidmk] {
62 c.subAndroidMkOnce[androidmk] = true
Colin Crossd80cbca2020-02-24 12:01:37 -080063 androidmk.AndroidMkEntries(c, entries)
Colin Crossb916a382016-07-29 17:28:03 -070064 }
65 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070066}
67
Colin Crossd80cbca2020-02-24 12:01:37 -080068func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
Colin Cross56a83212020-09-15 18:30:11 -070069 if c.hideApexVariantFromMake || c.Properties.HideFromMake {
Colin Crossd80cbca2020-02-24 12:01:37 -080070 return []android.AndroidMkEntries{{
Colin Crossa18e9cf2017-08-10 17:00:19 -070071 Disabled: true,
Colin Crossd80cbca2020-02-24 12:01:37 -080072 }}
Colin Crossbc6fb162016-05-24 15:39:04 -070073 }
74
Colin Crossd80cbca2020-02-24 12:01:37 -080075 entries := android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -070076 OutputFile: c.outputFile,
Martin Stjernholm7f511072020-10-12 15:10:36 +010077 // TODO(jiyong): add the APEXes providing shared libs to the required
78 // modules Currently, adding c.Properties.ApexesProvidingSharedLibs is
79 // causing multiple ART APEXes (com.android.art and com.android.art.debug)
80 // to be installed. And this is breaking some older devices (like marlin)
81 // where system.img is small.
Jiyong Parkb0788572018-12-20 22:10:17 +090082 Required: c.Properties.AndroidMkRuntimeLibs,
83 Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
Logan Chien43d34c32017-12-20 01:17:32 +080084
Colin Crossd80cbca2020-02-24 12:01:37 -080085 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
86 func(entries *android.AndroidMkEntries) {
Colin Cross5beccee2017-12-07 15:28:59 -080087 if len(c.Properties.Logtags) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -080088 entries.AddStrings("LOCAL_LOGTAGS_FILES", c.Properties.Logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080089 }
Yo Chiang219968c2020-09-22 18:45:04 +080090 // Note: Pass the exact value of AndroidMkSystemSharedLibs to the Make
91 // world, even if it is an empty list. In the Make world,
92 // LOCAL_SYSTEM_SHARED_LIBRARIES defaults to "none", which is expanded
93 // to the default list of system shared libs by the build system.
94 // Soong computes the exact list of system shared libs, so we have to
95 // override the default value when the list of libs is actually empty.
96 entries.SetString("LOCAL_SYSTEM_SHARED_LIBRARIES", strings.Join(c.Properties.AndroidMkSystemSharedLibs, " "))
Colin Crossa18e9cf2017-08-10 17:00:19 -070097 if len(c.Properties.AndroidMkSharedLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -080098 entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...)
Colin Crossa18e9cf2017-08-10 17:00:19 -070099 }
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +0000100 if len(c.Properties.AndroidMkStaticLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800101 entries.AddStrings("LOCAL_STATIC_LIBRARIES", c.Properties.AndroidMkStaticLibs...)
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +0000102 }
103 if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800104 entries.AddStrings("LOCAL_WHOLE_STATIC_LIBRARIES", c.Properties.AndroidMkWholeStaticLibs...)
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +0000105 }
Bill Peckhama46de702020-04-21 17:23:37 -0700106 if len(c.Properties.AndroidMkHeaderLibs) > 0 {
107 entries.AddStrings("LOCAL_HEADER_LIBRARIES", c.Properties.AndroidMkHeaderLibs...)
108 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800109 entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType)
Ivan Lozano52767be2019-10-18 14:49:46 -0700110 if c.UseVndk() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800111 entries.SetBool("LOCAL_USE_VNDK", true)
Ivan Lozano52767be2019-10-18 14:49:46 -0700112 if c.IsVndk() && !c.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800113 entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion())
Jooyung Hanb01c1142019-10-29 05:24:42 +0900114 // VNDK libraries available to vendor are not installed because
115 // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
Ivan Lozanof9e21722020-12-02 09:00:51 -0500116 if !c.IsVndkExt() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800117 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Jooyung Hanb01c1142019-10-29 05:24:42 +0900118 }
Jooyung Han76106d92019-05-20 18:49:10 +0900119 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700120 }
Colin Crossc511bc52020-04-07 16:50:32 +0000121 if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
122 // Make the SDK variant uninstallable so that there are not two rules to install
123 // to the same location.
124 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
125 // Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite
126 // dependencies to the .sdk suffix when building a module that uses the SDK.
127 entries.SetString("SOONG_SDK_VARIANT_MODULES",
128 "$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
129 }
130 },
131 },
132 ExtraFooters: []android.AndroidMkExtraFootersFunc{
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800133 func(w io.Writer, name, prefix, moduleDir string) {
Colin Crossc511bc52020-04-07 16:50:32 +0000134 if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake &&
135 c.CcLibraryInterface() && c.Shared() {
136 // Using the SDK variant as a JNI library needs a copy of the .so that
137 // is not named .sdk.so so that it can be packaged into the APK with
138 // the right name.
139 fmt.Fprintln(w, "$(eval $(call copy-one-file,",
140 "$(LOCAL_BUILT_MODULE),",
141 "$(patsubst %.sdk.so,%.so,$(LOCAL_BUILT_MODULE))))")
142 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700143 },
144 },
145 }
Colin Crossca860ac2016-01-04 14:34:37 -0800146
Colin Crossca860ac2016-01-04 14:34:37 -0800147 for _, feature := range c.features {
Colin Crossd80cbca2020-02-24 12:01:37 -0800148 c.subAndroidMk(&entries, feature)
Colin Crossca860ac2016-01-04 14:34:37 -0800149 }
150
Colin Crossd80cbca2020-02-24 12:01:37 -0800151 c.subAndroidMk(&entries, c.compiler)
152 c.subAndroidMk(&entries, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700153 if c.sanitize != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800154 c.subAndroidMk(&entries, c.sanitize)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700155 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800156 c.subAndroidMk(&entries, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -0800157
Colin Crossd80cbca2020-02-24 12:01:37 -0800158 entries.SubName += c.Properties.SubName
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700159
Colin Crossd80cbca2020-02-24 12:01:37 -0800160 return []android.AndroidMkEntries{entries}
Colin Crossca860ac2016-01-04 14:34:37 -0800161}
162
Dan Shi95d19422020-08-15 12:24:26 -0700163func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
164 if len(extraTestConfigs) > 0 {
165 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
166 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
167 })
168 }
169}
170
Chris Parsons216e10a2020-07-09 17:12:52 -0400171func androidMkWriteTestData(data []android.DataPath, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Dan Shi31949122020-09-21 12:11:02 -0700172 testFiles := android.AndroidMkDataPaths(data)
Anders Lewisb97e8182017-07-14 15:20:13 -0700173 if len(testFiles) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800174 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
175 entries.AddStrings("LOCAL_TEST_DATA", testFiles...)
Anders Lewisb97e8182017-07-14 15:20:13 -0700176 })
177 }
178}
179
dimitrydb417472019-05-20 16:16:47 +0200180func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string {
181 if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
182 var result []string
183 for _, override := range overrides {
184 result = append(result, override+nativeBridgeSuffix)
185 }
186 return result
187 }
188
189 return overrides
190}
191
Colin Crossd80cbca2020-02-24 12:01:37 -0800192func (library *libraryDecorator) androidMkWriteExportedFlags(entries *android.AndroidMkEntries) {
Colin Cross0de8a1e2020-09-18 14:15:30 -0700193 exportedFlags := library.flagExporter.flags
194 for _, dir := range library.flagExporter.dirs {
Jiyong Park74955042019-10-22 20:19:51 +0900195 exportedFlags = append(exportedFlags, "-I"+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900196 }
Colin Cross0de8a1e2020-09-18 14:15:30 -0700197 for _, dir := range library.flagExporter.systemDirs {
Jiyong Park74955042019-10-22 20:19:51 +0900198 exportedFlags = append(exportedFlags, "-isystem "+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900199 }
Dan Willemsen58539402017-03-19 13:44:32 -0700200 if len(exportedFlags) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800201 entries.AddStrings("LOCAL_EXPORT_CFLAGS", exportedFlags...)
Dan Willemsend5781342017-02-15 16:15:21 -0800202 }
Colin Cross0de8a1e2020-09-18 14:15:30 -0700203 exportedDeps := library.flagExporter.deps
Inseob Kim69378442019-06-03 19:10:47 +0900204 if len(exportedDeps) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800205 entries.AddStrings("LOCAL_EXPORT_C_INCLUDE_DEPS", exportedDeps.Strings()...)
Dan Willemsen58539402017-03-19 13:44:32 -0700206 }
207}
Dan Willemsend5781342017-02-15 16:15:21 -0800208
Colin Crossd80cbca2020-02-24 12:01:37 -0800209func (library *libraryDecorator) androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries *android.AndroidMkEntries) {
Yo Chiangeb912dc2020-07-28 20:01:31 +0800210 if library.sAbiDiff.Valid() && !library.static() {
211 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", library.sAbiDiff.String())
Logan Chien41eabe62019-04-10 13:33:58 +0800212 }
213}
214
Colin Crossd80cbca2020-02-24 12:01:37 -0800215// TODO(ccross): remove this once apex/androidmk.go is converted to AndroidMkEntries
216func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
Yo Chiangeb912dc2020-07-28 20:01:31 +0800217 if library.sAbiDiff.Valid() && !library.static() {
218 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiDiff.String())
Colin Crossd80cbca2020-02-24 12:01:37 -0800219 }
220}
221
222func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Dan Willemsend5781342017-02-15 16:15:21 -0800223 if library.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800224 entries.Class = "STATIC_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800225 } else if library.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800226 entries.Class = "SHARED_LIBRARIES"
227 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
228 entries.SetString("LOCAL_SOONG_TOC", library.toc().String())
Jiyong Park47e4fcb2019-02-05 22:33:10 +0900229 if !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800230 entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", library.unstrippedOutputFile.String())
Jiyong Park47e4fcb2019-02-05 22:33:10 +0900231 }
dimitryd95964a2018-11-07 13:43:34 +0100232 if len(library.Properties.Overrides) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800233 entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " "))
dimitryd95964a2018-11-07 13:43:34 +0100234 }
Jiyong Parkf1194352019-02-25 11:05:47 +0900235 if len(library.post_install_cmds) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800236 entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(library.post_install_cmds, "&& "))
Jiyong Parkf1194352019-02-25 11:05:47 +0900237 }
Colin Crossb60190a2018-09-04 16:28:17 -0700238 })
Dan Willemsend5781342017-02-15 16:15:21 -0800239 } else if library.header() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800240 entries.Class = "HEADER_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800241 }
242
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000243 if library.distFile != nil {
244 entries.DistFiles = android.MakeDefaultDistFiles(library.distFile)
245 }
246
Colin Crossd80cbca2020-02-24 12:01:37 -0800247 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
248 library.androidMkWriteExportedFlags(entries)
249 library.androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries)
Dan Willemsen218f6562015-07-08 18:13:11 -0700250
Colin Crossd80cbca2020-02-24 12:01:37 -0800251 _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base())
Logan Chien031d2b32018-07-26 00:19:50 +0800252
Colin Crossd80cbca2020-02-24 12:01:37 -0800253 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
Dan Willemsen218f6562015-07-08 18:13:11 -0700254
Dan Willemsen581341d2017-02-09 16:16:31 -0800255 if library.coverageOutputFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800256 entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", library.coverageOutputFile.String())
Dan Willemsen581341d2017-02-09 16:16:31 -0800257 }
Vic Yangefd249e2018-11-12 20:19:56 -0800258
259 if library.useCoreVariant {
Colin Crossd80cbca2020-02-24 12:01:37 -0800260 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
261 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
262 entries.SetBool("LOCAL_VNDK_DEPEND_ON_CORE_VARIANT", true)
Vic Yangefd249e2018-11-12 20:19:56 -0800263 }
Vic Yangd92090f2020-01-08 14:32:28 -0800264 if library.checkSameCoreVariant {
Colin Crossd80cbca2020-02-24 12:01:37 -0800265 entries.SetBool("LOCAL_CHECK_SAME_VNDK_VARIANTS", true)
Vic Yangd92090f2020-01-08 14:32:28 -0800266 }
Colin Crossca860ac2016-01-04 14:34:37 -0800267 })
Colin Crossb916a382016-07-29 17:28:03 -0700268
Jiyong Parkb0788572018-12-20 22:10:17 +0900269 if library.shared() && !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800270 ctx.subAndroidMk(entries, library.baseInstaller)
Colin Crossb60190a2018-09-04 16:28:17 -0700271 } else {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900272 if library.buildStubs() {
273 entries.SubName = "." + library.stubsVersion()
274 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800275 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Martin Stjernholm9e9bb7f2020-08-06 22:34:42 +0100276 // library.makeUninstallable() depends on this to bypass SkipInstall() for
277 // static libraries.
Colin Crossd80cbca2020-02-24 12:01:37 -0800278 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Jiyong Parkb0788572018-12-20 22:10:17 +0900279 if library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800280 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
Jiyong Parkb0788572018-12-20 22:10:17 +0900281 }
Colin Crossb60190a2018-09-04 16:28:17 -0700282 })
Colin Crossb916a382016-07-29 17:28:03 -0700283 }
Jiyong Parkf7c3bbe2020-12-09 21:18:56 +0900284 // If a library providing a stub is included in an APEX, the private APIs of the library
285 // is accessible only inside the APEX. From outside of the APEX, clients can only use the
286 // public APIs via the stub. To enforce this, the (latest version of the) stub gets the
287 // name of the library. The impl library instead gets the `.bootstrap` suffix to so that
288 // they can be exceptionally used directly when APEXes are not available (e.g. during the
289 // very early stage in the boot process).
290 if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.NotInPlatform() &&
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700291 !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() && !ctx.static() {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900292 if library.buildStubs() && library.isLatestStubVersion() {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900293 entries.SubName = ""
294 }
Jiyong Parkb0788572018-12-20 22:10:17 +0900295 if !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800296 entries.SubName = ".bootstrap"
Jiyong Parkb0788572018-12-20 22:10:17 +0900297 }
298 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700299}
300
Colin Crossd80cbca2020-02-24 12:01:37 -0800301func (object *objectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
302 entries.Class = "STATIC_LIBRARIES"
303 entries.ExtraFooters = append(entries.ExtraFooters,
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800304 func(w io.Writer, name, prefix, moduleDir string) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800305 out := entries.OutputFile.Path()
306 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
Dan Willemsen218f6562015-07-08 18:13:11 -0700307
Colin Crossd80cbca2020-02-24 12:01:37 -0800308 fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
309 fmt.Fprintln(w, ".KATI_READONLY: "+varname)
310 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700311}
312
Colin Crossd80cbca2020-02-24 12:01:37 -0800313func (binary *binaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
314 ctx.subAndroidMk(entries, binary.baseInstaller)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700315
Colin Crossd80cbca2020-02-24 12:01:37 -0800316 entries.Class = "EXECUTABLES"
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000317 entries.DistFiles = binary.distFiles
Colin Crossd80cbca2020-02-24 12:01:37 -0800318 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
319 entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", binary.unstrippedOutputFile.String())
Colin Cross9b09f242016-12-07 13:37:42 -0800320 if len(binary.symlinks) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800321 entries.AddStrings("LOCAL_MODULE_SYMLINKS", binary.symlinks...)
Colin Cross9b09f242016-12-07 13:37:42 -0800322 }
323
Dan Willemsen581341d2017-02-09 16:16:31 -0800324 if binary.coverageOutputFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800325 entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", binary.coverageOutputFile.String())
Dan Willemsen581341d2017-02-09 16:16:31 -0800326 }
Yifan Hong946e32e2018-04-03 13:22:50 -0700327
328 if len(binary.Properties.Overrides) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800329 entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " "))
Yifan Hong946e32e2018-04-03 13:22:50 -0700330 }
Jiyong Parkf1194352019-02-25 11:05:47 +0900331 if len(binary.post_install_cmds) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800332 entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(binary.post_install_cmds, "&& "))
Jiyong Parkf1194352019-02-25 11:05:47 +0900333 }
Colin Crossca860ac2016-01-04 14:34:37 -0800334 })
335}
336
Colin Crossd80cbca2020-02-24 12:01:37 -0800337func (benchmark *benchmarkDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
338 ctx.subAndroidMk(entries, benchmark.binaryDecorator)
339 entries.Class = "NATIVE_TESTS"
340 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700341 if len(benchmark.Properties.Test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800342 entries.AddCompatibilityTestSuites(benchmark.Properties.Test_suites...)
Colin Crosse28f4e22017-04-24 18:10:29 -0700343 }
Colin Cross303e21f2018-08-07 16:49:25 -0700344 if benchmark.testConfig != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800345 entries.SetString("LOCAL_FULL_TEST_CONFIG", benchmark.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700346 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800347 entries.SetBool("LOCAL_NATIVE_BENCHMARK", true)
Dan Shi2468d012020-01-06 15:47:57 -0800348 if !BoolDefault(benchmark.Properties.Auto_gen_config, true) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800349 entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
Dan Shi2468d012020-01-06 15:47:57 -0800350 }
Colin Crosse28f4e22017-04-24 18:10:29 -0700351 })
Chris Parsons216e10a2020-07-09 17:12:52 -0400352 dataPaths := []android.DataPath{}
353 for _, srcPath := range benchmark.data {
354 dataPaths = append(dataPaths, android.DataPath{SrcPath: srcPath})
355 }
356 androidMkWriteTestData(dataPaths, ctx, entries)
Colin Crossb916a382016-07-29 17:28:03 -0700357}
358
Colin Crossd80cbca2020-02-24 12:01:37 -0800359func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
360 ctx.subAndroidMk(entries, test.binaryDecorator)
361 entries.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700362 if Bool(test.Properties.Test_per_src) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800363 entries.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700364 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800365 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa929db02017-03-27 16:27:50 -0700366 if len(test.Properties.Test_suites) > 0 {
Liz Kammer57f5b332020-11-24 12:42:58 -0800367 entries.AddCompatibilityTestSuites(test.Properties.Test_suites...)
Colin Crossa929db02017-03-27 16:27:50 -0700368 }
Colin Cross303e21f2018-08-07 16:49:25 -0700369 if test.testConfig != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800370 entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700371 }
Dan Shi2468d012020-01-06 15:47:57 -0800372 if !BoolDefault(test.Properties.Auto_gen_config, true) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800373 entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
Dan Shi2468d012020-01-06 15:47:57 -0800374 }
kellyhung74b00522020-08-17 18:46:00 +0800375 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...)
Dan Shid79572f2020-11-13 14:33:46 -0800376 if Bool(test.Properties.Test_options.Unit_test) {
377 entries.SetBool("LOCAL_IS_UNIT_TEST", true)
378 }
Colin Crossa929db02017-03-27 16:27:50 -0700379 })
380
Colin Crossd80cbca2020-02-24 12:01:37 -0800381 androidMkWriteTestData(test.data, ctx, entries)
Dan Shi95d19422020-08-15 12:24:26 -0700382 androidMkWriteExtraTestConfigs(test.extraTestConfigs, entries)
Colin Crossa2344662016-03-24 13:14:12 -0700383}
384
Colin Crossd80cbca2020-02-24 12:01:37 -0800385func (fuzz *fuzzBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
386 ctx.subAndroidMk(entries, fuzz.binaryDecorator)
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700387
388 var fuzzFiles []string
389 for _, d := range fuzz.corpus {
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700390 fuzzFiles = append(fuzzFiles,
391 filepath.Dir(fuzz.corpusIntermediateDir.String())+":corpus/"+d.Base())
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700392 }
393
Tri Voad172d82019-11-27 13:45:45 -0800394 for _, d := range fuzz.data {
395 fuzzFiles = append(fuzzFiles,
396 filepath.Dir(fuzz.dataIntermediateDir.String())+":data/"+d.Rel())
397 }
398
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700399 if fuzz.dictionary != nil {
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700400 fuzzFiles = append(fuzzFiles,
401 filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base())
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700402 }
403
Kris Alderf979ee32019-10-22 10:52:01 -0700404 if fuzz.config != nil {
405 fuzzFiles = append(fuzzFiles,
406 filepath.Dir(fuzz.config.String())+":config.json")
407 }
408
Colin Crossd80cbca2020-02-24 12:01:37 -0800409 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
410 entries.SetBool("LOCAL_IS_FUZZ_TARGET", true)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700411 if len(fuzzFiles) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800412 entries.AddStrings("LOCAL_TEST_DATA", fuzzFiles...)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700413 }
414 if fuzz.installedSharedDeps != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800415 entries.AddStrings("LOCAL_FUZZ_INSTALLED_SHARED_DEPS", fuzz.installedSharedDeps...)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700416 }
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700417 })
418}
419
Colin Crossd80cbca2020-02-24 12:01:37 -0800420func (test *testLibrary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
421 ctx.subAndroidMk(entries, test.libraryDecorator)
Colin Crossb916a382016-07-29 17:28:03 -0700422}
Dan Willemsene7932e82016-05-16 15:56:53 -0700423
Colin Crossd80cbca2020-02-24 12:01:37 -0800424func (library *toolchainLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
425 entries.Class = "STATIC_LIBRARIES"
426 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
427 _, suffix, _ := android.SplitFileExt(entries.OutputFile.Path().Base())
428 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700429 })
430}
431
Colin Crossd80cbca2020-02-24 12:01:37 -0800432func (installer *baseInstaller) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Colin Crossc511bc52020-04-07 16:50:32 +0000433 if installer.path == (android.InstallPath{}) {
434 return
435 }
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700436 // Soong installation is only supported for host modules. Have Make
437 // installation trigger Soong installation.
438 if ctx.Target().Os.Class == android.Host {
Colin Crossd80cbca2020-02-24 12:01:37 -0800439 entries.OutputFile = android.OptionalPathForPath(installer.path)
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700440 }
441
Colin Crossd80cbca2020-02-24 12:01:37 -0800442 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossff6c33d2019-10-02 16:01:35 -0700443 path, file := filepath.Split(installer.path.ToMakePath().String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700444 stem, suffix, _ := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800445 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
446 entries.SetString("LOCAL_MODULE_PATH", path)
447 entries.SetString("LOCAL_MODULE_STEM", stem)
Colin Crossa2344662016-03-24 13:14:12 -0700448 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700449}
Dan Albert914449f2016-06-17 16:45:24 -0700450
Colin Crossd80cbca2020-02-24 12:01:37 -0800451func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Dan Albert1a246272020-07-06 14:49:35 -0700452 entries.SubName = ndkLibrarySuffix + "." + c.apiLevel.String()
Colin Crossd80cbca2020-02-24 12:01:37 -0800453 entries.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700454
Colin Cross5ec407b2020-09-30 11:41:33 -0700455 if !c.buildStubs() {
456 entries.Disabled = true
457 return
458 }
459
Colin Crossd80cbca2020-02-24 12:01:37 -0800460 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Cross0875c522017-11-28 17:34:01 -0800461 path, file := filepath.Split(c.installPath.String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700462 stem, suffix, _ := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800463 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
464 entries.SetString("LOCAL_MODULE_PATH", path)
465 entries.SetString("LOCAL_MODULE_STEM", stem)
466 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
sophiez58cabb72020-05-29 13:37:12 -0700467 if c.parsedCoverageXmlPath.String() != "" {
468 entries.SetString("SOONG_NDK_API_XML", "$(SOONG_NDK_API_XML) "+c.parsedCoverageXmlPath.String())
469 }
Dan Albert914449f2016-06-17 16:45:24 -0700470 })
471}
Dan Willemsenb916b802017-03-19 13:44:32 -0700472
Colin Crossd80cbca2020-02-24 12:01:37 -0800473func (c *llndkStubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
474 entries.Class = "SHARED_LIBRARIES"
Colin Cross0477b422020-10-13 18:43:54 -0700475 entries.OverrideName = c.implementationModuleName(ctx.BaseModuleName())
Dan Willemsenb916b802017-03-19 13:44:32 -0700476
Colin Crossd80cbca2020-02-24 12:01:37 -0800477 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
478 c.libraryDecorator.androidMkWriteExportedFlags(entries)
479 _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base())
Dan Willemsenb916b802017-03-19 13:44:32 -0700480
Colin Crossd80cbca2020-02-24 12:01:37 -0800481 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
482 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
483 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
484 entries.SetString("LOCAL_SOONG_TOC", c.toc().String())
Dan Willemsenb916b802017-03-19 13:44:32 -0700485 })
486}
Justin Yun71549282017-11-17 12:10:28 +0900487
Colin Crossd80cbca2020-02-24 12:01:37 -0800488func (c *vndkPrebuiltLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
489 entries.Class = "SHARED_LIBRARIES"
Justin Yun71549282017-11-17 12:10:28 +0900490
Colin Crossd80cbca2020-02-24 12:01:37 -0800491 entries.SubName = c.androidMkSuffix
Justin Yun71549282017-11-17 12:10:28 +0900492
Colin Crossd80cbca2020-02-24 12:01:37 -0800493 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
494 c.libraryDecorator.androidMkWriteExportedFlags(entries)
Justin Yun71549282017-11-17 12:10:28 +0900495
Inseob Kim81235ff2020-10-23 14:36:11 +0900496 // Specifying stem is to pass check_elf_files when vendor modules link against vndk prebuilt.
497 // We can't use install path because VNDKs are not installed. Instead, Srcs is directly used.
498 _, file := filepath.Split(c.properties.Srcs[0])
499 stem, suffix, ext := android.SplitFileExt(file)
500 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
501 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
502 entries.SetString("LOCAL_MODULE_STEM", stem)
503
Inseob Kimeec88e12020-01-22 11:11:29 +0900504 if c.tocFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800505 entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String())
Inseob Kimeec88e12020-01-22 11:11:29 +0900506 }
Inseob Kim81235ff2020-10-23 14:36:11 +0900507
508 // VNDK libraries available to vendor are not installed because
509 // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
510 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Inseob Kimeec88e12020-01-22 11:11:29 +0900511 })
512}
513
Jose Galmesf7294582020-11-13 12:07:36 -0800514func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Inseob Kimeec88e12020-01-22 11:11:29 +0900515 // Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current
516 // and the version of the prebuilt is same as BOARD_VNDK_VERSION.
517 if c.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800518 entries.Class = "SHARED_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900519 } else if c.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800520 entries.Class = "STATIC_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900521 } else if c.header() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800522 entries.Class = "HEADER_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900523 }
524
Inseob Kimc42f2f22020-07-29 20:32:10 +0900525 entries.SubName = ""
526
527 if c.sanitizerProperties.CfiEnabled {
528 entries.SubName += ".cfi"
529 }
530
Inseob Kimeec88e12020-01-22 11:11:29 +0900531 if c.androidMkVendorSuffix {
Inseob Kimc42f2f22020-07-29 20:32:10 +0900532 entries.SubName += vendorSuffix
Inseob Kimeec88e12020-01-22 11:11:29 +0900533 }
534
Colin Crossd80cbca2020-02-24 12:01:37 -0800535 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
536 c.libraryDecorator.androidMkWriteExportedFlags(entries)
Inseob Kimeec88e12020-01-22 11:11:29 +0900537
Inseob Kimc3b1a162020-02-18 12:42:54 +0900538 if c.shared() || c.static() {
Inseob Kimeec88e12020-01-22 11:11:29 +0900539 path, file := filepath.Split(c.path.ToMakePath().String())
540 stem, suffix, ext := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800541 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
542 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
543 entries.SetString("LOCAL_MODULE_STEM", stem)
Inseob Kimeec88e12020-01-22 11:11:29 +0900544 if c.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800545 entries.SetString("LOCAL_MODULE_PATH", path)
Inseob Kimeec88e12020-01-22 11:11:29 +0900546 }
547 if c.tocFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800548 entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String())
Inseob Kimeec88e12020-01-22 11:11:29 +0900549 }
Inseob Kimc3b1a162020-02-18 12:42:54 +0900550 }
551
552 if !c.shared() { // static or header
Colin Crossd80cbca2020-02-24 12:01:37 -0800553 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Inseob Kimeec88e12020-01-22 11:11:29 +0900554 }
555 })
556}
557
Jose Galmesf7294582020-11-13 12:07:36 -0800558func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800559 entries.Class = "EXECUTABLES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900560
561 if c.androidMkVendorSuffix {
Colin Crossd80cbca2020-02-24 12:01:37 -0800562 entries.SubName = vendorSuffix
Inseob Kimeec88e12020-01-22 11:11:29 +0900563 } else {
Colin Crossd80cbca2020-02-24 12:01:37 -0800564 entries.SubName = ""
Inseob Kimeec88e12020-01-22 11:11:29 +0900565 }
566
Colin Crossd80cbca2020-02-24 12:01:37 -0800567 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
568 entries.AddStrings("LOCAL_MODULE_SYMLINKS", c.Properties.Symlinks...)
Justin Yun71549282017-11-17 12:10:28 +0900569 })
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800570}
Dan Albert8ba131b2017-12-14 13:23:15 -0800571
Jose Galmesf7294582020-11-13 12:07:36 -0800572func (c *snapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Inseob Kim1042d292020-06-01 23:23:05 +0900573 entries.Class = "STATIC_LIBRARIES"
574
575 if c.androidMkVendorSuffix {
576 entries.SubName = vendorSuffix
577 } else {
578 entries.SubName = ""
579 }
580
581 entries.ExtraFooters = append(entries.ExtraFooters,
Jaewoong Jung02b11a62020-12-07 10:23:54 -0800582 func(w io.Writer, name, prefix, moduleDir string) {
Inseob Kim1042d292020-06-01 23:23:05 +0900583 out := entries.OutputFile.Path()
584 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
585
586 fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
587 fmt.Fprintln(w, ".KATI_READONLY: "+varname)
588 })
589}
590
Colin Crossd80cbca2020-02-24 12:01:37 -0800591func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
592 entries.Class = "SHARED_LIBRARIES"
Dan Albert8ba131b2017-12-14 13:23:15 -0800593}
Jiyong Park374510b2018-03-19 18:23:01 +0900594
Colin Crossd80cbca2020-02-24 12:01:37 -0800595func (c *vendorPublicLibraryStubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
596 entries.Class = "SHARED_LIBRARIES"
597 entries.SubName = vendorPublicLibrarySuffix
Jiyong Park374510b2018-03-19 18:23:01 +0900598
Colin Crossd80cbca2020-02-24 12:01:37 -0800599 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
600 c.libraryDecorator.androidMkWriteExportedFlags(entries)
601 _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base())
Jiyong Park374510b2018-03-19 18:23:01 +0900602
Colin Crossd80cbca2020-02-24 12:01:37 -0800603 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
604 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
605 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
Jiyong Park374510b2018-03-19 18:23:01 +0900606 })
607}
Logan Chien4fcea3d2018-11-20 11:59:08 +0800608
Colin Crossd80cbca2020-02-24 12:01:37 -0800609func (p *prebuiltLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
610 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Logan Chien4fcea3d2018-11-20 11:59:08 +0800611 if p.properties.Check_elf_files != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800612 entries.SetBool("LOCAL_CHECK_ELF_FILES", *p.properties.Check_elf_files)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800613 } else {
614 // soong_cc_prebuilt.mk does not include check_elf_file.mk by default
615 // because cc_library_shared and cc_binary use soong_cc_prebuilt.mk as well.
616 // In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to
617 // true if `p.properties.Check_elf_files` is not specified.
Colin Crossd80cbca2020-02-24 12:01:37 -0800618 entries.SetBool("LOCAL_CHECK_ELF_FILES", true)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800619 }
620 })
621}
622
Colin Crossd80cbca2020-02-24 12:01:37 -0800623func (p *prebuiltLibraryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
624 ctx.subAndroidMk(entries, p.libraryDecorator)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800625 if p.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800626 ctx.subAndroidMk(entries, &p.prebuiltLinker)
627 androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800628 }
629}
630
Colin Crossd80cbca2020-02-24 12:01:37 -0800631func (p *prebuiltBinaryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
632 ctx.subAndroidMk(entries, p.binaryDecorator)
633 ctx.subAndroidMk(entries, &p.prebuiltLinker)
634 androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800635}
636
Colin Crossd80cbca2020-02-24 12:01:37 -0800637func androidMkWriteAllowUndefinedSymbols(linker *baseLinker, entries *android.AndroidMkEntries) {
638 allow := linker.Properties.Allow_undefined_symbols
639 if allow != nil {
640 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
641 entries.SetBool("LOCAL_ALLOW_UNDEFINED_SYMBOLS", *allow)
642 })
643 }
Logan Chien4fcea3d2018-11-20 11:59:08 +0800644}