1// Copyright 2016 Google Inc. All rights reserved. 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 cc 16 17import ( 18 "path/filepath" 19 "regexp" 20 "sort" 21 "strconv" 22 "strings" 23 "sync" 24 25 "github.com/google/blueprint/pathtools" 26 27 "android/soong/android" 28 "android/soong/cc/config" 29 "android/soong/genrule" 30) 31 32type StaticSharedLibraryProperties struct { 33 Srcs []string `android:"path,arch_variant"` 34 Cflags []string `android:"path,arch_variant"` 35 36 Enabled *bool `android:"arch_variant"` 37 Whole_static_libs []string `android:"arch_variant"` 38 Static_libs []string `android:"arch_variant"` 39 Shared_libs []string `android:"arch_variant"` 40 System_shared_libs []string `android:"arch_variant"` 41 42 Export_shared_lib_headers []string `android:"arch_variant"` 43 Export_static_lib_headers []string `android:"arch_variant"` 44} 45 46type LibraryProperties struct { 47 Static StaticSharedLibraryProperties `android:"arch_variant"` 48 Shared StaticSharedLibraryProperties `android:"arch_variant"` 49 50 // local file name to pass to the linker as -unexported_symbols_list 51 Unexported_symbols_list *string `android:"path,arch_variant"` 52 // local file name to pass to the linker as -force_symbols_not_weak_list 53 Force_symbols_not_weak_list *string `android:"path,arch_variant"` 54 // local file name to pass to the linker as -force_symbols_weak_list 55 Force_symbols_weak_list *string `android:"path,arch_variant"` 56 57 // rename host libraries to prevent overlap with system installed libraries 58 Unique_host_soname *bool 59 60 Aidl struct { 61 // export headers generated from .aidl sources 62 Export_aidl_headers *bool 63 } 64 65 Proto struct { 66 // export headers generated from .proto sources 67 Export_proto_headers *bool 68 } 69 70 Sysprop struct { 71 // Whether platform owns this sysprop library. 72 Platform *bool 73 } `blueprint:"mutated"` 74 75 Static_ndk_lib *bool 76 77 Stubs struct { 78 // Relative path to the symbol map. The symbol map provides the list of 79 // symbols that are exported for stubs variant of this library. 80 Symbol_file *string `android:"path"` 81 82 // List versions to generate stubs libs for. 83 Versions []string 84 } 85 86 // set the name of the output 87 Stem *string `android:"arch_variant"` 88 89 // Names of modules to be overridden. Listed modules can only be other shared libraries 90 // (in Make or Soong). 91 // This does not completely prevent installation of the overridden libraries, but if both 92 // binaries would be installed by default (in PRODUCT_PACKAGES) the other library will be removed 93 // from PRODUCT_PACKAGES. 94 Overrides []string 95 96 // Properties for ABI compatibility checker 97 Header_abi_checker struct { 98 // Path to a symbol file that specifies the symbols to be included in the generated 99 // ABI dump file 100 Symbol_file *string `android:"path"` 101 102 // Symbol versions that should be ignored from the symbol file 103 Exclude_symbol_versions []string 104 105 // Symbol tags that should be ignored from the symbol file 106 Exclude_symbol_tags []string 107 } 108} 109 110type LibraryMutatedProperties struct { 111 VariantName string `blueprint:"mutated"` 112 113 // Build a static variant 114 BuildStatic bool `blueprint:"mutated"` 115 // Build a shared variant 116 BuildShared bool `blueprint:"mutated"` 117 // This variant is shared 118 VariantIsShared bool `blueprint:"mutated"` 119 // This variant is static 120 VariantIsStatic bool `blueprint:"mutated"` 121 122 // This variant is a stubs lib 123 BuildStubs bool `blueprint:"mutated"` 124 // Version of the stubs lib 125 StubsVersion string `blueprint:"mutated"` 126} 127 128type FlagExporterProperties struct { 129 // list of directories relative to the Blueprints file that will 130 // be added to the include path (using -I) for this module and any module that links 131 // against this module. Directories listed in export_include_dirs do not need to be 132 // listed in local_include_dirs. 133 Export_include_dirs []string `android:"arch_variant"` 134 135 Target struct { 136 Vendor struct { 137 // list of exported include directories, like 138 // export_include_dirs, that will be applied to the 139 // vendor variant of this library. This will overwrite 140 // any other declarations. 141 Override_export_include_dirs []string 142 } 143 } 144} 145 146func init() { 147 android.RegisterModuleType("cc_library_static", LibraryStaticFactory) 148 android.RegisterModuleType("cc_library_shared", LibrarySharedFactory) 149 android.RegisterModuleType("cc_library", LibraryFactory) 150 android.RegisterModuleType("cc_library_host_static", LibraryHostStaticFactory) 151 android.RegisterModuleType("cc_library_host_shared", LibraryHostSharedFactory) 152 android.RegisterModuleType("cc_library_headers", LibraryHeaderFactory) 153} 154 155// cc_library creates both static and/or shared libraries for a device and/or 156// host. By default, a cc_library has a single variant that targets the device. 157// Specifying `host_supported: true` also creates a library that targets the 158// host. 159func LibraryFactory() android.Module { 160 module, _ := NewLibrary(android.HostAndDeviceSupported) 161 return module.Init() 162} 163 164// cc_library_static creates a static library for a device and/or host binary. 165func LibraryStaticFactory() android.Module { 166 module, library := NewLibrary(android.HostAndDeviceSupported) 167 library.BuildOnlyStatic() 168 return module.Init() 169} 170 171// cc_library_shared creates a shared library for a device and/or host. 172func LibrarySharedFactory() android.Module { 173 module, library := NewLibrary(android.HostAndDeviceSupported) 174 library.BuildOnlyShared() 175 return module.Init() 176} 177 178// cc_library_host_static creates a static library that is linkable to a host 179// binary. 180func LibraryHostStaticFactory() android.Module { 181 module, library := NewLibrary(android.HostSupported) 182 library.BuildOnlyStatic() 183 return module.Init() 184} 185 186// cc_library_host_shared creates a shared library that is usable on a host. 187func LibraryHostSharedFactory() android.Module { 188 module, library := NewLibrary(android.HostSupported) 189 library.BuildOnlyShared() 190 return module.Init() 191} 192 193// cc_library_headers contains a set of c/c++ headers which are imported by 194// other soong cc modules using the header_libs property. For best practices, 195// use export_include_dirs property or LOCAL_EXPORT_C_INCLUDE_DIRS for 196// Make. 197func LibraryHeaderFactory() android.Module { 198 module, library := NewLibrary(android.HostAndDeviceSupported) 199 library.HeaderOnly() 200 return module.Init() 201} 202 203type flagExporter struct { 204 Properties FlagExporterProperties 205 206 flags []string 207 flagsDeps android.Paths 208} 209 210func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths { 211 if ctx.useVndk() && f.Properties.Target.Vendor.Override_export_include_dirs != nil { 212 return android.PathsForModuleSrc(ctx, f.Properties.Target.Vendor.Override_export_include_dirs) 213 } else { 214 return android.PathsForModuleSrc(ctx, f.Properties.Export_include_dirs) 215 } 216} 217 218func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) { 219 includeDirs := f.exportedIncludes(ctx) 220 for _, dir := range includeDirs.Strings() { 221 f.flags = append(f.flags, inc+dir) 222 } 223} 224 225func (f *flagExporter) reexportFlags(flags []string) { 226 f.flags = append(f.flags, flags...) 227} 228 229func (f *flagExporter) reexportDeps(deps android.Paths) { 230 f.flagsDeps = append(f.flagsDeps, deps...) 231} 232 233func (f *flagExporter) exportedFlags() []string { 234 return f.flags 235} 236 237func (f *flagExporter) exportedFlagsDeps() android.Paths { 238 return f.flagsDeps 239} 240 241type exportedFlagsProducer interface { 242 exportedFlags() []string 243 exportedFlagsDeps() android.Paths 244} 245 246var _ exportedFlagsProducer = (*flagExporter)(nil) 247 248// libraryDecorator wraps baseCompiler, baseLinker and baseInstaller to provide library-specific 249// functionality: static vs. shared linkage, reusing object files for shared libraries 250type libraryDecorator struct { 251 Properties LibraryProperties 252 MutatedProperties LibraryMutatedProperties 253 254 // For reusing static library objects for shared library 255 reuseObjects Objects 256 reuseExportedFlags []string 257 reuseExportedDeps android.Paths 258 259 // table-of-contents file to optimize out relinking when possible 260 tocFile android.OptionalPath 261 262 flagExporter 263 stripper 264 265 // If we're used as a whole_static_lib, our missing dependencies need 266 // to be given 267 wholeStaticMissingDeps []string 268 269 // For whole_static_libs 270 objects Objects 271 272 // Uses the module's name if empty, but can be overridden. Does not include 273 // shlib suffix. 274 libName string 275 276 sabi *sabi 277 278 // Output archive of gcno coverage information files 279 coverageOutputFile android.OptionalPath 280 281 // linked Source Abi Dump 282 sAbiOutputFile android.OptionalPath 283 284 // Source Abi Diff 285 sAbiDiff android.OptionalPath 286 287 // Location of the static library in the sysroot. Empty if the library is 288 // not included in the NDK. 289 ndkSysrootPath android.Path 290 291 // Location of the linked, unstripped library for shared libraries 292 unstrippedOutputFile android.Path 293 294 // Location of the file that should be copied to dist dir when requested 295 distFile android.OptionalPath 296 297 versionScriptPath android.ModuleGenPath 298 299 post_install_cmds []string 300 301 // If useCoreVariant is true, the vendor variant of a VNDK library is 302 // not installed. 303 useCoreVariant bool 304 305 // Decorated interafaces 306 *baseCompiler 307 *baseLinker 308 *baseInstaller 309} 310 311func (library *libraryDecorator) linkerProps() []interface{} { 312 var props []interface{} 313 props = append(props, library.baseLinker.linkerProps()...) 314 return append(props, 315 &library.Properties, 316 &library.MutatedProperties, 317 &library.flagExporter.Properties, 318 &library.stripper.StripProperties) 319} 320 321func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags { 322 flags = library.baseLinker.linkerFlags(ctx, flags) 323 324 // MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because 325 // all code is position independent, and then those warnings get promoted to 326 // errors. 327 if !ctx.Windows() { 328 flags.CFlags = append(flags.CFlags, "-fPIC") 329 } 330 331 if library.static() { 332 flags.CFlags = append(flags.CFlags, library.Properties.Static.Cflags...) 333 } else if library.shared() { 334 flags.CFlags = append(flags.CFlags, library.Properties.Shared.Cflags...) 335 } 336 337 if library.shared() { 338 libName := library.getLibName(ctx) 339 var f []string 340 if ctx.toolchain().Bionic() { 341 f = append(f, 342 "-nostdlib", 343 "-Wl,--gc-sections", 344 ) 345 } 346 347 if ctx.Darwin() { 348 f = append(f, 349 "-dynamiclib", 350 "-single_module", 351 "-install_name @rpath/"+libName+flags.Toolchain.ShlibSuffix(), 352 ) 353 if ctx.Arch().ArchType == android.X86 { 354 f = append(f, 355 "-read_only_relocs suppress", 356 ) 357 } 358 } else { 359 f = append(f, 360 "-shared", 361 "-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix()) 362 } 363 364 flags.LdFlags = append(f, flags.LdFlags...) 365 } 366 367 return flags 368} 369 370func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags { 371 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx) 372 if len(exportIncludeDirs) > 0 { 373 f := includeDirsToFlags(exportIncludeDirs) 374 flags.GlobalFlags = append(flags.GlobalFlags, f) 375 flags.YasmFlags = append(flags.YasmFlags, f) 376 } 377 378 flags = library.baseCompiler.compilerFlags(ctx, flags, deps) 379 if library.buildStubs() { 380 // Remove -include <file> when compiling stubs. Otherwise, the force included 381 // headers might cause conflicting types error with the symbols in the 382 // generated stubs source code. e.g. 383 // double acos(double); // in header 384 // void acos() {} // in the generated source code 385 removeInclude := func(flags []string) []string { 386 ret := flags[:0] 387 for _, f := range flags { 388 if strings.HasPrefix(f, "-include ") { 389 continue 390 } 391 ret = append(ret, f) 392 } 393 return ret 394 } 395 flags.GlobalFlags = removeInclude(flags.GlobalFlags) 396 flags.CFlags = removeInclude(flags.CFlags) 397 398 flags = addStubLibraryCompilerFlags(flags) 399 } 400 return flags 401} 402 403func extractExportIncludesFromFlags(flags []string) []string { 404 // This method is used in the generation of rules which produce 405 // abi-dumps for source files. Exported headers are needed to infer the 406 // abi exported by a library and filter out the rest of the abi dumped 407 // from a source. We extract the include flags exported by a library. 408 // This includes the flags exported which are re-exported from static 409 // library dependencies, exported header library dependencies and 410 // generated header dependencies. -isystem headers are not included 411 // since for bionic libraries, abi-filtering is taken care of by version 412 // scripts. 413 var exportedIncludes []string 414 for _, flag := range flags { 415 if strings.HasPrefix(flag, "-I") { 416 exportedIncludes = append(exportedIncludes, flag) 417 } 418 } 419 return exportedIncludes 420} 421 422func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { 423 if library.buildStubs() { 424 objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex") 425 library.versionScriptPath = versionScript 426 return objs 427 } 428 429 if !library.buildShared() && !library.buildStatic() { 430 if len(library.baseCompiler.Properties.Srcs) > 0 { 431 ctx.PropertyErrorf("srcs", "cc_library_headers must not have any srcs") 432 } 433 if len(library.Properties.Static.Srcs) > 0 { 434 ctx.PropertyErrorf("static.srcs", "cc_library_headers must not have any srcs") 435 } 436 if len(library.Properties.Shared.Srcs) > 0 { 437 ctx.PropertyErrorf("shared.srcs", "cc_library_headers must not have any srcs") 438 } 439 return Objects{} 440 } 441 if ctx.shouldCreateVndkSourceAbiDump() || library.sabi.Properties.CreateSAbiDumps { 442 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx) 443 var SourceAbiFlags []string 444 for _, dir := range exportIncludeDirs.Strings() { 445 SourceAbiFlags = append(SourceAbiFlags, "-I"+dir) 446 } 447 for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) { 448 SourceAbiFlags = append(SourceAbiFlags, reexportedInclude) 449 } 450 flags.SAbiFlags = SourceAbiFlags 451 total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) + 452 len(library.Properties.Static.Srcs) 453 if total_length > 0 { 454 flags.SAbiDump = true 455 } 456 } 457 objs := library.baseCompiler.compile(ctx, flags, deps) 458 library.reuseObjects = objs 459 buildFlags := flagsToBuilderFlags(flags) 460 461 if library.static() { 462 srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs) 463 objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary, 464 srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps)) 465 } else if library.shared() { 466 srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs) 467 objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary, 468 srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps)) 469 } 470 471 return objs 472} 473 474type libraryInterface interface { 475 getWholeStaticMissingDeps() []string 476 static() bool 477 objs() Objects 478 reuseObjs() (Objects, []string, android.Paths) 479 toc() android.OptionalPath 480 481 // Returns true if the build options for the module have selected a static or shared build 482 buildStatic() bool 483 buildShared() bool 484 485 // Sets whether a specific variant is static or shared 486 setStatic() 487 setShared() 488} 489 490func (library *libraryDecorator) getLibName(ctx ModuleContext) string { 491 name := library.libName 492 if name == "" { 493 name = String(library.Properties.Stem) 494 if name == "" { 495 name = ctx.baseModuleName() 496 } 497 } 498 499 if ctx.isVndkExt() { 500 name = ctx.getVndkExtendsModuleName() 501 } 502 503 if ctx.Host() && Bool(library.Properties.Unique_host_soname) { 504 if !strings.HasSuffix(name, "-host") { 505 name = name + "-host" 506 } 507 } 508 509 return name + library.MutatedProperties.VariantName 510} 511 512var versioningMacroNamesListMutex sync.Mutex 513 514func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) { 515 location := InstallInSystem 516 if library.baseLinker.sanitize.inSanitizerDir() { 517 location = InstallInSanitizerDir 518 } 519 library.baseInstaller.location = location 520 library.baseLinker.linkerInit(ctx) 521 // Let baseLinker know whether this variant is for stubs or not, so that 522 // it can omit things that are not required for linking stubs. 523 library.baseLinker.dynamicProperties.BuildStubs = library.buildStubs() 524 525 if library.buildStubs() { 526 macroNames := versioningMacroNamesList(ctx.Config()) 527 myName := versioningMacroName(ctx.ModuleName()) 528 versioningMacroNamesListMutex.Lock() 529 defer versioningMacroNamesListMutex.Unlock() 530 if (*macroNames)[myName] == "" { 531 (*macroNames)[myName] = ctx.ModuleName() 532 } else if (*macroNames)[myName] != ctx.ModuleName() { 533 ctx.ModuleErrorf("Macro name %q for versioning conflicts with macro name from module %q ", myName, (*macroNames)[myName]) 534 } 535 } 536} 537 538func (library *libraryDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps { 539 deps = library.baseCompiler.compilerDeps(ctx, deps) 540 541 return deps 542} 543 544func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps { 545 if library.static() { 546 if library.Properties.Static.System_shared_libs != nil { 547 library.baseLinker.Properties.System_shared_libs = library.Properties.Static.System_shared_libs 548 } 549 } else if library.shared() { 550 if library.Properties.Shared.System_shared_libs != nil { 551 library.baseLinker.Properties.System_shared_libs = library.Properties.Shared.System_shared_libs 552 } 553 } 554 555 deps = library.baseLinker.linkerDeps(ctx, deps) 556 557 if library.static() { 558 deps.WholeStaticLibs = append(deps.WholeStaticLibs, 559 library.Properties.Static.Whole_static_libs...) 560 deps.StaticLibs = append(deps.StaticLibs, library.Properties.Static.Static_libs...) 561 deps.SharedLibs = append(deps.SharedLibs, library.Properties.Static.Shared_libs...) 562 563 deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, library.Properties.Static.Export_shared_lib_headers...) 564 deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, library.Properties.Static.Export_static_lib_headers...) 565 } else if library.shared() { 566 if ctx.toolchain().Bionic() && !Bool(library.baseLinker.Properties.Nocrt) { 567 if !ctx.useSdk() { 568 deps.CrtBegin = "crtbegin_so" 569 deps.CrtEnd = "crtend_so" 570 } else { 571 // TODO(danalbert): Add generation of crt objects. 572 // For `sdk_version: "current"`, we don't actually have a 573 // freshly generated set of CRT objects. Use the last stable 574 // version. 575 version := ctx.sdkVersion() 576 if version == "current" { 577 version = getCurrentNdkPrebuiltVersion(ctx) 578 } 579 deps.CrtBegin = "ndk_crtbegin_so." + version 580 deps.CrtEnd = "ndk_crtend_so." + version 581 } 582 } 583 deps.WholeStaticLibs = append(deps.WholeStaticLibs, library.Properties.Shared.Whole_static_libs...) 584 deps.StaticLibs = append(deps.StaticLibs, library.Properties.Shared.Static_libs...) 585 deps.SharedLibs = append(deps.SharedLibs, library.Properties.Shared.Shared_libs...) 586 587 deps.ReexportSharedLibHeaders = append(deps.ReexportSharedLibHeaders, library.Properties.Shared.Export_shared_lib_headers...) 588 deps.ReexportStaticLibHeaders = append(deps.ReexportStaticLibHeaders, library.Properties.Shared.Export_static_lib_headers...) 589 } 590 if ctx.useVndk() { 591 deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs) 592 deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Vendor.Exclude_shared_libs) 593 deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs) 594 deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Vendor.Exclude_shared_libs) 595 deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Vendor.Exclude_static_libs) 596 } 597 if ctx.inRecovery() { 598 deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs) 599 deps.SharedLibs = removeListFromList(deps.SharedLibs, library.baseLinker.Properties.Target.Recovery.Exclude_shared_libs) 600 deps.StaticLibs = removeListFromList(deps.StaticLibs, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs) 601 deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, library.baseLinker.Properties.Target.Recovery.Exclude_shared_libs) 602 deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, library.baseLinker.Properties.Target.Recovery.Exclude_static_libs) 603 } 604 605 return deps 606} 607 608func (library *libraryDecorator) linkStatic(ctx ModuleContext, 609 flags Flags, deps PathDeps, objs Objects) android.Path { 610 611 library.objects = deps.WholeStaticLibObjs.Copy() 612 library.objects = library.objects.Append(objs) 613 614 fileName := ctx.ModuleName() + library.MutatedProperties.VariantName + staticLibraryExtension 615 outputFile := android.PathForModuleOut(ctx, fileName) 616 builderFlags := flagsToBuilderFlags(flags) 617 618 if Bool(library.baseLinker.Properties.Use_version_lib) { 619 if ctx.Host() { 620 versionedOutputFile := outputFile 621 outputFile = android.PathForModuleOut(ctx, "unversioned", fileName) 622 library.injectVersionSymbol(ctx, outputFile, versionedOutputFile) 623 } else { 624 versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName) 625 library.distFile = android.OptionalPathForPath(versionedOutputFile) 626 library.injectVersionSymbol(ctx, outputFile, versionedOutputFile) 627 } 628 } 629 630 TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles) 631 632 library.coverageOutputFile = TransformCoverageFilesToLib(ctx, library.objects, builderFlags, 633 ctx.ModuleName()+library.MutatedProperties.VariantName) 634 635 library.wholeStaticMissingDeps = ctx.GetMissingDependencies() 636 637 ctx.CheckbuildFile(outputFile) 638 639 return outputFile 640} 641 642func (library *libraryDecorator) linkShared(ctx ModuleContext, 643 flags Flags, deps PathDeps, objs Objects) android.Path { 644 645 var linkerDeps android.Paths 646 linkerDeps = append(linkerDeps, flags.LdFlagsDeps...) 647 648 unexportedSymbols := ctx.ExpandOptionalSource(library.Properties.Unexported_symbols_list, "unexported_symbols_list") 649 forceNotWeakSymbols := ctx.ExpandOptionalSource(library.Properties.Force_symbols_not_weak_list, "force_symbols_not_weak_list") 650 forceWeakSymbols := ctx.ExpandOptionalSource(library.Properties.Force_symbols_weak_list, "force_symbols_weak_list") 651 if !ctx.Darwin() { 652 if unexportedSymbols.Valid() { 653 ctx.PropertyErrorf("unexported_symbols_list", "Only supported on Darwin") 654 } 655 if forceNotWeakSymbols.Valid() { 656 ctx.PropertyErrorf("force_symbols_not_weak_list", "Only supported on Darwin") 657 } 658 if forceWeakSymbols.Valid() { 659 ctx.PropertyErrorf("force_symbols_weak_list", "Only supported on Darwin") 660 } 661 } else { 662 if unexportedSymbols.Valid() { 663 flags.LdFlags = append(flags.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String()) 664 linkerDeps = append(linkerDeps, unexportedSymbols.Path()) 665 } 666 if forceNotWeakSymbols.Valid() { 667 flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_not_weak_list,"+forceNotWeakSymbols.String()) 668 linkerDeps = append(linkerDeps, forceNotWeakSymbols.Path()) 669 } 670 if forceWeakSymbols.Valid() { 671 flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_weak_list,"+forceWeakSymbols.String()) 672 linkerDeps = append(linkerDeps, forceWeakSymbols.Path()) 673 } 674 } 675 if library.buildStubs() { 676 linkerScriptFlags := "-Wl,--version-script," + library.versionScriptPath.String() 677 flags.LdFlags = append(flags.LdFlags, linkerScriptFlags) 678 linkerDeps = append(linkerDeps, library.versionScriptPath) 679 } 680 681 fileName := library.getLibName(ctx) + flags.Toolchain.ShlibSuffix() 682 outputFile := android.PathForModuleOut(ctx, fileName) 683 ret := outputFile 684 685 builderFlags := flagsToBuilderFlags(flags) 686 687 // Optimize out relinking against shared libraries whose interface hasn't changed by 688 // depending on a table of contents file instead of the library itself. 689 tocPath := outputFile.RelPathString() 690 tocPath = pathtools.ReplaceExtension(tocPath, flags.Toolchain.ShlibSuffix()[1:]+".toc") 691 tocFile := android.PathForOutput(ctx, tocPath) 692 library.tocFile = android.OptionalPathForPath(tocFile) 693 TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags) 694 695 if library.stripper.needsStrip(ctx) { 696 if ctx.Darwin() { 697 builderFlags.stripUseGnuStrip = true 698 } 699 strippedOutputFile := outputFile 700 outputFile = android.PathForModuleOut(ctx, "unstripped", fileName) 701 library.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags) 702 } 703 704 library.unstrippedOutputFile = outputFile 705 706 if Bool(library.baseLinker.Properties.Use_version_lib) { 707 if ctx.Host() { 708 versionedOutputFile := outputFile 709 outputFile = android.PathForModuleOut(ctx, "unversioned", fileName) 710 library.injectVersionSymbol(ctx, outputFile, versionedOutputFile) 711 } else { 712 versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName) 713 library.distFile = android.OptionalPathForPath(versionedOutputFile) 714 715 if library.stripper.needsStrip(ctx) { 716 out := android.PathForModuleOut(ctx, "versioned-stripped", fileName) 717 library.distFile = android.OptionalPathForPath(out) 718 library.stripper.strip(ctx, versionedOutputFile, out, builderFlags) 719 } 720 721 library.injectVersionSymbol(ctx, outputFile, versionedOutputFile) 722 } 723 } 724 725 sharedLibs := deps.EarlySharedLibs 726 sharedLibs = append(sharedLibs, deps.SharedLibs...) 727 sharedLibs = append(sharedLibs, deps.LateSharedLibs...) 728 729 linkerDeps = append(linkerDeps, deps.EarlySharedLibsDeps...) 730 linkerDeps = append(linkerDeps, deps.SharedLibsDeps...) 731 linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...) 732 linkerDeps = append(linkerDeps, objs.tidyFiles...) 733 734 TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, 735 deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs, 736 linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile) 737 738 objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...) 739 objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...) 740 741 objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.StaticLibObjs.sAbiDumpFiles...) 742 objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.WholeStaticLibObjs.sAbiDumpFiles...) 743 744 library.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, library.getLibName(ctx)) 745 library.linkSAbiDumpFiles(ctx, objs, fileName, ret) 746 747 return ret 748} 749 750func (library *libraryDecorator) unstrippedOutputFilePath() android.Path { 751 return library.unstrippedOutputFile 752} 753 754func (library *libraryDecorator) nativeCoverage() bool { 755 if library.header() || library.buildStubs() { 756 return false 757 } 758 return true 759} 760 761func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path { 762 isLlndk := inList(ctx.baseModuleName(), llndkLibraries) || inList(ctx.baseModuleName(), ndkMigratedLibs) 763 764 refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk, false) 765 refAbiDumpGzipFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isLlndk, true) 766 767 if refAbiDumpTextFile.Valid() { 768 if refAbiDumpGzipFile.Valid() { 769 ctx.ModuleErrorf( 770 "Two reference ABI dump files are found: %q and %q. Please delete the stale one.", 771 refAbiDumpTextFile, refAbiDumpGzipFile) 772 return nil 773 } 774 return refAbiDumpTextFile.Path() 775 } 776 if refAbiDumpGzipFile.Valid() { 777 return UnzipRefDump(ctx, refAbiDumpGzipFile.Path(), fileName) 778 } 779 return nil 780} 781 782func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) { 783 if len(objs.sAbiDumpFiles) > 0 && ctx.shouldCreateVndkSourceAbiDump() { 784 vndkVersion := ctx.DeviceConfig().PlatformVndkVersion() 785 if ver := ctx.DeviceConfig().VndkVersion(); ver != "" && ver != "current" { 786 vndkVersion = ver 787 } 788 789 exportIncludeDirs := library.flagExporter.exportedIncludes(ctx) 790 var SourceAbiFlags []string 791 for _, dir := range exportIncludeDirs.Strings() { 792 SourceAbiFlags = append(SourceAbiFlags, "-I"+dir) 793 } 794 for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) { 795 SourceAbiFlags = append(SourceAbiFlags, reexportedInclude) 796 } 797 exportedHeaderFlags := strings.Join(SourceAbiFlags, " ") 798 library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags, 799 android.OptionalPathForModuleSrc(ctx, library.Properties.Header_abi_checker.Symbol_file), 800 library.Properties.Header_abi_checker.Exclude_symbol_versions, 801 library.Properties.Header_abi_checker.Exclude_symbol_tags) 802 803 refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName) 804 if refAbiDumpFile != nil { 805 library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(), 806 refAbiDumpFile, fileName, exportedHeaderFlags, ctx.isLlndk(), ctx.isVndkExt()) 807 } 808 } 809} 810 811func (library *libraryDecorator) link(ctx ModuleContext, 812 flags Flags, deps PathDeps, objs Objects) android.Path { 813 814 objs = deps.Objs.Copy().Append(objs) 815 var out android.Path 816 if library.static() || library.header() { 817 out = library.linkStatic(ctx, flags, deps, objs) 818 } else { 819 out = library.linkShared(ctx, flags, deps, objs) 820 } 821 822 library.exportIncludes(ctx, "-I") 823 library.reexportFlags(deps.ReexportedFlags) 824 library.reexportDeps(deps.ReexportedFlagsDeps) 825 826 if Bool(library.Properties.Aidl.Export_aidl_headers) { 827 if library.baseCompiler.hasSrcExt(".aidl") { 828 flags := []string{ 829 "-I" + android.PathForModuleGen(ctx, "aidl").String(), 830 } 831 library.reexportFlags(flags) 832 library.reuseExportedFlags = append(library.reuseExportedFlags, flags...) 833 library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to aidl deps 834 library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...) 835 } 836 } 837 838 if Bool(library.Properties.Proto.Export_proto_headers) { 839 if library.baseCompiler.hasSrcExt(".proto") { 840 includes := []string{} 841 if flags.proto.CanonicalPathFromRoot { 842 includes = append(includes, "-I"+flags.proto.SubDir.String()) 843 } 844 includes = append(includes, "-I"+flags.proto.Dir.String()) 845 library.reexportFlags(includes) 846 library.reuseExportedFlags = append(library.reuseExportedFlags, includes...) 847 library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to proto deps 848 library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...) 849 } 850 } 851 852 if library.baseCompiler.hasSrcExt(".sysprop") { 853 internalFlags := []string{ 854 "-I" + android.PathForModuleGen(ctx, "sysprop", "include").String(), 855 } 856 systemFlags := []string{ 857 "-I" + android.PathForModuleGen(ctx, "sysprop/system", "include").String(), 858 } 859 860 flags := internalFlags 861 862 if library.Properties.Sysprop.Platform != nil { 863 isProduct := ctx.ProductSpecific() && !ctx.useVndk() 864 isVendor := ctx.useVndk() 865 isOwnerPlatform := Bool(library.Properties.Sysprop.Platform) 866 867 useSystem := isProduct || (isOwnerPlatform == isVendor) 868 869 if useSystem { 870 flags = systemFlags 871 } 872 } 873 874 library.reexportFlags(flags) 875 library.reexportDeps(library.baseCompiler.pathDeps) 876 library.reuseExportedFlags = append(library.reuseExportedFlags, flags...) 877 } 878 879 if library.buildStubs() { 880 library.reexportFlags([]string{"-D" + versioningMacroName(ctx.ModuleName()) + "=" + library.stubsVersion()}) 881 } 882 883 return out 884} 885 886func (library *libraryDecorator) buildStatic() bool { 887 return library.MutatedProperties.BuildStatic && BoolDefault(library.Properties.Static.Enabled, true) 888} 889 890func (library *libraryDecorator) buildShared() bool { 891 return library.MutatedProperties.BuildShared && BoolDefault(library.Properties.Shared.Enabled, true) 892} 893 894func (library *libraryDecorator) getWholeStaticMissingDeps() []string { 895 return append([]string(nil), library.wholeStaticMissingDeps...) 896} 897 898func (library *libraryDecorator) objs() Objects { 899 return library.objects 900} 901 902func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) { 903 return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps 904} 905 906func (library *libraryDecorator) toc() android.OptionalPath { 907 return library.tocFile 908} 909 910func (library *libraryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext, file android.Path) { 911 dir := library.baseInstaller.installDir(ctx) 912 dirOnDevice := android.InstallPathToOnDevicePath(ctx, dir) 913 target := "/" + filepath.Join("apex", "com.android.runtime", dir.Base(), "bionic", file.Base()) 914 ctx.InstallAbsoluteSymlink(dir, file.Base(), target) 915 library.post_install_cmds = append(library.post_install_cmds, makeSymlinkCmd(dirOnDevice, file.Base(), target)) 916} 917 918func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { 919 if library.shared() { 920 if ctx.Device() && ctx.useVndk() { 921 if ctx.isVndkSp() { 922 library.baseInstaller.subDir = "vndk-sp" 923 } else if ctx.isVndk() { 924 if ctx.DeviceConfig().VndkUseCoreVariant() && !ctx.mustUseVendorVariant() { 925 library.useCoreVariant = true 926 } 927 library.baseInstaller.subDir = "vndk" 928 } 929 930 // Append a version to vndk or vndk-sp directories on the system partition. 931 if ctx.isVndk() && !ctx.isVndkExt() { 932 vndkVersion := ctx.DeviceConfig().PlatformVndkVersion() 933 if vndkVersion != "current" && vndkVersion != "" { 934 library.baseInstaller.subDir += "-" + vndkVersion 935 } 936 } 937 } else if len(library.Properties.Stubs.Versions) > 0 && android.DirectlyInAnyApex(ctx, ctx.ModuleName()) { 938 // Bionic libraries (e.g. libc.so) is installed to the bootstrap subdirectory. 939 // The original path becomes a symlink to the corresponding file in the 940 // runtime APEX. 941 if isBionic(ctx.baseModuleName()) && !library.buildStubs() && ctx.Arch().Native && !ctx.inRecovery() { 942 if ctx.Device() { 943 library.installSymlinkToRuntimeApex(ctx, file) 944 } 945 library.baseInstaller.subDir = "bootstrap" 946 } 947 } 948 library.baseInstaller.install(ctx, file) 949 } 950 951 if Bool(library.Properties.Static_ndk_lib) && library.static() && 952 !ctx.useVndk() && !ctx.inRecovery() && ctx.Device() && 953 library.baseLinker.sanitize.isUnsanitizedVariant() && 954 !library.buildStubs() { 955 installPath := getNdkSysrootBase(ctx).Join( 956 ctx, "usr/lib", config.NDKTriple(ctx.toolchain()), file.Base()) 957 958 ctx.ModuleBuild(pctx, android.ModuleBuildParams{ 959 Rule: android.Cp, 960 Description: "install " + installPath.Base(), 961 Output: installPath, 962 Input: file, 963 }) 964 965 library.ndkSysrootPath = installPath 966 } 967} 968 969func (library *libraryDecorator) static() bool { 970 return library.MutatedProperties.VariantIsStatic 971} 972 973func (library *libraryDecorator) shared() bool { 974 return library.MutatedProperties.VariantIsShared 975} 976 977func (library *libraryDecorator) header() bool { 978 return !library.static() && !library.shared() 979} 980 981func (library *libraryDecorator) setStatic() { 982 library.MutatedProperties.VariantIsStatic = true 983 library.MutatedProperties.VariantIsShared = false 984} 985 986func (library *libraryDecorator) setShared() { 987 library.MutatedProperties.VariantIsStatic = false 988 library.MutatedProperties.VariantIsShared = true 989} 990 991func (library *libraryDecorator) BuildOnlyStatic() { 992 library.MutatedProperties.BuildShared = false 993} 994 995func (library *libraryDecorator) BuildOnlyShared() { 996 library.MutatedProperties.BuildStatic = false 997} 998 999func (library *libraryDecorator) HeaderOnly() { 1000 library.MutatedProperties.BuildShared = false 1001 library.MutatedProperties.BuildStatic = false 1002} 1003 1004func (library *libraryDecorator) buildStubs() bool { 1005 return library.MutatedProperties.BuildStubs 1006} 1007 1008func (library *libraryDecorator) stubsVersion() string { 1009 return library.MutatedProperties.StubsVersion 1010} 1011 1012var versioningMacroNamesListKey = android.NewOnceKey("versioningMacroNamesList") 1013 1014func versioningMacroNamesList(config android.Config) *map[string]string { 1015 return config.Once(versioningMacroNamesListKey, func() interface{} { 1016 m := make(map[string]string) 1017 return &m 1018 }).(*map[string]string) 1019} 1020 1021// alphanumeric and _ characters are preserved. 1022// other characters are all converted to _ 1023var charsNotForMacro = regexp.MustCompile("[^a-zA-Z0-9_]+") 1024 1025func versioningMacroName(moduleName string) string { 1026 macroName := charsNotForMacro.ReplaceAllString(moduleName, "_") 1027 macroName = strings.ToUpper(moduleName) 1028 return "__" + macroName + "_API__" 1029} 1030 1031func NewLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) { 1032 module := newModule(hod, android.MultilibBoth) 1033 1034 library := &libraryDecorator{ 1035 MutatedProperties: LibraryMutatedProperties{ 1036 BuildShared: true, 1037 BuildStatic: true, 1038 }, 1039 baseCompiler: NewBaseCompiler(), 1040 baseLinker: NewBaseLinker(module.sanitize), 1041 baseInstaller: NewBaseInstaller("lib", "lib64", InstallInSystem), 1042 sabi: module.sabi, 1043 } 1044 1045 module.compiler = library 1046 module.linker = library 1047 module.installer = library 1048 1049 return module, library 1050} 1051 1052// connects a shared library to a static library in order to reuse its .o files to avoid 1053// compiling source files twice. 1054func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Module) { 1055 if staticCompiler, ok := static.compiler.(*libraryDecorator); ok { 1056 sharedCompiler := shared.compiler.(*libraryDecorator) 1057 1058 // Check libraries in addition to cflags, since libraries may be exporting different 1059 // include directories. 1060 if len(staticCompiler.Properties.Static.Cflags) == 0 && 1061 len(sharedCompiler.Properties.Shared.Cflags) == 0 && 1062 len(staticCompiler.Properties.Static.Whole_static_libs) == 0 && 1063 len(sharedCompiler.Properties.Shared.Whole_static_libs) == 0 && 1064 len(staticCompiler.Properties.Static.Static_libs) == 0 && 1065 len(sharedCompiler.Properties.Shared.Static_libs) == 0 && 1066 len(staticCompiler.Properties.Static.Shared_libs) == 0 && 1067 len(sharedCompiler.Properties.Shared.Shared_libs) == 0 && 1068 staticCompiler.Properties.Static.System_shared_libs == nil && 1069 sharedCompiler.Properties.Shared.System_shared_libs == nil { 1070 1071 mctx.AddInterVariantDependency(reuseObjTag, shared, static) 1072 sharedCompiler.baseCompiler.Properties.OriginalSrcs = 1073 sharedCompiler.baseCompiler.Properties.Srcs 1074 sharedCompiler.baseCompiler.Properties.Srcs = nil 1075 sharedCompiler.baseCompiler.Properties.Generated_sources = nil 1076 } else { 1077 // This dep is just to reference static variant from shared variant 1078 mctx.AddInterVariantDependency(staticVariantTag, shared, static) 1079 } 1080 } 1081} 1082 1083func LinkageMutator(mctx android.BottomUpMutatorContext) { 1084 if m, ok := mctx.Module().(*Module); ok && m.linker != nil { 1085 switch library := m.linker.(type) { 1086 case prebuiltLibraryInterface: 1087 // Always create both the static and shared variants for prebuilt libraries, and then disable the one 1088 // that is not being used. This allows them to share the name of a cc_library module, which requires that 1089 // all the variants of the cc_library also exist on the prebuilt. 1090 modules := mctx.CreateLocalVariations("static", "shared") 1091 static := modules[0].(*Module) 1092 shared := modules[1].(*Module) 1093 1094 static.linker.(prebuiltLibraryInterface).setStatic() 1095 shared.linker.(prebuiltLibraryInterface).setShared() 1096 1097 if !library.buildStatic() { 1098 static.linker.(prebuiltLibraryInterface).disablePrebuilt() 1099 } 1100 if !library.buildShared() { 1101 shared.linker.(prebuiltLibraryInterface).disablePrebuilt() 1102 } 1103 1104 case libraryInterface: 1105 if library.buildStatic() && library.buildShared() { 1106 modules := mctx.CreateLocalVariations("static", "shared") 1107 static := modules[0].(*Module) 1108 shared := modules[1].(*Module) 1109 1110 static.linker.(libraryInterface).setStatic() 1111 shared.linker.(libraryInterface).setShared() 1112 1113 reuseStaticLibrary(mctx, static, shared) 1114 1115 } else if library.buildStatic() { 1116 modules := mctx.CreateLocalVariations("static") 1117 modules[0].(*Module).linker.(libraryInterface).setStatic() 1118 } else if library.buildShared() { 1119 modules := mctx.CreateLocalVariations("shared") 1120 modules[0].(*Module).linker.(libraryInterface).setShared() 1121 } 1122 } 1123 } 1124} 1125 1126var stubVersionsKey = android.NewOnceKey("stubVersions") 1127 1128// maps a module name to the list of stubs versions available for the module 1129func stubsVersionsFor(config android.Config) map[string][]string { 1130 return config.Once(stubVersionsKey, func() interface{} { 1131 return make(map[string][]string) 1132 }).(map[string][]string) 1133} 1134 1135var stubsVersionsLock sync.Mutex 1136 1137func latestStubsVersionFor(config android.Config, name string) string { 1138 versions, ok := stubsVersionsFor(config)[name] 1139 if ok && len(versions) > 0 { 1140 // the versions are alreay sorted in ascending order 1141 return versions[len(versions)-1] 1142 } 1143 return "" 1144} 1145 1146// Version mutator splits a module into the mandatory non-stubs variant 1147// (which is unnamed) and zero or more stubs variants. 1148func VersionMutator(mctx android.BottomUpMutatorContext) { 1149 if m, ok := mctx.Module().(*Module); ok && !m.inRecovery() && m.linker != nil { 1150 if library, ok := m.linker.(*libraryDecorator); ok && library.buildShared() && 1151 len(library.Properties.Stubs.Versions) > 0 { 1152 versions := []string{} 1153 for _, v := range library.Properties.Stubs.Versions { 1154 if _, err := strconv.Atoi(v); err != nil { 1155 mctx.PropertyErrorf("versions", "%q is not a number", v) 1156 } 1157 versions = append(versions, v) 1158 } 1159 sort.Slice(versions, func(i, j int) bool { 1160 left, _ := strconv.Atoi(versions[i]) 1161 right, _ := strconv.Atoi(versions[j]) 1162 return left < right 1163 }) 1164 1165 // save the list of versions for later use 1166 copiedVersions := make([]string, len(versions)) 1167 copy(copiedVersions, versions) 1168 stubsVersionsLock.Lock() 1169 defer stubsVersionsLock.Unlock() 1170 stubsVersionsFor(mctx.Config())[mctx.ModuleName()] = copiedVersions 1171 1172 // "" is for the non-stubs variant 1173 versions = append([]string{""}, versions...) 1174 1175 modules := mctx.CreateVariations(versions...) 1176 for i, m := range modules { 1177 l := m.(*Module).linker.(*libraryDecorator) 1178 if versions[i] != "" { 1179 l.MutatedProperties.BuildStubs = true 1180 l.MutatedProperties.StubsVersion = versions[i] 1181 m.(*Module).Properties.HideFromMake = true 1182 m.(*Module).sanitize = nil 1183 m.(*Module).stl = nil 1184 m.(*Module).Properties.PreventInstall = true 1185 } 1186 } 1187 } else { 1188 mctx.CreateVariations("") 1189 } 1190 return 1191 } 1192 if genrule, ok := mctx.Module().(*genrule.Module); ok { 1193 if props, ok := genrule.Extra.(*GenruleExtraProperties); ok && !props.InRecovery { 1194 mctx.CreateVariations("") 1195 return 1196 } 1197 } 1198} 1199