boot_jars.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2020 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. package java
  15. import (
  16. "android/soong/android"
  17. )
  18. // isActiveModule returns true if the given module should be considered for boot
  19. // jars, i.e. if it's enabled and the preferred one in case of source and
  20. // prebuilt alternatives.
  21. func isActiveModule(module android.Module) bool {
  22. if !module.Enabled() {
  23. return false
  24. }
  25. return android.IsModulePreferred(module)
  26. }
  27. // buildRuleForBootJarsPackageCheck generates the build rule to perform the boot jars package
  28. // check.
  29. func buildRuleForBootJarsPackageCheck(ctx android.ModuleContext, bootDexJarByModule bootDexJarByModule) {
  30. bootDexJars := bootDexJarByModule.bootDexJarsWithoutCoverage()
  31. if len(bootDexJars) == 0 {
  32. return
  33. }
  34. timestamp := android.PathForOutput(ctx, "boot-jars-package-check/stamp")
  35. rule := android.NewRuleBuilder(pctx, ctx)
  36. rule.Command().BuiltTool("check_boot_jars").
  37. Input(ctx.Config().HostToolPath(ctx, "dexdump")).
  38. Input(android.PathForSource(ctx, "build/soong/scripts/check_boot_jars/package_allowed_list.txt")).
  39. Inputs(bootDexJars).
  40. Text("&& touch").Output(timestamp)
  41. rule.Build("boot_jars_package_check", "check boot jar packages")
  42. // The check-boot-jars phony target depends on the timestamp created if the check succeeds.
  43. ctx.Phony("check-boot-jars", timestamp)
  44. // The droidcore phony target depends on the check-boot-jars phony target
  45. ctx.Phony("droidcore", android.PathForPhony(ctx, "check-boot-jars"))
  46. }