blob: 920b58b2a5def756ee7406333459c9c07cd41890 [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 (
Matthew Maurera61e31f2021-05-27 11:09:11 -070027 NativeBridgeSuffix = ".native_bridge"
Matthew Maurer52af5b02021-05-27 10:01:36 -070028 ProductSuffix = ".product"
Ivan Lozanoe6d30982021-02-05 10:57:43 -050029 VendorSuffix = ".vendor"
Matthew Maurerc6868382021-07-13 14:12:37 -070030 RamdiskSuffix = ".ramdisk"
Ivan Lozanoe6d30982021-02-05 10:57:43 -050031 VendorRamdiskSuffix = ".vendor_ramdisk"
Matthew Maurer460ee942021-02-11 12:31:46 -080032 RecoverySuffix = ".recovery"
Yifan Hong60e0cfb2020-10-21 15:17:56 -070033 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
Yu Liu56400082024-10-15 20:45:35 +000039 subAndroidMk(android.Config, *android.AndroidMkInfo, 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
Kiyoung Kimaa394802024-01-08 12:55:45 +090050 InVendorOrProduct() bool
Yu Liu56400082024-10-15 20:45:35 +000051 ArchSpecific() bool
Colin Crossb916a382016-07-29 17:28:03 -070052}
53
Yu Liu56400082024-10-15 20:45:35 +000054type subAndroidMkProviderInfoProducer interface {
55 prepareAndroidMKProviderInfo(android.Config, AndroidMkContext, *android.AndroidMkInfo)
Colin Crossb916a382016-07-29 17:28:03 -070056}
57
Yu Liu56400082024-10-15 20:45:35 +000058type subAndroidMkFooterInfoProducer interface {
59 prepareAndroidMKFooterInfo(android.Config, AndroidMkContext, *android.AndroidMkInfo)
60}
61
62func (c *Module) subAndroidMk(config android.Config, entries *android.AndroidMkInfo, obj interface{}) {
Colin Crossb916a382016-07-29 17:28:03 -070063 if c.subAndroidMkOnce == nil {
Yu Liu56400082024-10-15 20:45:35 +000064 c.subAndroidMkOnce = make(map[subAndroidMkProviderInfoProducer]bool)
Colin Crossb916a382016-07-29 17:28:03 -070065 }
Yu Liu56400082024-10-15 20:45:35 +000066 if androidmk, ok := obj.(subAndroidMkProviderInfoProducer); ok {
Colin Crossb916a382016-07-29 17:28:03 -070067 if !c.subAndroidMkOnce[androidmk] {
68 c.subAndroidMkOnce[androidmk] = true
Yu Liu56400082024-10-15 20:45:35 +000069 androidmk.prepareAndroidMKProviderInfo(config, c, entries)
Colin Crossb916a382016-07-29 17:28:03 -070070 }
71 }
Dan Willemsenf2c27d72016-07-13 16:50:22 -070072}
73
Yu Liu56400082024-10-15 20:45:35 +000074var _ android.AndroidMkProviderInfoProducer = (*Module)(nil)
75
76func (c *Module) PrepareAndroidMKProviderInfo(config android.Config) *android.AndroidMkProviderInfo {
Colin Cross56a83212020-09-15 18:30:11 -070077 if c.hideApexVariantFromMake || c.Properties.HideFromMake {
Yu Liu56400082024-10-15 20:45:35 +000078 return &android.AndroidMkProviderInfo{
79 PrimaryInfo: android.AndroidMkInfo{
80 Disabled: true,
81 },
82 }
Colin Crossbc6fb162016-05-24 15:39:04 -070083 }
84
Yu Liu56400082024-10-15 20:45:35 +000085 providerData := android.AndroidMkProviderInfo{
86 PrimaryInfo: android.AndroidMkInfo{
87 OutputFile: c.outputFile,
88 Required: c.Properties.AndroidMkRuntimeLibs,
89 OverrideName: c.BaseModuleName(),
90 Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
91 EntryMap: make(map[string][]string),
Colin Crossa18e9cf2017-08-10 17:00:19 -070092 },
93 }
Colin Crossca860ac2016-01-04 14:34:37 -080094
Yu Liu56400082024-10-15 20:45:35 +000095 entries := &providerData.PrimaryInfo
96 if len(c.Properties.Logtags) > 0 {
97 entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", c.logtagsPaths.Strings()...)
98 }
99 // Note: Pass the exact value of AndroidMkSystemSharedLibs to the Make
100 // world, even if it is an empty list. In the Make world,
101 // LOCAL_SYSTEM_SHARED_LIBRARIES defaults to "none", which is expanded
102 // to the default list of system shared libs by the build system.
103 // Soong computes the exact list of system shared libs, so we have to
104 // override the default value when the list of libs is actually empty.
105 entries.SetString("LOCAL_SYSTEM_SHARED_LIBRARIES", strings.Join(c.Properties.AndroidMkSystemSharedLibs, " "))
106 if len(c.Properties.AndroidMkSharedLibs) > 0 {
107 entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...)
108 }
109 if len(c.Properties.AndroidMkRuntimeLibs) > 0 {
110 entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
111 }
112 entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType)
113 if c.InVendor() {
114 entries.SetBool("LOCAL_IN_VENDOR", true)
115 } else if c.InProduct() {
116 entries.SetBool("LOCAL_IN_PRODUCT", true)
117 }
118 if c.Properties.SdkAndPlatformVariantVisibleToMake {
119 // Add the unsuffixed name to SOONG_SDK_VARIANT_MODULES so that Make can rewrite
120 // dependencies to the .sdk suffix when building a module that uses the SDK.
121 entries.SetString("SOONG_SDK_VARIANT_MODULES",
122 "$(SOONG_SDK_VARIANT_MODULES) $(patsubst %.sdk,%,$(LOCAL_MODULE))")
123 }
124 entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", c.IsSkipInstall())
125
Colin Crossca860ac2016-01-04 14:34:37 -0800126 for _, feature := range c.features {
Yu Liu56400082024-10-15 20:45:35 +0000127 c.subAndroidMk(config, entries, feature)
Colin Crossca860ac2016-01-04 14:34:37 -0800128 }
129
Yu Liu56400082024-10-15 20:45:35 +0000130 c.subAndroidMk(config, entries, c.compiler)
131 c.subAndroidMk(config, entries, c.linker)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700132 if c.sanitize != nil {
Yu Liu56400082024-10-15 20:45:35 +0000133 c.subAndroidMk(config, entries, c.sanitize)
Colin Cross8ff9ef42017-05-08 13:44:11 -0700134 }
Yu Liu56400082024-10-15 20:45:35 +0000135 c.subAndroidMk(config, entries, c.installer)
Colin Crossca860ac2016-01-04 14:34:37 -0800136
Colin Crossd80cbca2020-02-24 12:01:37 -0800137 entries.SubName += c.Properties.SubName
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700138
Yu Liu56400082024-10-15 20:45:35 +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 entries.FooterStrings = []string{
145 fmt.Sprintf("%s %s %s", "$(eval $(call copy-one-file,",
146 "$(LOCAL_BUILT_MODULE),",
147 "$(patsubst %.sdk.so,%.so,$(LOCAL_BUILT_MODULE))))")}
148 }
149
150 for _, obj := range []interface{}{c.compiler, c.linker, c.sanitize, c.installer} {
151 if obj == nil {
152 continue
153 }
154 if p, ok := obj.(subAndroidMkFooterInfoProducer); ok {
155 p.prepareAndroidMKFooterInfo(config, c, entries)
156 }
157 }
158
159 return &providerData
Colin Crossca860ac2016-01-04 14:34:37 -0800160}
161
Yu Liu56400082024-10-15 20:45:35 +0000162func androidMkWriteExtraTestConfigs(extraTestConfigs android.Paths, entries *android.AndroidMkInfo) {
Dan Shi95d19422020-08-15 12:24:26 -0700163 if len(extraTestConfigs) > 0 {
Yu Liu56400082024-10-15 20:45:35 +0000164 entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", extraTestConfigs.Strings()...)
Dan Shi95d19422020-08-15 12:24:26 -0700165 }
166}
167
dimitrydb417472019-05-20 16:16:47 +0200168func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string {
169 if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
170 var result []string
171 for _, override := range overrides {
Matthew Maurera61e31f2021-05-27 11:09:11 -0700172 result = append(result, override+NativeBridgeSuffix)
dimitrydb417472019-05-20 16:16:47 +0200173 }
174 return result
175 }
176
177 return overrides
178}
179
Yu Liu56400082024-10-15 20:45:35 +0000180func (library *libraryDecorator) androidMkWriteExportedFlags(entries *android.AndroidMkInfo) {
Liz Kammerb6a55bf2021-04-12 15:42:51 -0400181 var exportedFlags []string
182 var includeDirs android.Paths
183 var systemIncludeDirs android.Paths
184 var exportedDeps android.Paths
185
186 if library.flagExporterInfo != nil {
187 exportedFlags = library.flagExporterInfo.Flags
188 includeDirs = library.flagExporterInfo.IncludeDirs
189 systemIncludeDirs = library.flagExporterInfo.SystemIncludeDirs
190 exportedDeps = library.flagExporterInfo.Deps
191 } else {
192 exportedFlags = library.flagExporter.flags
193 includeDirs = library.flagExporter.dirs
194 systemIncludeDirs = library.flagExporter.systemDirs
195 exportedDeps = library.flagExporter.deps
196 }
197 for _, dir := range includeDirs {
Jiyong Park74955042019-10-22 20:19:51 +0900198 exportedFlags = append(exportedFlags, "-I"+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900199 }
Liz Kammerb6a55bf2021-04-12 15:42:51 -0400200 for _, dir := range systemIncludeDirs {
Jiyong Park74955042019-10-22 20:19:51 +0900201 exportedFlags = append(exportedFlags, "-isystem "+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +0900202 }
Dan Willemsen58539402017-03-19 13:44:32 -0700203 if len(exportedFlags) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800204 entries.AddStrings("LOCAL_EXPORT_CFLAGS", exportedFlags...)
Dan Willemsend5781342017-02-15 16:15:21 -0800205 }
Inseob Kim69378442019-06-03 19:10:47 +0900206 if len(exportedDeps) > 0 {
Colin Crossd80cbca2020-02-24 12:01:37 -0800207 entries.AddStrings("LOCAL_EXPORT_C_INCLUDE_DEPS", exportedDeps.Strings()...)
Dan Willemsen58539402017-03-19 13:44:32 -0700208 }
209}
Dan Willemsend5781342017-02-15 16:15:21 -0800210
Yu Liu56400082024-10-15 20:45:35 +0000211func (library *libraryDecorator) androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries *android.AndroidMkInfo) {
Hsin-Yi Chena6ddb142022-10-27 14:55:42 +0800212 if !library.static() {
213 entries.AddPaths("LOCAL_ADDITIONAL_DEPENDENCIES", library.sAbiDiff)
214 }
Logan Chien41eabe62019-04-10 13:33:58 +0800215}
216
Colin Crossd80cbca2020-02-24 12:01:37 -0800217// TODO(ccross): remove this once apex/androidmk.go is converted to AndroidMkEntries
218func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
Hsin-Yi Chena6ddb142022-10-27 14:55:42 +0800219 if !library.static() {
220 fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", strings.Join(library.sAbiDiff.Strings(), " "))
221 }
Colin Crossd80cbca2020-02-24 12:01:37 -0800222}
223
Yu Liu56400082024-10-15 20:45:35 +0000224func (library *libraryDecorator) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
Dan Willemsend5781342017-02-15 16:15:21 -0800225 if library.static() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800226 entries.Class = "STATIC_LIBRARIES"
Dan Willemsend5781342017-02-15 16:15:21 -0800227 } else if library.shared() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800228 entries.Class = "SHARED_LIBRARIES"
Yu Liu56400082024-10-15 20:45:35 +0000229 entries.SetString("LOCAL_SOONG_TOC", library.toc().String())
230 if !library.buildStubs() && library.unstrippedOutputFile != nil {
231 entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", library.unstrippedOutputFile.String())
232 }
233 if len(library.Properties.Overrides) > 0 {
234 entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " "))
235 }
236 if len(library.postInstallCmds) > 0 {
237 entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(library.postInstallCmds, "&& "))
238 }
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
Yu Liu56400082024-10-15 20:45:35 +0000247 library.androidMkWriteExportedFlags(entries)
248 library.androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries)
Dan Willemsen218f6562015-07-08 18:13:11 -0700249
Yu Liu56400082024-10-15 20:45:35 +0000250 if entries.OutputFile.Valid() {
251 _, _, ext := android.SplitFileExt(entries.OutputFile.Path().Base())
252 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
253 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700254
Yu Liu56400082024-10-15 20:45:35 +0000255 if library.coverageOutputFile.Valid() {
256 entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", library.coverageOutputFile.String())
257 }
Colin Crossb916a382016-07-29 17:28:03 -0700258
Jiyong Parkb0788572018-12-20 22:10:17 +0900259 if library.shared() && !library.buildStubs() {
Yu Liu56400082024-10-15 20:45:35 +0000260 ctx.subAndroidMk(config, entries, library.baseInstaller)
Colin Crossb60190a2018-09-04 16:28:17 -0700261 } else {
Colin Cross127bb8b2020-12-16 16:46:01 -0800262 if library.buildStubs() && library.stubsVersion() != "" {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900263 entries.SubName = "." + library.stubsVersion()
264 }
Yu Liu56400082024-10-15 20:45:35 +0000265 // library.makeUninstallable() depends on this to bypass HideFromMake() for
266 // static libraries.
267 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
268 if library.buildStubs() {
269 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
270 }
Colin Crossb916a382016-07-29 17:28:03 -0700271 }
Jiyong Parkf7c3bbe2020-12-09 21:18:56 +0900272 // If a library providing a stub is included in an APEX, the private APIs of the library
273 // is accessible only inside the APEX. From outside of the APEX, clients can only use the
274 // public APIs via the stub. To enforce this, the (latest version of the) stub gets the
275 // name of the library. The impl library instead gets the `.bootstrap` suffix to so that
276 // they can be exceptionally used directly when APEXes are not available (e.g. during the
277 // very early stage in the boot process).
278 if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.NotInPlatform() &&
Kiyoung Kimaa394802024-01-08 12:55:45 +0900279 !ctx.InRamdisk() && !ctx.InVendorRamdisk() && !ctx.InRecovery() && !ctx.InVendorOrProduct() && !ctx.static() {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900280 if library.buildStubs() && library.isLatestStubVersion() {
Jooyung Hanad4c1872020-02-27 17:56:44 +0900281 entries.SubName = ""
282 }
Jiyong Parkb0788572018-12-20 22:10:17 +0900283 if !library.buildStubs() {
Colin Crossd80cbca2020-02-24 12:01:37 -0800284 entries.SubName = ".bootstrap"
Jiyong Parkb0788572018-12-20 22:10:17 +0900285 }
286 }
Dan Willemsen218f6562015-07-08 18:13:11 -0700287}
288
Yu Liu56400082024-10-15 20:45:35 +0000289func (object *objectLinker) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800290 entries.Class = "STATIC_LIBRARIES"
Dan Willemsen218f6562015-07-08 18:13:11 -0700291}
292
Yu Liu56400082024-10-15 20:45:35 +0000293func (object *objectLinker) prepareAndroidMKFooterInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
294 out := entries.OutputFile.Path()
295 name := ctx.BaseModuleName()
296 if entries.OverrideName != "" {
297 name = entries.OverrideName
298 }
299
300 prefix := ""
301 if ctx.ArchSpecific() {
302 switch ctx.Os().Class {
303 case android.Host:
304 if ctx.Target().HostCross {
305 prefix = "HOST_CROSS_"
306 } else {
307 prefix = "HOST_"
308 }
309 case android.Device:
310 prefix = "TARGET_"
311
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000312 }
Yu Liu56400082024-10-15 20:45:35 +0000313
314 if ctx.Arch().ArchType != config.Targets[ctx.Os()][0].Arch.ArchType {
315 prefix = "2ND_" + prefix
316 }
317 }
318
319 varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)
320
321 entries.FooterStrings = append(entries.FooterStrings,
322 fmt.Sprintf("\n%s := %s\n.KATI_READONLY: %s", varname, out.String(), varname))
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000323}
324
Yu Liu56400082024-10-15 20:45:35 +0000325func (test *testDecorator) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
326 if len(test.InstallerProperties.Test_suites) > 0 {
327 entries.AddCompatibilityTestSuites(test.InstallerProperties.Test_suites...)
328 }
329}
330
331func (binary *binaryDecorator) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
332 ctx.subAndroidMk(config, entries, binary.baseInstaller)
Dan Willemsen7517ed02016-06-10 17:20:30 -0700333
Colin Crossd80cbca2020-02-24 12:01:37 -0800334 entries.Class = "EXECUTABLES"
Jingwen Chen40fd90a2020-06-15 05:24:19 +0000335 entries.DistFiles = binary.distFiles
Yu Liu56400082024-10-15 20:45:35 +0000336 entries.SetString("LOCAL_SOONG_UNSTRIPPED_BINARY", binary.unstrippedOutputFile.String())
337 if len(binary.symlinks) > 0 {
338 entries.AddStrings("LOCAL_MODULE_SYMLINKS", binary.symlinks...)
339 }
Colin Cross9b09f242016-12-07 13:37:42 -0800340
Yu Liu56400082024-10-15 20:45:35 +0000341 if binary.coverageOutputFile.Valid() {
342 entries.SetString("LOCAL_PREBUILT_COVERAGE_ARCHIVE", binary.coverageOutputFile.String())
343 }
Yifan Hong946e32e2018-04-03 13:22:50 -0700344
Yu Liu56400082024-10-15 20:45:35 +0000345 if len(binary.Properties.Overrides) > 0 {
346 entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " "))
347 }
348 if len(binary.postInstallCmds) > 0 {
349 entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(binary.postInstallCmds, "&& "))
350 }
Colin Crossca860ac2016-01-04 14:34:37 -0800351}
352
Yu Liu56400082024-10-15 20:45:35 +0000353func (benchmark *benchmarkDecorator) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
354 ctx.subAndroidMk(config, entries, benchmark.binaryDecorator)
Colin Crossd80cbca2020-02-24 12:01:37 -0800355 entries.Class = "NATIVE_TESTS"
Yu Liu56400082024-10-15 20:45:35 +0000356 if len(benchmark.Properties.Test_suites) > 0 {
357 entries.AddCompatibilityTestSuites(benchmark.Properties.Test_suites...)
358 }
359 if benchmark.testConfig != nil {
360 entries.SetString("LOCAL_FULL_TEST_CONFIG", benchmark.testConfig.String())
361 }
362 entries.SetBool("LOCAL_NATIVE_BENCHMARK", true)
363 if !BoolDefault(benchmark.Properties.Auto_gen_config, true) {
364 entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
365 }
Colin Crossb916a382016-07-29 17:28:03 -0700366}
367
Yu Liu56400082024-10-15 20:45:35 +0000368func (test *testBinary) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
369 ctx.subAndroidMk(config, entries, test.binaryDecorator)
370 ctx.subAndroidMk(config, entries, test.testDecorator)
Trevor Radcliffef389cb42022-03-24 21:06:14 +0000371
Colin Crossd80cbca2020-02-24 12:01:37 -0800372 entries.Class = "NATIVE_TESTS"
Yu Liu56400082024-10-15 20:45:35 +0000373 if test.testConfig != nil {
374 entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String())
375 }
376 if !BoolDefault(test.Properties.Auto_gen_config, true) {
377 entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true)
378 }
379 entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...)
Colin Crosscfb0f5e2021-09-24 15:47:17 -0700380
Yu Liu56400082024-10-15 20:45:35 +0000381 entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(test.Properties.Per_testcase_directory))
382 if len(test.Properties.Data_bins) > 0 {
383 entries.AddStrings("LOCAL_TEST_DATA_BINS", test.Properties.Data_bins...)
384 }
Zhenhuang Wang0ac5a432022-08-12 18:49:20 +0800385
Yu Liu56400082024-10-15 20:45:35 +0000386 test.Properties.Test_options.CommonTestOptions.SetAndroidMkInfoEntries(entries)
Colin Crossa929db02017-03-27 16:27:50 -0700387
Dan Shi95d19422020-08-15 12:24:26 -0700388 androidMkWriteExtraTestConfigs(test.extraTestConfigs, entries)
Colin Crossa2344662016-03-24 13:14:12 -0700389}
390
Yu Liu56400082024-10-15 20:45:35 +0000391func (fuzz *fuzzBinary) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
392 ctx.subAndroidMk(config, entries, fuzz.binaryDecorator)
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700393
Yu Liu56400082024-10-15 20:45:35 +0000394 entries.SetBool("LOCAL_IS_FUZZ_TARGET", true)
395 if fuzz.installedSharedDeps != nil {
396 // TOOD: move to install dep
397 entries.AddStrings("LOCAL_FUZZ_INSTALLED_SHARED_DEPS", fuzz.installedSharedDeps...)
398 }
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -0700399}
400
Yu Liu56400082024-10-15 20:45:35 +0000401func (test *testLibrary) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
402 ctx.subAndroidMk(config, entries, test.libraryDecorator)
403 ctx.subAndroidMk(config, entries, test.testDecorator)
Colin Crossb916a382016-07-29 17:28:03 -0700404}
Dan Willemsene7932e82016-05-16 15:56:53 -0700405
Yu Liu56400082024-10-15 20:45:35 +0000406func (installer *baseInstaller) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
Colin Crossc511bc52020-04-07 16:50:32 +0000407 if installer.path == (android.InstallPath{}) {
408 return
409 }
Dan Willemsen03ce63e2016-09-29 12:17:49 -0700410
Yu Liu56400082024-10-15 20:45:35 +0000411 path, file := filepath.Split(installer.path.String())
412 stem, suffix, _ := android.SplitFileExt(file)
413 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
414 entries.SetString("LOCAL_MODULE_PATH", path)
415 entries.SetString("LOCAL_MODULE_STEM", stem)
Dan Willemsen218f6562015-07-08 18:13:11 -0700416}
Dan Albert914449f2016-06-17 16:45:24 -0700417
Yu Liu56400082024-10-15 20:45:35 +0000418func (c *stubDecorator) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
Dan Albert1a246272020-07-06 14:49:35 -0700419 entries.SubName = ndkLibrarySuffix + "." + c.apiLevel.String()
Colin Crossd80cbca2020-02-24 12:01:37 -0800420 entries.Class = "SHARED_LIBRARIES"
Dan Albert914449f2016-06-17 16:45:24 -0700421
Colin Cross5ec407b2020-09-30 11:41:33 -0700422 if !c.buildStubs() {
423 entries.Disabled = true
424 return
425 }
426
Yu Liu56400082024-10-15 20:45:35 +0000427 path, file := filepath.Split(c.installPath.String())
428 stem, suffix, _ := android.SplitFileExt(file)
429 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
430 entries.SetString("LOCAL_MODULE_PATH", path)
431 entries.SetString("LOCAL_MODULE_STEM", stem)
432 entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
433 if c.parsedCoverageXmlPath.String() != "" {
434 entries.SetString("SOONG_NDK_API_XML", "$(SOONG_NDK_API_XML) "+c.parsedCoverageXmlPath.String())
435 }
436 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true) // Stubs should not be installed
Dan Albert914449f2016-06-17 16:45:24 -0700437}
Dan Willemsenb916b802017-03-19 13:44:32 -0700438
Yu Liu56400082024-10-15 20:45:35 +0000439func (c *vndkPrebuiltLibraryDecorator) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800440 entries.Class = "SHARED_LIBRARIES"
Justin Yun71549282017-11-17 12:10:28 +0900441
Colin Crossd80cbca2020-02-24 12:01:37 -0800442 entries.SubName = c.androidMkSuffix
Justin Yun71549282017-11-17 12:10:28 +0900443
Yu Liu56400082024-10-15 20:45:35 +0000444 c.libraryDecorator.androidMkWriteExportedFlags(entries)
Justin Yun71549282017-11-17 12:10:28 +0900445
Yu Liu56400082024-10-15 20:45:35 +0000446 // Specifying stem is to pass check_elf_files when vendor modules link against vndk prebuilt.
447 // We can't use install path because VNDKs are not installed. Instead, Srcs is directly used.
448 _, file := filepath.Split(c.properties.Srcs[0])
449 stem, suffix, ext := android.SplitFileExt(file)
450 entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext)
451 entries.SetString("LOCAL_MODULE_SUFFIX", suffix)
452 entries.SetString("LOCAL_MODULE_STEM", stem)
Inseob Kim81235ff2020-10-23 14:36:11 +0900453
Yu Liu56400082024-10-15 20:45:35 +0000454 if c.tocFile.Valid() {
455 entries.SetString("LOCAL_SOONG_TOC", c.tocFile.String())
456 }
Inseob Kim81235ff2020-10-23 14:36:11 +0900457
Yu Liu56400082024-10-15 20:45:35 +0000458 // VNDK libraries available to vendor are not installed because
459 // they are packaged in VNDK APEX and installed by APEX packages (apex/apex.go)
460 entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
Inseob Kimeec88e12020-01-22 11:11:29 +0900461}
462
Yu Liu56400082024-10-15 20:45:35 +0000463func (p *prebuiltLinker) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
464 if p.properties.Check_elf_files != nil {
465 entries.SetBool("LOCAL_CHECK_ELF_FILES", *p.properties.Check_elf_files)
466 } else {
467 // soong_cc_rust_prebuilt.mk does not include check_elf_file.mk by default
468 // because cc_library_shared and cc_binary use soong_cc_rust_prebuilt.mk as well.
469 // In order to turn on prebuilt ABI checker, set `LOCAL_CHECK_ELF_FILES` to
470 // true if `p.properties.Check_elf_files` is not specified.
471 entries.SetBool("LOCAL_CHECK_ELF_FILES", true)
472 }
Logan Chien4fcea3d2018-11-20 11:59:08 +0800473}
474
Yu Liu56400082024-10-15 20:45:35 +0000475func (p *prebuiltLibraryLinker) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
476 ctx.subAndroidMk(config, entries, p.libraryDecorator)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800477 if p.shared() {
Yu Liu56400082024-10-15 20:45:35 +0000478 ctx.subAndroidMk(config, entries, &p.prebuiltLinker)
Steven Morelanddabe2d42024-06-04 01:22:40 +0000479 androidMkWritePrebuiltOptions(p.baseLinker, entries)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800480 }
481}
482
Yu Liu56400082024-10-15 20:45:35 +0000483func (p *prebuiltBinaryLinker) prepareAndroidMKProviderInfo(config android.Config, ctx AndroidMkContext, entries *android.AndroidMkInfo) {
484 ctx.subAndroidMk(config, entries, p.binaryDecorator)
485 ctx.subAndroidMk(config, entries, &p.prebuiltLinker)
Steven Morelanddabe2d42024-06-04 01:22:40 +0000486 androidMkWritePrebuiltOptions(p.baseLinker, entries)
Logan Chien4fcea3d2018-11-20 11:59:08 +0800487}
488
Yu Liu56400082024-10-15 20:45:35 +0000489func androidMkWritePrebuiltOptions(linker *baseLinker, entries *android.AndroidMkInfo) {
Colin Crossd80cbca2020-02-24 12:01:37 -0800490 allow := linker.Properties.Allow_undefined_symbols
491 if allow != nil {
Yu Liu56400082024-10-15 20:45:35 +0000492 entries.SetBool("LOCAL_ALLOW_UNDEFINED_SYMBOLS", *allow)
Colin Crossd80cbca2020-02-24 12:01:37 -0800493 }
Steven Morelanddabe2d42024-06-04 01:22:40 +0000494 ignore := linker.Properties.Ignore_max_page_size
495 if ignore != nil {
Yu Liu56400082024-10-15 20:45:35 +0000496 entries.SetBool("LOCAL_IGNORE_MAX_PAGE_SIZE", *ignore)
Steven Morelanddabe2d42024-06-04 01:22:40 +0000497 }
Logan Chien4fcea3d2018-11-20 11:59:08 +0800498}