blob: 66018d0f9aaa90a1b18ca698b5f885a1d1622340 [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 (
Dan Albert9e10cd42016-08-03 14:12:14 -070022 "strconv"
Colin Cross3f40fa42015-01-30 17:27:36 -080023 "strings"
24
Colin Cross97ba0732015-03-23 17:50:24 -070025 "github.com/google/blueprint"
Colin Cross06a931b2015-10-28 17:23:31 -070026 "github.com/google/blueprint/proptools"
Colin Cross97ba0732015-03-23 17:50:24 -070027
Colin Cross635c3b02016-05-18 15:37:25 -070028 "android/soong/android"
Colin Crossb98c8b02016-07-29 13:44:28 -070029 "android/soong/cc/config"
Colin Cross5049f022015-03-18 13:28:46 -070030 "android/soong/genrule"
Colin Cross3f40fa42015-01-30 17:27:36 -080031)
32
Colin Cross463a90e2015-06-17 14:20:06 -070033func init() {
Colin Cross798bfce2016-10-12 14:28:16 -070034 android.RegisterModuleType("cc_defaults", defaultsFactory)
Colin Cross463a90e2015-06-17 14:20:06 -070035
Colin Cross1e676be2016-10-12 14:38:15 -070036 android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
Jiyong Parkf9332f12018-02-01 00:54:12 +090037 ctx.BottomUp("image", imageMutator).Parallel()
Colin Crosse40b4ea2018-10-02 22:25:58 -070038 ctx.BottomUp("link", LinkageMutator).Parallel()
Jiyong Parkd5b18a52017-08-03 21:22:50 +090039 ctx.BottomUp("vndk", vndkMutator).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070040 ctx.BottomUp("ndk_api", ndkApiMutator).Parallel()
41 ctx.BottomUp("test_per_src", testPerSrcMutator).Parallel()
Jiyong Park7ed9de32018-10-15 22:25:07 +090042 ctx.BottomUp("version", versionMutator).Parallel()
Colin Crosse40b4ea2018-10-02 22:25:58 -070043 ctx.BottomUp("begin", BeginMutator).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070044 })
Colin Cross16b23492016-01-06 14:41:07 -080045
Colin Cross1e676be2016-10-12 14:38:15 -070046 android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
47 ctx.TopDown("asan_deps", sanitizerDepsMutator(asan))
48 ctx.BottomUp("asan", sanitizerMutator(asan)).Parallel()
Colin Cross16b23492016-01-06 14:41:07 -080049
Evgenii Stepanovd97a6e92018-08-02 16:19:13 -070050 ctx.TopDown("hwasan_deps", sanitizerDepsMutator(hwasan))
51 ctx.BottomUp("hwasan", sanitizerMutator(hwasan)).Parallel()
52
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000053 ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi))
54 ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel()
55
Colin Cross1e676be2016-10-12 14:38:15 -070056 ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
57 ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()
Dan Willemsen581341d2017-02-09 16:16:31 -080058
Colin Cross6b753602018-06-21 13:03:07 -070059 ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator)
Ivan Lozano30c5db22018-02-21 15:49:20 -080060
Pirama Arumuga Nainar0b882f02018-04-23 22:44:39 +000061 ctx.BottomUp("coverage", coverageLinkingMutator).Parallel()
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -080062 ctx.TopDown("vndk_deps", sabiDepsMutator)
Stephen Craneba090d12017-05-09 15:44:35 -070063
64 ctx.TopDown("lto_deps", ltoDepsMutator)
65 ctx.BottomUp("lto", ltoMutator).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070066 })
Colin Crossb98c8b02016-07-29 13:44:28 -070067
68 pctx.Import("android/soong/cc/config")
Colin Cross463a90e2015-06-17 14:20:06 -070069}
70
Colin Crossca860ac2016-01-04 14:34:37 -080071type Deps struct {
72 SharedLibs, LateSharedLibs []string
73 StaticLibs, LateStaticLibs, WholeStaticLibs []string
Colin Cross5950f382016-12-13 12:50:57 -080074 HeaderLibs []string
Logan Chien43d34c32017-12-20 01:17:32 +080075 RuntimeLibs []string
Colin Crossc472d572015-03-17 15:06:21 -070076
Colin Cross5950f382016-12-13 12:50:57 -080077 ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string
Dan Willemsen490a8dc2016-06-06 18:22:19 -070078
Colin Cross81413472016-04-11 14:37:39 -070079 ObjFiles []string
Dan Willemsen34cc69e2015-09-23 15:26:20 -070080
Dan Willemsenb40aab62016-04-20 14:21:14 -070081 GeneratedSources []string
82 GeneratedHeaders []string
83
Dan Willemsenb3454ab2016-09-28 17:34:58 -070084 ReexportGeneratedHeaders []string
85
Colin Cross97ba0732015-03-23 17:50:24 -070086 CrtBegin, CrtEnd string
Dan Willemsena0790e32018-10-12 00:24:23 -070087
88 // Used for host bionic
89 LinkerFlagsFile string
90 DynamicLinker string
Colin Crossc472d572015-03-17 15:06:21 -070091}
92
Colin Crossca860ac2016-01-04 14:34:37 -080093type PathDeps struct {
Colin Cross26c34ed2016-09-30 17:10:16 -070094 // Paths to .so files
95 SharedLibs, LateSharedLibs android.Paths
96 // Paths to the dependencies to use for .so files (.so.toc files)
97 SharedLibsDeps, LateSharedLibsDeps android.Paths
98 // Paths to .a files
Colin Cross635c3b02016-05-18 15:37:25 -070099 StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700100
Colin Cross26c34ed2016-09-30 17:10:16 -0700101 // Paths to .o files
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700102 Objs Objects
Dan Willemsen581341d2017-02-09 16:16:31 -0800103 StaticLibObjs Objects
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700104 WholeStaticLibObjs Objects
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700105
Colin Cross26c34ed2016-09-30 17:10:16 -0700106 // Paths to generated source files
Colin Cross635c3b02016-05-18 15:37:25 -0700107 GeneratedSources android.Paths
108 GeneratedHeaders android.Paths
Dan Willemsenb40aab62016-04-20 14:21:14 -0700109
Dan Willemsen76f08272016-07-09 00:14:08 -0700110 Flags, ReexportedFlags []string
Dan Willemsen847dcc72016-09-29 12:13:36 -0700111 ReexportedFlagsDeps android.Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700112
Colin Cross26c34ed2016-09-30 17:10:16 -0700113 // Paths to crt*.o files
Colin Cross635c3b02016-05-18 15:37:25 -0700114 CrtBegin, CrtEnd android.OptionalPath
Dan Willemsena0790e32018-10-12 00:24:23 -0700115
116 // Path to the file container flags to use with the linker
117 LinkerFlagsFile android.OptionalPath
118
119 // Path to the dynamic linker binary
120 DynamicLinker android.OptionalPath
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700121}
122
Colin Crossca860ac2016-01-04 14:34:37 -0800123type Flags struct {
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700124 GlobalFlags []string // Flags that apply to C, C++, and assembly source files
125 ArFlags []string // Flags that apply to ar
126 AsFlags []string // Flags that apply to assembly source files
127 CFlags []string // Flags that apply to C and C++ source files
128 ToolingCFlags []string // Flags that apply to C and C++ source files parsed by clang LibTooling tools
129 ConlyFlags []string // Flags that apply to C source files
130 CppFlags []string // Flags that apply to C++ source files
131 ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
132 YaccFlags []string // Flags that apply to Yacc source files
133 protoFlags []string // Flags that apply to proto source files
Joe Onorato09e94ab2017-11-18 18:23:14 -0800134 protoOutParams []string // Flags that modify the output of proto generated files
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700135 aidlFlags []string // Flags that apply to aidl source files
136 rsFlags []string // Flags that apply to renderscript source files
137 LdFlags []string // Flags that apply to linker command lines
138 libFlags []string // Flags to add libraries early to the link order
139 TidyFlags []string // Flags that apply to clang-tidy
140 SAbiFlags []string // Flags that apply to header-abi-dumper
141 YasmFlags []string // Flags that apply to yasm assembly source files
Colin Cross28344522015-04-22 13:07:53 -0700142
Colin Crossc3199482017-03-30 15:03:04 -0700143 // Global include flags that apply to C, C++, and assembly source files
144 // These must be after any module include flags, which will be in GlobalFlags.
145 SystemIncludeFlags []string
146
Colin Crossb98c8b02016-07-29 13:44:28 -0700147 Toolchain config.Toolchain
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700148 Tidy bool
Dan Willemsen581341d2017-02-09 16:16:31 -0800149 Coverage bool
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800150 SAbiDump bool
Dan Willemsenab9f4262018-02-14 13:58:34 -0800151 ProtoRoot bool
Colin Crossca860ac2016-01-04 14:34:37 -0800152
153 RequiredInstructionSet string
Colin Cross16b23492016-01-06 14:41:07 -0800154 DynamicLinker string
155
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700156 CFlagsDeps android.Paths // Files depended on by compiler flags
157 LdFlagsDeps android.Paths // Files depended on by linker flags
Colin Cross18c0c5a2016-12-01 14:45:23 -0800158
159 GroupStaticLibs bool
Zhizhou Yang51be6322018-02-08 18:32:11 -0800160 ArGoldPlugin bool // Whether LLVM gold plugin option is passed to llvm-ar
Colin Crossc472d572015-03-17 15:06:21 -0700161}
162
Colin Cross81413472016-04-11 14:37:39 -0700163type ObjectLinkerProperties struct {
164 // names of other cc_object modules to link into this module using partial linking
165 Objs []string `android:"arch_variant"`
Dan Willemsenefb1dd92017-09-18 22:47:20 -0700166
167 // if set, add an extra objcopy --prefix-symbols= step
Nan Zhang0007d812017-11-07 10:57:05 -0800168 Prefix_symbols *string
Colin Cross81413472016-04-11 14:37:39 -0700169}
170
Colin Crossca860ac2016-01-04 14:34:37 -0800171// Properties used to compile all C or C++ modules
172type BaseProperties struct {
Dan Willemsen742a5452018-07-23 17:19:36 -0700173 // Deprecated. true is the default, false is invalid.
Colin Crossca860ac2016-01-04 14:34:37 -0800174 Clang *bool `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -0700175
176 // Minimum sdk version supported when compiling against the ndk
Nan Zhang0007d812017-11-07 10:57:05 -0800177 Sdk_version *string
Colin Cross7d5136f2015-05-11 13:39:40 -0700178
Jaewoong Jung9d5ca152018-11-01 15:40:37 -0700179 AndroidMkSharedLibs []string `blueprint:"mutated"`
180 AndroidMkStaticLibs []string `blueprint:"mutated"`
181 AndroidMkRuntimeLibs []string `blueprint:"mutated"`
182 AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
183 HideFromMake bool `blueprint:"mutated"`
184 PreventInstall bool `blueprint:"mutated"`
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700185
186 UseVndk bool `blueprint:"mutated"`
Colin Cross5beccee2017-12-07 15:28:59 -0800187
188 // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
189 // file
190 Logtags []string
Jiyong Parkf9332f12018-02-01 00:54:12 +0900191
192 // Make this module available when building for recovery
193 Recovery_available *bool
194
195 InRecovery bool `blueprint:"mutated"`
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700196}
197
198type VendorProperties struct {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900199 // whether this module should be allowed to be directly depended by other
200 // modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`.
201 // If set to true, two variants will be built separately, one like
202 // normal, and the other limited to the set of libraries and headers
203 // that are exposed to /vendor modules.
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700204 //
205 // The vendor variant may be used with a different (newer) /system,
206 // so it shouldn't have any unversioned runtime dependencies, or
207 // make assumptions about the system that may not be true in the
208 // future.
209 //
Jiyong Park82e2bf32017-08-16 14:05:54 +0900210 // If set to false, this module becomes inaccessible from /vendor modules.
211 //
212 // Default value is true when vndk: {enabled: true} or vendor: true.
213 //
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700214 // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
215 Vendor_available *bool
Jiyong Park5fb8c102018-04-09 12:03:06 +0900216
217 // whether this module is capable of being loaded with other instance
218 // (possibly an older version) of the same module in the same process.
219 // Currently, a shared library that is a member of VNDK (vndk: {enabled: true})
220 // can be double loaded in a vendor process if the library is also a
221 // (direct and indirect) dependency of an LLNDK library. Such libraries must be
222 // explicitly marked as `double_loadable: true` by the owner, or the dependency
223 // from the LLNDK lib should be cut if the lib is not designed to be double loaded.
224 Double_loadable *bool
Colin Crossca860ac2016-01-04 14:34:37 -0800225}
226
Colin Crossca860ac2016-01-04 14:34:37 -0800227type ModuleContextIntf interface {
Colin Crossca860ac2016-01-04 14:34:37 -0800228 static() bool
229 staticBinary() bool
Colin Crossb98c8b02016-07-29 13:44:28 -0700230 toolchain() config.Toolchain
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700231 useSdk() bool
Colin Crossca860ac2016-01-04 14:34:37 -0800232 sdkVersion() string
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700233 useVndk() bool
Justin Yun8effde42017-06-23 19:24:43 +0900234 isVndk() bool
235 isVndkSp() bool
Logan Chienf3511742017-10-31 18:04:35 +0800236 isVndkExt() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900237 inRecovery() bool
Logan Chien2f2b8902018-07-10 15:01:19 +0800238 shouldCreateVndkSourceAbiDump() bool
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700239 selectedStl() string
Colin Crossce75d2c2016-10-06 16:12:58 -0700240 baseModuleName() string
Logan Chienf3511742017-10-31 18:04:35 +0800241 getVndkExtendsModuleName() string
Yi Kong7e53c572018-02-14 18:16:12 +0800242 isPgoCompile() bool
Colin Crossca860ac2016-01-04 14:34:37 -0800243}
244
245type ModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700246 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800247 ModuleContextIntf
248}
249
250type BaseModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700251 android.BaseContext
Colin Crossca860ac2016-01-04 14:34:37 -0800252 ModuleContextIntf
253}
254
Colin Cross37047f12016-12-13 17:06:13 -0800255type DepsContext interface {
256 android.BottomUpMutatorContext
257 ModuleContextIntf
258}
259
Colin Crossca860ac2016-01-04 14:34:37 -0800260type feature interface {
261 begin(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800262 deps(ctx DepsContext, deps Deps) Deps
Colin Crossca860ac2016-01-04 14:34:37 -0800263 flags(ctx ModuleContext, flags Flags) Flags
264 props() []interface{}
265}
266
267type compiler interface {
Colin Cross42742b82016-08-01 13:20:05 -0700268 compilerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800269 compilerDeps(ctx DepsContext, deps Deps) Deps
Colin Crossf18e1102017-11-16 14:33:08 -0800270 compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags
Colin Cross42742b82016-08-01 13:20:05 -0700271 compilerProps() []interface{}
272
Colin Cross76fada02016-07-27 10:31:13 -0700273 appendCflags([]string)
274 appendAsflags([]string)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700275 compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800276}
277
278type linker interface {
Colin Cross42742b82016-08-01 13:20:05 -0700279 linkerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800280 linkerDeps(ctx DepsContext, deps Deps) Deps
Colin Cross42742b82016-08-01 13:20:05 -0700281 linkerFlags(ctx ModuleContext, flags Flags) Flags
282 linkerProps() []interface{}
283
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700284 link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
Colin Cross76fada02016-07-27 10:31:13 -0700285 appendLdflags([]string)
Colin Crossca860ac2016-01-04 14:34:37 -0800286}
287
288type installer interface {
Colin Cross42742b82016-08-01 13:20:05 -0700289 installerProps() []interface{}
Colin Cross635c3b02016-05-18 15:37:25 -0700290 install(ctx ModuleContext, path android.Path)
Colin Crossca860ac2016-01-04 14:34:37 -0800291 inData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700292 inSanitizerDir() bool
Dan Willemsen4aa75ca2016-09-28 16:18:03 -0700293 hostToolPath() android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800294}
295
Colin Crossc99deeb2016-04-11 15:06:20 -0700296type dependencyTag struct {
297 blueprint.BaseDependencyTag
298 name string
299 library bool
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700300
301 reexportFlags bool
Colin Crossc99deeb2016-04-11 15:06:20 -0700302}
303
304var (
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700305 sharedDepTag = dependencyTag{name: "shared", library: true}
306 sharedExportDepTag = dependencyTag{name: "shared", library: true, reexportFlags: true}
307 lateSharedDepTag = dependencyTag{name: "late shared", library: true}
308 staticDepTag = dependencyTag{name: "static", library: true}
309 staticExportDepTag = dependencyTag{name: "static", library: true, reexportFlags: true}
310 lateStaticDepTag = dependencyTag{name: "late static", library: true}
311 wholeStaticDepTag = dependencyTag{name: "whole static", library: true, reexportFlags: true}
Colin Cross32ec36c2016-12-15 07:39:51 -0800312 headerDepTag = dependencyTag{name: "header", library: true}
313 headerExportDepTag = dependencyTag{name: "header", library: true, reexportFlags: true}
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700314 genSourceDepTag = dependencyTag{name: "gen source"}
315 genHeaderDepTag = dependencyTag{name: "gen header"}
316 genHeaderExportDepTag = dependencyTag{name: "gen header", reexportFlags: true}
317 objDepTag = dependencyTag{name: "obj"}
318 crtBeginDepTag = dependencyTag{name: "crtbegin"}
319 crtEndDepTag = dependencyTag{name: "crtend"}
Dan Willemsena0790e32018-10-12 00:24:23 -0700320 linkerFlagsDepTag = dependencyTag{name: "linker flags file"}
321 dynamicLinkerDepTag = dependencyTag{name: "dynamic linker"}
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700322 reuseObjTag = dependencyTag{name: "reuse objects"}
323 ndkStubDepTag = dependencyTag{name: "ndk stub", library: true}
324 ndkLateStubDepTag = dependencyTag{name: "ndk late stub", library: true}
Logan Chienf3511742017-10-31 18:04:35 +0800325 vndkExtDepTag = dependencyTag{name: "vndk extends", library: true}
Logan Chien43d34c32017-12-20 01:17:32 +0800326 runtimeDepTag = dependencyTag{name: "runtime lib"}
Colin Crossc99deeb2016-04-11 15:06:20 -0700327)
328
Colin Crossca860ac2016-01-04 14:34:37 -0800329// Module contains the properties and members used by all C/C++ module types, and implements
330// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
331// to construct the output file. Behavior can be customized with a Customizer interface
332type Module struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700333 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -0700334 android.DefaultableModuleBase
Jiyong Park9d452992018-10-03 00:38:19 +0900335 android.ApexModuleBase
Colin Crossc472d572015-03-17 15:06:21 -0700336
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700337 Properties BaseProperties
338 VendorProperties VendorProperties
Colin Crossfa138792015-04-24 17:31:52 -0700339
Colin Crossca860ac2016-01-04 14:34:37 -0800340 // initialize before calling Init
Colin Cross635c3b02016-05-18 15:37:25 -0700341 hod android.HostOrDeviceSupported
342 multilib android.Multilib
Colin Crossc472d572015-03-17 15:06:21 -0700343
Colin Crossca860ac2016-01-04 14:34:37 -0800344 // delegates, initialize before calling Init
Colin Crossb4ce0ec2016-09-13 13:41:39 -0700345 features []feature
346 compiler compiler
347 linker linker
348 installer installer
349 stl *stl
350 sanitize *sanitize
Dan Willemsen581341d2017-02-09 16:16:31 -0800351 coverage *coverage
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800352 sabi *sabi
Justin Yun8effde42017-06-23 19:24:43 +0900353 vndkdep *vndkdep
Stephen Craneba090d12017-05-09 15:44:35 -0700354 lto *lto
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700355 pgo *pgo
Colin Cross16b23492016-01-06 14:41:07 -0800356
357 androidMkSharedLibDeps []string
Colin Cross74d1ec02015-04-28 13:30:13 -0700358
Colin Cross635c3b02016-05-18 15:37:25 -0700359 outputFile android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800360
Colin Crossb98c8b02016-07-29 13:44:28 -0700361 cachedToolchain config.Toolchain
Colin Crossb916a382016-07-29 17:28:03 -0700362
363 subAndroidMkOnce map[subAndroidMkProvider]bool
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800364
365 // Flags used to compile this module
366 flags Flags
Jeff Gaston294356f2017-09-27 17:05:30 -0700367
368 // 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 -0800369 // line invocation. depsInLinkOrder stores the proper ordering of all of the transitive
Jeff Gaston294356f2017-09-27 17:05:30 -0700370 // deps of this module
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800371 depsInLinkOrder android.Paths
372
373 // only non-nil when this is a shared library that reuses the objects of a static library
374 staticVariant *Module
Colin Crossc472d572015-03-17 15:06:21 -0700375}
376
Jiyong Parkc20eee32018-09-05 22:36:17 +0900377func (c *Module) OutputFile() android.OptionalPath {
378 return c.outputFile
379}
380
Colin Cross36242852017-06-23 15:06:31 -0700381func (c *Module) Init() android.Module {
Dan Willemsenf923f2b2018-05-09 13:45:03 -0700382 c.AddProperties(&c.Properties, &c.VendorProperties)
Colin Crossca860ac2016-01-04 14:34:37 -0800383 if c.compiler != nil {
Colin Cross36242852017-06-23 15:06:31 -0700384 c.AddProperties(c.compiler.compilerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800385 }
386 if c.linker != nil {
Colin Cross36242852017-06-23 15:06:31 -0700387 c.AddProperties(c.linker.linkerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800388 }
389 if c.installer != nil {
Colin Cross36242852017-06-23 15:06:31 -0700390 c.AddProperties(c.installer.installerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800391 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700392 if c.stl != nil {
Colin Cross36242852017-06-23 15:06:31 -0700393 c.AddProperties(c.stl.props()...)
Colin Crossa8e07cc2016-04-04 15:07:06 -0700394 }
Colin Cross16b23492016-01-06 14:41:07 -0800395 if c.sanitize != nil {
Colin Cross36242852017-06-23 15:06:31 -0700396 c.AddProperties(c.sanitize.props()...)
Colin Cross16b23492016-01-06 14:41:07 -0800397 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800398 if c.coverage != nil {
Colin Cross36242852017-06-23 15:06:31 -0700399 c.AddProperties(c.coverage.props()...)
Dan Willemsen581341d2017-02-09 16:16:31 -0800400 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800401 if c.sabi != nil {
Colin Cross36242852017-06-23 15:06:31 -0700402 c.AddProperties(c.sabi.props()...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800403 }
Justin Yun8effde42017-06-23 19:24:43 +0900404 if c.vndkdep != nil {
405 c.AddProperties(c.vndkdep.props()...)
406 }
Stephen Craneba090d12017-05-09 15:44:35 -0700407 if c.lto != nil {
408 c.AddProperties(c.lto.props()...)
409 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700410 if c.pgo != nil {
411 c.AddProperties(c.pgo.props()...)
412 }
Colin Crossca860ac2016-01-04 14:34:37 -0800413 for _, feature := range c.features {
Colin Cross36242852017-06-23 15:06:31 -0700414 c.AddProperties(feature.props()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800415 }
Colin Crossc472d572015-03-17 15:06:21 -0700416
Colin Crossa9d8bee2018-10-02 13:59:46 -0700417 c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
418 switch class {
419 case android.Device:
420 return ctx.Config().DevicePrefer32BitExecutables()
421 case android.HostCross:
422 // Windows builds always prefer 32-bit
423 return true
424 default:
425 return false
426 }
427 })
Colin Cross36242852017-06-23 15:06:31 -0700428 android.InitAndroidArchModule(c, c.hod, c.multilib)
Colin Crossc472d572015-03-17 15:06:21 -0700429
Colin Cross1f44a3a2017-07-07 14:33:33 -0700430 android.InitDefaultableModule(c)
Colin Cross36242852017-06-23 15:06:31 -0700431
Jiyong Park9d452992018-10-03 00:38:19 +0900432 android.InitApexModule(c)
433
Colin Cross36242852017-06-23 15:06:31 -0700434 return c
Colin Crossc472d572015-03-17 15:06:21 -0700435}
436
Colin Crossb916a382016-07-29 17:28:03 -0700437// Returns true for dependency roots (binaries)
438// TODO(ccross): also handle dlopenable libraries
439func (c *Module) isDependencyRoot() bool {
440 if root, ok := c.linker.(interface {
441 isDependencyRoot() bool
442 }); ok {
443 return root.isDependencyRoot()
444 }
445 return false
446}
447
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700448func (c *Module) useVndk() bool {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700449 return c.Properties.UseVndk
450}
451
Justin Yun8effde42017-06-23 19:24:43 +0900452func (c *Module) isVndk() bool {
Logan Chienf3511742017-10-31 18:04:35 +0800453 if vndkdep := c.vndkdep; vndkdep != nil {
454 return vndkdep.isVndk()
Justin Yun8effde42017-06-23 19:24:43 +0900455 }
456 return false
457}
458
Yi Kong7e53c572018-02-14 18:16:12 +0800459func (c *Module) isPgoCompile() bool {
460 if pgo := c.pgo; pgo != nil {
461 return pgo.Properties.PgoCompile
462 }
463 return false
464}
465
Logan Chienf3511742017-10-31 18:04:35 +0800466func (c *Module) isVndkSp() bool {
467 if vndkdep := c.vndkdep; vndkdep != nil {
468 return vndkdep.isVndkSp()
469 }
470 return false
471}
472
473func (c *Module) isVndkExt() bool {
474 if vndkdep := c.vndkdep; vndkdep != nil {
475 return vndkdep.isVndkExt()
476 }
477 return false
478}
479
480func (c *Module) getVndkExtendsModuleName() string {
481 if vndkdep := c.vndkdep; vndkdep != nil {
482 return vndkdep.getVndkExtendsModuleName()
483 }
484 return ""
485}
486
Jiyong Park82e2bf32017-08-16 14:05:54 +0900487// Returns true only when this module is configured to have core and vendor
488// variants.
489func (c *Module) hasVendorVariant() bool {
490 return c.isVndk() || Bool(c.VendorProperties.Vendor_available)
491}
492
Jiyong Parkf9332f12018-02-01 00:54:12 +0900493func (c *Module) inRecovery() bool {
494 return c.Properties.InRecovery || c.ModuleBase.InstallInRecovery()
495}
496
497func (c *Module) onlyInRecovery() bool {
498 return c.ModuleBase.InstallInRecovery()
499}
500
Colin Crossca860ac2016-01-04 14:34:37 -0800501type baseModuleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700502 android.BaseContext
Colin Crossca860ac2016-01-04 14:34:37 -0800503 moduleContextImpl
504}
505
Colin Cross37047f12016-12-13 17:06:13 -0800506type depsContext struct {
507 android.BottomUpMutatorContext
508 moduleContextImpl
509}
510
Colin Crossca860ac2016-01-04 14:34:37 -0800511type moduleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700512 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800513 moduleContextImpl
514}
515
Jiyong Park2db76922017-11-08 16:03:48 +0900516func (ctx *moduleContext) SocSpecific() bool {
517 return ctx.ModuleContext.SocSpecific() ||
518 (ctx.mod.hasVendorVariant() && ctx.mod.useVndk() && !ctx.mod.isVndk())
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700519}
520
Colin Crossca860ac2016-01-04 14:34:37 -0800521type moduleContextImpl struct {
522 mod *Module
523 ctx BaseModuleContext
524}
525
Colin Crossb98c8b02016-07-29 13:44:28 -0700526func (ctx *moduleContextImpl) toolchain() config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -0800527 return ctx.mod.toolchain(ctx.ctx)
528}
529
530func (ctx *moduleContextImpl) static() bool {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000531 return ctx.mod.static()
Colin Crossca860ac2016-01-04 14:34:37 -0800532}
533
534func (ctx *moduleContextImpl) staticBinary() bool {
Colin Crossb916a382016-07-29 17:28:03 -0700535 if static, ok := ctx.mod.linker.(interface {
536 staticBinary() bool
537 }); ok {
538 return static.staticBinary()
Colin Crossca860ac2016-01-04 14:34:37 -0800539 }
Colin Crossb916a382016-07-29 17:28:03 -0700540 return false
Colin Crossca860ac2016-01-04 14:34:37 -0800541}
542
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700543func (ctx *moduleContextImpl) useSdk() bool {
Jiyong Parkf9332f12018-02-01 00:54:12 +0900544 if ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRecovery() {
Nan Zhang0007d812017-11-07 10:57:05 -0800545 return String(ctx.mod.Properties.Sdk_version) != ""
Dan Willemsena96ff642016-06-07 12:34:45 -0700546 }
547 return false
Colin Crossca860ac2016-01-04 14:34:37 -0800548}
549
550func (ctx *moduleContextImpl) sdkVersion() string {
Dan Willemsena96ff642016-06-07 12:34:45 -0700551 if ctx.ctx.Device() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700552 if ctx.useVndk() {
Justin Yun732aa6a2018-03-23 17:43:47 +0900553 vndk_ver := ctx.ctx.DeviceConfig().VndkVersion()
Ryan Prichard05206112018-03-26 21:25:27 -0700554 if vndk_ver == "current" {
Justin Yun732aa6a2018-03-23 17:43:47 +0900555 platform_vndk_ver := ctx.ctx.DeviceConfig().PlatformVndkVersion()
556 if inList(platform_vndk_ver, ctx.ctx.Config().PlatformVersionCombinedCodenames()) {
557 return "current"
558 }
559 return platform_vndk_ver
560 }
561 return vndk_ver
Dan Willemsend2ede872016-11-18 14:54:24 -0800562 }
Justin Yun732aa6a2018-03-23 17:43:47 +0900563 return String(ctx.mod.Properties.Sdk_version)
Dan Willemsena96ff642016-06-07 12:34:45 -0700564 }
565 return ""
Colin Crossca860ac2016-01-04 14:34:37 -0800566}
567
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700568func (ctx *moduleContextImpl) useVndk() bool {
569 return ctx.mod.useVndk()
570}
Justin Yun8effde42017-06-23 19:24:43 +0900571
Logan Chienf3511742017-10-31 18:04:35 +0800572func (ctx *moduleContextImpl) isVndk() bool {
573 return ctx.mod.isVndk()
574}
575
Yi Kong7e53c572018-02-14 18:16:12 +0800576func (ctx *moduleContextImpl) isPgoCompile() bool {
577 return ctx.mod.isPgoCompile()
578}
579
Justin Yun8effde42017-06-23 19:24:43 +0900580func (ctx *moduleContextImpl) isVndkSp() bool {
Logan Chienf3511742017-10-31 18:04:35 +0800581 return ctx.mod.isVndkSp()
582}
583
584func (ctx *moduleContextImpl) isVndkExt() bool {
585 return ctx.mod.isVndkExt()
Justin Yun8effde42017-06-23 19:24:43 +0900586}
587
Jiyong Parkf9332f12018-02-01 00:54:12 +0900588func (ctx *moduleContextImpl) inRecovery() bool {
589 return ctx.mod.inRecovery()
590}
591
Logan Chien2f2b8902018-07-10 15:01:19 +0800592// Check whether ABI dumps should be created for this module.
593func (ctx *moduleContextImpl) shouldCreateVndkSourceAbiDump() bool {
594 if ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") {
595 return false
Jayant Chowdharyea0a2e12018-03-01 19:12:16 -0800596 }
Logan Chien2f2b8902018-07-10 15:01:19 +0800597 if sanitize := ctx.mod.sanitize; sanitize != nil {
598 if !sanitize.isVariantOnProductionDevice() {
599 return false
600 }
601 }
602 if !ctx.ctx.Device() {
603 // Host modules do not need ABI dumps.
604 return false
605 }
606 if inList(ctx.baseModuleName(), llndkLibraries) {
607 return true
608 }
Logan Chienf4b79c62018-08-02 02:27:02 +0800609 if inList(ctx.baseModuleName(), ndkMigratedLibs) {
610 return true
611 }
Logan Chien2f2b8902018-07-10 15:01:19 +0800612 if ctx.useVndk() && ctx.isVndk() {
613 // Return true if this is VNDK-core, VNDK-SP, or VNDK-Ext and this is not
614 // VNDK-private.
615 return Bool(ctx.mod.VendorProperties.Vendor_available) || ctx.isVndkExt()
616 }
617 return false
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800618}
619
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700620func (ctx *moduleContextImpl) selectedStl() string {
621 if stl := ctx.mod.stl; stl != nil {
622 return stl.Properties.SelectedStl
623 }
624 return ""
625}
626
Colin Crossce75d2c2016-10-06 16:12:58 -0700627func (ctx *moduleContextImpl) baseModuleName() string {
628 return ctx.mod.ModuleBase.BaseModuleName()
629}
630
Logan Chienf3511742017-10-31 18:04:35 +0800631func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
632 return ctx.mod.getVndkExtendsModuleName()
633}
634
Colin Cross635c3b02016-05-18 15:37:25 -0700635func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -0800636 return &Module{
637 hod: hod,
638 multilib: multilib,
639 }
640}
641
Colin Cross635c3b02016-05-18 15:37:25 -0700642func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -0800643 module := newBaseModule(hod, multilib)
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700644 module.features = []feature{
645 &tidyFeature{},
646 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700647 module.stl = &stl{}
Colin Cross16b23492016-01-06 14:41:07 -0800648 module.sanitize = &sanitize{}
Dan Willemsen581341d2017-02-09 16:16:31 -0800649 module.coverage = &coverage{}
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800650 module.sabi = &sabi{}
Justin Yun8effde42017-06-23 19:24:43 +0900651 module.vndkdep = &vndkdep{}
Stephen Craneba090d12017-05-09 15:44:35 -0700652 module.lto = &lto{}
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700653 module.pgo = &pgo{}
Colin Crossca860ac2016-01-04 14:34:37 -0800654 return module
655}
656
Colin Crossce75d2c2016-10-06 16:12:58 -0700657func (c *Module) Prebuilt() *android.Prebuilt {
658 if p, ok := c.linker.(prebuiltLinkerInterface); ok {
659 return p.prebuilt()
660 }
661 return nil
662}
663
664func (c *Module) Name() string {
665 name := c.ModuleBase.Name()
Dan Willemsen01a90592017-04-07 15:21:13 -0700666 if p, ok := c.linker.(interface {
667 Name(string) string
668 }); ok {
Colin Crossce75d2c2016-10-06 16:12:58 -0700669 name = p.Name(name)
670 }
671 return name
672}
673
Jeff Gaston294356f2017-09-27 17:05:30 -0700674// orderDeps reorders dependencies into a list such that if module A depends on B, then
675// A will precede B in the resultant list.
676// This is convenient for passing into a linker.
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800677// Note that directSharedDeps should be the analogous static library for each shared lib dep
678func 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 -0700679 // If A depends on B, then
680 // Every list containing A will also contain B later in the list
681 // So, after concatenating all lists, the final instance of B will have come from the same
682 // original list as the final instance of A
683 // So, the final instance of B will be later in the concatenation than the final A
684 // So, keeping only the final instance of A and of B ensures that A is earlier in the output
685 // list than B
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800686 for _, dep := range directStaticDeps {
Jeff Gaston294356f2017-09-27 17:05:30 -0700687 orderedAllDeps = append(orderedAllDeps, dep)
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800688 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
689 }
690 for _, dep := range directSharedDeps {
691 orderedAllDeps = append(orderedAllDeps, dep)
692 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
Jeff Gaston294356f2017-09-27 17:05:30 -0700693 }
694
Colin Crossb6715442017-10-24 11:13:31 -0700695 orderedAllDeps = android.LastUniquePaths(orderedAllDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700696
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800697 // We don't want to add any new dependencies into directStaticDeps (to allow the caller to
Jeff Gaston294356f2017-09-27 17:05:30 -0700698 // intentionally exclude or replace any unwanted transitive dependencies), so we limit the
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800699 // resultant list to only what the caller has chosen to include in directStaticDeps
700 _, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700701
702 return orderedAllDeps, orderedDeclaredDeps
703}
704
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800705func orderStaticModuleDeps(module *Module, staticDeps []*Module, sharedDeps []*Module) (results []android.Path) {
706 // convert Module to Path
707 allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps))
708 staticDepFiles := []android.Path{}
709 for _, dep := range staticDeps {
710 allTransitiveDeps[dep.outputFile.Path()] = dep.depsInLinkOrder
711 staticDepFiles = append(staticDepFiles, dep.outputFile.Path())
Jeff Gaston294356f2017-09-27 17:05:30 -0700712 }
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800713 sharedDepFiles := []android.Path{}
714 for _, sharedDep := range sharedDeps {
715 staticAnalogue := sharedDep.staticVariant
716 if staticAnalogue != nil {
717 allTransitiveDeps[staticAnalogue.outputFile.Path()] = staticAnalogue.depsInLinkOrder
718 sharedDepFiles = append(sharedDepFiles, staticAnalogue.outputFile.Path())
719 }
Jeff Gaston294356f2017-09-27 17:05:30 -0700720 }
721
722 // reorder the dependencies based on transitive dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800723 module.depsInLinkOrder, results = orderDeps(staticDepFiles, sharedDepFiles, allTransitiveDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700724
725 return results
Jeff Gaston294356f2017-09-27 17:05:30 -0700726}
727
Colin Cross635c3b02016-05-18 15:37:25 -0700728func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
Colin Crossca860ac2016-01-04 14:34:37 -0800729 ctx := &moduleContext{
Colin Cross635c3b02016-05-18 15:37:25 -0700730 ModuleContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -0800731 moduleContextImpl: moduleContextImpl{
732 mod: c,
733 },
734 }
735 ctx.ctx = ctx
736
Colin Crossf18e1102017-11-16 14:33:08 -0800737 deps := c.depsToPaths(ctx)
738 if ctx.Failed() {
739 return
740 }
741
Dan Willemsen8536d6b2018-10-07 20:54:34 -0700742 if c.Properties.Clang != nil && *c.Properties.Clang == false {
743 ctx.PropertyErrorf("clang", "false (GCC) is no longer supported")
744 }
745
Colin Crossca860ac2016-01-04 14:34:37 -0800746 flags := Flags{
747 Toolchain: c.toolchain(ctx),
Colin Crossca860ac2016-01-04 14:34:37 -0800748 }
Colin Crossca860ac2016-01-04 14:34:37 -0800749 if c.compiler != nil {
Colin Crossf18e1102017-11-16 14:33:08 -0800750 flags = c.compiler.compilerFlags(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -0800751 }
752 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700753 flags = c.linker.linkerFlags(ctx, flags)
Colin Crossca860ac2016-01-04 14:34:37 -0800754 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700755 if c.stl != nil {
756 flags = c.stl.flags(ctx, flags)
757 }
Colin Cross16b23492016-01-06 14:41:07 -0800758 if c.sanitize != nil {
759 flags = c.sanitize.flags(ctx, flags)
760 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800761 if c.coverage != nil {
762 flags = c.coverage.flags(ctx, flags)
763 }
Stephen Craneba090d12017-05-09 15:44:35 -0700764 if c.lto != nil {
765 flags = c.lto.flags(ctx, flags)
766 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700767 if c.pgo != nil {
768 flags = c.pgo.flags(ctx, flags)
769 }
Colin Crossca860ac2016-01-04 14:34:37 -0800770 for _, feature := range c.features {
771 flags = feature.flags(ctx, flags)
772 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800773 if ctx.Failed() {
774 return
775 }
776
Colin Crossb98c8b02016-07-29 13:44:28 -0700777 flags.CFlags, _ = filterList(flags.CFlags, config.IllegalFlags)
778 flags.CppFlags, _ = filterList(flags.CppFlags, config.IllegalFlags)
779 flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags)
Colin Cross3f40fa42015-01-30 17:27:36 -0800780
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800781 flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...)
782 c.flags = flags
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700783 // We need access to all the flags seen by a source file.
784 if c.sabi != nil {
785 flags = c.sabi.flags(ctx, flags)
786 }
Colin Crossca860ac2016-01-04 14:34:37 -0800787 // Optimization to reduce size of build.ninja
788 // Replace the long list of flags for each file with a module-local variable
789 ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " "))
790 ctx.Variable(pctx, "cppflags", strings.Join(flags.CppFlags, " "))
791 ctx.Variable(pctx, "asflags", strings.Join(flags.AsFlags, " "))
792 flags.CFlags = []string{"$cflags"}
793 flags.CppFlags = []string{"$cppflags"}
794 flags.AsFlags = []string{"$asflags"}
795
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700796 var objs Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800797 if c.compiler != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700798 objs = c.compiler.compile(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -0800799 if ctx.Failed() {
800 return
801 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800802 }
803
Colin Crossca860ac2016-01-04 14:34:37 -0800804 if c.linker != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700805 outputFile := c.linker.link(ctx, flags, deps, objs)
Colin Crossca860ac2016-01-04 14:34:37 -0800806 if ctx.Failed() {
807 return
808 }
Colin Cross635c3b02016-05-18 15:37:25 -0700809 c.outputFile = android.OptionalPathForPath(outputFile)
Colin Crossce75d2c2016-10-06 16:12:58 -0700810 }
Colin Cross5049f022015-03-18 13:28:46 -0700811
Jiyong Park9d452992018-10-03 00:38:19 +0900812 if c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() {
Colin Crossce75d2c2016-10-06 16:12:58 -0700813 c.installer.install(ctx, c.outputFile.Path())
814 if ctx.Failed() {
815 return
Colin Crossca860ac2016-01-04 14:34:37 -0800816 }
Dan Albertc403f7c2015-03-18 14:01:18 -0700817 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800818}
819
Colin Crossb98c8b02016-07-29 13:44:28 -0700820func (c *Module) toolchain(ctx BaseModuleContext) config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -0800821 if c.cachedToolchain == nil {
Colin Crossb98c8b02016-07-29 13:44:28 -0700822 c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
Colin Cross3f40fa42015-01-30 17:27:36 -0800823 }
Colin Crossca860ac2016-01-04 14:34:37 -0800824 return c.cachedToolchain
Colin Cross3f40fa42015-01-30 17:27:36 -0800825}
826
Colin Crossca860ac2016-01-04 14:34:37 -0800827func (c *Module) begin(ctx BaseModuleContext) {
828 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700829 c.compiler.compilerInit(ctx)
Colin Cross21b9a242015-03-24 14:15:58 -0700830 }
Colin Crossca860ac2016-01-04 14:34:37 -0800831 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700832 c.linker.linkerInit(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -0800833 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700834 if c.stl != nil {
835 c.stl.begin(ctx)
836 }
Colin Cross16b23492016-01-06 14:41:07 -0800837 if c.sanitize != nil {
838 c.sanitize.begin(ctx)
839 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800840 if c.coverage != nil {
841 c.coverage.begin(ctx)
842 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800843 if c.sabi != nil {
844 c.sabi.begin(ctx)
845 }
Justin Yun8effde42017-06-23 19:24:43 +0900846 if c.vndkdep != nil {
847 c.vndkdep.begin(ctx)
848 }
Stephen Craneba090d12017-05-09 15:44:35 -0700849 if c.lto != nil {
850 c.lto.begin(ctx)
851 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700852 if c.pgo != nil {
853 c.pgo.begin(ctx)
854 }
Colin Crossca860ac2016-01-04 14:34:37 -0800855 for _, feature := range c.features {
856 feature.begin(ctx)
857 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700858 if ctx.useSdk() {
Dan Albertf5415d72017-08-17 16:19:59 -0700859 version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
Dan Albert7fa7b2e2016-08-05 16:37:52 -0700860 if err != nil {
861 ctx.PropertyErrorf("sdk_version", err.Error())
862 }
Nan Zhang0007d812017-11-07 10:57:05 -0800863 c.Properties.Sdk_version = StringPtr(version)
Dan Albert7fa7b2e2016-08-05 16:37:52 -0700864 }
Colin Crossca860ac2016-01-04 14:34:37 -0800865}
866
Colin Cross37047f12016-12-13 17:06:13 -0800867func (c *Module) deps(ctx DepsContext) Deps {
Colin Crossc99deeb2016-04-11 15:06:20 -0700868 deps := Deps{}
869
870 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700871 deps = c.compiler.compilerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -0700872 }
Pirama Arumuga Nainar0b882f02018-04-23 22:44:39 +0000873 // Add the PGO dependency (the clang_rt.profile runtime library), which
874 // sometimes depends on symbols from libgcc, before libgcc gets added
875 // in linkerDeps().
Pirama Arumuga Nainar49b53d52017-10-04 16:47:29 -0700876 if c.pgo != nil {
877 deps = c.pgo.deps(ctx, deps)
878 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700879 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700880 deps = c.linker.linkerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -0700881 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700882 if c.stl != nil {
883 deps = c.stl.deps(ctx, deps)
884 }
Colin Cross16b23492016-01-06 14:41:07 -0800885 if c.sanitize != nil {
886 deps = c.sanitize.deps(ctx, deps)
887 }
Pirama Arumuga Nainar0b882f02018-04-23 22:44:39 +0000888 if c.coverage != nil {
889 deps = c.coverage.deps(ctx, deps)
890 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800891 if c.sabi != nil {
892 deps = c.sabi.deps(ctx, deps)
893 }
Justin Yun8effde42017-06-23 19:24:43 +0900894 if c.vndkdep != nil {
895 deps = c.vndkdep.deps(ctx, deps)
896 }
Stephen Craneba090d12017-05-09 15:44:35 -0700897 if c.lto != nil {
898 deps = c.lto.deps(ctx, deps)
899 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700900 for _, feature := range c.features {
901 deps = feature.deps(ctx, deps)
902 }
903
Colin Crossb6715442017-10-24 11:13:31 -0700904 deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
905 deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
906 deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
907 deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
908 deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
909 deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
Logan Chien43d34c32017-12-20 01:17:32 +0800910 deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
Colin Crossc99deeb2016-04-11 15:06:20 -0700911
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700912 for _, lib := range deps.ReexportSharedLibHeaders {
913 if !inList(lib, deps.SharedLibs) {
914 ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
915 }
916 }
917
918 for _, lib := range deps.ReexportStaticLibHeaders {
919 if !inList(lib, deps.StaticLibs) {
920 ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs: '%s'", lib)
921 }
922 }
923
Colin Cross5950f382016-12-13 12:50:57 -0800924 for _, lib := range deps.ReexportHeaderLibHeaders {
925 if !inList(lib, deps.HeaderLibs) {
926 ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib)
927 }
928 }
929
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700930 for _, gen := range deps.ReexportGeneratedHeaders {
931 if !inList(gen, deps.GeneratedHeaders) {
932 ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen)
933 }
934 }
935
Colin Crossc99deeb2016-04-11 15:06:20 -0700936 return deps
937}
938
Dan Albert7e9d2952016-08-04 13:02:36 -0700939func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
Colin Crossca860ac2016-01-04 14:34:37 -0800940 ctx := &baseModuleContext{
Colin Cross635c3b02016-05-18 15:37:25 -0700941 BaseContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -0800942 moduleContextImpl: moduleContextImpl{
943 mod: c,
944 },
945 }
946 ctx.ctx = ctx
947
Colin Crossca860ac2016-01-04 14:34:37 -0800948 c.begin(ctx)
Dan Albert7e9d2952016-08-04 13:02:36 -0700949}
950
Jiyong Park7ed9de32018-10-15 22:25:07 +0900951// Split name#version into name and version
952func stubsLibNameAndVersion(name string) (string, string) {
953 if sharp := strings.LastIndex(name, "#"); sharp != -1 && sharp != len(name)-1 {
954 version := name[sharp+1:]
955 libname := name[:sharp]
956 return libname, version
957 }
958 return name, ""
959}
960
Colin Cross1e676be2016-10-12 14:38:15 -0700961func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
Colin Cross37047f12016-12-13 17:06:13 -0800962 ctx := &depsContext{
963 BottomUpMutatorContext: actx,
Dan Albert7e9d2952016-08-04 13:02:36 -0700964 moduleContextImpl: moduleContextImpl{
965 mod: c,
966 },
967 }
968 ctx.ctx = ctx
Colin Crossca860ac2016-01-04 14:34:37 -0800969
Colin Crossc99deeb2016-04-11 15:06:20 -0700970 deps := c.deps(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -0800971
Dan Albert914449f2016-06-17 16:45:24 -0700972 variantNdkLibs := []string{}
973 variantLateNdkLibs := []string{}
Dan Willemsenb916b802017-03-19 13:44:32 -0700974 if ctx.Os() == android.Android {
Dan Albert914449f2016-06-17 16:45:24 -0700975 version := ctx.sdkVersion()
Dan Willemsen72d39932016-07-08 23:23:48 -0700976
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700977 // rewriteNdkLibs takes a list of names of shared libraries and scans it for three types
978 // of names:
Dan Albert914449f2016-06-17 16:45:24 -0700979 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700980 // 1. Name of an NDK library that refers to a prebuilt module.
981 // For each of these, it adds the name of the prebuilt module (which will be in
982 // prebuilts/ndk) to the list of nonvariant libs.
983 // 2. Name of an NDK library that refers to an ndk_library module.
984 // For each of these, it adds the name of the ndk_library module to the list of
985 // variant libs.
986 // 3. Anything else (so anything that isn't an NDK library).
987 // It adds these to the nonvariantLibs list.
Dan Albert914449f2016-06-17 16:45:24 -0700988 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700989 // The caller can then know to add the variantLibs dependencies differently from the
990 // nonvariantLibs
991 rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
992 variantLibs = []string{}
993 nonvariantLibs = []string{}
Dan Albert914449f2016-06-17 16:45:24 -0700994 for _, entry := range list {
Jiyong Park7ed9de32018-10-15 22:25:07 +0900995 // strip #version suffix out
996 name, _ := stubsLibNameAndVersion(entry)
997 if ctx.useSdk() && inList(name, ndkPrebuiltSharedLibraries) {
998 if !inList(name, ndkMigratedLibs) {
999 nonvariantLibs = append(nonvariantLibs, name+".ndk."+version)
Dan Albert914449f2016-06-17 16:45:24 -07001000 } else {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001001 variantLibs = append(variantLibs, name+ndkLibrarySuffix)
Dan Albert914449f2016-06-17 16:45:24 -07001002 }
Jiyong Park7ed9de32018-10-15 22:25:07 +09001003 } else if ctx.useVndk() && inList(name, llndkLibraries) {
1004 nonvariantLibs = append(nonvariantLibs, name+llndkLibrarySuffix)
1005 } else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, vendorPublicLibraries) {
1006 vendorPublicLib := name + vendorPublicLibrarySuffix
Jiyong Park374510b2018-03-19 18:23:01 +09001007 if actx.OtherModuleExists(vendorPublicLib) {
1008 nonvariantLibs = append(nonvariantLibs, vendorPublicLib)
1009 } else {
1010 // This can happen if vendor_public_library module is defined in a
1011 // namespace that isn't visible to the current module. In that case,
1012 // link to the original library.
Jiyong Park7ed9de32018-10-15 22:25:07 +09001013 nonvariantLibs = append(nonvariantLibs, name)
Jiyong Park374510b2018-03-19 18:23:01 +09001014 }
Dan Albert914449f2016-06-17 16:45:24 -07001015 } else {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001016 // put name#version back
Dan Willemsen7cbf5f82017-03-28 00:08:30 -07001017 nonvariantLibs = append(nonvariantLibs, entry)
Dan Willemsen72d39932016-07-08 23:23:48 -07001018 }
1019 }
Dan Albert914449f2016-06-17 16:45:24 -07001020 return nonvariantLibs, variantLibs
Dan Willemsen72d39932016-07-08 23:23:48 -07001021 }
1022
Dan Albert914449f2016-06-17 16:45:24 -07001023 deps.SharedLibs, variantNdkLibs = rewriteNdkLibs(deps.SharedLibs)
1024 deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs)
Jiyong Park4c35af02017-07-05 13:41:55 +09001025 deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
Dan Willemsen72d39932016-07-08 23:23:48 -07001026 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001027
Jiyong Park7ed9de32018-10-15 22:25:07 +09001028 if c.linker != nil {
1029 if library, ok := c.linker.(*libraryDecorator); ok {
1030 if library.buildStubs() {
1031 // Stubs lib does not have dependency to other libraries. Don't proceed.
1032 return
1033 }
1034 }
1035 }
1036
Colin Cross32ec36c2016-12-15 07:39:51 -08001037 for _, lib := range deps.HeaderLibs {
1038 depTag := headerDepTag
1039 if inList(lib, deps.ReexportHeaderLibHeaders) {
1040 depTag = headerExportDepTag
1041 }
1042 actx.AddVariationDependencies(nil, depTag, lib)
1043 }
Colin Cross5950f382016-12-13 12:50:57 -08001044
Dan Willemsen59339a22018-07-22 21:18:45 -07001045 actx.AddVariationDependencies([]blueprint.Variation{
1046 {Mutator: "link", Variation: "static"},
1047 }, wholeStaticDepTag, deps.WholeStaticLibs...)
Colin Crossc99deeb2016-04-11 15:06:20 -07001048
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001049 for _, lib := range deps.StaticLibs {
1050 depTag := staticDepTag
1051 if inList(lib, deps.ReexportStaticLibHeaders) {
1052 depTag = staticExportDepTag
1053 }
Dan Willemsen59339a22018-07-22 21:18:45 -07001054 actx.AddVariationDependencies([]blueprint.Variation{
1055 {Mutator: "link", Variation: "static"},
1056 }, depTag, lib)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001057 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001058
Dan Willemsen59339a22018-07-22 21:18:45 -07001059 actx.AddVariationDependencies([]blueprint.Variation{
1060 {Mutator: "link", Variation: "static"},
1061 }, lateStaticDepTag, deps.LateStaticLibs...)
Colin Crossc99deeb2016-04-11 15:06:20 -07001062
Jiyong Park7ed9de32018-10-15 22:25:07 +09001063 // shared lib names without the #version suffix
1064 var sharedLibNames []string
1065
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001066 for _, lib := range deps.SharedLibs {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001067 name, version := stubsLibNameAndVersion(lib)
1068 sharedLibNames = append(sharedLibNames, name)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001069 depTag := sharedDepTag
1070 if inList(lib, deps.ReexportSharedLibHeaders) {
1071 depTag = sharedExportDepTag
1072 }
Jiyong Park7ed9de32018-10-15 22:25:07 +09001073 var variations []blueprint.Variation
1074 variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
1075 if version != "" && ctx.Os() == android.Android && !ctx.useVndk() && !c.inRecovery() {
1076 variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
1077 }
1078 actx.AddVariationDependencies(variations, depTag, name)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001079 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001080
Jiyong Park7ed9de32018-10-15 22:25:07 +09001081 for _, lib := range deps.LateSharedLibs {
1082 name, version := stubsLibNameAndVersion(lib)
1083 if inList(name, sharedLibNames) {
1084 // This is to handle the case that some of the late shared libs (libc, libdl, libm, ...)
1085 // are added also to SharedLibs with version (e.g., libc#10). If not skipped, we will be
1086 // linking against both the stubs lib and the non-stubs lib at the same time.
1087 continue
1088 }
1089 depTag := lateSharedDepTag
1090 var variations []blueprint.Variation
1091 variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
1092 if version != "" && ctx.Os() == android.Android && !ctx.useVndk() && !c.inRecovery() {
1093 variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
1094 }
1095 actx.AddVariationDependencies(variations, depTag, name)
1096 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001097
Dan Willemsen59339a22018-07-22 21:18:45 -07001098 actx.AddVariationDependencies([]blueprint.Variation{
1099 {Mutator: "link", Variation: "shared"},
1100 }, runtimeDepTag, deps.RuntimeLibs...)
Logan Chien43d34c32017-12-20 01:17:32 +08001101
Colin Cross68861832016-07-08 10:41:41 -07001102 actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...)
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001103
1104 for _, gen := range deps.GeneratedHeaders {
1105 depTag := genHeaderDepTag
1106 if inList(gen, deps.ReexportGeneratedHeaders) {
1107 depTag = genHeaderExportDepTag
1108 }
1109 actx.AddDependency(c, depTag, gen)
1110 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001111
Colin Cross42d48b72018-08-29 14:10:52 -07001112 actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)
Colin Crossc99deeb2016-04-11 15:06:20 -07001113
1114 if deps.CrtBegin != "" {
Colin Cross42d48b72018-08-29 14:10:52 -07001115 actx.AddVariationDependencies(nil, crtBeginDepTag, deps.CrtBegin)
Colin Crossca860ac2016-01-04 14:34:37 -08001116 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001117 if deps.CrtEnd != "" {
Colin Cross42d48b72018-08-29 14:10:52 -07001118 actx.AddVariationDependencies(nil, crtEndDepTag, deps.CrtEnd)
Colin Cross21b9a242015-03-24 14:15:58 -07001119 }
Dan Willemsena0790e32018-10-12 00:24:23 -07001120 if deps.LinkerFlagsFile != "" {
1121 actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
1122 }
1123 if deps.DynamicLinker != "" {
1124 actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001125 }
Dan Albert914449f2016-06-17 16:45:24 -07001126
1127 version := ctx.sdkVersion()
1128 actx.AddVariationDependencies([]blueprint.Variation{
Dan Willemsen59339a22018-07-22 21:18:45 -07001129 {Mutator: "ndk_api", Variation: version},
1130 {Mutator: "link", Variation: "shared"},
1131 }, ndkStubDepTag, variantNdkLibs...)
Dan Albert914449f2016-06-17 16:45:24 -07001132 actx.AddVariationDependencies([]blueprint.Variation{
Dan Willemsen59339a22018-07-22 21:18:45 -07001133 {Mutator: "ndk_api", Variation: version},
1134 {Mutator: "link", Variation: "shared"},
1135 }, ndkLateStubDepTag, variantLateNdkLibs...)
Logan Chienf3511742017-10-31 18:04:35 +08001136
1137 if vndkdep := c.vndkdep; vndkdep != nil {
1138 if vndkdep.isVndkExt() {
1139 baseModuleMode := vendorMode
1140 if actx.DeviceConfig().VndkVersion() == "" {
1141 baseModuleMode = coreMode
1142 }
1143 actx.AddVariationDependencies([]blueprint.Variation{
Dan Willemsen59339a22018-07-22 21:18:45 -07001144 {Mutator: "image", Variation: baseModuleMode},
1145 {Mutator: "link", Variation: "shared"},
1146 }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
Logan Chienf3511742017-10-31 18:04:35 +08001147 }
1148 }
Colin Cross6362e272015-10-29 15:25:03 -07001149}
Colin Cross21b9a242015-03-24 14:15:58 -07001150
Colin Crosse40b4ea2018-10-02 22:25:58 -07001151func BeginMutator(ctx android.BottomUpMutatorContext) {
Dan Albert7e9d2952016-08-04 13:02:36 -07001152 if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
1153 c.beginMutator(ctx)
1154 }
1155}
1156
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001157// Whether a module can link to another module, taking into
1158// account NDK linking.
Logan Chienf3511742017-10-31 18:04:35 +08001159func checkLinkType(ctx android.ModuleContext, from *Module, to *Module, tag dependencyTag) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001160 if from.Target().Os != android.Android {
1161 // Host code is not restricted
1162 return
1163 }
1164 if from.Properties.UseVndk {
1165 // Though vendor code is limited by the vendor mutator,
1166 // each vendor-available module needs to check
1167 // link-type for VNDK.
1168 if from.vndkdep != nil {
Logan Chienf3511742017-10-31 18:04:35 +08001169 from.vndkdep.vndkCheckLinkType(ctx, to, tag)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001170 }
1171 return
1172 }
Nan Zhang0007d812017-11-07 10:57:05 -08001173 if String(from.Properties.Sdk_version) == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001174 // Platform code can link to anything
1175 return
1176 }
Jiyong Parkf9332f12018-02-01 00:54:12 +09001177 if from.inRecovery() {
1178 // Recovery code is not NDK
1179 return
1180 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001181 if _, ok := to.linker.(*toolchainLibraryDecorator); ok {
1182 // These are always allowed
1183 return
1184 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001185 if _, ok := to.linker.(*ndkPrebuiltStlLinker); ok {
1186 // These are allowed, but they don't set sdk_version
1187 return
1188 }
1189 if _, ok := to.linker.(*stubDecorator); ok {
1190 // These aren't real libraries, but are the stub shared libraries that are included in
1191 // the NDK.
1192 return
1193 }
Nan Zhang0007d812017-11-07 10:57:05 -08001194 if String(to.Properties.Sdk_version) == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001195 // NDK code linking to platform code is never okay.
1196 ctx.ModuleErrorf("depends on non-NDK-built library %q",
1197 ctx.OtherModuleName(to))
1198 }
1199
1200 // At this point we know we have two NDK libraries, but we need to
1201 // check that we're not linking against anything built against a higher
1202 // API level, as it is only valid to link against older or equivalent
1203 // APIs.
1204
Inseob Kim01a28722018-04-11 09:48:45 +09001205 // Current can link against anything.
1206 if String(from.Properties.Sdk_version) != "current" {
1207 // Otherwise we need to check.
1208 if String(to.Properties.Sdk_version) == "current" {
1209 // Current can't be linked against by anything else.
1210 ctx.ModuleErrorf("links %q built against newer API version %q",
1211 ctx.OtherModuleName(to), "current")
1212 } else {
1213 fromApi, err := strconv.Atoi(String(from.Properties.Sdk_version))
1214 if err != nil {
1215 ctx.PropertyErrorf("sdk_version",
Inseob Kim34b22832018-04-11 10:13:16 +09001216 "Invalid sdk_version value (must be int or current): %q",
Inseob Kim01a28722018-04-11 09:48:45 +09001217 String(from.Properties.Sdk_version))
1218 }
1219 toApi, err := strconv.Atoi(String(to.Properties.Sdk_version))
1220 if err != nil {
1221 ctx.PropertyErrorf("sdk_version",
Inseob Kim34b22832018-04-11 10:13:16 +09001222 "Invalid sdk_version value (must be int or current): %q",
Inseob Kim01a28722018-04-11 09:48:45 +09001223 String(to.Properties.Sdk_version))
1224 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001225
Inseob Kim01a28722018-04-11 09:48:45 +09001226 if toApi > fromApi {
1227 ctx.ModuleErrorf("links %q built against newer API version %q",
1228 ctx.OtherModuleName(to), String(to.Properties.Sdk_version))
1229 }
1230 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001231 }
Dan Albert202fe492017-12-15 13:56:59 -08001232
1233 // Also check that the two STL choices are compatible.
1234 fromStl := from.stl.Properties.SelectedStl
1235 toStl := to.stl.Properties.SelectedStl
1236 if fromStl == "" || toStl == "" {
1237 // Libraries that don't use the STL are unrestricted.
Inseob Kimda2171a2018-04-11 15:41:38 +09001238 } else if fromStl == "ndk_system" || toStl == "ndk_system" {
Dan Albert202fe492017-12-15 13:56:59 -08001239 // We can be permissive with the system "STL" since it is only the C++
1240 // ABI layer, but in the future we should make sure that everyone is
1241 // using either libc++ or nothing.
Colin Crossb60190a2018-09-04 16:28:17 -07001242 } else if getNdkStlFamily(from) != getNdkStlFamily(to) {
Dan Albert202fe492017-12-15 13:56:59 -08001243 ctx.ModuleErrorf("uses %q and depends on %q which uses incompatible %q",
1244 from.stl.Properties.SelectedStl, ctx.OtherModuleName(to),
1245 to.stl.Properties.SelectedStl)
1246 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001247}
1248
Jiyong Park5fb8c102018-04-09 12:03:06 +09001249// Tests whether the dependent library is okay to be double loaded inside a single process.
1250// If a library is a member of VNDK and at the same time dependencies of an LLNDK library,
1251// it is subject to be double loaded. Such lib should be explicitly marked as double_loaded: true
1252// or as vndk-sp (vndk: { enabled: true, support_system_process: true}).
1253func checkDoubleLoadableLibries(ctx android.ModuleContext, from *Module, to *Module) {
1254 if _, ok := from.linker.(*libraryDecorator); !ok {
1255 return
1256 }
1257
1258 if inList(ctx.ModuleName(), llndkLibraries) ||
1259 (from.useVndk() && Bool(from.VendorProperties.Double_loadable)) {
1260 _, depIsLlndk := to.linker.(*llndkStubDecorator)
1261 depIsVndkSp := false
1262 if to.vndkdep != nil && to.vndkdep.isVndkSp() {
1263 depIsVndkSp = true
1264 }
1265 depIsVndk := false
1266 if to.vndkdep != nil && to.vndkdep.isVndk() {
1267 depIsVndk = true
1268 }
1269 depIsDoubleLoadable := Bool(to.VendorProperties.Double_loadable)
1270 if !depIsLlndk && !depIsVndkSp && !depIsDoubleLoadable && depIsVndk {
1271 ctx.ModuleErrorf("links VNDK library %q that isn't double_loadable.",
1272 ctx.OtherModuleName(to))
1273 }
1274 }
1275}
1276
Colin Crossc99deeb2016-04-11 15:06:20 -07001277// Convert dependencies to paths. Returns a PathDeps containing paths
Colin Cross635c3b02016-05-18 15:37:25 -07001278func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
Colin Crossca860ac2016-01-04 14:34:37 -08001279 var depPaths PathDeps
Colin Crossca860ac2016-01-04 14:34:37 -08001280
Jeff Gaston294356f2017-09-27 17:05:30 -07001281 directStaticDeps := []*Module{}
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001282 directSharedDeps := []*Module{}
Jeff Gaston294356f2017-09-27 17:05:30 -07001283
Colin Crossd11fcda2017-10-23 17:59:01 -07001284 ctx.VisitDirectDeps(func(dep android.Module) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001285 depName := ctx.OtherModuleName(dep)
1286 depTag := ctx.OtherModuleDependencyTag(dep)
Dan Albert9e10cd42016-08-03 14:12:14 -07001287
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001288 ccDep, _ := dep.(*Module)
1289 if ccDep == nil {
1290 // handling for a few module types that aren't cc Module but that are also supported
1291 switch depTag {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001292 case genSourceDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001293 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001294 depPaths.GeneratedSources = append(depPaths.GeneratedSources,
1295 genRule.GeneratedSourceFiles()...)
1296 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001297 ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07001298 }
Colin Crosse90bfd12017-04-26 16:59:26 -07001299 // Support exported headers from a generated_sources dependency
1300 fallthrough
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001301 case genHeaderDepTag, genHeaderExportDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001302 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001303 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
Dan Willemsen9da9d492018-02-21 18:28:18 -08001304 genRule.GeneratedDeps()...)
Colin Cross5ed99c62016-11-22 12:55:55 -08001305 flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001306 depPaths.Flags = append(depPaths.Flags, flags)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001307 if depTag == genHeaderExportDepTag {
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001308 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001309 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
Dan Willemsen9da9d492018-02-21 18:28:18 -08001310 genRule.GeneratedDeps()...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07001311 // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
1312 c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags)
1313
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001314 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001315 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001316 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07001317 }
Dan Willemsena0790e32018-10-12 00:24:23 -07001318 case linkerFlagsDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001319 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001320 files := genRule.GeneratedSourceFiles()
1321 if len(files) == 1 {
Dan Willemsena0790e32018-10-12 00:24:23 -07001322 depPaths.LinkerFlagsFile = android.OptionalPathForPath(files[0])
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001323 } else if len(files) > 1 {
Dan Willemsena0790e32018-10-12 00:24:23 -07001324 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 -07001325 }
1326 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001327 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001328 }
Colin Crossca860ac2016-01-04 14:34:37 -08001329 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001330 return
1331 }
1332
Colin Crossd11fcda2017-10-23 17:59:01 -07001333 if dep.Target().Os != ctx.Os() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001334 ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
1335 return
1336 }
Colin Crossd11fcda2017-10-23 17:59:01 -07001337 if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001338 ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
Colin Crossa1ad8d12016-06-01 17:09:44 -07001339 return
1340 }
1341
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001342 // re-exporting flags
1343 if depTag == reuseObjTag {
1344 if l, ok := ccDep.compiler.(libraryInterface); ok {
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001345 c.staticVariant = ccDep
Colin Crossbbc9f4d2017-05-03 16:24:55 -07001346 objs, flags, deps := l.reuseObjs()
Colin Cross10d22312017-05-03 11:01:58 -07001347 depPaths.Objs = depPaths.Objs.Append(objs)
1348 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
Colin Crossbbc9f4d2017-05-03 16:24:55 -07001349 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
Colin Crossbba99042016-11-23 15:45:05 -08001350 return
1351 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001352 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001353 if t, ok := depTag.(dependencyTag); ok && t.library {
1354 if i, ok := ccDep.linker.(exportedFlagsProducer); ok {
Dan Willemsen76f08272016-07-09 00:14:08 -07001355 flags := i.exportedFlags()
Dan Willemsen847dcc72016-09-29 12:13:36 -07001356 deps := i.exportedFlagsDeps()
Dan Willemsen76f08272016-07-09 00:14:08 -07001357 depPaths.Flags = append(depPaths.Flags, flags...)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001358 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, deps...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001359
1360 if t.reexportFlags {
Dan Willemsen76f08272016-07-09 00:14:08 -07001361 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001362 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07001363 // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
Jayant Chowdharyaf6eb712017-08-23 16:08:29 -07001364 // Re-exported shared library headers must be included as well since they can help us with type information
1365 // about template instantiations (instantiated from their headers).
1366 c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001367 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001368 }
Dan Willemsena96ff642016-06-07 12:34:45 -07001369
Logan Chienf3511742017-10-31 18:04:35 +08001370 checkLinkType(ctx, c, ccDep, t)
Jiyong Park5fb8c102018-04-09 12:03:06 +09001371 checkDoubleLoadableLibries(ctx, c, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07001372 }
1373
Colin Cross26c34ed2016-09-30 17:10:16 -07001374 var ptr *android.Paths
Colin Cross635c3b02016-05-18 15:37:25 -07001375 var depPtr *android.Paths
Colin Crossc99deeb2016-04-11 15:06:20 -07001376
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001377 linkFile := ccDep.outputFile
Colin Cross26c34ed2016-09-30 17:10:16 -07001378 depFile := android.OptionalPath{}
1379
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001380 switch depTag {
Dan Albert914449f2016-06-17 16:45:24 -07001381 case ndkStubDepTag, sharedDepTag, sharedExportDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001382 ptr = &depPaths.SharedLibs
1383 depPtr = &depPaths.SharedLibsDeps
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001384 depFile = ccDep.linker.(libraryInterface).toc()
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001385 directSharedDeps = append(directSharedDeps, ccDep)
Dan Albert914449f2016-06-17 16:45:24 -07001386 case lateSharedDepTag, ndkLateStubDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001387 ptr = &depPaths.LateSharedLibs
1388 depPtr = &depPaths.LateSharedLibsDeps
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001389 depFile = ccDep.linker.(libraryInterface).toc()
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001390 case staticDepTag, staticExportDepTag:
Jeff Gaston294356f2017-09-27 17:05:30 -07001391 ptr = nil
1392 directStaticDeps = append(directStaticDeps, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07001393 case lateStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001394 ptr = &depPaths.LateStaticLibs
Colin Crossc99deeb2016-04-11 15:06:20 -07001395 case wholeStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001396 ptr = &depPaths.WholeStaticLibs
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001397 staticLib, ok := ccDep.linker.(libraryInterface)
Colin Crossb916a382016-07-29 17:28:03 -07001398 if !ok || !staticLib.static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001399 ctx.ModuleErrorf("module %q not a static library", depName)
Colin Crossc99deeb2016-04-11 15:06:20 -07001400 return
1401 }
1402
1403 if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001404 postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
Colin Crossc99deeb2016-04-11 15:06:20 -07001405 for i := range missingDeps {
1406 missingDeps[i] += postfix
1407 }
1408 ctx.AddMissingDependencies(missingDeps)
1409 }
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001410 depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
Colin Cross5950f382016-12-13 12:50:57 -08001411 case headerDepTag:
1412 // Nothing
Colin Crossc99deeb2016-04-11 15:06:20 -07001413 case objDepTag:
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001414 depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
Colin Crossc99deeb2016-04-11 15:06:20 -07001415 case crtBeginDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001416 depPaths.CrtBegin = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07001417 case crtEndDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001418 depPaths.CrtEnd = linkFile
Dan Willemsena0790e32018-10-12 00:24:23 -07001419 case dynamicLinkerDepTag:
1420 depPaths.DynamicLinker = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07001421 }
1422
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001423 switch depTag {
Dan Willemsen581341d2017-02-09 16:16:31 -08001424 case staticDepTag, staticExportDepTag, lateStaticDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001425 staticLib, ok := ccDep.linker.(libraryInterface)
Dan Willemsen581341d2017-02-09 16:16:31 -08001426 if !ok || !staticLib.static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001427 ctx.ModuleErrorf("module %q not a static library", depName)
Dan Willemsen581341d2017-02-09 16:16:31 -08001428 return
1429 }
1430
1431 // When combining coverage files for shared libraries and executables, coverage files
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001432 // in static libraries act as if they were whole static libraries. The same goes for
1433 // source based Abi dump files.
Dan Willemsen581341d2017-02-09 16:16:31 -08001434 depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles,
1435 staticLib.objs().coverageFiles...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001436 depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
1437 staticLib.objs().sAbiDumpFiles...)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001438
Dan Willemsen581341d2017-02-09 16:16:31 -08001439 }
1440
Colin Cross26c34ed2016-09-30 17:10:16 -07001441 if ptr != nil {
Colin Crossce75d2c2016-10-06 16:12:58 -07001442 if !linkFile.Valid() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001443 ctx.ModuleErrorf("module %q missing output file", depName)
Colin Crossce75d2c2016-10-06 16:12:58 -07001444 return
1445 }
Colin Cross26c34ed2016-09-30 17:10:16 -07001446 *ptr = append(*ptr, linkFile.Path())
1447 }
1448
Colin Crossc99deeb2016-04-11 15:06:20 -07001449 if depPtr != nil {
Colin Cross26c34ed2016-09-30 17:10:16 -07001450 dep := depFile
1451 if !dep.Valid() {
1452 dep = linkFile
1453 }
1454 *depPtr = append(*depPtr, dep.Path())
Colin Crossca860ac2016-01-04 14:34:37 -08001455 }
Jiyong Park27b188b2017-07-18 13:23:39 +09001456
Logan Chien43d34c32017-12-20 01:17:32 +08001457 makeLibName := func(depName string) string {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001458 libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
Jiyong Park374510b2018-03-19 18:23:01 +09001459 libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix)
Jiyong Park27b188b2017-07-18 13:23:39 +09001460 libName = strings.TrimPrefix(libName, "prebuilt_")
Jiyong Parkd5b18a52017-08-03 21:22:50 +09001461 isLLndk := inList(libName, llndkLibraries)
Jiyong Park374510b2018-03-19 18:23:01 +09001462 isVendorPublicLib := inList(libName, vendorPublicLibraries)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001463 bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk
1464 if c.useVndk() && bothVendorAndCoreVariantsExist {
1465 // The vendor module in Make will have been renamed to not conflict with the core
1466 // module, so update the dependency name here accordingly.
Logan Chien43d34c32017-12-20 01:17:32 +08001467 return libName + vendorSuffix
Jiyong Park374510b2018-03-19 18:23:01 +09001468 } else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib {
Logan Chien43d34c32017-12-20 01:17:32 +08001469 return libName + vendorPublicLibrarySuffix
Jiyong Parkf9332f12018-02-01 00:54:12 +09001470 } else if ccDep.inRecovery() && !ccDep.onlyInRecovery() {
1471 return libName + recoverySuffix
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001472 } else {
Logan Chien43d34c32017-12-20 01:17:32 +08001473 return libName
Jiyong Park27b188b2017-07-18 13:23:39 +09001474 }
Logan Chien43d34c32017-12-20 01:17:32 +08001475 }
1476
1477 // Export the shared libs to Make.
1478 switch depTag {
1479 case sharedDepTag, sharedExportDepTag, lateSharedDepTag:
Jiyong Park27b188b2017-07-18 13:23:39 +09001480 // Note: the order of libs in this list is not important because
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001481 // they merely serve as Make dependencies and do not affect this lib itself.
Logan Chien43d34c32017-12-20 01:17:32 +08001482 c.Properties.AndroidMkSharedLibs = append(
1483 c.Properties.AndroidMkSharedLibs, makeLibName(depName))
Jaewoong Jung9d5ca152018-11-01 15:40:37 -07001484 case staticDepTag, staticExportDepTag, lateStaticDepTag:
1485 c.Properties.AndroidMkStaticLibs = append(
1486 c.Properties.AndroidMkStaticLibs, makeLibName(depName))
Logan Chien43d34c32017-12-20 01:17:32 +08001487 case runtimeDepTag:
1488 c.Properties.AndroidMkRuntimeLibs = append(
1489 c.Properties.AndroidMkRuntimeLibs, makeLibName(depName))
Jaewoong Jung9d5ca152018-11-01 15:40:37 -07001490 case wholeStaticDepTag:
1491 c.Properties.AndroidMkWholeStaticLibs = append(
1492 c.Properties.AndroidMkWholeStaticLibs, makeLibName(depName))
Jiyong Park27b188b2017-07-18 13:23:39 +09001493 }
Colin Crossca860ac2016-01-04 14:34:37 -08001494 })
1495
Jeff Gaston294356f2017-09-27 17:05:30 -07001496 // use the ordered dependencies as this module's dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001497 depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps, directSharedDeps)...)
Jeff Gaston294356f2017-09-27 17:05:30 -07001498
Colin Crossdd84e052017-05-17 13:44:16 -07001499 // Dedup exported flags from dependencies
Colin Crossb6715442017-10-24 11:13:31 -07001500 depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001501 depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
Colin Crossb6715442017-10-24 11:13:31 -07001502 depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001503 depPaths.ReexportedFlagsDeps = android.FirstUniquePaths(depPaths.ReexportedFlagsDeps)
1504
1505 if c.sabi != nil {
Colin Crossb6715442017-10-24 11:13:31 -07001506 c.sabi.Properties.ReexportedIncludeFlags = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludeFlags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001507 }
Colin Crossdd84e052017-05-17 13:44:16 -07001508
Colin Crossca860ac2016-01-04 14:34:37 -08001509 return depPaths
1510}
1511
1512func (c *Module) InstallInData() bool {
1513 if c.installer == nil {
1514 return false
1515 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001516 return c.installer.inData()
1517}
1518
1519func (c *Module) InstallInSanitizerDir() bool {
1520 if c.installer == nil {
1521 return false
1522 }
1523 if c.sanitize != nil && c.sanitize.inSanitizerDir() {
Colin Cross94610402016-08-29 13:41:32 -07001524 return true
1525 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001526 return c.installer.inSanitizerDir()
Colin Crossca860ac2016-01-04 14:34:37 -08001527}
1528
Jiyong Parkf9332f12018-02-01 00:54:12 +09001529func (c *Module) InstallInRecovery() bool {
1530 return c.inRecovery()
1531}
1532
Dan Willemsen4aa75ca2016-09-28 16:18:03 -07001533func (c *Module) HostToolPath() android.OptionalPath {
1534 if c.installer == nil {
1535 return android.OptionalPath{}
1536 }
1537 return c.installer.hostToolPath()
1538}
1539
Nan Zhangd4e641b2017-07-12 12:55:28 -07001540func (c *Module) IntermPathForModuleOut() android.OptionalPath {
1541 return c.outputFile
1542}
1543
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001544func (c *Module) Srcs() android.Paths {
1545 if c.outputFile.Valid() {
1546 return android.Paths{c.outputFile.Path()}
1547 }
1548 return android.Paths{}
1549}
1550
Vishwath Mohanb743e9c2017-11-01 09:20:21 +00001551func (c *Module) static() bool {
1552 if static, ok := c.linker.(interface {
1553 static() bool
1554 }); ok {
1555 return static.static()
1556 }
1557 return false
1558}
1559
Colin Crossb60190a2018-09-04 16:28:17 -07001560func (c *Module) getMakeLinkType() string {
1561 if c.useVndk() {
1562 if inList(c.Name(), vndkCoreLibraries) || inList(c.Name(), vndkSpLibraries) || inList(c.Name(), llndkLibraries) {
1563 if inList(c.Name(), vndkPrivateLibraries) {
1564 return "native:vndk_private"
1565 } else {
1566 return "native:vndk"
1567 }
1568 } else {
1569 return "native:vendor"
1570 }
1571 } else if c.inRecovery() {
1572 return "native:recovery"
1573 } else if c.Target().Os == android.Android && String(c.Properties.Sdk_version) != "" {
1574 return "native:ndk:none:none"
1575 // TODO(b/114741097): use the correct ndk stl once build errors have been fixed
1576 //family, link := getNdkStlFamilyAndLinkType(c)
1577 //return fmt.Sprintf("native:ndk:%s:%s", family, link)
1578 } else {
1579 return "native:platform"
1580 }
1581}
1582
Jiyong Park9d452992018-10-03 00:38:19 +09001583// Overrides ApexModule.IsInstallabeToApex()
1584// Only shared libraries are installable to APEX.
1585func (c *Module) IsInstallableToApex() bool {
1586 if shared, ok := c.linker.(interface {
1587 shared() bool
1588 }); ok {
1589 return shared.shared()
1590 }
1591 return false
1592}
1593
Colin Cross2ba19d92015-05-07 15:44:20 -07001594//
Colin Crosscfad1192015-11-02 16:43:11 -08001595// Defaults
1596//
Colin Crossca860ac2016-01-04 14:34:37 -08001597type Defaults struct {
Colin Cross635c3b02016-05-18 15:37:25 -07001598 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -07001599 android.DefaultsModuleBase
Jiyong Park9d452992018-10-03 00:38:19 +09001600 android.ApexModuleBase
Colin Crosscfad1192015-11-02 16:43:11 -08001601}
1602
Colin Cross635c3b02016-05-18 15:37:25 -07001603func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Crosscfad1192015-11-02 16:43:11 -08001604}
1605
Colin Cross1e676be2016-10-12 14:38:15 -07001606func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
1607}
1608
Colin Cross36242852017-06-23 15:06:31 -07001609func defaultsFactory() android.Module {
Colin Crosse1d764e2016-08-18 14:18:32 -07001610 return DefaultsFactory()
1611}
1612
Colin Cross36242852017-06-23 15:06:31 -07001613func DefaultsFactory(props ...interface{}) android.Module {
Colin Crossca860ac2016-01-04 14:34:37 -08001614 module := &Defaults{}
Colin Crosscfad1192015-11-02 16:43:11 -08001615
Colin Cross36242852017-06-23 15:06:31 -07001616 module.AddProperties(props...)
1617 module.AddProperties(
Colin Crossca860ac2016-01-04 14:34:37 -08001618 &BaseProperties{},
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001619 &VendorProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001620 &BaseCompilerProperties{},
1621 &BaseLinkerProperties{},
Chih-Hung Hsieh86814712018-05-23 18:30:46 -07001622 &MoreBaseLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07001623 &LibraryProperties{},
Colin Cross919281a2016-04-05 16:42:05 -07001624 &FlagExporterProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001625 &BinaryLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07001626 &TestProperties{},
1627 &TestBinaryProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001628 &StlProperties{},
Colin Cross16b23492016-01-06 14:41:07 -08001629 &SanitizeProperties{},
Colin Cross665dce92016-04-28 14:50:03 -07001630 &StripProperties{},
Dan Willemsen7424d612016-09-01 13:45:39 -07001631 &InstallerProperties{},
Dan Willemsena03cf6d2016-09-26 15:45:04 -07001632 &TidyProperties{},
Dan Willemsen581341d2017-02-09 16:16:31 -08001633 &CoverageProperties{},
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001634 &SAbiProperties{},
Justin Yun4b2382f2017-07-26 14:22:10 +09001635 &VndkProperties{},
Stephen Craneba090d12017-05-09 15:44:35 -07001636 &LTOProperties{},
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -07001637 &PgoProperties{},
Dan Willemsen6424d172018-03-08 13:27:59 -08001638 &android.ProtoProperties{},
Colin Crosse1d764e2016-08-18 14:18:32 -07001639 )
Colin Crosscfad1192015-11-02 16:43:11 -08001640
Colin Cross1f44a3a2017-07-07 14:33:33 -07001641 android.InitDefaultsModule(module)
Jiyong Park9d452992018-10-03 00:38:19 +09001642 android.InitApexModule(module)
Colin Cross36242852017-06-23 15:06:31 -07001643
1644 return module
Colin Crosscfad1192015-11-02 16:43:11 -08001645}
1646
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001647const (
1648 // coreMode is the variant used for framework-private libraries, or
1649 // SDK libraries. (which framework-private libraries can use)
1650 coreMode = "core"
1651
1652 // vendorMode is the variant used for /vendor code that compiles
1653 // against the VNDK.
1654 vendorMode = "vendor"
Jiyong Parkf9332f12018-02-01 00:54:12 +09001655
1656 recoveryMode = "recovery"
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001657)
1658
Jiyong Park6a43f042017-10-12 23:05:00 +09001659func squashVendorSrcs(m *Module) {
1660 if lib, ok := m.compiler.(*libraryDecorator); ok {
1661 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
1662 lib.baseCompiler.Properties.Target.Vendor.Srcs...)
1663
1664 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
1665 lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
1666 }
1667}
1668
Jiyong Parkf9332f12018-02-01 00:54:12 +09001669func squashRecoverySrcs(m *Module) {
1670 if lib, ok := m.compiler.(*libraryDecorator); ok {
1671 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
1672 lib.baseCompiler.Properties.Target.Recovery.Srcs...)
1673
1674 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
1675 lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
1676 }
1677}
1678
1679func imageMutator(mctx android.BottomUpMutatorContext) {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001680 if mctx.Os() != android.Android {
1681 return
1682 }
1683
Jiyong Park7ed9de32018-10-15 22:25:07 +09001684 if g, ok := mctx.Module().(*genrule.Module); ok {
1685 if props, ok := g.Extra.(*GenruleExtraProperties); ok {
Jiyong Park3f736c92018-05-24 13:36:56 +09001686 var coreVariantNeeded bool = false
1687 var vendorVariantNeeded bool = false
1688 var recoveryVariantNeeded bool = false
Justin Yun71549282017-11-17 12:10:28 +09001689 if mctx.DeviceConfig().VndkVersion() == "" {
Jiyong Park3f736c92018-05-24 13:36:56 +09001690 coreVariantNeeded = true
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001691 } else if Bool(props.Vendor_available) {
Jiyong Park3f736c92018-05-24 13:36:56 +09001692 coreVariantNeeded = true
1693 vendorVariantNeeded = true
Jiyong Park2db76922017-11-08 16:03:48 +09001694 } else if mctx.SocSpecific() || mctx.DeviceSpecific() {
Jiyong Park3f736c92018-05-24 13:36:56 +09001695 vendorVariantNeeded = true
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001696 } else {
Jiyong Park3f736c92018-05-24 13:36:56 +09001697 coreVariantNeeded = true
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001698 }
Jiyong Park3f736c92018-05-24 13:36:56 +09001699 if Bool(props.Recovery_available) {
1700 recoveryVariantNeeded = true
1701 }
1702
Jiyong Park413cc742018-06-19 01:46:06 +09001703 if recoveryVariantNeeded {
Jiyong Park8d52f862018-07-07 18:02:07 +09001704 primaryArch := mctx.Config().DevicePrimaryArchType()
Jiyong Park7ed9de32018-10-15 22:25:07 +09001705 moduleArch := g.Target().Arch.ArchType
Jiyong Park8d52f862018-07-07 18:02:07 +09001706 if moduleArch != primaryArch {
Jiyong Park413cc742018-06-19 01:46:06 +09001707 recoveryVariantNeeded = false
1708 }
1709 }
1710
Jiyong Park3f736c92018-05-24 13:36:56 +09001711 var variants []string
1712 if coreVariantNeeded {
1713 variants = append(variants, coreMode)
1714 }
1715 if vendorVariantNeeded {
1716 variants = append(variants, vendorMode)
1717 }
1718 if recoveryVariantNeeded {
1719 variants = append(variants, recoveryMode)
1720 }
Jiyong Park7ed9de32018-10-15 22:25:07 +09001721 mod := mctx.CreateVariations(variants...)
1722 for i, v := range variants {
1723 if v == recoveryMode {
1724 m := mod[i].(*genrule.Module)
1725 m.Extra.(*GenruleExtraProperties).InRecovery = true
1726 }
1727 }
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001728 }
1729 }
1730
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001731 m, ok := mctx.Module().(*Module)
1732 if !ok {
1733 return
1734 }
1735
1736 // Sanity check
Logan Chienf3511742017-10-31 18:04:35 +08001737 vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
1738
1739 if m.VendorProperties.Vendor_available != nil && vendorSpecific {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001740 mctx.PropertyErrorf("vendor_available",
Jiyong Park2db76922017-11-08 16:03:48 +09001741 "doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001742 return
1743 }
Logan Chienf3511742017-10-31 18:04:35 +08001744
1745 if vndkdep := m.vndkdep; vndkdep != nil {
1746 if vndkdep.isVndk() {
1747 if vendorSpecific {
1748 if !vndkdep.isVndkExt() {
1749 mctx.PropertyErrorf("vndk",
1750 "must set `extends: \"...\"` to vndk extension")
1751 return
1752 }
1753 } else {
1754 if vndkdep.isVndkExt() {
1755 mctx.PropertyErrorf("vndk",
1756 "must set `vendor: true` to set `extends: %q`",
1757 m.getVndkExtendsModuleName())
1758 return
1759 }
1760 if m.VendorProperties.Vendor_available == nil {
1761 mctx.PropertyErrorf("vndk",
1762 "vendor_available must be set to either true or false when `vndk: {enabled: true}`")
1763 return
1764 }
1765 }
1766 } else {
1767 if vndkdep.isVndkSp() {
1768 mctx.PropertyErrorf("vndk",
1769 "must set `enabled: true` to set `support_system_process: true`")
1770 return
1771 }
1772 if vndkdep.isVndkExt() {
1773 mctx.PropertyErrorf("vndk",
1774 "must set `enabled: true` to set `extends: %q`",
1775 m.getVndkExtendsModuleName())
1776 return
1777 }
Justin Yun8effde42017-06-23 19:24:43 +09001778 }
1779 }
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001780
Jiyong Parkf9332f12018-02-01 00:54:12 +09001781 var coreVariantNeeded bool = false
1782 var vendorVariantNeeded bool = false
1783 var recoveryVariantNeeded bool = false
1784
Justin Yun71549282017-11-17 12:10:28 +09001785 if mctx.DeviceConfig().VndkVersion() == "" {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001786 // If the device isn't compiling against the VNDK, we always
1787 // use the core mode.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001788 coreVariantNeeded = true
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001789 } else if _, ok := m.linker.(*llndkStubDecorator); ok {
1790 // LL-NDK stubs only exist in the vendor variant, since the
1791 // real libraries will be used in the core variant.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001792 vendorVariantNeeded = true
Jiyong Park2a454122017-10-19 15:59:33 +09001793 } else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
1794 // ... and LL-NDK headers as well
Jiyong Parkf9332f12018-02-01 00:54:12 +09001795 vendorVariantNeeded = true
Justin Yun312ccb92018-01-23 12:07:46 +09001796 } else if _, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
Justin Yun71549282017-11-17 12:10:28 +09001797 // Make vendor variants only for the versions in BOARD_VNDK_VERSION and
1798 // PRODUCT_EXTRA_VNDK_VERSIONS.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001799 vendorVariantNeeded = true
Logan Chienf3511742017-10-31 18:04:35 +08001800 } else if m.hasVendorVariant() && !vendorSpecific {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001801 // This will be available in both /system and /vendor
Justin Yun8effde42017-06-23 19:24:43 +09001802 // or a /system directory that is available to vendor.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001803 coreVariantNeeded = true
1804 vendorVariantNeeded = true
Logan Chienf3511742017-10-31 18:04:35 +08001805 } else if vendorSpecific && String(m.Properties.Sdk_version) == "" {
Jiyong Park2db76922017-11-08 16:03:48 +09001806 // This will be available in /vendor (or /odm) only
Jiyong Parkf9332f12018-02-01 00:54:12 +09001807 vendorVariantNeeded = true
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001808 } else {
1809 // This is either in /system (or similar: /data), or is a
1810 // modules built with the NDK. Modules built with the NDK
1811 // will be restricted using the existing link type checks.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001812 coreVariantNeeded = true
1813 }
1814
1815 if Bool(m.Properties.Recovery_available) {
1816 recoveryVariantNeeded = true
1817 }
1818
1819 if m.ModuleBase.InstallInRecovery() {
1820 recoveryVariantNeeded = true
1821 coreVariantNeeded = false
1822 }
1823
Jiyong Park413cc742018-06-19 01:46:06 +09001824 if recoveryVariantNeeded {
Jiyong Park8d52f862018-07-07 18:02:07 +09001825 primaryArch := mctx.Config().DevicePrimaryArchType()
1826 moduleArch := m.Target().Arch.ArchType
1827 if moduleArch != primaryArch {
Jiyong Park413cc742018-06-19 01:46:06 +09001828 recoveryVariantNeeded = false
1829 }
1830 }
1831
Jiyong Parkf9332f12018-02-01 00:54:12 +09001832 var variants []string
1833 if coreVariantNeeded {
1834 variants = append(variants, coreMode)
1835 }
1836 if vendorVariantNeeded {
1837 variants = append(variants, vendorMode)
1838 }
1839 if recoveryVariantNeeded {
1840 variants = append(variants, recoveryMode)
1841 }
1842 mod := mctx.CreateVariations(variants...)
1843 for i, v := range variants {
1844 if v == vendorMode {
1845 m := mod[i].(*Module)
1846 m.Properties.UseVndk = true
1847 squashVendorSrcs(m)
1848 } else if v == recoveryMode {
1849 m := mod[i].(*Module)
1850 m.Properties.InRecovery = true
Jiyong Park5baac542018-08-28 09:55:37 +09001851 m.MakeAsPlatform()
Jiyong Parkf9332f12018-02-01 00:54:12 +09001852 squashRecoverySrcs(m)
1853 }
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001854 }
1855}
1856
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001857func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
Colin Cross6510f912017-11-29 00:27:14 -08001858 if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001859 return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
1860 }
Colin Cross6510f912017-11-29 00:27:14 -08001861 return ctx.Config().PlatformSdkVersion()
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001862}
1863
Colin Cross06a931b2015-10-28 17:23:31 -07001864var Bool = proptools.Bool
Colin Cross38b40df2018-04-10 16:14:46 -07001865var BoolDefault = proptools.BoolDefault
Nan Zhang0007d812017-11-07 10:57:05 -08001866var BoolPtr = proptools.BoolPtr
1867var String = proptools.String
1868var StringPtr = proptools.StringPtr