Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #248

Closed
wants to merge 15 commits into from
Closed

Fix #248

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add deno2 prototype from external repo.
  • Loading branch information
ry committed Jun 9, 2018
commit 110ddab670cbf477488cceeea2842c980942d7b8
38 changes: 38 additions & 0 deletions deno2/.gclient
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
solutions = [{
'url': 'https://chromium.googlesource.com/v8/v8.git',
'custom_vars': {
'build_for_node': True
},
'name': 'v8',
'deps_file': 'DEPS',
'custom_deps': {
'v8/third_party/catapult': None,
'v8/third_party/colorama/src': None,
'v8/testing/gmock': None,
'v8/tools/swarming_client': None,
'v8/third_party/instrumented_libraries': None,
'v8/tools/gyp': None,
'v8/third_party/android_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
}
}, {
'url': 'https://github.com/ry/protobuf_chromium.git',
'name': 'third_party/protobuf',
'deps_file': 'DEPS'
}, {
'url':
'https://chromium.googlesource.com/chromium/src/tools/protoc_wrapper',
'name':
'tools/protoc_wrapper'
}, {
'url':
'https://chromium.googlesource.com/chromium/src/third_party/zlib',
'name':
'third_party/zlib'
}]
8 changes: 8 additions & 0 deletions deno2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
out/
js/.cache/
js/node_modules/
v8/
tools/protoc_wrapper/
third_party/protobuf/
third_party/zlib/
.gclient_entries
61 changes: 61 additions & 0 deletions deno2/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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.

import("//v8/build/dotfile_settings.gni")

# The location of the build configuration file.
buildconfig = "//v8/build/config/BUILDCONFIG.gn"

# The secondary source root is a parallel directory tree where
# GN build files are placed when they can not be placed directly
# in the source tree, e.g. for third party source trees.
secondary_source = "//v8/"

# 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 = []

# These are the list of GN files that run exec_script. This whitelist exists
# to force additional review for new uses of exec_script, which is strongly
# discouraged except for gypi_to_gn calls.
exec_script_whitelist = build_dotfile_settings.exec_script_whitelist + []

default_args = {
# Default to release builds for this project.
is_component_build = false
is_debug = false
libcpp_is_static = false
symbol_level = 1
treat_warnings_as_errors = false
use_custom_libcxx = false
use_sysroot = false
v8_deprecation_warnings = false

#v8_embedder_string = ""
v8_enable_gdbjit = false
v8_enable_i18n_support = false
v8_enable_test_features = false
v8_experimental_extra_library_files = []
v8_extra_library_files = []
v8_imminent_deprecation_warnings = false
v8_monolithic = false
v8_static_library = false
v8_target_cpu = "x64"
v8_untrusted_code_mitigations = false

# This tells V8 to write out/Default/gen/v8/snapshot.bin
# Which we can use to build our own snapshot.
v8_use_external_startup_data = true
v8_use_snapshot = true

# Snapshot the dist/main.js bundle into V8.
# Is ".gn" really the most appropriate place to specify this important
# value? This is how they do it in Chrome.
# https://cs.chromium.org/chromium/src/.gn?l=37&rcl=f1c8c3cf8bd4a63da6433ee67e2ff5ecbbdb4316

# "$target_gen_dir/main.js"
#]
}
134 changes: 134 additions & 0 deletions deno2/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import("//third_party/protobuf/proto_library.gni")
import("//v8/gni/v8.gni")
import("//v8/snapshot_toolchain.gni")

proto_library("msg_proto") {
sources = [
"msg.proto",
]
}

action("run_parcel") {
sources = [
"js/main.ts",
]
outputs = [
"$target_gen_dir/main.js",
"$target_gen_dir/main.map",
]

# Our script imports this Python file so we want to rebuild if it changes.
# inputs = [ "helper_library.py" ]

# Note that we have to manually pass the sources to our script if the
# script needs them as inputs.
script = "js/run_node.py"
root = root_build_dir + "/../../js"
args = [
"./node_modules/.bin/parcel",
"build",
"--log-level=1",
"--no-minify",
"--out-dir=" + rebase_path(target_gen_dir, root),
] + rebase_path(sources, root)
}

