Auto merge of #42664 - alexcrichton:moar-crates, r=eddyb

Remove in-tree flate/getopts crates

Remove `src/libflate` in favor of `flate2` on crates.io and `src/libgetopts` in favor of `getopts` on crates.io. The replacements have slightly different APIs and the usage in the compiler has been updated to reflect this.

This uncovered an unfortunate limitation of the compiler today to deal with linking everything correctly, and the workaround can be found documented in `src/librustc/Cargo.toml`.
This commit is contained in:
bors 2017-06-21 06:27:36 +00:00
commit 37a991abc0
33 changed files with 389 additions and 2409 deletions

View file

@ -22,12 +22,6 @@ The Rust Project includes packages written by third parties.
The following third party packages are included, and carry
their own copyright notices and license terms:
* The src/rt/miniz.c file, carrying an implementation of
RFC1950/RFC1951 DEFLATE, by Rich Geldreich
<richgel99@gmail.com>. All uses of this file are
permitted by the embedded "unlicense" notice
(effectively: public domain with warranty disclaimer).
* LLVM. Code for this package is found in src/llvm.
Copyright (c) 2003-2013 University of Illinois at

20
src/Cargo.lock generated
View file

@ -285,6 +285,7 @@ dependencies = [
"diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -422,14 +423,6 @@ dependencies = [
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "flate"
version = "0.0.0"
dependencies = [
"build_helper 0.1.0",
"gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "flate2"
version = "0.2.19"
@ -463,10 +456,6 @@ name = "gcc"
version = "0.3.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "getopts"
version = "0.0.0"
[[package]]
name = "getopts"
version = "0.2.14"
@ -1107,6 +1096,7 @@ name = "rustc"
version = "0.0.0"
dependencies = [
"arena 0.0.0",
"flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"fmt_macros 0.0.0",
"graphviz 0.0.0",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1296,7 +1286,7 @@ dependencies = [
name = "rustc_metadata"
version = "0.0.0"
dependencies = [
"flate 0.0.0",
"flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"proc_macro 0.0.0",
@ -1404,7 +1394,7 @@ dependencies = [
name = "rustc_trans"
version = "0.0.0"
dependencies = [
"flate 0.0.0",
"flate2 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1790,7 +1780,7 @@ dependencies = [
name = "test"
version = "0.0.0"
dependencies = [
"getopts 0.0.0",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.0.0",
]

View file

@ -567,7 +567,6 @@ pub fn rust_src(build: &Build) {
"src/rustc/libc_shim",
"src/libtest",
"src/libterm",
"src/libgetopts",
"src/compiler-rt",
"src/jemalloc",
"src/libprofiler_builtins",

View file

@ -1,14 +0,0 @@
[package]
authors = ["The Rust Project Developers"]
name = "flate"
version = "0.0.0"
build = "build.rs"
[lib]
name = "flate"
path = "lib.rs"
crate-type = ["dylib"]
[build-dependencies]
build_helper = { path = "../build_helper" }
gcc = "0.3.50"

View file

@ -1,18 +0,0 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate gcc;
fn main() {
println!("cargo:rerun-if-changed=../rt/miniz.c");
gcc::Config::new()
.file("../rt/miniz.c")
.compile("libminiz.a");
}

View file

@ -1,166 +0,0 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Simple [DEFLATE][def]-based compression. This is a wrapper around the
//! [`miniz`][mz] library, which is a one-file pure-C implementation of zlib.
//!
//! [def]: https://en.wikipedia.org/wiki/DEFLATE
//! [mz]: https://code.google.com/p/miniz/
#![crate_name = "flate"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
test(attr(deny(warnings))))]
#![deny(warnings)]
#![feature(libc)]
#![feature(unique)]
#![cfg_attr(test, feature(rand))]
extern crate libc;
use libc::{c_int, c_void, size_t};
use std::fmt;
use std::ops::Deref;
use std::ptr::Unique;
use std::slice;
#[derive(Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Error {
_unused: (),
}
impl Error {
fn new() -> Error {
Error { _unused: () }
}
}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
"decompression error".fmt(f)
}
}
pub struct Bytes {
ptr: Unique<u8>,
len: usize,
}
impl Deref for Bytes {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe { slice::from_raw_parts(self.ptr.as_ptr(), self.len) }
}
}
impl Drop for Bytes {
fn drop(&mut self) {
unsafe {
libc::free(self.ptr.as_ptr() as *mut _);
}
}
}
extern "C" {
/// Raw miniz compression function.
fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *mut c_void;
/// Raw miniz decompression function.
fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *mut c_void;
}
const LZ_FAST: c_int = 0x01; // LZ with 1 probe, "fast"
const TDEFL_GREEDY_PARSING_FLAG: c_int = 0x04000; // fast greedy parsing instead of lazy parsing
/// Compress a buffer without writing any sort of header on the output. Fast
/// compression is used because it is almost twice as fast as default
/// compression and the compression ratio is only marginally worse.
pub fn deflate_bytes(bytes: &[u8]) -> Bytes {
let flags = LZ_FAST | TDEFL_GREEDY_PARSING_FLAG;
unsafe {
let mut outsz: size_t = 0;
let res = tdefl_compress_mem_to_heap(bytes.as_ptr() as *const _,
bytes.len() as size_t,
&mut outsz,
flags);
assert!(!res.is_null());
Bytes {
ptr: Unique::new(res as *mut u8),
len: outsz as usize,
}
}
}
/// Decompress a buffer without parsing any sort of header on the input.
pub fn inflate_bytes(bytes: &[u8]) -> Result<Bytes, Error> {
let flags = 0;
unsafe {
let mut outsz: size_t = 0;
let res = tinfl_decompress_mem_to_heap(bytes.as_ptr() as *const _,
bytes.len() as size_t,
&mut outsz,
flags);
if !res.is_null() {
Ok(Bytes {
ptr: Unique::new(res as *mut u8),
len: outsz as usize,
})
} else {
Err(Error::new())
}
}
}
#[cfg(test)]
mod tests {
#![allow(deprecated)]
use super::{deflate_bytes, inflate_bytes};
use std::__rand::{Rng, thread_rng};
#[test]
fn test_flate_round_trip() {
let mut r = thread_rng();
let mut words = vec![];
for _ in 0..20 {
let range = r.gen_range(1, 10);
let v = r.gen_iter::<u8>().take(range).collect::<Vec<u8>>();
words.push(v);
}
for _ in 0..20 {
let mut input = vec![];
for _ in 0..2000 {
input.extend_from_slice(r.choose(&words).unwrap());
}
let cmp = deflate_bytes(&input);
let out = inflate_bytes(&cmp).unwrap();
assert_eq!(&*input, &*out);
}
}
#[test]
fn test_zlib_flate() {
let bytes = vec![1, 2, 3, 4, 5];
let deflated = deflate_bytes(&bytes);
let inflated = inflate_bytes(&deflated).unwrap();
assert_eq!(&*inflated, &*bytes);
}
}

View file

@ -1,9 +0,0 @@
[package]
authors = ["The Rust Project Developers"]
name = "getopts"
version = "0.0.0"
[lib]
name = "getopts"
path = "lib.rs"
crate-type = ["dylib", "rlib"]

View file

@ -22,3 +22,32 @@ rustc_errors = { path = "../librustc_errors" }
serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
# Note that these dependencies are a lie, they're just here to get linkage to
# work.
#
# We're creating a bunch of dylibs for the compiler but we're also compiling a
# bunch of crates.io crates. Everything in the compiler is compiled as an
# rlib/dylib pair but all crates.io crates tend to just be rlibs. This means
# we've got a problem for dependency graphs that look like:
#
# foo - rustc_trans
# / \
# rustc ---- rustc_driver
# \ /
# foo - rustc_metadata
#
# Here the crate `foo` is linked into the `rustc_trans` and the
# `rustc_metadata` dylibs, meaning we've got duplicate copies! When we then
# go to link `rustc_driver` the compiler notices this and gives us a compiler
# error.
#
# To work around this problem we just add these crates.io dependencies to the
# `rustc` crate which is a shared dependency above. That way the crate `foo`
# shows up in the dylib for the `rustc` crate, deduplicating it and allowing
# crates like `rustc_trans` to use `foo` *through* the `rustc` crate.
#
# tl;dr; this is not needed to get `rustc` to compile, but if you remove it then
# later crate stop compiling. If you can remove this and everything
# compiles, then please feel free to do so!
flate2 = "0.2"

View file

@ -41,6 +41,7 @@
#![feature(discriminant_value)]
#![feature(sort_unstable)]
#![feature(trace_macros)]
#![feature(test)]
#![recursion_limit="256"]
@ -63,6 +64,11 @@
extern crate serialize as rustc_serialize; // used by deriving
// Note that librustc doesn't actually depend on these crates, see the note in
// `Cargo.toml` for this crate about why these are here.
extern crate flate2;
extern crate test;
#[macro_use]
mod macros;

View file

@ -1135,9 +1135,9 @@ pub enum OptionStability {
Unstable,
}
#[derive(Clone, PartialEq, Eq)]
pub struct RustcOptGroup {
pub opt_group: getopts::OptGroup,
pub apply: Box<Fn(&mut getopts::Options) -> &mut getopts::Options>,
pub name: &'static str,
pub stability: OptionStability,
}
@ -1146,12 +1146,24 @@ pub fn is_stable(&self) -> bool {
self.stability == OptionStability::Stable
}
pub fn stable(g: getopts::OptGroup) -> RustcOptGroup {
RustcOptGroup { opt_group: g, stability: OptionStability::Stable }
pub fn stable<F>(name: &'static str, f: F) -> RustcOptGroup
where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static,
{
RustcOptGroup {
name: name,
apply: Box::new(f),
stability: OptionStability::Stable,
}
}
pub fn unstable(g: getopts::OptGroup) -> RustcOptGroup {
RustcOptGroup { opt_group: g, stability: OptionStability::Unstable }
pub fn unstable<F>(name: &'static str, f: F) -> RustcOptGroup
where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static,
{
RustcOptGroup {
name: name,
apply: Box::new(f),
stability: OptionStability::Unstable,
}
}
}
@ -1170,41 +1182,58 @@ mod opt {
use super::RustcOptGroup;
pub type R = RustcOptGroup;
pub type S<'a> = &'a str;
pub type S = &'static str;
fn stable(g: getopts::OptGroup) -> R { RustcOptGroup::stable(g) }
fn unstable(g: getopts::OptGroup) -> R { RustcOptGroup::unstable(g) }
fn stable<F>(name: S, f: F) -> R
where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static
{
RustcOptGroup::stable(name, f)
}
fn unstable<F>(name: S, f: F) -> R
where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static
{
RustcOptGroup::unstable(name, f)
}
fn longer(a: S, b: S) -> S {
if a.len() > b.len() {
a
} else {
b
}
}
pub fn opt_s(a: S, b: S, c: S, d: S) -> R {
stable(getopts::optopt(a, b, c, d))
stable(longer(a, b), move |opts| opts.optopt(a, b, c, d))
}
pub fn multi_s(a: S, b: S, c: S, d: S) -> R {
stable(getopts::optmulti(a, b, c, d))
stable(longer(a, b), move |opts| opts.optmulti(a, b, c, d))
}
pub fn flag_s(a: S, b: S, c: S) -> R {
stable(getopts::optflag(a, b, c))
stable(longer(a, b), move |opts| opts.optflag(a, b, c))
}
pub fn flagopt_s(a: S, b: S, c: S, d: S) -> R {
stable(getopts::optflagopt(a, b, c, d))
stable(longer(a, b), move |opts| opts.optflagopt(a, b, c, d))
}
pub fn flagmulti_s(a: S, b: S, c: S) -> R {
stable(getopts::optflagmulti(a, b, c))
stable(longer(a, b), move |opts| opts.optflagmulti(a, b, c))
}
pub fn opt(a: S, b: S, c: S, d: S) -> R {
unstable(getopts::optopt(a, b, c, d))
unstable(longer(a, b), move |opts| opts.optopt(a, b, c, d))
}
pub fn multi(a: S, b: S, c: S, d: S) -> R {
unstable(getopts::optmulti(a, b, c, d))
unstable(longer(a, b), move |opts| opts.optmulti(a, b, c, d))
}
pub fn flag(a: S, b: S, c: S) -> R {
unstable(getopts::optflag(a, b, c))
unstable(longer(a, b), move |opts| opts.optflag(a, b, c))
}
pub fn flagopt(a: S, b: S, c: S, d: S) -> R {
unstable(getopts::optflagopt(a, b, c, d))
unstable(longer(a, b), move |opts| opts.optflagopt(a, b, c, d))
}
pub fn flagmulti(a: S, b: S, c: S) -> R {
unstable(getopts::optflagmulti(a, b, c))
unstable(longer(a, b), move |opts| opts.optflagmulti(a, b, c))
}
}
@ -1212,13 +1241,6 @@ pub fn flagmulti(a: S, b: S, c: S) -> R {
/// including metadata for each option, such as whether the option is
/// part of the stable long-term interface for rustc.
pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
let mut print_opts = vec!["crate-name", "file-names", "sysroot", "cfg",
"target-list", "target-cpus", "target-features",
"relocation-models", "code-models"];
if nightly_options::is_nightly_build() {
print_opts.push("target-spec-json");
}
vec![
opt::flag_s("h", "help", "Display this message"),
opt::multi_s("", "cfg", "Configure the compilation environment", "SPEC"),
@ -1238,8 +1260,10 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
the compiler to emit",
"[asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]"),
opt::multi_s("", "print", "Comma separated list of compiler information to \
print on stdout", &format!("[{}]",
&print_opts.join("|"))),
print on stdout",
"[crate-name|file-names|sysroot|cfg|target-list|\
target-cpus|target-features|relocation-models|\
code-models|target-spec-json]"),
opt::flagmulti_s("g", "", "Equivalent to -C debuginfo=2"),
opt::flagmulti_s("O", "", "Equivalent to -C opt-level=2"),
opt::opt_s("o", "", "Write output to <filename>", "FILENAME"),
@ -1267,7 +1291,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
/// long-term interface for rustc.
pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
let mut opts = rustc_short_optgroups();
opts.extend_from_slice(&[
opts.extend(vec![
opt::multi_s("", "extern", "Specify where an external rust library is located",
"NAME=PATH"),
opt::opt_s("", "sysroot", "Override the system root", "PATH"),
@ -1680,19 +1704,14 @@ pub fn check_nightly_options(matches: &getopts::Matches, flags: &[RustcOptGroup]
if opt.stability == OptionStability::Stable {
continue
}
let opt_name = if opt.opt_group.long_name.is_empty() {
&opt.opt_group.short_name
} else {
&opt.opt_group.long_name
};
if !matches.opt_present(opt_name) {
if !matches.opt_present(opt.name) {
continue
}
if opt_name != "Z" && !has_z_unstable_option {
if opt.name != "Z" && !has_z_unstable_option {
early_error(ErrorOutputType::default(),
&format!("the `-Z unstable-options` flag must also be passed to enable \
the flag `{}`",
opt_name));
opt.name));
}
if really_allows_unstable_options {
continue
@ -1700,7 +1719,7 @@ pub fn check_nightly_options(matches: &getopts::Matches, flags: &[RustcOptGroup]
match opt.stability {
OptionStability::Unstable => {
let msg = format!("the option `{}` is only accepted on the \
nightly compiler", opt_name);
nightly compiler", opt.name);
early_error(ErrorOutputType::default(), &msg);
}
OptionStability::Stable => {}
@ -1869,7 +1888,7 @@ pub fn stable_hash(sub_hashes: BTreeMap<&'static str, &DepTrackingHash>,
mod tests {
use dep_graph::DepGraph;
use errors;
use getopts::{getopts, OptGroup};
use getopts;
use lint;
use middle::cstore::{self, DummyCrateStore};
use session::config::{build_configuration, build_session_options_and_crate_config};
@ -1882,10 +1901,12 @@ mod tests {
use rustc_back::PanicStrategy;
use syntax::symbol::Symbol;
fn optgroups() -> Vec<OptGroup> {
super::rustc_optgroups().into_iter()
.map(|a| a.opt_group)
.collect()
fn optgroups() -> getopts::Options {
let mut opts = getopts::Options::new();
for group in super::rustc_optgroups() {
(group.apply)(&mut opts);
}
return opts
}
fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
@ -1901,7 +1922,7 @@ fn mk_set<V: Ord>(entries: Vec<V>) -> BTreeSet<V> {
fn test_switch_implies_cfg_test() {
let dep_graph = DepGraph::new(false);
let matches =
&match getopts(&["--test".to_string()], &optgroups()) {
&match optgroups().parse(&["--test".to_string()]) {
Ok(m) => m,
Err(f) => panic!("test_switch_implies_cfg_test: {}", f)
};
@ -1918,8 +1939,7 @@ fn test_switch_implies_cfg_test() {
fn test_switch_implies_cfg_test_unless_cfg_test() {
let dep_graph = DepGraph::new(false);
let matches =
&match getopts(&["--test".to_string(), "--cfg=test".to_string()],
&optgroups()) {
&match optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]) {
Ok(m) => m,
Err(f) => {
panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f)
@ -1939,9 +1959,9 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
fn test_can_print_warnings() {
let dep_graph = DepGraph::new(false);
{
let matches = getopts(&[
let matches = optgroups().parse(&[
"-Awarnings".to_string()
], &optgroups()).unwrap();
]).unwrap();
let registry = errors::registry::Registry::new(&[]);
let (sessopts, _) = build_session_options_and_crate_config(&matches);
let sess = build_session(sessopts, &dep_graph, None, registry,
@ -1950,10 +1970,10 @@ fn test_can_print_warnings() {
}
{
let matches = getopts(&[
let matches = optgroups().parse(&[
"-Awarnings".to_string(),
"-Dwarnings".to_string()
], &optgroups()).unwrap();
]).unwrap();
let registry = errors::registry::Registry::new(&[]);
let (sessopts, _) = build_session_options_and_crate_config(&matches);
let sess = build_session(sessopts, &dep_graph, None, registry,
@ -1962,9 +1982,9 @@ fn test_can_print_warnings() {
}
{
let matches = getopts(&[
let matches = optgroups().parse(&[
"-Adead_code".to_string()
], &optgroups()).unwrap();
]).unwrap();
let registry = errors::registry::Registry::new(&[]);
let (sessopts, _) = build_session_options_and_crate_config(&matches);
let sess = build_session(sessopts, &dep_graph, None, registry,

View file

@ -725,10 +725,10 @@ fn usage(verbose: bool, include_unstable_options: bool) {
} else {
config::rustc_short_optgroups()
};
let groups: Vec<_> = groups.into_iter()
.filter(|x| include_unstable_options || x.is_stable())
.map(|x| x.opt_group)
.collect();
let mut options = getopts::Options::new();
for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) {
(option.apply)(&mut options);
}
let message = format!("Usage: rustc [OPTIONS] INPUT");
let extra_help = if verbose {
""
@ -741,7 +741,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
Print 'lint' options and default settings
-Z help Print internal \
options for debugging rustc{}\n",
getopts::usage(&message, &groups),
options.usage(&message),
extra_help);
}
@ -955,11 +955,11 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
// Parse with *all* options defined in the compiler, we don't worry about
// option stability here we just want to parse as much as possible.
let all_groups: Vec<getopts::OptGroup> = config::rustc_optgroups()
.into_iter()
.map(|x| x.opt_group)
.collect();
let matches = match getopts::getopts(&args, &all_groups) {
let mut options = getopts::Options::new();
for option in config::rustc_optgroups() {
(option.apply)(&mut options);
}
let matches = match options.parse(args) {
Ok(m) => m,
Err(f) => early_error(ErrorOutputType::default(), &f.to_string()),
};

View file

@ -9,7 +9,7 @@ path = "lib.rs"
crate-type = ["dylib"]
[dependencies]
flate = { path = "../libflate" }
flate2 = "0.2"
log = "0.3"
owning_ref = "0.3.3"
proc_macro = { path = "../libproc_macro" }

View file

@ -33,7 +33,7 @@
#[macro_use]
extern crate syntax;
extern crate syntax_pos;
extern crate flate;
extern crate flate2;
extern crate serialize as rustc_serialize; // used by deriving
extern crate owning_ref;
extern crate rustc_errors as errors;

View file

@ -242,7 +242,7 @@
use std::path::{Path, PathBuf};
use std::time::Instant;
use flate;
use flate2::read::ZlibDecoder;
use owning_ref::{ErasedBoxRef, OwningRef};
pub struct CrateMismatch {
@ -861,8 +861,9 @@ fn get_metadata_section_imp(target: &Target,
// Header is okay -> inflate the actual metadata
let compressed_bytes = &buf[header_len..];
debug!("inflating {} bytes of compressed metadata", compressed_bytes.len());
match flate::inflate_bytes(compressed_bytes) {
Ok(inflated) => {
let mut inflated = Vec::new();
match ZlibDecoder::new(compressed_bytes).read_to_end(&mut inflated) {
Ok(_) => {
let buf = unsafe { OwningRef::new_assert_stable_address(inflated) };
buf.map_owner_box().erase_owner()
}

View file

@ -10,7 +10,7 @@ crate-type = ["dylib"]
test = false
[dependencies]
flate = { path = "../libflate" }
flate2 = "0.2"
log = "0.3"
owning_ref = "0.3.3"
rustc = { path = "../librustc" }

View file

@ -42,7 +42,8 @@
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str;
use flate;
use flate2::Compression;
use flate2::write::ZlibEncoder;
use syntax::ast;
use syntax::attr;
use syntax_pos::Span;
@ -570,7 +571,9 @@ fn link_rlib<'a>(sess: &'a Session,
e))
}
let bc_data_deflated = flate::deflate_bytes(&bc_data);
let mut bc_data_deflated = Vec::new();
ZlibEncoder::new(&mut bc_data_deflated, Compression::Default)
.write_all(&bc_data).unwrap();
let mut bc_file_deflated = match fs::File::create(&bc_deflated_filename) {
Ok(file) => file,

View file

@ -21,8 +21,9 @@
use back::write::{ModuleConfig, with_llvm_pmb};
use libc;
use flate;
use flate2::read::ZlibDecoder;
use std::io::Read;
use std::ffi::CString;
use std::path::Path;
@ -112,13 +113,14 @@ pub fn run(sess: &session::Session,
link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET..
(link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as usize)];
match flate::inflate_bytes(compressed_data) {
Ok(inflated) => inflated,
Err(_) => {
sess.fatal(&format!("failed to decompress bc of `{}`",
name))
}
let mut inflated = Vec::new();
let res = ZlibDecoder::new(compressed_data)
.read_to_end(&mut inflated);
if res.is_err() {
sess.fatal(&format!("failed to decompress bc of `{}`",
name))
}
inflated
} else {
sess.fatal(&format!("Unsupported bytecode format version {}",
version))
@ -129,13 +131,14 @@ pub fn run(sess: &session::Session,
// the object must be in the old, pre-versioning format, so
// simply inflate everything and let LLVM decide if it can
// make sense of it
match flate::inflate_bytes(bc_encoded) {
Ok(bc) => bc,
Err(_) => {
sess.fatal(&format!("failed to decompress bc of `{}`",
name))
}
let mut inflated = Vec::new();
let res = ZlibDecoder::new(bc_encoded)
.read_to_end(&mut inflated);
if res.is_err() {
sess.fatal(&format!("failed to decompress bc of `{}`",
name))
}
inflated
})
};

View file

@ -727,7 +727,9 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
link_meta: &LinkMeta,
exported_symbols: &NodeSet)
-> (ContextRef, ModuleRef, EncodedMetadata) {
use flate;
use std::io::Write;
use flate2::Compression;
use flate2::write::ZlibEncoder;
let (metadata_llcx, metadata_llmod) = unsafe {
context::create_context_and_module(tcx.sess, "metadata")
@ -767,7 +769,8 @@ enum MetadataKind {
assert!(kind == MetadataKind::Compressed);
let mut compressed = cstore.metadata_encoding_version().to_vec();
compressed.extend_from_slice(&flate::deflate_bytes(&metadata.raw_data));
ZlibEncoder::new(&mut compressed, Compression::Default)
.write_all(&metadata.raw_data).unwrap();
let llmeta = C_bytes_in_context(metadata_llcx, &compressed);
let llconst = C_struct_in_context(metadata_llcx, &[llmeta], false);

View file

@ -39,7 +39,7 @@
use rustc::dep_graph::WorkProduct;
use syntax_pos::symbol::Symbol;
extern crate flate;
extern crate flate2;
extern crate libc;
extern crate owning_ref;
#[macro_use] extern crate rustc;

View file

@ -116,94 +116,149 @@ fn get_args() -> Option<Vec<String>> {
.collect()
}
fn stable(g: getopts::OptGroup) -> RustcOptGroup { RustcOptGroup::stable(g) }
fn unstable(g: getopts::OptGroup) -> RustcOptGroup { RustcOptGroup::unstable(g) }
fn stable<F>(name: &'static str, f: F) -> RustcOptGroup
where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static
{
RustcOptGroup::stable(name, f)
}
fn unstable<F>(name: &'static str, f: F) -> RustcOptGroup
where F: Fn(&mut getopts::Options) -> &mut getopts::Options + 'static
{
RustcOptGroup::unstable(name, f)
}
pub fn opts() -> Vec<RustcOptGroup> {
use getopts::*;
vec![
stable(optflag("h", "help", "show this help message")),
stable(optflag("V", "version", "print rustdoc's version")),
stable(optflag("v", "verbose", "use verbose output")),
stable(optopt("r", "input-format", "the input type of the specified file",
"[rust]")),
stable(optopt("w", "output-format", "the output type to write",
"[html]")),
stable(optopt("o", "output", "where to place the output", "PATH")),
stable(optopt("", "crate-name", "specify the name of this crate", "NAME")),
stable(optmulti("L", "library-path", "directory to add to crate search path",
"DIR")),
stable(optmulti("", "cfg", "pass a --cfg to rustc", "")),
stable(optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")),
stable(optmulti("", "plugin-path", "directory to load plugins from", "DIR")),
stable(optmulti("", "passes",
"list of passes to also run, you might want \
to pass it multiple times; a value of `list` \
will print available passes",
"PASSES")),
stable(optmulti("", "plugins", "space separated list of plugins to also load",
"PLUGINS")),
stable(optflag("", "no-defaults", "don't run the default passes")),
stable(optflag("", "test", "run code examples as tests")),
stable(optmulti("", "test-args", "arguments to pass to the test runner",
"ARGS")),
stable(optopt("", "target", "target triple to document", "TRIPLE")),
stable(optmulti("", "markdown-css",
"CSS files to include via <link> in a rendered Markdown file",
"FILES")),
stable(optmulti("", "html-in-header",
"files to include inline in the <head> section of a rendered Markdown file \
or generated documentation",
"FILES")),
stable(optmulti("", "html-before-content",
"files to include inline between <body> and the content of a rendered \
Markdown file or generated documentation",
"FILES")),
stable(optmulti("", "html-after-content",
"files to include inline between the content and </body> of a rendered \
Markdown file or generated documentation",
"FILES")),
unstable(optmulti("", "markdown-before-content",
"files to include inline between <body> and the content of a rendered \
Markdown file or generated documentation",
"FILES")),
unstable(optmulti("", "markdown-after-content",
"files to include inline between the content and </body> of a rendered \
Markdown file or generated documentation",
"FILES")),
stable(optopt("", "markdown-playground-url",
"URL to send code snippets to", "URL")),
stable(optflag("", "markdown-no-toc", "don't include table of contents")),
stable(optopt("e", "extend-css",
"To add some CSS rules with a given file to generate doc with your \
own theme. However, your theme might break if the rustdoc's generated HTML \
changes, so be careful!", "PATH")),
unstable(optmulti("Z", "",
"internal and debugging options (only on nightly build)", "FLAG")),
stable(optopt("", "sysroot", "Override the system root", "PATH")),
unstable(optopt("", "playground-url",
"URL to send code snippets to, may be reset by --markdown-playground-url \
or `#![doc(html_playground_url=...)]`",
"URL")),
unstable(optflag("", "enable-commonmark", "to enable commonmark doc rendering/testing")),
unstable(optflag("", "display-warnings", "to print code warnings when testing doc")),
stable("h", |o| o.optflag("h", "help", "show this help message")),
stable("V", |o| o.optflag("V", "version", "print rustdoc's version")),
stable("v", |o| o.optflag("v", "verbose", "use verbose output")),
stable("r", |o| {
o.optopt("r", "input-format", "the input type of the specified file",
"[rust]")
}),
stable("w", |o| {
o.optopt("w", "output-format", "the output type to write", "[html]")
}),
stable("o", |o| o.optopt("o", "output", "where to place the output", "PATH")),
stable("crate-name", |o| {
o.optopt("", "crate-name", "specify the name of this crate", "NAME")
}),
stable("L", |o| {
o.optmulti("L", "library-path", "directory to add to crate search path",
"DIR")
}),
stable("cfg", |o| o.optmulti("", "cfg", "pass a --cfg to rustc", "")),
stable("extern", |o| {
o.optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")
}),
stable("plugin-path", |o| {
o.optmulti("", "plugin-path", "directory to load plugins from", "DIR")
}),
stable("passes", |o| {
o.optmulti("", "passes",
"list of passes to also run, you might want \
to pass it multiple times; a value of `list` \
will print available passes",
"PASSES")
}),
stable("plugins", |o| {
o.optmulti("", "plugins", "space separated list of plugins to also load",
"PLUGINS")
}),
stable("no-default", |o| {
o.optflag("", "no-defaults", "don't run the default passes")
}),
stable("test", |o| o.optflag("", "test", "run code examples as tests")),
stable("test-args", |o| {
o.optmulti("", "test-args", "arguments to pass to the test runner",
"ARGS")
}),
stable("target", |o| o.optopt("", "target", "target triple to document", "TRIPLE")),
stable("markdown-css", |o| {
o.optmulti("", "markdown-css",
"CSS files to include via <link> in a rendered Markdown file",
"FILES")
}),
stable("html-in-header", |o| {
o.optmulti("", "html-in-header",
"files to include inline in the <head> section of a rendered Markdown file \
or generated documentation",
"FILES")
}),
stable("html-before-content", |o| {
o.optmulti("", "html-before-content",
"files to include inline between <body> and the content of a rendered \
Markdown file or generated documentation",
"FILES")
}),
stable("html-after-content", |o| {
o.optmulti("", "html-after-content",
"files to include inline between the content and </body> of a rendered \
Markdown file or generated documentation",
"FILES")
}),
unstable("markdown-before-content", |o| {
o.optmulti("", "markdown-before-content",
"files to include inline between <body> and the content of a rendered \
Markdown file or generated documentation",
"FILES")
}),
unstable("markdown-after-content", |o| {
o.optmulti("", "markdown-after-content",
"files to include inline between the content and </body> of a rendered \
Markdown file or generated documentation",
"FILES")
}),
stable("markdown-playground-url", |o| {
o.optopt("", "markdown-playground-url",
"URL to send code snippets to", "URL")
}),
stable("markdown-no-toc", |o| {
o.optflag("", "markdown-no-toc", "don't include table of contents")
}),
stable("e", |o| {
o.optopt("e", "extend-css",
"To add some CSS rules with a given file to generate doc with your \
own theme. However, your theme might break if the rustdoc's generated HTML \
changes, so be careful!", "PATH")
}),
unstable("Z", |o| {
o.optmulti("Z", "",
"internal and debugging options (only on nightly build)", "FLAG")
}),
stable("sysroot", |o| {
o.optopt("", "sysroot", "Override the system root", "PATH")
}),
unstable("playground-url", |o| {
o.optopt("", "playground-url",
"URL to send code snippets to, may be reset by --markdown-playground-url \
or `#![doc(html_playground_url=...)]`",
"URL")
}),
unstable("enable-commonmark", |o| {
o.optflag("", "enable-commonmark", "to enable commonmark doc rendering/testing")
}),
unstable("display-warnings", |o| {
o.optflag("", "display-warnings", "to print code warnings when testing doc")
}),
]
}
pub fn usage(argv0: &str) {
println!("{}",
getopts::usage(&format!("{} [options] <input>", argv0),
&opts().into_iter()
.map(|x| x.opt_group)
.collect::<Vec<getopts::OptGroup>>()));
let mut options = getopts::Options::new();
for option in opts() {
(option.apply)(&mut options);
}
println!("{}", options.usage(&format!("{} [options] <input>", argv0)));
}
pub fn main_args(args: &[String]) -> isize {
let all_groups: Vec<getopts::OptGroup> = opts()
.into_iter()
.map(|x| x.opt_group)
.collect();
let matches = match getopts::getopts(&args[1..], &all_groups) {
let mut options = getopts::Options::new();
for option in opts() {
(option.apply)(&mut options);
}
let matches = match options.parse(&args[1..]) {
Ok(m) => m,
Err(err) => {
print_error(err);

View file

@ -9,5 +9,5 @@ path = "lib.rs"
crate-type = ["dylib", "rlib"]
[dependencies]
getopts = { path = "../libgetopts" }
getopts = "0.2"
term = { path = "../libterm" }

View file

@ -372,30 +372,31 @@ fn new() -> TestOpts {
/// Result of parsing the options.
pub type OptRes = Result<TestOpts, String>;
#[cfg_attr(rustfmt, rustfmt_skip)]
fn optgroups() -> Vec<getopts::OptGroup> {
vec![getopts::optflag("", "ignored", "Run ignored tests"),
getopts::optflag("", "test", "Run tests and not benchmarks"),
getopts::optflag("", "bench", "Run benchmarks instead of tests"),
getopts::optflag("", "list", "List all tests and benchmarks"),
getopts::optflag("h", "help", "Display this message (longer with --help)"),
getopts::optopt("", "logfile", "Write logs to the specified file instead \
of stdout", "PATH"),
getopts::optflag("", "nocapture", "don't capture stdout/stderr of each \
task, allow printing directly"),
getopts::optopt("", "test-threads", "Number of threads used for running tests \
in parallel", "n_threads"),
getopts::optmulti("", "skip", "Skip tests whose names contain FILTER (this flag can \
be used multiple times)","FILTER"),
getopts::optflag("q", "quiet", "Display one character per test instead of one line"),
getopts::optflag("", "exact", "Exactly match filters rather than by substring"),
getopts::optopt("", "color", "Configure coloring of output:
fn optgroups() -> getopts::Options {
let mut opts = getopts::Options::new();
opts.optflag("", "ignored", "Run ignored tests")
.optflag("", "test", "Run tests and not benchmarks")
.optflag("", "bench", "Run benchmarks instead of tests")
.optflag("", "list", "List all tests and benchmarks")
.optflag("h", "help", "Display this message (longer with --help)")
.optopt("", "logfile", "Write logs to the specified file instead \
of stdout", "PATH")
.optflag("", "nocapture", "don't capture stdout/stderr of each \
task, allow printing directly")
.optopt("", "test-threads", "Number of threads used for running tests \
in parallel", "n_threads")
.optmulti("", "skip", "Skip tests whose names contain FILTER (this flag can \
be used multiple times)","FILTER")
.optflag("q", "quiet", "Display one character per test instead of one line")
.optflag("", "exact", "Exactly match filters rather than by substring")
.optopt("", "color", "Configure coloring of output:
auto = colorize if stdout is a tty and tests are run on serially (default);
always = always colorize output;
never = never colorize output;", "auto|always|never")]
never = never colorize output;", "auto|always|never");
return opts
}
fn usage(binary: &str) {
fn usage(binary: &str, options: &getopts::Options) {
let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
println!(r#"{usage}
@ -424,19 +425,19 @@ fn usage(binary: &str) {
test, then the test runner will ignore these tests during
normal test runs. Running with --ignored will run these
tests."#,
usage = getopts::usage(&message, &optgroups()));
usage = options.usage(&message));
}
// Parses command line arguments into test options
pub fn parse_opts(args: &[String]) -> Option<OptRes> {
let args_ = &args[1..];
let matches = match getopts::getopts(args_, &optgroups()) {
let opts = optgroups();
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
Err(f) => return Some(Err(f.to_string())),
};
if matches.opt_present("h") {
usage(&args[0]);
usage(&args[0], &opts);
return None;
}

File diff suppressed because it is too large Load diff

View file

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, libc, compiler_builtins_lib)]
#![feature(lang_items, alloc_system, compiler_builtins_lib)]
#![crate_type = "dylib"]
#![no_std]
extern crate libc;
extern crate alloc_system;
extern crate compiler_builtins;
#[no_mangle]

View file

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(lang_items, libc, compiler_builtins_lib)]
#![feature(lang_items, alloc_system, compiler_builtins_lib)]
#![no_std]
#![crate_type = "dylib"]
extern crate libc;
extern crate alloc_system;
extern crate compiler_builtins;
#[no_mangle]

View file

@ -17,7 +17,6 @@
extern crate krate2;
extern crate krate2 as krate3;
extern crate flate as myflate;
use graphviz::RenderOption;
use std::collections::{HashMap,HashSet};
@ -51,7 +50,6 @@ fn foo(x: &Write) {}
krate2::hello();
krate3::hello();
myflate::deflate_bytes(&[]);
let x = (3isize, 4usize);
let y = x.1;

View file

@ -18,7 +18,6 @@
extern crate krate2;
extern crate krate2 as krate3;
extern crate flate as myflate;
use graphviz::RenderOption;
use std::collections::{HashMap,HashSet};
@ -52,7 +51,6 @@ fn foo(x: &Write) {}
krate2::hello();
krate3::hello();
myflate::deflate_bytes(&[]);
let x = (3isize, 4usize);
let y = x.1;

View file

@ -10,33 +10,40 @@
// no-prefer-dynamic
#![feature(allocator, core_intrinsics, libc)]
#![feature(allocator, core_intrinsics)]
#![allocator]
#![crate_type = "rlib"]
#![no_std]
extern crate libc;
pub static mut HITS: usize = 0;
type size_t = usize;
extern {
fn malloc(size: usize) -> *mut u8;
fn free(ptr: *mut u8);
fn calloc(size: usize, amt: usize) -> *mut u8;
fn realloc(ptr: *mut u8, size: usize) -> *mut u8;
}
#[no_mangle]
pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
unsafe {
HITS += 1;
libc::malloc(size as libc::size_t) as *mut u8
malloc(size as size_t) as *mut u8
}
}
#[no_mangle]
pub extern fn __rust_allocate_zeroed(size: usize, _align: usize) -> *mut u8 {
unsafe { libc::calloc(size as libc::size_t, 1) as *mut u8 }
unsafe { calloc(size as size_t, 1) as *mut u8 }
}
#[no_mangle]
pub extern fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
unsafe {
HITS += 1;
libc::free(ptr as *mut _)
free(ptr as *mut _)
}
}
@ -44,7 +51,7 @@
pub extern fn __rust_reallocate(ptr: *mut u8, old_size: usize, size: usize,
align: usize) -> *mut u8 {
unsafe {
libc::realloc(ptr as *mut _, size as libc::size_t) as *mut u8
realloc(ptr as *mut _, size as size_t) as *mut u8
}
}

View file

@ -1,28 +0,0 @@
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_private)]
extern crate getopts;
use getopts::{optopt, getopts};
pub fn main() {
let args = Vec::new();
let opts = vec![optopt("b", "", "something", "SMTHNG")];
match getopts(&args, &opts) {
Ok(ref m) =>
assert!(!m.opt_present("b")),
Err(ref f) => panic!("{}", *f)
};
}

View file

@ -11,11 +11,12 @@
// Smallest "hello world" with a libc runtime
// pretty-expanded FIXME #23616
// ignore-windows
#![feature(intrinsics, lang_items, start, no_core, libc)]
#![feature(intrinsics, lang_items, start, no_core, alloc_system)]
#![no_core]
extern crate libc;
extern crate alloc_system;
extern { fn puts(s: *const u8); }
extern "rust-intrinsic" { fn transmute<T, U>(t: T) -> U; }

View file

@ -4,8 +4,9 @@ name = "compiletest"
version = "0.0.0"
[dependencies]
log = "0.3"
env_logger = { version = "0.4", default-features = false }
rustc-serialize = "0.3"
filetime = "0.1"
diff = "0.1.10"
env_logger = { version = "0.4", default-features = false }
filetime = "0.1"
getopts = "0.2"
log = "0.3"
rustc-serialize = "0.3"

View file

@ -11,7 +11,6 @@
#![crate_name = "compiletest"]
#![feature(box_syntax)]
#![feature(rustc_private)]
#![feature(test)]
#![feature(libc)]
@ -34,7 +33,7 @@
use std::path::{Path, PathBuf};
use std::process::Command;
use filetime::FileTime;
use getopts::{optopt, optflag, reqopt};
use getopts::Options;
use common::Config;
use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Mode};
use test::{TestPaths, ColorConfig};
@ -66,68 +65,68 @@ fn main() {
pub fn parse_config(args: Vec<String> ) -> Config {
let groups : Vec<getopts::OptGroup> =
vec![reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
reqopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH"),
reqopt("", "lldb-python", "path to python to use for doc tests", "PATH"),
reqopt("", "docck-python", "path to python to use for doc tests", "PATH"),
optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM"),
optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind"),
optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR"),
reqopt("", "src-base", "directory to scan for test files", "PATH"),
reqopt("", "build-base", "directory to deposit test outputs", "PATH"),
reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET"),
reqopt("", "mode", "which sort of compile tests to run",
"(compile-fail|parse-fail|run-fail|run-pass|\
run-pass-valgrind|pretty|debug-info|incremental|mir-opt)"),
optflag("", "ignored", "run tests marked as ignored"),
optflag("", "exact", "filters match exactly"),
optopt("", "runtool", "supervisor program to run tests under \
(eg. emulator, valgrind)", "PROGRAM"),
optopt("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS"),
optopt("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS"),
optflag("", "verbose", "run tests verbosely, showing all output"),
optflag("", "quiet", "print one character per test instead of one line"),
optopt("", "color", "coloring: auto, always, never", "WHEN"),
optopt("", "logfile", "file to log test execution to", "FILE"),
optopt("", "target", "the target to build for", "TARGET"),
optopt("", "host", "the host to build for", "HOST"),
optopt("", "gdb", "path to GDB to use for GDB debuginfo tests", "PATH"),
optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING"),
optopt("", "llvm-version", "the version of LLVM used", "VERSION STRING"),
optflag("", "system-llvm", "is LLVM the system LLVM"),
optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
optopt("", "adb-path", "path to the android debugger", "PATH"),
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
optopt("", "lldb-python-dir", "directory containing LLDB's python module", "PATH"),
reqopt("", "cc", "path to a C compiler", "PATH"),
reqopt("", "cxx", "path to a C++ compiler", "PATH"),
reqopt("", "cflags", "flags for the C compiler", "FLAGS"),
reqopt("", "llvm-components", "list of LLVM components built in", "LIST"),
reqopt("", "llvm-cxxflags", "C++ flags for LLVM", "FLAGS"),
optopt("", "nodejs", "the name of nodejs", "PATH"),
optopt("", "remote-test-client", "path to the remote test client", "PATH"),
optflag("h", "help", "show this message")];
let mut opts = Options::new();
opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
.reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH")
.reqopt("", "rustdoc-path", "path to rustdoc to use for compiling", "PATH")
.reqopt("", "lldb-python", "path to python to use for doc tests", "PATH")
.reqopt("", "docck-python", "path to python to use for doc tests", "PATH")
.optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM")
.optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind")
.optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR")
.reqopt("", "src-base", "directory to scan for test files", "PATH")
.reqopt("", "build-base", "directory to deposit test outputs", "PATH")
.reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET")
.reqopt("", "mode", "which sort of compile tests to run",
"(compile-fail|parse-fail|run-fail|run-pass|\
run-pass-valgrind|pretty|debug-info|incremental|mir-opt)")
.optflag("", "ignored", "run tests marked as ignored")
.optflag("", "exact", "filters match exactly")
.optopt("", "runtool", "supervisor program to run tests under \
(eg. emulator, valgrind)", "PROGRAM")
.optopt("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS")
.optopt("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS")
.optflag("", "verbose", "run tests verbosely, showing all output")
.optflag("", "quiet", "print one character per test instead of one line")
.optopt("", "color", "coloring: auto, always, never", "WHEN")
.optopt("", "logfile", "file to log test execution to", "FILE")
.optopt("", "target", "the target to build for", "TARGET")
.optopt("", "host", "the host to build for", "HOST")
.optopt("", "gdb", "path to GDB to use for GDB debuginfo tests", "PATH")
.optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING")
.optopt("", "llvm-version", "the version of LLVM used", "VERSION STRING")
.optflag("", "system-llvm", "is LLVM the system LLVM")
.optopt("", "android-cross-path", "Android NDK standalone path", "PATH")
.optopt("", "adb-path", "path to the android debugger", "PATH")
.optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH")
.optopt("", "lldb-python-dir", "directory containing LLDB's python module", "PATH")
.reqopt("", "cc", "path to a C compiler", "PATH")
.reqopt("", "cxx", "path to a C++ compiler", "PATH")
.reqopt("", "cflags", "flags for the C compiler", "FLAGS")
.reqopt("", "llvm-components", "list of LLVM components built in", "LIST")
.reqopt("", "llvm-cxxflags", "C++ flags for LLVM", "FLAGS")
.optopt("", "nodejs", "the name of nodejs", "PATH")
.optopt("", "remote-test-client", "path to the remote test client", "PATH")
.optflag("h", "help", "show this message");
let (argv0, args_) = args.split_first().unwrap();
if args.len() == 1 || args[1] == "-h" || args[1] == "--help" {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::usage(&message, &groups));
println!("{}", opts.usage(&message));
println!("");
panic!()
}
let matches =
&match getopts::getopts(args_, &groups) {
&match opts.parse(args_) {
Ok(m) => m,
Err(f) => panic!("{:?}", f)
};
if matches.opt_present("h") || matches.opt_present("help") {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::usage(&message, &groups));
println!("{}", opts.usage(&message));
println!("");
panic!()
}

View file

@ -101,9 +101,6 @@ pub fn check(path: &Path, bad: &mut bool) {
filename.starts_with(".#") {
return
}
if filename == "miniz.c" {
return
}
contents.truncate(0);
t!(t!(File::open(file), file).read_to_string(&mut contents));