forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
109 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,57 @@ | ||
import("rust.gni") | ||
|
||
# Dependencies between third party crates is mapped out here manually. This is | ||
# not so difficult and having it be tedious to add dependencies might help us | ||
# avoid dependency hell later on. | ||
# Versioning for third party rust crates is controlled in //gclient_config.py | ||
# TODO(ry) Use Cargo for versioning? | ||
|
||
# By compiling an empty file as crate-type=staticlib we get all the code | ||
# for the rust stdlib, which are not included in the object file outputs | ||
# of other libs. | ||
rust_component("stdlib") { | ||
crate_type = "staticlib" | ||
# TODO(ry) This is not used and maybe should be removed along with empty.rs. | ||
rust_staticlib("stdlib") { | ||
source_root = "empty.rs" | ||
if (current_os == "mac") { | ||
libs = [ "resolv" ] | ||
} | ||
if (current_os == "win") { | ||
libs = [ "userenv.lib" ] | ||
} | ||
} | ||
|
||
crates = "//third_party/rust_crates" | ||
|
||
rust_component("libc") { | ||
source_root = "//third_party/rust_crates/libc/src/lib.rs" | ||
cfg = [ | ||
"feature=\"default\"", | ||
"feature=\"use_std\"", | ||
source_root = "$crates/libc/src/lib.rs" | ||
cfg = [ "feature=\"use_std\"" ] | ||
} | ||
|
||
rust_component("url") { | ||
source_root = "$crates/url/src/lib.rs" | ||
extern = [ | ||
":matches", | ||
":idna", | ||
":percent_encoding", | ||
] | ||
} | ||
|
||
rust_component("percent_encoding") { | ||
source_root = "$crates/url/percent_encoding/lib.rs" | ||
} | ||
|
||
rust_component("matches") { | ||
source_root = "$crates/rust-std-candidates/matches/lib.rs" | ||
} | ||
|
||
rust_component("idna") { | ||
source_root = "$crates/url/idna/src/lib.rs" | ||
extern = [ | ||
":matches", | ||
":unicode_bidi", | ||
":unicode_normalization", | ||
] | ||
} | ||
|
||
rust_component("unicode_bidi") { | ||
source_root = "$crates/unicode-bidi/src/lib.rs" | ||
extern = [ ":matches" ] | ||
} | ||
|
||
rust_component("unicode_normalization") { | ||
source_root = "$crates/unicode-normalization/src/lib.rs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
extern crate libc; | ||
extern crate url; | ||
|
||
use libc::c_char; | ||
use std::ffi::CStr; | ||
use url::Url; | ||
|
||
fn string_from_ptr(ptr: *const c_char) -> String { | ||
let cstr = unsafe { CStr::from_ptr(ptr as *const i8) }; | ||
String::from(cstr.to_str().unwrap()) | ||
} | ||
|
||
#[test] | ||
fn test_example() { | ||
assert_eq!(2 + 2, 4); | ||
fn test_url() { | ||
let issue_list_url = Url::parse("https://github.com/rust-lang").unwrap(); | ||
assert!(issue_list_url.scheme() == "https"); | ||
} | ||
|
||
#[no_mangle] | ||
|