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

Use the counted_array macro for the ARGS arrays #298

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ byteorder = "1.0"
bytes = "0.4"
chrono = { version = "0.4", optional = true }
clap = "2.23.0"
counted-array = "0.1"
directories = "1"
env_logger = "0.5"
error-chain = { version = "0.12", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl CCompilerImpl for Clang {
}
}

pub static ARGS: [ArgInfo<gcc::ArgData>; 10] = [
counted_array!(pub static ARGS: [ArgInfo<gcc::ArgData>; _] = [
take_arg!("--serialize-diagnostics", OsString, Separated, PassThrough),
take_arg!("--target", OsString, Separated, PassThrough),
// TODO: should be extracted and reprocessed, though bear in mind some
Expand All @@ -95,7 +95,7 @@ pub static ARGS: [ArgInfo<gcc::ArgData>; 10] = [
take_arg!("-gcc-toolchain", OsString, Separated, PassThrough),
take_arg!("-include-pch", PathBuf, CanBeSeparated, PreprocessorArgumentPath),
take_arg!("-target", OsString, Separated, PassThrough),
];
]);

#[cfg(test)]
mod test {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ArgData!{ pub
use self::ArgData::*;

// Mostly taken from /~https://github.com/ccache/ccache/blob/master/src/compopt.c#L32-L84
pub static ARGS: [ArgInfo<ArgData>; 65] = [
counted_array!(pub static ARGS: [ArgInfo<ArgData>; _] = [
flag!("-", TooHardFlag),
flag!("--coverage", Coverage),
take_arg!("--param", OsString, Separated, PassThrough),
Expand Down Expand Up @@ -163,7 +163,7 @@ pub static ARGS: [ArgInfo<ArgData>; 65] = [
take_arg!("-u", OsString, CanBeSeparated, PassThrough),
take_arg!("-x", OsString, CanBeSeparated, Language),
take_arg!("@", OsString, Concatenated, TooHard),
];
]);

/// Parse `arguments`, determining whether it is supported.
///
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ArgData!{

use self::ArgData::*;

static ARGS: [ArgInfo<ArgData>; 23] = [
counted_array!(static ARGS: [ArgInfo<ArgData>; _] = [
take_arg!("-D", OsString, Concatenated, PreprocessorArgument),
take_arg!("-FA", OsString, Concatenated, TooHard),
take_arg!("-FI", PathBuf, CanBeSeparated, PreprocessorArgumentPath),
Expand All @@ -243,7 +243,7 @@ static ARGS: [ArgInfo<ArgData>; 23] = [
take_arg!("-o", PathBuf, Separated, Output), // Deprecated but valid
flag!("-showIncludes", ShowIncludes),
take_arg!("@", PathBuf, Concatenated, TooHardPath),
];
]);

pub fn parse_arguments(arguments: &[OsString], cwd: &Path, is_clang: bool) -> CompilerArguments<ParsedArguments> {
let mut output_arg = None;
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ ArgData!{
use self::ArgData::*;

// These are taken from /~https://github.com/rust-lang/rust/blob/b671c32ddc8c36d50866428d83b7716233356721/src/librustc/session/config.rs#L1186
static ARGS: [ArgInfo<ArgData>; 34] = [
counted_array!(static ARGS: [ArgInfo<ArgData>; _] = [
flag!("-", TooHardFlag),
take_arg!("--allow", OsString, CanBeSeparated('='), PassThrough),
take_arg!("--cap-lints", OsString, CanBeSeparated('='), PassThrough),
Expand Down Expand Up @@ -702,7 +702,7 @@ static ARGS: [ArgInfo<ArgData>; 34] = [
take_arg!("-Z", OsString, CanBeSeparated, PassThrough),
take_arg!("-l", ArgLinkLibrary, CanBeSeparated, LinkLibrary),
take_arg!("-o", PathBuf, CanBeSeparated, TooHardPath),
];
]);

fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments<ParsedArguments>
{
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ extern crate bytes;
extern crate chrono;
#[macro_use]
extern crate clap;
#[macro_use]
extern crate counted_array;
#[cfg(feature = "rust-crypto")]
extern crate crypto;
#[cfg(unix)]
Expand Down