-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-learner-index
- Loading branch information
Showing
45 changed files
with
3,518 additions
and
4,758 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,6 @@ tmp | |
harness/target | ||
|
||
Cargo.lock | ||
rust-toolchain | ||
*.rs.bk | ||
*.rs.fmt |
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,40 +1,30 @@ | ||
branches: | ||
only: | ||
# This is where pull requests from "bors r+" are built. | ||
- staging | ||
# This is where pull requests from "bors try" are built. | ||
- trying | ||
# Enable building pull requests. | ||
- master | ||
sudo: false | ||
|
||
language: rust | ||
sudo: false | ||
os: | ||
- linux | ||
- windows | ||
- osx | ||
rust: | ||
- stable | ||
- nightly | ||
# First Rust 2018 Stable. Officially the oldest compiler we support. | ||
- 1.31.0 | ||
env: | ||
global: | ||
- RUST_BACKTRACE=1 | ||
- RUSTFLAGS="-D warnings" | ||
cache: cargo | ||
|
||
rust: | ||
|
||
matrix: | ||
include: | ||
# This build uses stable and checks rustfmt and clippy. | ||
# We don't check them on nightly since their lints and formatting may differ. | ||
- rust: stable | ||
install: | ||
- rustup component add rustfmt-preview | ||
- rustup component add clippy-preview | ||
before_script: | ||
- cargo fmt --all -- --check | ||
- cargo clippy --all -- -D clippy | ||
# Since many users will use nightlies, also test that. | ||
- rust: nightly | ||
|
||
install: | ||
- if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then rustup component add rustfmt; fi | ||
- if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then rustup component add clippy; fi | ||
|
||
script: | ||
- if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo fmt -- --check; fi | ||
- if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo clippy -- -D clippy::all; fi | ||
- cargo test --all -- --nocapture | ||
# Validate benches still work. | ||
- cargo bench --all -- --test | ||
# Because failpoints inject failure in code path, which will affect all concurrently running tests, Hence they need to be synchronized, which make tests slow. | ||
- cargo test --tests --features failpoint -- --nocapture | ||
- cargo test --tests --features failpoint -- --nocapture |
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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2019 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use protobuf_build::*; | ||
use std::fs::{read_dir, File}; | ||
use std::io::Write; | ||
|
||
fn main() { | ||
// This build script creates files in the `src` directory. Since that is | ||
// outside Cargo's OUT_DIR it will cause an error when this crate is used | ||
// as a dependency. Therefore, the user must opt-in to regenerating the | ||
// Rust files. | ||
if !cfg!(feature = "gen") { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
return; | ||
} | ||
|
||
check_protoc_version(); | ||
|
||
let file_names: Vec<_> = read_dir("proto") | ||
.expect("Couldn't read proto directory") | ||
.filter_map(|e| { | ||
let e = e.expect("Couldn't list file"); | ||
if e.file_type().expect("File broken").is_dir() { | ||
None | ||
} else { | ||
Some(format!("proto/{}", e.file_name().to_string_lossy())) | ||
} | ||
}) | ||
.collect(); | ||
|
||
for f in &file_names { | ||
println!("cargo:rerun-if-changed={}", f); | ||
} | ||
|
||
// Generate Prost files. | ||
generate_prost_files(&file_names, "src/prost"); | ||
let mod_names = module_names_for_dir("src/prost"); | ||
generate_wrappers( | ||
&mod_names | ||
.iter() | ||
.map(|m| format!("src/prost/{}.rs", m)) | ||
.collect::<Vec<_>>(), | ||
"src/prost", | ||
GenOpt::All, | ||
); | ||
generate_prost_rs(&mod_names); | ||
} | ||
|
||
fn generate_prost_rs(mod_names: &[String]) { | ||
let mut text = "#![allow(dead_code)]\n\ | ||
#![allow(missing_docs)]\n\ | ||
#![allow(clippy::all)]\n\n" | ||
.to_owned(); | ||
|
||
for mod_name in mod_names { | ||
text.push_str("pub mod "); | ||
text.push_str(mod_name); | ||
text.push_str("{\n"); | ||
text.push_str("include!(\"prost/"); | ||
text.push_str(mod_name); | ||
text.push_str(".rs\");"); | ||
text.push_str("include!(\"prost/wrapper_"); | ||
text.push_str(mod_name); | ||
text.push_str(".rs\");"); | ||
text.push_str("}\n\n"); | ||
} | ||
|
||
let mut lib = File::create("src/prost.rs").expect("Could not create prost.rs"); | ||
lib.write_all(text.as_bytes()) | ||
.expect("Could not write prost.rs"); | ||
} |
Oops, something went wrong.