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

build: make cargo check pass #1125

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ environment:
DENO_THIRD_PARTY_PATH: $(APPVEYOR_BUILD_FOLDER)\third_party
MTIME_CACHE_DB: $(APPVEYOR_BUILD_FOLDER)\mtime_cache.xml
CARGO_HOME: $(USERPROFILE)\.cargo
CARGO_TARGET_DIR: $(APPVEYOR_BUILD_FOLDER)\out\target
RUSTUP_HOME: $(USERPROFILE)\.rustup
RUST_BACKTRACE: 1
RELEASE_ARTIFACT: deno_win_x64.zip
Expand Down Expand Up @@ -335,6 +336,8 @@ before_build:
build_script:
- python tools\build.py
- ps: Set-FilesNeeded -Auto -Reason "Build finished"
- cargo check --release
- ps: Set-FilesNeeded -Auto -Reason "Cargo check finished"

test_script:
- python tools\lint.py
Expand Down
7 changes: 7 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2018 the Deno authors. All rights reserved. MIT license.

[build]
# The location of the cargo build directory can be overridden, but the name of
# the directory itself is best left at 'target'.
# https://github.com/rust-lang/cargo/pull/1657#issue-36459101
target-dir = "out/target"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, let's leave this file out for now.

4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ matrix:
env:
global:
- CARGO_HOME=$HOME/.cargo/
- CARGO_TARGET_DIR=$HOME/out/target
- RUSTUP_HOME=$HOME/.rustup/
- RUST_BACKTRACE=1
- HOMEBREW_PATH=$HOME/homebrew/
Expand Down Expand Up @@ -88,8 +89,9 @@ before_script:
script:
- ./tools/lint.py
- ./tools/test_format.py
- bash -c "sleep 2100; pkill ninja" &
- bash -c "sleep 2100; pkill ninja; pkill cargo" &
- ./tools/build.py -j2
- RUSTC_WRAPPER=sccache cargo check -j2 --release
- ./tools/test.py $DENO_BUILD_PATH
after_script:
- ccache --show-stats
Expand Down
11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ atty = "0.2.11"
dirs = "1.0.4"
flatbuffers = { path = "third_party/flatbuffers/rust/flatbuffers/" }
futures = "0.1.25"
getopts = "0.2.18"
hyper = "0.12.12"
# The current version of hyper-rustls, 0.14.0, depends on tokio-core, which is
# deprecated.
hyper-rustls = { git = "https://github.com/ctz/hyper-rustls.git" }
lazy_static = "1.1.0"
libc = "0.2.43"
log = "0.4.5"
# `msg_rs` is a wrapper crate to help cargo find the generated Rust flatbuffer
# source code that is built with our GN/ninja setup.
msg_rs = { path = "msg_rs" }
rand = "0.4.3"
remove_dir_all = "0.5.1"
ring = "0.13.2"
tempfile = "3"
tokio = "0.1.11"
tokio-executor = "0.1.5"
tokio-fs = "0.1.3"
tokio-io = "0.1.8"
tokio-threadpool = "0.1.6"
url = "1.7.1"
getopts = "0.2.18"
14 changes: 14 additions & 0 deletions msg_rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2018 the Deno authors. All rights reserved. MIT license.

[package]
name = "msg_rs"
version = "0.0.0"

[lib]
path = "lib.rs"

[build]
build = "build.rs"

[dependencies]
flatbuffers = { path = "../third_party/flatbuffers/rust/flatbuffers/" }
48 changes: 48 additions & 0 deletions msg_rs/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.

// This file doesn't actually attempt to to build anything. It just tries to
// guess where the generated flatbuffers source file 'msg_generated.rs' lives.

use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;

fn main() {
let build_dir = match env::var("DENO_BUILD_PATH") {
Ok(s) => {
// If DENO_BUILD_PATH is set, msg_generated.rs can be found here.
Path::new(&s).to_path_buf()
}
Err(_) => {
// If DENO_BUILD_PATH is not set, derive the build dir from the source
// directory and the cargo build mode. Note that cargo sets $PROFILE
// to either "debug" or "release", so that's quite convenient.
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let crate_dir = Path::new(&crate_dir);
let src_root_dir = crate_dir.parent().unwrap();
let profile = env::var("PROFILE").unwrap();
src_root_dir.join("out").join(profile)
}
};

let msg_gen_rs = build_dir.join("gen/msg_generated.rs");
let msg_gen_rs = msg_gen_rs.to_string_lossy().replace("\\", "/");

let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = Path::new(&out_dir);
let wrapper_rs = out_dir.join("find_msg_generated.inc.rs");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1337


let mut wrapper_file = File::create(&wrapper_rs).unwrap();
write!(
wrapper_file,
"
#[path = \"{}\"]
mod msg;
pub use msg::*;
",
msg_gen_rs
).unwrap();

println!("cargo:rerun-if-env-changed=DENO_BUILD_PATH");
}
3 changes: 3 additions & 0 deletions msg_rs/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.

include!(concat!(env!("OUT_DIR"), "/find_msg_generated.inc.rs"));
2 changes: 1 addition & 1 deletion tools/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def qrun(cmd, env=None):
qrun([
"third_party/rustfmt/" + platform() +
"/rustfmt", "--config-path", rustfmt_config
] + find_exts(["src"], [".rs"]))
] + find_exts(["src", "msg_rs"], [".rs"]))