blob: ca85d74cc16b58b93628925d92932e450a406aca [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{},
Jakub Kotur1d640d02021-01-06 12:40:43 +0100437 &BenchmarkProperties{},
Ivan Lozanobc9e4212020-09-25 16:08:34 -0400438 &BindgenProperties{},
Ivan Lozanoffee3342019-08-27 12:03:00 -0700439 &BaseCompilerProperties{},
440 &BinaryCompilerProperties{},
441 &LibraryCompilerProperties{},
442 &ProcMacroCompilerProperties{},
443 &PrebuiltProperties{},
Ivan Lozano4fef93c2020-07-08 08:39:44 -0400444 &SourceProviderProperties{},
Chih-Hung Hsieh41805be2019-10-31 20:56:47 -0700445 &TestProperties{},
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400446 &cc.CoverageProperties{},
Ivan Lozanobc9e4212020-09-25 16:08:34 -0400447 &cc.RustBindgenClangProperties{},
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200448 &ClippyProperties{},
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500449 &SanitizeProperties{},
Ivan Lozanoffee3342019-08-27 12:03:00 -0700450 )
451
452 android.InitDefaultsModule(module)
453 return module
454}
455
456func (mod *Module) CrateName() string {
Ivan Lozanoad8b18b2019-10-31 19:38:29 -0700457 return mod.compiler.crateName()
Ivan Lozanoffee3342019-08-27 12:03:00 -0700458}
459
Ivan Lozano183a3212019-10-18 14:18:45 -0700460func (mod *Module) CcLibrary() bool {
461 if mod.compiler != nil {
462 if _, ok := mod.compiler.(*libraryDecorator); ok {
463 return true
464 }
465 }
466 return false
467}
468
469func (mod *Module) CcLibraryInterface() bool {
470 if mod.compiler != nil {
Ivan Lozano89435d12020-07-31 11:01:18 -0400471 // use build{Static,Shared}() instead of {static,shared}() here because this might be called before
472 // VariantIs{Static,Shared} is set.
473 if lib, ok := mod.compiler.(libraryInterface); ok && (lib.buildShared() || lib.buildStatic()) {
Ivan Lozano183a3212019-10-18 14:18:45 -0700474 return true
475 }
476 }
477 return false
478}
479
Ivan Lozanoe0833b12019-11-06 19:15:49 -0800480func (mod *Module) IncludeDirs() android.Paths {
Ivan Lozano183a3212019-10-18 14:18:45 -0700481 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700482 if library, ok := mod.compiler.(*libraryDecorator); ok {
Ivan Lozanoe0833b12019-11-06 19:15:49 -0800483 return library.includeDirs
Ivan Lozano183a3212019-10-18 14:18:45 -0700484 }
485 }
486 panic(fmt.Errorf("IncludeDirs called on non-library module: %q", mod.BaseModuleName()))
487}
488
489func (mod *Module) SetStatic() {
490 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700491 if library, ok := mod.compiler.(libraryInterface); ok {
492 library.setStatic()
Ivan Lozano183a3212019-10-18 14:18:45 -0700493 return
494 }
495 }
496 panic(fmt.Errorf("SetStatic called on non-library module: %q", mod.BaseModuleName()))
497}
498
499func (mod *Module) SetShared() {
500 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700501 if library, ok := mod.compiler.(libraryInterface); ok {
502 library.setShared()
Ivan Lozano183a3212019-10-18 14:18:45 -0700503 return
504 }
505 }
506 panic(fmt.Errorf("SetShared called on non-library module: %q", mod.BaseModuleName()))
507}
508
Ivan Lozano183a3212019-10-18 14:18:45 -0700509func (mod *Module) BuildStaticVariant() bool {
510 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700511 if library, ok := mod.compiler.(libraryInterface); ok {
512 return library.buildStatic()
Ivan Lozano183a3212019-10-18 14:18:45 -0700513 }
514 }
515 panic(fmt.Errorf("BuildStaticVariant called on non-library module: %q", mod.BaseModuleName()))
516}
517
518func (mod *Module) BuildSharedVariant() bool {
519 if mod.compiler != nil {
Ivan Lozano52767be2019-10-18 14:49:46 -0700520 if library, ok := mod.compiler.(libraryInterface); ok {
521 return library.buildShared()
Ivan Lozano183a3212019-10-18 14:18:45 -0700522 }
523 }
524 panic(fmt.Errorf("BuildSharedVariant called on non-library module: %q", mod.BaseModuleName()))
525}
526
Ivan Lozano183a3212019-10-18 14:18:45 -0700527func (mod *Module) Module() android.Module {
528 return mod
529}
530
Ivan Lozano183a3212019-10-18 14:18:45 -0700531func (mod *Module) OutputFile() android.OptionalPath {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900532 if mod.compiler != nil && mod.compiler.strippedOutputFilePath().Valid() {
533 return mod.compiler.strippedOutputFilePath()
534 }
535 return mod.unstrippedOutputFile
Ivan Lozano183a3212019-10-18 14:18:45 -0700536}
537
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400538func (mod *Module) CoverageFiles() android.Paths {
539 if mod.compiler != nil {
Joel Galensonfa049382021-01-14 16:03:18 -0800540 return android.Paths{}
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400541 }
542 panic(fmt.Errorf("CoverageFiles called on non-library module: %q", mod.BaseModuleName()))
543}
544
Jiyong Park459feca2020-12-15 11:02:21 +0900545func (mod *Module) installable(apexInfo android.ApexInfo) bool {
546 // The apex variant is not installable because it is included in the APEX and won't appear
547 // in the system partition as a standalone file.
548 if !apexInfo.IsForPlatform() {
549 return false
550 }
551
Jiyong Parke54f07e2021-04-07 15:08:04 +0900552 return mod.OutputFile().Valid() && !mod.Properties.PreventInstall
Jiyong Park459feca2020-12-15 11:02:21 +0900553}
554
Ivan Lozano183a3212019-10-18 14:18:45 -0700555var _ cc.LinkableInterface = (*Module)(nil)
556
Ivan Lozanoffee3342019-08-27 12:03:00 -0700557func (mod *Module) Init() android.Module {
558 mod.AddProperties(&mod.Properties)
Ivan Lozano6a884432020-12-02 09:15:16 -0500559 mod.AddProperties(&mod.VendorProperties)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700560
561 if mod.compiler != nil {
562 mod.AddProperties(mod.compiler.compilerProps()...)
563 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400564 if mod.coverage != nil {
565 mod.AddProperties(mod.coverage.props()...)
566 }
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200567 if mod.clippy != nil {
568 mod.AddProperties(mod.clippy.props()...)
569 }
Ivan Lozano4fef93c2020-07-08 08:39:44 -0400570 if mod.sourceProvider != nil {
Andrei Homescuc7767922020-08-05 06:36:19 -0700571 mod.AddProperties(mod.sourceProvider.SourceProviderProps()...)
Ivan Lozano4fef93c2020-07-08 08:39:44 -0400572 }
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500573 if mod.sanitize != nil {
574 mod.AddProperties(mod.sanitize.props()...)
575 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400576
Ivan Lozanoffee3342019-08-27 12:03:00 -0700577 android.InitAndroidArchModule(mod, mod.hod, mod.multilib)
Jiyong Park99644e92020-11-17 22:21:02 +0900578 android.InitApexModule(mod)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700579
580 android.InitDefaultableModule(mod)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700581 return mod
582}
583
584func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
585 return &Module{
586 hod: hod,
587 multilib: multilib,
588 }
589}
590func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
591 module := newBaseModule(hod, multilib)
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400592 module.coverage = &coverage{}
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200593 module.clippy = &clippy{}
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500594 module.sanitize = &sanitize{}
Ivan Lozanoffee3342019-08-27 12:03:00 -0700595 return module
596}
597
598type ModuleContext interface {
599 android.ModuleContext
600 ModuleContextIntf
601}
602
603type BaseModuleContext interface {
604 android.BaseModuleContext
605 ModuleContextIntf
606}
607
608type DepsContext interface {
609 android.BottomUpMutatorContext
610 ModuleContextIntf
611}
612
613type ModuleContextIntf interface {
Thiébaud Weksteen1f7f70f2020-06-24 11:32:48 +0200614 RustModule() *Module
Ivan Lozanoffee3342019-08-27 12:03:00 -0700615 toolchain() config.Toolchain
Ivan Lozanoffee3342019-08-27 12:03:00 -0700616}
617
618type depsContext struct {
619 android.BottomUpMutatorContext
Ivan Lozanoffee3342019-08-27 12:03:00 -0700620}
621
622type moduleContext struct {
623 android.ModuleContext
Ivan Lozanoffee3342019-08-27 12:03:00 -0700624}
625
Thiébaud Weksteen1f7f70f2020-06-24 11:32:48 +0200626type baseModuleContext struct {
627 android.BaseModuleContext
628}
629
630func (ctx *moduleContext) RustModule() *Module {
631 return ctx.Module().(*Module)
632}
633
634func (ctx *moduleContext) toolchain() config.Toolchain {
635 return ctx.RustModule().toolchain(ctx)
636}
637
638func (ctx *depsContext) RustModule() *Module {
639 return ctx.Module().(*Module)
640}
641
642func (ctx *depsContext) toolchain() config.Toolchain {
643 return ctx.RustModule().toolchain(ctx)
644}
645
646func (ctx *baseModuleContext) RustModule() *Module {
647 return ctx.Module().(*Module)
648}
649
650func (ctx *baseModuleContext) toolchain() config.Toolchain {
651 return ctx.RustModule().toolchain(ctx)
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400652}
653
654func (mod *Module) nativeCoverage() bool {
655 return mod.compiler != nil && mod.compiler.nativeCoverage()
656}
657
Ivan Lozanoffee3342019-08-27 12:03:00 -0700658func (mod *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
659 if mod.cachedToolchain == nil {
660 mod.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
661 }
662 return mod.cachedToolchain
663}
664
Thiébaud Weksteen31f1bb82020-08-27 13:37:29 +0200665func (mod *Module) ccToolchain(ctx android.BaseModuleContext) cc_config.Toolchain {
666 return cc_config.FindToolchain(ctx.Os(), ctx.Arch())
667}
668
Ivan Lozanoffee3342019-08-27 12:03:00 -0700669func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
670}
671
672func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
673 ctx := &moduleContext{
674 ModuleContext: actx,
Ivan Lozanoffee3342019-08-27 12:03:00 -0700675 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700676
Jiyong Park99644e92020-11-17 22:21:02 +0900677 apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
678 if !apexInfo.IsForPlatform() {
679 mod.hideApexVariantFromMake = true
680 }
681
Ivan Lozanoffee3342019-08-27 12:03:00 -0700682 toolchain := mod.toolchain(ctx)
Ivan Lozano6a884432020-12-02 09:15:16 -0500683 mod.makeLinkType = cc.GetMakeLinkType(actx, mod)
684
685 // Differentiate static libraries that are vendor available
686 if mod.UseVndk() {
Ivan Lozanoe6d30982021-02-05 10:57:43 -0500687 mod.Properties.SubName += cc.VendorSuffix
688 } else if mod.InVendorRamdisk() && !mod.OnlyInVendorRamdisk() {
689 mod.Properties.SubName += cc.VendorRamdiskSuffix
Ivan Lozano6a884432020-12-02 09:15:16 -0500690 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700691
692 if !toolchain.Supported() {
693 // This toolchain's unsupported, there's nothing to do for this mod.
694 return
695 }
696
697 deps := mod.depsToPaths(ctx)
698 flags := Flags{
699 Toolchain: toolchain,
700 }
701
702 if mod.compiler != nil {
703 flags = mod.compiler.compilerFlags(ctx, flags)
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400704 }
705 if mod.coverage != nil {
706 flags, deps = mod.coverage.flags(ctx, flags, deps)
707 }
Thiébaud Weksteen92f703b2020-06-22 13:28:02 +0200708 if mod.clippy != nil {
709 flags, deps = mod.clippy.flags(ctx, flags, deps)
710 }
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500711 if mod.sanitize != nil {
712 flags, deps = mod.sanitize.flags(ctx, flags, deps)
713 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400714
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200715 // SourceProvider needs to call GenerateSource() before compiler calls
716 // compile() so it can provide the source. A SourceProvider has
717 // multiple variants (e.g. source, rlib, dylib). Only the "source"
718 // variant is responsible for effectively generating the source. The
719 // remaining variants relies on the "source" variant output.
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400720 if mod.sourceProvider != nil {
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200721 if mod.compiler.(libraryInterface).source() {
722 mod.sourceProvider.GenerateSource(ctx, deps)
723 mod.sourceProvider.setSubName(ctx.ModuleSubDir())
724 } else {
725 sourceMod := actx.GetDirectDepWithTag(mod.Name(), sourceDepTag)
726 sourceLib := sourceMod.(*Module).compiler.(*libraryDecorator)
Chih-Hung Hsiehc49649c2020-10-01 21:25:05 -0700727 mod.sourceProvider.setOutputFiles(sourceLib.sourceProvider.Srcs())
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200728 }
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400729 }
730
731 if mod.compiler != nil && !mod.compiler.Disabled() {
Thiébaud Weksteenee6a89b2021-02-25 16:30:57 +0100732 mod.compiler.initialize(ctx)
Jiyong Parke54f07e2021-04-07 15:08:04 +0900733 unstrippedOutputFile := mod.compiler.compile(ctx, flags, deps)
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400734
Jiyong Parke54f07e2021-04-07 15:08:04 +0900735 mod.unstrippedOutputFile = android.OptionalPathForPath(unstrippedOutputFile)
Jiyong Park459feca2020-12-15 11:02:21 +0900736
737 apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
738 if mod.installable(apexInfo) {
Thiébaud Weksteenfabaff62020-08-27 13:48:36 +0200739 mod.compiler.install(ctx)
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400740 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700741 }
742}
743
744func (mod *Module) deps(ctx DepsContext) Deps {
745 deps := Deps{}
746
747 if mod.compiler != nil {
748 deps = mod.compiler.compilerDeps(ctx, deps)
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400749 }
750 if mod.sourceProvider != nil {
Andrei Homescuc7767922020-08-05 06:36:19 -0700751 deps = mod.sourceProvider.SourceProviderDeps(ctx, deps)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700752 }
753
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400754 if mod.coverage != nil {
755 deps = mod.coverage.deps(ctx, deps)
756 }
757
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500758 if mod.sanitize != nil {
759 deps = mod.sanitize.deps(ctx, deps)
760 }
761
Ivan Lozanoffee3342019-08-27 12:03:00 -0700762 deps.Rlibs = android.LastUniqueStrings(deps.Rlibs)
763 deps.Dylibs = android.LastUniqueStrings(deps.Dylibs)
Matthew Maurer0f003b12020-06-29 14:34:06 -0700764 deps.Rustlibs = android.LastUniqueStrings(deps.Rustlibs)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700765 deps.ProcMacros = android.LastUniqueStrings(deps.ProcMacros)
766 deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
767 deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
Ivan Lozano63bb7682021-03-23 15:53:44 -0400768 deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700769 return deps
770
771}
772
Ivan Lozanoffee3342019-08-27 12:03:00 -0700773type dependencyTag struct {
774 blueprint.BaseDependencyTag
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800775 name string
776 library bool
777 procMacro bool
Ivan Lozanoffee3342019-08-27 12:03:00 -0700778}
779
Jiyong Park65b62242020-11-25 12:44:59 +0900780// InstallDepNeeded returns true for rlibs, dylibs, and proc macros so that they or their transitive
781// dependencies (especially C/C++ shared libs) are installed as dependencies of a rust binary.
782func (d dependencyTag) InstallDepNeeded() bool {
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800783 return d.library || d.procMacro
Jiyong Park65b62242020-11-25 12:44:59 +0900784}
785
786var _ android.InstallNeededDependencyTag = dependencyTag{}
787
Ivan Lozanoffee3342019-08-27 12:03:00 -0700788var (
Ivan Lozanoc564d2d2020-08-04 15:43:37 -0400789 customBindgenDepTag = dependencyTag{name: "customBindgenTag"}
790 rlibDepTag = dependencyTag{name: "rlibTag", library: true}
791 dylibDepTag = dependencyTag{name: "dylib", library: true}
Jaewoong Jung18aefc12020-12-21 09:11:10 -0800792 procMacroDepTag = dependencyTag{name: "procMacro", procMacro: true}
Ivan Lozanoc564d2d2020-08-04 15:43:37 -0400793 testPerSrcDepTag = dependencyTag{name: "rust_unit_tests"}
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200794 sourceDepTag = dependencyTag{name: "source"}
Ivan Lozanoffee3342019-08-27 12:03:00 -0700795)
796
Jiyong Park99644e92020-11-17 22:21:02 +0900797func IsDylibDepTag(depTag blueprint.DependencyTag) bool {
798 tag, ok := depTag.(dependencyTag)
799 return ok && tag == dylibDepTag
800}
801
Jiyong Park94e22fd2021-04-08 18:19:15 +0900802func IsRlibDepTag(depTag blueprint.DependencyTag) bool {
803 tag, ok := depTag.(dependencyTag)
804 return ok && tag == rlibDepTag
805}
806
Matthew Maurer0f003b12020-06-29 14:34:06 -0700807type autoDep struct {
808 variation string
809 depTag dependencyTag
810}
811
812var (
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +0200813 rlibVariation = "rlib"
814 dylibVariation = "dylib"
815 rlibAutoDep = autoDep{variation: rlibVariation, depTag: rlibDepTag}
816 dylibAutoDep = autoDep{variation: dylibVariation, depTag: dylibDepTag}
Matthew Maurer0f003b12020-06-29 14:34:06 -0700817)
818
819type autoDeppable interface {
Liz Kammer356f7d42021-01-26 09:18:53 -0500820 autoDep(ctx android.BottomUpMutatorContext) autoDep
Matthew Maurer0f003b12020-06-29 14:34:06 -0700821}
822
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400823func (mod *Module) begin(ctx BaseModuleContext) {
824 if mod.coverage != nil {
825 mod.coverage.begin(ctx)
826 }
Ivan Lozano6cd99e62020-02-11 08:24:25 -0500827 if mod.sanitize != nil {
828 mod.sanitize.begin(ctx)
829 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400830}
831
Ivan Lozanoffee3342019-08-27 12:03:00 -0700832func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
833 var depPaths PathDeps
834
835 directRlibDeps := []*Module{}
836 directDylibDeps := []*Module{}
837 directProcMacroDeps := []*Module{}
Ivan Lozano52767be2019-10-18 14:49:46 -0700838 directSharedLibDeps := [](cc.LinkableInterface){}
839 directStaticLibDeps := [](cc.LinkableInterface){}
Ivan Lozano07cbaf42020-07-22 16:09:13 -0400840 directSrcProvidersDeps := []*Module{}
841 directSrcDeps := [](android.SourceFileProducer){}
Ivan Lozanoffee3342019-08-27 12:03:00 -0700842
843 ctx.VisitDirectDeps(func(dep android.Module) {
844 depName := ctx.OtherModuleName(dep)
845 depTag := ctx.OtherModuleDependencyTag(dep)
Ivan Lozano89435d12020-07-31 11:01:18 -0400846 if rustDep, ok := dep.(*Module); ok && !rustDep.CcLibraryInterface() {
Ivan Lozanoffee3342019-08-27 12:03:00 -0700847 //Handle Rust Modules
Ivan Lozano70e0a072019-09-13 14:23:15 -0700848
Ivan Lozanoffee3342019-08-27 12:03:00 -0700849 switch depTag {
850 case dylibDepTag:
851 dylib, ok := rustDep.compiler.(libraryInterface)
852 if !ok || !dylib.dylib() {
853 ctx.ModuleErrorf("mod %q not an dylib library", depName)
854 return
855 }
856 directDylibDeps = append(directDylibDeps, rustDep)
857 mod.Properties.AndroidMkDylibs = append(mod.Properties.AndroidMkDylibs, depName)
858 case rlibDepTag:
Ivan Lozano2b081132020-09-08 12:46:52 -0400859
Ivan Lozanoffee3342019-08-27 12:03:00 -0700860 rlib, ok := rustDep.compiler.(libraryInterface)
861 if !ok || !rlib.rlib() {
Ivan Lozano2b081132020-09-08 12:46:52 -0400862 ctx.ModuleErrorf("mod %q not an rlib library", depName+rustDep.Properties.SubName)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700863 return
864 }
865 directRlibDeps = append(directRlibDeps, rustDep)
Ivan Lozano2b081132020-09-08 12:46:52 -0400866 mod.Properties.AndroidMkRlibs = append(mod.Properties.AndroidMkRlibs, depName+rustDep.Properties.SubName)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700867 case procMacroDepTag:
868 directProcMacroDeps = append(directProcMacroDeps, rustDep)
869 mod.Properties.AndroidMkProcMacroLibs = append(mod.Properties.AndroidMkProcMacroLibs, depName)
Ivan Lozano07cbaf42020-07-22 16:09:13 -0400870 case android.SourceDepTag:
871 // Since these deps are added in path_properties.go via AddDependencies, we need to ensure the correct
872 // OS/Arch variant is used.
873 var helper string
874 if ctx.Host() {
875 helper = "missing 'host_supported'?"
876 } else {
877 helper = "device module defined?"
878 }
879
880 if dep.Target().Os != ctx.Os() {
881 ctx.ModuleErrorf("OS mismatch on dependency %q (%s)", dep.Name(), helper)
882 return
883 } else if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
884 ctx.ModuleErrorf("Arch mismatch on dependency %q (%s)", dep.Name(), helper)
885 return
886 }
887 directSrcProvidersDeps = append(directSrcProvidersDeps, rustDep)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700888 }
889
Ivan Lozano2bbcacf2020-08-07 09:00:50 -0400890 //Append the dependencies exportedDirs, except for proc-macros which target a different arch/OS
Colin Cross0de8a1e2020-09-18 14:15:30 -0700891 if depTag != procMacroDepTag {
892 exportedInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo)
893 depPaths.linkDirs = append(depPaths.linkDirs, exportedInfo.LinkDirs...)
894 depPaths.depFlags = append(depPaths.depFlags, exportedInfo.Flags...)
895 depPaths.linkObjects = append(depPaths.linkObjects, exportedInfo.LinkObjects...)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700896 }
897
Ivan Lozanoffee3342019-08-27 12:03:00 -0700898 if depTag == dylibDepTag || depTag == rlibDepTag || depTag == procMacroDepTag {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900899 linkFile := rustDep.unstrippedOutputFile
Ivan Lozano26ecd6c2020-07-31 13:40:31 -0400900 if !linkFile.Valid() {
901 ctx.ModuleErrorf("Invalid output file when adding dep %q to %q",
902 depName, ctx.ModuleName())
903 return
904 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700905 linkDir := linkPathFromFilePath(linkFile.Path())
Matthew Maurerbb3add12020-06-25 09:34:12 -0700906 if lib, ok := mod.compiler.(exportedFlagsProducer); ok {
907 lib.exportLinkDirs(linkDir)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700908 }
909 }
910
Ivan Lozano89435d12020-07-31 11:01:18 -0400911 } else if ccDep, ok := dep.(cc.LinkableInterface); ok {
Ivan Lozano52767be2019-10-18 14:49:46 -0700912 //Handle C dependencies
913 if _, ok := ccDep.(*Module); !ok {
914 if ccDep.Module().Target().Os != ctx.Os() {
915 ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
916 return
917 }
918 if ccDep.Module().Target().Arch.ArchType != ctx.Arch().ArchType {
919 ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
920 return
921 }
Ivan Lozano70e0a072019-09-13 14:23:15 -0700922 }
Ivan Lozano2093af22020-08-25 12:48:19 -0400923 linkObject := ccDep.OutputFile()
924 linkPath := linkPathFromFilePath(linkObject.Path())
Ivan Lozano6aa66022020-02-06 13:22:43 -0500925
Ivan Lozano2093af22020-08-25 12:48:19 -0400926 if !linkObject.Valid() {
Ivan Lozanoffee3342019-08-27 12:03:00 -0700927 ctx.ModuleErrorf("Invalid output file when adding dep %q to %q", depName, ctx.ModuleName())
928 }
929
930 exportDep := false
Colin Cross6e511a92020-07-27 21:26:48 -0700931 switch {
932 case cc.IsStaticDepTag(depTag):
Ivan Lozano63bb7682021-03-23 15:53:44 -0400933 if cc.IsWholeStaticLib(depTag) {
934 // rustc will bundle static libraries when they're passed with "-lstatic=<lib>". This will fail
935 // if the library is not prefixed by "lib".
Ivan Lozanofb6f36f2021-02-05 12:27:08 -0500936 if libName, ok := libNameFromFilePath(linkObject.Path()); ok {
937 depPaths.depFlags = append(depPaths.depFlags, "-lstatic="+libName)
Ivan Lozano63bb7682021-03-23 15:53:44 -0400938 } else {
939 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 -0500940 }
Ivan Lozano3dfa12d2021-02-04 11:29:41 -0500941 }
942
943 // Add this to linkObjects to pass the library directly to the linker as well. This propagates
944 // to dependencies to avoid having to redeclare static libraries for dependents of the dylib variant.
Ivan Lozano2093af22020-08-25 12:48:19 -0400945 depPaths.linkObjects = append(depPaths.linkObjects, linkObject.String())
Ivan Lozano3dfa12d2021-02-04 11:29:41 -0500946 depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
947
Colin Cross0de8a1e2020-09-18 14:15:30 -0700948 exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
949 depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
950 depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
951 depPaths.depClangFlags = append(depPaths.depClangFlags, exportedInfo.Flags...)
952 depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700953 directStaticLibDeps = append(directStaticLibDeps, ccDep)
954 mod.Properties.AndroidMkStaticLibs = append(mod.Properties.AndroidMkStaticLibs, depName)
Colin Cross6e511a92020-07-27 21:26:48 -0700955 case cc.IsSharedDepTag(depTag):
Ivan Lozanoffee3342019-08-27 12:03:00 -0700956 depPaths.linkDirs = append(depPaths.linkDirs, linkPath)
Ivan Lozano2093af22020-08-25 12:48:19 -0400957 depPaths.linkObjects = append(depPaths.linkObjects, linkObject.String())
Colin Cross0de8a1e2020-09-18 14:15:30 -0700958 exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
959 depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
960 depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
961 depPaths.depClangFlags = append(depPaths.depClangFlags, exportedInfo.Flags...)
962 depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
Ivan Lozanoffee3342019-08-27 12:03:00 -0700963 directSharedLibDeps = append(directSharedLibDeps, ccDep)
964 mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, depName)
965 exportDep = true
Zach Johnson3df4e632020-11-06 11:56:27 -0800966 case cc.IsHeaderDepTag(depTag):
967 exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo)
968 depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...)
969 depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...)
970 depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...)
Colin Cross6e511a92020-07-27 21:26:48 -0700971 case depTag == cc.CrtBeginDepTag:
Ivan Lozano2093af22020-08-25 12:48:19 -0400972 depPaths.CrtBegin = linkObject
Colin Cross6e511a92020-07-27 21:26:48 -0700973 case depTag == cc.CrtEndDepTag:
Ivan Lozano2093af22020-08-25 12:48:19 -0400974 depPaths.CrtEnd = linkObject
Ivan Lozanoffee3342019-08-27 12:03:00 -0700975 }
976
977 // Make sure these dependencies are propagated
Matthew Maurerbb3add12020-06-25 09:34:12 -0700978 if lib, ok := mod.compiler.(exportedFlagsProducer); ok && exportDep {
979 lib.exportLinkDirs(linkPath)
Ivan Lozano2093af22020-08-25 12:48:19 -0400980 lib.exportLinkObjects(linkObject.String())
Ivan Lozanoffee3342019-08-27 12:03:00 -0700981 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700982 }
Ivan Lozano89435d12020-07-31 11:01:18 -0400983
984 if srcDep, ok := dep.(android.SourceFileProducer); ok {
985 switch depTag {
986 case android.SourceDepTag:
987 // These are usually genrules which don't have per-target variants.
988 directSrcDeps = append(directSrcDeps, srcDep)
989 }
990 }
Ivan Lozanoffee3342019-08-27 12:03:00 -0700991 })
992
993 var rlibDepFiles RustLibraries
994 for _, dep := range directRlibDeps {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900995 rlibDepFiles = append(rlibDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
Ivan Lozanoffee3342019-08-27 12:03:00 -0700996 }
997 var dylibDepFiles RustLibraries
998 for _, dep := range directDylibDeps {
Jiyong Parke54f07e2021-04-07 15:08:04 +0900999 dylibDepFiles = append(dylibDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
Ivan Lozanoffee3342019-08-27 12:03:00 -07001000 }
1001 var procMacroDepFiles RustLibraries
1002 for _, dep := range directProcMacroDeps {
Jiyong Parke54f07e2021-04-07 15:08:04 +09001003 procMacroDepFiles = append(procMacroDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
Ivan Lozanoffee3342019-08-27 12:03:00 -07001004 }
1005
1006 var staticLibDepFiles android.Paths
1007 for _, dep := range directStaticLibDeps {
1008 staticLibDepFiles = append(staticLibDepFiles, dep.OutputFile().Path())
1009 }
1010
Ivan Lozanoec6e9912021-01-21 15:23:29 -05001011 var sharedLibFiles android.Paths
Ivan Lozanoffee3342019-08-27 12:03:00 -07001012 var sharedLibDepFiles android.Paths
1013 for _, dep := range directSharedLibDeps {
Ivan Lozanoec6e9912021-01-21 15:23:29 -05001014 sharedLibFiles = append(sharedLibFiles, dep.OutputFile().Path())
1015 if dep.Toc().Valid() {
1016 sharedLibDepFiles = append(sharedLibDepFiles, dep.Toc().Path())
1017 } else {
1018 sharedLibDepFiles = append(sharedLibDepFiles, dep.OutputFile().Path())
1019 }
Ivan Lozanoffee3342019-08-27 12:03:00 -07001020 }
1021
Ivan Lozano07cbaf42020-07-22 16:09:13 -04001022 var srcProviderDepFiles android.Paths
1023 for _, dep := range directSrcProvidersDeps {
1024 srcs, _ := dep.OutputFiles("")
1025 srcProviderDepFiles = append(srcProviderDepFiles, srcs...)
1026 }
1027 for _, dep := range directSrcDeps {
1028 srcs := dep.Srcs()
1029 srcProviderDepFiles = append(srcProviderDepFiles, srcs...)
1030 }
1031
Ivan Lozanoffee3342019-08-27 12:03:00 -07001032 depPaths.RLibs = append(depPaths.RLibs, rlibDepFiles...)
1033 depPaths.DyLibs = append(depPaths.DyLibs, dylibDepFiles...)
1034 depPaths.SharedLibs = append(depPaths.SharedLibs, sharedLibDepFiles...)
Ivan Lozanoec6e9912021-01-21 15:23:29 -05001035 depPaths.SharedLibDeps = append(depPaths.SharedLibDeps, sharedLibDepFiles...)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001036 depPaths.StaticLibs = append(depPaths.StaticLibs, staticLibDepFiles...)
1037 depPaths.ProcMacros = append(depPaths.ProcMacros, procMacroDepFiles...)
Ivan Lozano07cbaf42020-07-22 16:09:13 -04001038 depPaths.SrcDeps = append(depPaths.SrcDeps, srcProviderDepFiles...)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001039
1040 // Dedup exported flags from dependencies
1041 depPaths.linkDirs = android.FirstUniqueStrings(depPaths.linkDirs)
Ivan Lozanoec6e9912021-01-21 15:23:29 -05001042 depPaths.linkObjects = android.FirstUniqueStrings(depPaths.linkObjects)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001043 depPaths.depFlags = android.FirstUniqueStrings(depPaths.depFlags)
Ivan Lozano45901ed2020-07-24 16:05:01 -04001044 depPaths.depClangFlags = android.FirstUniqueStrings(depPaths.depClangFlags)
1045 depPaths.depIncludePaths = android.FirstUniquePaths(depPaths.depIncludePaths)
1046 depPaths.depSystemIncludePaths = android.FirstUniquePaths(depPaths.depSystemIncludePaths)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001047
1048 return depPaths
1049}
1050
Chih-Hung Hsieh9a4a7ba2019-12-12 19:36:05 -08001051func (mod *Module) InstallInData() bool {
1052 if mod.compiler == nil {
1053 return false
1054 }
1055 return mod.compiler.inData()
1056}
1057
Ivan Lozanoffee3342019-08-27 12:03:00 -07001058func linkPathFromFilePath(filepath android.Path) string {
1059 return strings.Split(filepath.String(), filepath.Base())[0]
1060}
Ivan Lozanod648c432020-02-06 12:05:10 -05001061
Ivan Lozanoffee3342019-08-27 12:03:00 -07001062func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
1063 ctx := &depsContext{
1064 BottomUpMutatorContext: actx,
Ivan Lozanoffee3342019-08-27 12:03:00 -07001065 }
Ivan Lozanoffee3342019-08-27 12:03:00 -07001066
1067 deps := mod.deps(ctx)
Colin Cross3146c5c2020-09-30 15:34:40 -07001068 var commonDepVariations []blueprint.Variation
Ivan Lozanodd055472020-09-28 13:22:45 -04001069
Ivan Lozano2b081132020-09-08 12:46:52 -04001070 stdLinkage := "dylib-std"
Ivan Lozanodd055472020-09-28 13:22:45 -04001071 if mod.compiler.stdLinkage(ctx) == RlibLinkage {
Ivan Lozano2b081132020-09-08 12:46:52 -04001072 stdLinkage = "rlib-std"
1073 }
1074
1075 rlibDepVariations := commonDepVariations
1076 if lib, ok := mod.compiler.(libraryInterface); !ok || !lib.sysroot() {
1077 rlibDepVariations = append(rlibDepVariations,
1078 blueprint.Variation{Mutator: "rust_stdlinkage", Variation: stdLinkage})
1079 }
1080
Ivan Lozano52767be2019-10-18 14:49:46 -07001081 actx.AddVariationDependencies(
Ivan Lozano2b081132020-09-08 12:46:52 -04001082 append(rlibDepVariations, []blueprint.Variation{
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +02001083 {Mutator: "rust_libraries", Variation: rlibVariation}}...),
Ivan Lozano52767be2019-10-18 14:49:46 -07001084 rlibDepTag, deps.Rlibs...)
1085 actx.AddVariationDependencies(
1086 append(commonDepVariations, []blueprint.Variation{
Thiébaud Weksteen295c72b2020-09-23 18:10:17 +02001087 {Mutator: "rust_libraries", Variation: dylibVariation}}...),
Ivan Lozano52767be2019-10-18 14:49:46 -07001088 dylibDepTag, deps.Dylibs...)
1089
Ivan Lozano042504f2020-08-18 14:31:23 -04001090 if deps.Rustlibs != nil && !mod.compiler.Disabled() {
1091 autoDep := mod.compiler.(autoDeppable).autoDep(ctx)
Ivan Lozano2b081132020-09-08 12:46:52 -04001092 if autoDep.depTag == rlibDepTag {
1093 actx.AddVariationDependencies(
1094 append(rlibDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: autoDep.variation}),
1095 autoDep.depTag, deps.Rustlibs...)
1096 } else {
1097 actx.AddVariationDependencies(
1098 append(commonDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: autoDep.variation}),
1099 autoDep.depTag, deps.Rustlibs...)
1100 }
Matthew Maurer0f003b12020-06-29 14:34:06 -07001101 }
Ivan Lozano2b081132020-09-08 12:46:52 -04001102 if deps.Stdlibs != nil {
Ivan Lozanodd055472020-09-28 13:22:45 -04001103 if mod.compiler.stdLinkage(ctx) == RlibLinkage {
Ivan Lozano2b081132020-09-08 12:46:52 -04001104 actx.AddVariationDependencies(
1105 append(commonDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: "rlib"}),
1106 rlibDepTag, deps.Stdlibs...)
1107 } else {
1108 actx.AddVariationDependencies(
1109 append(commonDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: "dylib"}),
1110 dylibDepTag, deps.Stdlibs...)
1111 }
1112 }
Ivan Lozano52767be2019-10-18 14:49:46 -07001113 actx.AddVariationDependencies(append(commonDepVariations,
1114 blueprint.Variation{Mutator: "link", Variation: "shared"}),
Colin Cross6e511a92020-07-27 21:26:48 -07001115 cc.SharedDepTag(), deps.SharedLibs...)
Ivan Lozano52767be2019-10-18 14:49:46 -07001116 actx.AddVariationDependencies(append(commonDepVariations,
1117 blueprint.Variation{Mutator: "link", Variation: "static"}),
Ivan Lozano63bb7682021-03-23 15:53:44 -04001118 cc.StaticDepTag(false), deps.StaticLibs...)
1119 actx.AddVariationDependencies(append(commonDepVariations,
1120 blueprint.Variation{Mutator: "link", Variation: "static"}),
1121 cc.StaticDepTag(true), deps.WholeStaticLibs...)
Ivan Lozano5ca5ef62019-09-23 10:10:40 -07001122
Zach Johnson3df4e632020-11-06 11:56:27 -08001123 actx.AddVariationDependencies(nil, cc.HeaderDepTag(), deps.HeaderLibs...)
1124
Colin Cross565cafd2020-09-25 18:47:38 -07001125 crtVariations := cc.GetCrtVariations(ctx, mod)
Ivan Lozanof1c84332019-09-20 11:00:37 -07001126 if deps.CrtBegin != "" {
Dan Albert92fe7402020-07-15 13:33:30 -07001127 actx.AddVariationDependencies(crtVariations, cc.CrtBeginDepTag, deps.CrtBegin)
Ivan Lozanof1c84332019-09-20 11:00:37 -07001128 }
1129 if deps.CrtEnd != "" {
Dan Albert92fe7402020-07-15 13:33:30 -07001130 actx.AddVariationDependencies(crtVariations, cc.CrtEndDepTag, deps.CrtEnd)
Ivan Lozanof1c84332019-09-20 11:00:37 -07001131 }
1132
Ivan Lozanoc564d2d2020-08-04 15:43:37 -04001133 if mod.sourceProvider != nil {
1134 if bindgen, ok := mod.sourceProvider.(*bindgenDecorator); ok &&
1135 bindgen.Properties.Custom_bindgen != "" {
1136 actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), customBindgenDepTag,
1137 bindgen.Properties.Custom_bindgen)
1138 }
1139 }
Ivan Lozano5ca5ef62019-09-23 10:10:40 -07001140 // proc_macros are compiler plugins, and so we need the host arch variant as a dependendcy.
Colin Cross0f7d2ef2019-10-16 11:03:10 -07001141 actx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(), procMacroDepTag, deps.ProcMacros...)
Ivan Lozanoffee3342019-08-27 12:03:00 -07001142}
1143
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001144func BeginMutator(ctx android.BottomUpMutatorContext) {
1145 if mod, ok := ctx.Module().(*Module); ok && mod.Enabled() {
1146 mod.beginMutator(ctx)
1147 }
1148}
1149
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001150func (mod *Module) beginMutator(actx android.BottomUpMutatorContext) {
1151 ctx := &baseModuleContext{
1152 BaseModuleContext: actx,
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001153 }
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -04001154
1155 mod.begin(ctx)
1156}
1157
Ivan Lozanoffee3342019-08-27 12:03:00 -07001158func (mod *Module) Name() string {
1159 name := mod.ModuleBase.Name()
1160 if p, ok := mod.compiler.(interface {
1161 Name(string) string
1162 }); ok {
1163 name = p.Name(name)
1164 }
1165 return name
1166}
1167
Thiébaud Weksteen9e8451e2020-08-13 12:55:59 +02001168func (mod *Module) disableClippy() {
Ivan Lozano32267c82020-08-04 16:27:16 -04001169 if mod.clippy != nil {
Thiébaud Weksteen9e8451e2020-08-13 12:55:59 +02001170 mod.clippy.Properties.Clippy_lints = proptools.StringPtr("none")
Ivan Lozano32267c82020-08-04 16:27:16 -04001171 }
1172}
1173
Chih-Hung Hsieh5c4e4892020-05-15 17:36:30 -07001174var _ android.HostToolProvider = (*Module)(nil)
1175
1176func (mod *Module) HostToolPath() android.OptionalPath {
1177 if !mod.Host() {
1178 return android.OptionalPath{}
1179 }
Chih-Hung Hsieha7562702020-08-10 21:50:43 -07001180 if binary, ok := mod.compiler.(*binaryDecorator); ok {
1181 return android.OptionalPathForPath(binary.baseCompiler.path)
Chih-Hung Hsieh5c4e4892020-05-15 17:36:30 -07001182 }
1183 return android.OptionalPath{}
1184}
1185
Jiyong Park99644e92020-11-17 22:21:02 +09001186var _ android.ApexModule = (*Module)(nil)
1187
Ivan Lozano3e9f9e42020-12-04 15:05:43 -05001188func (mod *Module) minSdkVersion() string {
1189 return String(mod.Properties.Min_sdk_version)
1190}
1191
Jiyong Park45bf82e2020-12-15 22:29:02 +09001192var _ android.ApexModule = (*Module)(nil)
1193
1194// Implements android.ApexModule
Jiyong Park99644e92020-11-17 22:21:02 +09001195func (mod *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
Ivan Lozano3e9f9e42020-12-04 15:05:43 -05001196 minSdkVersion := mod.minSdkVersion()
1197 if minSdkVersion == "apex_inherit" {
1198 return nil
1199 }
1200 if minSdkVersion == "" {
1201 return fmt.Errorf("min_sdk_version is not specificed")
1202 }
1203
1204 // Not using nativeApiLevelFromUser because the context here is not
1205 // necessarily a native context.
1206 ver, err := android.ApiLevelFromUser(ctx, minSdkVersion)
1207 if err != nil {
1208 return err
1209 }
1210
1211 if ver.GreaterThan(sdkVersion) {
1212 return fmt.Errorf("newer SDK(%v)", ver)
1213 }
Jiyong Park99644e92020-11-17 22:21:02 +09001214 return nil
1215}
1216
Jiyong Park45bf82e2020-12-15 22:29:02 +09001217// Implements android.ApexModule
Jiyong Park99644e92020-11-17 22:21:02 +09001218func (mod *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
1219 depTag := ctx.OtherModuleDependencyTag(dep)
1220
1221 if ccm, ok := dep.(*cc.Module); ok {
1222 if ccm.HasStubsVariants() {
1223 if cc.IsSharedDepTag(depTag) {
1224 // dynamic dep to a stubs lib crosses APEX boundary
1225 return false
1226 }
1227 if cc.IsRuntimeDepTag(depTag) {
1228 // runtime dep to a stubs lib also crosses APEX boundary
1229 return false
1230 }
1231
1232 if cc.IsHeaderDepTag(depTag) {
1233 return false
1234 }
1235 }
1236 if mod.Static() && cc.IsSharedDepTag(depTag) {
1237 // shared_lib dependency from a static lib is considered as crossing
1238 // the APEX boundary because the dependency doesn't actually is
1239 // linked; the dependency is used only during the compilation phase.
1240 return false
1241 }
1242 }
1243
1244 if depTag == procMacroDepTag {
1245 return false
1246 }
1247
1248 return true
1249}
1250
1251// Overrides ApexModule.IsInstallabeToApex()
1252func (mod *Module) IsInstallableToApex() bool {
1253 if mod.compiler != nil {
1254 if lib, ok := mod.compiler.(*libraryDecorator); ok && (lib.shared() || lib.dylib()) {
1255 return true
1256 }
1257 if _, ok := mod.compiler.(*binaryDecorator); ok {
1258 return true
1259 }
1260 }
1261 return false
1262}
1263
Ivan Lozano3dfa12d2021-02-04 11:29:41 -05001264// If a library file has a "lib" prefix, extract the library name without the prefix.
1265func libNameFromFilePath(filepath android.Path) (string, bool) {
1266 libName := strings.TrimSuffix(filepath.Base(), filepath.Ext())
1267 if strings.HasPrefix(libName, "lib") {
1268 libName = libName[3:]
1269 return libName, true
1270 }
1271 return "", false
1272}
1273
Ivan Lozanoffee3342019-08-27 12:03:00 -07001274var Bool = proptools.Bool
1275var BoolDefault = proptools.BoolDefault
1276var String = proptools.String
1277var StringPtr = proptools.StringPtr
Ivan Lozano43845682020-07-09 21:03:28 -04001278
1279var _ android.OutputFileProducer = (*Module)(nil)