Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 1 | package cc |
| 2 | |
| 3 | import ( |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 4 | "android/soong/android" |
Liz Kammer | b6a55bf | 2021-04-12 15:42:51 -0400 | [diff] [blame] | 5 | "android/soong/bazel/cquery" |
Ivan Lozano | 0f9963e | 2023-02-06 13:31:02 -0500 | [diff] [blame] | 6 | "android/soong/fuzz" |
Kiyoung Kim | 48f3778 | 2021-07-07 12:42:39 +0900 | [diff] [blame] | 7 | "android/soong/snapshot" |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 8 | |
| 9 | "github.com/google/blueprint" |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 10 | ) |
| 11 | |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 12 | // PlatformSanitizeable is an interface for sanitizing platform modules. |
| 13 | type PlatformSanitizeable interface { |
| 14 | LinkableInterface |
| 15 | |
| 16 | // SanitizePropDefined returns whether the Sanitizer properties struct for this module is defined. |
| 17 | SanitizePropDefined() bool |
| 18 | |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 19 | // 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 Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 26 | // SetSanitizer enables or disables the specified sanitizer type if it's supported, otherwise this should panic. |
| 27 | SetSanitizer(t SanitizerType, b bool) |
| 28 | |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 29 | // 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 Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 41 | // 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 Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 55 | // 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. |
| 65 | type SantizableDependencyTagChecker func(tag blueprint.DependencyTag) bool |
| 66 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 67 | // Snapshottable defines those functions necessary for handling module snapshots. |
| 68 | type Snapshottable interface { |
Kiyoung Kim | 48f3778 | 2021-07-07 12:42:39 +0900 | [diff] [blame] | 69 | snapshot.VendorSnapshotModuleInterface |
| 70 | snapshot.RecoverySnapshotModuleInterface |
| 71 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 72 | // SnapshotHeaders returns a list of header paths provided by this module. |
| 73 | SnapshotHeaders() android.Paths |
| 74 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 75 | // SnapshotLibrary returns true if this module is a snapshot library. |
| 76 | IsSnapshotLibrary() bool |
| 77 | |
Justin Yun | 885a7de | 2021-06-29 20:34:53 +0900 | [diff] [blame] | 78 | // EffectiveLicenseFiles returns the list of License files for this module. |
| 79 | EffectiveLicenseFiles() android.Paths |
| 80 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 81 | // 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 Yun | 5e03586 | 2021-06-29 20:50:37 +0900 | [diff] [blame] | 87 | // SnapshotStaticLibs returns the list of static library dependencies for this module. |
| 88 | SnapshotStaticLibs() []string |
| 89 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 90 | // IsSnapshotPrebuilt returns true if this module is a snapshot prebuilt. |
| 91 | IsSnapshotPrebuilt() bool |
| 92 | } |
| 93 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 94 | // LinkableInterface is an interface for a type of module that is linkable in a C++ library. |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 95 | type LinkableInterface interface { |
Ivan Lozano | f9e2172 | 2020-12-02 09:00:51 -0500 | [diff] [blame] | 96 | android.Module |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 97 | Snapshottable |
Ivan Lozano | f9e2172 | 2020-12-02 09:00:51 -0500 | [diff] [blame] | 98 | |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 99 | Module() android.Module |
| 100 | CcLibrary() bool |
| 101 | CcLibraryInterface() bool |
| 102 | |
Ivan Lozano | 61c02cc | 2023-06-09 14:06:44 -0400 | [diff] [blame^] | 103 | // RustLibraryInterface returns true if this is a Rust library module |
| 104 | RustLibraryInterface() bool |
| 105 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 106 | // BaseModuleName returns the android.ModuleBase.BaseModuleName() value for this module. |
| 107 | BaseModuleName() string |
| 108 | |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 109 | OutputFile() android.OptionalPath |
Ivan Lozano | 39b0bf0 | 2021-10-14 12:22:09 -0400 | [diff] [blame] | 110 | UnstrippedOutputFile() android.Path |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 111 | CoverageFiles() android.Paths |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 112 | |
Ivan Lozano | 7f67c2a | 2022-06-27 16:00:26 -0400 | [diff] [blame] | 113 | // CoverageOutputFile returns the output archive of gcno coverage information files. |
| 114 | CoverageOutputFile() android.OptionalPath |
| 115 | |
Ivan Lozano | 2b26297 | 2019-11-21 12:30:50 -0800 | [diff] [blame] | 116 | NonCcVariants() bool |
| 117 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 118 | SelectedStl() string |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 119 | |
| 120 | BuildStaticVariant() bool |
| 121 | BuildSharedVariant() bool |
| 122 | SetStatic() |
| 123 | SetShared() |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 124 | IsPrebuilt() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 125 | Toc() android.OptionalPath |
| 126 | |
Ivan Lozano | 0f9963e | 2023-02-06 13:31:02 -0500 | [diff] [blame] | 127 | // IsFuzzModule returns true if this a *_fuzz module. |
| 128 | IsFuzzModule() bool |
| 129 | |
| 130 | // FuzzPackagedModule returns the fuzz.FuzzPackagedModule for this module. |
| 131 | // Expects that IsFuzzModule returns true. |
| 132 | FuzzPackagedModule() fuzz.FuzzPackagedModule |
| 133 | |
| 134 | // FuzzSharedLibraries returns the shared library dependencies for this module. |
| 135 | // Expects that IsFuzzModule returns true. |
Hamzeh Zawawy | 3891749 | 2023-04-05 22:08:46 +0000 | [diff] [blame] | 136 | FuzzSharedLibraries() android.RuleBuilderInstalls |
Ivan Lozano | 0f9963e | 2023-02-06 13:31:02 -0500 | [diff] [blame] | 137 | |
Yi-Yo Chiang | 36d8e4e | 2021-07-02 21:21:13 +0800 | [diff] [blame] | 138 | Device() bool |
Jooyung Han | 624d35c | 2020-04-10 12:57:24 +0900 | [diff] [blame] | 139 | Host() bool |
| 140 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 141 | InRamdisk() bool |
| 142 | OnlyInRamdisk() bool |
| 143 | |
Yifan Hong | 60e0cfb | 2020-10-21 15:17:56 -0700 | [diff] [blame] | 144 | InVendorRamdisk() bool |
| 145 | OnlyInVendorRamdisk() bool |
| 146 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 147 | InRecovery() bool |
| 148 | OnlyInRecovery() bool |
| 149 | |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 150 | InVendor() bool |
| 151 | |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 152 | UseSdk() bool |
Ivan Lozano | 3a7d000 | 2021-03-30 12:19:36 -0400 | [diff] [blame] | 153 | |
Ivan Lozano | 7f67c2a | 2022-06-27 16:00:26 -0400 | [diff] [blame] | 154 | // IsNdk returns true if the library is in the configs known NDK list. |
| 155 | IsNdk(config android.Config) bool |
| 156 | |
| 157 | // IsStubs returns true if the this is a stubs library. |
| 158 | IsStubs() bool |
| 159 | |
Ivan Lozano | 3a7d000 | 2021-03-30 12:19:36 -0400 | [diff] [blame] | 160 | // IsLlndk returns true for both LLNDK (public) and LLNDK-private libs. |
| 161 | IsLlndk() bool |
| 162 | |
| 163 | // IsLlndkPublic returns true only for LLNDK (public) libs. |
| 164 | IsLlndkPublic() bool |
| 165 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 166 | // HasLlndkStubs returns true if this library has a variant that will build LLNDK stubs. |
| 167 | HasLlndkStubs() bool |
| 168 | |
Colin Cross | 1f3f130 | 2021-04-26 18:37:44 -0700 | [diff] [blame] | 169 | // NeedsLlndkVariants returns true if this module has LLNDK stubs or provides LLNDK headers. |
| 170 | NeedsLlndkVariants() bool |
Ivan Lozano | 3a7d000 | 2021-03-30 12:19:36 -0400 | [diff] [blame] | 171 | |
Colin Cross | 5271fea | 2021-04-27 13:06:04 -0700 | [diff] [blame] | 172 | // NeedsVendorPublicLibraryVariants returns true if this module has vendor public library stubs. |
| 173 | NeedsVendorPublicLibraryVariants() bool |
| 174 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 175 | //StubsVersion returns the stubs version for this module. |
| 176 | StubsVersion() string |
| 177 | |
| 178 | // UseVndk returns true if the module is using VNDK libraries instead of the libraries in /system/lib or /system/lib64. |
| 179 | // "product" and "vendor" variant modules return true for this function. |
| 180 | // When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true", |
| 181 | // "soc_specific: true" and more vendor installed modules are included here. |
| 182 | // When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "vendor_available: true" or |
| 183 | // "product_specific: true" modules are included here. |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 184 | UseVndk() bool |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 185 | |
Jiyong Park | 7d55b61 | 2021-06-11 17:22:09 +0900 | [diff] [blame] | 186 | // Bootstrap tests if this module is allowed to use non-APEX version of libraries. |
| 187 | Bootstrap() bool |
| 188 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 189 | // IsVndkSp returns true if this is a VNDK-SP module. |
| 190 | IsVndkSp() bool |
| 191 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 192 | MustUseVendorVariant() bool |
| 193 | IsVndk() bool |
Ivan Lozano | f9e2172 | 2020-12-02 09:00:51 -0500 | [diff] [blame] | 194 | IsVndkExt() bool |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 195 | IsVndkPrivate() bool |
Ivan Lozano | f1868af | 2022-04-12 13:08:36 -0400 | [diff] [blame] | 196 | IsVendorPublicLibrary() bool |
| 197 | IsVndkPrebuiltLibrary() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 198 | HasVendorVariant() bool |
Justin Yun | cbca373 | 2021-02-03 19:24:13 +0900 | [diff] [blame] | 199 | HasProductVariant() bool |
| 200 | HasNonSystemVariants() bool |
Ivan Lozano | f1868af | 2022-04-12 13:08:36 -0400 | [diff] [blame] | 201 | ProductSpecific() bool |
Ivan Lozano | f9e2172 | 2020-12-02 09:00:51 -0500 | [diff] [blame] | 202 | InProduct() bool |
Ivan Lozano | f1868af | 2022-04-12 13:08:36 -0400 | [diff] [blame] | 203 | SdkAndPlatformVariantVisibleToMake() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 204 | |
Ivan Lozano | c08897c | 2021-04-02 12:41:32 -0400 | [diff] [blame] | 205 | // SubName returns the modules SubName, used for image and NDK/SDK variations. |
| 206 | SubName() string |
| 207 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 208 | SdkVersion() string |
Jiyong Park | fdaa5f7 | 2021-03-19 22:18:04 +0900 | [diff] [blame] | 209 | MinSdkVersion() string |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 210 | AlwaysSdk() bool |
Jiyong Park | 2286afd | 2020-06-16 21:58:53 +0900 | [diff] [blame] | 211 | IsSdkVariant() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 212 | |
Colin Cross | 1348ce3 | 2020-10-01 13:37:16 -0700 | [diff] [blame] | 213 | SplitPerApiLevel() bool |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 214 | |
| 215 | // SetPreventInstall sets the PreventInstall property to 'true' for this module. |
| 216 | SetPreventInstall() |
| 217 | // SetHideFromMake sets the HideFromMake property to 'true' for this module. |
| 218 | SetHideFromMake() |
Ivan Lozano | 3a7d000 | 2021-03-30 12:19:36 -0400 | [diff] [blame] | 219 | |
| 220 | // KernelHeadersDecorator returns true if this is a kernel headers decorator module. |
| 221 | // This is specific to cc and should always return false for all other packages. |
| 222 | KernelHeadersDecorator() bool |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 223 | |
| 224 | // HiddenFromMake returns true if this module is hidden from Make. |
| 225 | HiddenFromMake() bool |
| 226 | |
| 227 | // RelativeInstallPath returns the relative install path for this module. |
| 228 | RelativeInstallPath() string |
| 229 | |
| 230 | // Binary returns true if this is a binary module. |
| 231 | Binary() bool |
| 232 | |
| 233 | // Object returns true if this is an object module. |
| 234 | Object() bool |
| 235 | |
| 236 | // Rlib returns true if this is an rlib module. |
| 237 | Rlib() bool |
| 238 | |
| 239 | // Dylib returns true if this is an dylib module. |
| 240 | Dylib() bool |
| 241 | |
| 242 | // Static returns true if this is a static library module. |
| 243 | Static() bool |
| 244 | |
| 245 | // Shared returns true if this is a shared library module. |
| 246 | Shared() bool |
| 247 | |
| 248 | // Header returns true if this is a library headers module. |
| 249 | Header() bool |
| 250 | |
Justin Yun | 5e03586 | 2021-06-29 20:50:37 +0900 | [diff] [blame] | 251 | // StaticExecutable returns true if this is a binary module with "static_executable: true". |
| 252 | StaticExecutable() bool |
| 253 | |
Ivan Lozano | d7586b6 | 2021-04-01 09:49:36 -0400 | [diff] [blame] | 254 | // EverInstallable returns true if the module is ever installable |
| 255 | EverInstallable() bool |
| 256 | |
| 257 | // PreventInstall returns true if this module is prevented from installation. |
| 258 | PreventInstall() bool |
| 259 | |
| 260 | // InstallInData returns true if this module is installed in data. |
| 261 | InstallInData() bool |
| 262 | |
| 263 | // Installable returns a bool pointer to the module installable property. |
| 264 | Installable() *bool |
| 265 | |
| 266 | // Symlinks returns a list of symlinks that should be created for this module. |
| 267 | Symlinks() []string |
| 268 | |
| 269 | // VndkVersion returns the VNDK version string for this module. |
| 270 | VndkVersion() string |
Jihoon Kang | f78a890 | 2022-09-01 22:47:07 +0000 | [diff] [blame] | 271 | |
| 272 | // Partition returns the partition string for this module. |
| 273 | Partition() string |
Ivan Lozano | 0f9963e | 2023-02-06 13:31:02 -0500 | [diff] [blame] | 274 | |
| 275 | // FuzzModule returns the fuzz.FuzzModule associated with the module. |
| 276 | FuzzModuleStruct() fuzz.FuzzModule |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 277 | } |
| 278 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 279 | var ( |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 280 | // Dependency tag for crtbegin, an object file responsible for initialization. |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 281 | CrtBeginDepTag = dependencyTag{name: "crtbegin"} |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 282 | // Dependency tag for crtend, an object file responsible for program termination. |
| 283 | CrtEndDepTag = dependencyTag{name: "crtend"} |
| 284 | // Dependency tag for coverage library. |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 285 | CoverageDepTag = dependencyTag{name: "coverage"} |
| 286 | ) |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 287 | |
Ivan Lozano | 3968d8f | 2020-12-14 11:27:52 -0500 | [diff] [blame] | 288 | // GetImageVariantType returns the ImageVariantType string value for the given module |
| 289 | // (these are defined in cc/image.go). |
| 290 | func GetImageVariantType(c LinkableInterface) ImageVariantType { |
| 291 | if c.Host() { |
| 292 | return hostImageVariant |
| 293 | } else if c.InVendor() { |
| 294 | return vendorImageVariant |
| 295 | } else if c.InProduct() { |
| 296 | return productImageVariant |
| 297 | } else if c.InRamdisk() { |
| 298 | return ramdiskImageVariant |
| 299 | } else if c.InVendorRamdisk() { |
| 300 | return vendorRamdiskImageVariant |
| 301 | } else if c.InRecovery() { |
| 302 | return recoveryImageVariant |
| 303 | } else { |
| 304 | return coreImageVariant |
| 305 | } |
| 306 | } |
| 307 | |
Ivan Lozano | c08897c | 2021-04-02 12:41:32 -0400 | [diff] [blame] | 308 | // DepTagMakeSuffix returns the makeSuffix value of a particular library dependency tag. |
| 309 | // Returns an empty string if not a library dependency tag. |
| 310 | func DepTagMakeSuffix(depTag blueprint.DependencyTag) string { |
| 311 | if libDepTag, ok := depTag.(libraryDependencyTag); ok { |
| 312 | return libDepTag.makeSuffix |
| 313 | } |
| 314 | return "" |
| 315 | } |
| 316 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 317 | // SharedDepTag returns the dependency tag for any C++ shared libraries. |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 318 | func SharedDepTag() blueprint.DependencyTag { |
| 319 | return libraryDependencyTag{Kind: sharedLibraryDependency} |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 320 | } |
| 321 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 322 | // StaticDepTag returns the dependency tag for any C++ static libraries. |
Ivan Lozano | 63bb768 | 2021-03-23 15:53:44 -0400 | [diff] [blame] | 323 | func StaticDepTag(wholeStatic bool) blueprint.DependencyTag { |
| 324 | return libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: wholeStatic} |
| 325 | } |
| 326 | |
| 327 | // IsWholeStaticLib whether a dependency tag is a whole static library dependency. |
| 328 | func IsWholeStaticLib(depTag blueprint.DependencyTag) bool { |
| 329 | if tag, ok := depTag.(libraryDependencyTag); ok { |
| 330 | return tag.wholeStatic |
| 331 | } |
| 332 | return false |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 333 | } |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 334 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 335 | // HeaderDepTag returns the dependency tag for any C++ "header-only" libraries. |
Zach Johnson | 3df4e63 | 2020-11-06 11:56:27 -0800 | [diff] [blame] | 336 | func HeaderDepTag() blueprint.DependencyTag { |
| 337 | return libraryDependencyTag{Kind: headerLibraryDependency} |
| 338 | } |
| 339 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 340 | // SharedLibraryInfo is a provider to propagate information about a shared C++ library. |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 341 | type SharedLibraryInfo struct { |
Liz Kammer | ef6dfea | 2021-06-08 15:37:09 -0400 | [diff] [blame] | 342 | SharedLibrary android.Path |
| 343 | Target android.Target |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 344 | |
Liz Kammer | ef6dfea | 2021-06-08 15:37:09 -0400 | [diff] [blame] | 345 | TableOfContents android.OptionalPath |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 346 | |
Liz Kammer | ef6dfea | 2021-06-08 15:37:09 -0400 | [diff] [blame] | 347 | // should be obtained from static analogue |
| 348 | TransitiveStaticLibrariesForOrdering *android.DepSet |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | var SharedLibraryInfoProvider = blueprint.NewProvider(SharedLibraryInfo{}) |
| 352 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 353 | // SharedStubLibrary is a struct containing information about a stub shared library. |
| 354 | // Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared |
| 355 | // library in another APEX, it must depend on the stub version of that library. |
| 356 | type SharedStubLibrary struct { |
| 357 | // The version of the stub (corresponding to the stable version of the shared library being |
| 358 | // stubbed). |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 359 | Version string |
| 360 | SharedLibraryInfo SharedLibraryInfo |
| 361 | FlagExporterInfo FlagExporterInfo |
| 362 | } |
| 363 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 364 | // SharedLibraryStubsInfo is a provider to propagate information about all shared library stubs |
| 365 | // which are dependencies of a library. |
| 366 | // Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared |
| 367 | // library in another APEX, it must depend on the stub version of that library. |
| 368 | type SharedLibraryStubsInfo struct { |
| 369 | SharedStubLibraries []SharedStubLibrary |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 370 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 371 | IsLLNDK bool |
| 372 | } |
| 373 | |
| 374 | var SharedLibraryStubsProvider = blueprint.NewProvider(SharedLibraryStubsInfo{}) |
| 375 | |
| 376 | // StaticLibraryInfo is a provider to propagate information about a static C++ library. |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 377 | type StaticLibraryInfo struct { |
| 378 | StaticLibrary android.Path |
| 379 | Objects Objects |
| 380 | ReuseObjects Objects |
| 381 | |
Colin Cross | a2bcf2c | 2022-02-11 13:11:55 -0800 | [diff] [blame] | 382 | // A static library may contain prebuilt static libraries included with whole_static_libs |
| 383 | // that won't appear in Objects. They are transitively available in |
| 384 | // WholeStaticLibsFromPrebuilts. |
| 385 | WholeStaticLibsFromPrebuilts android.Paths |
| 386 | |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 387 | // This isn't the actual transitive DepSet, shared library dependencies have been |
| 388 | // converted into static library analogues. It is only used to order the static |
| 389 | // library dependencies that were specified for the current module. |
| 390 | TransitiveStaticLibrariesForOrdering *android.DepSet |
| 391 | } |
| 392 | |
| 393 | var StaticLibraryInfoProvider = blueprint.NewProvider(StaticLibraryInfo{}) |
| 394 | |
Colin Cross | 649d817 | 2020-12-10 12:30:21 -0800 | [diff] [blame] | 395 | // HeaderLibraryInfo is a marker provider that identifies a module as a header library. |
| 396 | type HeaderLibraryInfo struct { |
| 397 | } |
| 398 | |
| 399 | // HeaderLibraryInfoProvider is a marker provider that identifies a module as a header library. |
| 400 | var HeaderLibraryInfoProvider = blueprint.NewProvider(HeaderLibraryInfo{}) |
| 401 | |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 402 | // FlagExporterInfo is a provider to propagate transitive library information |
| 403 | // pertaining to exported include paths and flags. |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 404 | type FlagExporterInfo struct { |
Chris Parsons | 3c27ca3 | 2020-11-20 12:42:07 -0500 | [diff] [blame] | 405 | IncludeDirs android.Paths // Include directories to be included with -I |
| 406 | SystemIncludeDirs android.Paths // System include directories to be included with -isystem |
| 407 | Flags []string // Exported raw flags. |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 408 | Deps android.Paths |
| 409 | GeneratedHeaders android.Paths |
| 410 | } |
| 411 | |
| 412 | var FlagExporterInfoProvider = blueprint.NewProvider(FlagExporterInfo{}) |
Liz Kammer | b6a55bf | 2021-04-12 15:42:51 -0400 | [diff] [blame] | 413 | |
| 414 | // flagExporterInfoFromCcInfo populates FlagExporterInfo provider with information from Bazel. |
| 415 | func flagExporterInfoFromCcInfo(ctx android.ModuleContext, ccInfo cquery.CcInfo) FlagExporterInfo { |
| 416 | |
| 417 | includes := android.PathsForBazelOut(ctx, ccInfo.Includes) |
| 418 | systemIncludes := android.PathsForBazelOut(ctx, ccInfo.SystemIncludes) |
Liz Kammer | eb2d6d1 | 2021-12-06 14:56:25 -0500 | [diff] [blame] | 419 | headers := android.PathsForBazelOut(ctx, ccInfo.Headers) |
Liz Kammer | b6a55bf | 2021-04-12 15:42:51 -0400 | [diff] [blame] | 420 | |
| 421 | return FlagExporterInfo{ |
Chris Parsons | f60ecf0 | 2021-04-27 14:48:30 -0400 | [diff] [blame] | 422 | IncludeDirs: android.FirstUniquePaths(includes), |
| 423 | SystemIncludeDirs: android.FirstUniquePaths(systemIncludes), |
Liz Kammer | eb2d6d1 | 2021-12-06 14:56:25 -0500 | [diff] [blame] | 424 | GeneratedHeaders: headers, |
| 425 | // necessary to ensure generated headers are considered implicit deps of dependent actions |
| 426 | Deps: headers, |
Liz Kammer | b6a55bf | 2021-04-12 15:42:51 -0400 | [diff] [blame] | 427 | } |
| 428 | } |