# Template to generate different V8 snapshots based on different runtime flags.
# Can be invoked with run_mksnapshot(<name>). The target will resolve to
# run_mksnapshot_<name>. If <name> is "default", no file suffixes will be used.
# Otherwise files are suffixed, e.g. embedded_<name>.cc and
# snapshot_blob_<name>.bin.
#
# The template exposes the variables:
# args: additional flags for mksnapshots
# embedded_suffix: a camel case suffix for method names in the embedded
# snapshot.
template("create_snapshot") {
name = target_name
suffix = "_$name"
action("create_snapshot_" + name) {
visibility = [ ":*" ] # Only targets in this file can depend on this.
deps = [ ":snapshot_creator" ] + invoker.deps
script = "v8/tools/run.py"
data = []
exe = rebase_path(get_label_info(":snapshot_creator", "root_out_dir") +
"/snapshot_creator")
natives_in_bin = "$root_out_dir/natives_blob.bin"
snapshot_in_bin = "$root_out_dir/snapshot_blob.bin"
natives_out_cc = "$target_gen_dir/natives${suffix}.cc"
snapshot_out_cc = "$target_gen_dir/snapshot${suffix}.cc"
sources = [
invoker.js,
]
outputs = [
natives_out_cc,
snapshot_out_cc,
]
args = [
exe,
rebase_path(invoker.js, root_build_dir),
rebase_path(natives_in_bin, root_build_dir),
rebase_path(snapshot_in_bin, root_build_dir),
rebase_path(natives_out_cc, root_build_dir),
rebase_path(snapshot_out_cc, root_build_dir),
]
data = [
invoker.js,
]
}
}

# Generates $target_gen_dir/snapshot_bundle.cc
create_snapshot("deno") {
js = "$target_gen_dir/main.js"
deps = [
":run_parcel",
]
}

v8_executable("snapshot_creator") {
sources = [
"deno.cc",
"deno.h",
"snapshot_creator.cc",
]
configs = [ "v8:libplatform_config" ]
deps = [
"v8:v8",
"v8:v8_libbase",
"v8:v8_libplatform",
"v8:v8_libsampler",
"//build/config:exe_and_shlib_deps",
"//build/win:default_exe_manifest",
]
}

v8_executable("deno") {
sources = [
"deno.cc",
"deno.h",
"main.cc",
]
include_dirs = [ target_gen_dir ]
configs = [ "v8:libplatform_config" ]
deps = [
":create_snapshot_deno",
":msg_proto",
"v8:v8",
"v8:v8_libbase",
"v8:v8_libplatform",
"v8:v8_libsampler",
"//build/config:exe_and_shlib_deps",
"//build/win:default_exe_manifest",
]
}

executable("deno_test") {
testonly = true
sources = [
"deno_test.cc",
]
deps = [
"//testing/gtest:gtest",
]
}
68 changes: 68 additions & 0 deletions deno2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Deno Prototype 2

## Status

This code is a rewrite of the unprivileged parts of Deno. It will soon become
the root of the project.

There are several goals:

* Use the gn build system for fast builds, sane configuration, and easy
linking into Chrome.

* Use V8 snapshots to improve startup time.

* Remove Golang. Although it has been working nicely, I am concerned the
double GC will become a problem sometime down the road.

* Distribute a C++ library called libdeno, containing the snapshotted
typescript runtime.

* Test the message passing and other functionality at that layer before
involving higher level languages.

The contenders for building the unprivileged part of Deno are Rust and C++.
Thanks to Chrome and gn, using C++ to link into high level libraries is not
untenable. However, there's a lot of interest in Rust in the JS community and
it seems like a reasonable choice. TBD.

There are many people exploring the project, so care will be taken to keep the
original code functional while this is developed. However, once it's ready this
the code in this deno2/ directory will be moved to the root.


## Prerequisites

Get Depot Tools and make sure it's in your path.
http:https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up

For linux you need these prereqs:

sudo apt-get install libgtk-3-dev pkg-config ccache


## Build

First install the javascript deps.

cd js; yarn install

TODO(ry) Remove the above step by a deps submodule.

Wrapper around the gclient/gn/ninja for end users. Try this first:

./tools/build.py --use_ccache --debug

If that doesn't work, or you need more control, try calling gn manually:

gn gen out/Debug --args='cc_wrapper="ccache" is_debug=true '

Then build with ninja:

ninja -C out/Debug/ deno


Other useful commands:

gn args out/Debug/ --list # List build args
gn args out/Debug/ # Modify args in $EDITOR
1 change: 1 addition & 0 deletions deno2/build
Loading