Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zelid/4254f5ac5960795cf64220625ae59949 to your computer and use it in GitHub Desktop.
Save zelid/4254f5ac5960795cf64220625ae59949 to your computer and use it in GitHub Desktop.
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Targets in ths file are to take a V8 context snapshot on build time.
# Created V8 context snapshot is used in
# third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.{cpp|h}.
# to speedup creating a V8 context and setting up around it.
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("//build/config/c++/c++.gni")
import("//build/config/compiler/compiler.gni")
import("//v8/snapshot_toolchain.gni")
if (is_android) {
import("//build/config/android/rules.gni")
}
group("v8_context_snapshot") {
if (use_v8_context_snapshot) {
public_deps = [
":generate_v8_context_snapshot",
]
if (!is_android) {
data = [
"$root_out_dir/v8_context_snapshot.bin",
]
}
}
}
config("use_v8_context_snapshot") {
if (use_v8_context_snapshot) {
defines = [ "USE_V8_CONTEXT_SNAPSHOT" ]
}
}
if (use_v8_context_snapshot) {
if (is_android && enable_java_templates) {
android_assets("v8_context_snapshot_assets") {
deps = [
":v8_context_snapshot",
]
sources = [
"$root_out_dir/natives_blob.bin",
]
renaming_sources = [ "$root_out_dir/v8_context_snapshot.bin" ]
if (current_cpu == "arm" || current_cpu == "x86" ||
current_cpu == "mipsel") {
renaming_destinations = [ "v8_context_snapshot_32.bin" ]
} else {
renaming_destinations = [ "v8_context_snapshot_64.bin" ]
}
disable_compression = true
}
}
action("generate_v8_context_snapshot") {
script = "run.py"
output_file = "$root_out_dir/v8_context_snapshot.bin"
output_path = rebase_path(output_file, root_build_dir)
args = [
"./" + rebase_path(
get_label_info(
":v8_context_snapshot_generator($v8_snapshot_toolchain)",
"root_out_dir") + "/v8_context_snapshot_generator",
root_build_dir),
"--output_file=$output_path",
]
outputs = [
output_file,
]
deps = [
":v8_context_snapshot_generator($v8_snapshot_toolchain)",
]
}
# This config disables a link time optimization "ICF", which may merge different
# functions into one if the function signature and body of them are identical.
#
# ICF breaks 1:1 mappings of the external references for V8 snapshot, so we
# disable it while taking a V8 snapshot.
config("disable_icf") {
visibility = [ ":*" ] # Only targets in this file can depend on this.
if (is_win) {
ldflags = [ "/OPT:NOICF" ] # link.exe, but also lld-link.exe.
} else if (use_gold || use_lld) {
ldflags = [ "-Wl,--icf=none" ]
}
}
executable("v8_context_snapshot_generator") {
sources = [
"v8_context_snapshot_generator.cc",
]
deps = [
"//gin:gin",
"//mojo/core/embedder",
"//services/service_manager/public/cpp",
"//third_party/blink/public:blink",
"//v8",
"//v8:v8_initializers",
]
if (is_linux && !is_component_build) {
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
}
if (is_mac && !is_component_build) {
# linking with ffmpeg lib
ldflags = [ "-rpath", "@executable_path/." ]
}
configs += [
"//v8:external_startup_data",
":disable_icf",
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment