blob: d92fabc0d0534615cea791a6152600a0009a4dbb [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 (
dimitry43204492019-05-23 13:24:38 +020027 nativeBridgeSuffix = ".native_bridge"
Justin Yun5f7f7e82019-11-18 19:52:14 +090028 productSuffix = ".product"
dimitry43204492019-05-23 13:24:38 +020029 vendorSuffix = ".vendor"
Yifan Hong1b3348d2020-01-21 15:53:22 -080030 ramdiskSuffix = ".ramdisk"
dimitry43204492019-05-23 13:24:38 +020031 recoverySuffix = ".recovery"
Colin Crossc511bc52020-04-07 16:50:32 +000032 sdkSuffix = ".sdk"
Jiyong Park27b188b2017-07-18 13:23:39 +090033)
34
Dan Willemsenf2c27d72016-07-13 16:50:22 -070035type AndroidMkContext interface {
Colin Crossd48fe732020-09-23 20:37:24 -070036 BaseModuleName() string
Dan Willemsenf2c27d72016-07-13 16:50:22 -070037 Target() android.Target
Colin Crossd80cbca2020-02-24 12:01:37 -080038 subAndroidMk(*android.AndroidMkEntries, interface{})
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +000039 Arch() android.Arch
40 Os() android.OsType
41 Host() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070042 UseVndk() bool
Justin Yun5f7f7e82019-11-18 19:52:14 +090043 VndkVersion() string
Jiyong Parkb0788572018-12-20 22:10:17 +090044 static() bool
Yifan Hong1b3348d2020-01-21 15:53:22 -080045 InRamdisk() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070046 InRecovery() bool
Colin Crossb916a382016-07-29 17:28:03 -070047}
48
49type subAndroidMkProvider interface {
Colin Crossd80cbca2020-02-24 12:01:37 -080050 AndroidMkEntries(AndroidMkContext, *android.AndroidMkEntries)
Colin Crossb916a382016-07-29 17:28:03 -070051}
52
Colin Crossd80cbca2020-02-24 12:01:37 -080053func (c *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) {
Colin Crossb916a382016-07-29 17:28:03 -070054 if c.subAndroidMkOnce == nil {
55 c.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
56 }
57 if androidmk, ok := obj.(subAndroidMkProvider); ok {
58 if !c.subAndroidMkOnce[androidmk] {
59 c.subAndroidMkOnce[androidmk] = true
Colin Crossd80cbca2020-02-24 12:01:37 -080060 androidmk.AndroidMkEntries(c, entries)
Colin Crossb916a382016-07-29 17:28:03 -070061 }
62 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070063}
64
Colin Crossd80cbca2020-02-24 12:01:37 -080065func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
Jiyong Park9d452992018-10-03 00:38:19 +090066 if c.Properties.HideFromMake || !c.IsForPlatform() {
Colin Crossd80cbca2020-02-24 12:01:37 -080067 return []android.AndroidMkEntries{{
Colin Crossa18e9cf2017-08-10 17:00:19 -070068 Disabled: true,
Colin Crossd80cbca2020-02-24 12:01:37 -080069 }}
Colin Crossbc6fb162016-05-24 15:39:04 -070070 }
71
Colin Crossd80cbca2020-02-24 12:01:37 -080072 entries := android.AndroidMkEntries{
Colin Crossa18e9cf2017-08-10 17:00:19 -070073 OutputFile: c.outputFile,
Jiyong Parkb0788572018-12-20 22:10:17 +090074 // TODO(jiyong): add the APEXes providing shared libs to the required modules
75 // Currently, adding c.Properties.ApexesProvidingSharedLibs is causing multiple
Martin Stjernholmcc4b0ad2019-07-05 22:38:25 +010076 // ART APEXes (com.android.art.debug|release) to be installed. And this
Jiyong Parkb0788572018-12-20 22:10:17 +090077 // is breaking some older devices (like marlin) where system.img is small.
78 Required: c.Properties.AndroidMkRuntimeLibs,
79 Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
Logan Chien43d34c32017-12-20 01:17:32 +080080
Colin Crossd80cbca2020-02-24 12:01:37 -080081 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
82 func(entries *android.AndroidMkEntries) {
Colin Cross5beccee2017-12-07 15:28:59 -080083 if len(c.Properties.Logtags) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -080084 entries.AddStrings("LOCAL_LOGTAGS_FILES", c.Properties.Logtags...)
Colin Cross5beccee2017-12-07 15:28:59 -080085 }
Yo Chiang219968c2020-09-22 18:45:04 +080086 // Note: Pass the exact value of AndroidMkSystemSharedLibs to the Make
87 // world, even if it is an empty list. In the Make world,
88 // LOCAL_SYSTEM_SHARED_LIBRARIES defaults to "none", which is expanded
89 // to the default list of system shared libs by the build system.
90 // Soong computes the exact list of system shared libs, so we have to
91 // override the default value when the list of libs is actually empty.
92 entries.SetString("LOCAL_SYSTEM_SHARED_LIBRARIES", strings.Join(c.Properties.AndroidMkSystemSharedLibs, " "))
Colin Crossa18e9cf2017-08-10 17:00:19 -070093 if len(c.Properties.AndroidMkSharedLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -080094 entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...)
Colin Crossa18e9cf2017-08-10 17:00:19 -070095 }
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +000096 if len(c.Properties.AndroidMkStaticLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -080097 entries.AddStrings("LOCAL_STATIC_LIBRARIES", c.Properties.AndroidMkStaticLibs...)
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +000098 }
99 if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800100 entries.AddStrings("LOCAL_WHOLE_STATIC_LIBRARIES", c.Properties.AndroidMkWholeStaticLibs...)
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +0000101 }
Bill Peckhama46de702020-04-21 17:23:37 -0700102 if len(c.Properties.AndroidMkHeaderLibs) > 0 {
103 entries.AddStrings("LOCAL_HEADER_LIBRARIES", c.Properties.AndroidMkHeaderLibs...)
104 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800105 entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType)
Ivan Lozano52767be2019-10-18 14:49:46 -0700106 if c.UseVndk() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800107 entries.SetBool("LOCAL_USE_VNDK", true)
Ivan Lozano52767be2019-10-18 14:49:46 -0700108 if c.IsVndk() && !c.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800109 entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion())
Jooyung Hanb01c1142019-10-29 05:24:42 +0900110 // VNDK libraries available to vendor are not installed because
111 // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
112 if !c.isVndkExt() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800113 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Jooyung Hanb01c1142019-10-29 05:24:42 +0900114 }
Jooyung Han76106d92019-05-20 18:49:10 +0900115 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700116 }
Colin Crossc511bc52020-04-07 16:50:32 +0000117 if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
118 // Make the SDK variant uninstallable so that there are not two rules to install
119 // to the same location.
120 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
121 // Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite
122 // dependencies to the .sdk suffix when building a module that uses the SDK.
123 entries.SetString("SOONG_SDK_VARIANT_MODULES",
124 "$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
125 }
126 },
127 },
128 ExtraFooters: []android.AndroidMkExtraFootersFunc{
129 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
130 if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake &&
131 c.CcLibraryInterface() && c.Shared() {
132 // Using the SDK variant as a JNI library needs a copy of the .so that
133 // is not named .sdk.so so that it can be packaged into the APK with
134 // the right name.
135 fmt.Fprintln(w, "$(eval $(call copy-one-file,",
136 "$(LOCAL_BUILT_MODULE),",
137 "$(patsubst %.sdk.so,%.so,$(LOCAL_BUILT_MODULE))))")
138 }
Colin Crossa18e9cf2017-08-10 17:00:19 -0700139 },
140 },
141 }
Colin Crossca860ac2016-01-04 14:34:37 -0800142
Colin Crossca860ac2016-01-04 14:34:37 -0800143 for _, feature := range c.features {
Colin Crossd80cbca2020-02-24 12:01:37 -0800144 c.subAndroidMk(&entries, feature)
Colin Crossca860ac2016-01-04 14:34:37 -0800145 }
146
Colin Crossd80cbca2020-02-24 12:01:37 -0800147 c.subAndroidMk(&entries, c.compiler)
148 c.subAndroidMk(&entries, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700149 if c.sanitize != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800150 c.subAndroidMk(&entries, c.sanitize)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700151 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800152 c.subAndroidMk(&entries, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -0800153
Colin Crossd80cbca2020-02-24 12:01:37 -0800154 entries.SubName += c.Properties.SubName
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700155
Colin Crossd80cbca2020-02-24 12:01:37 -0800156 return []android.AndroidMkEntries{entries}
Colin Crossca860ac2016-01-04 14:34:37 -0800157}
158
Dan Shi95d19422020-08-15 12:24:26 -0700159func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkEntries) {
160 if len(extraTestConfigs) > 0 {
161 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
162 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
163 })
164 }
165}
166
Chris Parsons216e10a2020-07-09 17:12:52 -0400167func androidMkWriteTestData(data []android.DataPath, ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Dan Shi31949122020-09-21 12:11:02 -0700168 testFiles := android.AndroidMkDataPaths(data)
Anders Lewisb97e8182017-07-14 15:20:13 -0700169 if len(testFiles) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800170 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
171 entries.AddStrings("LOCAL_TEST_DATA", testFiles...)
Anders Lewisb97e8182017-07-14 15:20:13 -0700172 })
173 }
174}
175
dimitrydb417472019-05-20 16:16:47 +0200176func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string {
177 if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
178 var result []string
179 for _, override := range overrides {
180 result = append(result, override+nativeBridgeSuffix)
181 }
182 return result
183 }
184
185 return overrides
186}
187
Colin Crossd80cbca2020-02-24 12:01:37 -0800188func (library *libraryDecorator) androidMkWriteExportedFlags(entries *android.AndroidMkEntries) {
Dan Willemsen58539402017-03-19 13:44:32 -0700189 exportedFlags := library.exportedFlags()
Inseob Kim69378442019-06-03 19:10:47 +0900190 for _, dir := range library.exportedDirs() {
Jiyong Park74955042019-10-22 20:19:51 +0900191 exportedFlags = append(exportedFlags, "-I"+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900192 }
193 for _, dir := range library.exportedSystemDirs() {
Jiyong Park74955042019-10-22 20:19:51 +0900194 exportedFlags = append(exportedFlags, "-isystem "+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900195 }
Dan Willemsen58539402017-03-19 13:44:32 -0700196 if len(exportedFlags) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800197 entries.AddStrings("LOCAL_EXPORT_CFLAGS", exportedFlags...)
Dan Willemsend5781342017-02-15 16:15:21 -0800198 }
Inseob Kim69378442019-06-03 19:10:47 +0900199 exportedDeps := library.exportedDeps()
200 if len(exportedDeps) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800201 entries.AddStrings("LOCAL_EXPORT_C_INCLUDE_DEPS", exportedDeps.Strings()...)
Dan Willemsen58539402017-03-19 13:44:32 -0700202 }
203}
Dan Willemsend5781342017-02-15 16:15:21 -0800204
Colin Crossd80cbca2020-02-24 12:01:37 -0800205func (library *libraryDecorator) androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries *android.AndroidMkEntries) {
Yo Chiangeb912dc2020-07-28 20:01:31 +0800206 if library.sAbiDiff.Valid() && !library.static() {
207 entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", library.sAbiDiff.String())
Logan Chien41eabe62019-04-10 13:33:58 +0800208 }
209}
210
Colin Crossd80cbca2020-02-24 12:01:37 -0800211// TODO(ccross): remove this once apex/androidmk.go is converted to AndroidMkEntries
212func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
Yo Chiangeb912dc2020-07-28 20:01:31 +0800213 if library.sAbiDiff.Valid() && !library.static() {
214 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiDiff.String())
Colin Crossd80cbca2020-02-24 12:01:37 -0800215 }
216}
217
218func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Dan Willemsend5781342017-02-15 16:15:21 -0800219 if library.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800220 entries.Class = "STATIC_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800221 } else if library.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800222 entries.Class = "SHARED_LIBRARIES"
223 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
224 entries.SetString("LOCAL_SOONG_TOC", library.toc().String())
Jiyong Park47e4fcb2019-02-05 22:33:10 +0900225 if !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800226 entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", library.unstrippedOutputFile.String())
Jiyong Park47e4fcb2019-02-05 22:33:10 +0900227 }
dimitryd95964a2018-11-07 13:43:34 +0100228 if len(library.Properties.Overrides) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800229 entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " "))
dimitryd95964a2018-11-07 13:43:34 +0100230 }
Jiyong Parkf1194352019-02-25 11:05:47 +0900231 if len(library.post_install_cmds) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800232 entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(library.post_install_cmds, "&& "))
Jiyong Parkf1194352019-02-25 11:05:47 +0900233 }
Colin Crossb60190a2018-09-04 16:28:17 -0700234 })
Dan Willemsend5781342017-02-15 16:15:21 -0800235 } else if library.header() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800236 entries.Class = "HEADER_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800237 }
238
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000239 if library.distFile != nil {
240 entries.DistFiles = android.MakeDefaultDistFiles(library.distFile)
241 }
242
Colin Crossd80cbca2020-02-24 12:01:37 -0800243 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
244 library.androidMkWriteExportedFlags(entries)
245 library.androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries)
Dan Willemsen218f6562015-07-08 18:13:11 -0700246
Colin Crossd80cbca2020-02-24 12:01:37 -0800247 _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base())
Logan Chien031d2b32018-07-26 00:19:50 +0800248
Colin Crossd80cbca2020-02-24 12:01:37 -0800249 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
Dan Willemsen218f6562015-07-08 18:13:11 -0700250
Dan Willemsen581341d2017-02-09 16:16:31 -0800251 if library.coverageOutputFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800252 entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", library.coverageOutputFile.String())
Dan Willemsen581341d2017-02-09 16:16:31 -0800253 }
Vic Yangefd249e2018-11-12 20:19:56 -0800254
255 if library.useCoreVariant {
Colin Crossd80cbca2020-02-24 12:01:37 -0800256 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
257 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
258 entries.SetBool("LOCAL_VNDK_DEPEND_ON_CORE_VARIANT", true)
Vic Yangefd249e2018-11-12 20:19:56 -0800259 }
Vic Yangd92090f2020-01-08 14:32:28 -0800260 if library.checkSameCoreVariant {
Colin Crossd80cbca2020-02-24 12:01:37 -0800261 entries.SetBool("LOCAL_CHECK_SAME_VNDK_VARIANTS", true)
Vic Yangd92090f2020-01-08 14:32:28 -0800262 }
Colin Crossca860ac2016-01-04 14:34:37 -0800263 })
Colin Crossb916a382016-07-29 17:28:03 -0700264
Jiyong Parkb0788572018-12-20 22:10:17 +0900265 if library.shared() && !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800266 ctx.subAndroidMk(entries, library.baseInstaller)
Colin Crossb60190a2018-09-04 16:28:17 -0700267 } else {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900268 if library.buildStubs() {
269 entries.SubName = "." + library.stubsVersion()
270 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800271 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Martin Stjernholm9e9bb7f2020-08-06 22:34:42 +0100272 // library.makeUninstallable() depends on this to bypass SkipInstall() for
273 // static libraries.
Colin Crossd80cbca2020-02-24 12:01:37 -0800274 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Jiyong Parkb0788572018-12-20 22:10:17 +0900275 if library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800276 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
Jiyong Parkb0788572018-12-20 22:10:17 +0900277 }
Colin Crossb60190a2018-09-04 16:28:17 -0700278 })
Colin Crossb916a382016-07-29 17:28:03 -0700279 }
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +0000280 if len(library.Properties.Stubs.Versions) > 0 &&
Colin Crossd48fe732020-09-23 20:37:24 -0700281 android.DirectlyInAnyApex(ctx, ctx.BaseModuleName()) && !ctx.InRamdisk() && !ctx.InRecovery() && !ctx.UseVndk() &&
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +0000282 !ctx.static() {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900283 if library.buildStubs() && library.isLatestStubVersion() {
284 // reference the latest version via its name without suffix when it is provided by apex
285 entries.SubName = ""
286 }
Jiyong Parkb0788572018-12-20 22:10:17 +0900287 if !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800288 entries.SubName = ".bootstrap"
Jiyong Parkb0788572018-12-20 22:10:17 +0900289 }
290 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700291}
292
Colin Crossd80cbca2020-02-24 12:01:37 -0800293func (object *objectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
294 entries.Class = "STATIC_LIBRARIES"
295 entries.ExtraFooters = append(entries.ExtraFooters,
296 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
297 out := entries.OutputFile.Path()
298 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
Dan Willemsen218f6562015-07-08 18:13:11 -0700299
Colin Crossd80cbca2020-02-24 12:01:37 -0800300 fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
301 fmt.Fprintln(w, ".KATI_READONLY: "+varname)
302 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700303}
304
Colin Crossd80cbca2020-02-24 12:01:37 -0800305func (binary *binaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
306 ctx.subAndroidMk(entries, binary.baseInstaller)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700307
Colin Crossd80cbca2020-02-24 12:01:37 -0800308 entries.Class = "EXECUTABLES"
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000309 entries.DistFiles = binary.distFiles
Colin Crossd80cbca2020-02-24 12:01:37 -0800310 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
311 entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", binary.unstrippedOutputFile.String())
Colin Cross9b09f242016-12-07 13:37:42 -0800312 if len(binary.symlinks) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800313 entries.AddStrings("LOCAL_MODULE_SYMLINKS", binary.symlinks...)
Colin Cross9b09f242016-12-07 13:37:42 -0800314 }
315
Dan Willemsen581341d2017-02-09 16:16:31 -0800316 if binary.coverageOutputFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800317 entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", binary.coverageOutputFile.String())
Dan Willemsen581341d2017-02-09 16:16:31 -0800318 }
Yifan Hong946e32e2018-04-03 13:22:50 -0700319
320 if len(binary.Properties.Overrides) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800321 entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " "))
Yifan Hong946e32e2018-04-03 13:22:50 -0700322 }
Jiyong Parkf1194352019-02-25 11:05:47 +0900323 if len(binary.post_install_cmds) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800324 entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(binary.post_install_cmds, "&& "))
Jiyong Parkf1194352019-02-25 11:05:47 +0900325 }
Colin Crossca860ac2016-01-04 14:34:37 -0800326 })
327}
328
Colin Crossd80cbca2020-02-24 12:01:37 -0800329func (benchmark *benchmarkDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
330 ctx.subAndroidMk(entries, benchmark.binaryDecorator)
331 entries.Class = "NATIVE_TESTS"
332 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crosse28f4e22017-04-24 18:10:29 -0700333 if len(benchmark.Properties.Test_suites) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800334 entries.SetString("LOCAL_COMPATIBILITY_SUITE",
Colin Crosse28f4e22017-04-24 18:10:29 -0700335 strings.Join(benchmark.Properties.Test_suites, " "))
336 }
Colin Cross303e21f2018-08-07 16:49:25 -0700337 if benchmark.testConfig != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800338 entries.SetString("LOCAL_FULL_TEST_CONFIG", benchmark.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700339 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800340 entries.SetBool("LOCAL_NATIVE_BENCHMARK", true)
Dan Shi2468d012020-01-06 15:47:57 -0800341 if !BoolDefault(benchmark.Properties.Auto_gen_config, true) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800342 entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
Dan Shi2468d012020-01-06 15:47:57 -0800343 }
Colin Crosse28f4e22017-04-24 18:10:29 -0700344 })
Chris Parsons216e10a2020-07-09 17:12:52 -0400345 dataPaths := []android.DataPath{}
346 for _, srcPath := range benchmark.data {
347 dataPaths = append(dataPaths, android.DataPath{SrcPath: srcPath})
348 }
349 androidMkWriteTestData(dataPaths, ctx, entries)
Colin Crossb916a382016-07-29 17:28:03 -0700350}
351
Colin Crossd80cbca2020-02-24 12:01:37 -0800352func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
353 ctx.subAndroidMk(entries, test.binaryDecorator)
354 entries.Class = "NATIVE_TESTS"
Colin Crossb916a382016-07-29 17:28:03 -0700355 if Bool(test.Properties.Test_per_src) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800356 entries.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
Colin Crossa2344662016-03-24 13:14:12 -0700357 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800358 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossa929db02017-03-27 16:27:50 -0700359 if len(test.Properties.Test_suites) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800360 entries.SetString("LOCAL_COMPATIBILITY_SUITE",
Colin Crossa929db02017-03-27 16:27:50 -0700361 strings.Join(test.Properties.Test_suites, " "))
362 }
Colin Cross303e21f2018-08-07 16:49:25 -0700363 if test.testConfig != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800364 entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String())
Julien Despreze146e392018-08-02 15:00:46 -0700365 }
Dan Shi2468d012020-01-06 15:47:57 -0800366 if !BoolDefault(test.Properties.Auto_gen_config, true) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800367 entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
Dan Shi2468d012020-01-06 15:47:57 -0800368 }
kellyhung74b00522020-08-17 18:46:00 +0800369 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...)
Colin Crossa929db02017-03-27 16:27:50 -0700370 })
371
Colin Crossd80cbca2020-02-24 12:01:37 -0800372 androidMkWriteTestData(test.data, ctx, entries)
Dan Shi95d19422020-08-15 12:24:26 -0700373 androidMkWriteExtraTestConfigs(test.extraTestConfigs, entries)
Colin Crossa2344662016-03-24 13:14:12 -0700374}
375
Colin Crossd80cbca2020-02-24 12:01:37 -0800376func (fuzz *fuzzBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
377 ctx.subAndroidMk(entries, fuzz.binaryDecorator)
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700378
379 var fuzzFiles []string
380 for _, d := range fuzz.corpus {
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700381 fuzzFiles = append(fuzzFiles,
382 filepath.Dir(fuzz.corpusIntermediateDir.String())+":corpus/"+d.Base())
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700383 }
384
Tri Voad172d82019-11-27 13:45:45 -0800385 for _, d := range fuzz.data {
386 fuzzFiles = append(fuzzFiles,
387 filepath.Dir(fuzz.dataIntermediateDir.String())+":data/"+d.Rel())
388 }
389
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700390 if fuzz.dictionary != nil {
Mitch Phillips8a2bc0b2019-10-17 15:04:01 -0700391 fuzzFiles = append(fuzzFiles,
392 filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base())
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700393 }
394
Kris Alderf979ee32019-10-22 10:52:01 -0700395 if fuzz.config != nil {
396 fuzzFiles = append(fuzzFiles,
397 filepath.Dir(fuzz.config.String())+":config.json")
398 }
399
Colin Crossd80cbca2020-02-24 12:01:37 -0800400 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
401 entries.SetBool("LOCAL_IS_FUZZ_TARGET", true)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700402 if len(fuzzFiles) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800403 entries.AddStrings("LOCAL_TEST_DATA", fuzzFiles...)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700404 }
405 if fuzz.installedSharedDeps != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800406 entries.AddStrings("LOCAL_FUZZ_INSTALLED_SHARED_DEPS", fuzz.installedSharedDeps...)
Mitch Phillipse1ee1a12019-10-17 19:20:41 -0700407 }
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700408 })
409}
410
Colin Crossd80cbca2020-02-24 12:01:37 -0800411func (test *testLibrary) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
412 ctx.subAndroidMk(entries, test.libraryDecorator)
Colin Crossb916a382016-07-29 17:28:03 -0700413}
Dan Willemsene7932e82016-05-16 15:56:53 -0700414
Colin Crossd80cbca2020-02-24 12:01:37 -0800415func (library *toolchainLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
416 entries.Class = "STATIC_LIBRARIES"
417 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
418 _, suffix, _ := android.SplitFileExt(entries.OutputFile.Path().Base())
419 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700420 })
421}
422
Colin Crossd80cbca2020-02-24 12:01:37 -0800423func (installer *baseInstaller) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Colin Crossc511bc52020-04-07 16:50:32 +0000424 if installer.path == (android.InstallPath{}) {
425 return
426 }
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700427 // Soong installation is only supported for host modules. Have Make
428 // installation trigger Soong installation.
429 if ctx.Target().Os.Class == android.Host {
Colin Crossd80cbca2020-02-24 12:01:37 -0800430 entries.OutputFile = android.OptionalPathForPath(installer.path)
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700431 }
432
Colin Crossd80cbca2020-02-24 12:01:37 -0800433 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Crossff6c33d2019-10-02 16:01:35 -0700434 path, file := filepath.Split(installer.path.ToMakePath().String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700435 stem, suffix, _ := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800436 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
437 entries.SetString("LOCAL_MODULE_PATH", path)
438 entries.SetString("LOCAL_MODULE_STEM", stem)
Colin Crossa2344662016-03-24 13:14:12 -0700439 })
Dan Willemsen218f6562015-07-08 18:13:11 -0700440}
Dan Albert914449f2016-06-17 16:45:24 -0700441
Colin Crossd80cbca2020-02-24 12:01:37 -0800442func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Dan Albert1a246272020-07-06 14:49:35 -0700443 entries.SubName = ndkLibrarySuffix + "." + c.apiLevel.String()
Colin Crossd80cbca2020-02-24 12:01:37 -0800444 entries.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700445
Colin Crossd80cbca2020-02-24 12:01:37 -0800446 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Colin Cross0875c522017-11-28 17:34:01 -0800447 path, file := filepath.Split(c.installPath.String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700448 stem, suffix, _ := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800449 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
450 entries.SetString("LOCAL_MODULE_PATH", path)
451 entries.SetString("LOCAL_MODULE_STEM", stem)
452 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
sophiez58cabb72020-05-29 13:37:12 -0700453 if c.parsedCoverageXmlPath.String() != "" {
454 entries.SetString("SOONG_NDK_API_XML", "$(SOONG_NDK_API_XML) "+c.parsedCoverageXmlPath.String())
455 }
Dan Albert914449f2016-06-17 16:45:24 -0700456 })
457}
Dan Willemsenb916b802017-03-19 13:44:32 -0700458
Colin Crossd80cbca2020-02-24 12:01:37 -0800459func (c *llndkStubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
460 entries.Class = "SHARED_LIBRARIES"
Dan Willemsenb916b802017-03-19 13:44:32 -0700461
Colin Crossd80cbca2020-02-24 12:01:37 -0800462 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
463 c.libraryDecorator.androidMkWriteExportedFlags(entries)
464 _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base())
Dan Willemsenb916b802017-03-19 13:44:32 -0700465
Colin Crossd80cbca2020-02-24 12:01:37 -0800466 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
467 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
468 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
469 entries.SetString("LOCAL_SOONG_TOC", c.toc().String())
Dan Willemsenb916b802017-03-19 13:44:32 -0700470 })
471}
Justin Yun71549282017-11-17 12:10:28 +0900472
Colin Crossd80cbca2020-02-24 12:01:37 -0800473func (c *vndkPrebuiltLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
474 entries.Class = "SHARED_LIBRARIES"
Justin Yun71549282017-11-17 12:10:28 +0900475
Colin Crossd80cbca2020-02-24 12:01:37 -0800476 entries.SubName = c.androidMkSuffix
Justin Yun71549282017-11-17 12:10:28 +0900477
Colin Crossd80cbca2020-02-24 12:01:37 -0800478 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
479 c.libraryDecorator.androidMkWriteExportedFlags(entries)
Justin Yun71549282017-11-17 12:10:28 +0900480
Colin Crossff6c33d2019-10-02 16:01:35 -0700481 path, file := filepath.Split(c.path.ToMakePath().String())
Ivan Lozano022a73b2019-09-09 20:29:31 -0700482 stem, suffix, ext := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800483 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
484 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
485 entries.SetString("LOCAL_MODULE_PATH", path)
486 entries.SetString("LOCAL_MODULE_STEM", stem)
Inseob Kimeec88e12020-01-22 11:11:29 +0900487 if c.tocFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800488 entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String())
Inseob Kimeec88e12020-01-22 11:11:29 +0900489 }
490 })
491}
492
Colin Crossd80cbca2020-02-24 12:01:37 -0800493func (c *vendorSnapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
Inseob Kimeec88e12020-01-22 11:11:29 +0900494 // Each vendor snapshot is exported to androidMk only when BOARD_VNDK_VERSION != current
495 // and the version of the prebuilt is same as BOARD_VNDK_VERSION.
496 if c.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800497 entries.Class = "SHARED_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900498 } else if c.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800499 entries.Class = "STATIC_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900500 } else if c.header() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800501 entries.Class = "HEADER_LIBRARIES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900502 }
503
Inseob Kimc42f2f22020-07-29 20:32:10 +0900504 entries.SubName = ""
505
506 if c.sanitizerProperties.CfiEnabled {
507 entries.SubName += ".cfi"
508 }
509
Inseob Kimeec88e12020-01-22 11:11:29 +0900510 if c.androidMkVendorSuffix {
Inseob Kimc42f2f22020-07-29 20:32:10 +0900511 entries.SubName += vendorSuffix
Inseob Kimeec88e12020-01-22 11:11:29 +0900512 }
513
Colin Crossd80cbca2020-02-24 12:01:37 -0800514 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
515 c.libraryDecorator.androidMkWriteExportedFlags(entries)
Inseob Kimeec88e12020-01-22 11:11:29 +0900516
Inseob Kimc3b1a162020-02-18 12:42:54 +0900517 if c.shared() || c.static() {
Inseob Kimeec88e12020-01-22 11:11:29 +0900518 path, file := filepath.Split(c.path.ToMakePath().String())
519 stem, suffix, ext := android.SplitFileExt(file)
Colin Crossd80cbca2020-02-24 12:01:37 -0800520 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
521 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
522 entries.SetString("LOCAL_MODULE_STEM", stem)
Inseob Kimeec88e12020-01-22 11:11:29 +0900523 if c.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800524 entries.SetString("LOCAL_MODULE_PATH", path)
Inseob Kimeec88e12020-01-22 11:11:29 +0900525 }
526 if c.tocFile.Valid() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800527 entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String())
Inseob Kimeec88e12020-01-22 11:11:29 +0900528 }
Inseob Kimc3b1a162020-02-18 12:42:54 +0900529 }
530
531 if !c.shared() { // static or header
Colin Crossd80cbca2020-02-24 12:01:37 -0800532 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Inseob Kimeec88e12020-01-22 11:11:29 +0900533 }
534 })
535}
536
Colin Crossd80cbca2020-02-24 12:01:37 -0800537func (c *vendorSnapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
538 entries.Class = "EXECUTABLES"
Inseob Kimeec88e12020-01-22 11:11:29 +0900539
540 if c.androidMkVendorSuffix {
Colin Crossd80cbca2020-02-24 12:01:37 -0800541 entries.SubName = vendorSuffix
Inseob Kimeec88e12020-01-22 11:11:29 +0900542 } else {
Colin Crossd80cbca2020-02-24 12:01:37 -0800543 entries.SubName = ""
Inseob Kimeec88e12020-01-22 11:11:29 +0900544 }
545
Colin Crossd80cbca2020-02-24 12:01:37 -0800546 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
547 entries.AddStrings("LOCAL_MODULE_SYMLINKS", c.Properties.Symlinks...)
Justin Yun71549282017-11-17 12:10:28 +0900548 })
Colin Cross7a6fcbe2017-12-06 13:08:00 -0800549}
Dan Albert8ba131b2017-12-14 13:23:15 -0800550
Inseob Kim1042d292020-06-01 23:23:05 +0900551func (c *vendorSnapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
552 entries.Class = "STATIC_LIBRARIES"
553
554 if c.androidMkVendorSuffix {
555 entries.SubName = vendorSuffix
556 } else {
557 entries.SubName = ""
558 }
559
560 entries.ExtraFooters = append(entries.ExtraFooters,
561 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
562 out := entries.OutputFile.Path()
563 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
564
565 fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
566 fmt.Fprintln(w, ".KATI_READONLY: "+varname)
567 })
568}
569
Colin Crossd80cbca2020-02-24 12:01:37 -0800570func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
571 entries.Class = "SHARED_LIBRARIES"
Dan Albert8ba131b2017-12-14 13:23:15 -0800572}
Jiyong Park374510b2018-03-19 18:23:01 +0900573
Colin Crossd80cbca2020-02-24 12:01:37 -0800574func (c *vendorPublicLibraryStubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
575 entries.Class = "SHARED_LIBRARIES"
576 entries.SubName = vendorPublicLibrarySuffix
Jiyong Park374510b2018-03-19 18:23:01 +0900577
Colin Crossd80cbca2020-02-24 12:01:37 -0800578 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
579 c.libraryDecorator.androidMkWriteExportedFlags(entries)
580 _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base())
Jiyong Park374510b2018-03-19 18:23:01 +0900581
Colin Crossd80cbca2020-02-24 12:01:37 -0800582 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
583 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
584 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
Jiyong Park374510b2018-03-19 18:23:01 +0900585 })
586}
Logan Chien4fcea3d2018-11-20 11:59:08 +0800587
Colin Crossd80cbca2020-02-24 12:01:37 -0800588func (p *prebuiltLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
589 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
Logan Chien4fcea3d2018-11-20 11:59:08 +0800590 if p.properties.Check_elf_files != nil {
Colin Crossd80cbca2020-02-24 12:01:37 -0800591 entries.SetBool("LOCAL_CHECK_ELF_FILES", *p.properties.Check_elf_files)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800592 } else {
593 // soong_cc_prebuilt.mk does not include check_elf_file.mk by default
594 // because cc_library_shared and cc_binary use soong_cc_prebuilt.mk as well.
595 // In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to
596 // true if `p.properties.Check_elf_files` is not specified.
Colin Crossd80cbca2020-02-24 12:01:37 -0800597 entries.SetBool("LOCAL_CHECK_ELF_FILES", true)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800598 }
599 })
600}
601
Colin Crossd80cbca2020-02-24 12:01:37 -0800602func (p *prebuiltLibraryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
603 ctx.subAndroidMk(entries, p.libraryDecorator)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800604 if p.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800605 ctx.subAndroidMk(entries, &p.prebuiltLinker)
606 androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800607 }
608}
609
Colin Crossd80cbca2020-02-24 12:01:37 -0800610func (p *prebuiltBinaryLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
611 ctx.subAndroidMk(entries, p.binaryDecorator)
612 ctx.subAndroidMk(entries, &p.prebuiltLinker)
613 androidMkWriteAllowUndefinedSymbols(p.baseLinker, entries)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800614}
615
Colin Crossd80cbca2020-02-24 12:01:37 -0800616func androidMkWriteAllowUndefinedSymbols(linker *baseLinker, entries *android.AndroidMkEntries) {
617 allow := linker.Properties.Allow_undefined_symbols
618 if allow != nil {
619 entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
620 entries.SetBool("LOCAL_ALLOW_UNDEFINED_SYMBOLS", *allow)
621 })
622 }
Logan Chien4fcea3d2018-11-20 11:59:08 +0800623}