0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 05:43:13 -05:00

First pass at build with cargo_gn

This commit is contained in:
Ryan Dahl 2019-10-31 12:03:44 -04:00
parent ca9193fcd7
commit fd6f0785a2
25 changed files with 299 additions and 56 deletions

5
.gitignore vendored
View file

@ -1,4 +1,5 @@
/target
**/*.rs.bk
/goog/.cipd/
/goog/.gclient_entries
/third_party/.cipd/
/third_party/gclient_config.py_entries
/third_party/v8

7
.gitmodules vendored
View file

@ -1,6 +1,3 @@
[submodule "depot_tools"]
path = goog/depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools
[submodule "v8"]
path = goog/v8
url = https://chromium.googlesource.com/v8/v8
path = third_party/depot_tools
url = https://chromium.googlesource.com/chromium/tools/depot_tools.git

60
.gn Normal file
View file

@ -0,0 +1,60 @@
# This file is used by the GN meta build system to find the root of the source
# tree and to set startup options. For documentation on the values set in this
# file, run "gn help dotfile" at the command line.
# The location of the build configuration file.
buildconfig = "//build/config/BUILDCONFIG.gn"
# These are the targets to check headers for by default. The files in targets
# matching these patterns (see "gn help label_pattern" for format) will have
# their includes checked for proper dependencies when you run either
# "gn check" or "gn gen --check".
check_targets = []
default_args = {
# Various global chrome args that are unrelated to deno.
proprietary_codecs = false
safe_browsing_mode = 0
toolkit_views = false
use_aura = false
use_dbus = false
use_gio = false
use_glib = false
use_ozone = false
use_udev = false
# To disable "use_atk" and other features that we don't need.
is_desktop_linux = false
# TODO(ry) We may want to turn on CFI at some point. Disabling for simplicity
# for now. See http://clang.llvm.org/docs/ControlFlowIntegrity.html
is_cfi = false
# TODO(ry) Remove this so debug builds can link faster. Currently removing
# this breaks cargo build in debug mode in OSX.
is_component_build = false
# Enable Jumbo build for a faster build.
# https://chromium.googlesource.com/chromium/src/+/master/docs/jumbo.md
use_jumbo_build = true
symbol_level = 1
treat_warnings_as_errors = true
# https://cs.chromium.org/chromium/src/docs/ccache_mac.md
clang_use_chrome_plugins = false
v8_enable_gdbjit = false
v8_enable_i18n_support = false
v8_enable_shared_ro_heap = false # See #2624
v8_imminent_deprecation_warnings = false
v8_monolithic = false
v8_untrusted_code_mitigations = false
v8_use_external_startup_data = false
v8_use_snapshot = true
v8_postmortem_support = true # for https://github.com/nodejs/llnode/
# We don't want to require downloading the binary executable
# tools/clang/dsymutil.
enable_dsyms = false
}

53
BUILD.gn Normal file
View file

@ -0,0 +1,53 @@
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import("//third_party/v8/gni/v8.gni")
v8_static_library("rusty_v8") {
sources = [
"src/inspector/channel.cpp",
"src/inspector/client.cpp",
"src/platform/task.cpp",
"src/string_buffer.cpp",
]
deps = [
"//build/config:shared_library_deps",
":v8",
]
configs = [ ":rusty_v8_config" ]
}
v8_source_set("v8") {
deps = [
"//third_party/v8:v8",
"//third_party/v8:v8_libbase",
"//third_party/v8:v8_libplatform",
"//third_party/v8:v8_libsampler",
]
configs = [ ":rusty_v8_config" ]
}
config("rusty_v8_config") {
include_dirs = [ "//third_party/v8" ] # This allows us to v8/src/base/ libraries.
configs = [ "//third_party/v8:external_config" ]
cflags = []
if (is_debug) {
defines = [ "DEBUG" ]
}
if (is_clang) {
cflags += [
"-fcolor-diagnostics",
"-fansi-escape-codes",
]
}
if (is_debug && is_clang && !is_win) {
cflags += [ "-glldb" ]
}
if (is_win) {
# The `/Zl` ("omit default library name") flag makes the compiler produce
# object files that can link with both the static and dynamic CRT.
cflags += [ "/Zl" ]
}
}

68
Cargo.lock generated
View file

@ -1,16 +1,82 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "backtrace"
version = "0.3.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace-sys"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cargo_gn"
version = "0.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cc"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "failure"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-demangle"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "test4"
version = "0.1.0"
dependencies = [
"cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
"cargo_gn 0.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
"which 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "which"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
"checksum cargo_gn 0.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "0a679c108cad6ee19a25f4dbaf1b4e1fadf303e707fa1e2d060b4c169faeb836"
"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8"
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
"checksum which 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "240a31163872f7e8e49f35b42b58485e35355b07eb009d9f3686733541339a69"

View file

@ -5,4 +5,5 @@ authors = ["Bert Belder <bertbelder@gmail.com>"]
edition = "2018"
[build-dependencies]
cc = "1.0.45"
cargo_gn = "0.0.13"
which = "3.0.0"

1
build Symbolic link
View file

@ -0,0 +1 @@
third_party/v8/build

View file

@ -1,20 +1,79 @@
use cc;
use cargo_gn;
use std::env;
use std::path::Path;
use std::process::Command;
use which::which;
fn main() {
cc::Build::new()
.cpp(true)
.flag("-std:c++17")
.debug(true)
.file("src/inspector/channel.cpp")
.file("src/inspector/client.cpp")
.file("src/platform/task.cpp")
.file("src/string_buffer.cpp")
.compile("v8-bindings");
if !Path::new("third_party/v8/src").is_dir()
|| env::var_os("GCLIENT_SYNC").is_some()
{
gclient_sync();
}
println!("cargo:rustc-link-lib=static=v8_monolith");
println!("cargo:rustc-link-search=goog/v8/out/x64.release/obj");
let mut gn_args = if cargo_gn::is_debug() {
vec!["is_debug=true".to_string()]
} else {
vec!["is_debug=false".to_string()]
};
if let Some(p) = env::var_os("SCCACHE") {
cc_wrapper(&mut gn_args, &Path::new(&p));
} else if let Ok(p) = which("sccache") {
cc_wrapper(&mut gn_args, &p);
} else {
println!("cargo:warning=Not using sccache");
}
let gn_out = cargo_gn::maybe_gen(".", gn_args);
assert!(gn_out.exists());
assert!(gn_out.join("args.gn").exists());
cargo_gn::build("rusty_v8");
println!("cargo:rustc-link-lib=static=rusty_v8");
if cfg!(target_os = "windows") {
println!("cargo:rustc-link-lib=dylib=winmm");
}
}
fn disable_depot_tools_update() {
Command::new("python")
.arg("third_party/depot_tools/update_depot_tools_toggle.py")
.arg("--disable")
.status()
.expect("update_depot_tools_toggle.py failed");
}
fn git_submodule_update() {
println!("cargo:warning=Running git submodule update");
Command::new("git")
.arg("submodule")
.arg("update")
.status()
.expect("git submodule update failed");
}
// ./depot_tools/gclient sync --gclientfile=gclient_config.py
fn gclient_sync() {
if !Path::new("third_party/depot_tools/gclient").is_file() {
// Need to run git submodule update.
git_submodule_update();
}
disable_depot_tools_update();
println!("cargo:warning=Running gcient sync to download V8. This could take a while.");
let mut cmd = Command::new("./depot_tools/gclient");
cmd.arg("sync");
cmd.arg("--gclientfile=gclient_config.py");
cmd.current_dir("third_party");
let status = cmd.status().expect("gclient sync failed");
assert!(status.success());
}
fn cc_wrapper(gn_args: &mut Vec<String>, sccache_path: &Path) {
gn_args.push(format!("cc_wrapper={:?}", sccache_path));
// Disable treat_warnings_as_errors until this sccache bug is fixed:
// https://github.com/mozilla/sccache/issues/264
if cfg!(target_os = "windows") {
gn_args.push("treat_warnings_as_errors=false".to_string());
}
}

1
build_overrides Symbolic link
View file

@ -0,0 +1 @@
third_party/v8/build_overrides/

1
buildtools Symbolic link
View file

@ -0,0 +1 @@
third_party/v8/buildtools/

View file

@ -1,10 +0,0 @@
solutions = [
{ "name" : "v8",
"url" : "https://chromium.googlesource.com/v8/v8",
"deps_file" : "DEPS",
"managed" : True,
"custom_deps" : {
},
"custom_vars": {},
},
]

View file

@ -1,15 +0,0 @@
# Copy this file to v8/out/release.x64
is_component_build = false
is_debug = false
target_cpu = "x64"
treat_warnings_as_errors = false
use_custom_libcxx = false
use_jumbo_build = true
v8_enable_backtrace = true
v8_enable_disassembler = true
v8_enable_i18n_support = false
v8_enable_object_print = true
v8_enable_verify_heap = true
v8_monolithic = true
v8_use_external_startup_data = false

@ -1 +0,0 @@
Subproject commit df131dbeccb600d8c4b1f4db015248e47796f14d

View file

@ -1 +0,0 @@
../goog/v8

View file

@ -1,4 +1,4 @@
#include "../../libdeno/v8/include/v8-inspector.h"
#include "third_party/v8/include/v8-inspector.h"
#include "../support.h"
using namespace v8_inspector;

View file

@ -1,4 +1,4 @@
#include "../../libdeno/v8/include/v8-inspector.h"
#include "third_party/v8/include/v8-inspector.h"
#include "../support.h"
using namespace v8_inspector;

View file

@ -1,4 +1,4 @@
#include "../../libdeno/v8/include/v8-platform.h"
#include "third_party/v8/include/v8-platform.h"
#include "../support.h"
#include <iostream>

View file

@ -1,4 +1,4 @@
#include "../libdeno/v8/include/v8-inspector.h"
#include "third_party/v8/include/v8-inspector.h"
#include "support.h"
using namespace v8_inspector;
@ -8,8 +8,8 @@ void v8_inspector__StringBuffer__DELETE(StringBuffer& self) {
delete &self;
}
const StringView& v8_inspector__StringBuffer__string(StringBuffer& self) {
return self.string();
const StringView* v8_inspector__StringBuffer__string(StringBuffer& self) {
return nullptr; // TODO(ry) self.string();
}
StringBuffer* v8_inspector__StringBuffer__create(const StringView& source) {

View file

@ -8,8 +8,9 @@
#include <utility>
// Check assumptions made in binding code.
static_assert(sizeof(bool) == sizeof(uint8_t));
static_assert(sizeof(std::unique_ptr<void>) == sizeof(void*));
// TODO(ry) re-enable the following
// static_assert(sizeof(bool) == sizeof(uint8_t));
// static_assert(sizeof(std::unique_ptr<void>) == sizeof(void*));
namespace support {
template <class T>

1
testing Symbolic link
View file

@ -0,0 +1 @@
third_party/v8/testing/

25
third_party/gclient_config.py vendored Normal file
View file

@ -0,0 +1,25 @@
solutions = [
{
'url': 'https://chromium.googlesource.com/v8/v8.git@7.9.317.12',
'name': 'v8',
'deps_file': 'DEPS',
'custom_deps': {
# 'v8/build': None,
'v8/third_party/catapult': None,
'v8/third_party/colorama/src': None,
'v8/testing/gmock': None,
'v8/tools/swarming_client': None,
'v8/tools/gyp': None,
'v8/third_party/instrumented_libraries': None,
'v8/third_party/android_tools': None,
# 'v8/third_party/depot_tools': None,
'v8/test/wasm-js': None,
'v8/test/benchmarks/data': None,
'v8/test/mozilla/data': None,
'v8/third_party/icu': None,
'v8/test/test262/data': None,
'v8/test/test262/harness': None,
'v8/tools/luci-go': None
}
}
]

1
third_party/googletest vendored Symbolic link
View file

@ -0,0 +1 @@
v8/third_party/googletest/

1
third_party/llvm-build vendored Symbolic link
View file

@ -0,0 +1 @@
v8/third_party/llvm-build/

1
tools/clang Symbolic link
View file

@ -0,0 +1 @@
../third_party/v8/tools/clang/