forked from abdul124/rust-core_io
Merge pull request #23 from jethrogb/fix-old-versions
Parse mapping.rs manually, fix CI versions.
This commit is contained in:
commit
83eeab3405
@ -9,7 +9,7 @@ branches:
|
|||||||
language: rust
|
language: rust
|
||||||
dist: xenial
|
dist: xenial
|
||||||
rust:
|
rust:
|
||||||
- nightly-2015-05-01 # see ct.sh for more versions
|
- nightly-2016-03-11 # see ct.sh for more versions
|
||||||
env:
|
env:
|
||||||
- RUST_BACKTRACE=1
|
- RUST_BACKTRACE=1
|
||||||
before_script:
|
before_script:
|
||||||
|
60
build.rs
60
build.rs
@ -4,35 +4,45 @@ use std::env;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::ops::{Neg,Sub};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Let me explain this hack. For the sync shell script it's easiest if every
|
|
||||||
* line in mapping.rs looks exactly the same. This means that specifying an
|
|
||||||
* array literal is not possible. include!() can only expand to expressions, so
|
|
||||||
* just specifying the contents of an array is also not possible.
|
|
||||||
*
|
|
||||||
* This leaves us with trying to find an expression in which every line looks
|
|
||||||
* the same. This can be done using the `-` operator. This can be a unary
|
|
||||||
* operator (first thing on the first line), or a binary operator (later
|
|
||||||
* lines). That is exactly what's going on here, and Neg and Sub simply build a
|
|
||||||
* vector of the operangs.
|
|
||||||
*/
|
|
||||||
struct Mapping(&'static str,&'static str);
|
struct Mapping(&'static str,&'static str);
|
||||||
|
|
||||||
impl Neg for Mapping {
|
fn parse_mappings(mut mappings: &'static str) -> Vec<Mapping> {
|
||||||
type Output = Vec<Mapping>;
|
// FIXME: The format used here used to be parsed directly by rustc, which
|
||||||
fn neg(self) -> Vec<Mapping> {
|
// is why it's kind of weird. It should be changed to a saner format.
|
||||||
vec![self.into()]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Sub<Mapping> for Vec<Mapping> {
|
const P1: &'static str = r#"-Mapping(""#;
|
||||||
type Output=Vec<Mapping>;
|
const P2: &'static str = r#"",""#; ;
|
||||||
fn sub(mut self, rhs: Mapping) -> Vec<Mapping> {
|
const P3: &'static str = "\")\n";
|
||||||
self.push(rhs.into());
|
|
||||||
self
|
trait TakePrefix: Sized {
|
||||||
|
fn take_prefix(&mut self, mid: usize) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> TakePrefix for &'a str {
|
||||||
|
fn take_prefix(&mut self, mid: usize) -> Self {
|
||||||
|
let prefix = &self[..mid];
|
||||||
|
*self = &self[mid..];
|
||||||
|
prefix
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut result = Vec::with_capacity( mappings.len() / (P1.len()+40+P2.len()+40+P3.len()) );
|
||||||
|
|
||||||
|
while mappings.len() != 0 {
|
||||||
|
match (
|
||||||
|
mappings.take_prefix(P1.len()),
|
||||||
|
mappings.take_prefix(40),
|
||||||
|
mappings.take_prefix(P2.len()),
|
||||||
|
mappings.take_prefix(40),
|
||||||
|
mappings.take_prefix(P3.len()),
|
||||||
|
) {
|
||||||
|
(P1, hash1, P2, hash2, P3) => result.push(Mapping(hash1, hash2)),
|
||||||
|
_ => panic!("Invalid input in mappings"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -42,7 +52,7 @@ fn main() {
|
|||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(env::VarError::NotUnicode(_)) => panic!("Invalid commit specified in CORE_IO_COMMIT"),
|
Err(env::VarError::NotUnicode(_)) => panic!("Invalid commit specified in CORE_IO_COMMIT"),
|
||||||
Err(env::VarError::NotPresent) => {
|
Err(env::VarError::NotPresent) => {
|
||||||
let mappings=include!("mapping.rs");
|
let mappings=parse_mappings(include_str!("mapping.rs"));
|
||||||
|
|
||||||
let compiler=ver.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()
|
mappings.iter().find(|&&Mapping(elem,_)|elem==compiler).expect("Unknown compiler version, upgrade core_io?").1.to_owned()
|
||||||
|
33
ct.sh
33
ct.sh
@ -1,21 +1,24 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
# Old versions should come first so we go from oldest Cargo.lock version to
|
||||||
|
# newest when building.
|
||||||
RUST_VERSIONS=$(awk '{print $1}' <<EOF
|
RUST_VERSIONS=$(awk '{print $1}' <<EOF
|
||||||
nightly-2019-04-27 # core_io release
|
nightly-2016-03-11 # first supported version
|
||||||
nightly-2018-08-14 # edge case: old features disallowed
|
|
||||||
nightly-2018-08-06 # edge case: old features allowed
|
|
||||||
nightly-2018-03-07 # core_io release
|
|
||||||
nightly-2018-01-02 # edge case: memchr in core
|
|
||||||
nightly-2018-01-01 # edge case: no memchr in core
|
|
||||||
nightly-2017-06-16 # edge case: no collections crate
|
|
||||||
nightly-2017-06-15 # edge case: collections crate
|
|
||||||
nightly-2017-04-09 # core_io release
|
|
||||||
nightly-2017-03-04 # edge case: std_unicode crate
|
|
||||||
nightly-2017-03-03 # edge case: rustc_unicode crate
|
|
||||||
nightly-2017-01-18 # edge case: rustc_unicode crate
|
|
||||||
nightly-2016-12-05 # edge case: no unicode crate
|
|
||||||
nightly-2016-10-28 # core_io release
|
|
||||||
nightly-2016-07-07 # core_io release
|
nightly-2016-07-07 # core_io release
|
||||||
nightly-2015-05-01 # some old version
|
nightly-2016-10-28 # core_io release
|
||||||
|
nightly-2016-12-05 # edge case: no unicode crate
|
||||||
|
nightly-2017-01-18 # edge case: rustc_unicode crate
|
||||||
|
nightly-2017-03-03 # edge case: rustc_unicode crate
|
||||||
|
nightly-2017-03-04 # edge case: std_unicode crate
|
||||||
|
nightly-2017-04-09 # core_io release
|
||||||
|
nightly-2017-06-15 # edge case: collections crate
|
||||||
|
nightly-2017-06-16 # edge case: no collections crate
|
||||||
|
nightly-2018-01-01 # edge case: no memchr in core
|
||||||
|
nightly-2018-01-02 # edge case: memchr in core
|
||||||
|
nightly-2018-03-07 # core_io release
|
||||||
|
nightly-2018-08-06 # edge case: old features allowed
|
||||||
|
nightly-2018-08-14 # edge case: old features disallowed
|
||||||
|
nightly-2019-04-27 # core_io release
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
//! the [std documentation](https://doc.rust-lang.org/nightly/std/io/index.html)
|
//! the [std documentation](https://doc.rust-lang.org/nightly/std/io/index.html)
|
||||||
//! for a full description of the functionality.
|
//! for a full description of the functionality.
|
||||||
#![allow(stable_features,unused_features)]
|
#![allow(stable_features,unused_features)]
|
||||||
#![feature(question_mark,const_fn,copy_from_slice,non_exhaustive,
|
#![feature(question_mark,const_fn,collections,alloc,unicode,copy_from_slice,
|
||||||
bind_by_move_pattern_guards,try_from,str_internals,align_offset,doc_spotlight,
|
str_char,try_from,str_internals,align_offset,doc_spotlight,
|
||||||
slice_internals)]
|
slice_internals,non_exhaustive,bind_by_move_pattern_guards)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
#[cfg_attr(feature="collections",macro_use)]
|
#[cfg_attr(feature="collections",macro_use)]
|
||||||
|
Loading…
Reference in New Issue
Block a user