Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package rust |
| 16 | |
| 17 | import ( |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 18 | "fmt" |
Ivan Lozano | ad8b18b | 2019-10-31 19:38:29 -0700 | [diff] [blame] | 19 | "regexp" |
| 20 | "strings" |
| 21 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 22 | "android/soong/android" |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 23 | "android/soong/cc" |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 24 | ) |
| 25 | |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 26 | var ( |
| 27 | DylibStdlibSuffix = ".dylib-std" |
| 28 | RlibStdlibSuffix = ".rlib-std" |
| 29 | ) |
| 30 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 31 | func init() { |
| 32 | android.RegisterModuleType("rust_library", RustLibraryFactory) |
| 33 | android.RegisterModuleType("rust_library_dylib", RustLibraryDylibFactory) |
| 34 | android.RegisterModuleType("rust_library_rlib", RustLibraryRlibFactory) |
| 35 | android.RegisterModuleType("rust_library_host", RustLibraryHostFactory) |
| 36 | android.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory) |
| 37 | android.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory) |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 38 | android.RegisterModuleType("rust_ffi", RustFFIFactory) |
| 39 | android.RegisterModuleType("rust_ffi_shared", RustFFISharedFactory) |
| 40 | android.RegisterModuleType("rust_ffi_static", RustFFIStaticFactory) |
| 41 | android.RegisterModuleType("rust_ffi_host", RustFFIHostFactory) |
| 42 | android.RegisterModuleType("rust_ffi_host_shared", RustFFISharedHostFactory) |
| 43 | android.RegisterModuleType("rust_ffi_host_static", RustFFIStaticHostFactory) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | type VariantLibraryProperties struct { |
Matthew Maurer | c761eec | 2020-06-25 00:47:46 -0700 | [diff] [blame] | 47 | Enabled *bool `android:"arch_variant"` |
| 48 | Srcs []string `android:"path,arch_variant"` |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | type LibraryCompilerProperties struct { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 52 | Rlib VariantLibraryProperties `android:"arch_variant"` |
| 53 | Dylib VariantLibraryProperties `android:"arch_variant"` |
| 54 | Shared VariantLibraryProperties `android:"arch_variant"` |
| 55 | Static VariantLibraryProperties `android:"arch_variant"` |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 56 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 57 | // path to include directories to pass to cc_* modules, only relevant for static/shared variants. |
| 58 | Include_dirs []string `android:"path,arch_variant"` |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 59 | |
| 60 | // Whether this library is part of the Rust toolchain sysroot. |
| 61 | Sysroot *bool |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | type LibraryMutatedProperties struct { |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 65 | // Build a dylib variant |
| 66 | BuildDylib bool `blueprint:"mutated"` |
| 67 | // Build an rlib variant |
| 68 | BuildRlib bool `blueprint:"mutated"` |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 69 | // Build a shared library variant |
| 70 | BuildShared bool `blueprint:"mutated"` |
| 71 | // Build a static library variant |
| 72 | BuildStatic bool `blueprint:"mutated"` |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 73 | |
| 74 | // This variant is a dylib |
| 75 | VariantIsDylib bool `blueprint:"mutated"` |
| 76 | // This variant is an rlib |
| 77 | VariantIsRlib bool `blueprint:"mutated"` |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 78 | // This variant is a shared library |
| 79 | VariantIsShared bool `blueprint:"mutated"` |
| 80 | // This variant is a static library |
| 81 | VariantIsStatic bool `blueprint:"mutated"` |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 82 | // This variant is a source provider |
| 83 | VariantIsSource bool `blueprint:"mutated"` |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 84 | |
| 85 | // This variant is disabled and should not be compiled |
| 86 | // (used for SourceProvider variants that produce only source) |
| 87 | VariantIsDisabled bool `blueprint:"mutated"` |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 88 | |
| 89 | // Whether this library variant should be link libstd via rlibs |
| 90 | VariantIsStaticStd bool `blueprint:"mutated"` |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | type libraryDecorator struct { |
| 94 | *baseCompiler |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 95 | *flagExporter |
Thiébaud Weksteen | fabaff6 | 2020-08-27 13:48:36 +0200 | [diff] [blame] | 96 | stripper Stripper |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 97 | |
Ivan Lozano | 8a23fa4 | 2020-06-16 10:26:57 -0400 | [diff] [blame] | 98 | Properties LibraryCompilerProperties |
| 99 | MutatedProperties LibraryMutatedProperties |
| 100 | includeDirs android.Paths |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 101 | sourceProvider SourceProvider |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | type libraryInterface interface { |
| 105 | rlib() bool |
| 106 | dylib() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 107 | static() bool |
| 108 | shared() bool |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 109 | sysroot() bool |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 110 | source() bool |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 111 | |
| 112 | // Returns true if the build options for the module have selected a particular build type |
| 113 | buildRlib() bool |
| 114 | buildDylib() bool |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 115 | buildShared() bool |
| 116 | buildStatic() bool |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 117 | |
| 118 | // Sets a particular variant type |
| 119 | setRlib() |
| 120 | setDylib() |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 121 | setShared() |
| 122 | setStatic() |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 123 | setSource() |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 124 | |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 125 | // Set libstd linkage |
| 126 | setRlibStd() |
| 127 | setDylibStd() |
| 128 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 129 | // Build a specific library variant |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 130 | BuildOnlyFFI() |
| 131 | BuildOnlyRust() |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 132 | BuildOnlyRlib() |
| 133 | BuildOnlyDylib() |
| 134 | BuildOnlyStatic() |
| 135 | BuildOnlyShared() |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 138 | func (library *libraryDecorator) nativeCoverage() bool { |
| 139 | return true |
| 140 | } |
| 141 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 142 | func (library *libraryDecorator) rlib() bool { |
| 143 | return library.MutatedProperties.VariantIsRlib |
| 144 | } |
| 145 | |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 146 | func (library *libraryDecorator) sysroot() bool { |
| 147 | return Bool(library.Properties.Sysroot) |
| 148 | } |
| 149 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 150 | func (library *libraryDecorator) dylib() bool { |
| 151 | return library.MutatedProperties.VariantIsDylib |
| 152 | } |
| 153 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 154 | func (library *libraryDecorator) shared() bool { |
| 155 | return library.MutatedProperties.VariantIsShared |
| 156 | } |
| 157 | |
| 158 | func (library *libraryDecorator) static() bool { |
| 159 | return library.MutatedProperties.VariantIsStatic |
| 160 | } |
| 161 | |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 162 | func (library *libraryDecorator) source() bool { |
| 163 | return library.MutatedProperties.VariantIsSource |
| 164 | } |
| 165 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 166 | func (library *libraryDecorator) buildRlib() bool { |
| 167 | return library.MutatedProperties.BuildRlib && BoolDefault(library.Properties.Rlib.Enabled, true) |
| 168 | } |
| 169 | |
| 170 | func (library *libraryDecorator) buildDylib() bool { |
| 171 | return library.MutatedProperties.BuildDylib && BoolDefault(library.Properties.Dylib.Enabled, true) |
| 172 | } |
| 173 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 174 | func (library *libraryDecorator) buildShared() bool { |
| 175 | return library.MutatedProperties.BuildShared && BoolDefault(library.Properties.Shared.Enabled, true) |
| 176 | } |
| 177 | |
| 178 | func (library *libraryDecorator) buildStatic() bool { |
| 179 | return library.MutatedProperties.BuildStatic && BoolDefault(library.Properties.Static.Enabled, true) |
| 180 | } |
| 181 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 182 | func (library *libraryDecorator) setRlib() { |
| 183 | library.MutatedProperties.VariantIsRlib = true |
| 184 | library.MutatedProperties.VariantIsDylib = false |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 185 | library.MutatedProperties.VariantIsStatic = false |
| 186 | library.MutatedProperties.VariantIsShared = false |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | func (library *libraryDecorator) setDylib() { |
| 190 | library.MutatedProperties.VariantIsRlib = false |
| 191 | library.MutatedProperties.VariantIsDylib = true |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 192 | library.MutatedProperties.VariantIsStatic = false |
| 193 | library.MutatedProperties.VariantIsShared = false |
| 194 | } |
| 195 | |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 196 | func (library *libraryDecorator) setRlibStd() { |
| 197 | library.MutatedProperties.VariantIsStaticStd = true |
| 198 | } |
| 199 | |
| 200 | func (library *libraryDecorator) setDylibStd() { |
| 201 | library.MutatedProperties.VariantIsStaticStd = false |
| 202 | } |
| 203 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 204 | func (library *libraryDecorator) setShared() { |
| 205 | library.MutatedProperties.VariantIsStatic = false |
| 206 | library.MutatedProperties.VariantIsShared = true |
| 207 | library.MutatedProperties.VariantIsRlib = false |
| 208 | library.MutatedProperties.VariantIsDylib = false |
| 209 | } |
| 210 | |
| 211 | func (library *libraryDecorator) setStatic() { |
| 212 | library.MutatedProperties.VariantIsStatic = true |
| 213 | library.MutatedProperties.VariantIsShared = false |
| 214 | library.MutatedProperties.VariantIsRlib = false |
| 215 | library.MutatedProperties.VariantIsDylib = false |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 218 | func (library *libraryDecorator) setSource() { |
| 219 | library.MutatedProperties.VariantIsSource = true |
| 220 | } |
| 221 | |
Liz Kammer | 356f7d4 | 2021-01-26 09:18:53 -0500 | [diff] [blame] | 222 | func (library *libraryDecorator) autoDep(ctx android.BottomUpMutatorContext) autoDep { |
Ivan Lozano | ea08613 | 2020-12-08 14:43:00 -0500 | [diff] [blame] | 223 | if library.preferRlib() { |
| 224 | return rlibAutoDep |
| 225 | } else if library.rlib() || library.static() { |
Matthew Maurer | 0f003b1 | 2020-06-29 14:34:06 -0700 | [diff] [blame] | 226 | return rlibAutoDep |
| 227 | } else if library.dylib() || library.shared() { |
| 228 | return dylibAutoDep |
Liz Kammer | 356f7d4 | 2021-01-26 09:18:53 -0500 | [diff] [blame] | 229 | } else if ctx.BazelConversionMode() { |
| 230 | // In Bazel conversion mode, we are currently ignoring the deptag, so we just need to supply a |
| 231 | // compatible tag in order to add the dependency. |
| 232 | return rlibAutoDep |
Matthew Maurer | 0f003b1 | 2020-06-29 14:34:06 -0700 | [diff] [blame] | 233 | } else { |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 234 | panic(fmt.Errorf("autoDep called on library %q that has no enabled variants.", ctx.ModuleName())) |
Matthew Maurer | 0f003b1 | 2020-06-29 14:34:06 -0700 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
Ivan Lozano | ea08613 | 2020-12-08 14:43:00 -0500 | [diff] [blame] | 238 | func (library *libraryDecorator) stdLinkage(ctx *depsContext) RustLinkage { |
| 239 | if library.static() || library.MutatedProperties.VariantIsStaticStd { |
| 240 | return RlibLinkage |
| 241 | } else if library.baseCompiler.preferRlib() { |
| 242 | return RlibLinkage |
| 243 | } |
| 244 | return DefaultLinkage |
| 245 | } |
| 246 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 247 | var _ compiler = (*libraryDecorator)(nil) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 248 | var _ libraryInterface = (*libraryDecorator)(nil) |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 249 | var _ exportedFlagsProducer = (*libraryDecorator)(nil) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 250 | |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 251 | // rust_library produces all rust variants. |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 252 | func RustLibraryFactory() android.Module { |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 253 | module, library := NewRustLibrary(android.HostAndDeviceSupported) |
| 254 | library.BuildOnlyRust() |
| 255 | return module.Init() |
| 256 | } |
| 257 | |
| 258 | // rust_ffi produces all ffi variants. |
| 259 | func RustFFIFactory() android.Module { |
| 260 | module, library := NewRustLibrary(android.HostAndDeviceSupported) |
| 261 | library.BuildOnlyFFI() |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 262 | return module.Init() |
| 263 | } |
| 264 | |
| 265 | // rust_library_dylib produces a dylib. |
| 266 | func RustLibraryDylibFactory() android.Module { |
| 267 | module, library := NewRustLibrary(android.HostAndDeviceSupported) |
| 268 | library.BuildOnlyDylib() |
| 269 | return module.Init() |
| 270 | } |
| 271 | |
| 272 | // rust_library_rlib produces an rlib. |
| 273 | func RustLibraryRlibFactory() android.Module { |
| 274 | module, library := NewRustLibrary(android.HostAndDeviceSupported) |
| 275 | library.BuildOnlyRlib() |
| 276 | return module.Init() |
| 277 | } |
| 278 | |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 279 | // rust_ffi_shared produces a shared library. |
| 280 | func RustFFISharedFactory() android.Module { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 281 | module, library := NewRustLibrary(android.HostAndDeviceSupported) |
| 282 | library.BuildOnlyShared() |
| 283 | return module.Init() |
| 284 | } |
| 285 | |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 286 | // rust_ffi_static produces a static library. |
| 287 | func RustFFIStaticFactory() android.Module { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 288 | module, library := NewRustLibrary(android.HostAndDeviceSupported) |
| 289 | library.BuildOnlyStatic() |
| 290 | return module.Init() |
| 291 | } |
| 292 | |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 293 | // rust_library_host produces all rust variants. |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 294 | func RustLibraryHostFactory() android.Module { |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 295 | module, library := NewRustLibrary(android.HostSupported) |
| 296 | library.BuildOnlyRust() |
| 297 | return module.Init() |
| 298 | } |
| 299 | |
| 300 | // rust_ffi_host produces all FFI variants. |
| 301 | func RustFFIHostFactory() android.Module { |
| 302 | module, library := NewRustLibrary(android.HostSupported) |
| 303 | library.BuildOnlyFFI() |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 304 | return module.Init() |
| 305 | } |
| 306 | |
| 307 | // rust_library_dylib_host produces a dylib. |
| 308 | func RustLibraryDylibHostFactory() android.Module { |
| 309 | module, library := NewRustLibrary(android.HostSupported) |
| 310 | library.BuildOnlyDylib() |
| 311 | return module.Init() |
| 312 | } |
| 313 | |
| 314 | // rust_library_rlib_host produces an rlib. |
| 315 | func RustLibraryRlibHostFactory() android.Module { |
| 316 | module, library := NewRustLibrary(android.HostSupported) |
| 317 | library.BuildOnlyRlib() |
| 318 | return module.Init() |
| 319 | } |
| 320 | |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 321 | // rust_ffi_static_host produces a static library. |
| 322 | func RustFFIStaticHostFactory() android.Module { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 323 | module, library := NewRustLibrary(android.HostSupported) |
| 324 | library.BuildOnlyStatic() |
| 325 | return module.Init() |
| 326 | } |
| 327 | |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 328 | // rust_ffi_shared_host produces an shared library. |
| 329 | func RustFFISharedHostFactory() android.Module { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 330 | module, library := NewRustLibrary(android.HostSupported) |
| 331 | library.BuildOnlyShared() |
| 332 | return module.Init() |
| 333 | } |
| 334 | |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 335 | func (library *libraryDecorator) BuildOnlyFFI() { |
| 336 | library.MutatedProperties.BuildDylib = false |
| 337 | library.MutatedProperties.BuildRlib = false |
| 338 | library.MutatedProperties.BuildShared = true |
| 339 | library.MutatedProperties.BuildStatic = true |
| 340 | } |
| 341 | |
| 342 | func (library *libraryDecorator) BuildOnlyRust() { |
| 343 | library.MutatedProperties.BuildDylib = true |
| 344 | library.MutatedProperties.BuildRlib = true |
| 345 | library.MutatedProperties.BuildShared = false |
| 346 | library.MutatedProperties.BuildStatic = false |
| 347 | } |
| 348 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 349 | func (library *libraryDecorator) BuildOnlyDylib() { |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 350 | library.MutatedProperties.BuildDylib = true |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 351 | library.MutatedProperties.BuildRlib = false |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 352 | library.MutatedProperties.BuildShared = false |
| 353 | library.MutatedProperties.BuildStatic = false |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | func (library *libraryDecorator) BuildOnlyRlib() { |
| 357 | library.MutatedProperties.BuildDylib = false |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 358 | library.MutatedProperties.BuildRlib = true |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 359 | library.MutatedProperties.BuildShared = false |
| 360 | library.MutatedProperties.BuildStatic = false |
| 361 | } |
| 362 | |
| 363 | func (library *libraryDecorator) BuildOnlyStatic() { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 364 | library.MutatedProperties.BuildRlib = false |
| 365 | library.MutatedProperties.BuildDylib = false |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 366 | library.MutatedProperties.BuildShared = false |
| 367 | library.MutatedProperties.BuildStatic = true |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | func (library *libraryDecorator) BuildOnlyShared() { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 371 | library.MutatedProperties.BuildRlib = false |
| 372 | library.MutatedProperties.BuildDylib = false |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 373 | library.MutatedProperties.BuildStatic = false |
| 374 | library.MutatedProperties.BuildShared = true |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | func NewRustLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) { |
Ivan Lozano | 9d1df10 | 2020-04-28 10:10:23 -0400 | [diff] [blame] | 378 | module := newModule(hod, android.MultilibBoth) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 379 | |
| 380 | library := &libraryDecorator{ |
| 381 | MutatedProperties: LibraryMutatedProperties{ |
Matthew Maurer | 2ae0513 | 2020-06-23 14:28:53 -0700 | [diff] [blame] | 382 | BuildDylib: false, |
| 383 | BuildRlib: false, |
| 384 | BuildShared: false, |
| 385 | BuildStatic: false, |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 386 | }, |
Chih-Hung Hsieh | 9a4a7ba | 2019-12-12 19:36:05 -0800 | [diff] [blame] | 387 | baseCompiler: NewBaseCompiler("lib", "lib64", InstallInSystem), |
Matthew Maurer | bb3add1 | 2020-06-25 09:34:12 -0700 | [diff] [blame] | 388 | flagExporter: NewFlagExporter(), |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | module.compiler = library |
| 392 | |
| 393 | return module, library |
| 394 | } |
| 395 | |
| 396 | func (library *libraryDecorator) compilerProps() []interface{} { |
| 397 | return append(library.baseCompiler.compilerProps(), |
| 398 | &library.Properties, |
Thiébaud Weksteen | fabaff6 | 2020-08-27 13:48:36 +0200 | [diff] [blame] | 399 | &library.MutatedProperties, |
| 400 | &library.stripper.StripProperties) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 401 | } |
| 402 | |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 403 | func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps { |
| 404 | deps = library.baseCompiler.compilerDeps(ctx, deps) |
| 405 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 406 | if ctx.toolchain().Bionic() && (library.dylib() || library.shared()) { |
Thiébaud Weksteen | f1ff54a | 2021-03-22 14:24:54 +0100 | [diff] [blame] | 407 | deps = bionicDeps(ctx, deps, false) |
Ivan Lozano | 12ee9ca | 2020-04-07 13:19:44 -0400 | [diff] [blame] | 408 | deps.CrtBegin = "crtbegin_so" |
| 409 | deps.CrtEnd = "crtend_so" |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | return deps |
| 413 | } |
Ivan Lozano | bec05ea | 2020-06-09 08:27:49 -0400 | [diff] [blame] | 414 | |
| 415 | func (library *libraryDecorator) sharedLibFilename(ctx ModuleContext) string { |
| 416 | return library.getStem(ctx) + ctx.toolchain().SharedLibSuffix() |
| 417 | } |
| 418 | |
Ivan Lozano | e0833b1 | 2019-11-06 19:15:49 -0800 | [diff] [blame] | 419 | func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags { |
Thiébaud Weksteen | 1f7f70f | 2020-06-24 11:32:48 +0200 | [diff] [blame] | 420 | flags.RustFlags = append(flags.RustFlags, "-C metadata="+ctx.ModuleName()) |
Ivan Lozano | e0833b1 | 2019-11-06 19:15:49 -0800 | [diff] [blame] | 421 | flags = library.baseCompiler.compilerFlags(ctx, flags) |
| 422 | if library.shared() || library.static() { |
| 423 | library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Include_dirs)...) |
| 424 | } |
Ivan Lozano | bec05ea | 2020-06-09 08:27:49 -0400 | [diff] [blame] | 425 | if library.shared() { |
| 426 | flags.LinkFlags = append(flags.LinkFlags, "-Wl,-soname="+library.sharedLibFilename(ctx)) |
| 427 | } |
| 428 | |
Ivan Lozano | e0833b1 | 2019-11-06 19:15:49 -0800 | [diff] [blame] | 429 | return flags |
| 430 | } |
Ivan Lozano | f1c8433 | 2019-09-20 11:00:37 -0700 | [diff] [blame] | 431 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 432 | func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path { |
Thiébaud Weksteen | fabaff6 | 2020-08-27 13:48:36 +0200 | [diff] [blame] | 433 | var outputFile android.ModuleOutPath |
| 434 | var fileName string |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 435 | var srcPath android.Path |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 436 | |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 437 | if library.sourceProvider != nil { |
Ivan Lozano | 57f434e | 2020-10-28 09:32:10 -0400 | [diff] [blame] | 438 | // Assume the first source from the source provider is the library entry point. |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 439 | srcPath = library.sourceProvider.Srcs()[0] |
Ivan Lozano | 9d74a52 | 2020-12-01 09:25:22 -0500 | [diff] [blame] | 440 | deps.srcProviderFiles = append(deps.srcProviderFiles, library.sourceProvider.Srcs()...) |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 441 | } else { |
| 442 | srcPath, _ = srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs) |
| 443 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 444 | |
| 445 | flags.RustFlags = append(flags.RustFlags, deps.depFlags...) |
Ivan Lozano | 3dfa12d | 2021-02-04 11:29:41 -0500 | [diff] [blame] | 446 | flags.LinkFlags = append(flags.LinkFlags, deps.depLinkFlags...) |
Ivan Lozano | 2093af2 | 2020-08-25 12:48:19 -0400 | [diff] [blame] | 447 | flags.LinkFlags = append(flags.LinkFlags, deps.linkObjects...) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 448 | |
Matthew Maurer | 46c46cc | 2020-01-13 16:34:34 -0800 | [diff] [blame] | 449 | if library.dylib() { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 450 | // We need prefer-dynamic for now to avoid linking in the static stdlib. See: |
| 451 | // https://github.com/rust-lang/rust/issues/19680 |
| 452 | // https://github.com/rust-lang/rust/issues/34909 |
| 453 | flags.RustFlags = append(flags.RustFlags, "-C prefer-dynamic") |
| 454 | } |
| 455 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 456 | if library.rlib() { |
Thiébaud Weksteen | fabaff6 | 2020-08-27 13:48:36 +0200 | [diff] [blame] | 457 | fileName = library.getStem(ctx) + ctx.toolchain().RlibSuffix() |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 458 | outputFile = android.PathForModuleOut(ctx, fileName) |
| 459 | |
Joel Galenson | fa04938 | 2021-01-14 16:03:18 -0800 | [diff] [blame] | 460 | TransformSrctoRlib(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 461 | } else if library.dylib() { |
Thiébaud Weksteen | fabaff6 | 2020-08-27 13:48:36 +0200 | [diff] [blame] | 462 | fileName = library.getStem(ctx) + ctx.toolchain().DylibSuffix() |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 463 | outputFile = android.PathForModuleOut(ctx, fileName) |
| 464 | |
Joel Galenson | fa04938 | 2021-01-14 16:03:18 -0800 | [diff] [blame] | 465 | TransformSrctoDylib(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 466 | } else if library.static() { |
Thiébaud Weksteen | fabaff6 | 2020-08-27 13:48:36 +0200 | [diff] [blame] | 467 | fileName = library.getStem(ctx) + ctx.toolchain().StaticLibSuffix() |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 468 | outputFile = android.PathForModuleOut(ctx, fileName) |
| 469 | |
Joel Galenson | fa04938 | 2021-01-14 16:03:18 -0800 | [diff] [blame] | 470 | TransformSrctoStatic(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 471 | } else if library.shared() { |
Thiébaud Weksteen | fabaff6 | 2020-08-27 13:48:36 +0200 | [diff] [blame] | 472 | fileName = library.sharedLibFilename(ctx) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 473 | outputFile = android.PathForModuleOut(ctx, fileName) |
| 474 | |
Joel Galenson | fa04938 | 2021-01-14 16:03:18 -0800 | [diff] [blame] | 475 | TransformSrctoShared(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 476 | } |
| 477 | |
Thiébaud Weksteen | 4fab05a | 2021-04-14 19:15:48 +0200 | [diff] [blame] | 478 | if !library.rlib() && !library.static() && library.stripper.NeedsStrip(ctx) { |
Thiébaud Weksteen | fabaff6 | 2020-08-27 13:48:36 +0200 | [diff] [blame] | 479 | strippedOutputFile := android.PathForModuleOut(ctx, "stripped", fileName) |
| 480 | library.stripper.StripExecutableOrSharedLib(ctx, outputFile, strippedOutputFile) |
| 481 | library.strippedOutputFile = android.OptionalPathForPath(strippedOutputFile) |
| 482 | } |
| 483 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 484 | if library.rlib() || library.dylib() { |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 485 | library.flagExporter.exportLinkDirs(deps.linkDirs...) |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 486 | library.flagExporter.exportLinkObjects(deps.linkObjects...) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 487 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 488 | |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 489 | if library.static() || library.shared() { |
| 490 | ctx.SetProvider(cc.FlagExporterInfoProvider, cc.FlagExporterInfo{ |
| 491 | IncludeDirs: library.includeDirs, |
| 492 | }) |
| 493 | } |
| 494 | |
| 495 | if library.shared() { |
| 496 | ctx.SetProvider(cc.SharedLibraryInfoProvider, cc.SharedLibraryInfo{ |
| 497 | SharedLibrary: outputFile, |
| 498 | UnstrippedSharedLibrary: outputFile, |
| 499 | }) |
| 500 | } |
| 501 | |
| 502 | if library.static() { |
| 503 | depSet := android.NewDepSetBuilder(android.TOPOLOGICAL).Direct(outputFile).Build() |
| 504 | ctx.SetProvider(cc.StaticLibraryInfoProvider, cc.StaticLibraryInfo{ |
| 505 | StaticLibrary: outputFile, |
| 506 | |
| 507 | TransitiveStaticLibrariesForOrdering: depSet, |
| 508 | }) |
| 509 | } |
| 510 | |
| 511 | library.flagExporter.setProvider(ctx) |
| 512 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 513 | return outputFile |
| 514 | } |
| 515 | |
Ivan Lozano | ad8b18b | 2019-10-31 19:38:29 -0700 | [diff] [blame] | 516 | func (library *libraryDecorator) getStem(ctx ModuleContext) string { |
| 517 | stem := library.baseCompiler.getStemWithoutSuffix(ctx) |
| 518 | validateLibraryStem(ctx, stem, library.crateName()) |
| 519 | |
| 520 | return stem + String(library.baseCompiler.Properties.Suffix) |
| 521 | } |
| 522 | |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 523 | func (library *libraryDecorator) install(ctx ModuleContext) { |
| 524 | // Only shared and dylib variants make sense to install. |
| 525 | if library.shared() || library.dylib() { |
| 526 | library.baseCompiler.install(ctx) |
| 527 | } |
| 528 | } |
| 529 | |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 530 | func (library *libraryDecorator) Disabled() bool { |
| 531 | return library.MutatedProperties.VariantIsDisabled |
| 532 | } |
| 533 | |
| 534 | func (library *libraryDecorator) SetDisabled() { |
| 535 | library.MutatedProperties.VariantIsDisabled = true |
| 536 | } |
| 537 | |
Ivan Lozano | ad8b18b | 2019-10-31 19:38:29 -0700 | [diff] [blame] | 538 | var validCrateName = regexp.MustCompile("[^a-zA-Z0-9_]+") |
| 539 | |
| 540 | func validateLibraryStem(ctx BaseModuleContext, filename string, crate_name string) { |
| 541 | if crate_name == "" { |
| 542 | ctx.PropertyErrorf("crate_name", "crate_name must be defined.") |
| 543 | } |
| 544 | |
| 545 | // crate_names are used for the library output file, and rustc expects these |
| 546 | // to be alphanumeric with underscores allowed. |
| 547 | if validCrateName.MatchString(crate_name) { |
| 548 | ctx.PropertyErrorf("crate_name", |
| 549 | "library crate_names must be alphanumeric with underscores allowed") |
| 550 | } |
| 551 | |
| 552 | // Libraries are expected to begin with "lib" followed by the crate_name |
| 553 | if !strings.HasPrefix(filename, "lib"+crate_name) { |
| 554 | ctx.ModuleErrorf("Invalid name or stem property; library filenames must start with lib<crate_name>") |
| 555 | } |
| 556 | } |
| 557 | |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 558 | // LibraryMutator mutates the libraries into variants according to the |
| 559 | // build{Rlib,Dylib} attributes. |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 560 | func LibraryMutator(mctx android.BottomUpMutatorContext) { |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 561 | // Only mutate on Rust libraries. |
| 562 | m, ok := mctx.Module().(*Module) |
| 563 | if !ok || m.compiler == nil { |
| 564 | return |
| 565 | } |
| 566 | library, ok := m.compiler.(libraryInterface) |
| 567 | if !ok { |
| 568 | return |
| 569 | } |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 570 | |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 571 | var variants []string |
| 572 | // The source variant is used for SourceProvider modules. The other variants (i.e. rlib and dylib) |
| 573 | // depend on this variant. It must be the first variant to be declared. |
| 574 | sourceVariant := false |
| 575 | if m.sourceProvider != nil { |
| 576 | variants = append(variants, "source") |
| 577 | sourceVariant = true |
| 578 | } |
| 579 | if library.buildRlib() { |
| 580 | variants = append(variants, rlibVariation) |
| 581 | } |
| 582 | if library.buildDylib() { |
| 583 | variants = append(variants, dylibVariation) |
| 584 | } |
Ivan Lozano | 26ecd6c | 2020-07-31 13:40:31 -0400 | [diff] [blame] | 585 | |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 586 | if len(variants) == 0 { |
| 587 | return |
| 588 | } |
| 589 | modules := mctx.CreateLocalVariations(variants...) |
| 590 | |
| 591 | // The order of the variations (modules) matches the variant names provided. Iterate |
| 592 | // through the new variation modules and set their mutated properties. |
| 593 | for i, v := range modules { |
| 594 | switch variants[i] { |
| 595 | case rlibVariation: |
| 596 | v.(*Module).compiler.(libraryInterface).setRlib() |
| 597 | case dylibVariation: |
| 598 | v.(*Module).compiler.(libraryInterface).setDylib() |
Ivan Lozano | c08897c | 2021-04-02 12:41:32 -0400 | [diff] [blame] | 599 | if v.(*Module).ModuleBase.ImageVariation().Variation == android.VendorRamdiskVariation { |
Ivan Lozano | 6a88443 | 2020-12-02 09:15:16 -0500 | [diff] [blame] | 600 | // TODO(b/165791368) |
Ivan Lozano | c08897c | 2021-04-02 12:41:32 -0400 | [diff] [blame] | 601 | // Disable dylib Vendor Ramdisk variations until we support these. |
Ivan Lozano | 6a88443 | 2020-12-02 09:15:16 -0500 | [diff] [blame] | 602 | v.(*Module).Disable() |
| 603 | } |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 604 | case "source": |
| 605 | v.(*Module).compiler.(libraryInterface).setSource() |
| 606 | // The source variant does not produce any library. |
| 607 | // Disable the compilation steps. |
| 608 | v.(*Module).compiler.SetDisabled() |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 609 | } |
| 610 | } |
Thiébaud Weksteen | 295c72b | 2020-09-23 18:10:17 +0200 | [diff] [blame] | 611 | |
| 612 | // If a source variant is created, add an inter-variant dependency |
| 613 | // between the other variants and the source variant. |
| 614 | if sourceVariant { |
| 615 | sv := modules[0] |
| 616 | for _, v := range modules[1:] { |
| 617 | if !v.Enabled() { |
| 618 | continue |
| 619 | } |
| 620 | mctx.AddInterVariantDependency(sourceDepTag, v, sv) |
| 621 | } |
| 622 | // Alias the source variation so it can be named directly in "srcs" properties. |
| 623 | mctx.AliasVariation("source") |
| 624 | } |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 625 | } |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 626 | |
| 627 | func LibstdMutator(mctx android.BottomUpMutatorContext) { |
| 628 | if m, ok := mctx.Module().(*Module); ok && m.compiler != nil && !m.compiler.Disabled() { |
| 629 | switch library := m.compiler.(type) { |
| 630 | case libraryInterface: |
| 631 | // Only create a variant if a library is actually being built. |
| 632 | if library.rlib() && !library.sysroot() { |
| 633 | variants := []string{"rlib-std", "dylib-std"} |
| 634 | modules := mctx.CreateLocalVariations(variants...) |
| 635 | |
| 636 | rlib := modules[0].(*Module) |
| 637 | dylib := modules[1].(*Module) |
| 638 | rlib.compiler.(libraryInterface).setRlibStd() |
| 639 | dylib.compiler.(libraryInterface).setDylibStd() |
Ivan Lozano | c08897c | 2021-04-02 12:41:32 -0400 | [diff] [blame] | 640 | if dylib.ModuleBase.ImageVariation().Variation == android.VendorRamdiskVariation { |
Ivan Lozano | 6a88443 | 2020-12-02 09:15:16 -0500 | [diff] [blame] | 641 | // TODO(b/165791368) |
Ivan Lozano | c08897c | 2021-04-02 12:41:32 -0400 | [diff] [blame] | 642 | // Disable rlibs that link against dylib-std on vendor ramdisk variations until those dylib |
Ivan Lozano | 6a88443 | 2020-12-02 09:15:16 -0500 | [diff] [blame] | 643 | // variants are properly supported. |
| 644 | dylib.Disable() |
| 645 | } |
Ivan Lozano | c08897c | 2021-04-02 12:41:32 -0400 | [diff] [blame] | 646 | rlib.Properties.RustSubName += RlibStdlibSuffix |
| 647 | dylib.Properties.RustSubName += DylibStdlibSuffix |
Ivan Lozano | 2b08113 | 2020-09-08 12:46:52 -0400 | [diff] [blame] | 648 | } |
| 649 | } |
| 650 | } |
| 651 | } |