blob: 8b3c7720297fc727f20cdb60819c1173c977f968 [file] [log] [blame]
Colin Cross5049f022015-03-18 13:28:46 -07001// Copyright 2015 Google Inc. All rights reserved.
Colin Cross3f40fa42015-01-30 17:27:36 -08002//
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
17// This file contains the module types for compiling C/C++ for Android, and converts the properties
18// into the flags and filenames necessary to pass to the compiler. The final creation of the rules
19// is handled in builder.go
20
21import (
Colin Cross41955e82019-05-29 14:40:35 -070022 "fmt"
Logan Chien41eabe62019-04-10 13:33:58 +080023 "io"
Dan Albert9e10cd42016-08-03 14:12:14 -070024 "strconv"
Colin Cross3f40fa42015-01-30 17:27:36 -080025 "strings"
26
Colin Cross97ba0732015-03-23 17:50:24 -070027 "github.com/google/blueprint"
Colin Cross06a931b2015-10-28 17:23:31 -070028 "github.com/google/blueprint/proptools"
Colin Cross97ba0732015-03-23 17:50:24 -070029
Colin Cross635c3b02016-05-18 15:37:25 -070030 "android/soong/android"
Colin Crossb98c8b02016-07-29 13:44:28 -070031 "android/soong/cc/config"
Colin Cross5049f022015-03-18 13:28:46 -070032 "android/soong/genrule"
Colin Cross3f40fa42015-01-30 17:27:36 -080033)
34
Colin Cross463a90e2015-06-17 14:20:06 -070035func init() {
Paul Duffin036e7002019-12-19 19:16:28 +000036 RegisterCCBuildComponents(android.InitRegistrationContext)
Colin Cross463a90e2015-06-17 14:20:06 -070037
Paul Duffin036e7002019-12-19 19:16:28 +000038 pctx.Import("android/soong/cc/config")
39}
40
41func RegisterCCBuildComponents(ctx android.RegistrationContext) {
42 ctx.RegisterModuleType("cc_defaults", defaultsFactory)
43
44 ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
Inseob Kim64c43952019-08-26 16:52:35 +090045 ctx.BottomUp("vndk", VndkMutator).Parallel()
Colin Crosse40b4ea2018-10-02 22:25:58 -070046 ctx.BottomUp("link", LinkageMutator).Parallel()
Jooyung Hanb90e4912019-12-09 18:21:48 +090047 ctx.BottomUp("ndk_api", NdkApiMutator).Parallel()
Roland Levillain9b5fde92019-06-28 15:41:19 +010048 ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
Jiyong Park25fc6a92018-11-18 18:02:45 +090049 ctx.BottomUp("version", VersionMutator).Parallel()
Colin Crosse40b4ea2018-10-02 22:25:58 -070050 ctx.BottomUp("begin", BeginMutator).Parallel()
Inseob Kimac1e9862019-12-09 18:15:47 +090051 ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
Inseob Kimeec88e12020-01-22 11:11:29 +090052 ctx.BottomUp("vendor_snapshot", VendorSnapshotMutator).Parallel()
53 ctx.BottomUp("vendor_snapshot_source", VendorSnapshotSourceMutator).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070054 })
Colin Cross16b23492016-01-06 14:41:07 -080055
Paul Duffin036e7002019-12-19 19:16:28 +000056 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
Colin Cross1e676be2016-10-12 14:38:15 -070057 ctx.TopDown("asan_deps", sanitizerDepsMutator(asan))
58 ctx.BottomUp("asan", sanitizerMutator(asan)).Parallel()
Colin Cross16b23492016-01-06 14:41:07 -080059
Evgenii Stepanovd97a6e92018-08-02 16:19:13 -070060 ctx.TopDown("hwasan_deps", sanitizerDepsMutator(hwasan))
61 ctx.BottomUp("hwasan", sanitizerMutator(hwasan)).Parallel()
62
Mitch Phillipsbfeade62019-05-01 14:42:05 -070063 ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(fuzzer))
64 ctx.BottomUp("fuzzer", sanitizerMutator(fuzzer)).Parallel()
65
Jiyong Park1d1119f2019-07-29 21:27:18 +090066 // cfi mutator shouldn't run before sanitizers that return true for
67 // incompatibleWithCfi()
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000068 ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi))
69 ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel()
70
Peter Collingbourne8c7e6e22018-11-19 16:03:58 -080071 ctx.TopDown("scs_deps", sanitizerDepsMutator(scs))
72 ctx.BottomUp("scs", sanitizerMutator(scs)).Parallel()
73
Colin Cross1e676be2016-10-12 14:38:15 -070074 ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
75 ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()
Dan Willemsen581341d2017-02-09 16:16:31 -080076
Colin Cross0b908332019-06-19 23:00:20 -070077 ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
Jiyong Park379de2f2018-12-19 02:47:14 +090078 ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
Ivan Lozano30c5db22018-02-21 15:49:20 -080079
Pirama Arumuga Nainar1acd4472018-12-10 15:12:40 -080080 ctx.BottomUp("coverage", coverageMutator).Parallel()
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -080081 ctx.TopDown("vndk_deps", sabiDepsMutator)
Stephen Craneba090d12017-05-09 15:44:35 -070082
83 ctx.TopDown("lto_deps", ltoDepsMutator)
84 ctx.BottomUp("lto", ltoMutator).Parallel()
Jooyung Hana70f0672019-01-18 15:20:43 +090085
86 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070087 })
Colin Crossb98c8b02016-07-29 13:44:28 -070088
Sasha Smundak2a4549e2018-11-05 16:49:08 -080089 android.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory)
Colin Cross463a90e2015-06-17 14:20:06 -070090}
91
Colin Crossca860ac2016-01-04 14:34:37 -080092type Deps struct {
93 SharedLibs, LateSharedLibs []string
94 StaticLibs, LateStaticLibs, WholeStaticLibs []string
Colin Cross5950f382016-12-13 12:50:57 -080095 HeaderLibs []string
Logan Chien43d34c32017-12-20 01:17:32 +080096 RuntimeLibs []string
Colin Crossc472d572015-03-17 15:06:21 -070097
Peter Collingbournedc4f9862020-02-12 17:13:25 -080098 StaticUnwinderIfLegacy bool
99
Colin Cross5950f382016-12-13 12:50:57 -0800100 ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700101
Colin Cross81413472016-04-11 14:37:39 -0700102 ObjFiles []string
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700103
Dan Willemsenb40aab62016-04-20 14:21:14 -0700104 GeneratedSources []string
105 GeneratedHeaders []string
Inseob Kimd110f872019-12-06 13:15:38 +0900106 GeneratedDeps []string
Dan Willemsenb40aab62016-04-20 14:21:14 -0700107
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700108 ReexportGeneratedHeaders []string
109
Colin Cross97ba0732015-03-23 17:50:24 -0700110 CrtBegin, CrtEnd string
Dan Willemsena0790e32018-10-12 00:24:23 -0700111
112 // Used for host bionic
113 LinkerFlagsFile string
114 DynamicLinker string
Colin Crossc472d572015-03-17 15:06:21 -0700115}
116
Colin Crossca860ac2016-01-04 14:34:37 -0800117type PathDeps struct {
Colin Cross26c34ed2016-09-30 17:10:16 -0700118 // Paths to .so files
Jiyong Park64a44f22019-01-18 14:37:08 +0900119 SharedLibs, EarlySharedLibs, LateSharedLibs android.Paths
Colin Cross26c34ed2016-09-30 17:10:16 -0700120 // Paths to the dependencies to use for .so files (.so.toc files)
Jiyong Park64a44f22019-01-18 14:37:08 +0900121 SharedLibsDeps, EarlySharedLibsDeps, LateSharedLibsDeps android.Paths
Colin Cross26c34ed2016-09-30 17:10:16 -0700122 // Paths to .a files
Colin Cross635c3b02016-05-18 15:37:25 -0700123 StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700124
Colin Cross26c34ed2016-09-30 17:10:16 -0700125 // Paths to .o files
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700126 Objs Objects
Dan Willemsen581341d2017-02-09 16:16:31 -0800127 StaticLibObjs Objects
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700128 WholeStaticLibObjs Objects
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700129
Colin Cross26c34ed2016-09-30 17:10:16 -0700130 // Paths to generated source files
Colin Cross635c3b02016-05-18 15:37:25 -0700131 GeneratedSources android.Paths
132 GeneratedHeaders android.Paths
Inseob Kimd110f872019-12-06 13:15:38 +0900133 GeneratedDeps android.Paths
Dan Willemsenb40aab62016-04-20 14:21:14 -0700134
Inseob Kimd110f872019-12-06 13:15:38 +0900135 Flags []string
136 IncludeDirs android.Paths
137 SystemIncludeDirs android.Paths
138 ReexportedDirs android.Paths
139 ReexportedSystemDirs android.Paths
140 ReexportedFlags []string
141 ReexportedGeneratedHeaders android.Paths
142 ReexportedDeps android.Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700143
Colin Cross26c34ed2016-09-30 17:10:16 -0700144 // Paths to crt*.o files
Colin Cross635c3b02016-05-18 15:37:25 -0700145 CrtBegin, CrtEnd android.OptionalPath
Dan Willemsena0790e32018-10-12 00:24:23 -0700146
147 // Path to the file container flags to use with the linker
148 LinkerFlagsFile android.OptionalPath
149
150 // Path to the dynamic linker binary
151 DynamicLinker android.OptionalPath
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700152}
153
Colin Cross4af21ed2019-11-04 09:37:55 -0800154// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module
155// tracked separately, in order to maintain the required ordering (most of the global flags need to go first on the
156// command line so they can be overridden by the local module flags).
157type LocalOrGlobalFlags struct {
158 CommonFlags []string // Flags that apply to C, C++, and assembly source files
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700159 AsFlags []string // Flags that apply to assembly source files
Colin Cross4af21ed2019-11-04 09:37:55 -0800160 YasmFlags []string // Flags that apply to yasm assembly source files
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700161 CFlags []string // Flags that apply to C and C++ source files
162 ToolingCFlags []string // Flags that apply to C and C++ source files parsed by clang LibTooling tools
163 ConlyFlags []string // Flags that apply to C source files
164 CppFlags []string // Flags that apply to C++ source files
165 ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700166 LdFlags []string // Flags that apply to linker command lines
Colin Cross4af21ed2019-11-04 09:37:55 -0800167}
168
169type Flags struct {
170 Local LocalOrGlobalFlags
171 Global LocalOrGlobalFlags
172
173 aidlFlags []string // Flags that apply to aidl source files
174 rsFlags []string // Flags that apply to renderscript source files
175 libFlags []string // Flags to add libraries early to the link order
176 extraLibFlags []string // Flags to add libraries late in the link order after LdFlags
177 TidyFlags []string // Flags that apply to clang-tidy
178 SAbiFlags []string // Flags that apply to header-abi-dumper
Colin Cross28344522015-04-22 13:07:53 -0700179
Colin Crossc3199482017-03-30 15:03:04 -0700180 // Global include flags that apply to C, C++, and assembly source files
Colin Cross4af21ed2019-11-04 09:37:55 -0800181 // These must be after any module include flags, which will be in CommonFlags.
Colin Crossc3199482017-03-30 15:03:04 -0700182 SystemIncludeFlags []string
183
Colin Crossb98c8b02016-07-29 13:44:28 -0700184 Toolchain config.Toolchain
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700185 Tidy bool
Dan Willemsen581341d2017-02-09 16:16:31 -0800186 Coverage bool
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800187 SAbiDump bool
Sasha Smundak2a4549e2018-11-05 16:49:08 -0800188 EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
Colin Crossca860ac2016-01-04 14:34:37 -0800189
190 RequiredInstructionSet string
Colin Cross16b23492016-01-06 14:41:07 -0800191 DynamicLinker string
192
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700193 CFlagsDeps android.Paths // Files depended on by compiler flags
194 LdFlagsDeps android.Paths // Files depended on by linker flags
Colin Cross18c0c5a2016-12-01 14:45:23 -0800195
Dan Willemsen98ab3112019-08-27 21:20:40 -0700196 AssemblerWithCpp bool
197 GroupStaticLibs bool
Dan Willemsen60e62f02018-11-16 21:05:32 -0800198
Colin Cross19878da2019-03-28 14:45:07 -0700199 proto android.ProtoFlags
Colin Cross19878da2019-03-28 14:45:07 -0700200 protoC bool // Whether to use C instead of C++
201 protoOptionsFile bool // Whether to look for a .options file next to the .proto
Dan Willemsen4e0aa232019-04-10 22:59:54 -0700202
203 Yacc *YaccProperties
Colin Crossc472d572015-03-17 15:06:21 -0700204}
205
Colin Crossca860ac2016-01-04 14:34:37 -0800206// Properties used to compile all C or C++ modules
207type BaseProperties struct {
Dan Willemsen742a5452018-07-23 17:19:36 -0700208 // Deprecated. true is the default, false is invalid.
Colin Crossca860ac2016-01-04 14:34:37 -0800209 Clang *bool `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -0700210
211 // Minimum sdk version supported when compiling against the ndk
Nan Zhang0007d812017-11-07 10:57:05 -0800212 Sdk_version *string
Colin Cross7d5136f2015-05-11 13:39:40 -0700213
Jiyong Parkde866cb2018-12-07 23:08:36 +0900214 AndroidMkSharedLibs []string `blueprint:"mutated"`
215 AndroidMkStaticLibs []string `blueprint:"mutated"`
216 AndroidMkRuntimeLibs []string `blueprint:"mutated"`
217 AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
218 HideFromMake bool `blueprint:"mutated"`
219 PreventInstall bool `blueprint:"mutated"`
220 ApexesProvidingSharedLibs []string `blueprint:"mutated"`
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700221
Justin Yun5f7f7e82019-11-18 19:52:14 +0900222 ImageVariationPrefix string `blueprint:"mutated"`
223 VndkVersion string `blueprint:"mutated"`
224 SubName string `blueprint:"mutated"`
Colin Cross5beccee2017-12-07 15:28:59 -0800225
226 // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
227 // file
228 Logtags []string
Jiyong Parkf9332f12018-02-01 00:54:12 +0900229
Yifan Hong1b3348d2020-01-21 15:53:22 -0800230 // Make this module available when building for ramdisk
231 Ramdisk_available *bool
232
Jiyong Parkf9332f12018-02-01 00:54:12 +0900233 // Make this module available when building for recovery
234 Recovery_available *bool
235
Colin Crossae6c5202019-11-20 13:35:50 -0800236 // Set by imageMutator
Colin Cross7228ecd2019-11-18 16:00:16 -0800237 CoreVariantNeeded bool `blueprint:"mutated"`
Yifan Hong1b3348d2020-01-21 15:53:22 -0800238 RamdiskVariantNeeded bool `blueprint:"mutated"`
Colin Cross7228ecd2019-11-18 16:00:16 -0800239 RecoveryVariantNeeded bool `blueprint:"mutated"`
Justin Yun5f7f7e82019-11-18 19:52:14 +0900240 ExtraVariants []string `blueprint:"mutated"`
Jiyong Parkb0788572018-12-20 22:10:17 +0900241
242 // Allows this module to use non-APEX version of libraries. Useful
243 // for building binaries that are started before APEXes are activated.
244 Bootstrap *bool
Jooyung Han097087b2019-10-22 19:32:18 +0900245
246 // Even if DeviceConfig().VndkUseCoreVariant() is set, this module must use vendor variant.
247 // see soong/cc/config/vndk.go
248 MustUseVendorVariant bool `blueprint:"mutated"`
Inseob Kim8471cda2019-11-15 09:59:12 +0900249
250 // Used by vendor snapshot to record dependencies from snapshot modules.
251 SnapshotSharedLibs []string `blueprint:"mutated"`
252 SnapshotRuntimeLibs []string `blueprint:"mutated"`
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700253}
254
255type VendorProperties struct {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900256 // whether this module should be allowed to be directly depended by other
257 // modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`.
Justin Yun5f7f7e82019-11-18 19:52:14 +0900258 // In addition, this module should be allowed to be directly depended by
259 // product modules with `product_specific: true`.
260 // If set to true, three variants will be built separately, one like
261 // normal, another limited to the set of libraries and headers
262 // that are exposed to /vendor modules, and the other to /product modules.
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700263 //
Justin Yun5f7f7e82019-11-18 19:52:14 +0900264 // The vendor and product variants may be used with a different (newer) /system,
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700265 // so it shouldn't have any unversioned runtime dependencies, or
266 // make assumptions about the system that may not be true in the
267 // future.
268 //
Justin Yun5f7f7e82019-11-18 19:52:14 +0900269 // If set to false, this module becomes inaccessible from /vendor or /product
270 // modules.
Jiyong Park82e2bf32017-08-16 14:05:54 +0900271 //
272 // Default value is true when vndk: {enabled: true} or vendor: true.
273 //
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700274 // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
Justin Yun5f7f7e82019-11-18 19:52:14 +0900275 // If PRODUCT_PRODUCT_VNDK_VERSION isn't set, product variant will not be used.
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700276 Vendor_available *bool
Jiyong Park5fb8c102018-04-09 12:03:06 +0900277
278 // whether this module is capable of being loaded with other instance
279 // (possibly an older version) of the same module in the same process.
280 // Currently, a shared library that is a member of VNDK (vndk: {enabled: true})
281 // can be double loaded in a vendor process if the library is also a
282 // (direct and indirect) dependency of an LLNDK library. Such libraries must be
283 // explicitly marked as `double_loadable: true` by the owner, or the dependency
284 // from the LLNDK lib should be cut if the lib is not designed to be double loaded.
285 Double_loadable *bool
Colin Crossca860ac2016-01-04 14:34:37 -0800286}
287
Colin Crossca860ac2016-01-04 14:34:37 -0800288type ModuleContextIntf interface {
Colin Crossca860ac2016-01-04 14:34:37 -0800289 static() bool
290 staticBinary() bool
Jiyong Park1d1119f2019-07-29 21:27:18 +0900291 header() bool
Colin Crossb98c8b02016-07-29 13:44:28 -0700292 toolchain() config.Toolchain
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700293 useSdk() bool
Colin Crossca860ac2016-01-04 14:34:37 -0800294 sdkVersion() string
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700295 useVndk() bool
Logan Chienf6dbd9c2019-01-16 20:19:51 +0800296 isNdk() bool
Inseob Kim9516ee92019-05-09 10:56:13 +0900297 isLlndk(config android.Config) bool
298 isLlndkPublic(config android.Config) bool
299 isVndkPrivate(config android.Config) bool
Justin Yun8effde42017-06-23 19:24:43 +0900300 isVndk() bool
301 isVndkSp() bool
Logan Chienf3511742017-10-31 18:04:35 +0800302 isVndkExt() bool
Justin Yun5f7f7e82019-11-18 19:52:14 +0900303 inProduct() bool
304 inVendor() bool
Yifan Hong1b3348d2020-01-21 15:53:22 -0800305 inRamdisk() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900306 inRecovery() bool
Hsin-Yi Chenaf17d742019-07-29 17:46:59 +0800307 shouldCreateSourceAbiDump() bool
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700308 selectedStl() string
Colin Crossce75d2c2016-10-06 16:12:58 -0700309 baseModuleName() string
Logan Chienf3511742017-10-31 18:04:35 +0800310 getVndkExtendsModuleName() string
Yi Kong7e53c572018-02-14 18:16:12 +0800311 isPgoCompile() bool
Pirama Arumuga Nainar1acd4472018-12-10 15:12:40 -0800312 isNDKStubLibrary() bool
Ivan Lozanobd721262018-11-27 14:33:03 -0800313 useClangLld(actx ModuleContext) bool
Logan Chiene274fc92019-12-03 11:18:32 -0800314 isForPlatform() bool
Jiyong Park58e364a2019-01-19 19:24:06 +0900315 apexName() string
Jiyong Parkb0788572018-12-20 22:10:17 +0900316 hasStubsVariants() bool
317 isStubs() bool
Jiyong Parka4b9dd02019-01-16 22:53:13 +0900318 bootstrap() bool
Vic Yangefd249e2018-11-12 20:19:56 -0800319 mustUseVendorVariant() bool
Pirama Arumuga Nainar65c95ff2019-03-25 10:21:31 -0700320 nativeCoverage() bool
Colin Crossca860ac2016-01-04 14:34:37 -0800321}
322
323type ModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700324 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800325 ModuleContextIntf
326}
327
328type BaseModuleContext interface {
Colin Cross0ea8ba82019-06-06 14:33:29 -0700329 android.BaseModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800330 ModuleContextIntf
331}
332
Colin Cross37047f12016-12-13 17:06:13 -0800333type DepsContext interface {
334 android.BottomUpMutatorContext
335 ModuleContextIntf
336}
337
Colin Crossca860ac2016-01-04 14:34:37 -0800338type feature interface {
339 begin(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800340 deps(ctx DepsContext, deps Deps) Deps
Colin Crossca860ac2016-01-04 14:34:37 -0800341 flags(ctx ModuleContext, flags Flags) Flags
342 props() []interface{}
343}
344
345type compiler interface {
Colin Cross42742b82016-08-01 13:20:05 -0700346 compilerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800347 compilerDeps(ctx DepsContext, deps Deps) Deps
Colin Crossf18e1102017-11-16 14:33:08 -0800348 compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags
Colin Cross42742b82016-08-01 13:20:05 -0700349 compilerProps() []interface{}
350
Colin Cross76fada02016-07-27 10:31:13 -0700351 appendCflags([]string)
352 appendAsflags([]string)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700353 compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800354}
355
356type linker interface {
Colin Cross42742b82016-08-01 13:20:05 -0700357 linkerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800358 linkerDeps(ctx DepsContext, deps Deps) Deps
Colin Cross42742b82016-08-01 13:20:05 -0700359 linkerFlags(ctx ModuleContext, flags Flags) Flags
360 linkerProps() []interface{}
Ivan Lozanobd721262018-11-27 14:33:03 -0800361 useClangLld(actx ModuleContext) bool
Colin Cross42742b82016-08-01 13:20:05 -0700362
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700363 link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
Colin Cross76fada02016-07-27 10:31:13 -0700364 appendLdflags([]string)
Jiyong Parkaf6d8952019-01-31 12:21:23 +0900365 unstrippedOutputFilePath() android.Path
Pirama Arumuga Nainar65c95ff2019-03-25 10:21:31 -0700366
367 nativeCoverage() bool
Jiyong Parkee9a98d2019-08-09 14:44:36 +0900368 coverageOutputFilePath() android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800369}
370
371type installer interface {
Colin Cross42742b82016-08-01 13:20:05 -0700372 installerProps() []interface{}
Colin Cross635c3b02016-05-18 15:37:25 -0700373 install(ctx ModuleContext, path android.Path)
Colin Crossca860ac2016-01-04 14:34:37 -0800374 inData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700375 inSanitizerDir() bool
Dan Willemsen4aa75ca2016-09-28 16:18:03 -0700376 hostToolPath() android.OptionalPath
Jiyong Parkb7c24df2019-02-01 12:03:59 +0900377 relativeInstallPath() string
Colin Crossca860ac2016-01-04 14:34:37 -0800378}
379
Sasha Smundak2a4549e2018-11-05 16:49:08 -0800380type xref interface {
381 XrefCcFiles() android.Paths
382}
383
Colin Crossc99deeb2016-04-11 15:06:20 -0700384var (
Ivan Lozano183a3212019-10-18 14:18:45 -0700385 sharedExportDepTag = DependencyTag{Name: "shared", Library: true, Shared: true, ReexportFlags: true}
386 earlySharedDepTag = DependencyTag{Name: "early_shared", Library: true, Shared: true}
387 lateSharedDepTag = DependencyTag{Name: "late shared", Library: true, Shared: true}
388 staticExportDepTag = DependencyTag{Name: "static", Library: true, ReexportFlags: true}
389 lateStaticDepTag = DependencyTag{Name: "late static", Library: true}
Peter Collingbournedc4f9862020-02-12 17:13:25 -0800390 staticUnwinderDepTag = DependencyTag{Name: "static unwinder", Library: true}
Ivan Lozano183a3212019-10-18 14:18:45 -0700391 wholeStaticDepTag = DependencyTag{Name: "whole static", Library: true, ReexportFlags: true}
392 headerDepTag = DependencyTag{Name: "header", Library: true}
393 headerExportDepTag = DependencyTag{Name: "header", Library: true, ReexportFlags: true}
394 genSourceDepTag = DependencyTag{Name: "gen source"}
395 genHeaderDepTag = DependencyTag{Name: "gen header"}
396 genHeaderExportDepTag = DependencyTag{Name: "gen header", ReexportFlags: true}
397 objDepTag = DependencyTag{Name: "obj"}
398 linkerFlagsDepTag = DependencyTag{Name: "linker flags file"}
399 dynamicLinkerDepTag = DependencyTag{Name: "dynamic linker"}
400 reuseObjTag = DependencyTag{Name: "reuse objects"}
401 staticVariantTag = DependencyTag{Name: "static variant"}
402 ndkStubDepTag = DependencyTag{Name: "ndk stub", Library: true}
403 ndkLateStubDepTag = DependencyTag{Name: "ndk late stub", Library: true}
404 vndkExtDepTag = DependencyTag{Name: "vndk extends", Library: true}
405 runtimeDepTag = DependencyTag{Name: "runtime lib"}
406 coverageDepTag = DependencyTag{Name: "coverage"}
407 testPerSrcDepTag = DependencyTag{Name: "test_per_src"}
Colin Crossc99deeb2016-04-11 15:06:20 -0700408)
409
Roland Levillainf89cd092019-07-29 16:22:59 +0100410func IsSharedDepTag(depTag blueprint.DependencyTag) bool {
Ivan Lozano183a3212019-10-18 14:18:45 -0700411 ccDepTag, ok := depTag.(DependencyTag)
412 return ok && ccDepTag.Shared
Roland Levillainf89cd092019-07-29 16:22:59 +0100413}
414
415func IsRuntimeDepTag(depTag blueprint.DependencyTag) bool {
Ivan Lozano183a3212019-10-18 14:18:45 -0700416 ccDepTag, ok := depTag.(DependencyTag)
Roland Levillainf89cd092019-07-29 16:22:59 +0100417 return ok && ccDepTag == runtimeDepTag
418}
419
420func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool {
Ivan Lozano183a3212019-10-18 14:18:45 -0700421 ccDepTag, ok := depTag.(DependencyTag)
Roland Levillainf89cd092019-07-29 16:22:59 +0100422 return ok && ccDepTag == testPerSrcDepTag
423}
424
Colin Crossca860ac2016-01-04 14:34:37 -0800425// Module contains the properties and members used by all C/C++ module types, and implements
426// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
427// to construct the output file. Behavior can be customized with a Customizer interface
428type Module struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700429 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -0700430 android.DefaultableModuleBase
Jiyong Park9d452992018-10-03 00:38:19 +0900431 android.ApexModuleBase
Jiyong Parkd1063c12019-07-17 20:08:41 +0900432 android.SdkBase
Colin Crossc472d572015-03-17 15:06:21 -0700433
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700434 Properties BaseProperties
435 VendorProperties VendorProperties
Colin Crossfa138792015-04-24 17:31:52 -0700436
Colin Crossca860ac2016-01-04 14:34:37 -0800437 // initialize before calling Init
Colin Cross635c3b02016-05-18 15:37:25 -0700438 hod android.HostOrDeviceSupported
439 multilib android.Multilib
Colin Crossc472d572015-03-17 15:06:21 -0700440
Paul Duffina0843f62019-12-13 19:50:38 +0000441 // Allowable SdkMemberTypes of this module type.
442 sdkMemberTypes []android.SdkMemberType
443
Colin Crossca860ac2016-01-04 14:34:37 -0800444 // delegates, initialize before calling Init
Colin Crossb4ce0ec2016-09-13 13:41:39 -0700445 features []feature
446 compiler compiler
447 linker linker
448 installer installer
449 stl *stl
450 sanitize *sanitize
Dan Willemsen581341d2017-02-09 16:16:31 -0800451 coverage *coverage
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800452 sabi *sabi
Justin Yun8effde42017-06-23 19:24:43 +0900453 vndkdep *vndkdep
Stephen Craneba090d12017-05-09 15:44:35 -0700454 lto *lto
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700455 pgo *pgo
Colin Cross16b23492016-01-06 14:41:07 -0800456
Colin Cross635c3b02016-05-18 15:37:25 -0700457 outputFile android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800458
Colin Crossb98c8b02016-07-29 13:44:28 -0700459 cachedToolchain config.Toolchain
Colin Crossb916a382016-07-29 17:28:03 -0700460
461 subAndroidMkOnce map[subAndroidMkProvider]bool
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800462
463 // Flags used to compile this module
464 flags Flags
Jeff Gaston294356f2017-09-27 17:05:30 -0700465
466 // When calling a linker, if module A depends on module B, then A must precede B in its command
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800467 // line invocation. depsInLinkOrder stores the proper ordering of all of the transitive
Jeff Gaston294356f2017-09-27 17:05:30 -0700468 // deps of this module
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800469 depsInLinkOrder android.Paths
470
471 // only non-nil when this is a shared library that reuses the objects of a static library
Ivan Lozano52767be2019-10-18 14:49:46 -0700472 staticVariant LinkableInterface
Inseob Kim9516ee92019-05-09 10:56:13 +0900473
474 makeLinkType string
Sasha Smundak2a4549e2018-11-05 16:49:08 -0800475 // Kythe (source file indexer) paths for this compilation module
476 kytheFiles android.Paths
Colin Crossc472d572015-03-17 15:06:21 -0700477}
478
Ivan Lozano52767be2019-10-18 14:49:46 -0700479func (c *Module) Toc() android.OptionalPath {
480 if c.linker != nil {
481 if library, ok := c.linker.(libraryInterface); ok {
482 return library.toc()
483 }
484 }
485 panic(fmt.Errorf("Toc() called on non-library module: %q", c.BaseModuleName()))
486}
487
488func (c *Module) ApiLevel() string {
489 if c.linker != nil {
490 if stub, ok := c.linker.(*stubDecorator); ok {
491 return stub.properties.ApiLevel
492 }
493 }
494 panic(fmt.Errorf("ApiLevel() called on non-stub library module: %q", c.BaseModuleName()))
495}
496
497func (c *Module) Static() bool {
498 if c.linker != nil {
499 if library, ok := c.linker.(libraryInterface); ok {
500 return library.static()
501 }
502 }
503 panic(fmt.Errorf("Static() called on non-library module: %q", c.BaseModuleName()))
504}
505
506func (c *Module) Shared() bool {
507 if c.linker != nil {
508 if library, ok := c.linker.(libraryInterface); ok {
509 return library.shared()
510 }
511 }
512 panic(fmt.Errorf("Shared() called on non-library module: %q", c.BaseModuleName()))
513}
514
515func (c *Module) SelectedStl() string {
516 return c.stl.Properties.SelectedStl
517}
518
519func (c *Module) ToolchainLibrary() bool {
520 if _, ok := c.linker.(*toolchainLibraryDecorator); ok {
521 return true
522 }
523 return false
524}
525
526func (c *Module) NdkPrebuiltStl() bool {
527 if _, ok := c.linker.(*ndkPrebuiltStlLinker); ok {
528 return true
529 }
530 return false
531}
532
533func (c *Module) StubDecorator() bool {
534 if _, ok := c.linker.(*stubDecorator); ok {
535 return true
536 }
537 return false
538}
539
540func (c *Module) SdkVersion() string {
541 return String(c.Properties.Sdk_version)
542}
543
Ivan Lozanoe0833b12019-11-06 19:15:49 -0800544func (c *Module) IncludeDirs() android.Paths {
Ivan Lozano183a3212019-10-18 14:18:45 -0700545 if c.linker != nil {
546 if library, ok := c.linker.(exportedFlagsProducer); ok {
547 return library.exportedDirs()
548 }
549 }
550 panic(fmt.Errorf("IncludeDirs called on non-exportedFlagsProducer module: %q", c.BaseModuleName()))
551}
552
553func (c *Module) HasStaticVariant() bool {
554 if c.staticVariant != nil {
555 return true
556 }
557 return false
558}
559
560func (c *Module) GetStaticVariant() LinkableInterface {
561 return c.staticVariant
562}
563
564func (c *Module) SetDepsInLinkOrder(depsInLinkOrder []android.Path) {
565 c.depsInLinkOrder = depsInLinkOrder
566}
567
568func (c *Module) GetDepsInLinkOrder() []android.Path {
569 return c.depsInLinkOrder
570}
571
572func (c *Module) StubsVersions() []string {
573 if c.linker != nil {
574 if library, ok := c.linker.(*libraryDecorator); ok {
575 return library.Properties.Stubs.Versions
576 }
577 }
578 panic(fmt.Errorf("StubsVersions called on non-library module: %q", c.BaseModuleName()))
579}
580
581func (c *Module) CcLibrary() bool {
582 if c.linker != nil {
583 if _, ok := c.linker.(*libraryDecorator); ok {
584 return true
585 }
586 }
587 return false
588}
589
590func (c *Module) CcLibraryInterface() bool {
Ivan Lozano52767be2019-10-18 14:49:46 -0700591 if _, ok := c.linker.(libraryInterface); ok {
Ivan Lozano183a3212019-10-18 14:18:45 -0700592 return true
593 }
594 return false
595}
596
Ivan Lozano2b262972019-11-21 12:30:50 -0800597func (c *Module) NonCcVariants() bool {
598 return false
599}
600
Ivan Lozano183a3212019-10-18 14:18:45 -0700601func (c *Module) SetBuildStubs() {
602 if c.linker != nil {
603 if library, ok := c.linker.(*libraryDecorator); ok {
604 library.MutatedProperties.BuildStubs = true
Ivan Lozano52767be2019-10-18 14:49:46 -0700605 c.Properties.HideFromMake = true
606 c.sanitize = nil
607 c.stl = nil
608 c.Properties.PreventInstall = true
Ivan Lozano183a3212019-10-18 14:18:45 -0700609 return
610 }
611 }
612 panic(fmt.Errorf("SetBuildStubs called on non-library module: %q", c.BaseModuleName()))
613}
614
Ivan Lozano52767be2019-10-18 14:49:46 -0700615func (c *Module) BuildStubs() bool {
616 if c.linker != nil {
617 if library, ok := c.linker.(*libraryDecorator); ok {
618 return library.buildStubs()
619 }
620 }
621 panic(fmt.Errorf("BuildStubs called on non-library module: %q", c.BaseModuleName()))
622}
623
Ivan Lozano183a3212019-10-18 14:18:45 -0700624func (c *Module) SetStubsVersions(version string) {
625 if c.linker != nil {
626 if library, ok := c.linker.(*libraryDecorator); ok {
627 library.MutatedProperties.StubsVersion = version
628 return
629 }
630 }
631 panic(fmt.Errorf("SetStubsVersions called on non-library module: %q", c.BaseModuleName()))
632}
633
Jooyung Han03b51852020-02-26 22:45:42 +0900634func (c *Module) StubsVersion() string {
635 if c.linker != nil {
636 if library, ok := c.linker.(*libraryDecorator); ok {
637 return library.MutatedProperties.StubsVersion
638 }
639 }
640 panic(fmt.Errorf("StubsVersion called on non-library module: %q", c.BaseModuleName()))
641}
642
Ivan Lozano183a3212019-10-18 14:18:45 -0700643func (c *Module) SetStatic() {
644 if c.linker != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700645 if library, ok := c.linker.(libraryInterface); ok {
Ivan Lozano183a3212019-10-18 14:18:45 -0700646 library.setStatic()
647 return
648 }
649 }
650 panic(fmt.Errorf("SetStatic called on non-library module: %q", c.BaseModuleName()))
651}
652
653func (c *Module) SetShared() {
654 if c.linker != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700655 if library, ok := c.linker.(libraryInterface); ok {
Ivan Lozano183a3212019-10-18 14:18:45 -0700656 library.setShared()
657 return
658 }
659 }
660 panic(fmt.Errorf("SetShared called on non-library module: %q", c.BaseModuleName()))
661}
662
663func (c *Module) BuildStaticVariant() bool {
664 if c.linker != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700665 if library, ok := c.linker.(libraryInterface); ok {
Ivan Lozano183a3212019-10-18 14:18:45 -0700666 return library.buildStatic()
667 }
668 }
669 panic(fmt.Errorf("BuildStaticVariant called on non-library module: %q", c.BaseModuleName()))
670}
671
672func (c *Module) BuildSharedVariant() bool {
673 if c.linker != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700674 if library, ok := c.linker.(libraryInterface); ok {
Ivan Lozano183a3212019-10-18 14:18:45 -0700675 return library.buildShared()
676 }
677 }
678 panic(fmt.Errorf("BuildSharedVariant called on non-library module: %q", c.BaseModuleName()))
679}
680
681func (c *Module) Module() android.Module {
682 return c
683}
684
Jiyong Parkc20eee32018-09-05 22:36:17 +0900685func (c *Module) OutputFile() android.OptionalPath {
686 return c.outputFile
687}
688
Ivan Lozano183a3212019-10-18 14:18:45 -0700689var _ LinkableInterface = (*Module)(nil)
690
Jiyong Park719b4462019-01-13 00:39:51 +0900691func (c *Module) UnstrippedOutputFile() android.Path {
Jiyong Parkaf6d8952019-01-31 12:21:23 +0900692 if c.linker != nil {
693 return c.linker.unstrippedOutputFilePath()
Jiyong Park719b4462019-01-13 00:39:51 +0900694 }
695 return nil
696}
697
Jiyong Parkee9a98d2019-08-09 14:44:36 +0900698func (c *Module) CoverageOutputFile() android.OptionalPath {
699 if c.linker != nil {
700 return c.linker.coverageOutputFilePath()
701 }
702 return android.OptionalPath{}
703}
704
Jiyong Parkb7c24df2019-02-01 12:03:59 +0900705func (c *Module) RelativeInstallPath() string {
706 if c.installer != nil {
707 return c.installer.relativeInstallPath()
708 }
709 return ""
710}
711
Jooyung Han344d5432019-08-23 11:17:39 +0900712func (c *Module) VndkVersion() string {
Justin Yun5f7f7e82019-11-18 19:52:14 +0900713 return c.Properties.VndkVersion
Jooyung Han344d5432019-08-23 11:17:39 +0900714}
715
Colin Cross36242852017-06-23 15:06:31 -0700716func (c *Module) Init() android.Module {
Dan Willemsenf923f2b2018-05-09 13:45:03 -0700717 c.AddProperties(&c.Properties, &c.VendorProperties)
Colin Crossca860ac2016-01-04 14:34:37 -0800718 if c.compiler != nil {
Colin Cross36242852017-06-23 15:06:31 -0700719 c.AddProperties(c.compiler.compilerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800720 }
721 if c.linker != nil {
Colin Cross36242852017-06-23 15:06:31 -0700722 c.AddProperties(c.linker.linkerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800723 }
724 if c.installer != nil {
Colin Cross36242852017-06-23 15:06:31 -0700725 c.AddProperties(c.installer.installerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800726 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700727 if c.stl != nil {
Colin Cross36242852017-06-23 15:06:31 -0700728 c.AddProperties(c.stl.props()...)
Colin Crossa8e07cc2016-04-04 15:07:06 -0700729 }
Colin Cross16b23492016-01-06 14:41:07 -0800730 if c.sanitize != nil {
Colin Cross36242852017-06-23 15:06:31 -0700731 c.AddProperties(c.sanitize.props()...)
Colin Cross16b23492016-01-06 14:41:07 -0800732 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800733 if c.coverage != nil {
Colin Cross36242852017-06-23 15:06:31 -0700734 c.AddProperties(c.coverage.props()...)
Dan Willemsen581341d2017-02-09 16:16:31 -0800735 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800736 if c.sabi != nil {
Colin Cross36242852017-06-23 15:06:31 -0700737 c.AddProperties(c.sabi.props()...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800738 }
Justin Yun8effde42017-06-23 19:24:43 +0900739 if c.vndkdep != nil {
740 c.AddProperties(c.vndkdep.props()...)
741 }
Stephen Craneba090d12017-05-09 15:44:35 -0700742 if c.lto != nil {
743 c.AddProperties(c.lto.props()...)
744 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700745 if c.pgo != nil {
746 c.AddProperties(c.pgo.props()...)
747 }
Colin Crossca860ac2016-01-04 14:34:37 -0800748 for _, feature := range c.features {
Colin Cross36242852017-06-23 15:06:31 -0700749 c.AddProperties(feature.props()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800750 }
Colin Crossc472d572015-03-17 15:06:21 -0700751
Colin Crossa9d8bee2018-10-02 13:59:46 -0700752 c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
753 switch class {
754 case android.Device:
755 return ctx.Config().DevicePrefer32BitExecutables()
756 case android.HostCross:
757 // Windows builds always prefer 32-bit
758 return true
759 default:
760 return false
761 }
762 })
Colin Cross36242852017-06-23 15:06:31 -0700763 android.InitAndroidArchModule(c, c.hod, c.multilib)
Jiyong Park7916bfc2019-09-30 19:13:12 +0900764 android.InitApexModule(c)
Jiyong Parkd1063c12019-07-17 20:08:41 +0900765 android.InitSdkAwareModule(c)
Jooyung Han18020ea2019-11-13 10:50:48 +0900766 android.InitDefaultableModule(c)
Jiyong Park9d452992018-10-03 00:38:19 +0900767
Colin Cross36242852017-06-23 15:06:31 -0700768 return c
Colin Crossc472d572015-03-17 15:06:21 -0700769}
770
Colin Crossb916a382016-07-29 17:28:03 -0700771// Returns true for dependency roots (binaries)
772// TODO(ccross): also handle dlopenable libraries
773func (c *Module) isDependencyRoot() bool {
774 if root, ok := c.linker.(interface {
775 isDependencyRoot() bool
776 }); ok {
777 return root.isDependencyRoot()
778 }
779 return false
780}
781
Justin Yun5f7f7e82019-11-18 19:52:14 +0900782// Returns true if the module is using VNDK libraries instead of the libraries in /system/lib or /system/lib64.
783// "product" and "vendor" variant modules return true for this function.
784// When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true",
785// "soc_specific: true" and more vendor installed modules are included here.
786// When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "vendor_available: true" or
787// "product_specific: true" modules are included here.
Ivan Lozano52767be2019-10-18 14:49:46 -0700788func (c *Module) UseVndk() bool {
Inseob Kim64c43952019-08-26 16:52:35 +0900789 return c.Properties.VndkVersion != ""
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700790}
791
Pirama Arumuga Nainar1acd4472018-12-10 15:12:40 -0800792func (c *Module) isCoverageVariant() bool {
793 return c.coverage.Properties.IsCoverageVariant
794}
795
Peter Collingbournead84f972019-12-17 16:46:18 -0800796func (c *Module) IsNdk() bool {
Logan Chienf6dbd9c2019-01-16 20:19:51 +0800797 return inList(c.Name(), ndkMigratedLibs)
798}
799
Inseob Kim9516ee92019-05-09 10:56:13 +0900800func (c *Module) isLlndk(config android.Config) bool {
Logan Chienf6dbd9c2019-01-16 20:19:51 +0800801 // Returns true for both LLNDK (public) and LLNDK-private libs.
Jooyung Han0302a842019-10-30 18:43:49 +0900802 return isLlndkLibrary(c.BaseModuleName(), config)
Logan Chienf6dbd9c2019-01-16 20:19:51 +0800803}
804
Inseob Kim9516ee92019-05-09 10:56:13 +0900805func (c *Module) isLlndkPublic(config android.Config) bool {
Logan Chienf6dbd9c2019-01-16 20:19:51 +0800806 // Returns true only for LLNDK (public) libs.
Jooyung Han0302a842019-10-30 18:43:49 +0900807 name := c.BaseModuleName()
808 return isLlndkLibrary(name, config) && !isVndkPrivateLibrary(name, config)
Logan Chienf6dbd9c2019-01-16 20:19:51 +0800809}
810
Inseob Kim9516ee92019-05-09 10:56:13 +0900811func (c *Module) isVndkPrivate(config android.Config) bool {
Logan Chienf6dbd9c2019-01-16 20:19:51 +0800812 // Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private.
Jooyung Han0302a842019-10-30 18:43:49 +0900813 return isVndkPrivateLibrary(c.BaseModuleName(), config)
Logan Chienf6dbd9c2019-01-16 20:19:51 +0800814}
815
Ivan Lozano52767be2019-10-18 14:49:46 -0700816func (c *Module) IsVndk() bool {
Logan Chienf3511742017-10-31 18:04:35 +0800817 if vndkdep := c.vndkdep; vndkdep != nil {
818 return vndkdep.isVndk()
Justin Yun8effde42017-06-23 19:24:43 +0900819 }
820 return false
821}
822
Yi Kong7e53c572018-02-14 18:16:12 +0800823func (c *Module) isPgoCompile() bool {
824 if pgo := c.pgo; pgo != nil {
825 return pgo.Properties.PgoCompile
826 }
827 return false
828}
829
Pirama Arumuga Nainar1acd4472018-12-10 15:12:40 -0800830func (c *Module) isNDKStubLibrary() bool {
831 if _, ok := c.compiler.(*stubDecorator); ok {
832 return true
833 }
834 return false
835}
836
Logan Chienf3511742017-10-31 18:04:35 +0800837func (c *Module) isVndkSp() bool {
838 if vndkdep := c.vndkdep; vndkdep != nil {
839 return vndkdep.isVndkSp()
840 }
841 return false
842}
843
844func (c *Module) isVndkExt() bool {
845 if vndkdep := c.vndkdep; vndkdep != nil {
846 return vndkdep.isVndkExt()
847 }
848 return false
849}
850
Ivan Lozano52767be2019-10-18 14:49:46 -0700851func (c *Module) MustUseVendorVariant() bool {
Jooyung Han097087b2019-10-22 19:32:18 +0900852 return c.isVndkSp() || c.Properties.MustUseVendorVariant
Vic Yangefd249e2018-11-12 20:19:56 -0800853}
854
Logan Chienf3511742017-10-31 18:04:35 +0800855func (c *Module) getVndkExtendsModuleName() string {
856 if vndkdep := c.vndkdep; vndkdep != nil {
857 return vndkdep.getVndkExtendsModuleName()
858 }
859 return ""
860}
861
Justin Yun5f7f7e82019-11-18 19:52:14 +0900862// Returns true only when this module is configured to have core, product and vendor
Jiyong Park82e2bf32017-08-16 14:05:54 +0900863// variants.
Ivan Lozano52767be2019-10-18 14:49:46 -0700864func (c *Module) HasVendorVariant() bool {
865 return c.IsVndk() || Bool(c.VendorProperties.Vendor_available)
Jiyong Park82e2bf32017-08-16 14:05:54 +0900866}
867
Justin Yun5f7f7e82019-11-18 19:52:14 +0900868const (
869 // VendorVariationPrefix is the variant prefix used for /vendor code that compiles
870 // against the VNDK.
871 VendorVariationPrefix = "vendor."
872
873 // ProductVariationPrefix is the variant prefix used for /product code that compiles
874 // against the VNDK.
875 ProductVariationPrefix = "product."
876)
877
878// Returns true if the module is "product" variant. Usually these modules are installed in /product
879func (c *Module) inProduct() bool {
880 return c.Properties.ImageVariationPrefix == ProductVariationPrefix
881}
882
883// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
884func (c *Module) inVendor() bool {
885 return c.Properties.ImageVariationPrefix == VendorVariationPrefix
886}
887
Yifan Hong1b3348d2020-01-21 15:53:22 -0800888func (c *Module) InRamdisk() bool {
889 return c.ModuleBase.InRamdisk() || c.ModuleBase.InstallInRamdisk()
890}
891
Ivan Lozano52767be2019-10-18 14:49:46 -0700892func (c *Module) InRecovery() bool {
Colin Cross7228ecd2019-11-18 16:00:16 -0800893 return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
Jiyong Parkf9332f12018-02-01 00:54:12 +0900894}
895
Yifan Hong1b3348d2020-01-21 15:53:22 -0800896func (c *Module) OnlyInRamdisk() bool {
897 return c.ModuleBase.InstallInRamdisk()
898}
899
Ivan Lozano52767be2019-10-18 14:49:46 -0700900func (c *Module) OnlyInRecovery() bool {
Jiyong Parkf9332f12018-02-01 00:54:12 +0900901 return c.ModuleBase.InstallInRecovery()
902}
903
Jiyong Park25fc6a92018-11-18 18:02:45 +0900904func (c *Module) IsStubs() bool {
905 if library, ok := c.linker.(*libraryDecorator); ok {
906 return library.buildStubs()
Jiyong Park379de2f2018-12-19 02:47:14 +0900907 } else if _, ok := c.linker.(*llndkStubDecorator); ok {
908 return true
Jiyong Park25fc6a92018-11-18 18:02:45 +0900909 }
910 return false
911}
912
913func (c *Module) HasStubsVariants() bool {
914 if library, ok := c.linker.(*libraryDecorator); ok {
915 return len(library.Properties.Stubs.Versions) > 0
916 }
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700917 if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
918 return len(library.Properties.Stubs.Versions) > 0
919 }
Jiyong Park25fc6a92018-11-18 18:02:45 +0900920 return false
921}
922
Jiyong Parka4b9dd02019-01-16 22:53:13 +0900923func (c *Module) bootstrap() bool {
924 return Bool(c.Properties.Bootstrap)
925}
926
Pirama Arumuga Nainar65c95ff2019-03-25 10:21:31 -0700927func (c *Module) nativeCoverage() bool {
Pirama Arumuga Nainar5f69b9a2019-09-12 13:18:48 -0700928 // Bug: http://b/137883967 - native-bridge modules do not currently work with coverage
929 if c.Target().NativeBridge == android.NativeBridgeEnabled {
930 return false
931 }
Pirama Arumuga Nainar65c95ff2019-03-25 10:21:31 -0700932 return c.linker != nil && c.linker.nativeCoverage()
933}
934
Inseob Kim8471cda2019-11-15 09:59:12 +0900935func (c *Module) isSnapshotPrebuilt() bool {
Inseob Kimeec88e12020-01-22 11:11:29 +0900936 if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
937 return true
938 }
939 if _, ok := c.linker.(*vendorSnapshotLibraryDecorator); ok {
940 return true
941 }
942 if _, ok := c.linker.(*vendorSnapshotBinaryDecorator); ok {
943 return true
944 }
945 return false
Inseob Kim8471cda2019-11-15 09:59:12 +0900946}
947
Jiyong Park73c54ee2019-10-22 20:31:18 +0900948func (c *Module) ExportedIncludeDirs() android.Paths {
949 if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
950 return flagsProducer.exportedDirs()
951 }
Jiyong Park232e7852019-11-04 12:23:40 +0900952 return nil
Jiyong Park73c54ee2019-10-22 20:31:18 +0900953}
954
955func (c *Module) ExportedSystemIncludeDirs() android.Paths {
956 if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
957 return flagsProducer.exportedSystemDirs()
958 }
Jiyong Park232e7852019-11-04 12:23:40 +0900959 return nil
Jiyong Park73c54ee2019-10-22 20:31:18 +0900960}
961
962func (c *Module) ExportedFlags() []string {
963 if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
964 return flagsProducer.exportedFlags()
965 }
Jiyong Park232e7852019-11-04 12:23:40 +0900966 return nil
967}
968
969func (c *Module) ExportedDeps() android.Paths {
970 if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
971 return flagsProducer.exportedDeps()
972 }
973 return nil
Jiyong Park73c54ee2019-10-22 20:31:18 +0900974}
975
Inseob Kimd110f872019-12-06 13:15:38 +0900976func (c *Module) ExportedGeneratedHeaders() android.Paths {
977 if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
978 return flagsProducer.exportedGeneratedHeaders()
979 }
980 return nil
981}
982
Jiyong Parkf1194352019-02-25 11:05:47 +0900983func isBionic(name string) bool {
984 switch name {
Martin Stjernholm203489b2019-11-11 15:33:27 +0000985 case "libc", "libm", "libdl", "libdl_android", "linker":
Jiyong Parkf1194352019-02-25 11:05:47 +0900986 return true
987 }
988 return false
989}
990
Martin Stjernholm279de572019-09-10 23:18:20 +0100991func InstallToBootstrap(name string, config android.Config) bool {
Peter Collingbourne3478bb22019-04-24 14:41:12 -0700992 if name == "libclang_rt.hwasan-aarch64-android" {
993 return inList("hwaddress", config.SanitizeDevice())
994 }
995 return isBionic(name)
996}
997
Sasha Smundak2a4549e2018-11-05 16:49:08 -0800998func (c *Module) XrefCcFiles() android.Paths {
999 return c.kytheFiles
1000}
1001
Colin Crossca860ac2016-01-04 14:34:37 -08001002type baseModuleContext struct {
Colin Cross0ea8ba82019-06-06 14:33:29 -07001003 android.BaseModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -08001004 moduleContextImpl
1005}
1006
Colin Cross37047f12016-12-13 17:06:13 -08001007type depsContext struct {
1008 android.BottomUpMutatorContext
1009 moduleContextImpl
1010}
1011
Colin Crossca860ac2016-01-04 14:34:37 -08001012type moduleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -07001013 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -08001014 moduleContextImpl
1015}
1016
Justin Yun5f7f7e82019-11-18 19:52:14 +09001017func (ctx *moduleContext) ProductSpecific() bool {
1018 return ctx.ModuleContext.ProductSpecific() ||
1019 (ctx.mod.HasVendorVariant() && ctx.mod.inProduct() && !ctx.mod.IsVndk())
1020}
1021
Jiyong Park2db76922017-11-08 16:03:48 +09001022func (ctx *moduleContext) SocSpecific() bool {
1023 return ctx.ModuleContext.SocSpecific() ||
Justin Yun5f7f7e82019-11-18 19:52:14 +09001024 (ctx.mod.HasVendorVariant() && ctx.mod.inVendor() && !ctx.mod.IsVndk())
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001025}
1026
Colin Crossca860ac2016-01-04 14:34:37 -08001027type moduleContextImpl struct {
1028 mod *Module
1029 ctx BaseModuleContext
1030}
1031
Colin Crossb98c8b02016-07-29 13:44:28 -07001032func (ctx *moduleContextImpl) toolchain() config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -08001033 return ctx.mod.toolchain(ctx.ctx)
1034}
1035
1036func (ctx *moduleContextImpl) static() bool {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +00001037 return ctx.mod.static()
Colin Crossca860ac2016-01-04 14:34:37 -08001038}
1039
1040func (ctx *moduleContextImpl) staticBinary() bool {
Jiyong Park379de2f2018-12-19 02:47:14 +09001041 return ctx.mod.staticBinary()
Colin Crossca860ac2016-01-04 14:34:37 -08001042}
1043
Jiyong Park1d1119f2019-07-29 21:27:18 +09001044func (ctx *moduleContextImpl) header() bool {
1045 return ctx.mod.header()
1046}
1047
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001048func (ctx *moduleContextImpl) useSdk() bool {
Yifan Hong1b3348d2020-01-21 15:53:22 -08001049 if ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRamdisk() && !ctx.inRecovery() && !ctx.ctx.Fuchsia() {
Nan Zhang0007d812017-11-07 10:57:05 -08001050 return String(ctx.mod.Properties.Sdk_version) != ""
Dan Willemsena96ff642016-06-07 12:34:45 -07001051 }
1052 return false
Colin Crossca860ac2016-01-04 14:34:37 -08001053}
1054
1055func (ctx *moduleContextImpl) sdkVersion() string {
Dan Willemsena96ff642016-06-07 12:34:45 -07001056 if ctx.ctx.Device() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001057 if ctx.useVndk() {
Justin Yun5f7f7e82019-11-18 19:52:14 +09001058 vndkVer := ctx.mod.VndkVersion()
1059 if inList(vndkVer, ctx.ctx.Config().PlatformVersionCombinedCodenames()) {
1060 return "current"
Justin Yun732aa6a2018-03-23 17:43:47 +09001061 }
Justin Yun5f7f7e82019-11-18 19:52:14 +09001062 return vndkVer
Dan Willemsend2ede872016-11-18 14:54:24 -08001063 }
Justin Yun732aa6a2018-03-23 17:43:47 +09001064 return String(ctx.mod.Properties.Sdk_version)
Dan Willemsena96ff642016-06-07 12:34:45 -07001065 }
1066 return ""
Colin Crossca860ac2016-01-04 14:34:37 -08001067}
1068
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001069func (ctx *moduleContextImpl) useVndk() bool {
Ivan Lozano52767be2019-10-18 14:49:46 -07001070 return ctx.mod.UseVndk()
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001071}
Justin Yun8effde42017-06-23 19:24:43 +09001072
Logan Chienf6dbd9c2019-01-16 20:19:51 +08001073func (ctx *moduleContextImpl) isNdk() bool {
Peter Collingbournead84f972019-12-17 16:46:18 -08001074 return ctx.mod.IsNdk()
Logan Chienf6dbd9c2019-01-16 20:19:51 +08001075}
1076
Inseob Kim9516ee92019-05-09 10:56:13 +09001077func (ctx *moduleContextImpl) isLlndk(config android.Config) bool {
1078 return ctx.mod.isLlndk(config)
Logan Chienf6dbd9c2019-01-16 20:19:51 +08001079}
1080
Inseob Kim9516ee92019-05-09 10:56:13 +09001081func (ctx *moduleContextImpl) isLlndkPublic(config android.Config) bool {
1082 return ctx.mod.isLlndkPublic(config)
Logan Chienf6dbd9c2019-01-16 20:19:51 +08001083}
1084
Inseob Kim9516ee92019-05-09 10:56:13 +09001085func (ctx *moduleContextImpl) isVndkPrivate(config android.Config) bool {
1086 return ctx.mod.isVndkPrivate(config)
Logan Chienf6dbd9c2019-01-16 20:19:51 +08001087}
1088
Logan Chienf3511742017-10-31 18:04:35 +08001089func (ctx *moduleContextImpl) isVndk() bool {
Ivan Lozano52767be2019-10-18 14:49:46 -07001090 return ctx.mod.IsVndk()
Logan Chienf3511742017-10-31 18:04:35 +08001091}
1092
Yi Kong7e53c572018-02-14 18:16:12 +08001093func (ctx *moduleContextImpl) isPgoCompile() bool {
1094 return ctx.mod.isPgoCompile()
1095}
1096
Pirama Arumuga Nainar1acd4472018-12-10 15:12:40 -08001097func (ctx *moduleContextImpl) isNDKStubLibrary() bool {
1098 return ctx.mod.isNDKStubLibrary()
1099}
1100
Justin Yun8effde42017-06-23 19:24:43 +09001101func (ctx *moduleContextImpl) isVndkSp() bool {
Logan Chienf3511742017-10-31 18:04:35 +08001102 return ctx.mod.isVndkSp()
1103}
1104
1105func (ctx *moduleContextImpl) isVndkExt() bool {
1106 return ctx.mod.isVndkExt()
Justin Yun8effde42017-06-23 19:24:43 +09001107}
1108
Vic Yangefd249e2018-11-12 20:19:56 -08001109func (ctx *moduleContextImpl) mustUseVendorVariant() bool {
Ivan Lozano52767be2019-10-18 14:49:46 -07001110 return ctx.mod.MustUseVendorVariant()
Vic Yangefd249e2018-11-12 20:19:56 -08001111}
1112
Justin Yun5f7f7e82019-11-18 19:52:14 +09001113func (ctx *moduleContextImpl) inProduct() bool {
1114 return ctx.mod.inProduct()
1115}
1116
1117func (ctx *moduleContextImpl) inVendor() bool {
1118 return ctx.mod.inVendor()
1119}
1120
Yifan Hong1b3348d2020-01-21 15:53:22 -08001121func (ctx *moduleContextImpl) inRamdisk() bool {
1122 return ctx.mod.InRamdisk()
1123}
1124
Jiyong Parkf9332f12018-02-01 00:54:12 +09001125func (ctx *moduleContextImpl) inRecovery() bool {
Ivan Lozano52767be2019-10-18 14:49:46 -07001126 return ctx.mod.InRecovery()
Jiyong Parkf9332f12018-02-01 00:54:12 +09001127}
1128
Logan Chien2f2b8902018-07-10 15:01:19 +08001129// Check whether ABI dumps should be created for this module.
Hsin-Yi Chenaf17d742019-07-29 17:46:59 +08001130func (ctx *moduleContextImpl) shouldCreateSourceAbiDump() bool {
Logan Chien2f2b8902018-07-10 15:01:19 +08001131 if ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") {
1132 return false
Jayant Chowdharyea0a2e12018-03-01 19:12:16 -08001133 }
Doug Hornc32c6b02019-01-17 14:44:05 -08001134
1135 if ctx.ctx.Fuchsia() {
1136 return false
1137 }
1138
Logan Chien2f2b8902018-07-10 15:01:19 +08001139 if sanitize := ctx.mod.sanitize; sanitize != nil {
1140 if !sanitize.isVariantOnProductionDevice() {
1141 return false
1142 }
1143 }
1144 if !ctx.ctx.Device() {
1145 // Host modules do not need ABI dumps.
1146 return false
1147 }
Hsin-Yi Chend2451682020-01-10 16:47:50 +08001148 if ctx.isStubs() || ctx.isNDKStubLibrary() {
Hsin-Yi Chenf6a95462019-06-25 14:46:52 +08001149 // Stubs do not need ABI dumps.
1150 return false
1151 }
Hsin-Yi Chenaf17d742019-07-29 17:46:59 +08001152 return true
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001153}
1154
Dan Willemsen8146b2f2016-03-30 21:00:30 -07001155func (ctx *moduleContextImpl) selectedStl() string {
1156 if stl := ctx.mod.stl; stl != nil {
1157 return stl.Properties.SelectedStl
1158 }
1159 return ""
1160}
1161
Ivan Lozanobd721262018-11-27 14:33:03 -08001162func (ctx *moduleContextImpl) useClangLld(actx ModuleContext) bool {
1163 return ctx.mod.linker.useClangLld(actx)
1164}
1165
Colin Crossce75d2c2016-10-06 16:12:58 -07001166func (ctx *moduleContextImpl) baseModuleName() string {
1167 return ctx.mod.ModuleBase.BaseModuleName()
1168}
1169
Logan Chienf3511742017-10-31 18:04:35 +08001170func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
1171 return ctx.mod.getVndkExtendsModuleName()
1172}
1173
Logan Chiene274fc92019-12-03 11:18:32 -08001174func (ctx *moduleContextImpl) isForPlatform() bool {
1175 return ctx.mod.IsForPlatform()
1176}
1177
Jiyong Park58e364a2019-01-19 19:24:06 +09001178func (ctx *moduleContextImpl) apexName() string {
1179 return ctx.mod.ApexName()
Jiyong Park25fc6a92018-11-18 18:02:45 +09001180}
1181
Jiyong Parkb0788572018-12-20 22:10:17 +09001182func (ctx *moduleContextImpl) hasStubsVariants() bool {
1183 return ctx.mod.HasStubsVariants()
1184}
1185
1186func (ctx *moduleContextImpl) isStubs() bool {
1187 return ctx.mod.IsStubs()
1188}
1189
Jiyong Parka4b9dd02019-01-16 22:53:13 +09001190func (ctx *moduleContextImpl) bootstrap() bool {
1191 return ctx.mod.bootstrap()
1192}
1193
Pirama Arumuga Nainar65c95ff2019-03-25 10:21:31 -07001194func (ctx *moduleContextImpl) nativeCoverage() bool {
1195 return ctx.mod.nativeCoverage()
1196}
1197
Colin Cross635c3b02016-05-18 15:37:25 -07001198func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -08001199 return &Module{
1200 hod: hod,
1201 multilib: multilib,
1202 }
1203}
1204
Colin Cross635c3b02016-05-18 15:37:25 -07001205func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -08001206 module := newBaseModule(hod, multilib)
Dan Willemsena03cf6d2016-09-26 15:45:04 -07001207 module.features = []feature{
1208 &tidyFeature{},
1209 }
Colin Crossa8e07cc2016-04-04 15:07:06 -07001210 module.stl = &stl{}
Colin Cross16b23492016-01-06 14:41:07 -08001211 module.sanitize = &sanitize{}
Dan Willemsen581341d2017-02-09 16:16:31 -08001212 module.coverage = &coverage{}
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001213 module.sabi = &sabi{}
Justin Yun8effde42017-06-23 19:24:43 +09001214 module.vndkdep = &vndkdep{}
Stephen Craneba090d12017-05-09 15:44:35 -07001215 module.lto = &lto{}
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -07001216 module.pgo = &pgo{}
Colin Crossca860ac2016-01-04 14:34:37 -08001217 return module
1218}
1219
Colin Crossce75d2c2016-10-06 16:12:58 -07001220func (c *Module) Prebuilt() *android.Prebuilt {
1221 if p, ok := c.linker.(prebuiltLinkerInterface); ok {
1222 return p.prebuilt()
1223 }
1224 return nil
1225}
1226
1227func (c *Module) Name() string {
1228 name := c.ModuleBase.Name()
Dan Willemsen01a90592017-04-07 15:21:13 -07001229 if p, ok := c.linker.(interface {
1230 Name(string) string
1231 }); ok {
Colin Crossce75d2c2016-10-06 16:12:58 -07001232 name = p.Name(name)
1233 }
1234 return name
1235}
1236
Alex Light3d673592019-01-18 14:37:31 -08001237func (c *Module) Symlinks() []string {
1238 if p, ok := c.installer.(interface {
1239 symlinkList() []string
1240 }); ok {
1241 return p.symlinkList()
1242 }
1243 return nil
1244}
1245
Jeff Gaston294356f2017-09-27 17:05:30 -07001246// orderDeps reorders dependencies into a list such that if module A depends on B, then
1247// A will precede B in the resultant list.
1248// This is convenient for passing into a linker.
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001249// Note that directSharedDeps should be the analogous static library for each shared lib dep
1250func orderDeps(directStaticDeps []android.Path, directSharedDeps []android.Path, allTransitiveDeps map[android.Path][]android.Path) (orderedAllDeps []android.Path, orderedDeclaredDeps []android.Path) {
Jeff Gaston294356f2017-09-27 17:05:30 -07001251 // If A depends on B, then
1252 // Every list containing A will also contain B later in the list
1253 // So, after concatenating all lists, the final instance of B will have come from the same
1254 // original list as the final instance of A
1255 // So, the final instance of B will be later in the concatenation than the final A
1256 // So, keeping only the final instance of A and of B ensures that A is earlier in the output
1257 // list than B
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001258 for _, dep := range directStaticDeps {
Jeff Gaston294356f2017-09-27 17:05:30 -07001259 orderedAllDeps = append(orderedAllDeps, dep)
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001260 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
1261 }
1262 for _, dep := range directSharedDeps {
1263 orderedAllDeps = append(orderedAllDeps, dep)
1264 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
Jeff Gaston294356f2017-09-27 17:05:30 -07001265 }
1266
Colin Crossb6715442017-10-24 11:13:31 -07001267 orderedAllDeps = android.LastUniquePaths(orderedAllDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -07001268
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001269 // We don't want to add any new dependencies into directStaticDeps (to allow the caller to
Jeff Gaston294356f2017-09-27 17:05:30 -07001270 // intentionally exclude or replace any unwanted transitive dependencies), so we limit the
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001271 // resultant list to only what the caller has chosen to include in directStaticDeps
1272 _, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -07001273
1274 return orderedAllDeps, orderedDeclaredDeps
1275}
1276
Ivan Lozano183a3212019-10-18 14:18:45 -07001277func orderStaticModuleDeps(module LinkableInterface, staticDeps []LinkableInterface, sharedDeps []LinkableInterface) (results []android.Path) {
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001278 // convert Module to Path
Ivan Lozano183a3212019-10-18 14:18:45 -07001279 var depsInLinkOrder []android.Path
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001280 allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps))
1281 staticDepFiles := []android.Path{}
1282 for _, dep := range staticDeps {
Nicolas Geoffray0b787662020-02-04 18:27:55 +00001283 // The OutputFile may not be valid for a variant not present, and the AllowMissingDependencies flag is set.
1284 if dep.OutputFile().Valid() {
1285 allTransitiveDeps[dep.OutputFile().Path()] = dep.GetDepsInLinkOrder()
1286 staticDepFiles = append(staticDepFiles, dep.OutputFile().Path())
1287 }
Jeff Gaston294356f2017-09-27 17:05:30 -07001288 }
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001289 sharedDepFiles := []android.Path{}
1290 for _, sharedDep := range sharedDeps {
Ivan Lozano183a3212019-10-18 14:18:45 -07001291 if sharedDep.HasStaticVariant() {
1292 staticAnalogue := sharedDep.GetStaticVariant()
1293 allTransitiveDeps[staticAnalogue.OutputFile().Path()] = staticAnalogue.GetDepsInLinkOrder()
1294 sharedDepFiles = append(sharedDepFiles, staticAnalogue.OutputFile().Path())
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001295 }
Jeff Gaston294356f2017-09-27 17:05:30 -07001296 }
1297
1298 // reorder the dependencies based on transitive dependencies
Ivan Lozano183a3212019-10-18 14:18:45 -07001299 depsInLinkOrder, results = orderDeps(staticDepFiles, sharedDepFiles, allTransitiveDeps)
1300 module.SetDepsInLinkOrder(depsInLinkOrder)
Jeff Gaston294356f2017-09-27 17:05:30 -07001301
1302 return results
Jeff Gaston294356f2017-09-27 17:05:30 -07001303}
1304
Roland Levillainf89cd092019-07-29 16:22:59 +01001305func (c *Module) IsTestPerSrcAllTestsVariation() bool {
1306 test, ok := c.linker.(testPerSrc)
1307 return ok && test.isAllTestsVariation()
1308}
1309
Justin Yun5f7f7e82019-11-18 19:52:14 +09001310func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string {
1311 // Returns the name suffix for product and vendor variants. If the VNDK version is not
1312 // "current", it will append the VNDK version to the name suffix.
1313 var vndkVersion string
1314 var nameSuffix string
1315 if c.inProduct() {
1316 vndkVersion = ctx.DeviceConfig().ProductVndkVersion()
1317 nameSuffix = productSuffix
1318 } else {
1319 vndkVersion = ctx.DeviceConfig().VndkVersion()
1320 nameSuffix = vendorSuffix
1321 }
1322 if vndkVersion == "current" {
1323 vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
1324 }
1325 if c.Properties.VndkVersion != vndkVersion {
1326 // add version suffix only if the module is using different vndk version than the
1327 // version in product or vendor partition.
1328 nameSuffix += "." + c.Properties.VndkVersion
1329 }
1330 return nameSuffix
1331}
1332
Colin Cross635c3b02016-05-18 15:37:25 -07001333func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
Roland Levillainf2fad972019-06-28 15:41:19 +01001334 // Handle the case of a test module split by `test_per_src` mutator.
Roland Levillainf89cd092019-07-29 16:22:59 +01001335 //
1336 // The `test_per_src` mutator adds an extra variation named "", depending on all the other
1337 // `test_per_src` variations of the test module. Set `outputFile` to an empty path for this
1338 // module and return early, as this module does not produce an output file per se.
1339 if c.IsTestPerSrcAllTestsVariation() {
1340 c.outputFile = android.OptionalPath{}
1341 return
Roland Levillainf2fad972019-06-28 15:41:19 +01001342 }
1343
Jooyung Han38002912019-05-16 04:01:54 +09001344 c.makeLinkType = c.getMakeLinkType(actx)
Inseob Kim9516ee92019-05-09 10:56:13 +09001345
Inseob Kim64c43952019-08-26 16:52:35 +09001346 c.Properties.SubName = ""
1347
1348 if c.Target().NativeBridge == android.NativeBridgeEnabled {
1349 c.Properties.SubName += nativeBridgeSuffix
1350 }
1351
Justin Yun5f7f7e82019-11-18 19:52:14 +09001352 _, llndk := c.linker.(*llndkStubDecorator)
1353 _, llndkHeader := c.linker.(*llndkHeadersDecorator)
1354 if llndk || llndkHeader || (c.UseVndk() && c.HasVendorVariant()) {
1355 // .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
1356 // added for product variant only when we have vendor and product variants with core
1357 // variant. The suffix is not added for vendor-only or product-only module.
1358 c.Properties.SubName += c.getNameSuffixWithVndkVersion(actx)
1359 } else if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
Inseob Kim64c43952019-08-26 16:52:35 +09001360 // .vendor suffix is added for backward compatibility with VNDK snapshot whose names with
1361 // such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
1362 c.Properties.SubName += vendorSuffix
Yifan Hong1b3348d2020-01-21 15:53:22 -08001363 } else if c.InRamdisk() && !c.OnlyInRamdisk() {
1364 c.Properties.SubName += ramdiskSuffix
Ivan Lozano52767be2019-10-18 14:49:46 -07001365 } else if c.InRecovery() && !c.OnlyInRecovery() {
Inseob Kim64c43952019-08-26 16:52:35 +09001366 c.Properties.SubName += recoverySuffix
1367 }
1368
Colin Crossca860ac2016-01-04 14:34:37 -08001369 ctx := &moduleContext{
Colin Cross635c3b02016-05-18 15:37:25 -07001370 ModuleContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -08001371 moduleContextImpl: moduleContextImpl{
1372 mod: c,
1373 },
1374 }
1375 ctx.ctx = ctx
1376
Colin Crossf18e1102017-11-16 14:33:08 -08001377 deps := c.depsToPaths(ctx)
1378 if ctx.Failed() {
1379 return
1380 }
1381
Dan Willemsen8536d6b2018-10-07 20:54:34 -07001382 if c.Properties.Clang != nil && *c.Properties.Clang == false {
1383 ctx.PropertyErrorf("clang", "false (GCC) is no longer supported")
1384 }
1385
Colin Crossca860ac2016-01-04 14:34:37 -08001386 flags := Flags{
1387 Toolchain: c.toolchain(ctx),
Sasha Smundak2a4549e2018-11-05 16:49:08 -08001388 EmitXrefs: ctx.Config().EmitXrefRules(),
Colin Crossca860ac2016-01-04 14:34:37 -08001389 }
Colin Crossca860ac2016-01-04 14:34:37 -08001390 if c.compiler != nil {
Colin Crossf18e1102017-11-16 14:33:08 -08001391 flags = c.compiler.compilerFlags(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -08001392 }
1393 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -07001394 flags = c.linker.linkerFlags(ctx, flags)
Colin Crossca860ac2016-01-04 14:34:37 -08001395 }
Colin Crossa8e07cc2016-04-04 15:07:06 -07001396 if c.stl != nil {
1397 flags = c.stl.flags(ctx, flags)
1398 }
Colin Cross16b23492016-01-06 14:41:07 -08001399 if c.sanitize != nil {
1400 flags = c.sanitize.flags(ctx, flags)
1401 }
Dan Willemsen581341d2017-02-09 16:16:31 -08001402 if c.coverage != nil {
Pirama Arumuga Nainar82fe59b2019-07-02 14:55:35 -07001403 flags, deps = c.coverage.flags(ctx, flags, deps)
Dan Willemsen581341d2017-02-09 16:16:31 -08001404 }
Stephen Craneba090d12017-05-09 15:44:35 -07001405 if c.lto != nil {
1406 flags = c.lto.flags(ctx, flags)
1407 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -07001408 if c.pgo != nil {
1409 flags = c.pgo.flags(ctx, flags)
1410 }
Colin Crossca860ac2016-01-04 14:34:37 -08001411 for _, feature := range c.features {
1412 flags = feature.flags(ctx, flags)
1413 }
Colin Cross3f40fa42015-01-30 17:27:36 -08001414 if ctx.Failed() {
1415 return
1416 }
1417
Colin Cross4af21ed2019-11-04 09:37:55 -08001418 flags.Local.CFlags, _ = filterList(flags.Local.CFlags, config.IllegalFlags)
1419 flags.Local.CppFlags, _ = filterList(flags.Local.CppFlags, config.IllegalFlags)
1420 flags.Local.ConlyFlags, _ = filterList(flags.Local.ConlyFlags, config.IllegalFlags)
Colin Cross3f40fa42015-01-30 17:27:36 -08001421
Colin Cross4af21ed2019-11-04 09:37:55 -08001422 flags.Local.CommonFlags = append(flags.Local.CommonFlags, deps.Flags...)
Inseob Kim69378442019-06-03 19:10:47 +09001423
1424 for _, dir := range deps.IncludeDirs {
Colin Cross4af21ed2019-11-04 09:37:55 -08001425 flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +09001426 }
1427 for _, dir := range deps.SystemIncludeDirs {
Colin Cross4af21ed2019-11-04 09:37:55 -08001428 flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-isystem "+dir.String())
Inseob Kim69378442019-06-03 19:10:47 +09001429 }
1430
Fabien Sanglardd61f1f42017-01-10 16:21:22 -08001431 c.flags = flags
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -07001432 // We need access to all the flags seen by a source file.
1433 if c.sabi != nil {
1434 flags = c.sabi.flags(ctx, flags)
1435 }
Dan Willemsen98ab3112019-08-27 21:20:40 -07001436
Colin Cross4af21ed2019-11-04 09:37:55 -08001437 flags.AssemblerWithCpp = inList("-xassembler-with-cpp", flags.Local.AsFlags)
Dan Willemsen98ab3112019-08-27 21:20:40 -07001438
Colin Crossca860ac2016-01-04 14:34:37 -08001439 // Optimization to reduce size of build.ninja
1440 // Replace the long list of flags for each file with a module-local variable
Colin Cross4af21ed2019-11-04 09:37:55 -08001441 ctx.Variable(pctx, "cflags", strings.Join(flags.Local.CFlags, " "))
1442 ctx.Variable(pctx, "cppflags", strings.Join(flags.Local.CppFlags, " "))
1443 ctx.Variable(pctx, "asflags", strings.Join(flags.Local.AsFlags, " "))
1444 flags.Local.CFlags = []string{"$cflags"}
1445 flags.Local.CppFlags = []string{"$cppflags"}
1446 flags.Local.AsFlags = []string{"$asflags"}
Colin Crossca860ac2016-01-04 14:34:37 -08001447
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001448 var objs Objects
Colin Crossca860ac2016-01-04 14:34:37 -08001449 if c.compiler != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001450 objs = c.compiler.compile(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -08001451 if ctx.Failed() {
1452 return
1453 }
Sasha Smundak2a4549e2018-11-05 16:49:08 -08001454 c.kytheFiles = objs.kytheFiles
Colin Cross3f40fa42015-01-30 17:27:36 -08001455 }
1456
Colin Crossca860ac2016-01-04 14:34:37 -08001457 if c.linker != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001458 outputFile := c.linker.link(ctx, flags, deps, objs)
Colin Crossca860ac2016-01-04 14:34:37 -08001459 if ctx.Failed() {
1460 return
1461 }
Colin Cross635c3b02016-05-18 15:37:25 -07001462 c.outputFile = android.OptionalPathForPath(outputFile)
Jiyong Parkb0788572018-12-20 22:10:17 +09001463
1464 // If a lib is directly included in any of the APEXes, unhide the stubs
1465 // variant having the latest version gets visible to make. In addition,
1466 // the non-stubs variant is renamed to <libname>.bootstrap. This is to
1467 // force anything in the make world to link against the stubs library.
1468 // (unless it is explicitly referenced via .bootstrap suffix or the
1469 // module is marked with 'bootstrap: true').
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +00001470 if c.HasStubsVariants() &&
Yifan Hong1b3348d2020-01-21 15:53:22 -08001471 android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) && !c.InRamdisk() &&
Ivan Lozano52767be2019-10-18 14:49:46 -07001472 !c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() &&
Pirama Arumuga Nainar1acd4472018-12-10 15:12:40 -08001473 c.IsStubs() {
Jiyong Parkb0788572018-12-20 22:10:17 +09001474 c.Properties.HideFromMake = false // unhide
1475 // Note: this is still non-installable
1476 }
Inseob Kimeda2e9c2020-03-03 22:06:32 +09001477
1478 // glob exported headers for snapshot, if BOARD_VNDK_VERSION is current.
1479 if i, ok := c.linker.(snapshotLibraryInterface); ok && ctx.DeviceConfig().VndkVersion() == "current" {
1480 if isSnapshotAware(ctx, c) {
1481 i.collectHeadersForSnapshot(ctx)
1482 }
1483 }
Colin Crossce75d2c2016-10-06 16:12:58 -07001484 }
Colin Cross5049f022015-03-18 13:28:46 -07001485
Inseob Kim1f086e22019-05-09 13:29:15 +09001486 if c.installable() {
Colin Crossce75d2c2016-10-06 16:12:58 -07001487 c.installer.install(ctx, c.outputFile.Path())
1488 if ctx.Failed() {
1489 return
Colin Crossca860ac2016-01-04 14:34:37 -08001490 }
Dan Albertc403f7c2015-03-18 14:01:18 -07001491 }
Colin Cross3f40fa42015-01-30 17:27:36 -08001492}
1493
Colin Cross0ea8ba82019-06-06 14:33:29 -07001494func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -08001495 if c.cachedToolchain == nil {
Colin Crossb98c8b02016-07-29 13:44:28 -07001496 c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
Colin Cross3f40fa42015-01-30 17:27:36 -08001497 }
Colin Crossca860ac2016-01-04 14:34:37 -08001498 return c.cachedToolchain
Colin Cross3f40fa42015-01-30 17:27:36 -08001499}
1500
Colin Crossca860ac2016-01-04 14:34:37 -08001501func (c *Module) begin(ctx BaseModuleContext) {
1502 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -07001503 c.compiler.compilerInit(ctx)
Colin Cross21b9a242015-03-24 14:15:58 -07001504 }
Colin Crossca860ac2016-01-04 14:34:37 -08001505 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -07001506 c.linker.linkerInit(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -08001507 }
Colin Crossa8e07cc2016-04-04 15:07:06 -07001508 if c.stl != nil {
1509 c.stl.begin(ctx)
1510 }
Colin Cross16b23492016-01-06 14:41:07 -08001511 if c.sanitize != nil {
1512 c.sanitize.begin(ctx)
1513 }
Dan Willemsen581341d2017-02-09 16:16:31 -08001514 if c.coverage != nil {
1515 c.coverage.begin(ctx)
1516 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001517 if c.sabi != nil {
1518 c.sabi.begin(ctx)
1519 }
Justin Yun8effde42017-06-23 19:24:43 +09001520 if c.vndkdep != nil {
1521 c.vndkdep.begin(ctx)
1522 }
Stephen Craneba090d12017-05-09 15:44:35 -07001523 if c.lto != nil {
1524 c.lto.begin(ctx)
1525 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -07001526 if c.pgo != nil {
1527 c.pgo.begin(ctx)
1528 }
Colin Crossca860ac2016-01-04 14:34:37 -08001529 for _, feature := range c.features {
1530 feature.begin(ctx)
1531 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001532 if ctx.useSdk() {
Dan Albertf5415d72017-08-17 16:19:59 -07001533 version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
Dan Albert7fa7b2e2016-08-05 16:37:52 -07001534 if err != nil {
1535 ctx.PropertyErrorf("sdk_version", err.Error())
1536 }
Nan Zhang0007d812017-11-07 10:57:05 -08001537 c.Properties.Sdk_version = StringPtr(version)
Dan Albert7fa7b2e2016-08-05 16:37:52 -07001538 }
Colin Crossca860ac2016-01-04 14:34:37 -08001539}
1540
Colin Cross37047f12016-12-13 17:06:13 -08001541func (c *Module) deps(ctx DepsContext) Deps {
Colin Crossc99deeb2016-04-11 15:06:20 -07001542 deps := Deps{}
1543
1544 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -07001545 deps = c.compiler.compilerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -07001546 }
Pirama Arumuga Nainar0b882f02018-04-23 22:44:39 +00001547 // Add the PGO dependency (the clang_rt.profile runtime library), which
1548 // sometimes depends on symbols from libgcc, before libgcc gets added
1549 // in linkerDeps().
Pirama Arumuga Nainar49b53d52017-10-04 16:47:29 -07001550 if c.pgo != nil {
1551 deps = c.pgo.deps(ctx, deps)
1552 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001553 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -07001554 deps = c.linker.linkerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -07001555 }
Colin Crossa8e07cc2016-04-04 15:07:06 -07001556 if c.stl != nil {
1557 deps = c.stl.deps(ctx, deps)
1558 }
Colin Cross16b23492016-01-06 14:41:07 -08001559 if c.sanitize != nil {
1560 deps = c.sanitize.deps(ctx, deps)
1561 }
Pirama Arumuga Nainar0b882f02018-04-23 22:44:39 +00001562 if c.coverage != nil {
1563 deps = c.coverage.deps(ctx, deps)
1564 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001565 if c.sabi != nil {
1566 deps = c.sabi.deps(ctx, deps)
1567 }
Justin Yun8effde42017-06-23 19:24:43 +09001568 if c.vndkdep != nil {
1569 deps = c.vndkdep.deps(ctx, deps)
1570 }
Stephen Craneba090d12017-05-09 15:44:35 -07001571 if c.lto != nil {
1572 deps = c.lto.deps(ctx, deps)
1573 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001574 for _, feature := range c.features {
1575 deps = feature.deps(ctx, deps)
1576 }
1577
Colin Crossb6715442017-10-24 11:13:31 -07001578 deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
1579 deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
1580 deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
1581 deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
1582 deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
1583 deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
Logan Chien43d34c32017-12-20 01:17:32 +08001584 deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
Colin Crossc99deeb2016-04-11 15:06:20 -07001585
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001586 for _, lib := range deps.ReexportSharedLibHeaders {
1587 if !inList(lib, deps.SharedLibs) {
1588 ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
1589 }
1590 }
1591
1592 for _, lib := range deps.ReexportStaticLibHeaders {
1593 if !inList(lib, deps.StaticLibs) {
1594 ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs: '%s'", lib)
1595 }
1596 }
1597
Colin Cross5950f382016-12-13 12:50:57 -08001598 for _, lib := range deps.ReexportHeaderLibHeaders {
1599 if !inList(lib, deps.HeaderLibs) {
1600 ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib)
1601 }
1602 }
1603
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001604 for _, gen := range deps.ReexportGeneratedHeaders {
1605 if !inList(gen, deps.GeneratedHeaders) {
1606 ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen)
1607 }
1608 }
1609
Colin Crossc99deeb2016-04-11 15:06:20 -07001610 return deps
1611}
1612
Dan Albert7e9d2952016-08-04 13:02:36 -07001613func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
Colin Crossca860ac2016-01-04 14:34:37 -08001614 ctx := &baseModuleContext{
Colin Cross0ea8ba82019-06-06 14:33:29 -07001615 BaseModuleContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -08001616 moduleContextImpl: moduleContextImpl{
1617 mod: c,
1618 },
1619 }
1620 ctx.ctx = ctx
1621
Colin Crossca860ac2016-01-04 14:34:37 -08001622 c.begin(ctx)
Dan Albert7e9d2952016-08-04 13:02:36 -07001623}
1624
Jiyong Park7ed9de32018-10-15 22:25:07 +09001625// Split name#version into name and version
Jiyong Park73c54ee2019-10-22 20:31:18 +09001626func StubsLibNameAndVersion(name string) (string, string) {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001627 if sharp := strings.LastIndex(name, "#"); sharp != -1 && sharp != len(name)-1 {
1628 version := name[sharp+1:]
1629 libname := name[:sharp]
1630 return libname, version
1631 }
1632 return name, ""
1633}
1634
Colin Cross1e676be2016-10-12 14:38:15 -07001635func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
Inseob Kimeec88e12020-01-22 11:11:29 +09001636 if !c.Enabled() {
1637 return
1638 }
1639
Colin Cross37047f12016-12-13 17:06:13 -08001640 ctx := &depsContext{
1641 BottomUpMutatorContext: actx,
Dan Albert7e9d2952016-08-04 13:02:36 -07001642 moduleContextImpl: moduleContextImpl{
1643 mod: c,
1644 },
1645 }
1646 ctx.ctx = ctx
Colin Crossca860ac2016-01-04 14:34:37 -08001647
Colin Crossc99deeb2016-04-11 15:06:20 -07001648 deps := c.deps(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -08001649
Dan Albert914449f2016-06-17 16:45:24 -07001650 variantNdkLibs := []string{}
1651 variantLateNdkLibs := []string{}
Dan Willemsenb916b802017-03-19 13:44:32 -07001652 if ctx.Os() == android.Android {
Dan Albert914449f2016-06-17 16:45:24 -07001653 version := ctx.sdkVersion()
Dan Willemsen72d39932016-07-08 23:23:48 -07001654
Inseob Kimeec88e12020-01-22 11:11:29 +09001655 // rewriteLibs takes a list of names of shared libraries and scans it for three types
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001656 // of names:
Dan Albert914449f2016-06-17 16:45:24 -07001657 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001658 // 1. Name of an NDK library that refers to a prebuilt module.
1659 // For each of these, it adds the name of the prebuilt module (which will be in
1660 // prebuilts/ndk) to the list of nonvariant libs.
1661 // 2. Name of an NDK library that refers to an ndk_library module.
1662 // For each of these, it adds the name of the ndk_library module to the list of
1663 // variant libs.
1664 // 3. Anything else (so anything that isn't an NDK library).
1665 // It adds these to the nonvariantLibs list.
Dan Albert914449f2016-06-17 16:45:24 -07001666 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001667 // The caller can then know to add the variantLibs dependencies differently from the
1668 // nonvariantLibs
Inseob Kim9516ee92019-05-09 10:56:13 +09001669
Inseob Kim9516ee92019-05-09 10:56:13 +09001670 vendorPublicLibraries := vendorPublicLibraries(actx.Config())
Inseob Kimeec88e12020-01-22 11:11:29 +09001671 vendorSnapshotSharedLibs := vendorSnapshotSharedLibs(actx.Config())
1672
1673 rewriteVendorLibs := func(lib string) string {
1674 if isLlndkLibrary(lib, ctx.Config()) {
1675 return lib + llndkLibrarySuffix
1676 }
1677
1678 // only modules with BOARD_VNDK_VERSION uses snapshot.
1679 if c.VndkVersion() != actx.DeviceConfig().VndkVersion() {
1680 return lib
1681 }
1682
1683 if snapshot, ok := vendorSnapshotSharedLibs.get(lib, actx.Arch().ArchType); ok {
1684 return snapshot
1685 }
1686
1687 return lib
1688 }
1689
1690 rewriteLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001691 variantLibs = []string{}
1692 nonvariantLibs = []string{}
Dan Albert914449f2016-06-17 16:45:24 -07001693 for _, entry := range list {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001694 // strip #version suffix out
Jiyong Park73c54ee2019-10-22 20:31:18 +09001695 name, _ := StubsLibNameAndVersion(entry)
Jiyong Park7ed9de32018-10-15 22:25:07 +09001696 if ctx.useSdk() && inList(name, ndkPrebuiltSharedLibraries) {
1697 if !inList(name, ndkMigratedLibs) {
1698 nonvariantLibs = append(nonvariantLibs, name+".ndk."+version)
Dan Albert914449f2016-06-17 16:45:24 -07001699 } else {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001700 variantLibs = append(variantLibs, name+ndkLibrarySuffix)
Dan Albert914449f2016-06-17 16:45:24 -07001701 }
Inseob Kimeec88e12020-01-22 11:11:29 +09001702 } else if ctx.useVndk() {
1703 nonvariantLibs = append(nonvariantLibs, rewriteVendorLibs(entry))
Inseob Kim9516ee92019-05-09 10:56:13 +09001704 } else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001705 vendorPublicLib := name + vendorPublicLibrarySuffix
Jiyong Park374510b2018-03-19 18:23:01 +09001706 if actx.OtherModuleExists(vendorPublicLib) {
1707 nonvariantLibs = append(nonvariantLibs, vendorPublicLib)
1708 } else {
1709 // This can happen if vendor_public_library module is defined in a
1710 // namespace that isn't visible to the current module. In that case,
1711 // link to the original library.
Jiyong Park7ed9de32018-10-15 22:25:07 +09001712 nonvariantLibs = append(nonvariantLibs, name)
Jiyong Park374510b2018-03-19 18:23:01 +09001713 }
Dan Albert914449f2016-06-17 16:45:24 -07001714 } else {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001715 // put name#version back
Dan Willemsen7cbf5f82017-03-28 00:08:30 -07001716 nonvariantLibs = append(nonvariantLibs, entry)
Dan Willemsen72d39932016-07-08 23:23:48 -07001717 }
1718 }
Dan Albert914449f2016-06-17 16:45:24 -07001719 return nonvariantLibs, variantLibs
Dan Willemsen72d39932016-07-08 23:23:48 -07001720 }
1721
Inseob Kimeec88e12020-01-22 11:11:29 +09001722 deps.SharedLibs, variantNdkLibs = rewriteLibs(deps.SharedLibs)
1723 deps.LateSharedLibs, variantLateNdkLibs = rewriteLibs(deps.LateSharedLibs)
1724 deps.ReexportSharedLibHeaders, _ = rewriteLibs(deps.ReexportSharedLibHeaders)
1725 if ctx.useVndk() {
1726 for idx, lib := range deps.RuntimeLibs {
1727 deps.RuntimeLibs[idx] = rewriteVendorLibs(lib)
1728 }
1729 }
Dan Willemsen72d39932016-07-08 23:23:48 -07001730 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001731
Jiyong Park7e636d02019-01-28 16:16:54 +09001732 buildStubs := false
Jiyong Park7ed9de32018-10-15 22:25:07 +09001733 if c.linker != nil {
1734 if library, ok := c.linker.(*libraryDecorator); ok {
1735 if library.buildStubs() {
Jiyong Park7e636d02019-01-28 16:16:54 +09001736 buildStubs = true
Jiyong Park7ed9de32018-10-15 22:25:07 +09001737 }
1738 }
1739 }
1740
Inseob Kimeec88e12020-01-22 11:11:29 +09001741 rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
1742 // only modules with BOARD_VNDK_VERSION uses snapshot.
1743 if c.VndkVersion() != actx.DeviceConfig().VndkVersion() {
1744 return lib
1745 }
1746
1747 if snapshot, ok := snapshotMap.get(lib, actx.Arch().ArchType); ok {
1748 return snapshot
1749 }
1750
1751 return lib
1752 }
1753
1754 vendorSnapshotHeaderLibs := vendorSnapshotHeaderLibs(actx.Config())
Colin Cross32ec36c2016-12-15 07:39:51 -08001755 for _, lib := range deps.HeaderLibs {
1756 depTag := headerDepTag
1757 if inList(lib, deps.ReexportHeaderLibHeaders) {
1758 depTag = headerExportDepTag
1759 }
Inseob Kimeec88e12020-01-22 11:11:29 +09001760
1761 lib = rewriteSnapshotLibs(lib, vendorSnapshotHeaderLibs)
1762
Jiyong Park7e636d02019-01-28 16:16:54 +09001763 if buildStubs {
Colin Cross7228ecd2019-11-18 16:00:16 -08001764 actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001765 depTag, lib)
Jiyong Park7e636d02019-01-28 16:16:54 +09001766 } else {
1767 actx.AddVariationDependencies(nil, depTag, lib)
1768 }
1769 }
1770
1771 if buildStubs {
1772 // Stubs lib does not have dependency to other static/shared libraries.
1773 // Don't proceed.
1774 return
Colin Cross32ec36c2016-12-15 07:39:51 -08001775 }
Colin Cross5950f382016-12-13 12:50:57 -08001776
Inseob Kimc0907f12019-02-08 21:00:45 +09001777 syspropImplLibraries := syspropImplLibraries(actx.Config())
Inseob Kimeec88e12020-01-22 11:11:29 +09001778 vendorSnapshotStaticLibs := vendorSnapshotStaticLibs(actx.Config())
Inseob Kimc0907f12019-02-08 21:00:45 +09001779
Jiyong Park5d1598f2019-02-25 22:14:17 +09001780 for _, lib := range deps.WholeStaticLibs {
1781 depTag := wholeStaticDepTag
1782 if impl, ok := syspropImplLibraries[lib]; ok {
1783 lib = impl
1784 }
Inseob Kimeec88e12020-01-22 11:11:29 +09001785
1786 lib = rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs)
1787
Jiyong Park5d1598f2019-02-25 22:14:17 +09001788 actx.AddVariationDependencies([]blueprint.Variation{
1789 {Mutator: "link", Variation: "static"},
1790 }, depTag, lib)
1791 }
1792
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001793 for _, lib := range deps.StaticLibs {
Ivan Lozano183a3212019-10-18 14:18:45 -07001794 depTag := StaticDepTag
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001795 if inList(lib, deps.ReexportStaticLibHeaders) {
1796 depTag = staticExportDepTag
1797 }
Inseob Kimc0907f12019-02-08 21:00:45 +09001798
1799 if impl, ok := syspropImplLibraries[lib]; ok {
1800 lib = impl
1801 }
1802
Inseob Kimeec88e12020-01-22 11:11:29 +09001803 lib = rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs)
1804
Dan Willemsen59339a22018-07-22 21:18:45 -07001805 actx.AddVariationDependencies([]blueprint.Variation{
1806 {Mutator: "link", Variation: "static"},
1807 }, depTag, lib)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001808 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001809
Peter Collingbournedc4f9862020-02-12 17:13:25 -08001810 if deps.StaticUnwinderIfLegacy && ctx.Config().UnbundledBuild() {
1811 actx.AddVariationDependencies([]blueprint.Variation{
1812 {Mutator: "link", Variation: "static"},
1813 }, staticUnwinderDepTag, staticUnwinder(actx))
1814 }
1815
Inseob Kimeec88e12020-01-22 11:11:29 +09001816 for _, lib := range deps.LateStaticLibs {
1817 actx.AddVariationDependencies([]blueprint.Variation{
1818 {Mutator: "link", Variation: "static"},
1819 }, lateStaticDepTag, rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs))
1820 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001821
Ivan Lozano183a3212019-10-18 14:18:45 -07001822 addSharedLibDependencies := func(depTag DependencyTag, name string, version string) {
Jiyong Park25fc6a92018-11-18 18:02:45 +09001823 var variations []blueprint.Variation
1824 variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
Yifan Hong1b3348d2020-01-21 15:53:22 -08001825 versionVariantAvail := !ctx.useVndk() && !c.InRecovery() && !c.InRamdisk()
Jiyong Park25fc6a92018-11-18 18:02:45 +09001826 if version != "" && versionVariantAvail {
1827 // Version is explicitly specified. i.e. libFoo#30
1828 variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
Ivan Lozano183a3212019-10-18 14:18:45 -07001829 depTag.ExplicitlyVersioned = true
Jiyong Park25fc6a92018-11-18 18:02:45 +09001830 }
1831 actx.AddVariationDependencies(variations, depTag, name)
1832
Jooyung Han03b51852020-02-26 22:45:42 +09001833 // If the version is not specified, add dependency to all stubs libraries.
Jiyong Park25fc6a92018-11-18 18:02:45 +09001834 // The stubs library will be used when the depending module is built for APEX and
1835 // the dependent module is not in the same APEX.
Jooyung Han03b51852020-02-26 22:45:42 +09001836 if version == "" && versionVariantAvail {
1837 for _, ver := range stubsVersionsFor(actx.Config())[name] {
1838 // Note that depTag.ExplicitlyVersioned is false in this case.
1839 actx.AddVariationDependencies([]blueprint.Variation{
1840 {Mutator: "link", Variation: "shared"},
1841 {Mutator: "version", Variation: ver},
1842 }, depTag, name)
1843 }
Jiyong Park25fc6a92018-11-18 18:02:45 +09001844 }
1845 }
1846
Jiyong Park7ed9de32018-10-15 22:25:07 +09001847 // shared lib names without the #version suffix
1848 var sharedLibNames []string
1849
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001850 for _, lib := range deps.SharedLibs {
Ivan Lozano183a3212019-10-18 14:18:45 -07001851 depTag := SharedDepTag
Jiyong Parkd7536ba2020-01-16 17:14:23 +09001852 if c.static() {
1853 depTag = SharedFromStaticDepTag
1854 }
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001855 if inList(lib, deps.ReexportSharedLibHeaders) {
1856 depTag = sharedExportDepTag
1857 }
Inseob Kimc0907f12019-02-08 21:00:45 +09001858
1859 if impl, ok := syspropImplLibraries[lib]; ok {
1860 lib = impl
1861 }
1862
Jiyong Park73c54ee2019-10-22 20:31:18 +09001863 name, version := StubsLibNameAndVersion(lib)
Inseob Kimc0907f12019-02-08 21:00:45 +09001864 sharedLibNames = append(sharedLibNames, name)
1865
Jiyong Park25fc6a92018-11-18 18:02:45 +09001866 addSharedLibDependencies(depTag, name, version)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001867 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001868
Jiyong Park7ed9de32018-10-15 22:25:07 +09001869 for _, lib := range deps.LateSharedLibs {
Jiyong Park25fc6a92018-11-18 18:02:45 +09001870 if inList(lib, sharedLibNames) {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001871 // This is to handle the case that some of the late shared libs (libc, libdl, libm, ...)
1872 // are added also to SharedLibs with version (e.g., libc#10). If not skipped, we will be
1873 // linking against both the stubs lib and the non-stubs lib at the same time.
1874 continue
1875 }
Jiyong Park25fc6a92018-11-18 18:02:45 +09001876 addSharedLibDependencies(lateSharedDepTag, lib, "")
Jiyong Park7ed9de32018-10-15 22:25:07 +09001877 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001878
Dan Willemsen59339a22018-07-22 21:18:45 -07001879 actx.AddVariationDependencies([]blueprint.Variation{
1880 {Mutator: "link", Variation: "shared"},
1881 }, runtimeDepTag, deps.RuntimeLibs...)
Logan Chien43d34c32017-12-20 01:17:32 +08001882
Colin Cross68861832016-07-08 10:41:41 -07001883 actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...)
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001884
1885 for _, gen := range deps.GeneratedHeaders {
1886 depTag := genHeaderDepTag
1887 if inList(gen, deps.ReexportGeneratedHeaders) {
1888 depTag = genHeaderExportDepTag
1889 }
1890 actx.AddDependency(c, depTag, gen)
1891 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001892
Colin Cross42d48b72018-08-29 14:10:52 -07001893 actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)
Colin Crossc99deeb2016-04-11 15:06:20 -07001894
1895 if deps.CrtBegin != "" {
Ivan Lozano183a3212019-10-18 14:18:45 -07001896 actx.AddVariationDependencies(nil, CrtBeginDepTag, deps.CrtBegin)
Colin Crossca860ac2016-01-04 14:34:37 -08001897 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001898 if deps.CrtEnd != "" {
Ivan Lozano183a3212019-10-18 14:18:45 -07001899 actx.AddVariationDependencies(nil, CrtEndDepTag, deps.CrtEnd)
Colin Cross21b9a242015-03-24 14:15:58 -07001900 }
Dan Willemsena0790e32018-10-12 00:24:23 -07001901 if deps.LinkerFlagsFile != "" {
1902 actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
1903 }
1904 if deps.DynamicLinker != "" {
1905 actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001906 }
Dan Albert914449f2016-06-17 16:45:24 -07001907
1908 version := ctx.sdkVersion()
1909 actx.AddVariationDependencies([]blueprint.Variation{
Dan Willemsen59339a22018-07-22 21:18:45 -07001910 {Mutator: "ndk_api", Variation: version},
1911 {Mutator: "link", Variation: "shared"},
1912 }, ndkStubDepTag, variantNdkLibs...)
Dan Albert914449f2016-06-17 16:45:24 -07001913 actx.AddVariationDependencies([]blueprint.Variation{
Dan Willemsen59339a22018-07-22 21:18:45 -07001914 {Mutator: "ndk_api", Variation: version},
1915 {Mutator: "link", Variation: "shared"},
1916 }, ndkLateStubDepTag, variantLateNdkLibs...)
Logan Chienf3511742017-10-31 18:04:35 +08001917
1918 if vndkdep := c.vndkdep; vndkdep != nil {
1919 if vndkdep.isVndkExt() {
Logan Chienf3511742017-10-31 18:04:35 +08001920 actx.AddVariationDependencies([]blueprint.Variation{
Colin Cross7228ecd2019-11-18 16:00:16 -08001921 c.ImageVariation(),
Dan Willemsen59339a22018-07-22 21:18:45 -07001922 {Mutator: "link", Variation: "shared"},
1923 }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
Logan Chienf3511742017-10-31 18:04:35 +08001924 }
1925 }
Colin Cross6362e272015-10-29 15:25:03 -07001926}
Colin Cross21b9a242015-03-24 14:15:58 -07001927
Colin Crosse40b4ea2018-10-02 22:25:58 -07001928func BeginMutator(ctx android.BottomUpMutatorContext) {
Dan Albert7e9d2952016-08-04 13:02:36 -07001929 if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
1930 c.beginMutator(ctx)
1931 }
1932}
1933
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001934// Whether a module can link to another module, taking into
1935// account NDK linking.
Ivan Lozano52767be2019-10-18 14:49:46 -07001936func checkLinkType(ctx android.ModuleContext, from LinkableInterface, to LinkableInterface, tag DependencyTag) {
1937 if from.Module().Target().Os != android.Android {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001938 // Host code is not restricted
1939 return
1940 }
Ivan Lozano52767be2019-10-18 14:49:46 -07001941
1942 // VNDK is cc.Module supported only for now.
1943 if ccFrom, ok := from.(*Module); ok && from.UseVndk() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001944 // Though vendor code is limited by the vendor mutator,
1945 // each vendor-available module needs to check
1946 // link-type for VNDK.
Ivan Lozano52767be2019-10-18 14:49:46 -07001947 if ccTo, ok := to.(*Module); ok {
1948 if ccFrom.vndkdep != nil {
1949 ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag)
1950 }
1951 } else {
1952 ctx.ModuleErrorf("Attempting to link VNDK cc.Module with unsupported module type")
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001953 }
1954 return
1955 }
Ivan Lozano52767be2019-10-18 14:49:46 -07001956 if from.SdkVersion() == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001957 // Platform code can link to anything
1958 return
1959 }
Yifan Hong1b3348d2020-01-21 15:53:22 -08001960 if from.InRamdisk() {
1961 // Ramdisk code is not NDK
1962 return
1963 }
Ivan Lozano52767be2019-10-18 14:49:46 -07001964 if from.InRecovery() {
Jiyong Parkf9332f12018-02-01 00:54:12 +09001965 // Recovery code is not NDK
1966 return
1967 }
Ivan Lozano52767be2019-10-18 14:49:46 -07001968 if to.ToolchainLibrary() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001969 // These are always allowed
1970 return
1971 }
Ivan Lozano52767be2019-10-18 14:49:46 -07001972 if to.NdkPrebuiltStl() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001973 // These are allowed, but they don't set sdk_version
1974 return
1975 }
Ivan Lozano52767be2019-10-18 14:49:46 -07001976 if to.StubDecorator() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001977 // These aren't real libraries, but are the stub shared libraries that are included in
1978 // the NDK.
1979 return
1980 }
Logan Chien834b9a62019-01-14 15:39:03 +08001981
Ivan Lozano52767be2019-10-18 14:49:46 -07001982 if strings.HasPrefix(ctx.ModuleName(), "libclang_rt.") && to.Module().Name() == "libc++" {
Logan Chien834b9a62019-01-14 15:39:03 +08001983 // Bug: http://b/121358700 - Allow libclang_rt.* shared libraries (with sdk_version)
1984 // to link to libc++ (non-NDK and without sdk_version).
1985 return
1986 }
1987
Ivan Lozano52767be2019-10-18 14:49:46 -07001988 if to.SdkVersion() == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001989 // NDK code linking to platform code is never okay.
1990 ctx.ModuleErrorf("depends on non-NDK-built library %q",
Ivan Lozano52767be2019-10-18 14:49:46 -07001991 ctx.OtherModuleName(to.Module()))
Dan Willemsen155d17c2019-02-06 18:30:02 -08001992 return
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001993 }
1994
1995 // At this point we know we have two NDK libraries, but we need to
1996 // check that we're not linking against anything built against a higher
1997 // API level, as it is only valid to link against older or equivalent
1998 // APIs.
1999
Inseob Kim01a28722018-04-11 09:48:45 +09002000 // Current can link against anything.
Ivan Lozano52767be2019-10-18 14:49:46 -07002001 if from.SdkVersion() != "current" {
Inseob Kim01a28722018-04-11 09:48:45 +09002002 // Otherwise we need to check.
Ivan Lozano52767be2019-10-18 14:49:46 -07002003 if to.SdkVersion() == "current" {
Inseob Kim01a28722018-04-11 09:48:45 +09002004 // Current can't be linked against by anything else.
2005 ctx.ModuleErrorf("links %q built against newer API version %q",
Ivan Lozano52767be2019-10-18 14:49:46 -07002006 ctx.OtherModuleName(to.Module()), "current")
Inseob Kim01a28722018-04-11 09:48:45 +09002007 } else {
Ivan Lozano52767be2019-10-18 14:49:46 -07002008 fromApi, err := strconv.Atoi(from.SdkVersion())
Inseob Kim01a28722018-04-11 09:48:45 +09002009 if err != nil {
2010 ctx.PropertyErrorf("sdk_version",
Inseob Kim34b22832018-04-11 10:13:16 +09002011 "Invalid sdk_version value (must be int or current): %q",
Ivan Lozano52767be2019-10-18 14:49:46 -07002012 from.SdkVersion())
Inseob Kim01a28722018-04-11 09:48:45 +09002013 }
Ivan Lozano52767be2019-10-18 14:49:46 -07002014 toApi, err := strconv.Atoi(to.SdkVersion())
Inseob Kim01a28722018-04-11 09:48:45 +09002015 if err != nil {
2016 ctx.PropertyErrorf("sdk_version",
Inseob Kim34b22832018-04-11 10:13:16 +09002017 "Invalid sdk_version value (must be int or current): %q",
Ivan Lozano52767be2019-10-18 14:49:46 -07002018 to.SdkVersion())
Inseob Kim01a28722018-04-11 09:48:45 +09002019 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002020
Inseob Kim01a28722018-04-11 09:48:45 +09002021 if toApi > fromApi {
2022 ctx.ModuleErrorf("links %q built against newer API version %q",
Ivan Lozano52767be2019-10-18 14:49:46 -07002023 ctx.OtherModuleName(to.Module()), to.SdkVersion())
Inseob Kim01a28722018-04-11 09:48:45 +09002024 }
2025 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002026 }
Dan Albert202fe492017-12-15 13:56:59 -08002027
2028 // Also check that the two STL choices are compatible.
Ivan Lozano52767be2019-10-18 14:49:46 -07002029 fromStl := from.SelectedStl()
2030 toStl := to.SelectedStl()
Dan Albert202fe492017-12-15 13:56:59 -08002031 if fromStl == "" || toStl == "" {
2032 // Libraries that don't use the STL are unrestricted.
Inseob Kimda2171a2018-04-11 15:41:38 +09002033 } else if fromStl == "ndk_system" || toStl == "ndk_system" {
Dan Albert202fe492017-12-15 13:56:59 -08002034 // We can be permissive with the system "STL" since it is only the C++
2035 // ABI layer, but in the future we should make sure that everyone is
2036 // using either libc++ or nothing.
Colin Crossb60190a2018-09-04 16:28:17 -07002037 } else if getNdkStlFamily(from) != getNdkStlFamily(to) {
Dan Albert202fe492017-12-15 13:56:59 -08002038 ctx.ModuleErrorf("uses %q and depends on %q which uses incompatible %q",
Ivan Lozano52767be2019-10-18 14:49:46 -07002039 from.SelectedStl(), ctx.OtherModuleName(to.Module()),
2040 to.SelectedStl())
Dan Albert202fe492017-12-15 13:56:59 -08002041 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002042}
2043
Jiyong Park5fb8c102018-04-09 12:03:06 +09002044// Tests whether the dependent library is okay to be double loaded inside a single process.
Jooyung Hana70f0672019-01-18 15:20:43 +09002045// If a library has a vendor variant and is a (transitive) dependency of an LLNDK library,
2046// it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true
Jiyong Park5fb8c102018-04-09 12:03:06 +09002047// or as vndk-sp (vndk: { enabled: true, support_system_process: true}).
Jooyung Hana70f0672019-01-18 15:20:43 +09002048func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
2049 check := func(child, parent android.Module) bool {
2050 to, ok := child.(*Module)
2051 if !ok {
2052 // follow thru cc.Defaults, etc.
2053 return true
2054 }
Jiyong Park5fb8c102018-04-09 12:03:06 +09002055
Jooyung Hana70f0672019-01-18 15:20:43 +09002056 if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
2057 return false
Jiyong Park5fb8c102018-04-09 12:03:06 +09002058 }
Jooyung Hana70f0672019-01-18 15:20:43 +09002059
2060 // if target lib has no vendor variant, keep checking dependency graph
Ivan Lozano52767be2019-10-18 14:49:46 -07002061 if !to.HasVendorVariant() {
Jooyung Hana70f0672019-01-18 15:20:43 +09002062 return true
Jiyong Park5fb8c102018-04-09 12:03:06 +09002063 }
Jooyung Hana70f0672019-01-18 15:20:43 +09002064
Jooyung Han0302a842019-10-30 18:43:49 +09002065 if to.isVndkSp() || to.isLlndk(ctx.Config()) || Bool(to.VendorProperties.Double_loadable) {
Jooyung Hana70f0672019-01-18 15:20:43 +09002066 return false
2067 }
2068
2069 var stringPath []string
2070 for _, m := range ctx.GetWalkPath() {
2071 stringPath = append(stringPath, m.Name())
2072 }
2073 ctx.ModuleErrorf("links a library %q which is not LL-NDK, "+
2074 "VNDK-SP, or explicitly marked as 'double_loadable:true'. "+
2075 "(dependency: %s)", ctx.OtherModuleName(to), strings.Join(stringPath, " -> "))
2076 return false
2077 }
2078 if module, ok := ctx.Module().(*Module); ok {
2079 if lib, ok := module.linker.(*libraryDecorator); ok && lib.shared() {
Jooyung Han0302a842019-10-30 18:43:49 +09002080 if module.isLlndk(ctx.Config()) || Bool(module.VendorProperties.Double_loadable) {
Jooyung Hana70f0672019-01-18 15:20:43 +09002081 ctx.WalkDeps(check)
2082 }
Jiyong Park5fb8c102018-04-09 12:03:06 +09002083 }
2084 }
2085}
2086
Colin Crossc99deeb2016-04-11 15:06:20 -07002087// Convert dependencies to paths. Returns a PathDeps containing paths
Colin Cross635c3b02016-05-18 15:37:25 -07002088func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
Colin Crossca860ac2016-01-04 14:34:37 -08002089 var depPaths PathDeps
Colin Crossca860ac2016-01-04 14:34:37 -08002090
Ivan Lozano183a3212019-10-18 14:18:45 -07002091 directStaticDeps := []LinkableInterface{}
2092 directSharedDeps := []LinkableInterface{}
Jeff Gaston294356f2017-09-27 17:05:30 -07002093
Inseob Kim9516ee92019-05-09 10:56:13 +09002094 vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
2095
Inseob Kim69378442019-06-03 19:10:47 +09002096 reexportExporter := func(exporter exportedFlagsProducer) {
2097 depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, exporter.exportedDirs()...)
2098 depPaths.ReexportedSystemDirs = append(depPaths.ReexportedSystemDirs, exporter.exportedSystemDirs()...)
2099 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, exporter.exportedFlags()...)
2100 depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, exporter.exportedDeps()...)
Inseob Kimd110f872019-12-06 13:15:38 +09002101 depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, exporter.exportedGeneratedHeaders()...)
Inseob Kim69378442019-06-03 19:10:47 +09002102 }
2103
Colin Crossd11fcda2017-10-23 17:59:01 -07002104 ctx.VisitDirectDeps(func(dep android.Module) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002105 depName := ctx.OtherModuleName(dep)
2106 depTag := ctx.OtherModuleDependencyTag(dep)
Dan Albert9e10cd42016-08-03 14:12:14 -07002107
Ivan Lozano52767be2019-10-18 14:49:46 -07002108 ccDep, ok := dep.(LinkableInterface)
2109 if !ok {
2110
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002111 // handling for a few module types that aren't cc Module but that are also supported
2112 switch depTag {
Dan Willemsenb40aab62016-04-20 14:21:14 -07002113 case genSourceDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002114 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07002115 depPaths.GeneratedSources = append(depPaths.GeneratedSources,
2116 genRule.GeneratedSourceFiles()...)
2117 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002118 ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07002119 }
Colin Crosse90bfd12017-04-26 16:59:26 -07002120 // Support exported headers from a generated_sources dependency
2121 fallthrough
Dan Willemsenb3454ab2016-09-28 17:34:58 -07002122 case genHeaderDepTag, genHeaderExportDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002123 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07002124 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
Inseob Kimd110f872019-12-06 13:15:38 +09002125 genRule.GeneratedSourceFiles()...)
2126 depPaths.GeneratedDeps = append(depPaths.GeneratedDeps,
Dan Willemsen9da9d492018-02-21 18:28:18 -08002127 genRule.GeneratedDeps()...)
Jiyong Park74955042019-10-22 20:19:51 +09002128 dirs := genRule.GeneratedHeaderDirs()
Inseob Kim69378442019-06-03 19:10:47 +09002129 depPaths.IncludeDirs = append(depPaths.IncludeDirs, dirs...)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002130 if depTag == genHeaderExportDepTag {
Inseob Kim69378442019-06-03 19:10:47 +09002131 depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, dirs...)
Inseob Kimd110f872019-12-06 13:15:38 +09002132 depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders,
2133 genRule.GeneratedSourceFiles()...)
Inseob Kim69378442019-06-03 19:10:47 +09002134 depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, genRule.GeneratedDeps()...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07002135 // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
Jiyong Park74955042019-10-22 20:19:51 +09002136 c.sabi.Properties.ReexportedIncludes = append(c.sabi.Properties.ReexportedIncludes, dirs.Strings()...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07002137
Dan Willemsenb3454ab2016-09-28 17:34:58 -07002138 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07002139 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002140 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07002141 }
Dan Willemsena0790e32018-10-12 00:24:23 -07002142 case linkerFlagsDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002143 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenc77a0b32017-09-18 23:19:12 -07002144 files := genRule.GeneratedSourceFiles()
2145 if len(files) == 1 {
Dan Willemsena0790e32018-10-12 00:24:23 -07002146 depPaths.LinkerFlagsFile = android.OptionalPathForPath(files[0])
Dan Willemsenc77a0b32017-09-18 23:19:12 -07002147 } else if len(files) > 1 {
Dan Willemsena0790e32018-10-12 00:24:23 -07002148 ctx.ModuleErrorf("module %q can only generate a single file if used for a linker flag file", depName)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07002149 }
2150 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002151 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07002152 }
Colin Crossca860ac2016-01-04 14:34:37 -08002153 }
Colin Crossc99deeb2016-04-11 15:06:20 -07002154 return
2155 }
2156
Colin Crossfe17f6f2019-03-28 19:30:56 -07002157 if depTag == android.ProtoPluginDepTag {
2158 return
2159 }
2160
Colin Crossd11fcda2017-10-23 17:59:01 -07002161 if dep.Target().Os != ctx.Os() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002162 ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
2163 return
2164 }
Colin Crossd11fcda2017-10-23 17:59:01 -07002165 if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002166 ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
Colin Crossa1ad8d12016-06-01 17:09:44 -07002167 return
2168 }
2169
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002170 // re-exporting flags
2171 if depTag == reuseObjTag {
Ivan Lozano52767be2019-10-18 14:49:46 -07002172 // reusing objects only make sense for cc.Modules.
2173 if ccReuseDep, ok := ccDep.(*Module); ok && ccDep.CcLibraryInterface() {
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08002174 c.staticVariant = ccDep
Ivan Lozano52767be2019-10-18 14:49:46 -07002175 objs, exporter := ccReuseDep.compiler.(libraryInterface).reuseObjs()
Colin Cross10d22312017-05-03 11:01:58 -07002176 depPaths.Objs = depPaths.Objs.Append(objs)
Inseob Kim69378442019-06-03 19:10:47 +09002177 reexportExporter(exporter)
Colin Crossbba99042016-11-23 15:45:05 -08002178 return
2179 }
Colin Crossc99deeb2016-04-11 15:06:20 -07002180 }
Jiyong Park25fc6a92018-11-18 18:02:45 +09002181
Jiyong Parke4bb9862019-02-01 00:31:10 +09002182 if depTag == staticVariantTag {
Ivan Lozano52767be2019-10-18 14:49:46 -07002183 // staticVariants are a cc.Module specific concept.
2184 if _, ok := ccDep.(*Module); ok && ccDep.CcLibraryInterface() {
Jiyong Parke4bb9862019-02-01 00:31:10 +09002185 c.staticVariant = ccDep
2186 return
2187 }
2188 }
2189
Peter Collingbournedc4f9862020-02-12 17:13:25 -08002190 if depTag == staticUnwinderDepTag {
Jooyung Han03b51852020-02-26 22:45:42 +09002191 // Use static unwinder for legacy (min_sdk_version = 29) apexes (b/144430859)
2192 if c.ShouldSupportAndroid10() {
Peter Collingbournedc4f9862020-02-12 17:13:25 -08002193 depTag = StaticDepTag
2194 } else {
2195 return
2196 }
2197 }
2198
Ivan Lozano183a3212019-10-18 14:18:45 -07002199 // Extract ExplicitlyVersioned field from the depTag and reset it inside the struct.
2200 // Otherwise, SharedDepTag and lateSharedDepTag with ExplicitlyVersioned set to true
2201 // won't be matched to SharedDepTag and lateSharedDepTag.
Jiyong Park25fc6a92018-11-18 18:02:45 +09002202 explicitlyVersioned := false
Ivan Lozano183a3212019-10-18 14:18:45 -07002203 if t, ok := depTag.(DependencyTag); ok {
2204 explicitlyVersioned = t.ExplicitlyVersioned
2205 t.ExplicitlyVersioned = false
Jiyong Park25fc6a92018-11-18 18:02:45 +09002206 depTag = t
2207 }
2208
Ivan Lozano183a3212019-10-18 14:18:45 -07002209 if t, ok := depTag.(DependencyTag); ok && t.Library {
Jiyong Park16e91a02018-12-20 18:18:08 +09002210 depIsStatic := false
2211 switch depTag {
Ivan Lozano183a3212019-10-18 14:18:45 -07002212 case StaticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag:
Jiyong Park16e91a02018-12-20 18:18:08 +09002213 depIsStatic = true
2214 }
Ivan Lozano52767be2019-10-18 14:49:46 -07002215 if ccDep.CcLibrary() && !depIsStatic {
2216 depIsStubs := ccDep.BuildStubs()
Jiyong Park25fc6a92018-11-18 18:02:45 +09002217 depHasStubs := ccDep.HasStubsVariants()
Jiyong Park0ddfcd12018-12-11 01:35:25 +09002218 depInSameApex := android.DirectlyInApex(c.ApexName(), depName)
Nicolas Geoffrayc22c1bf2019-01-15 19:53:23 +00002219 depInPlatform := !android.DirectlyInAnyApex(ctx, depName)
Jiyong Park25fc6a92018-11-18 18:02:45 +09002220
2221 var useThisDep bool
2222 if depIsStubs && explicitlyVersioned {
2223 // Always respect dependency to the versioned stubs (i.e. libX#10)
2224 useThisDep = true
2225 } else if !depHasStubs {
2226 // Use non-stub variant if that is the only choice
2227 // (i.e. depending on a lib without stubs.version property)
2228 useThisDep = true
2229 } else if c.IsForPlatform() {
2230 // If not building for APEX, use stubs only when it is from
2231 // an APEX (and not from platform)
2232 useThisDep = (depInPlatform != depIsStubs)
Yifan Hong1b3348d2020-01-21 15:53:22 -08002233 if c.InRamdisk() || c.InRecovery() || c.bootstrap() {
2234 // However, for ramdisk, recovery or bootstrap modules,
Jiyong Park25fc6a92018-11-18 18:02:45 +09002235 // always link to non-stub variant
2236 useThisDep = !depIsStubs
2237 }
2238 } else {
2239 // If building for APEX, use stubs only when it is not from
2240 // the same APEX
2241 useThisDep = (depInSameApex != depIsStubs)
2242 }
2243
Jooyung Han03b51852020-02-26 22:45:42 +09002244 // when to use (unspecified) stubs, check min_sdk_version and choose the right one
2245 if useThisDep && depIsStubs && !explicitlyVersioned {
2246 useLatest := c.IsForPlatform() || (c.ShouldSupportAndroid10() && !ctx.Config().UnbundledBuild())
2247 versionToUse, err := c.ChooseSdkVersion(ccDep.StubsVersions(), useLatest)
2248 if err != nil {
2249 ctx.OtherModuleErrorf(dep, err.Error())
2250 return
2251 }
2252 if versionToUse != ccDep.StubsVersion() {
2253 useThisDep = false
2254 }
2255 }
2256
Jiyong Park25fc6a92018-11-18 18:02:45 +09002257 if !useThisDep {
2258 return // stop processing this dep
2259 }
2260 }
2261
Ivan Lozanoe0833b12019-11-06 19:15:49 -08002262 depPaths.IncludeDirs = append(depPaths.IncludeDirs, ccDep.IncludeDirs()...)
2263
Ivan Lozano52767be2019-10-18 14:49:46 -07002264 // Exporting flags only makes sense for cc.Modules
2265 if _, ok := ccDep.(*Module); ok {
2266 if i, ok := ccDep.(*Module).linker.(exportedFlagsProducer); ok {
Ivan Lozano52767be2019-10-18 14:49:46 -07002267 depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, i.exportedSystemDirs()...)
Inseob Kimd110f872019-12-06 13:15:38 +09002268 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, i.exportedGeneratedHeaders()...)
2269 depPaths.GeneratedDeps = append(depPaths.GeneratedDeps, i.exportedDeps()...)
Ivan Lozano52767be2019-10-18 14:49:46 -07002270 depPaths.Flags = append(depPaths.Flags, i.exportedFlags()...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07002271
Ivan Lozano52767be2019-10-18 14:49:46 -07002272 if t.ReexportFlags {
2273 reexportExporter(i)
2274 // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
2275 // Re-exported shared library headers must be included as well since they can help us with type information
2276 // about template instantiations (instantiated from their headers).
2277 // -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version
2278 // scripts.
2279 c.sabi.Properties.ReexportedIncludes = append(
2280 c.sabi.Properties.ReexportedIncludes, i.exportedDirs().Strings()...)
2281 }
Dan Willemsen490a8dc2016-06-06 18:22:19 -07002282 }
Colin Crossc99deeb2016-04-11 15:06:20 -07002283 }
Logan Chienf3511742017-10-31 18:04:35 +08002284 checkLinkType(ctx, c, ccDep, t)
Colin Crossc99deeb2016-04-11 15:06:20 -07002285 }
2286
Colin Cross26c34ed2016-09-30 17:10:16 -07002287 var ptr *android.Paths
Colin Cross635c3b02016-05-18 15:37:25 -07002288 var depPtr *android.Paths
Colin Crossc99deeb2016-04-11 15:06:20 -07002289
Ivan Lozano52767be2019-10-18 14:49:46 -07002290 linkFile := ccDep.OutputFile()
Colin Cross26c34ed2016-09-30 17:10:16 -07002291 depFile := android.OptionalPath{}
2292
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002293 switch depTag {
Jiyong Parkd7536ba2020-01-16 17:14:23 +09002294 case ndkStubDepTag, SharedDepTag, SharedFromStaticDepTag, sharedExportDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07002295 ptr = &depPaths.SharedLibs
2296 depPtr = &depPaths.SharedLibsDeps
Ivan Lozano52767be2019-10-18 14:49:46 -07002297 depFile = ccDep.Toc()
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08002298 directSharedDeps = append(directSharedDeps, ccDep)
Ivan Lozano183a3212019-10-18 14:18:45 -07002299
Jiyong Park64a44f22019-01-18 14:37:08 +09002300 case earlySharedDepTag:
2301 ptr = &depPaths.EarlySharedLibs
2302 depPtr = &depPaths.EarlySharedLibsDeps
Ivan Lozano52767be2019-10-18 14:49:46 -07002303 depFile = ccDep.Toc()
Jiyong Park64a44f22019-01-18 14:37:08 +09002304 directSharedDeps = append(directSharedDeps, ccDep)
Dan Albert914449f2016-06-17 16:45:24 -07002305 case lateSharedDepTag, ndkLateStubDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07002306 ptr = &depPaths.LateSharedLibs
2307 depPtr = &depPaths.LateSharedLibsDeps
Ivan Lozano52767be2019-10-18 14:49:46 -07002308 depFile = ccDep.Toc()
Ivan Lozano183a3212019-10-18 14:18:45 -07002309 case StaticDepTag, staticExportDepTag:
Jeff Gaston294356f2017-09-27 17:05:30 -07002310 ptr = nil
2311 directStaticDeps = append(directStaticDeps, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07002312 case lateStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07002313 ptr = &depPaths.LateStaticLibs
Colin Crossc99deeb2016-04-11 15:06:20 -07002314 case wholeStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07002315 ptr = &depPaths.WholeStaticLibs
Ivan Lozano52767be2019-10-18 14:49:46 -07002316 if !ccDep.CcLibraryInterface() || !ccDep.Static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002317 ctx.ModuleErrorf("module %q not a static library", depName)
Colin Crossc99deeb2016-04-11 15:06:20 -07002318 return
2319 }
2320
Ivan Lozano52767be2019-10-18 14:49:46 -07002321 // Because the static library objects are included, this only makes sense
2322 // in the context of proper cc.Modules.
2323 if ccWholeStaticLib, ok := ccDep.(*Module); ok {
2324 staticLib := ccWholeStaticLib.linker.(libraryInterface)
2325 if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
2326 postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
2327 for i := range missingDeps {
2328 missingDeps[i] += postfix
2329 }
2330 ctx.AddMissingDependencies(missingDeps)
Colin Crossc99deeb2016-04-11 15:06:20 -07002331 }
Ivan Lozano52767be2019-10-18 14:49:46 -07002332 depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
2333 } else {
2334 ctx.ModuleErrorf(
2335 "non-cc.Modules cannot be included as whole static libraries.", depName)
2336 return
Colin Crossc99deeb2016-04-11 15:06:20 -07002337 }
Colin Cross5950f382016-12-13 12:50:57 -08002338 case headerDepTag:
2339 // Nothing
Colin Crossc99deeb2016-04-11 15:06:20 -07002340 case objDepTag:
Dan Willemsen5cb580f2016-09-26 17:33:01 -07002341 depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
Ivan Lozano183a3212019-10-18 14:18:45 -07002342 case CrtBeginDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07002343 depPaths.CrtBegin = linkFile
Ivan Lozano183a3212019-10-18 14:18:45 -07002344 case CrtEndDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07002345 depPaths.CrtEnd = linkFile
Dan Willemsena0790e32018-10-12 00:24:23 -07002346 case dynamicLinkerDepTag:
2347 depPaths.DynamicLinker = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07002348 }
2349
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002350 switch depTag {
Ivan Lozano183a3212019-10-18 14:18:45 -07002351 case StaticDepTag, staticExportDepTag, lateStaticDepTag:
Ivan Lozano52767be2019-10-18 14:49:46 -07002352 if !ccDep.CcLibraryInterface() || !ccDep.Static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002353 ctx.ModuleErrorf("module %q not a static library", depName)
Dan Willemsen581341d2017-02-09 16:16:31 -08002354 return
2355 }
2356
2357 // When combining coverage files for shared libraries and executables, coverage files
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08002358 // in static libraries act as if they were whole static libraries. The same goes for
2359 // source based Abi dump files.
Ivan Lozano52767be2019-10-18 14:49:46 -07002360 // This should only be done for cc.Modules
2361 if c, ok := ccDep.(*Module); ok {
2362 staticLib := c.linker.(libraryInterface)
2363 depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles,
2364 staticLib.objs().coverageFiles...)
2365 depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
2366 staticLib.objs().sAbiDumpFiles...)
2367 }
Dan Willemsen581341d2017-02-09 16:16:31 -08002368 }
2369
Colin Cross26c34ed2016-09-30 17:10:16 -07002370 if ptr != nil {
Colin Crossce75d2c2016-10-06 16:12:58 -07002371 if !linkFile.Valid() {
Isaac Chen2c0a1802019-10-15 17:16:05 +08002372 if !ctx.Config().AllowMissingDependencies() {
2373 ctx.ModuleErrorf("module %q missing output file", depName)
2374 } else {
2375 ctx.AddMissingDependencies([]string{depName})
2376 }
Colin Crossce75d2c2016-10-06 16:12:58 -07002377 return
2378 }
Colin Cross26c34ed2016-09-30 17:10:16 -07002379 *ptr = append(*ptr, linkFile.Path())
2380 }
2381
Colin Crossc99deeb2016-04-11 15:06:20 -07002382 if depPtr != nil {
Colin Cross26c34ed2016-09-30 17:10:16 -07002383 dep := depFile
2384 if !dep.Valid() {
2385 dep = linkFile
2386 }
2387 *depPtr = append(*depPtr, dep.Path())
Colin Crossca860ac2016-01-04 14:34:37 -08002388 }
Jiyong Park27b188b2017-07-18 13:23:39 +09002389
Inseob Kimeec88e12020-01-22 11:11:29 +09002390 vendorSuffixModules := vendorSuffixModules(ctx.Config())
2391
2392 baseLibName := func(depName string) string {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002393 libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
Jiyong Park374510b2018-03-19 18:23:01 +09002394 libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix)
Jiyong Park27b188b2017-07-18 13:23:39 +09002395 libName = strings.TrimPrefix(libName, "prebuilt_")
Inseob Kimeec88e12020-01-22 11:11:29 +09002396 return libName
2397 }
2398
2399 makeLibName := func(depName string) string {
2400 libName := baseLibName(depName)
Jooyung Han0302a842019-10-30 18:43:49 +09002401 isLLndk := isLlndkLibrary(libName, ctx.Config())
Inseob Kim9516ee92019-05-09 10:56:13 +09002402 isVendorPublicLib := inList(libName, *vendorPublicLibraries)
Ivan Lozano52767be2019-10-18 14:49:46 -07002403 bothVendorAndCoreVariantsExist := ccDep.HasVendorVariant() || isLLndk
Vic Yangefd249e2018-11-12 20:19:56 -08002404
Inseob Kimeec88e12020-01-22 11:11:29 +09002405 if c, ok := ccDep.(*Module); ok {
2406 // Use base module name for snapshots when exporting to Makefile.
2407 if c.isSnapshotPrebuilt() && !c.IsVndk() {
2408 baseName := c.BaseModuleName()
2409 if vendorSuffixModules[baseName] {
2410 return baseName + ".vendor"
2411 } else {
2412 return baseName
2413 }
2414 }
2415 }
2416
Yifan Hong1b3348d2020-01-21 15:53:22 -08002417 if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() && !c.InRamdisk() && !c.InRecovery() {
Vic Yangefd249e2018-11-12 20:19:56 -08002418 // The vendor module is a no-vendor-variant VNDK library. Depend on the
2419 // core module instead.
2420 return libName
Ivan Lozano52767be2019-10-18 14:49:46 -07002421 } else if c.UseVndk() && bothVendorAndCoreVariantsExist {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002422 // The vendor module in Make will have been renamed to not conflict with the core
2423 // module, so update the dependency name here accordingly.
Justin Yun5f7f7e82019-11-18 19:52:14 +09002424 return libName + c.getNameSuffixWithVndkVersion(ctx)
Jiyong Park374510b2018-03-19 18:23:01 +09002425 } else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib {
Logan Chien43d34c32017-12-20 01:17:32 +08002426 return libName + vendorPublicLibrarySuffix
Yifan Hong1b3348d2020-01-21 15:53:22 -08002427 } else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() {
2428 return libName + ramdiskSuffix
Ivan Lozano52767be2019-10-18 14:49:46 -07002429 } else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() {
Jiyong Parkf9332f12018-02-01 00:54:12 +09002430 return libName + recoverySuffix
Ivan Lozano52767be2019-10-18 14:49:46 -07002431 } else if ccDep.Module().Target().NativeBridge == android.NativeBridgeEnabled {
dimitry43204492019-05-23 13:24:38 +02002432 return libName + nativeBridgeSuffix
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002433 } else {
Logan Chien43d34c32017-12-20 01:17:32 +08002434 return libName
Jiyong Park27b188b2017-07-18 13:23:39 +09002435 }
Logan Chien43d34c32017-12-20 01:17:32 +08002436 }
2437
2438 // Export the shared libs to Make.
2439 switch depTag {
Ivan Lozano183a3212019-10-18 14:18:45 -07002440 case SharedDepTag, sharedExportDepTag, lateSharedDepTag, earlySharedDepTag:
Ivan Lozano52767be2019-10-18 14:49:46 -07002441 if ccDep.CcLibrary() {
2442 if ccDep.BuildStubs() && android.InAnyApex(depName) {
Logan Chien09106e12019-01-18 14:57:48 +08002443 // Add the dependency to the APEX(es) providing the library so that
Jiyong Parkde866cb2018-12-07 23:08:36 +09002444 // m <module> can trigger building the APEXes as well.
Jiyong Park0ddfcd12018-12-11 01:35:25 +09002445 for _, an := range android.GetApexesForModule(depName) {
Jiyong Parkde866cb2018-12-07 23:08:36 +09002446 c.Properties.ApexesProvidingSharedLibs = append(
2447 c.Properties.ApexesProvidingSharedLibs, an)
2448 }
Jiyong Parkde866cb2018-12-07 23:08:36 +09002449 }
2450 }
2451
Jiyong Park27b188b2017-07-18 13:23:39 +09002452 // Note: the order of libs in this list is not important because
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07002453 // they merely serve as Make dependencies and do not affect this lib itself.
Logan Chien43d34c32017-12-20 01:17:32 +08002454 c.Properties.AndroidMkSharedLibs = append(
2455 c.Properties.AndroidMkSharedLibs, makeLibName(depName))
Inseob Kimeec88e12020-01-22 11:11:29 +09002456 // Record baseLibName for snapshots.
2457 c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, baseLibName(depName))
Logan Chienc7f797e2019-01-14 15:35:08 +08002458 case ndkStubDepTag, ndkLateStubDepTag:
Logan Chienc7f797e2019-01-14 15:35:08 +08002459 c.Properties.AndroidMkSharedLibs = append(
2460 c.Properties.AndroidMkSharedLibs,
Ivan Lozano52767be2019-10-18 14:49:46 -07002461 depName+"."+ccDep.ApiLevel())
Ivan Lozano183a3212019-10-18 14:18:45 -07002462 case StaticDepTag, staticExportDepTag, lateStaticDepTag:
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +00002463 c.Properties.AndroidMkStaticLibs = append(
2464 c.Properties.AndroidMkStaticLibs, makeLibName(depName))
Logan Chien43d34c32017-12-20 01:17:32 +08002465 case runtimeDepTag:
2466 c.Properties.AndroidMkRuntimeLibs = append(
2467 c.Properties.AndroidMkRuntimeLibs, makeLibName(depName))
Inseob Kimeec88e12020-01-22 11:11:29 +09002468 // Record baseLibName for snapshots.
2469 c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, baseLibName(depName))
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +00002470 case wholeStaticDepTag:
2471 c.Properties.AndroidMkWholeStaticLibs = append(
2472 c.Properties.AndroidMkWholeStaticLibs, makeLibName(depName))
Jiyong Park27b188b2017-07-18 13:23:39 +09002473 }
Colin Crossca860ac2016-01-04 14:34:37 -08002474 })
2475
Jeff Gaston294356f2017-09-27 17:05:30 -07002476 // use the ordered dependencies as this module's dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08002477 depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps, directSharedDeps)...)
Jeff Gaston294356f2017-09-27 17:05:30 -07002478
Colin Crossdd84e052017-05-17 13:44:16 -07002479 // Dedup exported flags from dependencies
Colin Crossb6715442017-10-24 11:13:31 -07002480 depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
Jiyong Park74955042019-10-22 20:19:51 +09002481 depPaths.IncludeDirs = android.FirstUniquePaths(depPaths.IncludeDirs)
2482 depPaths.SystemIncludeDirs = android.FirstUniquePaths(depPaths.SystemIncludeDirs)
Dan Willemsenfe92c962017-08-29 12:28:37 -07002483 depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
Inseob Kimd110f872019-12-06 13:15:38 +09002484 depPaths.GeneratedDeps = android.FirstUniquePaths(depPaths.GeneratedDeps)
Jiyong Park74955042019-10-22 20:19:51 +09002485 depPaths.ReexportedDirs = android.FirstUniquePaths(depPaths.ReexportedDirs)
2486 depPaths.ReexportedSystemDirs = android.FirstUniquePaths(depPaths.ReexportedSystemDirs)
Colin Crossb6715442017-10-24 11:13:31 -07002487 depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
Inseob Kim69378442019-06-03 19:10:47 +09002488 depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps)
Inseob Kimd110f872019-12-06 13:15:38 +09002489 depPaths.ReexportedGeneratedHeaders = android.FirstUniquePaths(depPaths.ReexportedGeneratedHeaders)
Dan Willemsenfe92c962017-08-29 12:28:37 -07002490
2491 if c.sabi != nil {
Inseob Kim69378442019-06-03 19:10:47 +09002492 c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes)
Dan Willemsenfe92c962017-08-29 12:28:37 -07002493 }
Colin Crossdd84e052017-05-17 13:44:16 -07002494
Colin Crossca860ac2016-01-04 14:34:37 -08002495 return depPaths
2496}
2497
2498func (c *Module) InstallInData() bool {
2499 if c.installer == nil {
2500 return false
2501 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07002502 return c.installer.inData()
2503}
2504
2505func (c *Module) InstallInSanitizerDir() bool {
2506 if c.installer == nil {
2507 return false
2508 }
2509 if c.sanitize != nil && c.sanitize.inSanitizerDir() {
Colin Cross94610402016-08-29 13:41:32 -07002510 return true
2511 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07002512 return c.installer.inSanitizerDir()
Colin Crossca860ac2016-01-04 14:34:37 -08002513}
2514
Yifan Hong1b3348d2020-01-21 15:53:22 -08002515func (c *Module) InstallInRamdisk() bool {
2516 return c.InRamdisk()
2517}
2518
Jiyong Parkf9332f12018-02-01 00:54:12 +09002519func (c *Module) InstallInRecovery() bool {
Ivan Lozano52767be2019-10-18 14:49:46 -07002520 return c.InRecovery()
Jiyong Parkf9332f12018-02-01 00:54:12 +09002521}
2522
Dan Willemsen4aa75ca2016-09-28 16:18:03 -07002523func (c *Module) HostToolPath() android.OptionalPath {
2524 if c.installer == nil {
2525 return android.OptionalPath{}
2526 }
2527 return c.installer.hostToolPath()
2528}
2529
Nan Zhangd4e641b2017-07-12 12:55:28 -07002530func (c *Module) IntermPathForModuleOut() android.OptionalPath {
2531 return c.outputFile
2532}
2533
Colin Cross41955e82019-05-29 14:40:35 -07002534func (c *Module) OutputFiles(tag string) (android.Paths, error) {
2535 switch tag {
2536 case "":
2537 if c.outputFile.Valid() {
2538 return android.Paths{c.outputFile.Path()}, nil
2539 }
2540 return android.Paths{}, nil
2541 default:
2542 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07002543 }
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07002544}
2545
Vishwath Mohanb743e9c2017-11-01 09:20:21 +00002546func (c *Module) static() bool {
2547 if static, ok := c.linker.(interface {
2548 static() bool
2549 }); ok {
2550 return static.static()
2551 }
2552 return false
2553}
2554
Jiyong Park379de2f2018-12-19 02:47:14 +09002555func (c *Module) staticBinary() bool {
2556 if static, ok := c.linker.(interface {
2557 staticBinary() bool
2558 }); ok {
2559 return static.staticBinary()
2560 }
2561 return false
2562}
2563
Jiyong Park1d1119f2019-07-29 21:27:18 +09002564func (c *Module) header() bool {
2565 if h, ok := c.linker.(interface {
2566 header() bool
2567 }); ok {
2568 return h.header()
2569 }
2570 return false
2571}
2572
Jooyung Han38002912019-05-16 04:01:54 +09002573func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
Ivan Lozano52767be2019-10-18 14:49:46 -07002574 if c.UseVndk() {
Jooyung Han38002912019-05-16 04:01:54 +09002575 if lib, ok := c.linker.(*llndkStubDecorator); ok {
2576 if Bool(lib.Properties.Vendor_available) {
Colin Crossb60190a2018-09-04 16:28:17 -07002577 return "native:vndk"
2578 }
Jooyung Han38002912019-05-16 04:01:54 +09002579 return "native:vndk_private"
Colin Crossb60190a2018-09-04 16:28:17 -07002580 }
Ivan Lozano52767be2019-10-18 14:49:46 -07002581 if c.IsVndk() && !c.isVndkExt() {
Jooyung Han38002912019-05-16 04:01:54 +09002582 if Bool(c.VendorProperties.Vendor_available) {
2583 return "native:vndk"
2584 }
2585 return "native:vndk_private"
2586 }
Justin Yun5f7f7e82019-11-18 19:52:14 +09002587 if c.inProduct() {
2588 return "native:product"
2589 }
Jooyung Han38002912019-05-16 04:01:54 +09002590 return "native:vendor"
Yifan Hong1b3348d2020-01-21 15:53:22 -08002591 } else if c.InRamdisk() {
2592 return "native:ramdisk"
Ivan Lozano52767be2019-10-18 14:49:46 -07002593 } else if c.InRecovery() {
Colin Crossb60190a2018-09-04 16:28:17 -07002594 return "native:recovery"
2595 } else if c.Target().Os == android.Android && String(c.Properties.Sdk_version) != "" {
2596 return "native:ndk:none:none"
2597 // TODO(b/114741097): use the correct ndk stl once build errors have been fixed
2598 //family, link := getNdkStlFamilyAndLinkType(c)
2599 //return fmt.Sprintf("native:ndk:%s:%s", family, link)
Ivan Lozano52767be2019-10-18 14:49:46 -07002600 } else if actx.DeviceConfig().VndkUseCoreVariant() && !c.MustUseVendorVariant() {
Vic Yangefd249e2018-11-12 20:19:56 -08002601 return "native:platform_vndk"
Colin Crossb60190a2018-09-04 16:28:17 -07002602 } else {
2603 return "native:platform"
2604 }
2605}
2606
Jiyong Park9d452992018-10-03 00:38:19 +09002607// Overrides ApexModule.IsInstallabeToApex()
Roland Levillainf89cd092019-07-29 16:22:59 +01002608// Only shared/runtime libraries and "test_per_src" tests are installable to APEX.
Jiyong Park9d452992018-10-03 00:38:19 +09002609func (c *Module) IsInstallableToApex() bool {
2610 if shared, ok := c.linker.(interface {
2611 shared() bool
2612 }); ok {
Jiyong Park73c54ee2019-10-22 20:31:18 +09002613 // Stub libs and prebuilt libs in a versioned SDK are not
2614 // installable to APEX even though they are shared libs.
2615 return shared.shared() && !c.IsStubs() && c.ContainingSdk().Unversioned()
Roland Levillainf89cd092019-07-29 16:22:59 +01002616 } else if _, ok := c.linker.(testPerSrc); ok {
2617 return true
Jiyong Park9d452992018-10-03 00:38:19 +09002618 }
2619 return false
2620}
2621
Jiyong Parka90ca002019-10-07 15:47:24 +09002622func (c *Module) AvailableFor(what string) bool {
2623 if linker, ok := c.linker.(interface {
2624 availableFor(string) bool
2625 }); ok {
2626 return c.ApexModuleBase.AvailableFor(what) || linker.availableFor(what)
2627 } else {
2628 return c.ApexModuleBase.AvailableFor(what)
2629 }
2630}
2631
Inseob Kim1f086e22019-05-09 13:29:15 +09002632func (c *Module) installable() bool {
Jiyong Parkfe9a4302020-01-07 16:59:44 +09002633 ret := c.installer != nil && !c.Properties.PreventInstall && c.outputFile.Valid()
2634
2635 // The platform variant doesn't need further condition. Apex variants however might not
2636 // be installable because it will likely to be included in the APEX and won't appear
2637 // in the system partition.
2638 if c.IsForPlatform() {
2639 return ret
2640 }
2641
2642 // Special case for modules that are configured to be installed to /data, which includes
2643 // test modules. For these modules, both APEX and non-APEX variants are considered as
2644 // installable. This is because even the APEX variants won't be included in the APEX, but
2645 // will anyway be installed to /data/*.
2646 // See b/146995717
2647 if c.InstallInData() {
2648 return ret
2649 }
2650
2651 return false
Inseob Kim1f086e22019-05-09 13:29:15 +09002652}
2653
Logan Chien41eabe62019-04-10 13:33:58 +08002654func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
2655 if c.linker != nil {
2656 if library, ok := c.linker.(*libraryDecorator); ok {
2657 library.androidMkWriteAdditionalDependenciesForSourceAbiDiff(w)
2658 }
2659 }
2660}
2661
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09002662func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
Ivan Lozano183a3212019-10-18 14:18:45 -07002663 if depTag, ok := ctx.OtherModuleDependencyTag(dep).(DependencyTag); ok {
Jiyong Parkd7536ba2020-01-16 17:14:23 +09002664 if cc, ok := dep.(*Module); ok {
Jiyong Park323a4c32020-03-01 17:29:06 +09002665 if cc.HasStubsVariants() {
2666 if depTag.Shared && depTag.Library {
2667 // dynamic dep to a stubs lib crosses APEX boundary
2668 return false
2669 }
2670 if IsRuntimeDepTag(depTag) {
2671 // runtime dep to a stubs lib also crosses APEX boundary
2672 return false
2673 }
Jiyong Parkd7536ba2020-01-16 17:14:23 +09002674 }
2675 if depTag.FromStatic {
2676 // shared_lib dependency from a static lib is considered as crossing
2677 // the APEX boundary because the dependency doesn't actually is
2678 // linked; the dependency is used only during the compilation phase.
2679 return false
2680 }
Jiyong Parka7bc8ad2019-10-15 15:20:07 +09002681 }
2682 }
2683 return true
2684}
2685
Colin Cross2ba19d92015-05-07 15:44:20 -07002686//
Colin Crosscfad1192015-11-02 16:43:11 -08002687// Defaults
2688//
Colin Crossca860ac2016-01-04 14:34:37 -08002689type Defaults struct {
Colin Cross635c3b02016-05-18 15:37:25 -07002690 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -07002691 android.DefaultsModuleBase
Jiyong Park9d452992018-10-03 00:38:19 +09002692 android.ApexModuleBase
Colin Crosscfad1192015-11-02 16:43:11 -08002693}
2694
Patrice Arrudac249c712019-03-19 17:00:29 -07002695// cc_defaults provides a set of properties that can be inherited by other cc
2696// modules. A module can use the properties from a cc_defaults using
2697// `defaults: ["<:default_module_name>"]`. Properties of both modules are
2698// merged (when possible) by prepending the default module's values to the
2699// depending module's values.
Colin Cross36242852017-06-23 15:06:31 -07002700func defaultsFactory() android.Module {
Colin Crosse1d764e2016-08-18 14:18:32 -07002701 return DefaultsFactory()
2702}
2703
Colin Cross36242852017-06-23 15:06:31 -07002704func DefaultsFactory(props ...interface{}) android.Module {
Colin Crossca860ac2016-01-04 14:34:37 -08002705 module := &Defaults{}
Colin Crosscfad1192015-11-02 16:43:11 -08002706
Colin Cross36242852017-06-23 15:06:31 -07002707 module.AddProperties(props...)
2708 module.AddProperties(
Colin Crossca860ac2016-01-04 14:34:37 -08002709 &BaseProperties{},
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07002710 &VendorProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08002711 &BaseCompilerProperties{},
2712 &BaseLinkerProperties{},
Paul Duffina37832a2019-07-18 12:31:26 +01002713 &ObjectLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07002714 &LibraryProperties{},
Colin Crosse1bb5d02019-09-24 14:55:04 -07002715 &StaticProperties{},
2716 &SharedProperties{},
Colin Cross919281a2016-04-05 16:42:05 -07002717 &FlagExporterProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08002718 &BinaryLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07002719 &TestProperties{},
2720 &TestBinaryProperties{},
Mitch Phillips4e4ab8a2019-09-13 17:32:50 -07002721 &FuzzProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08002722 &StlProperties{},
Colin Cross16b23492016-01-06 14:41:07 -08002723 &SanitizeProperties{},
Colin Cross665dce92016-04-28 14:50:03 -07002724 &StripProperties{},
Dan Willemsen7424d612016-09-01 13:45:39 -07002725 &InstallerProperties{},
Dan Willemsena03cf6d2016-09-26 15:45:04 -07002726 &TidyProperties{},
Dan Willemsen581341d2017-02-09 16:16:31 -08002727 &CoverageProperties{},
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08002728 &SAbiProperties{},
Justin Yun4b2382f2017-07-26 14:22:10 +09002729 &VndkProperties{},
Stephen Craneba090d12017-05-09 15:44:35 -07002730 &LTOProperties{},
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -07002731 &PgoProperties{},
Dan Willemsen6424d172018-03-08 13:27:59 -08002732 &android.ProtoProperties{},
Colin Crosse1d764e2016-08-18 14:18:32 -07002733 )
Colin Crosscfad1192015-11-02 16:43:11 -08002734
Jooyung Hancc372c52019-09-25 15:18:44 +09002735 android.InitDefaultsModule(module)
Colin Cross36242852017-06-23 15:06:31 -07002736
2737 return module
Colin Crosscfad1192015-11-02 16:43:11 -08002738}
2739
Jiyong Park6a43f042017-10-12 23:05:00 +09002740func squashVendorSrcs(m *Module) {
2741 if lib, ok := m.compiler.(*libraryDecorator); ok {
2742 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
2743 lib.baseCompiler.Properties.Target.Vendor.Srcs...)
2744
2745 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
2746 lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
2747 }
2748}
2749
Jiyong Parkf9332f12018-02-01 00:54:12 +09002750func squashRecoverySrcs(m *Module) {
2751 if lib, ok := m.compiler.(*libraryDecorator); ok {
2752 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
2753 lib.baseCompiler.Properties.Target.Recovery.Srcs...)
2754
2755 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
2756 lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
2757 }
2758}
2759
Colin Cross7228ecd2019-11-18 16:00:16 -08002760var _ android.ImageInterface = (*Module)(nil)
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002761
Colin Cross7228ecd2019-11-18 16:00:16 -08002762func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002763 // Sanity check
Logan Chienf3511742017-10-31 18:04:35 +08002764 vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
Justin Yun9357f4a2018-11-28 15:14:47 +09002765 productSpecific := mctx.ProductSpecific()
Logan Chienf3511742017-10-31 18:04:35 +08002766
2767 if m.VendorProperties.Vendor_available != nil && vendorSpecific {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002768 mctx.PropertyErrorf("vendor_available",
Jiyong Park2db76922017-11-08 16:03:48 +09002769 "doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002770 }
Logan Chienf3511742017-10-31 18:04:35 +08002771
2772 if vndkdep := m.vndkdep; vndkdep != nil {
2773 if vndkdep.isVndk() {
Justin Yun0ecf0b22020-02-28 15:07:59 +09002774 if vendorSpecific || productSpecific {
Logan Chienf3511742017-10-31 18:04:35 +08002775 if !vndkdep.isVndkExt() {
2776 mctx.PropertyErrorf("vndk",
2777 "must set `extends: \"...\"` to vndk extension")
Justin Yun0ecf0b22020-02-28 15:07:59 +09002778 } else if m.VendorProperties.Vendor_available != nil {
2779 mctx.PropertyErrorf("vendor_available",
2780 "must not set at the same time as `vndk: {extends: \"...\"}`")
Logan Chienf3511742017-10-31 18:04:35 +08002781 }
2782 } else {
2783 if vndkdep.isVndkExt() {
2784 mctx.PropertyErrorf("vndk",
Justin Yun0ecf0b22020-02-28 15:07:59 +09002785 "must set `vendor: true` or `product_specific: true` to set `extends: %q`",
Logan Chienf3511742017-10-31 18:04:35 +08002786 m.getVndkExtendsModuleName())
Logan Chienf3511742017-10-31 18:04:35 +08002787 }
2788 if m.VendorProperties.Vendor_available == nil {
2789 mctx.PropertyErrorf("vndk",
2790 "vendor_available must be set to either true or false when `vndk: {enabled: true}`")
Logan Chienf3511742017-10-31 18:04:35 +08002791 }
2792 }
2793 } else {
2794 if vndkdep.isVndkSp() {
2795 mctx.PropertyErrorf("vndk",
2796 "must set `enabled: true` to set `support_system_process: true`")
Logan Chienf3511742017-10-31 18:04:35 +08002797 }
2798 if vndkdep.isVndkExt() {
2799 mctx.PropertyErrorf("vndk",
2800 "must set `enabled: true` to set `extends: %q`",
2801 m.getVndkExtendsModuleName())
Logan Chienf3511742017-10-31 18:04:35 +08002802 }
Justin Yun8effde42017-06-23 19:24:43 +09002803 }
2804 }
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002805
Jiyong Parkf9332f12018-02-01 00:54:12 +09002806 var coreVariantNeeded bool = false
Yifan Hong1b3348d2020-01-21 15:53:22 -08002807 var ramdiskVariantNeeded bool = false
Jiyong Parkf9332f12018-02-01 00:54:12 +09002808 var recoveryVariantNeeded bool = false
2809
Inseob Kim64c43952019-08-26 16:52:35 +09002810 var vendorVariants []string
Justin Yun5f7f7e82019-11-18 19:52:14 +09002811 var productVariants []string
Inseob Kim64c43952019-08-26 16:52:35 +09002812
2813 platformVndkVersion := mctx.DeviceConfig().PlatformVndkVersion()
Justin Yun5f7f7e82019-11-18 19:52:14 +09002814 boardVndkVersion := mctx.DeviceConfig().VndkVersion()
2815 productVndkVersion := mctx.DeviceConfig().ProductVndkVersion()
2816 if boardVndkVersion == "current" {
2817 boardVndkVersion = platformVndkVersion
2818 }
2819 if productVndkVersion == "current" {
2820 productVndkVersion = platformVndkVersion
Inseob Kim64c43952019-08-26 16:52:35 +09002821 }
2822
Justin Yun5f7f7e82019-11-18 19:52:14 +09002823 if boardVndkVersion == "" {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002824 // If the device isn't compiling against the VNDK, we always
2825 // use the core mode.
Jiyong Parkf9332f12018-02-01 00:54:12 +09002826 coreVariantNeeded = true
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002827 } else if _, ok := m.linker.(*llndkStubDecorator); ok {
Justin Yun5f7f7e82019-11-18 19:52:14 +09002828 // LL-NDK stubs only exist in the vendor and product variants,
2829 // since the real libraries will be used in the core variant.
Inseob Kim64c43952019-08-26 16:52:35 +09002830 vendorVariants = append(vendorVariants,
2831 platformVndkVersion,
Justin Yun5f7f7e82019-11-18 19:52:14 +09002832 boardVndkVersion,
2833 )
2834 productVariants = append(productVariants,
2835 platformVndkVersion,
2836 productVndkVersion,
Inseob Kim64c43952019-08-26 16:52:35 +09002837 )
Jiyong Park2a454122017-10-19 15:59:33 +09002838 } else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
2839 // ... and LL-NDK headers as well
Inseob Kim64c43952019-08-26 16:52:35 +09002840 vendorVariants = append(vendorVariants,
2841 platformVndkVersion,
Justin Yun5f7f7e82019-11-18 19:52:14 +09002842 boardVndkVersion,
2843 )
2844 productVariants = append(productVariants,
2845 platformVndkVersion,
2846 productVndkVersion,
Inseob Kim64c43952019-08-26 16:52:35 +09002847 )
Inseob Kimeec88e12020-01-22 11:11:29 +09002848 } else if m.isSnapshotPrebuilt() {
Justin Yun71549282017-11-17 12:10:28 +09002849 // Make vendor variants only for the versions in BOARD_VNDK_VERSION and
2850 // PRODUCT_EXTRA_VNDK_VERSIONS.
Inseob Kimeec88e12020-01-22 11:11:29 +09002851 if snapshot, ok := m.linker.(interface {
2852 version() string
2853 }); ok {
2854 vendorVariants = append(vendorVariants, snapshot.version())
2855 } else {
2856 mctx.ModuleErrorf("version is unknown for snapshot prebuilt")
2857 }
Justin Yun0ecf0b22020-02-28 15:07:59 +09002858 } else if m.HasVendorVariant() && !m.isVndkExt() {
Justin Yun5f7f7e82019-11-18 19:52:14 +09002859 // This will be available in /system, /vendor and /product
2860 // or a /system directory that is available to vendor and product.
Jiyong Parkf9332f12018-02-01 00:54:12 +09002861 coreVariantNeeded = true
Inseob Kim64c43952019-08-26 16:52:35 +09002862 vendorVariants = append(vendorVariants, platformVndkVersion)
Justin Yun5f7f7e82019-11-18 19:52:14 +09002863 productVariants = append(productVariants, platformVndkVersion)
Inseob Kimbc093672019-11-01 11:29:44 +09002864 // VNDK modules must not create BOARD_VNDK_VERSION variant because its
2865 // code is PLATFORM_VNDK_VERSION.
2866 // On the other hand, vendor_available modules which are not VNDK should
2867 // also build BOARD_VNDK_VERSION because it's installed in /vendor.
Justin Yun5f7f7e82019-11-18 19:52:14 +09002868 // vendor_available modules are also available to /product.
Inseob Kimbc093672019-11-01 11:29:44 +09002869 if !m.IsVndk() {
Justin Yun5f7f7e82019-11-18 19:52:14 +09002870 vendorVariants = append(vendorVariants, boardVndkVersion)
2871 productVariants = append(productVariants, productVndkVersion)
Inseob Kim64c43952019-08-26 16:52:35 +09002872 }
Logan Chienf3511742017-10-31 18:04:35 +08002873 } else if vendorSpecific && String(m.Properties.Sdk_version) == "" {
Jiyong Park2db76922017-11-08 16:03:48 +09002874 // This will be available in /vendor (or /odm) only
Justin Yun5f7f7e82019-11-18 19:52:14 +09002875 vendorVariants = append(vendorVariants, boardVndkVersion)
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002876 } else {
2877 // This is either in /system (or similar: /data), or is a
2878 // modules built with the NDK. Modules built with the NDK
2879 // will be restricted using the existing link type checks.
Jiyong Parkf9332f12018-02-01 00:54:12 +09002880 coreVariantNeeded = true
2881 }
2882
Justin Yun5f7f7e82019-11-18 19:52:14 +09002883 if boardVndkVersion != "" && productVndkVersion != "" {
2884 if coreVariantNeeded && productSpecific && String(m.Properties.Sdk_version) == "" {
2885 // The module has "product_specific: true" that does not create core variant.
2886 coreVariantNeeded = false
2887 productVariants = append(productVariants, productVndkVersion)
2888 }
2889 } else {
2890 // Unless PRODUCT_PRODUCT_VNDK_VERSION is set, product partition has no
2891 // restriction to use system libs.
2892 // No product variants defined in this case.
2893 productVariants = []string{}
2894 }
2895
Yifan Hong1b3348d2020-01-21 15:53:22 -08002896 if Bool(m.Properties.Ramdisk_available) {
2897 ramdiskVariantNeeded = true
2898 }
2899
2900 if m.ModuleBase.InstallInRamdisk() {
2901 ramdiskVariantNeeded = true
2902 coreVariantNeeded = false
2903 }
2904
Jiyong Parkf9332f12018-02-01 00:54:12 +09002905 if Bool(m.Properties.Recovery_available) {
2906 recoveryVariantNeeded = true
2907 }
2908
2909 if m.ModuleBase.InstallInRecovery() {
2910 recoveryVariantNeeded = true
2911 coreVariantNeeded = false
2912 }
2913
Inseob Kim64c43952019-08-26 16:52:35 +09002914 for _, variant := range android.FirstUniqueStrings(vendorVariants) {
Justin Yun5f7f7e82019-11-18 19:52:14 +09002915 m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, VendorVariationPrefix+variant)
2916 }
2917
2918 for _, variant := range android.FirstUniqueStrings(productVariants) {
2919 m.Properties.ExtraVariants = append(m.Properties.ExtraVariants, ProductVariationPrefix+variant)
Jiyong Parkf9332f12018-02-01 00:54:12 +09002920 }
Colin Cross7228ecd2019-11-18 16:00:16 -08002921
Yifan Hong1b3348d2020-01-21 15:53:22 -08002922 m.Properties.RamdiskVariantNeeded = ramdiskVariantNeeded
Colin Cross7228ecd2019-11-18 16:00:16 -08002923 m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
2924 m.Properties.CoreVariantNeeded = coreVariantNeeded
2925}
2926
2927func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
2928 return c.Properties.CoreVariantNeeded
2929}
2930
Yifan Hong1b3348d2020-01-21 15:53:22 -08002931func (c *Module) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
2932 return c.Properties.RamdiskVariantNeeded
2933}
2934
Colin Cross7228ecd2019-11-18 16:00:16 -08002935func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
2936 return c.Properties.RecoveryVariantNeeded
2937}
2938
2939func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
Justin Yun5f7f7e82019-11-18 19:52:14 +09002940 return c.Properties.ExtraVariants
Colin Cross7228ecd2019-11-18 16:00:16 -08002941}
2942
2943func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
2944 m := module.(*Module)
Yifan Hong1b3348d2020-01-21 15:53:22 -08002945 if variant == android.RamdiskVariation {
2946 m.MakeAsPlatform()
2947 } else if variant == android.RecoveryVariation {
Colin Cross7228ecd2019-11-18 16:00:16 -08002948 m.MakeAsPlatform()
2949 squashRecoverySrcs(m)
2950 } else if strings.HasPrefix(variant, VendorVariationPrefix) {
Justin Yun5f7f7e82019-11-18 19:52:14 +09002951 m.Properties.ImageVariationPrefix = VendorVariationPrefix
Colin Cross7228ecd2019-11-18 16:00:16 -08002952 m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
2953 squashVendorSrcs(m)
Inseob Kimeec88e12020-01-22 11:11:29 +09002954
2955 // Makefile shouldn't know vendor modules other than BOARD_VNDK_VERSION.
2956 // Hide other vendor variants to avoid collision.
2957 vndkVersion := ctx.DeviceConfig().VndkVersion()
2958 if vndkVersion != "current" && vndkVersion != "" && vndkVersion != m.Properties.VndkVersion {
2959 m.Properties.HideFromMake = true
2960 m.SkipInstall()
2961 }
Justin Yun5f7f7e82019-11-18 19:52:14 +09002962 } else if strings.HasPrefix(variant, ProductVariationPrefix) {
2963 m.Properties.ImageVariationPrefix = ProductVariationPrefix
2964 m.Properties.VndkVersion = strings.TrimPrefix(variant, ProductVariationPrefix)
2965 squashVendorSrcs(m)
Dan Willemsen4416e5d2017-04-06 12:43:22 -07002966 }
2967}
2968
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07002969func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
Colin Cross6510f912017-11-29 00:27:14 -08002970 if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07002971 return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
2972 }
Colin Cross6510f912017-11-29 00:27:14 -08002973 return ctx.Config().PlatformSdkVersion()
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07002974}
2975
Sasha Smundak2a4549e2018-11-05 16:49:08 -08002976func kytheExtractAllFactory() android.Singleton {
2977 return &kytheExtractAllSingleton{}
2978}
2979
2980type kytheExtractAllSingleton struct {
2981}
2982
2983func (ks *kytheExtractAllSingleton) GenerateBuildActions(ctx android.SingletonContext) {
2984 var xrefTargets android.Paths
2985 ctx.VisitAllModules(func(module android.Module) {
2986 if ccModule, ok := module.(xref); ok {
2987 xrefTargets = append(xrefTargets, ccModule.XrefCcFiles()...)
2988 }
2989 })
2990 // TODO(asmundak): Perhaps emit a rule to output a warning if there were no xrefTargets
2991 if len(xrefTargets) > 0 {
2992 ctx.Build(pctx, android.BuildParams{
2993 Rule: blueprint.Phony,
2994 Output: android.PathForPhony(ctx, "xref_cxx"),
2995 Inputs: xrefTargets,
2996 //Default: true,
2997 })
2998 }
2999}
3000
Colin Cross06a931b2015-10-28 17:23:31 -07003001var Bool = proptools.Bool
Colin Cross38b40df2018-04-10 16:14:46 -07003002var BoolDefault = proptools.BoolDefault
Nan Zhang0007d812017-11-07 10:57:05 -08003003var BoolPtr = proptools.BoolPtr
3004var String = proptools.String
3005var StringPtr = proptools.StringPtr