From 64dd1634348c9e4f37b655271420f3519fe5a880 Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Sun, 9 Apr 2017 13:50:59 -0700 Subject: [PATCH] Add try_patch shell function and update glue for latest nightlies --- build-src.sh | 2 +- build.rs | 10 +++++++++- functions.sh | 16 ++++++++++++++-- src/lib.rs | 5 ++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/build-src.sh b/build-src.sh index 2433b05..4af8ae8 100755 --- a/build-src.sh +++ b/build-src.sh @@ -17,7 +17,7 @@ prompt_changes() { GIT_DIR="$MAIN_GIT_DIR" git_commits_ordered '%H %cd' $(get_patch_commits) $IO_COMMIT | \ grep --color=always -1 $IO_COMMIT | sed /$IO_COMMIT/'s/$/ <=== your commit/' echo - bold_arrow; echo -e "Try applying one of those using: \e[1;36mpatch -p1 < ../../patches/COMMIT.patch\e[0m" + bold_arrow; echo -e "Try applying one of those using: \e[1;36mtry_patch COMMIT\e[0m" bold_arrow; echo -e "Remember to test your changes with: \e[1;36mcargo build\e[0m" bold_arrow; echo -e "Make your changes now (\e[1;36mctrl-D\e[0m when finished)" bash_diff_loop "No changes were made" diff --git a/build.rs b/build.rs index fb8ad75..a345b72 100644 --- a/build.rs +++ b/build.rs @@ -36,17 +36,25 @@ impl Sub for Vec { } fn main() { + let ver=rustc_version::version_meta(); + let io_commit=match env::var("CORE_IO_COMMIT") { Ok(c) => c, Err(env::VarError::NotUnicode(_)) => panic!("Invalid commit specified in CORE_IO_COMMIT"), Err(env::VarError::NotPresent) => { let mappings=include!("mapping.rs"); - let compiler=rustc_version::version_meta().commit_hash.expect("Couldn't determine compiler version"); + let compiler=ver.commit_hash.expect("Couldn't determine compiler version"); mappings.iter().find(|&&Mapping(elem,_)|elem==compiler).expect("Unknown compiler version, upgrade core_io?").1.to_owned() } }; + if ver.commit_date.as_ref().map_or(false,|d| &**d<"2016-12-15") { + println!("cargo:rustc-cfg=rustc_unicode"); + } else if ver.commit_date.as_ref().map_or(false,|d| &**d<"2017-03-03") { + println!("cargo:rustc-cfg=std_unicode"); + } + let mut dest_path=PathBuf::from(env::var_os("OUT_DIR").unwrap()); dest_path.push("io.rs"); let mut f=File::create(&dest_path).unwrap(); diff --git a/functions.sh b/functions.sh index dcd0b89..e099e01 100644 --- a/functions.sh +++ b/functions.sh @@ -41,7 +41,9 @@ get_patch_commits() { prepare_version() { mkdir src/$IO_COMMIT git_extract src/libstd/io/ - if git_file_exists src/libstd/sys/common/memchr.rs; then + if git_file_exists src/libstd/sys_common/memchr.rs; then + git_extract src/libstd/sys_common/memchr.rs + elif git_file_exists src/libstd/sys/common/memchr.rs; then git_extract src/libstd/sys/common/memchr.rs else git_extract src/libstd/memchr.rs @@ -53,8 +55,18 @@ bold_arrow() { echo -ne '\e[1;36m==> \e[0m' } +custom_bashrc() { + echo ' +if [ -f ~/.bashrc ]; then . ~/.bashrc; fi + +try_patch() { + patch -p1 < ../../patches/$1.patch +} +' +} + bash_diff_loop() { - bash <> /dev/stderr + bash --rcfile <(custom_bashrc) <> /dev/stderr while git diff --exit-code > /dev/null; do bold_arrow; echo "$1" while true; do diff --git a/src/lib.rs b/src/lib.rs index 6eca89b..bf07157 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,13 +3,16 @@ //! the [std documentation](https://doc.rust-lang.org/nightly/std/io/index.html) //! for a full description of the functionality. #![allow(stable_features,unused_features)] -#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,str_char,try_from)] +#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,str_char,try_from,str_internals)] #![no_std] #[cfg_attr(feature="collections",macro_use)] #[cfg(feature="collections")] extern crate collections; #[cfg(feature="alloc")] extern crate alloc; +#[cfg(rustc_unicode)] extern crate rustc_unicode; +#[cfg(std_unicode)] +extern crate std_unicode; #[cfg(not(feature="collections"))] pub type ErrorString = &'static str;