Skip to content

Commit

Permalink
Replace libdeno with rusty_v8 (#3556)
Browse files Browse the repository at this point in the history
  • Loading branch information
ry authored Jan 5, 2020
1 parent c41280a commit 5f1df03
Show file tree
Hide file tree
Showing 50 changed files with 2,281 additions and 7,293 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ jobs:
rustc --version
cargo --version
- name: Run setup.py
run: python ./tools/setup.py

- name: Start sccache
env:
AWS_ACCESS_KEY_ID: AKIAIVRN52PLDBP55LBQ
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "chromium_build"]
path = core/libdeno/build
url = https://github.com/denoland/chromium_build.git
[submodule "deno_third_party"]
path = third_party
url = https://github.com/denoland/deno_third_party.git
Expand Down
38 changes: 34 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions cli/js/os_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,8 @@ testPerm({ env: true }, function getDir(): void {
for (const r of s.runtime) {
if (Deno.build.os !== r.os) continue;
if (r.shouldHaveValue) {
assertNotEquals(Deno.dir(s.kind), "");
} else {
assertEquals(Deno.dir(s.kind), null);
const d = Deno.dir(s.kind);
assert(d.length > 0);
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ fn repl_test() {
util::run_python_script("tools/repl_test.py")
}

#[test]
fn setup_test() {
util::run_python_script("tools/setup_test.py")
}

#[test]
fn target_test() {
util::run_python_script("tools/target_test.py")
Expand Down
3 changes: 3 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ log = "0.4.8"
serde_json = "1.0.41"
url = "2.1"

rusty_v8 = "0.0.23"
# rusty_v8 = { path = "../../rusty_v8" }

[[example]]
name = "deno_core_http_bench"
path = "examples/http_bench.rs"
Expand Down
148 changes: 0 additions & 148 deletions core/build.rs

This file was deleted.

41 changes: 2 additions & 39 deletions core/flags.rs
Original file line number Diff line number Diff line change
@@ -1,44 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
//! This module wraps libdeno::deno_set_v8_flags
use crate::libdeno::deno_set_v8_flags;
use libc::c_char;
use libc::c_int;
use std::ffi::CStr;
use std::ffi::CString;
use std::vec::Vec;

use rusty_v8 as v8;
/// Pass the command line arguments to v8.
/// Returns a vector of command line arguments that V8 did not understand.
pub fn v8_set_flags(args: Vec<String>) -> Vec<String> {
// deno_set_v8_flags(int* argc, char** argv) mutates argc and argv to remove
// flags that v8 understands.

// Make a new array, that can be modified by V8::SetFlagsFromCommandLine(),
// containing mutable raw pointers to the individual command line args.
let mut raw_argv = args
.iter()
.map(|arg| CString::new(arg.as_str()).unwrap().into_bytes_with_nul())
.collect::<Vec<_>>();
let mut c_argv = raw_argv
.iter_mut()
.map(|arg| arg.as_mut_ptr() as *mut c_char)
.collect::<Vec<_>>();

// Store the length of the c_argv array in a local variable. We'll pass
// a pointer to this local variable to deno_set_v8_flags(), which then
// updates its value.
let mut c_argv_len = c_argv.len() as c_int;
// Let v8 parse the arguments it recognizes and remove them from c_argv.
unsafe { deno_set_v8_flags(&mut c_argv_len, c_argv.as_mut_ptr()) };
// If c_argv_len was updated we have to change the length of c_argv to match.
c_argv.truncate(c_argv_len as usize);
// Copy the modified arguments list into a proper rust vec and return it.
c_argv
.iter()
.map(|ptr| unsafe {
let cstr = CStr::from_ptr(*ptr as *const c_char);
let slice = cstr.to_str().unwrap();
slice.to_string()
})
.collect()
v8::V8::set_flags_from_command_line(args)
}
Loading

0 comments on commit 5f1df03

Please sign in to comment.