blob: 34e197a07a133ba14d22af2ab8cb5b0c933a5d19 [file] [log] [blame]
Ivan Lozanoffee3342019-08-27 12:03:00 -07001// Copyright 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package rust
16
17import (
Ivan Lozano183a3212019-10-18 14:18:45 -070018 "fmt"
Ivan Lozanoffee3342019-08-27 12:03:00 -070019 "strings"
20
21 "github.com/google/blueprint"
22 "github.com/google/blueprint/proptools"
23
24 "android/soong/android"
25 "android/soong/cc"
Thiébaud Weksteen31f1bb82020-08-27 13:37:29 +020026 cc_config "android/soong/cc/config"
Ivan Lozanoffee3342019-08-27 12:03:00 -070027 "android/soong/rust/config"
28)
29
30var pctx = android.NewPackageContext("android/soong/rust")
31
32func init() {
33 // Only allow rust modules to be defined for certain projects
Ivan Lozanoffee3342019-08-27 12:03:00 -070034
35 android.AddNeverAllowRules(
36 android.NeverAllow().
Ivan Lozanoe169ad72019-09-18 08:42:54 -070037 NotIn(config.RustAllowedPaths...).
38 ModuleType(config.RustModuleTypes...))
Ivan Lozanoffee3342019-08-27 12:03:00 -070039
40 android.RegisterModuleType("rust_defaults", defaultsFactory)
41 android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
42 ctx.BottomUp("rust_libraries", LibraryMutator).Parallel()
Ivan Lozano2b081132020-09-08 12:46:52 -040043 ctx.BottomUp("rust_stdlinkage", LibstdMutator).Parallel()
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -040044 ctx.BottomUp("rust_begin", BeginMutator).Parallel()
Ivan Lozano6cd99e62020-02-11 08:24:25 -050045
46 })
47 android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
48 ctx.BottomUp("rust_sanitizers", rustSanitizerRuntimeMutator).Parallel()
Ivan Lozanoffee3342019-08-27 12:03:00 -070049 })
50 pctx.Import("android/soong/rust/config")
Thiébaud Weksteen682c9d72020-08-31 10:06:16 +020051 pctx.ImportAs("cc_config", "android/soong/cc/config")
Ivan Lozanoffee3342019-08-27 12:03:00 -070052}
53
54type Flags struct {
Ivan Lozano8a23fa42020-06-16 10:26:57 -040055 GlobalRustFlags []string // Flags that apply globally to rust
56 GlobalLinkFlags []string // Flags that apply globally to linker
57 RustFlags []string // Flags that apply to rust
58 LinkFlags []string // Flags that apply to linker
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +020059 ClippyFlags []string // Flags that apply to clippy-driver, during the linting
Ivan Lozanof1c84332019-09-20 11:00:37 -070060 Toolchain config.Toolchain
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -040061 Coverage bool
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +020062 Clippy bool
Ivan Lozanoffee3342019-08-27 12:03:00 -070063}
64
65type BaseProperties struct {
66 AndroidMkRlibs []string
67 AndroidMkDylibs []string
68 AndroidMkProcMacroLibs []string
69 AndroidMkSharedLibs []string
70 AndroidMkStaticLibs []string
Ivan Lozano43845682020-07-09 21:03:28 -040071
Ivan Lozano6a884432020-12-02 09:15:16 -050072 ImageVariationPrefix string `blueprint:"mutated"`
73 VndkVersion string `blueprint:"mutated"`
74 SubName string `blueprint:"mutated"`
75
76 // Set by imageMutator
Ivan Lozanoe6d30982021-02-05 10:57:43 -050077 CoreVariantNeeded bool `blueprint:"mutated"`
78 VendorRamdiskVariantNeeded bool `blueprint:"mutated"`
79 ExtraVariants []string `blueprint:"mutated"`
80
81 // Make this module available when building for vendor ramdisk.
82 // On device without a dedicated recovery partition, the module is only
83 // available after switching root into
84 // /first_stage_ramdisk. To expose the module before switching root, install
85 // the recovery variant instead (TODO(b/165791368) recovery not yet supported)
86 Vendor_ramdisk_available *bool
Ivan Lozano26ecd6c2020-07-31 13:40:31 -040087
Ivan Lozano3e9f9e42020-12-04 15:05:43 -050088 // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX).
89 Min_sdk_version *string
90
Ivan Lozano43845682020-07-09 21:03:28 -040091 PreventInstall bool
92 HideFromMake bool
Ivan Lozanoffee3342019-08-27 12:03:00 -070093}
94
95type Module struct {
96 android.ModuleBase
97 android.DefaultableModuleBase
Jiyong Park99644e92020-11-17 22:21:02 +090098 android.ApexModuleBase
Ivan Lozanoffee3342019-08-27 12:03:00 -070099
Ivan Lozano6a884432020-12-02 09:15:16 -0500100 VendorProperties cc.VendorProperties
101
Ivan Lozanoffee3342019-08-27 12:03:00 -0700102 Properties BaseProperties
103
104 hod android.HostOrDeviceSupported
105 multilib android.Multilib
106
Ivan Lozano6a884432020-12-02 09:15:16 -0500107 makeLinkType string
108
Ivan Lozanoffee3342019-08-27 12:03:00 -0700109 compiler compiler
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400110 coverage *coverage
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200111 clippy *clippy
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500112 sanitize *sanitize
Ivan Lozanoffee3342019-08-27 12:03:00 -0700113 cachedToolchain config.Toolchain
Ivan Lozano4fef93c2020-07-08 08:39:44 -0400114 sourceProvider SourceProvider
Andrei Homescuc7767922020-08-05 06:36:19 -0700115 subAndroidMkOnce map[SubAndroidMkProvider]bool
Ivan Lozano4fef93c2020-07-08 08:39:44 -0400116
Jiyong Parke54f07e2021-04-07 15:08:04 +0900117 // Unstripped output. This is usually used when this module is linked to another module
118 // as a library. The stripped output which is used for installation can be found via
119 // compiler.strippedOutputFile if it exists.
120 unstrippedOutputFile android.OptionalPath
Jiyong Park99644e92020-11-17 22:21:02 +0900121
122 hideApexVariantFromMake bool
Ivan Lozanoffee3342019-08-27 12:03:00 -0700123}
124
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500125func (mod *Module) Header() bool {
126 //TODO: If Rust libraries provide header variants, this needs to be updated.
127 return false
128}
129
130func (mod *Module) SetPreventInstall() {
131 mod.Properties.PreventInstall = true
132}
133
134// Returns true if the module is "vendor" variant. Usually these modules are installed in /vendor
135func (mod *Module) InVendor() bool {
136 return mod.Properties.ImageVariationPrefix == cc.VendorVariationPrefix
137}
138
139func (mod *Module) SetHideFromMake() {
140 mod.Properties.HideFromMake = true
141}
142
143func (mod *Module) SanitizePropDefined() bool {
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500144 // Because compiler is not set for some Rust modules where sanitize might be set, check that compiler is also not
145 // nil since we need compiler to actually sanitize.
146 return mod.sanitize != nil && mod.compiler != nil
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500147}
148
149func (mod *Module) IsDependencyRoot() bool {
150 if mod.compiler != nil {
151 return mod.compiler.isDependencyRoot()
152 }
153 panic("IsDependencyRoot called on a non-compiler Rust module")
154}
155
156func (mod *Module) IsPrebuilt() bool {
157 if _, ok := mod.compiler.(*prebuiltLibraryDecorator); ok {
158 return true
159 }
160 return false
161}
162
Ivan Lozano43845682020-07-09 21:03:28 -0400163func (mod *Module) OutputFiles(tag string) (android.Paths, error) {
164 switch tag {
165 case "":
Andrei Homescu5db69cc2020-08-06 15:27:45 -0700166 if mod.sourceProvider != nil && (mod.compiler == nil || mod.compiler.Disabled()) {
Ivan Lozano43845682020-07-09 21:03:28 -0400167 return mod.sourceProvider.Srcs(), nil
168 } else {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900169 if mod.OutputFile().Valid() {
170 return android.Paths{mod.OutputFile().Path()}, nil
Ivan Lozano43845682020-07-09 21:03:28 -0400171 }
172 return android.Paths{}, nil
173 }
174 default:
175 return nil, fmt.Errorf("unsupported module reference tag %q", tag)
176 }
177}
178
Ivan Lozano52767be2019-10-18 14:49:46 -0700179func (mod *Module) SelectedStl() string {
180 return ""
181}
182
Ivan Lozano2b262972019-11-21 12:30:50 -0800183func (mod *Module) NonCcVariants() bool {
184 if mod.compiler != nil {
Ivan Lozano89435d12020-07-31 11:01:18 -0400185 if _, ok := mod.compiler.(libraryInterface); ok {
186 return false
Ivan Lozano2b262972019-11-21 12:30:50 -0800187 }
188 }
189 panic(fmt.Errorf("NonCcVariants called on non-library module: %q", mod.BaseModuleName()))
190}
191
Ivan Lozano52767be2019-10-18 14:49:46 -0700192func (mod *Module) Static() bool {
193 if mod.compiler != nil {
194 if library, ok := mod.compiler.(libraryInterface); ok {
195 return library.static()
196 }
197 }
Ivan Lozano89435d12020-07-31 11:01:18 -0400198 return false
Ivan Lozano52767be2019-10-18 14:49:46 -0700199}
200
201func (mod *Module) Shared() bool {
202 if mod.compiler != nil {
203 if library, ok := mod.compiler.(libraryInterface); ok {
Ivan Lozano89435d12020-07-31 11:01:18 -0400204 return library.shared()
Ivan Lozano52767be2019-10-18 14:49:46 -0700205 }
206 }
Ivan Lozano89435d12020-07-31 11:01:18 -0400207 return false
Ivan Lozano52767be2019-10-18 14:49:46 -0700208}
209
210func (mod *Module) Toc() android.OptionalPath {
211 if mod.compiler != nil {
212 if _, ok := mod.compiler.(libraryInterface); ok {
213 return android.OptionalPath{}
214 }
215 }
216 panic(fmt.Errorf("Toc() called on non-library module: %q", mod.BaseModuleName()))
217}
218
Colin Crossc511bc52020-04-07 16:50:32 +0000219func (mod *Module) UseSdk() bool {
220 return false
221}
222
Ivan Lozano6a884432020-12-02 09:15:16 -0500223// Returns true if the module is using VNDK libraries instead of the libraries in /system/lib or /system/lib64.
224// "product" and "vendor" variant modules return true for this function.
225// When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true",
226// "soc_specific: true" and more vendor installed modules are included here.
227// When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "vendor_available: true" or
228// "product_specific: true" modules are included here.
Ivan Lozano52767be2019-10-18 14:49:46 -0700229func (mod *Module) UseVndk() bool {
Ivan Lozano6a884432020-12-02 09:15:16 -0500230 return mod.Properties.VndkVersion != ""
Ivan Lozano52767be2019-10-18 14:49:46 -0700231}
232
233func (mod *Module) MustUseVendorVariant() bool {
234 return false
235}
236
237func (mod *Module) IsVndk() bool {
Ivan Lozano6a884432020-12-02 09:15:16 -0500238 // TODO(b/165791368)
Ivan Lozano52767be2019-10-18 14:49:46 -0700239 return false
240}
241
Ivan Lozanof9e21722020-12-02 09:00:51 -0500242func (mod *Module) IsVndkExt() bool {
243 return false
244}
245
Colin Cross127bb8b2020-12-16 16:46:01 -0800246func (c *Module) IsVndkPrivate() bool {
247 return false
248}
249
250func (c *Module) IsLlndk() bool {
251 return false
252}
253
254func (c *Module) IsLlndkPublic() bool {
Ivan Lozanof9e21722020-12-02 09:00:51 -0500255 return false
256}
257
Ivan Lozano52767be2019-10-18 14:49:46 -0700258func (mod *Module) SdkVersion() string {
259 return ""
260}
261
Jiyong Parkfdaa5f72021-03-19 22:18:04 +0900262func (mod *Module) MinSdkVersion() string {
263 return ""
264}
265
Colin Crossc511bc52020-04-07 16:50:32 +0000266func (mod *Module) AlwaysSdk() bool {
267 return false
268}
269
Jiyong Park2286afd2020-06-16 21:58:53 +0900270func (mod *Module) IsSdkVariant() bool {
271 return false
272}
273
Colin Cross1348ce32020-10-01 13:37:16 -0700274func (mod *Module) SplitPerApiLevel() bool {
275 return false
276}
277
Ivan Lozanoffee3342019-08-27 12:03:00 -0700278type Deps struct {
Ivan Lozano63bb7682021-03-23 15:53:44 -0400279 Dylibs []string
280 Rlibs []string
281 Rustlibs []string
282 Stdlibs []string
283 ProcMacros []string
284 SharedLibs []string
285 StaticLibs []string
286 WholeStaticLibs []string
287 HeaderLibs []string
Ivan Lozanoffee3342019-08-27 12:03:00 -0700288
289 CrtBegin, CrtEnd string
290}
291
292type PathDeps struct {
Ivan Lozanoec6e9912021-01-21 15:23:29 -0500293 DyLibs RustLibraries
294 RLibs RustLibraries
295 SharedLibs android.Paths
296 SharedLibDeps android.Paths
297 StaticLibs android.Paths
298 ProcMacros RustLibraries
Ivan Lozano3dfa12d2021-02-04 11:29:41 -0500299
300 // depFlags and depLinkFlags are rustc and linker (clang) flags.
301 depFlags []string
302 depLinkFlags []string
303
304 // linkDirs are link paths passed via -L to rustc. linkObjects are objects passed directly to the linker.
305 // Both of these are exported and propagate to dependencies.
306 linkDirs []string
307 linkObjects []string
Ivan Lozanof1c84332019-09-20 11:00:37 -0700308
Ivan Lozano45901ed2020-07-24 16:05:01 -0400309 // Used by bindgen modules which call clang
310 depClangFlags []string
311 depIncludePaths android.Paths
Ivan Lozanoddd0bdb2020-08-28 17:00:26 -0400312 depGeneratedHeaders android.Paths
Ivan Lozano45901ed2020-07-24 16:05:01 -0400313 depSystemIncludePaths android.Paths
314
Ivan Lozanof1c84332019-09-20 11:00:37 -0700315 CrtBegin android.OptionalPath
316 CrtEnd android.OptionalPath
Chih-Hung Hsiehbbd25ae2020-05-15 17:36:30 -0700317
318 // Paths to generated source files
Ivan Lozano9d74a522020-12-01 09:25:22 -0500319 SrcDeps android.Paths
320 srcProviderFiles android.Paths
Ivan Lozanoffee3342019-08-27 12:03:00 -0700321}
322
323type RustLibraries []RustLibrary
324
325type RustLibrary struct {
326 Path android.Path
327 CrateName string
328}
329
330type compiler interface {
Thiébaud Weksteenee6a89b2021-02-25 16:30:57 +0100331 initialize(ctx ModuleContext)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700332 compilerFlags(ctx ModuleContext, flags Flags) Flags
333 compilerProps() []interface{}
334 compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path
335 compilerDeps(ctx DepsContext, deps Deps) Deps
336 crateName() string
337
Thiébaud Weksteenee6a89b2021-02-25 16:30:57 +0100338 // Output directory in which source-generated code from dependencies is
339 // copied. This is equivalent to Cargo's OUT_DIR variable.
340 CargoOutDir() android.OptionalPath
Chih-Hung Hsieh9a4a7ba2019-12-12 19:36:05 -0800341 inData() bool
Thiébaud Weksteenfabaff62020-08-27 13:48:36 +0200342 install(ctx ModuleContext)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700343 relativeInstallPath() string
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400344
345 nativeCoverage() bool
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400346
347 Disabled() bool
348 SetDisabled()
Ivan Lozano042504f2020-08-18 14:31:23 -0400349
Ivan Lozanodd055472020-09-28 13:22:45 -0400350 stdLinkage(ctx *depsContext) RustLinkage
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500351 isDependencyRoot() bool
Jiyong Parke54f07e2021-04-07 15:08:04 +0900352
353 strippedOutputFilePath() android.OptionalPath
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400354}
355
Matthew Maurerbb3add12020-06-25 09:34:12 -0700356type exportedFlagsProducer interface {
Matthew Maurerbb3add12020-06-25 09:34:12 -0700357 exportLinkDirs(...string)
Ivan Lozano2093af22020-08-25 12:48:19 -0400358 exportLinkObjects(...string)
Matthew Maurerbb3add12020-06-25 09:34:12 -0700359}
360
361type flagExporter struct {
Ivan Lozano2093af22020-08-25 12:48:19 -0400362 linkDirs []string
363 linkObjects []string
Matthew Maurerbb3add12020-06-25 09:34:12 -0700364}
365
Matthew Maurerbb3add12020-06-25 09:34:12 -0700366func (flagExporter *flagExporter) exportLinkDirs(dirs ...string) {
367 flagExporter.linkDirs = android.FirstUniqueStrings(append(flagExporter.linkDirs, dirs...))
368}
369
Ivan Lozano2093af22020-08-25 12:48:19 -0400370func (flagExporter *flagExporter) exportLinkObjects(flags ...string) {
371 flagExporter.linkObjects = android.FirstUniqueStrings(append(flagExporter.linkObjects, flags...))
372}
373
Colin Cross0de8a1e2020-09-18 14:15:30 -0700374func (flagExporter *flagExporter) setProvider(ctx ModuleContext) {
375 ctx.SetProvider(FlagExporterInfoProvider, FlagExporterInfo{
Colin Cross0de8a1e2020-09-18 14:15:30 -0700376 LinkDirs: flagExporter.linkDirs,
377 LinkObjects: flagExporter.linkObjects,
378 })
379}
380
Matthew Maurerbb3add12020-06-25 09:34:12 -0700381var _ exportedFlagsProducer = (*flagExporter)(nil)
382
383func NewFlagExporter() *flagExporter {
Colin Cross0de8a1e2020-09-18 14:15:30 -0700384 return &flagExporter{}
Matthew Maurerbb3add12020-06-25 09:34:12 -0700385}
386
Colin Cross0de8a1e2020-09-18 14:15:30 -0700387type FlagExporterInfo struct {
388 Flags []string
389 LinkDirs []string // TODO: this should be android.Paths
390 LinkObjects []string // TODO: this should be android.Paths
391}
392
393var FlagExporterInfoProvider = blueprint.NewProvider(FlagExporterInfo{})
394
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400395func (mod *Module) isCoverageVariant() bool {
396 return mod.coverage.Properties.IsCoverageVariant
397}
398
399var _ cc.Coverage = (*Module)(nil)
400
401func (mod *Module) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
402 return mod.coverage != nil && mod.coverage.Properties.NeedCoverageVariant
403}
404
405func (mod *Module) PreventInstall() {
406 mod.Properties.PreventInstall = true
407}
408
409func (mod *Module) HideFromMake() {
410 mod.Properties.HideFromMake = true
411}
412
413func (mod *Module) MarkAsCoverageVariant(coverage bool) {
414 mod.coverage.Properties.IsCoverageVariant = coverage
415}
416
417func (mod *Module) EnableCoverageIfNeeded() {
418 mod.coverage.Properties.CoverageEnabled = mod.coverage.Properties.NeedCoverageBuild
Ivan Lozanoffee3342019-08-27 12:03:00 -0700419}
420
421func defaultsFactory() android.Module {
422 return DefaultsFactory()
423}
424
425type Defaults struct {
426 android.ModuleBase
427 android.DefaultsModuleBase
428}
429
430func DefaultsFactory(props ...interface{}) android.Module {
431 module := &Defaults{}
432
433 module.AddProperties(props...)
434 module.AddProperties(
435 &BaseProperties{},
Ivan Lozano6a884432020-12-02 09:15:16 -0500436 &cc.VendorProperties{},
Ivan Lozanobc9e4212020-09-25 16:08:34 -0400437 &BindgenProperties{},
Ivan Lozanoffee3342019-08-27 12:03:00 -0700438 &BaseCompilerProperties{},
439 &BinaryCompilerProperties{},
440 &LibraryCompilerProperties{},
441 &ProcMacroCompilerProperties{},
442 &PrebuiltProperties{},
Ivan Lozano4fef93c2020-07-08 08:39:44 -0400443 &SourceProviderProperties{},
Chih-Hung Hsieh41805be2019-10-31 20:56:47 -0700444 &TestProperties{},
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400445 &cc.CoverageProperties{},
Ivan Lozanobc9e4212020-09-25 16:08:34 -0400446 &cc.RustBindgenClangProperties{},
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200447 &ClippyProperties{},
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500448 &SanitizeProperties{},
Ivan Lozanoffee3342019-08-27 12:03:00 -0700449 )
450
451 android.InitDefaultsModule(module)
452 return module
453}
454
455func (mod *Module) CrateName() string {
Ivan Lozanoad8b18b2019-10-31 19:38:29 -0700456 return mod.compiler.crateName()
Ivan Lozanoffee3342019-08-27 12:03:00 -0700457}
458
Ivan Lozano183a3212019-10-18 14:18:45 -0700459func (mod *Module) CcLibrary() bool {
460 if mod.compiler != nil {
461 if _, ok := mod.compiler.(*libraryDecorator); ok {
462 return true
463 }
464 }
465 return false
466}
467
468func (mod *Module) CcLibraryInterface() bool {
469 if mod.compiler != nil {
Ivan Lozano89435d12020-07-31 11:01:18 -0400470 // use build{Static,Shared}() instead of {static,shared}() here because this might be called before
471 // VariantIs{Static,Shared} is set.
472 if lib, ok := mod.compiler.(libraryInterface); ok && (lib.buildShared() || lib.buildStatic()) {
Ivan Lozano183a3212019-10-18 14:18:45 -0700473 return true
474 }
475 }
476 return false
477}
478
Ivan Lozanoe0833b12019-11-06 19:15:49 -0800479func (mod *Module) IncludeDirs() android.Paths {
Ivan Lozano183a3212019-10-18 14:18:45 -0700480 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700481 if library, ok := mod.compiler.(*libraryDecorator); ok {
Ivan Lozanoe0833b12019-11-06 19:15:49 -0800482 return library.includeDirs
Ivan Lozano183a3212019-10-18 14:18:45 -0700483 }
484 }
485 panic(fmt.Errorf("IncludeDirs called on non-library module: %q", mod.BaseModuleName()))
486}
487
488func (mod *Module) SetStatic() {
489 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700490 if library, ok := mod.compiler.(libraryInterface); ok {
491 library.setStatic()
Ivan Lozano183a3212019-10-18 14:18:45 -0700492 return
493 }
494 }
495 panic(fmt.Errorf("SetStatic called on non-library module: %q", mod.BaseModuleName()))
496}
497
498func (mod *Module) SetShared() {
499 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700500 if library, ok := mod.compiler.(libraryInterface); ok {
501 library.setShared()
Ivan Lozano183a3212019-10-18 14:18:45 -0700502 return
503 }
504 }
505 panic(fmt.Errorf("SetShared called on non-library module: %q", mod.BaseModuleName()))
506}
507
Ivan Lozano183a3212019-10-18 14:18:45 -0700508func (mod *Module) BuildStaticVariant() bool {
509 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700510 if library, ok := mod.compiler.(libraryInterface); ok {
511 return library.buildStatic()
Ivan Lozano183a3212019-10-18 14:18:45 -0700512 }
513 }
514 panic(fmt.Errorf("BuildStaticVariant called on non-library module: %q", mod.BaseModuleName()))
515}
516
517func (mod *Module) BuildSharedVariant() bool {
518 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700519 if library, ok := mod.compiler.(libraryInterface); ok {
520 return library.buildShared()
Ivan Lozano183a3212019-10-18 14:18:45 -0700521 }
522 }
523 panic(fmt.Errorf("BuildSharedVariant called on non-library module: %q", mod.BaseModuleName()))
524}
525
Ivan Lozano183a3212019-10-18 14:18:45 -0700526func (mod *Module) Module() android.Module {
527 return mod
528}
529
Ivan Lozano183a3212019-10-18 14:18:45 -0700530func (mod *Module) OutputFile() android.OptionalPath {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900531 if mod.compiler != nil && mod.compiler.strippedOutputFilePath().Valid() {
532 return mod.compiler.strippedOutputFilePath()
533 }
534 return mod.unstrippedOutputFile
Ivan Lozano183a3212019-10-18 14:18:45 -0700535}
536
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400537func (mod *Module) CoverageFiles() android.Paths {
538 if mod.compiler != nil {
Joel Galensonfa049382021-01-14 16:03:18 -0800539 return android.Paths{}
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400540 }
541 panic(fmt.Errorf("CoverageFiles called on non-library module: %q", mod.BaseModuleName()))
542}
543
Jiyong Park459feca2020-12-15 11:02:21 +0900544func (mod *Module) installable(apexInfo android.ApexInfo) bool {
545 // The apex variant is not installable because it is included in the APEX and won't appear
546 // in the system partition as a standalone file.
547 if !apexInfo.IsForPlatform() {
548 return false
549 }
550
Jiyong Parke54f07e2021-04-07 15:08:04 +0900551 return mod.OutputFile().Valid() && !mod.Properties.PreventInstall
Jiyong Park459feca2020-12-15 11:02:21 +0900552}
553
Ivan Lozano183a3212019-10-18 14:18:45 -0700554var _ cc.LinkableInterface = (*Module)(nil)
555
Ivan Lozanoffee3342019-08-27 12:03:00 -0700556func (mod *Module) Init() android.Module {
557 mod.AddProperties(&mod.Properties)
Ivan Lozano6a884432020-12-02 09:15:16 -0500558 mod.AddProperties(&mod.VendorProperties)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700559
560 if mod.compiler != nil {
561 mod.AddProperties(mod.compiler.compilerProps()...)
562 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400563 if mod.coverage != nil {
564 mod.AddProperties(mod.coverage.props()...)
565 }
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200566 if mod.clippy != nil {
567 mod.AddProperties(mod.clippy.props()...)
568 }
Ivan Lozano4fef93c2020-07-08 08:39:44 -0400569 if mod.sourceProvider != nil {
Andrei Homescuc7767922020-08-05 06:36:19 -0700570 mod.AddProperties(mod.sourceProvider.SourceProviderProps()...)
Ivan Lozano4fef93c2020-07-08 08:39:44 -0400571 }
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500572 if mod.sanitize != nil {
573 mod.AddProperties(mod.sanitize.props()...)
574 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400575
Ivan Lozanoffee3342019-08-27 12:03:00 -0700576 android.InitAndroidArchModule(mod, mod.hod, mod.multilib)
Jiyong Park99644e92020-11-17 22:21:02 +0900577 android.InitApexModule(mod)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700578
579 android.InitDefaultableModule(mod)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700580 return mod
581}
582
583func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
584 return &Module{
585 hod: hod,
586 multilib: multilib,
587 }
588}
589func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
590 module := newBaseModule(hod, multilib)
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400591 module.coverage = &coverage{}
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200592 module.clippy = &clippy{}
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500593 module.sanitize = &sanitize{}
Ivan Lozanoffee3342019-08-27 12:03:00 -0700594 return module
595}
596
597type ModuleContext interface {
598 android.ModuleContext
599 ModuleContextIntf
600}
601
602type BaseModuleContext interface {
603 android.BaseModuleContext
604 ModuleContextIntf
605}
606
607type DepsContext interface {
608 android.BottomUpMutatorContext
609 ModuleContextIntf
610}
611
612type ModuleContextIntf interface {
Thiébaud Weksteen1f7f70f2020-06-24 11:32:48 +0200613 RustModule() *Module
Ivan Lozanoffee3342019-08-27 12:03:00 -0700614 toolchain() config.Toolchain
Ivan Lozanoffee3342019-08-27 12:03:00 -0700615}
616
617type depsContext struct {
618 android.BottomUpMutatorContext
Ivan Lozanoffee3342019-08-27 12:03:00 -0700619}
620
621type moduleContext struct {
622 android.ModuleContext
Ivan Lozanoffee3342019-08-27 12:03:00 -0700623}
624
Thiébaud Weksteen1f7f70f2020-06-24 11:32:48 +0200625type baseModuleContext struct {
626 android.BaseModuleContext
627}
628
629func (ctx *moduleContext) RustModule() *Module {
630 return ctx.Module().(*Module)
631}
632
633func (ctx *moduleContext) toolchain() config.Toolchain {
634 return ctx.RustModule().toolchain(ctx)
635}
636
637func (ctx *depsContext) RustModule() *Module {
638 return ctx.Module().(*Module)
639}
640
641func (ctx *depsContext) toolchain() config.Toolchain {
642 return ctx.RustModule().toolchain(ctx)
643}
644
645func (ctx *baseModuleContext) RustModule() *Module {
646 return ctx.Module().(*Module)
647}
648
649func (ctx *baseModuleContext) toolchain() config.Toolchain {
650 return ctx.RustModule().toolchain(ctx)
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400651}
652
653func (mod *Module) nativeCoverage() bool {
654 return mod.compiler != nil && mod.compiler.nativeCoverage()
655}
656
Ivan Lozanoffee3342019-08-27 12:03:00 -0700657func (mod *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
658 if mod.cachedToolchain == nil {
659 mod.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
660 }
661 return mod.cachedToolchain
662}
663
Thiébaud Weksteen31f1bb82020-08-27 13:37:29 +0200664func (mod *Module) ccToolchain(ctx android.BaseModuleContext) cc_config.Toolchain {
665 return cc_config.FindToolchain(ctx.Os(), ctx.Arch())
666}
667
Ivan Lozanoffee3342019-08-27 12:03:00 -0700668func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
669}
670
671func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
672 ctx := &moduleContext{
673 ModuleContext: actx,
Ivan Lozanoffee3342019-08-27 12:03:00 -0700674 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700675
Jiyong Park99644e92020-11-17 22:21:02 +0900676 apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
677 if !apexInfo.IsForPlatform() {
678 mod.hideApexVariantFromMake = true
679 }
680
Ivan Lozanoffee3342019-08-27 12:03:00 -0700681 toolchain := mod.toolchain(ctx)
Ivan Lozano6a884432020-12-02 09:15:16 -0500682 mod.makeLinkType = cc.GetMakeLinkType(actx, mod)
683
684 // Differentiate static libraries that are vendor available
685 if mod.UseVndk() {
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500686 mod.Properties.SubName += cc.VendorSuffix
687 } else if mod.InVendorRamdisk() && !mod.OnlyInVendorRamdisk() {
688 mod.Properties.SubName += cc.VendorRamdiskSuffix
Ivan Lozano6a884432020-12-02 09:15:16 -0500689 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700690
691 if !toolchain.Supported() {
692 // This toolchain's unsupported, there's nothing to do for this mod.
693 return
694 }
695
696 deps := mod.depsToPaths(ctx)
697 flags := Flags{
698 Toolchain: toolchain,
699 }
700
701 if mod.compiler != nil {
702 flags = mod.compiler.compilerFlags(ctx, flags)
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400703 }
704 if mod.coverage != nil {
705 flags, deps = mod.coverage.flags(ctx, flags, deps)
706 }
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200707 if mod.clippy != nil {
708 flags, deps = mod.clippy.flags(ctx, flags, deps)
709 }
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500710 if mod.sanitize != nil {
711 flags, deps = mod.sanitize.flags(ctx, flags, deps)
712 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400713
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200714 // SourceProvider needs to call GenerateSource() before compiler calls
715 // compile() so it can provide the source. A SourceProvider has
716 // multiple variants (e.g. source, rlib, dylib). Only the "source"
717 // variant is responsible for effectively generating the source. The
718 // remaining variants relies on the "source" variant output.
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400719 if mod.sourceProvider != nil {
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200720 if mod.compiler.(libraryInterface).source() {
721 mod.sourceProvider.GenerateSource(ctx, deps)
722 mod.sourceProvider.setSubName(ctx.ModuleSubDir())
723 } else {
724 sourceMod := actx.GetDirectDepWithTag(mod.Name(), sourceDepTag)
725 sourceLib := sourceMod.(*Module).compiler.(*libraryDecorator)
Chih-Hung Hsiehc49649c2020-10-01 21:25:05 -0700726 mod.sourceProvider.setOutputFiles(sourceLib.sourceProvider.Srcs())
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200727 }
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400728 }
729
730 if mod.compiler != nil && !mod.compiler.Disabled() {
Thiébaud Weksteenee6a89b2021-02-25 16:30:57 +0100731 mod.compiler.initialize(ctx)
Jiyong Parke54f07e2021-04-07 15:08:04 +0900732 unstrippedOutputFile := mod.compiler.compile(ctx, flags, deps)
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400733
Jiyong Parke54f07e2021-04-07 15:08:04 +0900734 mod.unstrippedOutputFile = android.OptionalPathForPath(unstrippedOutputFile)
Jiyong Park459feca2020-12-15 11:02:21 +0900735
736 apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
737 if mod.installable(apexInfo) {
Thiébaud Weksteenfabaff62020-08-27 13:48:36 +0200738 mod.compiler.install(ctx)
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400739 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700740 }
741}
742
743func (mod *Module) deps(ctx DepsContext) Deps {
744 deps := Deps{}
745
746 if mod.compiler != nil {
747 deps = mod.compiler.compilerDeps(ctx, deps)
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400748 }
749 if mod.sourceProvider != nil {
Andrei Homescuc7767922020-08-05 06:36:19 -0700750 deps = mod.sourceProvider.SourceProviderDeps(ctx, deps)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700751 }
752
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400753 if mod.coverage != nil {
754 deps = mod.coverage.deps(ctx, deps)
755 }
756
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500757 if mod.sanitize != nil {
758 deps = mod.sanitize.deps(ctx, deps)
759 }
760
Ivan Lozanoffee3342019-08-27 12:03:00 -0700761 deps.Rlibs = android.LastUniqueStrings(deps.Rlibs)
762 deps.Dylibs = android.LastUniqueStrings(deps.Dylibs)
Matthew Maurer0f003b12020-06-29 14:34:06 -0700763 deps.Rustlibs = android.LastUniqueStrings(deps.Rustlibs)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700764 deps.ProcMacros = android.LastUniqueStrings(deps.ProcMacros)
765 deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
766 deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
Ivan Lozano63bb7682021-03-23 15:53:44 -0400767 deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700768 return deps
769
770}
771
Ivan Lozanoffee3342019-08-27 12:03:00 -0700772type dependencyTag struct {
773 blueprint.BaseDependencyTag
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800774 name string
775 library bool
776 procMacro bool
Ivan Lozanoffee3342019-08-27 12:03:00 -0700777}
778
Jiyong Park65b62242020-11-25 12:44:59 +0900779// InstallDepNeeded returns true for rlibs, dylibs, and proc macros so that they or their transitive
780// dependencies (especially C/C++ shared libs) are installed as dependencies of a rust binary.
781func (d dependencyTag) InstallDepNeeded() bool {
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800782 return d.library || d.procMacro
Jiyong Park65b62242020-11-25 12:44:59 +0900783}
784
785var _ android.InstallNeededDependencyTag = dependencyTag{}
786
Ivan Lozanoffee3342019-08-27 12:03:00 -0700787var (
Ivan Lozanoc564d2d2020-08-04 15:43:37 -0400788 customBindgenDepTag = dependencyTag{name: "customBindgenTag"}
789 rlibDepTag = dependencyTag{name: "rlibTag", library: true}
790 dylibDepTag = dependencyTag{name: "dylib", library: true}
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800791 procMacroDepTag = dependencyTag{name: "procMacro", procMacro: true}
Ivan Lozanoc564d2d2020-08-04 15:43:37 -0400792 testPerSrcDepTag = dependencyTag{name: "rust_unit_tests"}
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200793 sourceDepTag = dependencyTag{name: "source"}
Ivan Lozanoffee3342019-08-27 12:03:00 -0700794)
795
Jiyong Park99644e92020-11-17 22:21:02 +0900796func IsDylibDepTag(depTag blueprint.DependencyTag) bool {
797 tag, ok := depTag.(dependencyTag)
798 return ok && tag == dylibDepTag
799}
800
Jiyong Park94e22fd2021-04-08 18:19:15 +0900801func IsRlibDepTag(depTag blueprint.DependencyTag) bool {
802 tag, ok := depTag.(dependencyTag)
803 return ok && tag == rlibDepTag
804}
805
Matthew Maurer0f003b12020-06-29 14:34:06 -0700806type autoDep struct {
807 variation string
808 depTag dependencyTag
809}
810
811var (
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200812 rlibVariation = "rlib"
813 dylibVariation = "dylib"
814 rlibAutoDep = autoDep{variation: rlibVariation, depTag: rlibDepTag}
815 dylibAutoDep = autoDep{variation: dylibVariation, depTag: dylibDepTag}
Matthew Maurer0f003b12020-06-29 14:34:06 -0700816)
817
818type autoDeppable interface {
Liz Kammer356f7d42021-01-26 09:18:53 -0500819 autoDep(ctx android.BottomUpMutatorContext) autoDep
Matthew Maurer0f003b12020-06-29 14:34:06 -0700820}
821
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400822func (mod *Module) begin(ctx BaseModuleContext) {
823 if mod.coverage != nil {
824 mod.coverage.begin(ctx)
825 }
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500826 if mod.sanitize != nil {
827 mod.sanitize.begin(ctx)
828 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400829}
830
Ivan Lozanoffee3342019-08-27 12:03:00 -0700831func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
832 var depPaths PathDeps
833
834 directRlibDeps := []*Module{}
835 directDylibDeps := []*Module{}
836 directProcMacroDeps := []*Module{}
Ivan Lozano52767be2019-10-18 14:49:46 -0700837 directSharedLibDeps := [](cc.LinkableInterface){}
838 directStaticLibDeps := [](cc.LinkableInterface){}
Ivan Lozano07cbaf42020-07-22 16:09:13 -0400839 directSrcProvidersDeps := []*Module{}
840 directSrcDeps := [](android.SourceFileProducer){}
Ivan Lozanoffee3342019-08-27 12:03:00 -0700841
842 ctx.VisitDirectDeps(func(dep android.Module) {
843 depName := ctx.OtherModuleName(dep)
844 depTag := ctx.OtherModuleDependencyTag(dep)
Ivan Lozano89435d12020-07-31 11:01:18 -0400845 if rustDep, ok := dep.(*Module); ok && !rustDep.CcLibraryInterface() {
Ivan Lozanoffee3342019-08-27 12:03:00 -0700846 //Handle Rust Modules
Ivan Lozano70e0a072019-09-13 14:23:15 -0700847
Ivan Lozanoffee3342019-08-27 12:03:00 -0700848 switch depTag {
849 case dylibDepTag:
850 dylib, ok := rustDep.compiler.(libraryInterface)
851 if !ok || !dylib.dylib() {
852 ctx.ModuleErrorf("mod %q not an dylib library", depName)
853 return
854 }
855 directDylibDeps = append(directDylibDeps, rustDep)
856 mod.Properties.AndroidMkDylibs = append(mod.Properties.AndroidMkDylibs, depName)
857 case rlibDepTag:
Ivan Lozano2b081132020-09-08 12:46:52 -0400858
Ivan Lozanoffee3342019-08-27 12:03:00 -0700859 rlib, ok := rustDep.compiler.(libraryInterface)
860 if !ok || !rlib.rlib() {
Ivan Lozano2b081132020-09-08 12:46:52 -0400861 ctx.ModuleErrorf("mod %q not an rlib library", depName+rustDep.Properties.SubName)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700862 return
863 }
864 directRlibDeps = append(directRlibDeps, rustDep)
Ivan Lozano2b081132020-09-08 12:46:52 -0400865 mod.Properties.AndroidMkRlibs = append(mod.Properties.AndroidMkRlibs, depName+rustDep.Properties.SubName)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700866 case procMacroDepTag:
867 directProcMacroDeps = append(directProcMacroDeps, rustDep)
868 mod.Properties.AndroidMkProcMacroLibs = append(mod.Properties.AndroidMkProcMacroLibs, depName)
Ivan Lozano07cbaf42020-07-22 16:09:13 -0400869 case android.SourceDepTag:
870 // Since these deps are added in path_properties.go via AddDependencies, we need to ensure the correct
871 // OS/Arch variant is used.
872 var helper string
873 if ctx.Host() {
874 helper = "missing 'host_supported'?"
875 } else {
876 helper = "device module defined?"
877 }
878
879 if dep.Target().Os != ctx.Os() {
880 ctx.ModuleErrorf("OS mismatch on dependency %q (%s)", dep.Name(), helper)
881 return
882 } else if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
883 ctx.ModuleErrorf("Arch mismatch on dependency %q (%s)", dep.Name(), helper)
884 return
885 }
886 directSrcProvidersDeps = append(directSrcProvidersDeps, rustDep)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700887 }
888
Ivan Lozano2bbcacf2020-08-07 09:00:50 -0400889 //Append the dependencies exportedDirs, except for proc-macros which target a different arch/OS
Colin Cross0de8a1e2020-09-18 14:15:30 -0700890 if depTag != procMacroDepTag {
891 exportedInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
892 depPaths.linkDirs = append(depPaths.linkDirs, exportedInfo.LinkDirs...)
893 depPaths.depFlags = append(depPaths.depFlags, exportedInfo.Flags...)
894 depPaths.linkObjects = append(depPaths.linkObjects, exportedInfo.LinkObjects...)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700895 }
896
Ivan Lozanoffee3342019-08-27 12:03:00 -0700897 if depTag == dylibDepTag || depTag == rlibDepTag || depTag == procMacroDepTag {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900898 linkFile := rustDep.unstrippedOutputFile
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400899 if !linkFile.Valid() {
900 ctx.ModuleErrorf("Invalid output file when adding dep %q to %q",
901 depName, ctx.ModuleName())
902 return
903 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700904 linkDir := linkPathFromFilePath(linkFile.Path())
Matthew Maurerbb3add12020-06-25 09:34:12 -0700905 if lib, ok := mod.compiler.(exportedFlagsProducer); ok {
906 lib.exportLinkDirs(linkDir)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700907 }
908 }
909
Ivan Lozano89435d12020-07-31 11:01:18 -0400910 } else if ccDep, ok := dep.(cc.LinkableInterface); ok {
Ivan Lozano52767be2019-10-18 14:49:46 -0700911 //Handle C dependencies
912 if _, ok := ccDep.(*Module); !ok {
913 if ccDep.Module().Target().Os != ctx.Os() {
914 ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
915 return
916 }
917 if ccDep.Module().Target().Arch.ArchType != ctx.Arch().ArchType {
918 ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
919 return
920 }
Ivan Lozano70e0a072019-09-13 14:23:15 -0700921 }
Ivan Lozano2093af22020-08-25 12:48:19 -0400922 linkObject := ccDep.OutputFile()
923 linkPath := linkPathFromFilePath(linkObject.Path())
Ivan Lozano6aa66022020-02-06 13:22:43 -0500924
Ivan Lozano2093af22020-08-25 12:48:19 -0400925 if !linkObject.Valid() {
Ivan Lozanoffee3342019-08-27 12:03:00 -0700926 ctx.ModuleErrorf("Invalid output file when adding dep %q to %q", depName, ctx.ModuleName())
927 }
928
929 exportDep := false
Colin Cross6e511a92020-07-27 21:26:48 -0700930 switch {
931 case cc.IsStaticDepTag(depTag):
Ivan Lozano63bb7682021-03-23 15:53:44 -0400932 if cc.IsWholeStaticLib(depTag) {
933 // rustc will bundle static libraries when they're passed with "-lstatic=<lib>". This will fail
934 // if the library is not prefixed by "lib".
Ivan Lozanofb6f36f2021-02-05 12:27:08 -0500935 if libName, ok := libNameFromFilePath(linkObject.Path()); ok {
936 depPaths.depFlags = append(depPaths.depFlags, "-lstatic="+libName)
Ivan Lozano63bb7682021-03-23 15:53:44 -0400937 } else {
938 ctx.ModuleErrorf("'%q' cannot be listed as a whole_static_library in Rust modules unless the output is prefixed by 'lib'", depName, ctx.ModuleName())
Ivan Lozanofb6f36f2021-02-05 12:27:08 -0500939 }
Ivan Lozano3dfa12d2021-02-04 11:29:41 -0500940 }
941
942 // Add this to linkObjects to pass the library directly to the linker as well. This propagates
943 // to dependencies to avoid having to redeclare static libraries for dependents of the dylib variant.
Ivan Lozano2093af22020-08-25 12:48:19 -0400944 depPaths.linkObjects = append(depPaths.linkObjects, linkObject.String())
Ivan Lozano3dfa12d2021-02-04 11:29:41 -0500945 depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
946
Colin Cross0de8a1e2020-09-18 14:15:30 -0700947 exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
948 depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
949 depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
950 depPaths.depClangFlags = append(depPaths.depClangFlags, exportedInfo.Flags...)
951 depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700952 directStaticLibDeps = append(directStaticLibDeps, ccDep)
953 mod.Properties.AndroidMkStaticLibs = append(mod.Properties.AndroidMkStaticLibs, depName)
Colin Cross6e511a92020-07-27 21:26:48 -0700954 case cc.IsSharedDepTag(depTag):
Ivan Lozanoffee3342019-08-27 12:03:00 -0700955 depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
Ivan Lozano2093af22020-08-25 12:48:19 -0400956 depPaths.linkObjects = append(depPaths.linkObjects, linkObject.String())
Colin Cross0de8a1e2020-09-18 14:15:30 -0700957 exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
958 depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
959 depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
960 depPaths.depClangFlags = append(depPaths.depClangFlags, exportedInfo.Flags...)
961 depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700962 directSharedLibDeps = append(directSharedLibDeps, ccDep)
963 mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, depName)
964 exportDep = true
Zach Johnson3df4e632020-11-06 11:56:27 -0800965 case cc.IsHeaderDepTag(depTag):
966 exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
967 depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
968 depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
969 depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
Colin Cross6e511a92020-07-27 21:26:48 -0700970 case depTag == cc.CrtBeginDepTag:
Ivan Lozano2093af22020-08-25 12:48:19 -0400971 depPaths.CrtBegin = linkObject
Colin Cross6e511a92020-07-27 21:26:48 -0700972 case depTag == cc.CrtEndDepTag:
Ivan Lozano2093af22020-08-25 12:48:19 -0400973 depPaths.CrtEnd = linkObject
Ivan Lozanoffee3342019-08-27 12:03:00 -0700974 }
975
976 // Make sure these dependencies are propagated
Matthew Maurerbb3add12020-06-25 09:34:12 -0700977 if lib, ok := mod.compiler.(exportedFlagsProducer); ok && exportDep {
978 lib.exportLinkDirs(linkPath)
Ivan Lozano2093af22020-08-25 12:48:19 -0400979 lib.exportLinkObjects(linkObject.String())
Ivan Lozanoffee3342019-08-27 12:03:00 -0700980 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700981 }
Ivan Lozano89435d12020-07-31 11:01:18 -0400982
983 if srcDep, ok := dep.(android.SourceFileProducer); ok {
984 switch depTag {
985 case android.SourceDepTag:
986 // These are usually genrules which don't have per-target variants.
987 directSrcDeps = append(directSrcDeps, srcDep)
988 }
989 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700990 })
991
992 var rlibDepFiles RustLibraries
993 for _, dep := range directRlibDeps {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900994 rlibDepFiles = append(rlibDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
Ivan Lozanoffee3342019-08-27 12:03:00 -0700995 }
996 var dylibDepFiles RustLibraries
997 for _, dep := range directDylibDeps {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900998 dylibDepFiles = append(dylibDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
Ivan Lozanoffee3342019-08-27 12:03:00 -0700999 }
1000 var procMacroDepFiles RustLibraries
1001 for _, dep := range directProcMacroDeps {
Jiyong Parke54f07e2021-04-07 15:08:04 +09001002 procMacroDepFiles = append(procMacroDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
Ivan Lozanoffee3342019-08-27 12:03:00 -07001003 }
1004
1005 var staticLibDepFiles android.Paths
1006 for _, dep := range directStaticLibDeps {
1007 staticLibDepFiles = append(staticLibDepFiles, dep.OutputFile().Path())
1008 }
1009
Ivan Lozanoec6e9912021-01-21 15:23:29 -05001010 var sharedLibFiles android.Paths
Ivan Lozanoffee3342019-08-27 12:03:00 -07001011 var sharedLibDepFiles android.Paths
1012 for _, dep := range directSharedLibDeps {
Ivan Lozanoec6e9912021-01-21 15:23:29 -05001013 sharedLibFiles = append(sharedLibFiles, dep.OutputFile().Path())
1014 if dep.Toc().Valid() {
1015 sharedLibDepFiles = append(sharedLibDepFiles, dep.Toc().Path())
1016 } else {
1017 sharedLibDepFiles = append(sharedLibDepFiles, dep.OutputFile().Path())
1018 }
Ivan Lozanoffee3342019-08-27 12:03:00 -07001019 }
1020
Ivan Lozano07cbaf42020-07-22 16:09:13 -04001021 var srcProviderDepFiles android.Paths
1022 for _, dep := range directSrcProvidersDeps {
1023 srcs, _ := dep.OutputFiles("")
1024 srcProviderDepFiles = append(srcProviderDepFiles, srcs...)
1025 }
1026 for _, dep := range directSrcDeps {
1027 srcs := dep.Srcs()
1028 srcProviderDepFiles = append(srcProviderDepFiles, srcs...)
1029 }
1030
Ivan Lozanoffee3342019-08-27 12:03:00 -07001031 depPaths.RLibs = append(depPaths.RLibs, rlibDepFiles...)
1032 depPaths.DyLibs = append(depPaths.DyLibs, dylibDepFiles...)
1033 depPaths.SharedLibs = append(depPaths.SharedLibs, sharedLibDepFiles...)
Ivan Lozanoec6e9912021-01-21 15:23:29 -05001034 depPaths.SharedLibDeps = append(depPaths.SharedLibDeps, sharedLibDepFiles...)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001035 depPaths.StaticLibs = append(depPaths.StaticLibs, staticLibDepFiles...)
1036 depPaths.ProcMacros = append(depPaths.ProcMacros, procMacroDepFiles...)
Ivan Lozano07cbaf42020-07-22 16:09:13 -04001037 depPaths.SrcDeps = append(depPaths.SrcDeps, srcProviderDepFiles...)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001038
1039 // Dedup exported flags from dependencies
1040 depPaths.linkDirs = android.FirstUniqueStrings(depPaths.linkDirs)
Ivan Lozanoec6e9912021-01-21 15:23:29 -05001041 depPaths.linkObjects = android.FirstUniqueStrings(depPaths.linkObjects)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001042 depPaths.depFlags = android.FirstUniqueStrings(depPaths.depFlags)
Ivan Lozano45901ed2020-07-24 16:05:01 -04001043 depPaths.depClangFlags = android.FirstUniqueStrings(depPaths.depClangFlags)
1044 depPaths.depIncludePaths = android.FirstUniquePaths(depPaths.depIncludePaths)
1045 depPaths.depSystemIncludePaths = android.FirstUniquePaths(depPaths.depSystemIncludePaths)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001046
1047 return depPaths
1048}
1049
Chih-Hung Hsieh9a4a7ba2019-12-12 19:36:05 -08001050func (mod *Module) InstallInData() bool {
1051 if mod.compiler == nil {
1052 return false
1053 }
1054 return mod.compiler.inData()
1055}
1056
Ivan Lozanoffee3342019-08-27 12:03:00 -07001057func linkPathFromFilePath(filepath android.Path) string {
1058 return strings.Split(filepath.String(), filepath.Base())[0]
1059}
Ivan Lozanod648c432020-02-06 12:05:10 -05001060
Ivan Lozanoffee3342019-08-27 12:03:00 -07001061func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
1062 ctx := &depsContext{
1063 BottomUpMutatorContext: actx,
Ivan Lozanoffee3342019-08-27 12:03:00 -07001064 }
Ivan Lozanoffee3342019-08-27 12:03:00 -07001065
1066 deps := mod.deps(ctx)
Colin Cross3146c5c2020-09-30 15:34:40 -07001067 var commonDepVariations []blueprint.Variation
Ivan Lozanodd055472020-09-28 13:22:45 -04001068
Ivan Lozano2b081132020-09-08 12:46:52 -04001069 stdLinkage := "dylib-std"
Ivan Lozanodd055472020-09-28 13:22:45 -04001070 if mod.compiler.stdLinkage(ctx) == RlibLinkage {
Ivan Lozano2b081132020-09-08 12:46:52 -04001071 stdLinkage = "rlib-std"
1072 }
1073
1074 rlibDepVariations := commonDepVariations
1075 if lib, ok := mod.compiler.(libraryInterface); !ok || !lib.sysroot() {
1076 rlibDepVariations = append(rlibDepVariations,
1077 blueprint.Variation{Mutator: "rust_stdlinkage", Variation: stdLinkage})
1078 }
1079
Ivan Lozano52767be2019-10-18 14:49:46 -07001080 actx.AddVariationDependencies(
Ivan Lozano2b081132020-09-08 12:46:52 -04001081 append(rlibDepVariations, []blueprint.Variation{
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +02001082 {Mutator: "rust_libraries", Variation: rlibVariation}}...),
Ivan Lozano52767be2019-10-18 14:49:46 -07001083 rlibDepTag, deps.Rlibs...)
1084 actx.AddVariationDependencies(
1085 append(commonDepVariations, []blueprint.Variation{
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +02001086 {Mutator: "rust_libraries", Variation: dylibVariation}}...),
Ivan Lozano52767be2019-10-18 14:49:46 -07001087 dylibDepTag, deps.Dylibs...)
1088
Ivan Lozano042504f2020-08-18 14:31:23 -04001089 if deps.Rustlibs != nil && !mod.compiler.Disabled() {
1090 autoDep := mod.compiler.(autoDeppable).autoDep(ctx)
Ivan Lozano2b081132020-09-08 12:46:52 -04001091 if autoDep.depTag == rlibDepTag {
1092 actx.AddVariationDependencies(
1093 append(rlibDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: autoDep.variation}),
1094 autoDep.depTag, deps.Rustlibs...)
1095 } else {
1096 actx.AddVariationDependencies(
1097 append(commonDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: autoDep.variation}),
1098 autoDep.depTag, deps.Rustlibs...)
1099 }
Matthew Maurer0f003b12020-06-29 14:34:06 -07001100 }
Ivan Lozano2b081132020-09-08 12:46:52 -04001101 if deps.Stdlibs != nil {
Ivan Lozanodd055472020-09-28 13:22:45 -04001102 if mod.compiler.stdLinkage(ctx) == RlibLinkage {
Ivan Lozano2b081132020-09-08 12:46:52 -04001103 actx.AddVariationDependencies(
1104 append(commonDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: "rlib"}),
1105 rlibDepTag, deps.Stdlibs...)
1106 } else {
1107 actx.AddVariationDependencies(
1108 append(commonDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: "dylib"}),
1109 dylibDepTag, deps.Stdlibs...)
1110 }
1111 }
Ivan Lozano52767be2019-10-18 14:49:46 -07001112 actx.AddVariationDependencies(append(commonDepVariations,
1113 blueprint.Variation{Mutator: "link", Variation: "shared"}),
Colin Cross6e511a92020-07-27 21:26:48 -07001114 cc.SharedDepTag(), deps.SharedLibs...)
Ivan Lozano52767be2019-10-18 14:49:46 -07001115 actx.AddVariationDependencies(append(commonDepVariations,
1116 blueprint.Variation{Mutator: "link", Variation: "static"}),
Ivan Lozano63bb7682021-03-23 15:53:44 -04001117 cc.StaticDepTag(false), deps.StaticLibs...)
1118 actx.AddVariationDependencies(append(commonDepVariations,
1119 blueprint.Variation{Mutator: "link", Variation: "static"}),
1120 cc.StaticDepTag(true), deps.WholeStaticLibs...)
Ivan Lozano5ca5ef62019-09-23 10:10:40 -07001121
Zach Johnson3df4e632020-11-06 11:56:27 -08001122 actx.AddVariationDependencies(nil, cc.HeaderDepTag(), deps.HeaderLibs...)
1123
Colin Cross565cafd2020-09-25 18:47:38 -07001124 crtVariations := cc.GetCrtVariations(ctx, mod)
Ivan Lozanof1c84332019-09-20 11:00:37 -07001125 if deps.CrtBegin != "" {
Dan Albert92fe7402020-07-15 13:33:30 -07001126 actx.AddVariationDependencies(crtVariations, cc.CrtBeginDepTag, deps.CrtBegin)
Ivan Lozanof1c84332019-09-20 11:00:37 -07001127 }
1128 if deps.CrtEnd != "" {
Dan Albert92fe7402020-07-15 13:33:30 -07001129 actx.AddVariationDependencies(crtVariations, cc.CrtEndDepTag, deps.CrtEnd)
Ivan Lozanof1c84332019-09-20 11:00:37 -07001130 }
1131
Ivan Lozanoc564d2d2020-08-04 15:43:37 -04001132 if mod.sourceProvider != nil {
1133 if bindgen, ok := mod.sourceProvider.(*bindgenDecorator); ok &&
1134 bindgen.Properties.Custom_bindgen != "" {
1135 actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), customBindgenDepTag,
1136 bindgen.Properties.Custom_bindgen)
1137 }
1138 }
Ivan Lozano5ca5ef62019-09-23 10:10:40 -07001139 // proc_macros are compiler plugins, and so we need the host arch variant as a dependendcy.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001140 actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), procMacroDepTag, deps.ProcMacros...)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001141}
1142
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001143func BeginMutator(ctx android.BottomUpMutatorContext) {
1144 if mod, ok := ctx.Module().(*Module); ok && mod.Enabled() {
1145 mod.beginMutator(ctx)
1146 }
1147}
1148
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001149func (mod *Module) beginMutator(actx android.BottomUpMutatorContext) {
1150 ctx := &baseModuleContext{
1151 BaseModuleContext: actx,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001152 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001153
1154 mod.begin(ctx)
1155}
1156
Ivan Lozanoffee3342019-08-27 12:03:00 -07001157func (mod *Module) Name() string {
1158 name := mod.ModuleBase.Name()
1159 if p, ok := mod.compiler.(interface {
1160 Name(string) string
1161 }); ok {
1162 name = p.Name(name)
1163 }
1164 return name
1165}
1166
Thiébaud Weksteen9e8451e2020-08-13 12:55:59 +02001167func (mod *Module) disableClippy() {
Ivan Lozano32267c82020-08-04 16:27:16 -04001168 if mod.clippy != nil {
Thiébaud Weksteen9e8451e2020-08-13 12:55:59 +02001169 mod.clippy.Properties.Clippy_lints = proptools.StringPtr("none")
Ivan Lozano32267c82020-08-04 16:27:16 -04001170 }
1171}
1172
Chih-Hung Hsieh5c4e4892020-05-15 17:36:30 -07001173var _ android.HostToolProvider = (*Module)(nil)
1174
1175func (mod *Module) HostToolPath() android.OptionalPath {
1176 if !mod.Host() {
1177 return android.OptionalPath{}
1178 }
Chih-Hung Hsieha7562702020-08-10 21:50:43 -07001179 if binary, ok := mod.compiler.(*binaryDecorator); ok {
1180 return android.OptionalPathForPath(binary.baseCompiler.path)
Chih-Hung Hsieh5c4e4892020-05-15 17:36:30 -07001181 }
1182 return android.OptionalPath{}
1183}
1184
Jiyong Park99644e92020-11-17 22:21:02 +09001185var _ android.ApexModule = (*Module)(nil)
1186
Ivan Lozano3e9f9e42020-12-04 15:05:43 -05001187func (mod *Module) minSdkVersion() string {
1188 return String(mod.Properties.Min_sdk_version)
1189}
1190
Jiyong Park45bf82e2020-12-15 22:29:02 +09001191var _ android.ApexModule = (*Module)(nil)
1192
1193// Implements android.ApexModule
Jiyong Park99644e92020-11-17 22:21:02 +09001194func (mod *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
Ivan Lozano3e9f9e42020-12-04 15:05:43 -05001195 minSdkVersion := mod.minSdkVersion()
1196 if minSdkVersion == "apex_inherit" {
1197 return nil
1198 }
1199 if minSdkVersion == "" {
1200 return fmt.Errorf("min_sdk_version is not specificed")
1201 }
1202
1203 // Not using nativeApiLevelFromUser because the context here is not
1204 // necessarily a native context.
1205 ver, err := android.ApiLevelFromUser(ctx, minSdkVersion)
1206 if err != nil {
1207 return err
1208 }
1209
1210 if ver.GreaterThan(sdkVersion) {
1211 return fmt.Errorf("newer SDK(%v)", ver)
1212 }
Jiyong Park99644e92020-11-17 22:21:02 +09001213 return nil
1214}
1215
Jiyong Park45bf82e2020-12-15 22:29:02 +09001216// Implements android.ApexModule
Jiyong Park99644e92020-11-17 22:21:02 +09001217func (mod *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1218 depTag := ctx.OtherModuleDependencyTag(dep)
1219
1220 if ccm, ok := dep.(*cc.Module); ok {
1221 if ccm.HasStubsVariants() {
1222 if cc.IsSharedDepTag(depTag) {
1223 // dynamic dep to a stubs lib crosses APEX boundary
1224 return false
1225 }
1226 if cc.IsRuntimeDepTag(depTag) {
1227 // runtime dep to a stubs lib also crosses APEX boundary
1228 return false
1229 }
1230
1231 if cc.IsHeaderDepTag(depTag) {
1232 return false
1233 }
1234 }
1235 if mod.Static() && cc.IsSharedDepTag(depTag) {
1236 // shared_lib dependency from a static lib is considered as crossing
1237 // the APEX boundary because the dependency doesn't actually is
1238 // linked; the dependency is used only during the compilation phase.
1239 return false
1240 }
1241 }
1242
1243 if depTag == procMacroDepTag {
1244 return false
1245 }
1246
1247 return true
1248}
1249
1250// Overrides ApexModule.IsInstallabeToApex()
1251func (mod *Module) IsInstallableToApex() bool {
1252 if mod.compiler != nil {
1253 if lib, ok := mod.compiler.(*libraryDecorator); ok && (lib.shared() || lib.dylib()) {
1254 return true
1255 }
1256 if _, ok := mod.compiler.(*binaryDecorator); ok {
1257 return true
1258 }
1259 }
1260 return false
1261}
1262
Ivan Lozano3dfa12d2021-02-04 11:29:41 -05001263// If a library file has a "lib" prefix, extract the library name without the prefix.
1264func libNameFromFilePath(filepath android.Path) (string, bool) {
1265 libName := strings.TrimSuffix(filepath.Base(), filepath.Ext())
1266 if strings.HasPrefix(libName, "lib") {
1267 libName = libName[3:]
1268 return libName, true
1269 }
1270 return "", false
1271}
1272
Ivan Lozanoffee3342019-08-27 12:03:00 -07001273var Bool = proptools.Bool
1274var BoolDefault = proptools.BoolDefault
1275var String = proptools.String
1276var StringPtr = proptools.StringPtr
Ivan Lozano43845682020-07-09 21:03:28 -04001277
1278var _ android.OutputFileProducer = (*Module)(nil)