blob: 5485ae33bab1418e6b9ae134a35052bd781f595e [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
Peter Collingbourne8c7e6e22018-11-19 16:03:58 -080056 ctx.TopDown("scs_deps", sanitizerDepsMutator(scs))
57 ctx.BottomUp("scs", sanitizerMutator(scs)).Parallel()
58
Colin Cross1e676be2016-10-12 14:38:15 -070059 ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
60 ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()
Dan Willemsen581341d2017-02-09 16:16:31 -080061
Colin Cross6b753602018-06-21 13:03:07 -070062 ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator)
Ivan Lozano30c5db22018-02-21 15:49:20 -080063
Pirama Arumuga Nainar0b882f02018-04-23 22:44:39 +000064 ctx.BottomUp("coverage", coverageLinkingMutator).Parallel()
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -080065 ctx.TopDown("vndk_deps", sabiDepsMutator)
Stephen Craneba090d12017-05-09 15:44:35 -070066
67 ctx.TopDown("lto_deps", ltoDepsMutator)
68 ctx.BottomUp("lto", ltoMutator).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070069 })
Colin Crossb98c8b02016-07-29 13:44:28 -070070
71 pctx.Import("android/soong/cc/config")
Colin Cross463a90e2015-06-17 14:20:06 -070072}
73
Colin Crossca860ac2016-01-04 14:34:37 -080074type Deps struct {
75 SharedLibs, LateSharedLibs []string
76 StaticLibs, LateStaticLibs, WholeStaticLibs []string
Colin Cross5950f382016-12-13 12:50:57 -080077 HeaderLibs []string
Logan Chien43d34c32017-12-20 01:17:32 +080078 RuntimeLibs []string
Colin Crossc472d572015-03-17 15:06:21 -070079
Colin Cross5950f382016-12-13 12:50:57 -080080 ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string
Dan Willemsen490a8dc2016-06-06 18:22:19 -070081
Colin Cross81413472016-04-11 14:37:39 -070082 ObjFiles []string
Dan Willemsen34cc69e2015-09-23 15:26:20 -070083
Dan Willemsenb40aab62016-04-20 14:21:14 -070084 GeneratedSources []string
85 GeneratedHeaders []string
86
Dan Willemsenb3454ab2016-09-28 17:34:58 -070087 ReexportGeneratedHeaders []string
88
Colin Cross97ba0732015-03-23 17:50:24 -070089 CrtBegin, CrtEnd string
Dan Willemsena0790e32018-10-12 00:24:23 -070090
91 // Used for host bionic
92 LinkerFlagsFile string
93 DynamicLinker string
Colin Crossc472d572015-03-17 15:06:21 -070094}
95
Colin Crossca860ac2016-01-04 14:34:37 -080096type PathDeps struct {
Colin Cross26c34ed2016-09-30 17:10:16 -070097 // Paths to .so files
98 SharedLibs, LateSharedLibs android.Paths
99 // Paths to the dependencies to use for .so files (.so.toc files)
100 SharedLibsDeps, LateSharedLibsDeps android.Paths
101 // Paths to .a files
Colin Cross635c3b02016-05-18 15:37:25 -0700102 StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700103
Colin Cross26c34ed2016-09-30 17:10:16 -0700104 // Paths to .o files
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700105 Objs Objects
Dan Willemsen581341d2017-02-09 16:16:31 -0800106 StaticLibObjs Objects
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700107 WholeStaticLibObjs Objects
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700108
Colin Cross26c34ed2016-09-30 17:10:16 -0700109 // Paths to generated source files
Colin Cross635c3b02016-05-18 15:37:25 -0700110 GeneratedSources android.Paths
111 GeneratedHeaders android.Paths
Dan Willemsenb40aab62016-04-20 14:21:14 -0700112
Dan Willemsen76f08272016-07-09 00:14:08 -0700113 Flags, ReexportedFlags []string
Dan Willemsen847dcc72016-09-29 12:13:36 -0700114 ReexportedFlagsDeps android.Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700115
Colin Cross26c34ed2016-09-30 17:10:16 -0700116 // Paths to crt*.o files
Colin Cross635c3b02016-05-18 15:37:25 -0700117 CrtBegin, CrtEnd android.OptionalPath
Dan Willemsena0790e32018-10-12 00:24:23 -0700118
119 // Path to the file container flags to use with the linker
120 LinkerFlagsFile android.OptionalPath
121
122 // Path to the dynamic linker binary
123 DynamicLinker android.OptionalPath
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700124}
125
Colin Crossca860ac2016-01-04 14:34:37 -0800126type Flags struct {
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700127 GlobalFlags []string // Flags that apply to C, C++, and assembly source files
128 ArFlags []string // Flags that apply to ar
129 AsFlags []string // Flags that apply to assembly source files
130 CFlags []string // Flags that apply to C and C++ source files
131 ToolingCFlags []string // Flags that apply to C and C++ source files parsed by clang LibTooling tools
132 ConlyFlags []string // Flags that apply to C source files
133 CppFlags []string // Flags that apply to C++ source files
134 ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
135 YaccFlags []string // Flags that apply to Yacc source files
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700136 aidlFlags []string // Flags that apply to aidl source files
137 rsFlags []string // Flags that apply to renderscript source files
138 LdFlags []string // Flags that apply to linker command lines
139 libFlags []string // Flags to add libraries early to the link order
140 TidyFlags []string // Flags that apply to clang-tidy
141 SAbiFlags []string // Flags that apply to header-abi-dumper
142 YasmFlags []string // Flags that apply to yasm assembly source files
Colin Cross28344522015-04-22 13:07:53 -0700143
Colin Crossc3199482017-03-30 15:03:04 -0700144 // Global include flags that apply to C, C++, and assembly source files
145 // These must be after any module include flags, which will be in GlobalFlags.
146 SystemIncludeFlags []string
147
Colin Crossb98c8b02016-07-29 13:44:28 -0700148 Toolchain config.Toolchain
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700149 Tidy bool
Dan Willemsen581341d2017-02-09 16:16:31 -0800150 Coverage bool
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800151 SAbiDump 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
Dan Willemsen60e62f02018-11-16 21:05:32 -0800160
161 protoDeps android.Paths
162 protoFlags []string // Flags that apply to proto source files
163 protoOutTypeFlag string // The output type, --cpp_out for example
164 protoOutParams []string // Flags that modify the output of proto generated files
165 protoC bool // Whether to use C instead of C++
166 protoOptionsFile bool // Whether to look for a .options file next to the .proto
167 ProtoRoot bool
Colin Crossc472d572015-03-17 15:06:21 -0700168}
169
Colin Cross81413472016-04-11 14:37:39 -0700170type ObjectLinkerProperties struct {
171 // names of other cc_object modules to link into this module using partial linking
172 Objs []string `android:"arch_variant"`
Dan Willemsenefb1dd92017-09-18 22:47:20 -0700173
174 // if set, add an extra objcopy --prefix-symbols= step
Nan Zhang0007d812017-11-07 10:57:05 -0800175 Prefix_symbols *string
Colin Cross81413472016-04-11 14:37:39 -0700176}
177
Colin Crossca860ac2016-01-04 14:34:37 -0800178// Properties used to compile all C or C++ modules
179type BaseProperties struct {
Dan Willemsen742a5452018-07-23 17:19:36 -0700180 // Deprecated. true is the default, false is invalid.
Colin Crossca860ac2016-01-04 14:34:37 -0800181 Clang *bool `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -0700182
183 // Minimum sdk version supported when compiling against the ndk
Nan Zhang0007d812017-11-07 10:57:05 -0800184 Sdk_version *string
Colin Cross7d5136f2015-05-11 13:39:40 -0700185
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +0000186 AndroidMkSharedLibs []string `blueprint:"mutated"`
187 AndroidMkStaticLibs []string `blueprint:"mutated"`
188 AndroidMkRuntimeLibs []string `blueprint:"mutated"`
189 AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
190 HideFromMake bool `blueprint:"mutated"`
191 PreventInstall bool `blueprint:"mutated"`
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700192
193 UseVndk bool `blueprint:"mutated"`
Colin Cross5beccee2017-12-07 15:28:59 -0800194
195 // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
196 // file
197 Logtags []string
Jiyong Parkf9332f12018-02-01 00:54:12 +0900198
199 // Make this module available when building for recovery
200 Recovery_available *bool
201
202 InRecovery bool `blueprint:"mutated"`
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700203}
204
205type VendorProperties struct {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900206 // whether this module should be allowed to be directly depended by other
207 // modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`.
208 // If set to true, two variants will be built separately, one like
209 // normal, and the other limited to the set of libraries and headers
210 // that are exposed to /vendor modules.
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700211 //
212 // The vendor variant may be used with a different (newer) /system,
213 // so it shouldn't have any unversioned runtime dependencies, or
214 // make assumptions about the system that may not be true in the
215 // future.
216 //
Jiyong Park82e2bf32017-08-16 14:05:54 +0900217 // If set to false, this module becomes inaccessible from /vendor modules.
218 //
219 // Default value is true when vndk: {enabled: true} or vendor: true.
220 //
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700221 // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
222 Vendor_available *bool
Jiyong Park5fb8c102018-04-09 12:03:06 +0900223
224 // whether this module is capable of being loaded with other instance
225 // (possibly an older version) of the same module in the same process.
226 // Currently, a shared library that is a member of VNDK (vndk: {enabled: true})
227 // can be double loaded in a vendor process if the library is also a
228 // (direct and indirect) dependency of an LLNDK library. Such libraries must be
229 // explicitly marked as `double_loadable: true` by the owner, or the dependency
230 // from the LLNDK lib should be cut if the lib is not designed to be double loaded.
231 Double_loadable *bool
Colin Crossca860ac2016-01-04 14:34:37 -0800232}
233
Colin Crossca860ac2016-01-04 14:34:37 -0800234type ModuleContextIntf interface {
Colin Crossca860ac2016-01-04 14:34:37 -0800235 static() bool
236 staticBinary() bool
Colin Crossb98c8b02016-07-29 13:44:28 -0700237 toolchain() config.Toolchain
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700238 useSdk() bool
Colin Crossca860ac2016-01-04 14:34:37 -0800239 sdkVersion() string
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700240 useVndk() bool
Justin Yun8effde42017-06-23 19:24:43 +0900241 isVndk() bool
242 isVndkSp() bool
Logan Chienf3511742017-10-31 18:04:35 +0800243 isVndkExt() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900244 inRecovery() bool
Logan Chien2f2b8902018-07-10 15:01:19 +0800245 shouldCreateVndkSourceAbiDump() bool
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700246 selectedStl() string
Colin Crossce75d2c2016-10-06 16:12:58 -0700247 baseModuleName() string
Logan Chienf3511742017-10-31 18:04:35 +0800248 getVndkExtendsModuleName() string
Yi Kong7e53c572018-02-14 18:16:12 +0800249 isPgoCompile() bool
Colin Crossca860ac2016-01-04 14:34:37 -0800250}
251
252type ModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700253 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800254 ModuleContextIntf
255}
256
257type BaseModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700258 android.BaseContext
Colin Crossca860ac2016-01-04 14:34:37 -0800259 ModuleContextIntf
260}
261
Colin Cross37047f12016-12-13 17:06:13 -0800262type DepsContext interface {
263 android.BottomUpMutatorContext
264 ModuleContextIntf
265}
266
Colin Crossca860ac2016-01-04 14:34:37 -0800267type feature interface {
268 begin(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800269 deps(ctx DepsContext, deps Deps) Deps
Colin Crossca860ac2016-01-04 14:34:37 -0800270 flags(ctx ModuleContext, flags Flags) Flags
271 props() []interface{}
272}
273
274type compiler interface {
Colin Cross42742b82016-08-01 13:20:05 -0700275 compilerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800276 compilerDeps(ctx DepsContext, deps Deps) Deps
Colin Crossf18e1102017-11-16 14:33:08 -0800277 compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags
Colin Cross42742b82016-08-01 13:20:05 -0700278 compilerProps() []interface{}
279
Colin Cross76fada02016-07-27 10:31:13 -0700280 appendCflags([]string)
281 appendAsflags([]string)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700282 compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800283}
284
285type linker interface {
Colin Cross42742b82016-08-01 13:20:05 -0700286 linkerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800287 linkerDeps(ctx DepsContext, deps Deps) Deps
Colin Cross42742b82016-08-01 13:20:05 -0700288 linkerFlags(ctx ModuleContext, flags Flags) Flags
289 linkerProps() []interface{}
290
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700291 link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
Colin Cross76fada02016-07-27 10:31:13 -0700292 appendLdflags([]string)
Colin Crossca860ac2016-01-04 14:34:37 -0800293}
294
295type installer interface {
Colin Cross42742b82016-08-01 13:20:05 -0700296 installerProps() []interface{}
Colin Cross635c3b02016-05-18 15:37:25 -0700297 install(ctx ModuleContext, path android.Path)
Colin Crossca860ac2016-01-04 14:34:37 -0800298 inData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700299 inSanitizerDir() bool
Dan Willemsen4aa75ca2016-09-28 16:18:03 -0700300 hostToolPath() android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800301}
302
Colin Crossc99deeb2016-04-11 15:06:20 -0700303type dependencyTag struct {
304 blueprint.BaseDependencyTag
305 name string
306 library bool
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700307
308 reexportFlags bool
Colin Crossc99deeb2016-04-11 15:06:20 -0700309}
310
311var (
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700312 sharedDepTag = dependencyTag{name: "shared", library: true}
313 sharedExportDepTag = dependencyTag{name: "shared", library: true, reexportFlags: true}
314 lateSharedDepTag = dependencyTag{name: "late shared", library: true}
315 staticDepTag = dependencyTag{name: "static", library: true}
316 staticExportDepTag = dependencyTag{name: "static", library: true, reexportFlags: true}
317 lateStaticDepTag = dependencyTag{name: "late static", library: true}
318 wholeStaticDepTag = dependencyTag{name: "whole static", library: true, reexportFlags: true}
Colin Cross32ec36c2016-12-15 07:39:51 -0800319 headerDepTag = dependencyTag{name: "header", library: true}
320 headerExportDepTag = dependencyTag{name: "header", library: true, reexportFlags: true}
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700321 genSourceDepTag = dependencyTag{name: "gen source"}
322 genHeaderDepTag = dependencyTag{name: "gen header"}
323 genHeaderExportDepTag = dependencyTag{name: "gen header", reexportFlags: true}
324 objDepTag = dependencyTag{name: "obj"}
325 crtBeginDepTag = dependencyTag{name: "crtbegin"}
326 crtEndDepTag = dependencyTag{name: "crtend"}
Dan Willemsena0790e32018-10-12 00:24:23 -0700327 linkerFlagsDepTag = dependencyTag{name: "linker flags file"}
328 dynamicLinkerDepTag = dependencyTag{name: "dynamic linker"}
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700329 reuseObjTag = dependencyTag{name: "reuse objects"}
330 ndkStubDepTag = dependencyTag{name: "ndk stub", library: true}
331 ndkLateStubDepTag = dependencyTag{name: "ndk late stub", library: true}
Logan Chienf3511742017-10-31 18:04:35 +0800332 vndkExtDepTag = dependencyTag{name: "vndk extends", library: true}
Logan Chien43d34c32017-12-20 01:17:32 +0800333 runtimeDepTag = dependencyTag{name: "runtime lib"}
Colin Crossc99deeb2016-04-11 15:06:20 -0700334)
335
Colin Crossca860ac2016-01-04 14:34:37 -0800336// Module contains the properties and members used by all C/C++ module types, and implements
337// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
338// to construct the output file. Behavior can be customized with a Customizer interface
339type Module struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700340 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -0700341 android.DefaultableModuleBase
Jiyong Park9d452992018-10-03 00:38:19 +0900342 android.ApexModuleBase
Colin Crossc472d572015-03-17 15:06:21 -0700343
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700344 Properties BaseProperties
345 VendorProperties VendorProperties
Colin Crossfa138792015-04-24 17:31:52 -0700346
Colin Crossca860ac2016-01-04 14:34:37 -0800347 // initialize before calling Init
Colin Cross635c3b02016-05-18 15:37:25 -0700348 hod android.HostOrDeviceSupported
349 multilib android.Multilib
Colin Crossc472d572015-03-17 15:06:21 -0700350
Colin Crossca860ac2016-01-04 14:34:37 -0800351 // delegates, initialize before calling Init
Colin Crossb4ce0ec2016-09-13 13:41:39 -0700352 features []feature
353 compiler compiler
354 linker linker
355 installer installer
356 stl *stl
357 sanitize *sanitize
Dan Willemsen581341d2017-02-09 16:16:31 -0800358 coverage *coverage
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800359 sabi *sabi
Justin Yun8effde42017-06-23 19:24:43 +0900360 vndkdep *vndkdep
Stephen Craneba090d12017-05-09 15:44:35 -0700361 lto *lto
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700362 pgo *pgo
Colin Cross16b23492016-01-06 14:41:07 -0800363
364 androidMkSharedLibDeps []string
Colin Cross74d1ec02015-04-28 13:30:13 -0700365
Colin Cross635c3b02016-05-18 15:37:25 -0700366 outputFile android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800367
Colin Crossb98c8b02016-07-29 13:44:28 -0700368 cachedToolchain config.Toolchain
Colin Crossb916a382016-07-29 17:28:03 -0700369
370 subAndroidMkOnce map[subAndroidMkProvider]bool
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800371
372 // Flags used to compile this module
373 flags Flags
Jeff Gaston294356f2017-09-27 17:05:30 -0700374
375 // 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 -0800376 // line invocation. depsInLinkOrder stores the proper ordering of all of the transitive
Jeff Gaston294356f2017-09-27 17:05:30 -0700377 // deps of this module
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800378 depsInLinkOrder android.Paths
379
380 // only non-nil when this is a shared library that reuses the objects of a static library
381 staticVariant *Module
Colin Crossc472d572015-03-17 15:06:21 -0700382}
383
Jiyong Parkc20eee32018-09-05 22:36:17 +0900384func (c *Module) OutputFile() android.OptionalPath {
385 return c.outputFile
386}
387
Colin Cross36242852017-06-23 15:06:31 -0700388func (c *Module) Init() android.Module {
Dan Willemsenf923f2b2018-05-09 13:45:03 -0700389 c.AddProperties(&c.Properties, &c.VendorProperties)
Colin Crossca860ac2016-01-04 14:34:37 -0800390 if c.compiler != nil {
Colin Cross36242852017-06-23 15:06:31 -0700391 c.AddProperties(c.compiler.compilerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800392 }
393 if c.linker != nil {
Colin Cross36242852017-06-23 15:06:31 -0700394 c.AddProperties(c.linker.linkerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800395 }
396 if c.installer != nil {
Colin Cross36242852017-06-23 15:06:31 -0700397 c.AddProperties(c.installer.installerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800398 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700399 if c.stl != nil {
Colin Cross36242852017-06-23 15:06:31 -0700400 c.AddProperties(c.stl.props()...)
Colin Crossa8e07cc2016-04-04 15:07:06 -0700401 }
Colin Cross16b23492016-01-06 14:41:07 -0800402 if c.sanitize != nil {
Colin Cross36242852017-06-23 15:06:31 -0700403 c.AddProperties(c.sanitize.props()...)
Colin Cross16b23492016-01-06 14:41:07 -0800404 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800405 if c.coverage != nil {
Colin Cross36242852017-06-23 15:06:31 -0700406 c.AddProperties(c.coverage.props()...)
Dan Willemsen581341d2017-02-09 16:16:31 -0800407 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800408 if c.sabi != nil {
Colin Cross36242852017-06-23 15:06:31 -0700409 c.AddProperties(c.sabi.props()...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800410 }
Justin Yun8effde42017-06-23 19:24:43 +0900411 if c.vndkdep != nil {
412 c.AddProperties(c.vndkdep.props()...)
413 }
Stephen Craneba090d12017-05-09 15:44:35 -0700414 if c.lto != nil {
415 c.AddProperties(c.lto.props()...)
416 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700417 if c.pgo != nil {
418 c.AddProperties(c.pgo.props()...)
419 }
Colin Crossca860ac2016-01-04 14:34:37 -0800420 for _, feature := range c.features {
Colin Cross36242852017-06-23 15:06:31 -0700421 c.AddProperties(feature.props()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800422 }
Colin Crossc472d572015-03-17 15:06:21 -0700423
Colin Crossa9d8bee2018-10-02 13:59:46 -0700424 c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
425 switch class {
426 case android.Device:
427 return ctx.Config().DevicePrefer32BitExecutables()
428 case android.HostCross:
429 // Windows builds always prefer 32-bit
430 return true
431 default:
432 return false
433 }
434 })
Colin Cross36242852017-06-23 15:06:31 -0700435 android.InitAndroidArchModule(c, c.hod, c.multilib)
Colin Crossc472d572015-03-17 15:06:21 -0700436
Colin Cross1f44a3a2017-07-07 14:33:33 -0700437 android.InitDefaultableModule(c)
Colin Cross36242852017-06-23 15:06:31 -0700438
Jiyong Park9d452992018-10-03 00:38:19 +0900439 android.InitApexModule(c)
440
Colin Cross36242852017-06-23 15:06:31 -0700441 return c
Colin Crossc472d572015-03-17 15:06:21 -0700442}
443
Colin Crossb916a382016-07-29 17:28:03 -0700444// Returns true for dependency roots (binaries)
445// TODO(ccross): also handle dlopenable libraries
446func (c *Module) isDependencyRoot() bool {
447 if root, ok := c.linker.(interface {
448 isDependencyRoot() bool
449 }); ok {
450 return root.isDependencyRoot()
451 }
452 return false
453}
454
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700455func (c *Module) useVndk() bool {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700456 return c.Properties.UseVndk
457}
458
Justin Yun8effde42017-06-23 19:24:43 +0900459func (c *Module) isVndk() bool {
Logan Chienf3511742017-10-31 18:04:35 +0800460 if vndkdep := c.vndkdep; vndkdep != nil {
461 return vndkdep.isVndk()
Justin Yun8effde42017-06-23 19:24:43 +0900462 }
463 return false
464}
465
Yi Kong7e53c572018-02-14 18:16:12 +0800466func (c *Module) isPgoCompile() bool {
467 if pgo := c.pgo; pgo != nil {
468 return pgo.Properties.PgoCompile
469 }
470 return false
471}
472
Logan Chienf3511742017-10-31 18:04:35 +0800473func (c *Module) isVndkSp() bool {
474 if vndkdep := c.vndkdep; vndkdep != nil {
475 return vndkdep.isVndkSp()
476 }
477 return false
478}
479
480func (c *Module) isVndkExt() bool {
481 if vndkdep := c.vndkdep; vndkdep != nil {
482 return vndkdep.isVndkExt()
483 }
484 return false
485}
486
487func (c *Module) getVndkExtendsModuleName() string {
488 if vndkdep := c.vndkdep; vndkdep != nil {
489 return vndkdep.getVndkExtendsModuleName()
490 }
491 return ""
492}
493
Jiyong Park82e2bf32017-08-16 14:05:54 +0900494// Returns true only when this module is configured to have core and vendor
495// variants.
496func (c *Module) hasVendorVariant() bool {
497 return c.isVndk() || Bool(c.VendorProperties.Vendor_available)
498}
499
Jiyong Parkf9332f12018-02-01 00:54:12 +0900500func (c *Module) inRecovery() bool {
501 return c.Properties.InRecovery || c.ModuleBase.InstallInRecovery()
502}
503
504func (c *Module) onlyInRecovery() bool {
505 return c.ModuleBase.InstallInRecovery()
506}
507
Colin Crossca860ac2016-01-04 14:34:37 -0800508type baseModuleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700509 android.BaseContext
Colin Crossca860ac2016-01-04 14:34:37 -0800510 moduleContextImpl
511}
512
Colin Cross37047f12016-12-13 17:06:13 -0800513type depsContext struct {
514 android.BottomUpMutatorContext
515 moduleContextImpl
516}
517
Colin Crossca860ac2016-01-04 14:34:37 -0800518type moduleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700519 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800520 moduleContextImpl
521}
522
Jiyong Park2db76922017-11-08 16:03:48 +0900523func (ctx *moduleContext) SocSpecific() bool {
524 return ctx.ModuleContext.SocSpecific() ||
525 (ctx.mod.hasVendorVariant() && ctx.mod.useVndk() && !ctx.mod.isVndk())
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700526}
527
Colin Crossca860ac2016-01-04 14:34:37 -0800528type moduleContextImpl struct {
529 mod *Module
530 ctx BaseModuleContext
531}
532
Colin Crossb98c8b02016-07-29 13:44:28 -0700533func (ctx *moduleContextImpl) toolchain() config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -0800534 return ctx.mod.toolchain(ctx.ctx)
535}
536
537func (ctx *moduleContextImpl) static() bool {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000538 return ctx.mod.static()
Colin Crossca860ac2016-01-04 14:34:37 -0800539}
540
541func (ctx *moduleContextImpl) staticBinary() bool {
Colin Crossb916a382016-07-29 17:28:03 -0700542 if static, ok := ctx.mod.linker.(interface {
543 staticBinary() bool
544 }); ok {
545 return static.staticBinary()
Colin Crossca860ac2016-01-04 14:34:37 -0800546 }
Colin Crossb916a382016-07-29 17:28:03 -0700547 return false
Colin Crossca860ac2016-01-04 14:34:37 -0800548}
549
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700550func (ctx *moduleContextImpl) useSdk() bool {
Jiyong Parkf9332f12018-02-01 00:54:12 +0900551 if ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRecovery() {
Nan Zhang0007d812017-11-07 10:57:05 -0800552 return String(ctx.mod.Properties.Sdk_version) != ""
Dan Willemsena96ff642016-06-07 12:34:45 -0700553 }
554 return false
Colin Crossca860ac2016-01-04 14:34:37 -0800555}
556
557func (ctx *moduleContextImpl) sdkVersion() string {
Dan Willemsena96ff642016-06-07 12:34:45 -0700558 if ctx.ctx.Device() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700559 if ctx.useVndk() {
Justin Yun732aa6a2018-03-23 17:43:47 +0900560 vndk_ver := ctx.ctx.DeviceConfig().VndkVersion()
Ryan Prichard05206112018-03-26 21:25:27 -0700561 if vndk_ver == "current" {
Justin Yun732aa6a2018-03-23 17:43:47 +0900562 platform_vndk_ver := ctx.ctx.DeviceConfig().PlatformVndkVersion()
563 if inList(platform_vndk_ver, ctx.ctx.Config().PlatformVersionCombinedCodenames()) {
564 return "current"
565 }
566 return platform_vndk_ver
567 }
568 return vndk_ver
Dan Willemsend2ede872016-11-18 14:54:24 -0800569 }
Justin Yun732aa6a2018-03-23 17:43:47 +0900570 return String(ctx.mod.Properties.Sdk_version)
Dan Willemsena96ff642016-06-07 12:34:45 -0700571 }
572 return ""
Colin Crossca860ac2016-01-04 14:34:37 -0800573}
574
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700575func (ctx *moduleContextImpl) useVndk() bool {
576 return ctx.mod.useVndk()
577}
Justin Yun8effde42017-06-23 19:24:43 +0900578
Logan Chienf3511742017-10-31 18:04:35 +0800579func (ctx *moduleContextImpl) isVndk() bool {
580 return ctx.mod.isVndk()
581}
582
Yi Kong7e53c572018-02-14 18:16:12 +0800583func (ctx *moduleContextImpl) isPgoCompile() bool {
584 return ctx.mod.isPgoCompile()
585}
586
Justin Yun8effde42017-06-23 19:24:43 +0900587func (ctx *moduleContextImpl) isVndkSp() bool {
Logan Chienf3511742017-10-31 18:04:35 +0800588 return ctx.mod.isVndkSp()
589}
590
591func (ctx *moduleContextImpl) isVndkExt() bool {
592 return ctx.mod.isVndkExt()
Justin Yun8effde42017-06-23 19:24:43 +0900593}
594
Jiyong Parkf9332f12018-02-01 00:54:12 +0900595func (ctx *moduleContextImpl) inRecovery() bool {
596 return ctx.mod.inRecovery()
597}
598
Logan Chien2f2b8902018-07-10 15:01:19 +0800599// Check whether ABI dumps should be created for this module.
600func (ctx *moduleContextImpl) shouldCreateVndkSourceAbiDump() bool {
601 if ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") {
602 return false
Jayant Chowdharyea0a2e12018-03-01 19:12:16 -0800603 }
Logan Chien2f2b8902018-07-10 15:01:19 +0800604 if sanitize := ctx.mod.sanitize; sanitize != nil {
605 if !sanitize.isVariantOnProductionDevice() {
606 return false
607 }
608 }
609 if !ctx.ctx.Device() {
610 // Host modules do not need ABI dumps.
611 return false
612 }
613 if inList(ctx.baseModuleName(), llndkLibraries) {
614 return true
615 }
Logan Chienf4b79c62018-08-02 02:27:02 +0800616 if inList(ctx.baseModuleName(), ndkMigratedLibs) {
617 return true
618 }
Logan Chien2f2b8902018-07-10 15:01:19 +0800619 if ctx.useVndk() && ctx.isVndk() {
620 // Return true if this is VNDK-core, VNDK-SP, or VNDK-Ext and this is not
621 // VNDK-private.
622 return Bool(ctx.mod.VendorProperties.Vendor_available) || ctx.isVndkExt()
623 }
624 return false
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800625}
626
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700627func (ctx *moduleContextImpl) selectedStl() string {
628 if stl := ctx.mod.stl; stl != nil {
629 return stl.Properties.SelectedStl
630 }
631 return ""
632}
633
Colin Crossce75d2c2016-10-06 16:12:58 -0700634func (ctx *moduleContextImpl) baseModuleName() string {
635 return ctx.mod.ModuleBase.BaseModuleName()
636}
637
Logan Chienf3511742017-10-31 18:04:35 +0800638func (ctx *moduleContextImpl) getVndkExtendsModuleName() string {
639 return ctx.mod.getVndkExtendsModuleName()
640}
641
Colin Cross635c3b02016-05-18 15:37:25 -0700642func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -0800643 return &Module{
644 hod: hod,
645 multilib: multilib,
646 }
647}
648
Colin Cross635c3b02016-05-18 15:37:25 -0700649func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -0800650 module := newBaseModule(hod, multilib)
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700651 module.features = []feature{
652 &tidyFeature{},
653 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700654 module.stl = &stl{}
Colin Cross16b23492016-01-06 14:41:07 -0800655 module.sanitize = &sanitize{}
Dan Willemsen581341d2017-02-09 16:16:31 -0800656 module.coverage = &coverage{}
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800657 module.sabi = &sabi{}
Justin Yun8effde42017-06-23 19:24:43 +0900658 module.vndkdep = &vndkdep{}
Stephen Craneba090d12017-05-09 15:44:35 -0700659 module.lto = &lto{}
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700660 module.pgo = &pgo{}
Colin Crossca860ac2016-01-04 14:34:37 -0800661 return module
662}
663
Colin Crossce75d2c2016-10-06 16:12:58 -0700664func (c *Module) Prebuilt() *android.Prebuilt {
665 if p, ok := c.linker.(prebuiltLinkerInterface); ok {
666 return p.prebuilt()
667 }
668 return nil
669}
670
671func (c *Module) Name() string {
672 name := c.ModuleBase.Name()
Dan Willemsen01a90592017-04-07 15:21:13 -0700673 if p, ok := c.linker.(interface {
674 Name(string) string
675 }); ok {
Colin Crossce75d2c2016-10-06 16:12:58 -0700676 name = p.Name(name)
677 }
678 return name
679}
680
Jeff Gaston294356f2017-09-27 17:05:30 -0700681// orderDeps reorders dependencies into a list such that if module A depends on B, then
682// A will precede B in the resultant list.
683// This is convenient for passing into a linker.
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800684// Note that directSharedDeps should be the analogous static library for each shared lib dep
685func 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 -0700686 // If A depends on B, then
687 // Every list containing A will also contain B later in the list
688 // So, after concatenating all lists, the final instance of B will have come from the same
689 // original list as the final instance of A
690 // So, the final instance of B will be later in the concatenation than the final A
691 // So, keeping only the final instance of A and of B ensures that A is earlier in the output
692 // list than B
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800693 for _, dep := range directStaticDeps {
Jeff Gaston294356f2017-09-27 17:05:30 -0700694 orderedAllDeps = append(orderedAllDeps, dep)
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800695 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
696 }
697 for _, dep := range directSharedDeps {
698 orderedAllDeps = append(orderedAllDeps, dep)
699 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
Jeff Gaston294356f2017-09-27 17:05:30 -0700700 }
701
Colin Crossb6715442017-10-24 11:13:31 -0700702 orderedAllDeps = android.LastUniquePaths(orderedAllDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700703
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800704 // We don't want to add any new dependencies into directStaticDeps (to allow the caller to
Jeff Gaston294356f2017-09-27 17:05:30 -0700705 // intentionally exclude or replace any unwanted transitive dependencies), so we limit the
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800706 // resultant list to only what the caller has chosen to include in directStaticDeps
707 _, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700708
709 return orderedAllDeps, orderedDeclaredDeps
710}
711
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800712func orderStaticModuleDeps(module *Module, staticDeps []*Module, sharedDeps []*Module) (results []android.Path) {
713 // convert Module to Path
714 allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps))
715 staticDepFiles := []android.Path{}
716 for _, dep := range staticDeps {
717 allTransitiveDeps[dep.outputFile.Path()] = dep.depsInLinkOrder
718 staticDepFiles = append(staticDepFiles, dep.outputFile.Path())
Jeff Gaston294356f2017-09-27 17:05:30 -0700719 }
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800720 sharedDepFiles := []android.Path{}
721 for _, sharedDep := range sharedDeps {
722 staticAnalogue := sharedDep.staticVariant
723 if staticAnalogue != nil {
724 allTransitiveDeps[staticAnalogue.outputFile.Path()] = staticAnalogue.depsInLinkOrder
725 sharedDepFiles = append(sharedDepFiles, staticAnalogue.outputFile.Path())
726 }
Jeff Gaston294356f2017-09-27 17:05:30 -0700727 }
728
729 // reorder the dependencies based on transitive dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800730 module.depsInLinkOrder, results = orderDeps(staticDepFiles, sharedDepFiles, allTransitiveDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700731
732 return results
Jeff Gaston294356f2017-09-27 17:05:30 -0700733}
734
Colin Cross635c3b02016-05-18 15:37:25 -0700735func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
Colin Crossca860ac2016-01-04 14:34:37 -0800736 ctx := &moduleContext{
Colin Cross635c3b02016-05-18 15:37:25 -0700737 ModuleContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -0800738 moduleContextImpl: moduleContextImpl{
739 mod: c,
740 },
741 }
742 ctx.ctx = ctx
743
Colin Crossf18e1102017-11-16 14:33:08 -0800744 deps := c.depsToPaths(ctx)
745 if ctx.Failed() {
746 return
747 }
748
Dan Willemsen8536d6b2018-10-07 20:54:34 -0700749 if c.Properties.Clang != nil && *c.Properties.Clang == false {
750 ctx.PropertyErrorf("clang", "false (GCC) is no longer supported")
751 }
752
Colin Crossca860ac2016-01-04 14:34:37 -0800753 flags := Flags{
754 Toolchain: c.toolchain(ctx),
Colin Crossca860ac2016-01-04 14:34:37 -0800755 }
Colin Crossca860ac2016-01-04 14:34:37 -0800756 if c.compiler != nil {
Colin Crossf18e1102017-11-16 14:33:08 -0800757 flags = c.compiler.compilerFlags(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -0800758 }
759 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700760 flags = c.linker.linkerFlags(ctx, flags)
Colin Crossca860ac2016-01-04 14:34:37 -0800761 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700762 if c.stl != nil {
763 flags = c.stl.flags(ctx, flags)
764 }
Colin Cross16b23492016-01-06 14:41:07 -0800765 if c.sanitize != nil {
766 flags = c.sanitize.flags(ctx, flags)
767 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800768 if c.coverage != nil {
769 flags = c.coverage.flags(ctx, flags)
770 }
Stephen Craneba090d12017-05-09 15:44:35 -0700771 if c.lto != nil {
772 flags = c.lto.flags(ctx, flags)
773 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700774 if c.pgo != nil {
775 flags = c.pgo.flags(ctx, flags)
776 }
Colin Crossca860ac2016-01-04 14:34:37 -0800777 for _, feature := range c.features {
778 flags = feature.flags(ctx, flags)
779 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800780 if ctx.Failed() {
781 return
782 }
783
Colin Crossb98c8b02016-07-29 13:44:28 -0700784 flags.CFlags, _ = filterList(flags.CFlags, config.IllegalFlags)
785 flags.CppFlags, _ = filterList(flags.CppFlags, config.IllegalFlags)
786 flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags)
Colin Cross3f40fa42015-01-30 17:27:36 -0800787
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800788 flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...)
789 c.flags = flags
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700790 // We need access to all the flags seen by a source file.
791 if c.sabi != nil {
792 flags = c.sabi.flags(ctx, flags)
793 }
Colin Crossca860ac2016-01-04 14:34:37 -0800794 // Optimization to reduce size of build.ninja
795 // Replace the long list of flags for each file with a module-local variable
796 ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " "))
797 ctx.Variable(pctx, "cppflags", strings.Join(flags.CppFlags, " "))
798 ctx.Variable(pctx, "asflags", strings.Join(flags.AsFlags, " "))
799 flags.CFlags = []string{"$cflags"}
800 flags.CppFlags = []string{"$cppflags"}
801 flags.AsFlags = []string{"$asflags"}
802
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700803 var objs Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800804 if c.compiler != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700805 objs = c.compiler.compile(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -0800806 if ctx.Failed() {
807 return
808 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800809 }
810
Colin Crossca860ac2016-01-04 14:34:37 -0800811 if c.linker != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700812 outputFile := c.linker.link(ctx, flags, deps, objs)
Colin Crossca860ac2016-01-04 14:34:37 -0800813 if ctx.Failed() {
814 return
815 }
Colin Cross635c3b02016-05-18 15:37:25 -0700816 c.outputFile = android.OptionalPathForPath(outputFile)
Colin Crossce75d2c2016-10-06 16:12:58 -0700817 }
Colin Cross5049f022015-03-18 13:28:46 -0700818
Jiyong Park9d452992018-10-03 00:38:19 +0900819 if c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() {
Colin Crossce75d2c2016-10-06 16:12:58 -0700820 c.installer.install(ctx, c.outputFile.Path())
821 if ctx.Failed() {
822 return
Colin Crossca860ac2016-01-04 14:34:37 -0800823 }
Dan Albertc403f7c2015-03-18 14:01:18 -0700824 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800825}
826
Colin Crossb98c8b02016-07-29 13:44:28 -0700827func (c *Module) toolchain(ctx BaseModuleContext) config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -0800828 if c.cachedToolchain == nil {
Colin Crossb98c8b02016-07-29 13:44:28 -0700829 c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
Colin Cross3f40fa42015-01-30 17:27:36 -0800830 }
Colin Crossca860ac2016-01-04 14:34:37 -0800831 return c.cachedToolchain
Colin Cross3f40fa42015-01-30 17:27:36 -0800832}
833
Colin Crossca860ac2016-01-04 14:34:37 -0800834func (c *Module) begin(ctx BaseModuleContext) {
835 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700836 c.compiler.compilerInit(ctx)
Colin Cross21b9a242015-03-24 14:15:58 -0700837 }
Colin Crossca860ac2016-01-04 14:34:37 -0800838 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700839 c.linker.linkerInit(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -0800840 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700841 if c.stl != nil {
842 c.stl.begin(ctx)
843 }
Colin Cross16b23492016-01-06 14:41:07 -0800844 if c.sanitize != nil {
845 c.sanitize.begin(ctx)
846 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800847 if c.coverage != nil {
848 c.coverage.begin(ctx)
849 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800850 if c.sabi != nil {
851 c.sabi.begin(ctx)
852 }
Justin Yun8effde42017-06-23 19:24:43 +0900853 if c.vndkdep != nil {
854 c.vndkdep.begin(ctx)
855 }
Stephen Craneba090d12017-05-09 15:44:35 -0700856 if c.lto != nil {
857 c.lto.begin(ctx)
858 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700859 if c.pgo != nil {
860 c.pgo.begin(ctx)
861 }
Colin Crossca860ac2016-01-04 14:34:37 -0800862 for _, feature := range c.features {
863 feature.begin(ctx)
864 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700865 if ctx.useSdk() {
Dan Albertf5415d72017-08-17 16:19:59 -0700866 version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
Dan Albert7fa7b2e2016-08-05 16:37:52 -0700867 if err != nil {
868 ctx.PropertyErrorf("sdk_version", err.Error())
869 }
Nan Zhang0007d812017-11-07 10:57:05 -0800870 c.Properties.Sdk_version = StringPtr(version)
Dan Albert7fa7b2e2016-08-05 16:37:52 -0700871 }
Colin Crossca860ac2016-01-04 14:34:37 -0800872}
873
Colin Cross37047f12016-12-13 17:06:13 -0800874func (c *Module) deps(ctx DepsContext) Deps {
Colin Crossc99deeb2016-04-11 15:06:20 -0700875 deps := Deps{}
876
877 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700878 deps = c.compiler.compilerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -0700879 }
Pirama Arumuga Nainar0b882f02018-04-23 22:44:39 +0000880 // Add the PGO dependency (the clang_rt.profile runtime library), which
881 // sometimes depends on symbols from libgcc, before libgcc gets added
882 // in linkerDeps().
Pirama Arumuga Nainar49b53d52017-10-04 16:47:29 -0700883 if c.pgo != nil {
884 deps = c.pgo.deps(ctx, deps)
885 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700886 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700887 deps = c.linker.linkerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -0700888 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700889 if c.stl != nil {
890 deps = c.stl.deps(ctx, deps)
891 }
Colin Cross16b23492016-01-06 14:41:07 -0800892 if c.sanitize != nil {
893 deps = c.sanitize.deps(ctx, deps)
894 }
Pirama Arumuga Nainar0b882f02018-04-23 22:44:39 +0000895 if c.coverage != nil {
896 deps = c.coverage.deps(ctx, deps)
897 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800898 if c.sabi != nil {
899 deps = c.sabi.deps(ctx, deps)
900 }
Justin Yun8effde42017-06-23 19:24:43 +0900901 if c.vndkdep != nil {
902 deps = c.vndkdep.deps(ctx, deps)
903 }
Stephen Craneba090d12017-05-09 15:44:35 -0700904 if c.lto != nil {
905 deps = c.lto.deps(ctx, deps)
906 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700907 for _, feature := range c.features {
908 deps = feature.deps(ctx, deps)
909 }
910
Colin Crossb6715442017-10-24 11:13:31 -0700911 deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
912 deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
913 deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
914 deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
915 deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
916 deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
Logan Chien43d34c32017-12-20 01:17:32 +0800917 deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
Colin Crossc99deeb2016-04-11 15:06:20 -0700918
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700919 for _, lib := range deps.ReexportSharedLibHeaders {
920 if !inList(lib, deps.SharedLibs) {
921 ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
922 }
923 }
924
925 for _, lib := range deps.ReexportStaticLibHeaders {
926 if !inList(lib, deps.StaticLibs) {
927 ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs: '%s'", lib)
928 }
929 }
930
Colin Cross5950f382016-12-13 12:50:57 -0800931 for _, lib := range deps.ReexportHeaderLibHeaders {
932 if !inList(lib, deps.HeaderLibs) {
933 ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib)
934 }
935 }
936
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700937 for _, gen := range deps.ReexportGeneratedHeaders {
938 if !inList(gen, deps.GeneratedHeaders) {
939 ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen)
940 }
941 }
942
Colin Crossc99deeb2016-04-11 15:06:20 -0700943 return deps
944}
945
Dan Albert7e9d2952016-08-04 13:02:36 -0700946func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
Colin Crossca860ac2016-01-04 14:34:37 -0800947 ctx := &baseModuleContext{
Colin Cross635c3b02016-05-18 15:37:25 -0700948 BaseContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -0800949 moduleContextImpl: moduleContextImpl{
950 mod: c,
951 },
952 }
953 ctx.ctx = ctx
954
Colin Crossca860ac2016-01-04 14:34:37 -0800955 c.begin(ctx)
Dan Albert7e9d2952016-08-04 13:02:36 -0700956}
957
Jiyong Park7ed9de32018-10-15 22:25:07 +0900958// Split name#version into name and version
959func stubsLibNameAndVersion(name string) (string, string) {
960 if sharp := strings.LastIndex(name, "#"); sharp != -1 && sharp != len(name)-1 {
961 version := name[sharp+1:]
962 libname := name[:sharp]
963 return libname, version
964 }
965 return name, ""
966}
967
Colin Cross1e676be2016-10-12 14:38:15 -0700968func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
Colin Cross37047f12016-12-13 17:06:13 -0800969 ctx := &depsContext{
970 BottomUpMutatorContext: actx,
Dan Albert7e9d2952016-08-04 13:02:36 -0700971 moduleContextImpl: moduleContextImpl{
972 mod: c,
973 },
974 }
975 ctx.ctx = ctx
Colin Crossca860ac2016-01-04 14:34:37 -0800976
Colin Crossc99deeb2016-04-11 15:06:20 -0700977 deps := c.deps(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -0800978
Dan Albert914449f2016-06-17 16:45:24 -0700979 variantNdkLibs := []string{}
980 variantLateNdkLibs := []string{}
Dan Willemsenb916b802017-03-19 13:44:32 -0700981 if ctx.Os() == android.Android {
Dan Albert914449f2016-06-17 16:45:24 -0700982 version := ctx.sdkVersion()
Dan Willemsen72d39932016-07-08 23:23:48 -0700983
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700984 // rewriteNdkLibs takes a list of names of shared libraries and scans it for three types
985 // of names:
Dan Albert914449f2016-06-17 16:45:24 -0700986 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700987 // 1. Name of an NDK library that refers to a prebuilt module.
988 // For each of these, it adds the name of the prebuilt module (which will be in
989 // prebuilts/ndk) to the list of nonvariant libs.
990 // 2. Name of an NDK library that refers to an ndk_library module.
991 // For each of these, it adds the name of the ndk_library module to the list of
992 // variant libs.
993 // 3. Anything else (so anything that isn't an NDK library).
994 // It adds these to the nonvariantLibs list.
Dan Albert914449f2016-06-17 16:45:24 -0700995 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700996 // The caller can then know to add the variantLibs dependencies differently from the
997 // nonvariantLibs
998 rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
999 variantLibs = []string{}
1000 nonvariantLibs = []string{}
Dan Albert914449f2016-06-17 16:45:24 -07001001 for _, entry := range list {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001002 // strip #version suffix out
1003 name, _ := stubsLibNameAndVersion(entry)
1004 if ctx.useSdk() && inList(name, ndkPrebuiltSharedLibraries) {
1005 if !inList(name, ndkMigratedLibs) {
1006 nonvariantLibs = append(nonvariantLibs, name+".ndk."+version)
Dan Albert914449f2016-06-17 16:45:24 -07001007 } else {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001008 variantLibs = append(variantLibs, name+ndkLibrarySuffix)
Dan Albert914449f2016-06-17 16:45:24 -07001009 }
Jiyong Park7ed9de32018-10-15 22:25:07 +09001010 } else if ctx.useVndk() && inList(name, llndkLibraries) {
1011 nonvariantLibs = append(nonvariantLibs, name+llndkLibrarySuffix)
1012 } else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, vendorPublicLibraries) {
1013 vendorPublicLib := name + vendorPublicLibrarySuffix
Jiyong Park374510b2018-03-19 18:23:01 +09001014 if actx.OtherModuleExists(vendorPublicLib) {
1015 nonvariantLibs = append(nonvariantLibs, vendorPublicLib)
1016 } else {
1017 // This can happen if vendor_public_library module is defined in a
1018 // namespace that isn't visible to the current module. In that case,
1019 // link to the original library.
Jiyong Park7ed9de32018-10-15 22:25:07 +09001020 nonvariantLibs = append(nonvariantLibs, name)
Jiyong Park374510b2018-03-19 18:23:01 +09001021 }
Dan Albert914449f2016-06-17 16:45:24 -07001022 } else {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001023 // put name#version back
Dan Willemsen7cbf5f82017-03-28 00:08:30 -07001024 nonvariantLibs = append(nonvariantLibs, entry)
Dan Willemsen72d39932016-07-08 23:23:48 -07001025 }
1026 }
Dan Albert914449f2016-06-17 16:45:24 -07001027 return nonvariantLibs, variantLibs
Dan Willemsen72d39932016-07-08 23:23:48 -07001028 }
1029
Dan Albert914449f2016-06-17 16:45:24 -07001030 deps.SharedLibs, variantNdkLibs = rewriteNdkLibs(deps.SharedLibs)
1031 deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs)
Jiyong Park4c35af02017-07-05 13:41:55 +09001032 deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
Dan Willemsen72d39932016-07-08 23:23:48 -07001033 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001034
Jiyong Park7ed9de32018-10-15 22:25:07 +09001035 if c.linker != nil {
1036 if library, ok := c.linker.(*libraryDecorator); ok {
1037 if library.buildStubs() {
1038 // Stubs lib does not have dependency to other libraries. Don't proceed.
1039 return
1040 }
1041 }
1042 }
1043
Colin Cross32ec36c2016-12-15 07:39:51 -08001044 for _, lib := range deps.HeaderLibs {
1045 depTag := headerDepTag
1046 if inList(lib, deps.ReexportHeaderLibHeaders) {
1047 depTag = headerExportDepTag
1048 }
1049 actx.AddVariationDependencies(nil, depTag, lib)
1050 }
Colin Cross5950f382016-12-13 12:50:57 -08001051
Dan Willemsen59339a22018-07-22 21:18:45 -07001052 actx.AddVariationDependencies([]blueprint.Variation{
1053 {Mutator: "link", Variation: "static"},
1054 }, wholeStaticDepTag, deps.WholeStaticLibs...)
Colin Crossc99deeb2016-04-11 15:06:20 -07001055
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001056 for _, lib := range deps.StaticLibs {
1057 depTag := staticDepTag
1058 if inList(lib, deps.ReexportStaticLibHeaders) {
1059 depTag = staticExportDepTag
1060 }
Dan Willemsen59339a22018-07-22 21:18:45 -07001061 actx.AddVariationDependencies([]blueprint.Variation{
1062 {Mutator: "link", Variation: "static"},
1063 }, depTag, lib)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001064 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001065
Dan Willemsen59339a22018-07-22 21:18:45 -07001066 actx.AddVariationDependencies([]blueprint.Variation{
1067 {Mutator: "link", Variation: "static"},
1068 }, lateStaticDepTag, deps.LateStaticLibs...)
Colin Crossc99deeb2016-04-11 15:06:20 -07001069
Jiyong Park7ed9de32018-10-15 22:25:07 +09001070 // shared lib names without the #version suffix
1071 var sharedLibNames []string
1072
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001073 for _, lib := range deps.SharedLibs {
Jiyong Park7ed9de32018-10-15 22:25:07 +09001074 name, version := stubsLibNameAndVersion(lib)
1075 sharedLibNames = append(sharedLibNames, name)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001076 depTag := sharedDepTag
1077 if inList(lib, deps.ReexportSharedLibHeaders) {
1078 depTag = sharedExportDepTag
1079 }
Jiyong Park7ed9de32018-10-15 22:25:07 +09001080 var variations []blueprint.Variation
1081 variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
1082 if version != "" && ctx.Os() == android.Android && !ctx.useVndk() && !c.inRecovery() {
1083 variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
1084 }
1085 actx.AddVariationDependencies(variations, depTag, name)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001086 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001087
Jiyong Park7ed9de32018-10-15 22:25:07 +09001088 for _, lib := range deps.LateSharedLibs {
1089 name, version := stubsLibNameAndVersion(lib)
1090 if inList(name, sharedLibNames) {
1091 // This is to handle the case that some of the late shared libs (libc, libdl, libm, ...)
1092 // are added also to SharedLibs with version (e.g., libc#10). If not skipped, we will be
1093 // linking against both the stubs lib and the non-stubs lib at the same time.
1094 continue
1095 }
1096 depTag := lateSharedDepTag
1097 var variations []blueprint.Variation
1098 variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
1099 if version != "" && ctx.Os() == android.Android && !ctx.useVndk() && !c.inRecovery() {
1100 variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
1101 }
1102 actx.AddVariationDependencies(variations, depTag, name)
1103 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001104
Dan Willemsen59339a22018-07-22 21:18:45 -07001105 actx.AddVariationDependencies([]blueprint.Variation{
1106 {Mutator: "link", Variation: "shared"},
1107 }, runtimeDepTag, deps.RuntimeLibs...)
Logan Chien43d34c32017-12-20 01:17:32 +08001108
Colin Cross68861832016-07-08 10:41:41 -07001109 actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...)
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001110
1111 for _, gen := range deps.GeneratedHeaders {
1112 depTag := genHeaderDepTag
1113 if inList(gen, deps.ReexportGeneratedHeaders) {
1114 depTag = genHeaderExportDepTag
1115 }
1116 actx.AddDependency(c, depTag, gen)
1117 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001118
Colin Cross42d48b72018-08-29 14:10:52 -07001119 actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)
Colin Crossc99deeb2016-04-11 15:06:20 -07001120
1121 if deps.CrtBegin != "" {
Colin Cross42d48b72018-08-29 14:10:52 -07001122 actx.AddVariationDependencies(nil, crtBeginDepTag, deps.CrtBegin)
Colin Crossca860ac2016-01-04 14:34:37 -08001123 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001124 if deps.CrtEnd != "" {
Colin Cross42d48b72018-08-29 14:10:52 -07001125 actx.AddVariationDependencies(nil, crtEndDepTag, deps.CrtEnd)
Colin Cross21b9a242015-03-24 14:15:58 -07001126 }
Dan Willemsena0790e32018-10-12 00:24:23 -07001127 if deps.LinkerFlagsFile != "" {
1128 actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
1129 }
1130 if deps.DynamicLinker != "" {
1131 actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001132 }
Dan Albert914449f2016-06-17 16:45:24 -07001133
1134 version := ctx.sdkVersion()
1135 actx.AddVariationDependencies([]blueprint.Variation{
Dan Willemsen59339a22018-07-22 21:18:45 -07001136 {Mutator: "ndk_api", Variation: version},
1137 {Mutator: "link", Variation: "shared"},
1138 }, ndkStubDepTag, variantNdkLibs...)
Dan Albert914449f2016-06-17 16:45:24 -07001139 actx.AddVariationDependencies([]blueprint.Variation{
Dan Willemsen59339a22018-07-22 21:18:45 -07001140 {Mutator: "ndk_api", Variation: version},
1141 {Mutator: "link", Variation: "shared"},
1142 }, ndkLateStubDepTag, variantLateNdkLibs...)
Logan Chienf3511742017-10-31 18:04:35 +08001143
1144 if vndkdep := c.vndkdep; vndkdep != nil {
1145 if vndkdep.isVndkExt() {
1146 baseModuleMode := vendorMode
1147 if actx.DeviceConfig().VndkVersion() == "" {
1148 baseModuleMode = coreMode
1149 }
1150 actx.AddVariationDependencies([]blueprint.Variation{
Dan Willemsen59339a22018-07-22 21:18:45 -07001151 {Mutator: "image", Variation: baseModuleMode},
1152 {Mutator: "link", Variation: "shared"},
1153 }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
Logan Chienf3511742017-10-31 18:04:35 +08001154 }
1155 }
Colin Cross6362e272015-10-29 15:25:03 -07001156}
Colin Cross21b9a242015-03-24 14:15:58 -07001157
Colin Crosse40b4ea2018-10-02 22:25:58 -07001158func BeginMutator(ctx android.BottomUpMutatorContext) {
Dan Albert7e9d2952016-08-04 13:02:36 -07001159 if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
1160 c.beginMutator(ctx)
1161 }
1162}
1163
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001164// Whether a module can link to another module, taking into
1165// account NDK linking.
Logan Chienf3511742017-10-31 18:04:35 +08001166func checkLinkType(ctx android.ModuleContext, from *Module, to *Module, tag dependencyTag) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001167 if from.Target().Os != android.Android {
1168 // Host code is not restricted
1169 return
1170 }
1171 if from.Properties.UseVndk {
1172 // Though vendor code is limited by the vendor mutator,
1173 // each vendor-available module needs to check
1174 // link-type for VNDK.
1175 if from.vndkdep != nil {
Logan Chienf3511742017-10-31 18:04:35 +08001176 from.vndkdep.vndkCheckLinkType(ctx, to, tag)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001177 }
1178 return
1179 }
Nan Zhang0007d812017-11-07 10:57:05 -08001180 if String(from.Properties.Sdk_version) == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001181 // Platform code can link to anything
1182 return
1183 }
Jiyong Parkf9332f12018-02-01 00:54:12 +09001184 if from.inRecovery() {
1185 // Recovery code is not NDK
1186 return
1187 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001188 if _, ok := to.linker.(*toolchainLibraryDecorator); ok {
1189 // These are always allowed
1190 return
1191 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001192 if _, ok := to.linker.(*ndkPrebuiltStlLinker); ok {
1193 // These are allowed, but they don't set sdk_version
1194 return
1195 }
1196 if _, ok := to.linker.(*stubDecorator); ok {
1197 // These aren't real libraries, but are the stub shared libraries that are included in
1198 // the NDK.
1199 return
1200 }
Nan Zhang0007d812017-11-07 10:57:05 -08001201 if String(to.Properties.Sdk_version) == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001202 // NDK code linking to platform code is never okay.
1203 ctx.ModuleErrorf("depends on non-NDK-built library %q",
1204 ctx.OtherModuleName(to))
1205 }
1206
1207 // At this point we know we have two NDK libraries, but we need to
1208 // check that we're not linking against anything built against a higher
1209 // API level, as it is only valid to link against older or equivalent
1210 // APIs.
1211
Inseob Kim01a28722018-04-11 09:48:45 +09001212 // Current can link against anything.
1213 if String(from.Properties.Sdk_version) != "current" {
1214 // Otherwise we need to check.
1215 if String(to.Properties.Sdk_version) == "current" {
1216 // Current can't be linked against by anything else.
1217 ctx.ModuleErrorf("links %q built against newer API version %q",
1218 ctx.OtherModuleName(to), "current")
1219 } else {
1220 fromApi, err := strconv.Atoi(String(from.Properties.Sdk_version))
1221 if err != nil {
1222 ctx.PropertyErrorf("sdk_version",
Inseob Kim34b22832018-04-11 10:13:16 +09001223 "Invalid sdk_version value (must be int or current): %q",
Inseob Kim01a28722018-04-11 09:48:45 +09001224 String(from.Properties.Sdk_version))
1225 }
1226 toApi, err := strconv.Atoi(String(to.Properties.Sdk_version))
1227 if err != nil {
1228 ctx.PropertyErrorf("sdk_version",
Inseob Kim34b22832018-04-11 10:13:16 +09001229 "Invalid sdk_version value (must be int or current): %q",
Inseob Kim01a28722018-04-11 09:48:45 +09001230 String(to.Properties.Sdk_version))
1231 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001232
Inseob Kim01a28722018-04-11 09:48:45 +09001233 if toApi > fromApi {
1234 ctx.ModuleErrorf("links %q built against newer API version %q",
1235 ctx.OtherModuleName(to), String(to.Properties.Sdk_version))
1236 }
1237 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001238 }
Dan Albert202fe492017-12-15 13:56:59 -08001239
1240 // Also check that the two STL choices are compatible.
1241 fromStl := from.stl.Properties.SelectedStl
1242 toStl := to.stl.Properties.SelectedStl
1243 if fromStl == "" || toStl == "" {
1244 // Libraries that don't use the STL are unrestricted.
Inseob Kimda2171a2018-04-11 15:41:38 +09001245 } else if fromStl == "ndk_system" || toStl == "ndk_system" {
Dan Albert202fe492017-12-15 13:56:59 -08001246 // We can be permissive with the system "STL" since it is only the C++
1247 // ABI layer, but in the future we should make sure that everyone is
1248 // using either libc++ or nothing.
Colin Crossb60190a2018-09-04 16:28:17 -07001249 } else if getNdkStlFamily(from) != getNdkStlFamily(to) {
Dan Albert202fe492017-12-15 13:56:59 -08001250 ctx.ModuleErrorf("uses %q and depends on %q which uses incompatible %q",
1251 from.stl.Properties.SelectedStl, ctx.OtherModuleName(to),
1252 to.stl.Properties.SelectedStl)
1253 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001254}
1255
Jiyong Park5fb8c102018-04-09 12:03:06 +09001256// Tests whether the dependent library is okay to be double loaded inside a single process.
1257// If a library is a member of VNDK and at the same time dependencies of an LLNDK library,
1258// it is subject to be double loaded. Such lib should be explicitly marked as double_loaded: true
1259// or as vndk-sp (vndk: { enabled: true, support_system_process: true}).
1260func checkDoubleLoadableLibries(ctx android.ModuleContext, from *Module, to *Module) {
1261 if _, ok := from.linker.(*libraryDecorator); !ok {
1262 return
1263 }
1264
1265 if inList(ctx.ModuleName(), llndkLibraries) ||
1266 (from.useVndk() && Bool(from.VendorProperties.Double_loadable)) {
1267 _, depIsLlndk := to.linker.(*llndkStubDecorator)
1268 depIsVndkSp := false
1269 if to.vndkdep != nil && to.vndkdep.isVndkSp() {
1270 depIsVndkSp = true
1271 }
1272 depIsVndk := false
1273 if to.vndkdep != nil && to.vndkdep.isVndk() {
1274 depIsVndk = true
1275 }
1276 depIsDoubleLoadable := Bool(to.VendorProperties.Double_loadable)
1277 if !depIsLlndk && !depIsVndkSp && !depIsDoubleLoadable && depIsVndk {
1278 ctx.ModuleErrorf("links VNDK library %q that isn't double_loadable.",
1279 ctx.OtherModuleName(to))
1280 }
1281 }
1282}
1283
Colin Crossc99deeb2016-04-11 15:06:20 -07001284// Convert dependencies to paths. Returns a PathDeps containing paths
Colin Cross635c3b02016-05-18 15:37:25 -07001285func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
Colin Crossca860ac2016-01-04 14:34:37 -08001286 var depPaths PathDeps
Colin Crossca860ac2016-01-04 14:34:37 -08001287
Jeff Gaston294356f2017-09-27 17:05:30 -07001288 directStaticDeps := []*Module{}
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001289 directSharedDeps := []*Module{}
Jeff Gaston294356f2017-09-27 17:05:30 -07001290
Colin Crossd11fcda2017-10-23 17:59:01 -07001291 ctx.VisitDirectDeps(func(dep android.Module) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001292 depName := ctx.OtherModuleName(dep)
1293 depTag := ctx.OtherModuleDependencyTag(dep)
Dan Albert9e10cd42016-08-03 14:12:14 -07001294
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001295 ccDep, _ := dep.(*Module)
1296 if ccDep == nil {
1297 // handling for a few module types that aren't cc Module but that are also supported
1298 switch depTag {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001299 case genSourceDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001300 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001301 depPaths.GeneratedSources = append(depPaths.GeneratedSources,
1302 genRule.GeneratedSourceFiles()...)
1303 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001304 ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07001305 }
Colin Crosse90bfd12017-04-26 16:59:26 -07001306 // Support exported headers from a generated_sources dependency
1307 fallthrough
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001308 case genHeaderDepTag, genHeaderExportDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001309 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001310 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
Dan Willemsen9da9d492018-02-21 18:28:18 -08001311 genRule.GeneratedDeps()...)
Colin Cross5ed99c62016-11-22 12:55:55 -08001312 flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001313 depPaths.Flags = append(depPaths.Flags, flags)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001314 if depTag == genHeaderExportDepTag {
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001315 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001316 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
Dan Willemsen9da9d492018-02-21 18:28:18 -08001317 genRule.GeneratedDeps()...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07001318 // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
1319 c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags)
1320
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001321 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001322 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001323 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07001324 }
Dan Willemsena0790e32018-10-12 00:24:23 -07001325 case linkerFlagsDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001326 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001327 files := genRule.GeneratedSourceFiles()
1328 if len(files) == 1 {
Dan Willemsena0790e32018-10-12 00:24:23 -07001329 depPaths.LinkerFlagsFile = android.OptionalPathForPath(files[0])
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001330 } else if len(files) > 1 {
Dan Willemsena0790e32018-10-12 00:24:23 -07001331 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 -07001332 }
1333 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001334 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001335 }
Colin Crossca860ac2016-01-04 14:34:37 -08001336 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001337 return
1338 }
1339
Colin Crossd11fcda2017-10-23 17:59:01 -07001340 if dep.Target().Os != ctx.Os() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001341 ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
1342 return
1343 }
Colin Crossd11fcda2017-10-23 17:59:01 -07001344 if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001345 ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
Colin Crossa1ad8d12016-06-01 17:09:44 -07001346 return
1347 }
1348
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001349 // re-exporting flags
1350 if depTag == reuseObjTag {
1351 if l, ok := ccDep.compiler.(libraryInterface); ok {
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001352 c.staticVariant = ccDep
Colin Crossbbc9f4d2017-05-03 16:24:55 -07001353 objs, flags, deps := l.reuseObjs()
Colin Cross10d22312017-05-03 11:01:58 -07001354 depPaths.Objs = depPaths.Objs.Append(objs)
1355 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
Colin Crossbbc9f4d2017-05-03 16:24:55 -07001356 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
Colin Crossbba99042016-11-23 15:45:05 -08001357 return
1358 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001359 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001360 if t, ok := depTag.(dependencyTag); ok && t.library {
1361 if i, ok := ccDep.linker.(exportedFlagsProducer); ok {
Dan Willemsen76f08272016-07-09 00:14:08 -07001362 flags := i.exportedFlags()
Dan Willemsen847dcc72016-09-29 12:13:36 -07001363 deps := i.exportedFlagsDeps()
Dan Willemsen76f08272016-07-09 00:14:08 -07001364 depPaths.Flags = append(depPaths.Flags, flags...)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001365 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, deps...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001366
1367 if t.reexportFlags {
Dan Willemsen76f08272016-07-09 00:14:08 -07001368 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001369 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07001370 // 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 -07001371 // Re-exported shared library headers must be included as well since they can help us with type information
1372 // about template instantiations (instantiated from their headers).
1373 c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001374 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001375 }
Dan Willemsena96ff642016-06-07 12:34:45 -07001376
Logan Chienf3511742017-10-31 18:04:35 +08001377 checkLinkType(ctx, c, ccDep, t)
Jiyong Park5fb8c102018-04-09 12:03:06 +09001378 checkDoubleLoadableLibries(ctx, c, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07001379 }
1380
Colin Cross26c34ed2016-09-30 17:10:16 -07001381 var ptr *android.Paths
Colin Cross635c3b02016-05-18 15:37:25 -07001382 var depPtr *android.Paths
Colin Crossc99deeb2016-04-11 15:06:20 -07001383
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001384 linkFile := ccDep.outputFile
Colin Cross26c34ed2016-09-30 17:10:16 -07001385 depFile := android.OptionalPath{}
1386
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001387 switch depTag {
Dan Albert914449f2016-06-17 16:45:24 -07001388 case ndkStubDepTag, sharedDepTag, sharedExportDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001389 ptr = &depPaths.SharedLibs
1390 depPtr = &depPaths.SharedLibsDeps
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001391 depFile = ccDep.linker.(libraryInterface).toc()
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001392 directSharedDeps = append(directSharedDeps, ccDep)
Dan Albert914449f2016-06-17 16:45:24 -07001393 case lateSharedDepTag, ndkLateStubDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001394 ptr = &depPaths.LateSharedLibs
1395 depPtr = &depPaths.LateSharedLibsDeps
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001396 depFile = ccDep.linker.(libraryInterface).toc()
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001397 case staticDepTag, staticExportDepTag:
Jeff Gaston294356f2017-09-27 17:05:30 -07001398 ptr = nil
1399 directStaticDeps = append(directStaticDeps, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07001400 case lateStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001401 ptr = &depPaths.LateStaticLibs
Colin Crossc99deeb2016-04-11 15:06:20 -07001402 case wholeStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001403 ptr = &depPaths.WholeStaticLibs
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001404 staticLib, ok := ccDep.linker.(libraryInterface)
Colin Crossb916a382016-07-29 17:28:03 -07001405 if !ok || !staticLib.static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001406 ctx.ModuleErrorf("module %q not a static library", depName)
Colin Crossc99deeb2016-04-11 15:06:20 -07001407 return
1408 }
1409
1410 if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001411 postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
Colin Crossc99deeb2016-04-11 15:06:20 -07001412 for i := range missingDeps {
1413 missingDeps[i] += postfix
1414 }
1415 ctx.AddMissingDependencies(missingDeps)
1416 }
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001417 depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
Colin Cross5950f382016-12-13 12:50:57 -08001418 case headerDepTag:
1419 // Nothing
Colin Crossc99deeb2016-04-11 15:06:20 -07001420 case objDepTag:
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001421 depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
Colin Crossc99deeb2016-04-11 15:06:20 -07001422 case crtBeginDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001423 depPaths.CrtBegin = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07001424 case crtEndDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001425 depPaths.CrtEnd = linkFile
Dan Willemsena0790e32018-10-12 00:24:23 -07001426 case dynamicLinkerDepTag:
1427 depPaths.DynamicLinker = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07001428 }
1429
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001430 switch depTag {
Dan Willemsen581341d2017-02-09 16:16:31 -08001431 case staticDepTag, staticExportDepTag, lateStaticDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001432 staticLib, ok := ccDep.linker.(libraryInterface)
Dan Willemsen581341d2017-02-09 16:16:31 -08001433 if !ok || !staticLib.static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001434 ctx.ModuleErrorf("module %q not a static library", depName)
Dan Willemsen581341d2017-02-09 16:16:31 -08001435 return
1436 }
1437
1438 // When combining coverage files for shared libraries and executables, coverage files
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001439 // in static libraries act as if they were whole static libraries. The same goes for
1440 // source based Abi dump files.
Dan Willemsen581341d2017-02-09 16:16:31 -08001441 depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles,
1442 staticLib.objs().coverageFiles...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001443 depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
1444 staticLib.objs().sAbiDumpFiles...)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001445
Dan Willemsen581341d2017-02-09 16:16:31 -08001446 }
1447
Colin Cross26c34ed2016-09-30 17:10:16 -07001448 if ptr != nil {
Colin Crossce75d2c2016-10-06 16:12:58 -07001449 if !linkFile.Valid() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001450 ctx.ModuleErrorf("module %q missing output file", depName)
Colin Crossce75d2c2016-10-06 16:12:58 -07001451 return
1452 }
Colin Cross26c34ed2016-09-30 17:10:16 -07001453 *ptr = append(*ptr, linkFile.Path())
1454 }
1455
Colin Crossc99deeb2016-04-11 15:06:20 -07001456 if depPtr != nil {
Colin Cross26c34ed2016-09-30 17:10:16 -07001457 dep := depFile
1458 if !dep.Valid() {
1459 dep = linkFile
1460 }
1461 *depPtr = append(*depPtr, dep.Path())
Colin Crossca860ac2016-01-04 14:34:37 -08001462 }
Jiyong Park27b188b2017-07-18 13:23:39 +09001463
Logan Chien43d34c32017-12-20 01:17:32 +08001464 makeLibName := func(depName string) string {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001465 libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
Jiyong Park374510b2018-03-19 18:23:01 +09001466 libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix)
Jiyong Park27b188b2017-07-18 13:23:39 +09001467 libName = strings.TrimPrefix(libName, "prebuilt_")
Jiyong Parkd5b18a52017-08-03 21:22:50 +09001468 isLLndk := inList(libName, llndkLibraries)
Jiyong Park374510b2018-03-19 18:23:01 +09001469 isVendorPublicLib := inList(libName, vendorPublicLibraries)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001470 bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk
1471 if c.useVndk() && bothVendorAndCoreVariantsExist {
1472 // The vendor module in Make will have been renamed to not conflict with the core
1473 // module, so update the dependency name here accordingly.
Logan Chien43d34c32017-12-20 01:17:32 +08001474 return libName + vendorSuffix
Jiyong Park374510b2018-03-19 18:23:01 +09001475 } else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib {
Logan Chien43d34c32017-12-20 01:17:32 +08001476 return libName + vendorPublicLibrarySuffix
Jiyong Parkf9332f12018-02-01 00:54:12 +09001477 } else if ccDep.inRecovery() && !ccDep.onlyInRecovery() {
1478 return libName + recoverySuffix
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001479 } else {
Logan Chien43d34c32017-12-20 01:17:32 +08001480 return libName
Jiyong Park27b188b2017-07-18 13:23:39 +09001481 }
Logan Chien43d34c32017-12-20 01:17:32 +08001482 }
1483
1484 // Export the shared libs to Make.
1485 switch depTag {
1486 case sharedDepTag, sharedExportDepTag, lateSharedDepTag:
Jiyong Park27b188b2017-07-18 13:23:39 +09001487 // Note: the order of libs in this list is not important because
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001488 // they merely serve as Make dependencies and do not affect this lib itself.
Logan Chien43d34c32017-12-20 01:17:32 +08001489 c.Properties.AndroidMkSharedLibs = append(
1490 c.Properties.AndroidMkSharedLibs, makeLibName(depName))
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +00001491 case staticDepTag, staticExportDepTag, lateStaticDepTag:
1492 c.Properties.AndroidMkStaticLibs = append(
1493 c.Properties.AndroidMkStaticLibs, makeLibName(depName))
Logan Chien43d34c32017-12-20 01:17:32 +08001494 case runtimeDepTag:
1495 c.Properties.AndroidMkRuntimeLibs = append(
1496 c.Properties.AndroidMkRuntimeLibs, makeLibName(depName))
Jaewoong Jung16c7d3d2018-11-16 01:19:56 +00001497 case wholeStaticDepTag:
1498 c.Properties.AndroidMkWholeStaticLibs = append(
1499 c.Properties.AndroidMkWholeStaticLibs, makeLibName(depName))
Jiyong Park27b188b2017-07-18 13:23:39 +09001500 }
Colin Crossca860ac2016-01-04 14:34:37 -08001501 })
1502
Jeff Gaston294356f2017-09-27 17:05:30 -07001503 // use the ordered dependencies as this module's dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001504 depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps, directSharedDeps)...)
Jeff Gaston294356f2017-09-27 17:05:30 -07001505
Colin Crossdd84e052017-05-17 13:44:16 -07001506 // Dedup exported flags from dependencies
Colin Crossb6715442017-10-24 11:13:31 -07001507 depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001508 depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
Colin Crossb6715442017-10-24 11:13:31 -07001509 depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001510 depPaths.ReexportedFlagsDeps = android.FirstUniquePaths(depPaths.ReexportedFlagsDeps)
1511
1512 if c.sabi != nil {
Colin Crossb6715442017-10-24 11:13:31 -07001513 c.sabi.Properties.ReexportedIncludeFlags = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludeFlags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001514 }
Colin Crossdd84e052017-05-17 13:44:16 -07001515
Colin Crossca860ac2016-01-04 14:34:37 -08001516 return depPaths
1517}
1518
1519func (c *Module) InstallInData() bool {
1520 if c.installer == nil {
1521 return false
1522 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001523 return c.installer.inData()
1524}
1525
1526func (c *Module) InstallInSanitizerDir() bool {
1527 if c.installer == nil {
1528 return false
1529 }
1530 if c.sanitize != nil && c.sanitize.inSanitizerDir() {
Colin Cross94610402016-08-29 13:41:32 -07001531 return true
1532 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001533 return c.installer.inSanitizerDir()
Colin Crossca860ac2016-01-04 14:34:37 -08001534}
1535
Jiyong Parkf9332f12018-02-01 00:54:12 +09001536func (c *Module) InstallInRecovery() bool {
1537 return c.inRecovery()
1538}
1539
Dan Willemsen4aa75ca2016-09-28 16:18:03 -07001540func (c *Module) HostToolPath() android.OptionalPath {
1541 if c.installer == nil {
1542 return android.OptionalPath{}
1543 }
1544 return c.installer.hostToolPath()
1545}
1546
Nan Zhangd4e641b2017-07-12 12:55:28 -07001547func (c *Module) IntermPathForModuleOut() android.OptionalPath {
1548 return c.outputFile
1549}
1550
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001551func (c *Module) Srcs() android.Paths {
1552 if c.outputFile.Valid() {
1553 return android.Paths{c.outputFile.Path()}
1554 }
1555 return android.Paths{}
1556}
1557
Vishwath Mohanb743e9c2017-11-01 09:20:21 +00001558func (c *Module) static() bool {
1559 if static, ok := c.linker.(interface {
1560 static() bool
1561 }); ok {
1562 return static.static()
1563 }
1564 return false
1565}
1566
Colin Crossb60190a2018-09-04 16:28:17 -07001567func (c *Module) getMakeLinkType() string {
1568 if c.useVndk() {
1569 if inList(c.Name(), vndkCoreLibraries) || inList(c.Name(), vndkSpLibraries) || inList(c.Name(), llndkLibraries) {
1570 if inList(c.Name(), vndkPrivateLibraries) {
1571 return "native:vndk_private"
1572 } else {
1573 return "native:vndk"
1574 }
1575 } else {
1576 return "native:vendor"
1577 }
1578 } else if c.inRecovery() {
1579 return "native:recovery"
1580 } else if c.Target().Os == android.Android && String(c.Properties.Sdk_version) != "" {
1581 return "native:ndk:none:none"
1582 // TODO(b/114741097): use the correct ndk stl once build errors have been fixed
1583 //family, link := getNdkStlFamilyAndLinkType(c)
1584 //return fmt.Sprintf("native:ndk:%s:%s", family, link)
1585 } else {
1586 return "native:platform"
1587 }
1588}
1589
Jiyong Park9d452992018-10-03 00:38:19 +09001590// Overrides ApexModule.IsInstallabeToApex()
1591// Only shared libraries are installable to APEX.
1592func (c *Module) IsInstallableToApex() bool {
1593 if shared, ok := c.linker.(interface {
1594 shared() bool
1595 }); ok {
1596 return shared.shared()
1597 }
1598 return false
1599}
1600
Colin Cross2ba19d92015-05-07 15:44:20 -07001601//
Colin Crosscfad1192015-11-02 16:43:11 -08001602// Defaults
1603//
Colin Crossca860ac2016-01-04 14:34:37 -08001604type Defaults struct {
Colin Cross635c3b02016-05-18 15:37:25 -07001605 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -07001606 android.DefaultsModuleBase
Jiyong Park9d452992018-10-03 00:38:19 +09001607 android.ApexModuleBase
Colin Crosscfad1192015-11-02 16:43:11 -08001608}
1609
Colin Cross635c3b02016-05-18 15:37:25 -07001610func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Crosscfad1192015-11-02 16:43:11 -08001611}
1612
Colin Cross1e676be2016-10-12 14:38:15 -07001613func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
1614}
1615
Colin Cross36242852017-06-23 15:06:31 -07001616func defaultsFactory() android.Module {
Colin Crosse1d764e2016-08-18 14:18:32 -07001617 return DefaultsFactory()
1618}
1619
Colin Cross36242852017-06-23 15:06:31 -07001620func DefaultsFactory(props ...interface{}) android.Module {
Colin Crossca860ac2016-01-04 14:34:37 -08001621 module := &Defaults{}
Colin Crosscfad1192015-11-02 16:43:11 -08001622
Colin Cross36242852017-06-23 15:06:31 -07001623 module.AddProperties(props...)
1624 module.AddProperties(
Colin Crossca860ac2016-01-04 14:34:37 -08001625 &BaseProperties{},
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001626 &VendorProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001627 &BaseCompilerProperties{},
1628 &BaseLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07001629 &LibraryProperties{},
Colin Cross919281a2016-04-05 16:42:05 -07001630 &FlagExporterProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001631 &BinaryLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07001632 &TestProperties{},
1633 &TestBinaryProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001634 &StlProperties{},
Colin Cross16b23492016-01-06 14:41:07 -08001635 &SanitizeProperties{},
Colin Cross665dce92016-04-28 14:50:03 -07001636 &StripProperties{},
Dan Willemsen7424d612016-09-01 13:45:39 -07001637 &InstallerProperties{},
Dan Willemsena03cf6d2016-09-26 15:45:04 -07001638 &TidyProperties{},
Dan Willemsen581341d2017-02-09 16:16:31 -08001639 &CoverageProperties{},
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001640 &SAbiProperties{},
Justin Yun4b2382f2017-07-26 14:22:10 +09001641 &VndkProperties{},
Stephen Craneba090d12017-05-09 15:44:35 -07001642 &LTOProperties{},
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -07001643 &PgoProperties{},
Dan Willemsen6424d172018-03-08 13:27:59 -08001644 &android.ProtoProperties{},
Colin Crosse1d764e2016-08-18 14:18:32 -07001645 )
Colin Crosscfad1192015-11-02 16:43:11 -08001646
Colin Cross1f44a3a2017-07-07 14:33:33 -07001647 android.InitDefaultsModule(module)
Jiyong Park9d452992018-10-03 00:38:19 +09001648 android.InitApexModule(module)
Colin Cross36242852017-06-23 15:06:31 -07001649
1650 return module
Colin Crosscfad1192015-11-02 16:43:11 -08001651}
1652
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001653const (
1654 // coreMode is the variant used for framework-private libraries, or
1655 // SDK libraries. (which framework-private libraries can use)
1656 coreMode = "core"
1657
1658 // vendorMode is the variant used for /vendor code that compiles
1659 // against the VNDK.
1660 vendorMode = "vendor"
Jiyong Parkf9332f12018-02-01 00:54:12 +09001661
1662 recoveryMode = "recovery"
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001663)
1664
Jiyong Park6a43f042017-10-12 23:05:00 +09001665func squashVendorSrcs(m *Module) {
1666 if lib, ok := m.compiler.(*libraryDecorator); ok {
1667 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
1668 lib.baseCompiler.Properties.Target.Vendor.Srcs...)
1669
1670 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
1671 lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
1672 }
1673}
1674
Jiyong Parkf9332f12018-02-01 00:54:12 +09001675func squashRecoverySrcs(m *Module) {
1676 if lib, ok := m.compiler.(*libraryDecorator); ok {
1677 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
1678 lib.baseCompiler.Properties.Target.Recovery.Srcs...)
1679
1680 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
1681 lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
1682 }
1683}
1684
1685func imageMutator(mctx android.BottomUpMutatorContext) {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001686 if mctx.Os() != android.Android {
1687 return
1688 }
1689
Jiyong Park7ed9de32018-10-15 22:25:07 +09001690 if g, ok := mctx.Module().(*genrule.Module); ok {
1691 if props, ok := g.Extra.(*GenruleExtraProperties); ok {
Jiyong Park3f736c92018-05-24 13:36:56 +09001692 var coreVariantNeeded bool = false
1693 var vendorVariantNeeded bool = false
1694 var recoveryVariantNeeded bool = false
Justin Yun71549282017-11-17 12:10:28 +09001695 if mctx.DeviceConfig().VndkVersion() == "" {
Jiyong Park3f736c92018-05-24 13:36:56 +09001696 coreVariantNeeded = true
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001697 } else if Bool(props.Vendor_available) {
Jiyong Park3f736c92018-05-24 13:36:56 +09001698 coreVariantNeeded = true
1699 vendorVariantNeeded = true
Jiyong Park2db76922017-11-08 16:03:48 +09001700 } else if mctx.SocSpecific() || mctx.DeviceSpecific() {
Jiyong Park3f736c92018-05-24 13:36:56 +09001701 vendorVariantNeeded = true
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001702 } else {
Jiyong Park3f736c92018-05-24 13:36:56 +09001703 coreVariantNeeded = true
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001704 }
Jiyong Park3f736c92018-05-24 13:36:56 +09001705 if Bool(props.Recovery_available) {
1706 recoveryVariantNeeded = true
1707 }
1708
Jiyong Park413cc742018-06-19 01:46:06 +09001709 if recoveryVariantNeeded {
Jiyong Park8d52f862018-07-07 18:02:07 +09001710 primaryArch := mctx.Config().DevicePrimaryArchType()
Jiyong Park7ed9de32018-10-15 22:25:07 +09001711 moduleArch := g.Target().Arch.ArchType
Jiyong Park8d52f862018-07-07 18:02:07 +09001712 if moduleArch != primaryArch {
Jiyong Park413cc742018-06-19 01:46:06 +09001713 recoveryVariantNeeded = false
1714 }
1715 }
1716
Jiyong Park3f736c92018-05-24 13:36:56 +09001717 var variants []string
1718 if coreVariantNeeded {
1719 variants = append(variants, coreMode)
1720 }
1721 if vendorVariantNeeded {
1722 variants = append(variants, vendorMode)
1723 }
1724 if recoveryVariantNeeded {
1725 variants = append(variants, recoveryMode)
1726 }
Jiyong Park7ed9de32018-10-15 22:25:07 +09001727 mod := mctx.CreateVariations(variants...)
1728 for i, v := range variants {
1729 if v == recoveryMode {
1730 m := mod[i].(*genrule.Module)
1731 m.Extra.(*GenruleExtraProperties).InRecovery = true
1732 }
1733 }
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001734 }
1735 }
1736
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001737 m, ok := mctx.Module().(*Module)
1738 if !ok {
1739 return
1740 }
1741
1742 // Sanity check
Logan Chienf3511742017-10-31 18:04:35 +08001743 vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
1744
1745 if m.VendorProperties.Vendor_available != nil && vendorSpecific {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001746 mctx.PropertyErrorf("vendor_available",
Jiyong Park2db76922017-11-08 16:03:48 +09001747 "doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001748 return
1749 }
Logan Chienf3511742017-10-31 18:04:35 +08001750
1751 if vndkdep := m.vndkdep; vndkdep != nil {
1752 if vndkdep.isVndk() {
1753 if vendorSpecific {
1754 if !vndkdep.isVndkExt() {
1755 mctx.PropertyErrorf("vndk",
1756 "must set `extends: \"...\"` to vndk extension")
1757 return
1758 }
1759 } else {
1760 if vndkdep.isVndkExt() {
1761 mctx.PropertyErrorf("vndk",
1762 "must set `vendor: true` to set `extends: %q`",
1763 m.getVndkExtendsModuleName())
1764 return
1765 }
1766 if m.VendorProperties.Vendor_available == nil {
1767 mctx.PropertyErrorf("vndk",
1768 "vendor_available must be set to either true or false when `vndk: {enabled: true}`")
1769 return
1770 }
1771 }
1772 } else {
1773 if vndkdep.isVndkSp() {
1774 mctx.PropertyErrorf("vndk",
1775 "must set `enabled: true` to set `support_system_process: true`")
1776 return
1777 }
1778 if vndkdep.isVndkExt() {
1779 mctx.PropertyErrorf("vndk",
1780 "must set `enabled: true` to set `extends: %q`",
1781 m.getVndkExtendsModuleName())
1782 return
1783 }
Justin Yun8effde42017-06-23 19:24:43 +09001784 }
1785 }
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001786
Jiyong Parkf9332f12018-02-01 00:54:12 +09001787 var coreVariantNeeded bool = false
1788 var vendorVariantNeeded bool = false
1789 var recoveryVariantNeeded bool = false
1790
Justin Yun71549282017-11-17 12:10:28 +09001791 if mctx.DeviceConfig().VndkVersion() == "" {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001792 // If the device isn't compiling against the VNDK, we always
1793 // use the core mode.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001794 coreVariantNeeded = true
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001795 } else if _, ok := m.linker.(*llndkStubDecorator); ok {
1796 // LL-NDK stubs only exist in the vendor variant, since the
1797 // real libraries will be used in the core variant.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001798 vendorVariantNeeded = true
Jiyong Park2a454122017-10-19 15:59:33 +09001799 } else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
1800 // ... and LL-NDK headers as well
Jiyong Parkf9332f12018-02-01 00:54:12 +09001801 vendorVariantNeeded = true
Justin Yun312ccb92018-01-23 12:07:46 +09001802 } else if _, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
Justin Yun71549282017-11-17 12:10:28 +09001803 // Make vendor variants only for the versions in BOARD_VNDK_VERSION and
1804 // PRODUCT_EXTRA_VNDK_VERSIONS.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001805 vendorVariantNeeded = true
Logan Chienf3511742017-10-31 18:04:35 +08001806 } else if m.hasVendorVariant() && !vendorSpecific {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001807 // This will be available in both /system and /vendor
Justin Yun8effde42017-06-23 19:24:43 +09001808 // or a /system directory that is available to vendor.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001809 coreVariantNeeded = true
1810 vendorVariantNeeded = true
Logan Chienf3511742017-10-31 18:04:35 +08001811 } else if vendorSpecific && String(m.Properties.Sdk_version) == "" {
Jiyong Park2db76922017-11-08 16:03:48 +09001812 // This will be available in /vendor (or /odm) only
Jiyong Parkf9332f12018-02-01 00:54:12 +09001813 vendorVariantNeeded = true
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001814 } else {
1815 // This is either in /system (or similar: /data), or is a
1816 // modules built with the NDK. Modules built with the NDK
1817 // will be restricted using the existing link type checks.
Jiyong Parkf9332f12018-02-01 00:54:12 +09001818 coreVariantNeeded = true
1819 }
1820
1821 if Bool(m.Properties.Recovery_available) {
1822 recoveryVariantNeeded = true
1823 }
1824
1825 if m.ModuleBase.InstallInRecovery() {
1826 recoveryVariantNeeded = true
1827 coreVariantNeeded = false
1828 }
1829
Jiyong Park413cc742018-06-19 01:46:06 +09001830 if recoveryVariantNeeded {
Jiyong Park8d52f862018-07-07 18:02:07 +09001831 primaryArch := mctx.Config().DevicePrimaryArchType()
1832 moduleArch := m.Target().Arch.ArchType
1833 if moduleArch != primaryArch {
Jiyong Park413cc742018-06-19 01:46:06 +09001834 recoveryVariantNeeded = false
1835 }
1836 }
1837
Jiyong Parkf9332f12018-02-01 00:54:12 +09001838 var variants []string
1839 if coreVariantNeeded {
1840 variants = append(variants, coreMode)
1841 }
1842 if vendorVariantNeeded {
1843 variants = append(variants, vendorMode)
1844 }
1845 if recoveryVariantNeeded {
1846 variants = append(variants, recoveryMode)
1847 }
1848 mod := mctx.CreateVariations(variants...)
1849 for i, v := range variants {
1850 if v == vendorMode {
1851 m := mod[i].(*Module)
1852 m.Properties.UseVndk = true
1853 squashVendorSrcs(m)
1854 } else if v == recoveryMode {
1855 m := mod[i].(*Module)
1856 m.Properties.InRecovery = true
Jiyong Park5baac542018-08-28 09:55:37 +09001857 m.MakeAsPlatform()
Jiyong Parkf9332f12018-02-01 00:54:12 +09001858 squashRecoverySrcs(m)
1859 }
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001860 }
1861}
1862
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001863func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
Colin Cross6510f912017-11-29 00:27:14 -08001864 if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001865 return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
1866 }
Colin Cross6510f912017-11-29 00:27:14 -08001867 return ctx.Config().PlatformSdkVersion()
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001868}
1869
Colin Cross06a931b2015-10-28 17:23:31 -07001870var Bool = proptools.Bool
Colin Cross38b40df2018-04-10 16:14:46 -07001871var BoolDefault = proptools.BoolDefault
Nan Zhang0007d812017-11-07 10:57:05 -08001872var BoolPtr = proptools.BoolPtr
1873var String = proptools.String
1874var StringPtr = proptools.StringPtr