github.com/westcoastroms/westcoastroms-build@v0.0.0-20190928114312-2350e5a73030/build/soong/java/java.go (about) 1 // Copyright 2015 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 15 package java 16 17 // This file contains the module types for compiling Java for Android, and converts the properties 18 // into the flags and filenames necessary to pass to the Module. The final creation of the rules 19 // is handled in builder.go 20 21 import ( 22 "fmt" 23 "path/filepath" 24 "strconv" 25 "strings" 26 27 "github.com/google/blueprint" 28 "github.com/google/blueprint/proptools" 29 30 "android/soong/android" 31 "android/soong/java/config" 32 ) 33 34 func init() { 35 android.RegisterModuleType("java_defaults", defaultsFactory) 36 37 android.RegisterModuleType("java_library", LibraryFactory(true)) 38 android.RegisterModuleType("java_library_static", LibraryFactory(false)) 39 android.RegisterModuleType("java_library_host", LibraryHostFactory) 40 android.RegisterModuleType("java_binary", BinaryFactory) 41 android.RegisterModuleType("java_binary_host", BinaryHostFactory) 42 android.RegisterModuleType("java_import", ImportFactory) 43 android.RegisterModuleType("java_import_host", ImportFactoryHost) 44 45 android.RegisterSingletonType("logtags", LogtagsSingleton) 46 } 47 48 // TODO: 49 // Autogenerated files: 50 // Renderscript 51 // Post-jar passes: 52 // Proguard 53 // Rmtypedefs 54 // DroidDoc 55 // Findbugs 56 57 type CompilerProperties struct { 58 // list of source files used to compile the Java module. May be .java, .logtags, .proto, 59 // or .aidl files. 60 Srcs []string `android:"arch_variant"` 61 62 // list of source files that should not be used to build the Java module. 63 // This is most useful in the arch/multilib variants to remove non-common files 64 Exclude_srcs []string `android:"arch_variant"` 65 66 // list of directories containing Java resources 67 Java_resource_dirs []string `android:"arch_variant"` 68 69 // list of directories that should be excluded from java_resource_dirs 70 Exclude_java_resource_dirs []string `android:"arch_variant"` 71 72 // list of files to use as Java resources 73 Java_resources []string `android:"arch_variant"` 74 75 // list of files that should be excluded from java_resources 76 Exclude_java_resources []string `android:"arch_variant"` 77 78 // don't build against the default libraries (bootclasspath, legacy-test, core-junit, 79 // ext, and framework for device targets) 80 No_standard_libs *bool 81 82 // don't build against the framework libraries (legacy-test, core-junit, 83 // ext, and framework for device targets) 84 No_framework_libs *bool 85 86 // list of module-specific flags that will be used for javac compiles 87 Javacflags []string `android:"arch_variant"` 88 89 // list of of java libraries that will be in the classpath 90 Libs []string `android:"arch_variant"` 91 92 // list of java libraries that will be compiled into the resulting jar 93 Static_libs []string `android:"arch_variant"` 94 95 // manifest file to be included in resulting jar 96 Manifest *string 97 98 // if not blank, run jarjar using the specified rules file 99 Jarjar_rules *string `android:"arch_variant"` 100 101 // If not blank, set the java version passed to javac as -source and -target 102 Java_version *string 103 104 // If set to false, don't allow this module to be installed. Defaults to true. 105 Installable *bool 106 107 // If set to true, include sources used to compile the module in to the final jar 108 Include_srcs *bool 109 110 // List of modules to use as annotation processors 111 Annotation_processors []string 112 113 // List of classes to pass to javac to use as annotation processors 114 Annotation_processor_classes []string 115 116 // The number of Java source entries each Javac instance can process 117 Javac_shard_size *int64 118 119 // Add host jdk tools.jar to bootclasspath 120 Use_tools_jar *bool 121 122 Openjdk9 struct { 123 // List of source files that should only be used when passing -source 1.9 124 Srcs []string 125 126 // List of javac flags that should only be used when passing -source 1.9 127 Javacflags []string 128 } 129 130 Jacoco struct { 131 // List of classes to include for instrumentation with jacoco to collect coverage 132 // information at runtime when building with coverage enabled. If unset defaults to all 133 // classes. 134 // Supports '*' as the last character of an entry in the list as a wildcard match. 135 // If preceded by '.' it matches all classes in the package and subpackages, otherwise 136 // it matches classes in the package that have the class name as a prefix. 137 Include_filter []string 138 139 // List of classes to exclude from instrumentation with jacoco to collect coverage 140 // information at runtime when building with coverage enabled. Overrides classes selected 141 // by the include_filter property. 142 // Supports '*' as the last character of an entry in the list as a wildcard match. 143 // If preceded by '.' it matches all classes in the package and subpackages, otherwise 144 // it matches classes in the package that have the class name as a prefix. 145 Exclude_filter []string 146 } 147 148 Errorprone struct { 149 // List of javac flags that should only be used when running errorprone. 150 Javacflags []string 151 } 152 153 Proto struct { 154 // List of extra options that will be passed to the proto generator. 155 Output_params []string 156 } 157 158 Instrument bool `blueprint:"mutated"` 159 } 160 161 type CompilerDeviceProperties struct { 162 // list of module-specific flags that will be used for dex compiles 163 Dxflags []string `android:"arch_variant"` 164 165 // if not blank, set to the version of the sdk to compile against 166 Sdk_version *string 167 168 Aidl struct { 169 // Top level directories to pass to aidl tool 170 Include_dirs []string 171 172 // Directories rooted at the Android.bp file to pass to aidl tool 173 Local_include_dirs []string 174 175 // directories that should be added as include directories for any aidl sources of modules 176 // that depend on this module, as well as to aidl for this module. 177 Export_include_dirs []string 178 179 // whether to generate traces (for systrace) for this interface 180 Generate_traces *bool 181 } 182 183 // If true, export a copy of the module as a -hostdex module for host testing. 184 Hostdex *bool 185 186 Dex_preopt struct { 187 // If false, prevent dexpreopting and stripping the dex file from the final jar. Defaults to 188 // true. 189 Enabled *bool 190 191 // If true, generate an app image (.art file) for this module. 192 App_image *bool 193 194 // If true, use a checked-in profile to guide optimization. Defaults to false unless 195 // a matching profile is set or a profile is found in PRODUCT_DEX_PREOPT_PROFILE_DIR 196 // that matches the name of this module, in which case it is defaulted to true. 197 Profile_guided *bool 198 199 // If set, provides the path to profile relative to the Android.bp file. If not set, 200 // defaults to searching for a file that matches the name of this module in the default 201 // profile location set by PRODUCT_DEX_PREOPT_PROFILE_DIR, or empty if not found. 202 Profile *string 203 } 204 205 Optimize struct { 206 // If false, disable all optimization. Defaults to true for apps, false for 207 // libraries and tests. 208 Enabled *bool 209 210 // If true, optimize for size by removing unused code. Defaults to true for apps, 211 // false for libraries and tests. 212 Shrink *bool 213 214 // If true, optimize bytecode. Defaults to false. 215 Optimize *bool 216 217 // If true, obfuscate bytecode. Defaults to false. 218 Obfuscate *bool 219 220 // If true, do not use the flag files generated by aapt that automatically keep 221 // classes referenced by the app manifest. Defaults to false. 222 No_aapt_flags *bool 223 224 // Flags to pass to proguard. 225 Proguard_flags []string 226 227 // Specifies the locations of files containing proguard flags. 228 Proguard_flags_files []string 229 } 230 231 // When targeting 1.9, override the modules to use with --system 232 System_modules *string 233 } 234 235 // Module contains the properties and members used by all java module types 236 type Module struct { 237 android.ModuleBase 238 android.DefaultableModuleBase 239 240 properties CompilerProperties 241 protoProperties android.ProtoProperties 242 deviceProperties CompilerDeviceProperties 243 244 // header jar file suitable for inserting into the bootclasspath/classpath of another compile 245 headerJarFile android.Path 246 247 // full implementation jar file suitable for static dependency of another module compile 248 implementationJarFile android.Path 249 250 // output file containing classes.dex 251 dexJarFile android.Path 252 253 // output file containing uninstrumented classes that will be instrumented by jacoco 254 jacocoReportClassesFile android.Path 255 256 // output file containing mapping of obfuscated names 257 proguardDictionary android.Path 258 259 // output file suitable for installing or running 260 outputFile android.Path 261 262 exportAidlIncludeDirs android.Paths 263 264 logtagsSrcs android.Paths 265 266 // installed file for binary dependency 267 installFile android.Path 268 269 // list of .java files and srcjars that was passed to javac 270 compiledJavaSrcs android.Paths 271 compiledSrcJars android.Paths 272 273 // list of extra progurad flag files 274 extraProguardFlagFiles android.Paths 275 } 276 277 func (j *Module) Srcs() android.Paths { 278 return android.Paths{j.implementationJarFile} 279 } 280 281 var _ android.SourceFileProducer = (*Module)(nil) 282 283 type Dependency interface { 284 HeaderJars() android.Paths 285 ImplementationJars() android.Paths 286 AidlIncludeDirs() android.Paths 287 } 288 289 func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) { 290 android.InitAndroidArchModule(module, hod, android.MultilibCommon) 291 android.InitDefaultableModule(module) 292 } 293 294 type dependencyTag struct { 295 blueprint.BaseDependencyTag 296 name string 297 } 298 299 var ( 300 staticLibTag = dependencyTag{name: "staticlib"} 301 libTag = dependencyTag{name: "javalib"} 302 bootClasspathTag = dependencyTag{name: "bootclasspath"} 303 systemModulesTag = dependencyTag{name: "system modules"} 304 frameworkResTag = dependencyTag{name: "framework-res"} 305 kotlinStdlibTag = dependencyTag{name: "kotlin-stdlib"} 306 proguardRaiseTag = dependencyTag{name: "proguard-raise"} 307 ) 308 309 type sdkDep struct { 310 useModule, useFiles, useDefaultLibs, invalidVersion bool 311 312 module string 313 systemModules string 314 315 frameworkResModule string 316 317 jar android.Path 318 aidl android.Path 319 } 320 321 func sdkStringToNumber(ctx android.BaseContext, v string) int { 322 switch v { 323 case "", "current", "system_current", "test_current", "core_current": 324 return android.FutureApiLevel 325 default: 326 if i, err := strconv.Atoi(android.GetNumericSdkVersion(v)); err != nil { 327 ctx.PropertyErrorf("sdk_version", "invalid sdk version") 328 return -1 329 } else { 330 return i 331 } 332 } 333 } 334 335 func (j *Module) shouldInstrument(ctx android.BaseContext) bool { 336 return j.properties.Instrument && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") 337 } 338 339 func (j *Module) shouldInstrumentStatic(ctx android.BaseContext) bool { 340 return j.shouldInstrument(ctx) && 341 (ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") || 342 ctx.Config().UnbundledBuild()) 343 } 344 345 func decodeSdkDep(ctx android.BaseContext, v string) sdkDep { 346 i := sdkStringToNumber(ctx, v) 347 if i == -1 { 348 // Invalid sdk version, error handled by sdkStringToNumber. 349 return sdkDep{} 350 } 351 352 // Ensures that the specificed system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor apks) 353 // or PRODUCT_SYSTEMSDK_VERSIONS (for other apks or when BOARD_SYSTEMSDK_VERSIONS is not set) 354 if strings.HasPrefix(v, "system_") && i != android.FutureApiLevel { 355 allowed_versions := ctx.DeviceConfig().PlatformSystemSdkVersions() 356 if ctx.DeviceSpecific() || ctx.SocSpecific() { 357 if len(ctx.DeviceConfig().SystemSdkVersions()) > 0 { 358 allowed_versions = ctx.DeviceConfig().SystemSdkVersions() 359 } 360 } 361 version := strings.TrimPrefix(v, "system_") 362 if len(allowed_versions) > 0 && !android.InList(version, allowed_versions) { 363 ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q", 364 v, allowed_versions) 365 } 366 } 367 368 toFile := func(v string) sdkDep { 369 isCore := strings.HasPrefix(v, "core_") 370 if isCore { 371 v = strings.TrimPrefix(v, "core_") 372 } 373 dir := filepath.Join("prebuilts/sdk", v) 374 jar := filepath.Join(dir, "android.jar") 375 if isCore { 376 jar = filepath.Join(dir, "core.jar") 377 } 378 aidl := filepath.Join(dir, "framework.aidl") 379 jarPath := android.ExistentPathForSource(ctx, jar) 380 aidlPath := android.ExistentPathForSource(ctx, aidl) 381 382 if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() { 383 return sdkDep{ 384 invalidVersion: true, 385 module: "sdk_v" + v, 386 } 387 } 388 389 if !jarPath.Valid() { 390 ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, jar) 391 return sdkDep{} 392 } 393 394 if !aidlPath.Valid() { 395 ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, aidl) 396 return sdkDep{} 397 } 398 399 return sdkDep{ 400 useFiles: true, 401 jar: jarPath.Path(), 402 aidl: aidlPath.Path(), 403 } 404 } 405 406 //toModule := func(m string) sdkDep { 407 // return sdkDep{ 408 // useModule: true, 409 // module: m, 410 // systemModules: m + "_system_modules", 411 // frameworkResModule: r, 412 // } 413 //} 414 415 if ctx.Config().UnbundledBuild() && v != "" { 416 return toFile(v) 417 } 418 419 switch v { 420 case "": 421 return sdkDep{ 422 useDefaultLibs: true, 423 frameworkResModule: "framework-res", 424 } 425 // TODO(ccross): re-enable these once we generate stubs, until then 426 // use the stubs in prebuilts/sdk/*current 427 //case "current": 428 // return toModule("android_stubs_current", "framework-res") 429 //case "system_current": 430 // return toModule("android_system_stubs_current", "framework-res") 431 //case "test_current": 432 // return toModule("android_test_stubs_current", "framework-res") 433 default: 434 return toFile(v) 435 } 436 } 437 438 func (j *Module) deps(ctx android.BottomUpMutatorContext) { 439 if ctx.Device() { 440 if !proptools.Bool(j.properties.No_standard_libs) { 441 sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version)) 442 if sdkDep.useDefaultLibs { 443 ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...) 444 if ctx.Config().TargetOpenJDK9() { 445 ctx.AddDependency(ctx.Module(), systemModulesTag, config.DefaultSystemModules) 446 } 447 if !proptools.Bool(j.properties.No_framework_libs) { 448 ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...) 449 } 450 } else if sdkDep.useModule { 451 if ctx.Config().TargetOpenJDK9() { 452 ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules) 453 } 454 ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module) 455 if Bool(j.deviceProperties.Optimize.Enabled) { 456 ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultBootclasspathLibraries...) 457 ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultLibraries...) 458 } 459 } 460 } else if j.deviceProperties.System_modules == nil { 461 ctx.PropertyErrorf("no_standard_libs", 462 "system_modules is required to be set when no_standard_libs is true, did you mean no_framework_libs?") 463 } else if *j.deviceProperties.System_modules != "none" && ctx.Config().TargetOpenJDK9() { 464 ctx.AddDependency(ctx.Module(), systemModulesTag, *j.deviceProperties.System_modules) 465 } 466 if ctx.ModuleName() == "framework" { 467 ctx.AddDependency(ctx.Module(), frameworkResTag, "framework-res") 468 } 469 } 470 471 ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...) 472 ctx.AddDependency(ctx.Module(), staticLibTag, j.properties.Static_libs...) 473 ctx.AddDependency(ctx.Module(), libTag, j.properties.Annotation_processors...) 474 475 android.ExtractSourcesDeps(ctx, j.properties.Srcs) 476 android.ExtractSourcesDeps(ctx, j.properties.Exclude_srcs) 477 android.ExtractSourcesDeps(ctx, j.properties.Java_resources) 478 android.ExtractSourceDeps(ctx, j.properties.Manifest) 479 480 if j.hasSrcExt(".proto") { 481 protoDeps(ctx, &j.protoProperties) 482 } 483 484 if j.hasSrcExt(".kt") { 485 // TODO(ccross): move this to a mutator pass that can tell if generated sources contain 486 // Kotlin files 487 ctx.AddDependency(ctx.Module(), kotlinStdlibTag, "kotlin-stdlib") 488 } 489 490 if j.shouldInstrumentStatic(ctx) { 491 ctx.AddDependency(ctx.Module(), staticLibTag, "jacocoagent") 492 } 493 } 494 495 func hasSrcExt(srcs []string, ext string) bool { 496 for _, src := range srcs { 497 if filepath.Ext(src) == ext { 498 return true 499 } 500 } 501 502 return false 503 } 504 505 func shardPaths(paths android.Paths, shardSize int) []android.Paths { 506 ret := make([]android.Paths, 0, (len(paths)+shardSize-1)/shardSize) 507 for len(paths) > shardSize { 508 ret = append(ret, paths[0:shardSize]) 509 paths = paths[shardSize:] 510 } 511 if len(paths) > 0 { 512 ret = append(ret, paths) 513 } 514 return ret 515 } 516 517 func (j *Module) hasSrcExt(ext string) bool { 518 return hasSrcExt(j.properties.Srcs, ext) 519 } 520 521 func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath, 522 aidlIncludeDirs android.Paths) []string { 523 524 aidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Local_include_dirs) 525 aidlIncludes = append(aidlIncludes, 526 android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)...) 527 aidlIncludes = append(aidlIncludes, 528 android.PathsForSource(ctx, j.deviceProperties.Aidl.Include_dirs)...) 529 530 var flags []string 531 if aidlPreprocess.Valid() { 532 flags = append(flags, "-p"+aidlPreprocess.String()) 533 } else { 534 flags = append(flags, android.JoinWithPrefix(aidlIncludeDirs.Strings(), "-I")) 535 } 536 537 flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I")) 538 flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I")) 539 flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String()) 540 if src := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "src"); src.Valid() { 541 flags = append(flags, "-I"+src.String()) 542 } 543 544 if Bool(j.deviceProperties.Aidl.Generate_traces) { 545 flags = append(flags, "-t") 546 } 547 548 return flags 549 } 550 551 type deps struct { 552 classpath classpath 553 bootClasspath classpath 554 staticJars android.Paths 555 staticHeaderJars android.Paths 556 staticJarResources android.Paths 557 aidlIncludeDirs android.Paths 558 srcJars android.Paths 559 systemModules android.Path 560 aidlPreprocess android.OptionalPath 561 kotlinStdlib android.Paths 562 } 563 564 func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer) { 565 for _, f := range dep.Srcs() { 566 if f.Ext() != ".jar" { 567 ctx.ModuleErrorf("genrule %q must generate files ending with .jar to be used as a libs or static_libs dependency", 568 ctx.OtherModuleName(dep.(blueprint.Module))) 569 } 570 } 571 } 572 573 func checkLinkType(ctx android.ModuleContext, from *Module, to *Library, tag dependencyTag) { 574 if strings.HasPrefix(String(from.deviceProperties.Sdk_version), "core_") { 575 if !strings.HasPrefix(String(to.deviceProperties.Sdk_version), "core_") { 576 ctx.ModuleErrorf("depends on other library %q using non-core Java APIs", 577 ctx.OtherModuleName(to)) 578 } 579 } 580 } 581 582 func (j *Module) collectDeps(ctx android.ModuleContext) deps { 583 var deps deps 584 585 sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version)) 586 if sdkDep.invalidVersion { 587 ctx.AddMissingDependencies([]string{sdkDep.module}) 588 } else if sdkDep.useFiles { 589 // sdkDep.jar is actually equivalent to turbine header.jar. 590 deps.classpath = append(deps.classpath, sdkDep.jar) 591 deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl) 592 } 593 594 ctx.VisitDirectDeps(func(module android.Module) { 595 otherName := ctx.OtherModuleName(module) 596 tag := ctx.OtherModuleDependencyTag(module) 597 598 if to, ok := module.(*Library); ok { 599 switch tag { 600 case bootClasspathTag, libTag, staticLibTag: 601 checkLinkType(ctx, j, to, tag.(dependencyTag)) 602 } 603 } 604 switch dep := module.(type) { 605 case Dependency: 606 switch tag { 607 case bootClasspathTag: 608 deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars()...) 609 case libTag: 610 deps.classpath = append(deps.classpath, dep.HeaderJars()...) 611 case staticLibTag: 612 deps.classpath = append(deps.classpath, dep.HeaderJars()...) 613 deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...) 614 deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...) 615 case frameworkResTag: 616 if ctx.ModuleName() == "framework" { 617 // framework.jar has a one-off dependency on the R.java and Manifest.java files 618 // generated by framework-res.apk 619 deps.srcJars = append(deps.srcJars, dep.(*AndroidApp).aaptSrcJar) 620 } 621 case kotlinStdlibTag: 622 deps.kotlinStdlib = dep.HeaderJars() 623 default: 624 panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName())) 625 } 626 627 deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...) 628 case android.SourceFileProducer: 629 switch tag { 630 case libTag: 631 checkProducesJars(ctx, dep) 632 deps.classpath = append(deps.classpath, dep.Srcs()...) 633 case staticLibTag: 634 checkProducesJars(ctx, dep) 635 deps.classpath = append(deps.classpath, dep.Srcs()...) 636 deps.staticJars = append(deps.staticJars, dep.Srcs()...) 637 deps.staticHeaderJars = append(deps.staticHeaderJars, dep.Srcs()...) 638 case android.DefaultsDepTag, android.SourceDepTag: 639 // Nothing to do 640 default: 641 ctx.ModuleErrorf("dependency on genrule %q may only be in srcs, libs, or static_libs", otherName) 642 } 643 default: 644 switch tag { 645 case android.DefaultsDepTag, android.SourceDepTag: 646 // Nothing to do 647 case systemModulesTag: 648 if deps.systemModules != nil { 649 panic("Found two system module dependencies") 650 } 651 sm := module.(*SystemModules) 652 if sm.outputFile == nil { 653 panic("Missing directory for system module dependency") 654 } 655 deps.systemModules = sm.outputFile 656 default: 657 ctx.ModuleErrorf("depends on non-java module %q", otherName) 658 } 659 } 660 }) 661 662 return deps 663 } 664 665 func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaBuilderFlags { 666 667 var flags javaBuilderFlags 668 669 // javac flags. 670 javacFlags := j.properties.Javacflags 671 if ctx.Config().TargetOpenJDK9() { 672 javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...) 673 } 674 if ctx.Config().MinimizeJavaDebugInfo() { 675 // Override the -g flag passed globally to remove local variable debug info to reduce 676 // disk and memory usage. 677 javacFlags = append(javacFlags, "-g:source,lines") 678 } 679 if len(javacFlags) > 0 { 680 // optimization. 681 ctx.Variable(pctx, "javacFlags", strings.Join(javacFlags, " ")) 682 flags.javacFlags = "$javacFlags" 683 } 684 685 if len(j.properties.Errorprone.Javacflags) > 0 { 686 flags.errorProneExtraJavacFlags = strings.Join(j.properties.Errorprone.Javacflags, " ") 687 } 688 689 // javaVersion flag. 690 sdk := sdkStringToNumber(ctx, String(j.deviceProperties.Sdk_version)) 691 if j.properties.Java_version != nil { 692 flags.javaVersion = *j.properties.Java_version 693 } else if ctx.Device() && sdk <= 23 { 694 flags.javaVersion = "1.7" 695 } else if ctx.Device() && sdk <= 26 || !ctx.Config().TargetOpenJDK9() { 696 flags.javaVersion = "1.8" 697 } else if ctx.Device() && String(j.deviceProperties.Sdk_version) != "" && sdk == android.FutureApiLevel { 698 // TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current" 699 flags.javaVersion = "1.8" 700 } else { 701 flags.javaVersion = "1.9" 702 } 703 704 // classpath 705 flags.bootClasspath = append(flags.bootClasspath, deps.bootClasspath...) 706 flags.classpath = append(flags.classpath, deps.classpath...) 707 708 if len(flags.bootClasspath) == 0 && ctx.Host() && !ctx.Config().TargetOpenJDK9() && 709 !Bool(j.properties.No_standard_libs) && 710 inList(flags.javaVersion, []string{"1.6", "1.7", "1.8"}) { 711 // Give host-side tools a version of OpenJDK's standard libraries 712 // close to what they're targeting. As of Dec 2017, AOSP is only 713 // bundling OpenJDK 8 and 9, so nothing < 8 is available. 714 // 715 // When building with OpenJDK 8, the following should have no 716 // effect since those jars would be available by default. 717 // 718 // When building with OpenJDK 9 but targeting a version < 1.8, 719 // putting them on the bootclasspath means that: 720 // a) code can't (accidentally) refer to OpenJDK 9 specific APIs 721 // b) references to existing APIs are not reinterpreted in an 722 // OpenJDK 9-specific way, eg. calls to subclasses of 723 // java.nio.Buffer as in http://b/70862583 724 java8Home := ctx.Config().Getenv("ANDROID_JAVA8_HOME") 725 flags.bootClasspath = append(flags.bootClasspath, 726 android.PathForSource(ctx, java8Home, "jre/lib/jce.jar"), 727 android.PathForSource(ctx, java8Home, "jre/lib/rt.jar")) 728 if Bool(j.properties.Use_tools_jar) { 729 flags.bootClasspath = append(flags.bootClasspath, 730 android.PathForSource(ctx, java8Home, "lib/tools.jar")) 731 } 732 } 733 734 // systemModules 735 if deps.systemModules != nil { 736 flags.systemModules = append(flags.systemModules, deps.systemModules) 737 } 738 739 // aidl flags. 740 aidlFlags := j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs) 741 if len(aidlFlags) > 0 { 742 // optimization. 743 ctx.Variable(pctx, "aidlFlags", strings.Join(aidlFlags, " ")) 744 flags.aidlFlags = "$aidlFlags" 745 } 746 747 return flags 748 } 749 750 func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path) { 751 752 j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs) 753 754 deps := j.collectDeps(ctx) 755 flags := j.collectBuilderFlags(ctx, deps) 756 757 if ctx.Config().TargetOpenJDK9() { 758 j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...) 759 } 760 srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs) 761 if hasSrcExt(srcFiles.Strings(), ".proto") { 762 flags = protoFlags(ctx, &j.properties, &j.protoProperties, flags) 763 } 764 765 srcFiles = j.genSources(ctx, srcFiles, flags) 766 767 srcJars := srcFiles.FilterByExt(".srcjar") 768 srcJars = append(srcJars, deps.srcJars...) 769 srcJars = append(srcJars, extraSrcJars...) 770 771 var jars android.Paths 772 773 jarName := ctx.ModuleName() + ".jar" 774 775 javaSrcFiles := srcFiles.FilterByExt(".java") 776 var uniqueSrcFiles android.Paths 777 set := make(map[string]bool) 778 for _, v := range javaSrcFiles { 779 if _, found := set[v.String()]; !found { 780 set[v.String()] = true 781 uniqueSrcFiles = append(uniqueSrcFiles, v) 782 } 783 } 784 785 if srcFiles.HasExt(".kt") { 786 // If there are kotlin files, compile them first but pass all the kotlin and java files 787 // kotlinc will use the java files to resolve types referenced by the kotlin files, but 788 // won't emit any classes for them. 789 790 flags.kotlincFlags = "-no-stdlib" 791 if ctx.Device() { 792 flags.kotlincFlags += " -no-jdk" 793 } 794 795 var kotlinSrcFiles android.Paths 796 kotlinSrcFiles = append(kotlinSrcFiles, uniqueSrcFiles...) 797 kotlinSrcFiles = append(kotlinSrcFiles, srcFiles.FilterByExt(".kt")...) 798 799 flags.kotlincClasspath = append(flags.kotlincClasspath, deps.kotlinStdlib...) 800 flags.kotlincClasspath = append(flags.kotlincClasspath, deps.classpath...) 801 802 kotlinJar := android.PathForModuleOut(ctx, "kotlin", jarName) 803 TransformKotlinToClasses(ctx, kotlinJar, kotlinSrcFiles, srcJars, flags) 804 if ctx.Failed() { 805 return 806 } 807 808 // Make javac rule depend on the kotlinc rule 809 flags.classpath = append(flags.classpath, deps.kotlinStdlib...) 810 flags.classpath = append(flags.classpath, kotlinJar) 811 // Jar kotlin classes into the final jar after javac 812 jars = append(jars, kotlinJar) 813 jars = append(jars, deps.kotlinStdlib...) 814 } 815 816 // Store the list of .java files that was passed to javac 817 j.compiledJavaSrcs = uniqueSrcFiles 818 j.compiledSrcJars = srcJars 819 820 enable_sharding := false 821 if ctx.Device() && !ctx.Config().IsEnvFalse("TURBINE_ENABLED") { 822 if j.properties.Javac_shard_size != nil && *(j.properties.Javac_shard_size) > 0 { 823 enable_sharding = true 824 if len(j.properties.Annotation_processors) != 0 || 825 len(j.properties.Annotation_processor_classes) != 0 { 826 ctx.PropertyErrorf("javac_shard_size", 827 "%q cannot be set when annotation processors are enabled.", 828 j.properties.Javac_shard_size) 829 } 830 } 831 // If sdk jar is java module, then directly return classesJar as header.jar 832 if j.Name() != "android_stubs_current" && j.Name() != "android_system_stubs_current" && 833 j.Name() != "android_test_stubs_current" { 834 j.headerJarFile = j.compileJavaHeader(ctx, uniqueSrcFiles, srcJars, deps, flags, jarName) 835 if ctx.Failed() { 836 return 837 } 838 } 839 } 840 if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 { 841 var extraJarDeps android.Paths 842 if ctx.Config().IsEnvTrue("RUN_ERROR_PRONE") { 843 // If error-prone is enabled, add an additional rule to compile the java files into 844 // a separate set of classes (so that they don't overwrite the normal ones and require 845 // a rebuild when error-prone is turned off). 846 // TODO(ccross): Once we always compile with javac9 we may be able to conditionally 847 // enable error-prone without affecting the output class files. 848 errorprone := android.PathForModuleOut(ctx, "errorprone", jarName) 849 RunErrorProne(ctx, errorprone, uniqueSrcFiles, srcJars, flags) 850 extraJarDeps = append(extraJarDeps, errorprone) 851 } 852 853 if enable_sharding { 854 flags.classpath = append(flags.classpath, j.headerJarFile) 855 shardSize := int(*(j.properties.Javac_shard_size)) 856 var shardSrcs []android.Paths 857 if len(uniqueSrcFiles) > 0 { 858 shardSrcs = shardPaths(uniqueSrcFiles, shardSize) 859 for idx, shardSrc := range shardSrcs { 860 classes := android.PathForModuleOut(ctx, "javac", jarName+strconv.Itoa(idx)) 861 TransformJavaToClasses(ctx, classes, idx, shardSrc, nil, flags, extraJarDeps) 862 jars = append(jars, classes) 863 } 864 } 865 if len(srcJars) > 0 { 866 classes := android.PathForModuleOut(ctx, "javac", jarName+strconv.Itoa(len(shardSrcs))) 867 TransformJavaToClasses(ctx, classes, len(shardSrcs), nil, srcJars, flags, extraJarDeps) 868 jars = append(jars, classes) 869 } 870 } else { 871 classes := android.PathForModuleOut(ctx, "javac", jarName) 872 TransformJavaToClasses(ctx, classes, -1, uniqueSrcFiles, srcJars, flags, extraJarDeps) 873 jars = append(jars, classes) 874 } 875 if ctx.Failed() { 876 return 877 } 878 } 879 880 dirArgs, dirDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs, j.properties.Exclude_java_resource_dirs) 881 fileArgs, fileDeps := ResourceFilesToJarArgs(ctx, j.properties.Java_resources, j.properties.Exclude_java_resources) 882 883 var resArgs []string 884 var resDeps android.Paths 885 886 resArgs = append(resArgs, dirArgs...) 887 resDeps = append(resDeps, dirDeps...) 888 889 resArgs = append(resArgs, fileArgs...) 890 resDeps = append(resDeps, fileDeps...) 891 892 if proptools.Bool(j.properties.Include_srcs) { 893 srcArgs, srcDeps := SourceFilesToJarArgs(ctx, j.properties.Srcs, j.properties.Exclude_srcs) 894 resArgs = append(resArgs, srcArgs...) 895 resDeps = append(resDeps, srcDeps...) 896 } 897 898 if len(resArgs) > 0 { 899 resourceJar := android.PathForModuleOut(ctx, "res", jarName) 900 TransformResourcesToJar(ctx, resourceJar, resArgs, resDeps) 901 if ctx.Failed() { 902 return 903 } 904 905 jars = append(jars, resourceJar) 906 } 907 908 // static classpath jars have the resources in them, so the resource jars aren't necessary here 909 jars = append(jars, deps.staticJars...) 910 911 var manifest android.OptionalPath 912 if j.properties.Manifest != nil { 913 manifest = android.OptionalPathForPath(ctx.ExpandSource(*j.properties.Manifest, "manifest")) 914 } 915 916 // Combine the classes built from sources, any manifests, and any static libraries into 917 // classes.jar. If there is only one input jar this step will be skipped. 918 var outputFile android.Path 919 920 if len(jars) == 1 && !manifest.Valid() { 921 // Optimization: skip the combine step if there is nothing to do 922 // TODO(ccross): this leaves any module-info.class files, but those should only come from 923 // prebuilt dependencies until we support modules in the platform build, so there shouldn't be 924 // any if len(jars) == 1. 925 outputFile = jars[0] 926 } else { 927 combinedJar := android.PathForModuleOut(ctx, "combined", jarName) 928 TransformJarsToJar(ctx, combinedJar, "for javac", jars, manifest, false, nil) 929 outputFile = combinedJar 930 } 931 932 if j.properties.Jarjar_rules != nil { 933 jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules) 934 // Transform classes.jar into classes-jarjar.jar 935 jarjarFile := android.PathForModuleOut(ctx, "jarjar", jarName) 936 TransformJarJar(ctx, jarjarFile, outputFile, jarjar_rules) 937 outputFile = jarjarFile 938 if ctx.Failed() { 939 return 940 } 941 } 942 j.implementationJarFile = outputFile 943 if j.headerJarFile == nil { 944 j.headerJarFile = j.implementationJarFile 945 } 946 947 if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { 948 if inList(ctx.ModuleName(), config.InstrumentFrameworkModules) { 949 j.properties.Instrument = true 950 } 951 } 952 953 if j.shouldInstrument(ctx) { 954 outputFile = j.instrument(ctx, flags, outputFile, jarName) 955 } 956 957 if ctx.Device() && j.installable() { 958 outputFile = j.compileDex(ctx, flags, outputFile, jarName) 959 if ctx.Failed() { 960 return 961 } 962 } 963 ctx.CheckbuildFile(outputFile) 964 j.outputFile = outputFile 965 } 966 967 func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars android.Paths, 968 deps deps, flags javaBuilderFlags, jarName string) android.Path { 969 970 var jars android.Paths 971 if len(srcFiles) > 0 || len(srcJars) > 0 { 972 // Compile java sources into turbine.jar. 973 turbineJar := android.PathForModuleOut(ctx, "turbine", jarName) 974 TransformJavaToHeaderClasses(ctx, turbineJar, srcFiles, srcJars, flags) 975 if ctx.Failed() { 976 return nil 977 } 978 jars = append(jars, turbineJar) 979 } 980 981 // Combine any static header libraries into classes-header.jar. If there is only 982 // one input jar this step will be skipped. 983 var headerJar android.Path 984 jars = append(jars, deps.staticHeaderJars...) 985 986 // we cannot skip the combine step for now if there is only one jar 987 // since we have to strip META-INF/TRANSITIVE dir from turbine.jar 988 combinedJar := android.PathForModuleOut(ctx, "turbine-combined", jarName) 989 TransformJarsToJar(ctx, combinedJar, "for turbine", jars, android.OptionalPath{}, false, []string{"META-INF"}) 990 headerJar = combinedJar 991 992 if j.properties.Jarjar_rules != nil { 993 jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules) 994 // Transform classes.jar into classes-jarjar.jar 995 jarjarFile := android.PathForModuleOut(ctx, "turbine-jarjar", jarName) 996 TransformJarJar(ctx, jarjarFile, headerJar, jarjar_rules) 997 headerJar = jarjarFile 998 if ctx.Failed() { 999 return nil 1000 } 1001 } 1002 1003 return headerJar 1004 } 1005 1006 func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags, 1007 classesJar android.Path, jarName string) android.Path { 1008 1009 specs := j.jacocoModuleToZipCommand(ctx) 1010 1011 jacocoReportClassesFile := android.PathForModuleOut(ctx, "jacoco-report-classes", jarName) 1012 instrumentedJar := android.PathForModuleOut(ctx, "jacoco", jarName) 1013 1014 jacocoInstrumentJar(ctx, instrumentedJar, jacocoReportClassesFile, classesJar, specs) 1015 1016 j.jacocoReportClassesFile = jacocoReportClassesFile 1017 1018 return instrumentedJar 1019 } 1020 1021 // Returns a sdk version as a string that is guaranteed to be a parseable as a number. For 1022 // modules targeting an unreleased SDK (meaning it does not yet have a number) it returns "10000". 1023 func (j *Module) minSdkVersionNumber(ctx android.ModuleContext) string { 1024 switch String(j.deviceProperties.Sdk_version) { 1025 case "", "current", "test_current", "system_current", "core_current": 1026 return strconv.Itoa(ctx.Config().DefaultAppTargetSdkInt()) 1027 default: 1028 return android.GetNumericSdkVersion(String(j.deviceProperties.Sdk_version)) 1029 } 1030 } 1031 1032 func (j *Module) installable() bool { 1033 return j.properties.Installable == nil || *j.properties.Installable 1034 } 1035 1036 var _ Dependency = (*Library)(nil) 1037 1038 func (j *Module) HeaderJars() android.Paths { 1039 return android.Paths{j.headerJarFile} 1040 } 1041 1042 func (j *Module) ImplementationJars() android.Paths { 1043 return android.Paths{j.implementationJarFile} 1044 } 1045 1046 func (j *Module) AidlIncludeDirs() android.Paths { 1047 return j.exportAidlIncludeDirs 1048 } 1049 1050 var _ logtagsProducer = (*Module)(nil) 1051 1052 func (j *Module) logtags() android.Paths { 1053 return j.logtagsSrcs 1054 } 1055 1056 // 1057 // Java libraries (.jar file) 1058 // 1059 1060 type Library struct { 1061 Module 1062 } 1063 1064 func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { 1065 j.compile(ctx) 1066 1067 if j.installable() { 1068 j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), 1069 ctx.ModuleName()+".jar", j.outputFile) 1070 } 1071 } 1072 1073 func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) { 1074 j.deps(ctx) 1075 } 1076 1077 func LibraryFactory(installable bool) func() android.Module { 1078 return func() android.Module { 1079 module := &Library{} 1080 1081 if !installable { 1082 module.properties.Installable = proptools.BoolPtr(false) 1083 } 1084 1085 module.AddProperties( 1086 &module.Module.properties, 1087 &module.Module.deviceProperties, 1088 &module.Module.protoProperties) 1089 1090 InitJavaModule(module, android.HostAndDeviceSupported) 1091 return module 1092 } 1093 } 1094 1095 func LibraryHostFactory() android.Module { 1096 module := &Library{} 1097 1098 module.AddProperties( 1099 &module.Module.properties, 1100 &module.Module.protoProperties) 1101 1102 InitJavaModule(module, android.HostSupported) 1103 return module 1104 } 1105 1106 // 1107 // Java Binaries (.jar file plus wrapper script) 1108 // 1109 1110 type binaryProperties struct { 1111 // installable script to execute the resulting jar 1112 Wrapper *string 1113 } 1114 1115 type Binary struct { 1116 Library 1117 1118 binaryProperties binaryProperties 1119 1120 isWrapperVariant bool 1121 1122 wrapperFile android.Path 1123 binaryFile android.OutputPath 1124 } 1125 1126 func (j *Binary) HostToolPath() android.OptionalPath { 1127 return android.OptionalPathForPath(j.binaryFile) 1128 } 1129 1130 func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) { 1131 if ctx.Arch().ArchType == android.Common { 1132 // Compile the jar 1133 j.Library.GenerateAndroidBuildActions(ctx) 1134 } else { 1135 // Handle the binary wrapper 1136 j.isWrapperVariant = true 1137 1138 if j.binaryProperties.Wrapper != nil { 1139 j.wrapperFile = ctx.ExpandSource(*j.binaryProperties.Wrapper, "wrapper") 1140 } else { 1141 j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh") 1142 } 1143 1144 // Depend on the installed jar so that the wrapper doesn't get executed by 1145 // another build rule before the jar has been installed. 1146 jarFile := ctx.PrimaryModule().(*Binary).installFile 1147 1148 j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"), 1149 ctx.ModuleName(), j.wrapperFile, jarFile) 1150 } 1151 } 1152 1153 func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) { 1154 if ctx.Arch().ArchType == android.Common { 1155 j.deps(ctx) 1156 } else { 1157 android.ExtractSourceDeps(ctx, j.binaryProperties.Wrapper) 1158 } 1159 } 1160 1161 func BinaryFactory() android.Module { 1162 module := &Binary{} 1163 1164 module.AddProperties( 1165 &module.Module.properties, 1166 &module.Module.deviceProperties, 1167 &module.Module.protoProperties, 1168 &module.binaryProperties) 1169 1170 android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommonFirst) 1171 android.InitDefaultableModule(module) 1172 return module 1173 } 1174 1175 func BinaryHostFactory() android.Module { 1176 module := &Binary{} 1177 1178 module.AddProperties( 1179 &module.Module.properties, 1180 &module.Module.deviceProperties, 1181 &module.Module.protoProperties, 1182 &module.binaryProperties) 1183 1184 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommonFirst) 1185 android.InitDefaultableModule(module) 1186 return module 1187 } 1188 1189 // 1190 // Java prebuilts 1191 // 1192 1193 type ImportProperties struct { 1194 Jars []string 1195 1196 Sdk_version *string 1197 1198 Installable *bool 1199 } 1200 1201 type Import struct { 1202 android.ModuleBase 1203 prebuilt android.Prebuilt 1204 1205 properties ImportProperties 1206 1207 classpathFiles android.Paths 1208 combinedClasspathFile android.Path 1209 } 1210 1211 func (j *Import) Prebuilt() *android.Prebuilt { 1212 return &j.prebuilt 1213 } 1214 1215 func (j *Import) PrebuiltSrcs() []string { 1216 return j.properties.Jars 1217 } 1218 1219 func (j *Import) Name() string { 1220 return j.prebuilt.Name(j.ModuleBase.Name()) 1221 } 1222 1223 func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) { 1224 } 1225 1226 func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { 1227 j.classpathFiles = android.PathsForModuleSrc(ctx, j.properties.Jars) 1228 1229 outputFile := android.PathForModuleOut(ctx, "classes.jar") 1230 TransformJarsToJar(ctx, outputFile, "for prebuilts", j.classpathFiles, android.OptionalPath{}, false, nil) 1231 j.combinedClasspathFile = outputFile 1232 } 1233 1234 var _ Dependency = (*Import)(nil) 1235 1236 func (j *Import) HeaderJars() android.Paths { 1237 return j.classpathFiles 1238 } 1239 1240 func (j *Import) ImplementationJars() android.Paths { 1241 return j.classpathFiles 1242 } 1243 1244 func (j *Import) AidlIncludeDirs() android.Paths { 1245 return nil 1246 } 1247 1248 var _ android.PrebuiltInterface = (*Import)(nil) 1249 1250 func ImportFactory() android.Module { 1251 module := &Import{} 1252 1253 module.AddProperties(&module.properties) 1254 1255 android.InitPrebuiltModule(module, &module.properties.Jars) 1256 android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) 1257 return module 1258 } 1259 1260 func ImportFactoryHost() android.Module { 1261 module := &Import{} 1262 1263 module.AddProperties(&module.properties) 1264 1265 android.InitPrebuiltModule(module, &module.properties.Jars) 1266 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) 1267 return module 1268 } 1269 1270 // 1271 // Defaults 1272 // 1273 type Defaults struct { 1274 android.ModuleBase 1275 android.DefaultsModuleBase 1276 } 1277 1278 func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) { 1279 } 1280 1281 func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) { 1282 } 1283 1284 func defaultsFactory() android.Module { 1285 return DefaultsFactory() 1286 } 1287 1288 func DefaultsFactory(props ...interface{}) android.Module { 1289 module := &Defaults{} 1290 1291 module.AddProperties(props...) 1292 module.AddProperties( 1293 &CompilerProperties{}, 1294 &CompilerDeviceProperties{}, 1295 &android.ProtoProperties{}, 1296 ) 1297 1298 android.InitDefaultsModule(module) 1299 1300 return module 1301 } 1302 1303 var Bool = proptools.Bool 1304 var String = proptools.String 1305 var inList = android.InList