v8_context_snapshot.gni 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Copyright 2017 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. # Targets in ths file are to take a V8 context snapshot on build time.
  5. # Created V8 context snapshot is used in
  6. # third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.{cpp|h}.
  7. # to speedup creating a V8 context and setting up around it.
  8. import("//build/config/chromecast_build.gni")
  9. import("//build/config/chromeos/ui_mode.gni")
  10. import("//build/config/v8_target_cpu.gni")
  11. import("//v8/gni/v8.gni")
  12. declare_args() {
  13. # TODO(crbug.com/764576): Enable the feature on more environments.
  14. # Disable in mac and win cross builds since building Blink twice is slow.
  15. use_v8_context_snapshot =
  16. !is_chromeos && !is_android && !is_castos && !is_fuchsia &&
  17. !(host_os == "mac" && current_cpu == "x86") &&
  18. # Android may build for both 64 bit and 32bit. When this happens, the
  19. # v8_target_cpu will not equal the target_cpu (for example,
  20. # v8_target_cpu == "arm" but target_os == "arm64").
  21. (v8_target_cpu == target_cpu || target_os == "android") &&
  22. !(host_toolchain == default_toolchain && is_msan) &&
  23. !(is_win && host_os != "win") && !(is_mac && host_os != "mac")
  24. # We use a different filename for arm64 macOS builds so that the arm64 and
  25. # x64 snapshots can live side-by-side in a universal macOS app.
  26. if (is_mac) {
  27. if (v8_target_cpu == "x64") {
  28. v8_context_snapshot_filename = "v8_context_snapshot.x86_64.bin"
  29. } else if (v8_target_cpu == "arm64") {
  30. v8_context_snapshot_filename = "v8_context_snapshot.arm64.bin"
  31. }
  32. } else if (target_os == "android") {
  33. if (v8_current_cpu == "arm" || v8_current_cpu == "x86" ||
  34. v8_current_cpu == "mipsel") {
  35. v8_context_snapshot_filename = "v8_context_snapshot_32.bin"
  36. } else {
  37. v8_context_snapshot_filename = "v8_context_snapshot_64.bin"
  38. }
  39. } else {
  40. v8_context_snapshot_filename = "v8_context_snapshot.bin"
  41. }
  42. }
  43. # We cannot use V8 context snapshot, if V8 doesn't use snapshot files.
  44. if (use_v8_context_snapshot && !v8_use_external_startup_data) {
  45. use_v8_context_snapshot = false
  46. }