blob: 5b5b856abfbdebc2aa66e298baade00102b0522a [file] [log] [blame]
Ivan Lozano183a3212019-10-18 14:18:45 -07001package cc
2
3import (
Ivan Lozano183a3212019-10-18 14:18:45 -07004 "android/soong/android"
Liz Kammerb6a55bf2021-04-12 15:42:51 -04005 "android/soong/bazel/cquery"
Ivan Lozano0f9963e2023-02-06 13:31:02 -05006 "android/soong/fuzz"
Kiyoung Kim48f37782021-07-07 12:42:39 +09007 "android/soong/snapshot"
Colin Cross6e511a92020-07-27 21:26:48 -07008
9 "github.com/google/blueprint"
Ivan Lozano183a3212019-10-18 14:18:45 -070010)
11
Ivan Lozano3968d8f2020-12-14 11:27:52 -050012// PlatformSanitizeable is an interface for sanitizing platform modules.
13type PlatformSanitizeable interface {
14 LinkableInterface
15
16 // SanitizePropDefined returns whether the Sanitizer properties struct for this module is defined.
17 SanitizePropDefined() bool
18
Ivan Lozano3968d8f2020-12-14 11:27:52 -050019 // IsSanitizerEnabled returns whether a sanitizer is enabled.
20 IsSanitizerEnabled(t SanitizerType) bool
21
22 // IsSanitizerExplicitlyDisabled returns whether a sanitizer has been explicitly disabled (set to false) rather
23 // than left undefined.
24 IsSanitizerExplicitlyDisabled(t SanitizerType) bool
25
Ivan Lozano3968d8f2020-12-14 11:27:52 -050026 // SetSanitizer enables or disables the specified sanitizer type if it's supported, otherwise this should panic.
27 SetSanitizer(t SanitizerType, b bool)
28
Ivan Lozano3968d8f2020-12-14 11:27:52 -050029 // StaticallyLinked returns true if the module is statically linked.
30 StaticallyLinked() bool
31
32 // SetInSanitizerDir sets the module installation to the sanitizer directory.
33 SetInSanitizerDir()
34
35 // SanitizeNever returns true if this module should never be sanitized.
36 SanitizeNever() bool
37
38 // SanitizerSupported returns true if a sanitizer type is supported by this modules compiler.
39 SanitizerSupported(t SanitizerType) bool
40
Ivan Lozanod7586b62021-04-01 09:49:36 -040041 // MinimalRuntimeDep returns true if this module needs to link the minimal UBSan runtime,
42 // either because it requires it or because a dependent module which requires it to be linked in this module.
43 MinimalRuntimeDep() bool
44
45 // UbsanRuntimeDep returns true if this module needs to link the full UBSan runtime,
46 // either because it requires it or because a dependent module which requires it to be linked in this module.
47 UbsanRuntimeDep() bool
48
49 // UbsanRuntimeNeeded returns true if the full UBSan runtime is required by this module.
50 UbsanRuntimeNeeded() bool
51
52 // MinimalRuntimeNeeded returns true if the minimal UBSan runtime is required by this module
53 MinimalRuntimeNeeded() bool
54
Ivan Lozano3968d8f2020-12-14 11:27:52 -050055 // SanitizableDepTagChecker returns a SantizableDependencyTagChecker function type.
56 SanitizableDepTagChecker() SantizableDependencyTagChecker
57}
58
59// SantizableDependencyTagChecker functions check whether or not a dependency
60// tag can be sanitized. These functions should return true if the tag can be
61// sanitized, otherwise they should return false. These functions should also
62// handle all possible dependency tags in the dependency tree. For example,
63// Rust modules can depend on both Rust and CC libraries, so the Rust module
64// implementation should handle tags from both.
65type SantizableDependencyTagChecker func(tag blueprint.DependencyTag) bool
66
Ivan Lozanod7586b62021-04-01 09:49:36 -040067// Snapshottable defines those functions necessary for handling module snapshots.
68type Snapshottable interface {
Kiyoung Kim48f37782021-07-07 12:42:39 +090069 snapshot.VendorSnapshotModuleInterface
70 snapshot.RecoverySnapshotModuleInterface
71
Ivan Lozanod7586b62021-04-01 09:49:36 -040072 // SnapshotHeaders returns a list of header paths provided by this module.
73 SnapshotHeaders() android.Paths
74
Ivan Lozanod7586b62021-04-01 09:49:36 -040075 // SnapshotLibrary returns true if this module is a snapshot library.
76 IsSnapshotLibrary() bool
77
Justin Yun885a7de2021-06-29 20:34:53 +090078 // EffectiveLicenseFiles returns the list of License files for this module.
79 EffectiveLicenseFiles() android.Paths
80
Ivan Lozanod7586b62021-04-01 09:49:36 -040081 // SnapshotRuntimeLibs returns a list of libraries needed by this module at runtime but which aren't build dependencies.
82 SnapshotRuntimeLibs() []string
83
84 // SnapshotSharedLibs returns the list of shared library dependencies for this module.
85 SnapshotSharedLibs() []string
86
Justin Yun5e035862021-06-29 20:50:37 +090087 // SnapshotStaticLibs returns the list of static library dependencies for this module.
88 SnapshotStaticLibs() []string
89
Ivan Lozanoadd122a2023-07-13 11:01:41 -040090 // SnapshotDylibs returns the list of dylib library dependencies for this module.
91 SnapshotDylibs() []string
92
93 // SnapshotRlibs returns the list of rlib library dependencies for this module.
94 SnapshotRlibs() []string
95
Ivan Lozanod7586b62021-04-01 09:49:36 -040096 // IsSnapshotPrebuilt returns true if this module is a snapshot prebuilt.
97 IsSnapshotPrebuilt() bool
Ivan Lozano5467a392023-08-23 14:20:25 -040098
99 // IsSnapshotSanitizer returns true if this snapshot module implements SnapshotSanitizer.
100 IsSnapshotSanitizer() bool
101
102 // IsSnapshotSanitizerAvailable returns true if this snapshot module has a sanitizer source available (cfi, hwasan).
103 IsSnapshotSanitizerAvailable(t SanitizerType) bool
104
105 // SetSnapshotSanitizerVariation sets the sanitizer variation type for this snapshot module.
106 SetSnapshotSanitizerVariation(t SanitizerType, enabled bool)
107
108 // IsSnapshotUnsanitizedVariant returns true if this is the unsanitized snapshot module variant.
109 IsSnapshotUnsanitizedVariant() bool
Ivan Lozanod7586b62021-04-01 09:49:36 -0400110}
111
Chris Parsons3c27ca32020-11-20 12:42:07 -0500112// LinkableInterface is an interface for a type of module that is linkable in a C++ library.
Ivan Lozano183a3212019-10-18 14:18:45 -0700113type LinkableInterface interface {
Ivan Lozanof9e21722020-12-02 09:00:51 -0500114 android.Module
Ivan Lozanod7586b62021-04-01 09:49:36 -0400115 Snapshottable
Ivan Lozanof9e21722020-12-02 09:00:51 -0500116
Ivan Lozano183a3212019-10-18 14:18:45 -0700117 Module() android.Module
118 CcLibrary() bool
119 CcLibraryInterface() bool
120
Ivan Lozano61c02cc2023-06-09 14:06:44 -0400121 // RustLibraryInterface returns true if this is a Rust library module
122 RustLibraryInterface() bool
123
Ivan Lozanod7586b62021-04-01 09:49:36 -0400124 // BaseModuleName returns the android.ModuleBase.BaseModuleName() value for this module.
125 BaseModuleName() string
126
Ivan Lozano183a3212019-10-18 14:18:45 -0700127 OutputFile() android.OptionalPath
Ivan Lozano39b0bf02021-10-14 12:22:09 -0400128 UnstrippedOutputFile() android.Path
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -0400129 CoverageFiles() android.Paths
Ivan Lozano183a3212019-10-18 14:18:45 -0700130
Ivan Lozano7f67c2a2022-06-27 16:00:26 -0400131 // CoverageOutputFile returns the output archive of gcno coverage information files.
132 CoverageOutputFile() android.OptionalPath
133
Ivan Lozano2b262972019-11-21 12:30:50 -0800134 NonCcVariants() bool
135
Ivan Lozano52767be2019-10-18 14:49:46 -0700136 SelectedStl() string
Ivan Lozano183a3212019-10-18 14:18:45 -0700137
138 BuildStaticVariant() bool
139 BuildSharedVariant() bool
140 SetStatic()
141 SetShared()
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500142 IsPrebuilt() bool
Ivan Lozano52767be2019-10-18 14:49:46 -0700143 Toc() android.OptionalPath
144
Ivan Lozano0f9963e2023-02-06 13:31:02 -0500145 // IsFuzzModule returns true if this a *_fuzz module.
146 IsFuzzModule() bool
147
148 // FuzzPackagedModule returns the fuzz.FuzzPackagedModule for this module.
149 // Expects that IsFuzzModule returns true.
150 FuzzPackagedModule() fuzz.FuzzPackagedModule
151
152 // FuzzSharedLibraries returns the shared library dependencies for this module.
153 // Expects that IsFuzzModule returns true.
Hamzeh Zawawy38917492023-04-05 22:08:46 +0000154 FuzzSharedLibraries() android.RuleBuilderInstalls
Ivan Lozano0f9963e2023-02-06 13:31:02 -0500155
Yi-Yo Chiang36d8e4e2021-07-02 21:21:13 +0800156 Device() bool
Jooyung Han624d35c2020-04-10 12:57:24 +0900157 Host() bool
158
Yifan Hong1b3348d2020-01-21 15:53:22 -0800159 InRamdisk() bool
160 OnlyInRamdisk() bool
161
Yifan Hong60e0cfb2020-10-21 15:17:56 -0700162 InVendorRamdisk() bool
163 OnlyInVendorRamdisk() bool
164
Ivan Lozano52767be2019-10-18 14:49:46 -0700165 InRecovery() bool
166 OnlyInRecovery() bool
167
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500168 InVendor() bool
169
Colin Crossc511bc52020-04-07 16:50:32 +0000170 UseSdk() bool
Ivan Lozano3a7d0002021-03-30 12:19:36 -0400171
Ivan Lozano7f67c2a2022-06-27 16:00:26 -0400172 // IsNdk returns true if the library is in the configs known NDK list.
173 IsNdk(config android.Config) bool
174
175 // IsStubs returns true if the this is a stubs library.
176 IsStubs() bool
177
Ivan Lozano3a7d0002021-03-30 12:19:36 -0400178 // IsLlndk returns true for both LLNDK (public) and LLNDK-private libs.
179 IsLlndk() bool
180
181 // IsLlndkPublic returns true only for LLNDK (public) libs.
182 IsLlndkPublic() bool
183
Ivan Lozanod7586b62021-04-01 09:49:36 -0400184 // HasLlndkStubs returns true if this library has a variant that will build LLNDK stubs.
185 HasLlndkStubs() bool
186
Colin Cross1f3f1302021-04-26 18:37:44 -0700187 // NeedsLlndkVariants returns true if this module has LLNDK stubs or provides LLNDK headers.
188 NeedsLlndkVariants() bool
Ivan Lozano3a7d0002021-03-30 12:19:36 -0400189
Colin Cross5271fea2021-04-27 13:06:04 -0700190 // NeedsVendorPublicLibraryVariants returns true if this module has vendor public library stubs.
191 NeedsVendorPublicLibraryVariants() bool
192
Ivan Lozanod7586b62021-04-01 09:49:36 -0400193 //StubsVersion returns the stubs version for this module.
194 StubsVersion() string
195
196 // UseVndk returns true if the module is using VNDK libraries instead of the libraries in /system/lib or /system/lib64.
197 // "product" and "vendor" variant modules return true for this function.
198 // When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true",
199 // "soc_specific: true" and more vendor installed modules are included here.
200 // When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "vendor_available: true" or
201 // "product_specific: true" modules are included here.
Ivan Lozano52767be2019-10-18 14:49:46 -0700202 UseVndk() bool
Ivan Lozanod7586b62021-04-01 09:49:36 -0400203
Jiyong Park7d55b612021-06-11 17:22:09 +0900204 // Bootstrap tests if this module is allowed to use non-APEX version of libraries.
205 Bootstrap() bool
206
Ivan Lozanod7586b62021-04-01 09:49:36 -0400207 // IsVndkSp returns true if this is a VNDK-SP module.
208 IsVndkSp() bool
209
Ivan Lozano52767be2019-10-18 14:49:46 -0700210 MustUseVendorVariant() bool
211 IsVndk() bool
Ivan Lozanof9e21722020-12-02 09:00:51 -0500212 IsVndkExt() bool
Colin Cross127bb8b2020-12-16 16:46:01 -0800213 IsVndkPrivate() bool
Ivan Lozanof1868af2022-04-12 13:08:36 -0400214 IsVendorPublicLibrary() bool
215 IsVndkPrebuiltLibrary() bool
Ivan Lozano52767be2019-10-18 14:49:46 -0700216 HasVendorVariant() bool
Justin Yuncbca3732021-02-03 19:24:13 +0900217 HasProductVariant() bool
218 HasNonSystemVariants() bool
Ivan Lozanof1868af2022-04-12 13:08:36 -0400219 ProductSpecific() bool
Ivan Lozanof9e21722020-12-02 09:00:51 -0500220 InProduct() bool
Ivan Lozanof1868af2022-04-12 13:08:36 -0400221 SdkAndPlatformVariantVisibleToMake() bool
Ivan Lozano52767be2019-10-18 14:49:46 -0700222
Ivan Lozanoc08897c2021-04-02 12:41:32 -0400223 // SubName returns the modules SubName, used for image and NDK/SDK variations.
224 SubName() string
225
Ivan Lozano52767be2019-10-18 14:49:46 -0700226 SdkVersion() string
Jiyong Parkfdaa5f72021-03-19 22:18:04 +0900227 MinSdkVersion() string
Colin Crossc511bc52020-04-07 16:50:32 +0000228 AlwaysSdk() bool
Jiyong Park2286afd2020-06-16 21:58:53 +0900229 IsSdkVariant() bool
Ivan Lozano52767be2019-10-18 14:49:46 -0700230
Colin Cross1348ce32020-10-01 13:37:16 -0700231 SplitPerApiLevel() bool
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500232
233 // SetPreventInstall sets the PreventInstall property to 'true' for this module.
234 SetPreventInstall()
235 // SetHideFromMake sets the HideFromMake property to 'true' for this module.
236 SetHideFromMake()
Ivan Lozano3a7d0002021-03-30 12:19:36 -0400237
238 // KernelHeadersDecorator returns true if this is a kernel headers decorator module.
239 // This is specific to cc and should always return false for all other packages.
240 KernelHeadersDecorator() bool
Ivan Lozanod7586b62021-04-01 09:49:36 -0400241
242 // HiddenFromMake returns true if this module is hidden from Make.
243 HiddenFromMake() bool
244
245 // RelativeInstallPath returns the relative install path for this module.
246 RelativeInstallPath() string
247
248 // Binary returns true if this is a binary module.
249 Binary() bool
250
251 // Object returns true if this is an object module.
252 Object() bool
253
254 // Rlib returns true if this is an rlib module.
255 Rlib() bool
256
257 // Dylib returns true if this is an dylib module.
258 Dylib() bool
259
Ivan Lozanoadd122a2023-07-13 11:01:41 -0400260 // RlibStd returns true if this is an rlib which links against an rlib libstd.
261 RlibStd() bool
262
Ivan Lozanod7586b62021-04-01 09:49:36 -0400263 // Static returns true if this is a static library module.
264 Static() bool
265
266 // Shared returns true if this is a shared library module.
267 Shared() bool
268
269 // Header returns true if this is a library headers module.
270 Header() bool
271
Justin Yun5e035862021-06-29 20:50:37 +0900272 // StaticExecutable returns true if this is a binary module with "static_executable: true".
273 StaticExecutable() bool
274
Ivan Lozanod7586b62021-04-01 09:49:36 -0400275 // EverInstallable returns true if the module is ever installable
276 EverInstallable() bool
277
278 // PreventInstall returns true if this module is prevented from installation.
279 PreventInstall() bool
280
281 // InstallInData returns true if this module is installed in data.
282 InstallInData() bool
283
284 // Installable returns a bool pointer to the module installable property.
285 Installable() *bool
286
287 // Symlinks returns a list of symlinks that should be created for this module.
288 Symlinks() []string
289
290 // VndkVersion returns the VNDK version string for this module.
291 VndkVersion() string
Jihoon Kangf78a8902022-09-01 22:47:07 +0000292
293 // Partition returns the partition string for this module.
294 Partition() string
Ivan Lozano0f9963e2023-02-06 13:31:02 -0500295
296 // FuzzModule returns the fuzz.FuzzModule associated with the module.
297 FuzzModuleStruct() fuzz.FuzzModule
Ivan Lozano183a3212019-10-18 14:18:45 -0700298}
299
Colin Cross6e511a92020-07-27 21:26:48 -0700300var (
Chris Parsons3c27ca32020-11-20 12:42:07 -0500301 // Dependency tag for crtbegin, an object file responsible for initialization.
Colin Cross6e511a92020-07-27 21:26:48 -0700302 CrtBeginDepTag = dependencyTag{name: "crtbegin"}
Chris Parsons3c27ca32020-11-20 12:42:07 -0500303 // Dependency tag for crtend, an object file responsible for program termination.
304 CrtEndDepTag = dependencyTag{name: "crtend"}
305 // Dependency tag for coverage library.
Colin Cross6e511a92020-07-27 21:26:48 -0700306 CoverageDepTag = dependencyTag{name: "coverage"}
307)
Ivan Lozano183a3212019-10-18 14:18:45 -0700308
Ivan Lozano3968d8f2020-12-14 11:27:52 -0500309// GetImageVariantType returns the ImageVariantType string value for the given module
310// (these are defined in cc/image.go).
311func GetImageVariantType(c LinkableInterface) ImageVariantType {
312 if c.Host() {
313 return hostImageVariant
314 } else if c.InVendor() {
315 return vendorImageVariant
316 } else if c.InProduct() {
317 return productImageVariant
318 } else if c.InRamdisk() {
319 return ramdiskImageVariant
320 } else if c.InVendorRamdisk() {
321 return vendorRamdiskImageVariant
322 } else if c.InRecovery() {
323 return recoveryImageVariant
324 } else {
325 return coreImageVariant
326 }
327}
328
Ivan Lozanoc08897c2021-04-02 12:41:32 -0400329// DepTagMakeSuffix returns the makeSuffix value of a particular library dependency tag.
330// Returns an empty string if not a library dependency tag.
331func DepTagMakeSuffix(depTag blueprint.DependencyTag) string {
332 if libDepTag, ok := depTag.(libraryDependencyTag); ok {
333 return libDepTag.makeSuffix
334 }
335 return ""
336}
337
Chris Parsons3c27ca32020-11-20 12:42:07 -0500338// SharedDepTag returns the dependency tag for any C++ shared libraries.
Colin Cross6e511a92020-07-27 21:26:48 -0700339func SharedDepTag() blueprint.DependencyTag {
340 return libraryDependencyTag{Kind: sharedLibraryDependency}
Ivan Lozano183a3212019-10-18 14:18:45 -0700341}
342
Chris Parsons3c27ca32020-11-20 12:42:07 -0500343// StaticDepTag returns the dependency tag for any C++ static libraries.
Ivan Lozano63bb7682021-03-23 15:53:44 -0400344func StaticDepTag(wholeStatic bool) blueprint.DependencyTag {
345 return libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: wholeStatic}
346}
347
348// IsWholeStaticLib whether a dependency tag is a whole static library dependency.
349func IsWholeStaticLib(depTag blueprint.DependencyTag) bool {
350 if tag, ok := depTag.(libraryDependencyTag); ok {
351 return tag.wholeStatic
352 }
353 return false
Colin Cross6e511a92020-07-27 21:26:48 -0700354}
Colin Cross0de8a1e2020-09-18 14:15:30 -0700355
Chris Parsons3c27ca32020-11-20 12:42:07 -0500356// HeaderDepTag returns the dependency tag for any C++ "header-only" libraries.
Zach Johnson3df4e632020-11-06 11:56:27 -0800357func HeaderDepTag() blueprint.DependencyTag {
358 return libraryDependencyTag{Kind: headerLibraryDependency}
359}
360
Chris Parsons3c27ca32020-11-20 12:42:07 -0500361// SharedLibraryInfo is a provider to propagate information about a shared C++ library.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700362type SharedLibraryInfo struct {
Liz Kammeref6dfea2021-06-08 15:37:09 -0400363 SharedLibrary android.Path
364 Target android.Target
Colin Cross0de8a1e2020-09-18 14:15:30 -0700365
Liz Kammeref6dfea2021-06-08 15:37:09 -0400366 TableOfContents android.OptionalPath
Colin Cross0de8a1e2020-09-18 14:15:30 -0700367
Liz Kammeref6dfea2021-06-08 15:37:09 -0400368 // should be obtained from static analogue
Colin Crossc85750b2022-04-21 12:50:51 -0700369 TransitiveStaticLibrariesForOrdering *android.DepSet[android.Path]
Colin Cross0de8a1e2020-09-18 14:15:30 -0700370}
371
372var SharedLibraryInfoProvider = blueprint.NewProvider(SharedLibraryInfo{})
373
Chris Parsons3c27ca32020-11-20 12:42:07 -0500374// SharedStubLibrary is a struct containing information about a stub shared library.
375// Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared
376// library in another APEX, it must depend on the stub version of that library.
377type SharedStubLibrary struct {
378 // The version of the stub (corresponding to the stable version of the shared library being
379 // stubbed).
Colin Cross0de8a1e2020-09-18 14:15:30 -0700380 Version string
381 SharedLibraryInfo SharedLibraryInfo
382 FlagExporterInfo FlagExporterInfo
383}
384
Chris Parsons3c27ca32020-11-20 12:42:07 -0500385// SharedLibraryStubsInfo is a provider to propagate information about all shared library stubs
386// which are dependencies of a library.
387// Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared
388// library in another APEX, it must depend on the stub version of that library.
389type SharedLibraryStubsInfo struct {
390 SharedStubLibraries []SharedStubLibrary
Colin Cross0de8a1e2020-09-18 14:15:30 -0700391
Chris Parsons3c27ca32020-11-20 12:42:07 -0500392 IsLLNDK bool
393}
394
395var SharedLibraryStubsProvider = blueprint.NewProvider(SharedLibraryStubsInfo{})
396
397// StaticLibraryInfo is a provider to propagate information about a static C++ library.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700398type StaticLibraryInfo struct {
399 StaticLibrary android.Path
400 Objects Objects
401 ReuseObjects Objects
402
Colin Crossa2bcf2c2022-02-11 13:11:55 -0800403 // A static library may contain prebuilt static libraries included with whole_static_libs
404 // that won't appear in Objects. They are transitively available in
405 // WholeStaticLibsFromPrebuilts.
406 WholeStaticLibsFromPrebuilts android.Paths
407
Colin Cross0de8a1e2020-09-18 14:15:30 -0700408 // This isn't the actual transitive DepSet, shared library dependencies have been
409 // converted into static library analogues. It is only used to order the static
410 // library dependencies that were specified for the current module.
Colin Crossc85750b2022-04-21 12:50:51 -0700411 TransitiveStaticLibrariesForOrdering *android.DepSet[android.Path]
Colin Cross0de8a1e2020-09-18 14:15:30 -0700412}
413
414var StaticLibraryInfoProvider = blueprint.NewProvider(StaticLibraryInfo{})
415
Colin Cross649d8172020-12-10 12:30:21 -0800416// HeaderLibraryInfo is a marker provider that identifies a module as a header library.
417type HeaderLibraryInfo struct {
418}
419
420// HeaderLibraryInfoProvider is a marker provider that identifies a module as a header library.
421var HeaderLibraryInfoProvider = blueprint.NewProvider(HeaderLibraryInfo{})
422
Chris Parsons3c27ca32020-11-20 12:42:07 -0500423// FlagExporterInfo is a provider to propagate transitive library information
424// pertaining to exported include paths and flags.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700425type FlagExporterInfo struct {
Chris Parsons3c27ca32020-11-20 12:42:07 -0500426 IncludeDirs android.Paths // Include directories to be included with -I
427 SystemIncludeDirs android.Paths // System include directories to be included with -isystem
428 Flags []string // Exported raw flags.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700429 Deps android.Paths
430 GeneratedHeaders android.Paths
431}
432
433var FlagExporterInfoProvider = blueprint.NewProvider(FlagExporterInfo{})
Liz Kammerb6a55bf2021-04-12 15:42:51 -0400434
435// flagExporterInfoFromCcInfo populates FlagExporterInfo provider with information from Bazel.
436func flagExporterInfoFromCcInfo(ctx android.ModuleContext, ccInfo cquery.CcInfo) FlagExporterInfo {
437
438 includes := android.PathsForBazelOut(ctx, ccInfo.Includes)
439 systemIncludes := android.PathsForBazelOut(ctx, ccInfo.SystemIncludes)
Liz Kammereb2d6d12021-12-06 14:56:25 -0500440 headers := android.PathsForBazelOut(ctx, ccInfo.Headers)
Liz Kammerb6a55bf2021-04-12 15:42:51 -0400441
442 return FlagExporterInfo{
Chris Parsonsf60ecf02021-04-27 14:48:30 -0400443 IncludeDirs: android.FirstUniquePaths(includes),
444 SystemIncludeDirs: android.FirstUniquePaths(systemIncludes),
Liz Kammereb2d6d12021-12-06 14:56:25 -0500445 GeneratedHeaders: headers,
446 // necessary to ensure generated headers are considered implicit deps of dependent actions
447 Deps: headers,
Liz Kammerb6a55bf2021-04-12 15:42:51 -0400448 }
449}