Skip to content

Commit

Permalink
Use Cargo to install rust deps into //third_party/rust_crates (denola…
Browse files Browse the repository at this point in the history
  • Loading branch information
robbym authored and ry committed Jul 19, 2018
1 parent 3dde880 commit d93bd4b
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ node_modules

# third party deps
/third_party/

# RLS generated files
/target/
80 changes: 80 additions & 0 deletions Cargo.lock

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

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Dummy package info required by `cargo fetch`
# Called from tools/build_third_party.py
# Should not be called with `cargo build`
[package]
name = "deno"
version = "0.0.0"

[dependencies]
url = "1.7.1"
libc = "0.2.42"
log = "0.4.3"
24 changes: 15 additions & 9 deletions build_extra/rust/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ rust_staticlib("stdlib") {
crates = "//third_party/rust_crates"

rust_component("libc") {
source_root = "$crates/libc/src/lib.rs"
source_root =
"$crates/registry/src/github.com-1ecc6299db9ec823/libc-0.2.42/src/lib.rs"
cfg = [ "feature=\"use_std\"" ]
}

rust_component("url") {
source_root = "$crates/url/src/lib.rs"
source_root =
"$crates/registry/src/github.com-1ecc6299db9ec823/url-1.7.1/src/lib.rs"
extern = [
":matches",
":idna",
Expand All @@ -31,15 +33,17 @@ rust_component("url") {
}

rust_component("percent_encoding") {
source_root = "$crates/url/percent_encoding/lib.rs"
source_root = "$crates/registry/src/github.com-1ecc6299db9ec823/percent-encoding-1.0.1/lib.rs"
}

rust_component("matches") {
source_root = "$crates/rust-std-candidates/matches/lib.rs"
source_root =
"$crates/registry/src/github.com-1ecc6299db9ec823/matches-0.1.6/lib.rs"
}

rust_component("idna") {
source_root = "$crates/url/idna/src/lib.rs"
source_root =
"$crates/registry/src/github.com-1ecc6299db9ec823/idna-0.1.5/src/lib.rs"
extern = [
":matches",
":unicode_bidi",
Expand All @@ -48,19 +52,21 @@ rust_component("idna") {
}

rust_component("unicode_bidi") {
source_root = "$crates/unicode-bidi/src/lib.rs"
source_root = "$crates/registry/src/github.com-1ecc6299db9ec823/unicode-bidi-0.3.4/src/lib.rs"
extern = [ ":matches" ]
}

rust_component("unicode_normalization") {
source_root = "$crates/unicode-normalization/src/lib.rs"
source_root = "$crates/registry/src/github.com-1ecc6299db9ec823/unicode-normalization-0.1.7/src/lib.rs"
}

rust_component("log") {
source_root = "$crates/log/src/lib.rs"
source_root =
"$crates/registry/src/github.com-1ecc6299db9ec823/log-0.4.3/src/lib.rs"
extern = [ ":cfg_if" ]
}

rust_component("cfg_if") {
source_root = "$crates/cfg_if/src/lib.rs"
source_root =
"$crates/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.4/src/lib.rs"
}
35 changes: 0 additions & 35 deletions gclient_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,4 @@
'https://github.com/rw/flatbuffers.git@2018-02--rust',
'name':
'flatbuffers'
}, {
'url':
'https://github.com/rust-lang/libc.git@8a85d662b90c14d458bc4ae9521a05564e20d7ae',
'name':
'rust_crates/libc'
}, {
'url':
'https://github.com/servo/rust-url.git@fbe5e50316105482dcd53d2dabb148c445a5f4cd',
'name':
'rust_crates/url'
}, {
# Needed for url.
'url':
'https://github.com/SimonSapin/rust-std-candidates.git@88a017b79ea146d6fde389c96982fc7518ba98bf',
'name':
'rust_crates/rust-std-candidates'
}, {
# Needed for url.
'url':
'https://github.com/servo/unicode-bidi.git@32c81729db0ac90289ebeca9e0d4886f264e724d',
'name':
'rust_crates/unicode-bidi'
}, {
# Needed for url.
'url':
'https://github.com/behnam/rust-unicode-normalization.git@3898e77b110246cb7243bf29b896c58d8975304a',
'name':
'rust_crates/unicode-normalization'
}, {
'url': 'https://github.com/rust-lang-nursery/[email protected]',
'name': 'rust_crates/log'
}, {
# Needed for log.
'url': 'https://github.com/alexcrichton/[email protected]',
'name': 'rust_crates/cfg_if'
}]
2 changes: 2 additions & 0 deletions tools/build_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
remove_and_symlink(join("v8", "third_party", "markupsafe"), "markupsafe")
run(["gclient", "sync", "--shallow", "--no-history"])
run(["yarn"])
run(["cargo", "fetch", "--manifest-path=../Cargo.toml"],
envs={'CARGO_HOME': third_party_path + '/rust_crates'})
4 changes: 3 additions & 1 deletion tools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import subprocess


def run(args, quiet=False):
def run(args, quiet=False, envs={}):
if not quiet:
print " ".join(args)
env = os.environ.copy()
for key in envs.keys():
env[key] = envs[key]
if os.name == "nt":
# Run through shell to make .bat/.cmd files work.
args = ["cmd", "/c"] + args
Expand Down

0 comments on commit d93bd4b

Please sign in to comment.