зеркало из https://github.com/mozilla/sccache.git
Fix remaining clippy warnings
This commit is contained in:
Родитель
ca73029ee3
Коммит
65bb3b63ff
|
@ -80,23 +80,16 @@ pub enum Error {
|
|||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.description())
|
||||
write!(f, "{}", self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl StdError for Error {
|
||||
fn description(&self) -> &str {
|
||||
match *self {
|
||||
Error::FileTooLarge => "File too large",
|
||||
Error::FileNotInCache => "File not in cache",
|
||||
Error::Io(ref e) => e.description(),
|
||||
}
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&dyn StdError> {
|
||||
match *self {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Error::FileTooLarge => None,
|
||||
Error::FileNotInCache => None,
|
||||
Error::Io(ref e) => Some(e),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ const BLOB_API_VERSION: &str = "2017-04-17";
|
|||
fn hmac(data: &[u8], secret: &[u8]) -> Vec<u8> {
|
||||
let mut hmac = Hmac::<Sha256>::new_varkey(secret).expect("HMAC can take key of any size");
|
||||
hmac.input(data);
|
||||
hmac.result().code().iter().map(|b| *b).collect::<Vec<u8>>()
|
||||
hmac.result().code().iter().copied().collect::<Vec<u8>>()
|
||||
}
|
||||
|
||||
fn signature(to_sign: &str, secret: &str) -> String {
|
||||
|
@ -117,7 +117,7 @@ impl BlobContainer {
|
|||
.map(|header::ContentLength(len)| len);
|
||||
Ok((res.into_body(), content_length))
|
||||
} else {
|
||||
Err(ErrorKind::BadHTTPStatus(res.status().clone()).into())
|
||||
Err(ErrorKind::BadHTTPStatus(res.status()).into())
|
||||
}
|
||||
})
|
||||
.and_then(|(body, content_length)| {
|
||||
|
@ -207,7 +207,7 @@ impl BlobContainer {
|
|||
Ok(())
|
||||
} else {
|
||||
trace!("PUT failed with HTTP status: {}", res.status());
|
||||
Err(ErrorKind::BadHTTPStatus(res.status().clone()).into())
|
||||
Err(ErrorKind::BadHTTPStatus(res.status()).into())
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
@ -336,12 +336,12 @@ mod test {
|
|||
|
||||
let container = BlobContainer::new(creds.azure_blob_endpoint(), container_name).unwrap();
|
||||
|
||||
let put_future = container.put("foo", "barbell".as_bytes().to_vec(), &creds);
|
||||
let put_future = container.put("foo", b"barbell".to_vec(), &creds);
|
||||
runtime.block_on(put_future).unwrap();
|
||||
|
||||
let get_future = container.get("foo", &creds);
|
||||
let result = runtime.block_on(get_future).unwrap();
|
||||
|
||||
assert_eq!("barbell".as_bytes().to_vec(), result);
|
||||
assert_eq!(b"barbell".to_vec(), result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ impl AzureCredentials {
|
|||
account_key: &str,
|
||||
container_name: String,
|
||||
) -> AzureCredentials {
|
||||
let endpoint = if blob_endpoint.ends_with("/") {
|
||||
let endpoint = if blob_endpoint.ends_with('/') {
|
||||
blob_endpoint.to_owned()
|
||||
} else {
|
||||
blob_endpoint.to_owned() + "/"
|
||||
|
@ -42,7 +42,7 @@ impl AzureCredentials {
|
|||
blob_endpoint: endpoint,
|
||||
account_name: account_name.to_owned(),
|
||||
account_key: account_key.to_owned(),
|
||||
container_name: container_name,
|
||||
container_name,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ fn parse_connection_string(conn: &str, container_name: String) -> Result<AzureCr
|
|||
let mut account_key = String::default();
|
||||
let mut endpoint_suffix = String::default();
|
||||
|
||||
let split = conn.split(";");
|
||||
let split = conn.split(';');
|
||||
for part in split {
|
||||
if part.starts_with("BlobEndpoint=") {
|
||||
blob_endpoint = substr(part, "BlobEndpoint=".len()).to_owned();
|
||||
|
|
|
@ -45,7 +45,7 @@ impl AzureBlobCache {
|
|||
|
||||
Ok(AzureBlobCache {
|
||||
container: Rc::new(container),
|
||||
credentials: credentials,
|
||||
credentials,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,6 +168,7 @@ pub trait Storage {
|
|||
}
|
||||
|
||||
/// Get a suitable `Storage` implementation from configuration.
|
||||
#[allow(clippy::cognitive_complexity)] // TODO simplify!
|
||||
pub fn storage_from_config(config: &Config, pool: &CpuPool) -> Arc<dyn Storage> {
|
||||
for cache_type in config.caches.iter() {
|
||||
match *cache_type {
|
||||
|
@ -216,7 +217,7 @@ pub fn storage_from_config(config: &Config, pool: &CpuPool) -> Arc<dyn Storage>
|
|||
|
||||
service_account_key_res
|
||||
.ok()
|
||||
.map(|account_key| ServiceAccountInfo::AccountKey(account_key))
|
||||
.map(ServiceAccountInfo::AccountKey)
|
||||
} else if let Some(ref url) = *url {
|
||||
Some(ServiceAccountInfo::URL(url.clone()))
|
||||
} else {
|
||||
|
@ -265,14 +266,10 @@ pub fn storage_from_config(config: &Config, pool: &CpuPool) -> Arc<dyn Storage>
|
|||
Err(e) => warn!("Failed to create RedisCache: {:?}", e),
|
||||
}
|
||||
}
|
||||
CacheType::S3(config::S3CacheConfig {
|
||||
ref bucket,
|
||||
ref endpoint,
|
||||
use_ssl,
|
||||
}) => {
|
||||
debug!("Trying S3Cache({}, {})", bucket, endpoint);
|
||||
CacheType::S3(ref c) => {
|
||||
debug!("Trying S3Cache({}, {})", c.bucket, c.endpoint);
|
||||
#[cfg(feature = "s3")]
|
||||
match S3Cache::new(&bucket, &endpoint, use_ssl) {
|
||||
match S3Cache::new(&c.bucket, &c.endpoint, c.use_ssl) {
|
||||
Ok(s) => {
|
||||
trace!("Using S3Cache");
|
||||
return Arc::new(s);
|
||||
|
|
|
@ -61,7 +61,7 @@ impl Bucket {
|
|||
|
||||
let client = self.client.clone();
|
||||
|
||||
let creds_opt_future = if let &Some(ref cred_provider) = cred_provider {
|
||||
let creds_opt_future = if let Some(ref cred_provider) = *cred_provider {
|
||||
future::Either::A(
|
||||
cred_provider
|
||||
.credentials(&self.client)
|
||||
|
@ -89,7 +89,7 @@ impl Bucket {
|
|||
if res.status().is_success() {
|
||||
Ok(res.into_body())
|
||||
} else {
|
||||
Err(ErrorKind::BadHTTPStatus(res.status().clone()).into())
|
||||
Err(ErrorKind::BadHTTPStatus(res.status()).into())
|
||||
}
|
||||
})
|
||||
.and_then(|body| {
|
||||
|
@ -116,7 +116,7 @@ impl Bucket {
|
|||
|
||||
let client = self.client.clone();
|
||||
|
||||
let creds_opt_future = if let &Some(ref cred_provider) = cred_provider {
|
||||
let creds_opt_future = if let Some(ref cred_provider) = cred_provider {
|
||||
future::Either::A(cred_provider.credentials(&self.client).map(Some))
|
||||
} else {
|
||||
future::Either::B(future::ok(None))
|
||||
|
@ -141,7 +141,7 @@ impl Bucket {
|
|||
Ok(())
|
||||
} else {
|
||||
trace!("PUT failed with HTTP status: {}", res.status());
|
||||
Err(ErrorKind::BadHTTPStatus(res.status().clone()).into())
|
||||
Err(ErrorKind::BadHTTPStatus(res.status()).into())
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
@ -388,7 +388,7 @@ impl GCSCredentialProvider {
|
|||
if res.status().is_success() {
|
||||
Ok(res.into_body())
|
||||
} else {
|
||||
Err(ErrorKind::BadHTTPStatus(res.status().clone()).into())
|
||||
Err(ErrorKind::BadHTTPStatus(res.status()).into())
|
||||
}
|
||||
})
|
||||
.and_then(move |body| {
|
||||
|
@ -422,7 +422,7 @@ impl GCSCredentialProvider {
|
|||
if res.status().is_success() {
|
||||
Ok(res.into_body())
|
||||
} else {
|
||||
Err(ErrorKind::BadHTTPStatus(res.status().clone()).into())
|
||||
Err(ErrorKind::BadHTTPStatus(res.status()).into())
|
||||
}
|
||||
})
|
||||
.and_then(move |body| {
|
||||
|
@ -493,8 +493,8 @@ impl GCSCache {
|
|||
) -> Result<GCSCache> {
|
||||
Ok(GCSCache {
|
||||
bucket: Rc::new(Bucket::new(bucket)?),
|
||||
rw_mode: rw_mode,
|
||||
credential_provider: credential_provider,
|
||||
rw_mode,
|
||||
credential_provider,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ impl Storage for GCSCache {
|
|||
let start = time::Instant::now();
|
||||
let data = match entry.finish() {
|
||||
Ok(data) => data,
|
||||
Err(e) => return Box::new(future::err(e.into())),
|
||||
Err(e) => return Box::new(future::err(e)),
|
||||
};
|
||||
let bucket = self.bucket.clone();
|
||||
let response = bucket
|
||||
|
|
|
@ -283,7 +283,7 @@ pub fn request_zero_stats(mut conn: ServerConnection) -> Result<ServerInfo> {
|
|||
"failed to send zero statistics command to server or failed to receive respone"
|
||||
})?;
|
||||
if let Response::Stats(stats) = response {
|
||||
Ok(stats)
|
||||
Ok(*stats)
|
||||
} else {
|
||||
bail!("Unexpected server response!")
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ pub fn request_stats(mut conn: ServerConnection) -> Result<ServerInfo> {
|
|||
.request(Request::GetStats)
|
||||
.chain_err(|| "Failed to send data to or receive data from server")?;
|
||||
if let Response::Stats(stats) = response {
|
||||
Ok(stats)
|
||||
Ok(*stats)
|
||||
} else {
|
||||
bail!("Unexpected server response!")
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ pub fn request_shutdown(mut conn: ServerConnection) -> Result<ServerInfo> {
|
|||
.request(Request::Shutdown)
|
||||
.chain_err(|| "Failed to send data to or receive data from server")?;
|
||||
if let Response::ShuttingDown(stats) = response {
|
||||
Ok(stats)
|
||||
Ok(*stats)
|
||||
} else {
|
||||
bail!("Unexpected server response!")
|
||||
}
|
||||
|
|
|
@ -713,6 +713,7 @@ mod tests {
|
|||
use self::ArgData::*;
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn test_arginfo_cmp() {
|
||||
let info = flag!("-foo", FooFlag);
|
||||
assert_eq!(info.cmp("-foo"), Ordering::Equal);
|
||||
|
@ -783,7 +784,7 @@ mod tests {
|
|||
ArgParseError::UnexpectedEndOfArgs
|
||||
);
|
||||
assert_eq!(
|
||||
info.clone().process("-foo", || Some("bar".into())).unwrap(),
|
||||
info.process("-foo", || Some("bar".into())).unwrap(),
|
||||
arg!(WithValue("-foo", Foo("bar"), Separated))
|
||||
);
|
||||
|
||||
|
@ -793,7 +794,7 @@ mod tests {
|
|||
arg!(WithValue("-foo", Foo(""), Concatenated))
|
||||
);
|
||||
assert_eq!(
|
||||
info.clone().process("-foobar", || None).unwrap(),
|
||||
info.process("-foobar", || None).unwrap(),
|
||||
arg!(WithValue("-foo", Foo("bar"), Concatenated))
|
||||
);
|
||||
|
||||
|
@ -803,7 +804,7 @@ mod tests {
|
|||
arg!(WithValue("-foo", Foo(""), Concatenated('=')))
|
||||
);
|
||||
assert_eq!(
|
||||
info.clone().process("-foo=bar", || None).unwrap(),
|
||||
info.process("-foo=bar", || None).unwrap(),
|
||||
arg!(WithValue("-foo", Foo("bar"), Concatenated('=')))
|
||||
);
|
||||
|
||||
|
@ -817,7 +818,7 @@ mod tests {
|
|||
arg!(WithValue("-foo", Foo("bar"), CanBeSeparated))
|
||||
);
|
||||
assert_eq!(
|
||||
info.clone().process("-foo", || Some("bar".into())).unwrap(),
|
||||
info.process("-foo", || Some("bar".into())).unwrap(),
|
||||
arg!(WithValue("-foo", Foo("bar"), CanBeConcatenated))
|
||||
);
|
||||
|
||||
|
@ -835,7 +836,7 @@ mod tests {
|
|||
arg!(WithValue("-foo", Foo("bar"), CanBeSeparated('=')))
|
||||
);
|
||||
assert_eq!(
|
||||
info.clone().process("-foo", || Some("bar".into())).unwrap(),
|
||||
info.process("-foo", || Some("bar".into())).unwrap(),
|
||||
arg!(WithValue("-foo", Foo("bar"), CanBeConcatenated('=')))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use crate::compiler::{
|
|||
CompilerKind, HashResult,
|
||||
};
|
||||
#[cfg(feature = "dist-client")]
|
||||
use crate::compiler::{NoopOutputsRewriter, OutputsRewriter};
|
||||
use crate::compiler::{DistPackagers, NoopOutputsRewriter};
|
||||
use crate::dist;
|
||||
#[cfg(feature = "dist-client")]
|
||||
use crate::dist::pkg;
|
||||
|
@ -27,7 +27,6 @@ use futures::Future;
|
|||
use futures_cpupool::CpuPool;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::env::consts::DLL_EXTENSION;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fmt;
|
||||
use std::fs;
|
||||
|
@ -402,11 +401,7 @@ impl<I: CCompilerImpl> Compilation for CCompilation<I> {
|
|||
fn into_dist_packagers(
|
||||
self: Box<Self>,
|
||||
path_transformer: dist::PathTransformer,
|
||||
) -> Result<(
|
||||
Box<dyn pkg::InputsPackager>,
|
||||
Box<dyn pkg::ToolchainPackager>,
|
||||
Box<dyn OutputsRewriter>,
|
||||
)> {
|
||||
) -> Result<DistPackagers> {
|
||||
let CCompilation {
|
||||
parsed_args,
|
||||
cwd,
|
||||
|
@ -460,7 +455,7 @@ impl pkg::InputsPackager for CInputsPackager {
|
|||
{
|
||||
let input_path = pkg::simplify_path(&input_path)?;
|
||||
let dist_input_path = path_transformer
|
||||
.to_dist(&input_path)
|
||||
.as_dist(&input_path)
|
||||
.chain_err(|| format!("unable to transform input path {}", input_path.display()))?;
|
||||
|
||||
let mut file_header = pkg::make_tar_header(&input_path, &dist_input_path)?;
|
||||
|
@ -475,7 +470,7 @@ impl pkg::InputsPackager for CInputsPackager {
|
|||
if !super::CAN_DIST_DYLIBS
|
||||
&& input_path
|
||||
.extension()
|
||||
.map_or(false, |ext| ext == DLL_EXTENSION)
|
||||
.map_or(false, |ext| ext == std::env::consts::DLL_EXTENSION)
|
||||
{
|
||||
bail!(
|
||||
"Cannot distribute dylib input {} on this platform",
|
||||
|
@ -484,7 +479,7 @@ impl pkg::InputsPackager for CInputsPackager {
|
|||
}
|
||||
|
||||
let dist_input_path = path_transformer
|
||||
.to_dist(&input_path)
|
||||
.as_dist(&input_path)
|
||||
.chain_err(|| format!("unable to transform input path {}", input_path.display()))?;
|
||||
|
||||
let mut file = io::BufReader::new(fs::File::open(&input_path)?);
|
||||
|
@ -515,7 +510,6 @@ struct CToolchainPackager {
|
|||
impl pkg::ToolchainPackager for CToolchainPackager {
|
||||
fn write_pkg(self: Box<Self>, f: fs::File) -> Result<()> {
|
||||
use std::os::unix::ffi::OsStringExt;
|
||||
use which::which;
|
||||
|
||||
info!("Generating toolchain {}", self.executable.display());
|
||||
let mut package_builder = pkg::ToolchainPackageBuilder::new();
|
||||
|
@ -658,7 +652,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_hash_key_executable_contents_differs() {
|
||||
let args = ovec!["a", "b", "c"];
|
||||
const PREPROCESSED: &'static [u8] = b"hello world";
|
||||
const PREPROCESSED: &[u8] = b"hello world";
|
||||
assert_neq!(
|
||||
hash_key("abcd", Language::C, &args, &[], &[], &PREPROCESSED),
|
||||
hash_key("wxyz", Language::C, &args, &[], &[], &PREPROCESSED)
|
||||
|
@ -672,7 +666,7 @@ mod test {
|
|||
let xyz = ovec!["x", "y", "z"];
|
||||
let ab = ovec!["a", "b"];
|
||||
let a = ovec!["a"];
|
||||
const PREPROCESSED: &'static [u8] = b"hello world";
|
||||
const PREPROCESSED: &[u8] = b"hello world";
|
||||
assert_neq!(
|
||||
hash_key(digest, Language::C, &abc, &[], &[], &PREPROCESSED),
|
||||
hash_key(digest, Language::C, &xyz, &[], &[], &PREPROCESSED)
|
||||
|
@ -702,7 +696,7 @@ mod test {
|
|||
fn test_hash_key_env_var_differs() {
|
||||
let args = ovec!["a", "b", "c"];
|
||||
let digest = "abcd";
|
||||
const PREPROCESSED: &'static [u8] = b"hello world";
|
||||
const PREPROCESSED: &[u8] = b"hello world";
|
||||
for var in CACHED_ENV_VARS.iter() {
|
||||
let h1 = hash_key(digest, Language::C, &args, &[], &[], &PREPROCESSED);
|
||||
let vars = vec![(OsString::from(var), OsString::from("something"))];
|
||||
|
@ -718,7 +712,7 @@ mod test {
|
|||
fn test_extra_hash_data() {
|
||||
let args = ovec!["a", "b", "c"];
|
||||
let digest = "abcd";
|
||||
const PREPROCESSED: &'static [u8] = b"hello world";
|
||||
const PREPROCESSED: &[u8] = b"hello world";
|
||||
let extra_data = stringvec!["hello", "world"];
|
||||
|
||||
assert_neq!(
|
||||
|
|
|
@ -129,16 +129,16 @@ mod test {
|
|||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn _parse_arguments(arguments: &[String]) -> CompilerArguments<ParsedArguments> {
|
||||
fn parse_arguments_(arguments: Vec<String>) -> CompilerArguments<ParsedArguments> {
|
||||
let arguments = arguments.iter().map(OsString::from).collect::<Vec<_>>();
|
||||
Clang.parse_arguments(&arguments, ".".as_ref())
|
||||
}
|
||||
|
||||
macro_rules! parses {
|
||||
( $( $s:expr ),* ) => {
|
||||
match _parse_arguments(&[ $( $s.to_string(), )* ]) {
|
||||
match parse_arguments_(vec![ $( $s.to_string(), )* ]) {
|
||||
CompilerArguments::Ok(a) => a,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,11 +188,11 @@ mod test {
|
|||
fn test_parse_arguments_clangmodules() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-fcxx-modules", None),
|
||||
_parse_arguments(&stringvec!["-c", "foo.c", "-fcxx-modules", "-o", "foo.o"])
|
||||
parse_arguments_(stringvec!["-c", "foo.c", "-fcxx-modules", "-o", "foo.o"])
|
||||
);
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-fmodules", None),
|
||||
_parse_arguments(&stringvec!["-c", "foo.c", "-fmodules", "-o", "foo.o"])
|
||||
parse_arguments_(stringvec!["-c", "foo.c", "-fmodules", "-o", "foo.o"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -200,13 +200,13 @@ mod test {
|
|||
fn test_parse_xclang_invalid() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("Can't handle Raw arguments with -Xclang", None),
|
||||
_parse_arguments(&stringvec![
|
||||
parse_arguments_(stringvec![
|
||||
"-c", "foo.c", "-o", "foo.o", "-Xclang", "broken"
|
||||
])
|
||||
);
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("Can't handle UnknownFlag arguments with -Xclang", None),
|
||||
_parse_arguments(&stringvec![
|
||||
parse_arguments_(stringvec![
|
||||
"-c", "foo.c", "-o", "foo.o", "-Xclang", "-broken"
|
||||
])
|
||||
);
|
||||
|
@ -215,9 +215,7 @@ mod test {
|
|||
"argument parse",
|
||||
Some("Unexpected end of args".to_string())
|
||||
),
|
||||
_parse_arguments(&stringvec![
|
||||
"-c", "foo.c", "-o", "foo.o", "-Xclang", "-load"
|
||||
])
|
||||
parse_arguments_(stringvec!["-c", "foo.c", "-o", "foo.o", "-Xclang", "-load"])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ use crate::mock_command::{exit_status, CommandChild, CommandCreatorSync, RunComm
|
|||
use crate::util::{fmt_duration_as_secs, ref_env, run_input_output};
|
||||
use futures::Future;
|
||||
use futures_cpupool::CpuPool;
|
||||
use lru_disk_cache::Error as LruError;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
|
@ -96,6 +95,13 @@ impl CompilerKind {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "dist-client")]
|
||||
pub type DistPackagers = (
|
||||
Box<dyn pkg::InputsPackager>,
|
||||
Box<dyn pkg::ToolchainPackager>,
|
||||
Box<dyn OutputsRewriter>,
|
||||
);
|
||||
|
||||
/// An interface to a compiler for argument parsing.
|
||||
pub trait Compiler<T>: Send + 'static
|
||||
where
|
||||
|
@ -401,7 +407,7 @@ fn dist_or_local_compile<T>(
|
|||
where
|
||||
T: CommandCreatorSync,
|
||||
{
|
||||
let mut path_transformer = dist::PathTransformer::new();
|
||||
let mut path_transformer = dist::PathTransformer::default();
|
||||
let compile_commands = compilation
|
||||
.generate_compile_commands(&mut path_transformer, true)
|
||||
.chain_err(|| "Failed to generate compile commands");
|
||||
|
@ -437,7 +443,7 @@ where
|
|||
Ok(Some(ref client)) => client.rewrite_includes_only(),
|
||||
_ => false,
|
||||
};
|
||||
let mut path_transformer = dist::PathTransformer::new();
|
||||
let mut path_transformer = dist::PathTransformer::default();
|
||||
let compile_commands = compilation
|
||||
.generate_compile_commands(&mut path_transformer, rewrite_includes_only)
|
||||
.chain_err(|| "Failed to generate compile commands");
|
||||
|
@ -473,7 +479,7 @@ where
|
|||
.and_then(move |dist_compile_cmd| {
|
||||
debug!("[{}]: Creating distributed compile request", compile_out_pretty);
|
||||
let dist_output_paths = compilation.outputs()
|
||||
.map(|(_key, path)| path_transformer.to_dist_abs(&cwd.join(path)))
|
||||
.map(|(_key, path)| path_transformer.as_dist_abs(&cwd.join(path)))
|
||||
.collect::<Option<_>>()
|
||||
.ok_or_else(|| Error::from("Failed to adapt an output path for distributed compile"))?;
|
||||
compilation.into_dist_packagers(path_transformer)
|
||||
|
@ -585,7 +591,7 @@ where
|
|||
}
|
||||
match e {
|
||||
Error(ErrorKind::HttpClientError(_), _) => f_err(e),
|
||||
Error(ErrorKind::Lru(LruError::FileTooLarge), _) => f_err(format!(
|
||||
Error(ErrorKind::Lru(lru_disk_cache::Error::FileTooLarge), _) => f_err(format!(
|
||||
"Could not cache dist toolchain for {:?} locally.
|
||||
Increase `toolchain_cache_size` or decrease the toolchain archive size.",
|
||||
local_executable2)),
|
||||
|
@ -620,13 +626,7 @@ pub trait Compilation {
|
|||
fn into_dist_packagers(
|
||||
self: Box<Self>,
|
||||
_path_transformer: dist::PathTransformer,
|
||||
) -> Result<(
|
||||
Box<dyn pkg::InputsPackager>,
|
||||
Box<dyn pkg::ToolchainPackager>,
|
||||
Box<dyn OutputsRewriter>,
|
||||
)> {
|
||||
bail!("distributed compilation not implemented")
|
||||
}
|
||||
) -> Result<DistPackagers>;
|
||||
|
||||
/// Returns an iterator over the results of this compilation.
|
||||
///
|
||||
|
@ -763,14 +763,14 @@ impl Default for ColorMode {
|
|||
/// Can't derive(Debug) because of `CacheWriteFuture`.
|
||||
impl fmt::Debug for CompileResult {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
&CompileResult::Error => write!(f, "CompileResult::Error"),
|
||||
&CompileResult::CacheHit(ref d) => write!(f, "CompileResult::CacheHit({:?})", d),
|
||||
&CompileResult::CacheMiss(ref m, ref dt, ref d, _) => {
|
||||
match *self {
|
||||
CompileResult::Error => write!(f, "CompileResult::Error"),
|
||||
CompileResult::CacheHit(ref d) => write!(f, "CompileResult::CacheHit({:?})", d),
|
||||
CompileResult::CacheMiss(ref m, ref dt, ref d, _) => {
|
||||
write!(f, "CompileResult::CacheMiss({:?}, {:?}, {:?}, _)", d, m, dt)
|
||||
}
|
||||
&CompileResult::NotCacheable => write!(f, "CompileResult::NotCacheable"),
|
||||
&CompileResult::CompileFailed => write!(f, "CompileResult::CompileFailed"),
|
||||
CompileResult::NotCacheable => write!(f, "CompileResult::NotCacheable"),
|
||||
CompileResult::CompileFailed => write!(f, "CompileResult::CompileFailed"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1229,8 +1229,8 @@ LLVM version: 6.0",
|
|||
Ok(MockChild::new(exit_status(0), "preprocessor output", "")),
|
||||
);
|
||||
// The compiler invocation.
|
||||
const COMPILER_STDOUT: &'static [u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &'static [u8] = b"compiler stderr";
|
||||
const COMPILER_STDOUT: &[u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &[u8] = b"compiler stderr";
|
||||
let obj = f.tempdir.path().join("foo.o");
|
||||
let o = obj.clone();
|
||||
next_command_calls(&creator, move |_| {
|
||||
|
@ -1247,7 +1247,7 @@ LLVM version: 6.0",
|
|||
let arguments = ovec!["-c", "foo.c", "-o", "foo.o"];
|
||||
let hasher = match c.parse_arguments(&arguments, ".".as_ref()) {
|
||||
CompilerArguments::Ok(h) => h,
|
||||
o @ _ => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
o => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
};
|
||||
let hasher2 = hasher.clone();
|
||||
let (cached, res) = runtime
|
||||
|
@ -1333,8 +1333,8 @@ LLVM version: 6.0",
|
|||
Ok(MockChild::new(exit_status(0), "preprocessor output", "")),
|
||||
);
|
||||
// The compiler invocation.
|
||||
const COMPILER_STDOUT: &'static [u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &'static [u8] = b"compiler stderr";
|
||||
const COMPILER_STDOUT: &[u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &[u8] = b"compiler stderr";
|
||||
let obj = f.tempdir.path().join("foo.o");
|
||||
// Dist client will do the compilation
|
||||
let dist_client = Some(test_dist::OneshotClient::new(
|
||||
|
@ -1346,7 +1346,7 @@ LLVM version: 6.0",
|
|||
let arguments = ovec!["-c", "foo.c", "-o", "foo.o"];
|
||||
let hasher = match c.parse_arguments(&arguments, ".".as_ref()) {
|
||||
CompilerArguments::Ok(h) => h,
|
||||
o @ _ => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
o => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
};
|
||||
let hasher2 = hasher.clone();
|
||||
let (cached, res) = runtime
|
||||
|
@ -1433,8 +1433,8 @@ LLVM version: 6.0",
|
|||
Ok(MockChild::new(exit_status(0), "preprocessor output", "")),
|
||||
);
|
||||
// The compiler invocation.
|
||||
const COMPILER_STDOUT: &'static [u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &'static [u8] = b"compiler stderr";
|
||||
const COMPILER_STDOUT: &[u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &[u8] = b"compiler stderr";
|
||||
let obj = f.tempdir.path().join("foo.o");
|
||||
let o = obj.clone();
|
||||
next_command_calls(&creator, move |_| {
|
||||
|
@ -1451,7 +1451,7 @@ LLVM version: 6.0",
|
|||
let arguments = ovec!["-c", "foo.c", "-o", "foo.o"];
|
||||
let hasher = match c.parse_arguments(&arguments, ".".as_ref()) {
|
||||
CompilerArguments::Ok(h) => h,
|
||||
o @ _ => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
o => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
};
|
||||
// The cache will return an error.
|
||||
storage.next_get(f_err("Some Error"));
|
||||
|
@ -1501,8 +1501,8 @@ LLVM version: 6.0",
|
|||
let c = get_compiler_info(&creator, &f.bins[0], &[], &pool, None)
|
||||
.wait()
|
||||
.unwrap();
|
||||
const COMPILER_STDOUT: &'static [u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &'static [u8] = b"compiler stderr";
|
||||
const COMPILER_STDOUT: &[u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &[u8] = b"compiler stderr";
|
||||
// The compiler should be invoked twice, since we're forcing
|
||||
// recaching.
|
||||
let obj = f.tempdir.path().join("foo.o");
|
||||
|
@ -1529,7 +1529,7 @@ LLVM version: 6.0",
|
|||
let arguments = ovec!["-c", "foo.c", "-o", "foo.o"];
|
||||
let hasher = match c.parse_arguments(&arguments, ".".as_ref()) {
|
||||
CompilerArguments::Ok(h) => h,
|
||||
o @ _ => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
o => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
};
|
||||
let hasher2 = hasher.clone();
|
||||
let (cached, res) = runtime
|
||||
|
@ -1617,7 +1617,7 @@ LLVM version: 6.0",
|
|||
// We should now have a fake object file.
|
||||
assert_eq!(fs::metadata(&obj).is_ok(), true);
|
||||
// The preprocessor invocation.
|
||||
const PREPROCESSOR_STDERR: &'static [u8] = b"something went wrong";
|
||||
const PREPROCESSOR_STDERR: &[u8] = b"something went wrong";
|
||||
next_command(
|
||||
&creator,
|
||||
Ok(MockChild::new(
|
||||
|
@ -1630,7 +1630,7 @@ LLVM version: 6.0",
|
|||
let arguments = ovec!["-c", "foo.c", "-o", "foo.o"];
|
||||
let hasher = match c.parse_arguments(&arguments, ".".as_ref()) {
|
||||
CompilerArguments::Ok(h) => h,
|
||||
o @ _ => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
o => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
};
|
||||
let (cached, res) = runtime
|
||||
.block_on(future::lazy(|| {
|
||||
|
@ -1675,8 +1675,8 @@ LLVM version: 6.0",
|
|||
let c = get_compiler_info(&creator, &f.bins[0], &[], &pool, None)
|
||||
.wait()
|
||||
.unwrap();
|
||||
const COMPILER_STDOUT: &'static [u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &'static [u8] = b"compiler stderr";
|
||||
const COMPILER_STDOUT: &[u8] = b"compiler stdout";
|
||||
const COMPILER_STDERR: &[u8] = b"compiler stderr";
|
||||
// The compiler should be invoked twice, since we're forcing
|
||||
// recaching.
|
||||
let obj = f.tempdir.path().join("foo.o");
|
||||
|
@ -1703,7 +1703,7 @@ LLVM version: 6.0",
|
|||
let arguments = ovec!["-c", "foo.c", "-o", "foo.o"];
|
||||
let hasher = match c.parse_arguments(&arguments, ".".as_ref()) {
|
||||
CompilerArguments::Ok(h) => h,
|
||||
o @ _ => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
o => panic!("Bad result from parse_arguments: {:?}", o),
|
||||
};
|
||||
// All these dist clients will fail, but should still result in successful compiles
|
||||
for dist_client in dist_clients {
|
||||
|
@ -1760,6 +1760,7 @@ mod test_dist {
|
|||
|
||||
pub struct ErrorPutToolchainClient;
|
||||
impl ErrorPutToolchainClient {
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new() -> Arc<dyn dist::Client> {
|
||||
Arc::new(ErrorPutToolchainClient)
|
||||
}
|
||||
|
@ -1803,6 +1804,7 @@ mod test_dist {
|
|||
tc: Toolchain,
|
||||
}
|
||||
impl ErrorAllocJobClient {
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new() -> Arc<dyn dist::Client> {
|
||||
Arc::new(Self {
|
||||
tc: Toolchain {
|
||||
|
@ -1852,6 +1854,7 @@ mod test_dist {
|
|||
tc: Toolchain,
|
||||
}
|
||||
impl ErrorSubmitToolchainClient {
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new() -> Arc<dyn dist::Client> {
|
||||
Arc::new(Self {
|
||||
has_started: Cell::new(false),
|
||||
|
@ -1916,6 +1919,7 @@ mod test_dist {
|
|||
tc: Toolchain,
|
||||
}
|
||||
impl ErrorRunJobClient {
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new() -> Arc<dyn dist::Client> {
|
||||
Arc::new(Self {
|
||||
has_started: Cell::new(false),
|
||||
|
@ -1990,6 +1994,7 @@ mod test_dist {
|
|||
}
|
||||
|
||||
impl OneshotClient {
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new(code: i32, stdout: Vec<u8>, stderr: Vec<u8>) -> Arc<dyn dist::Client> {
|
||||
Arc::new(Self {
|
||||
has_started: Cell::new(false),
|
||||
|
|
|
@ -235,7 +235,7 @@ where
|
|||
cannot_cache!("multiple input files");
|
||||
}
|
||||
let input = match input_arg {
|
||||
Some(i) => i.to_owned(),
|
||||
Some(i) => i,
|
||||
// We can't cache compilation without an input.
|
||||
None => cannot_cache!("no input file"),
|
||||
};
|
||||
|
@ -407,7 +407,7 @@ mod test {
|
|||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
fn _parse_arguments(arguments: &[String]) -> CompilerArguments<ParsedArguments> {
|
||||
fn parse_arguments_(arguments: Vec<String>) -> CompilerArguments<ParsedArguments> {
|
||||
let args = arguments.iter().map(OsString::from).collect::<Vec<_>>();
|
||||
parse_arguments(&args, ".".as_ref(), &ARGS[..])
|
||||
}
|
||||
|
@ -418,17 +418,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -444,17 +442,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -470,17 +466,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.cc"), input.to_str());
|
||||
assert_eq!(Language::Cxx, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -498,17 +492,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.cxx"), input.to_str());
|
||||
assert_eq!(Language::Cxx, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -534,17 +526,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -564,14 +554,14 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_parse_arguments_empty_args() {
|
||||
assert_eq!(CompilerArguments::NotCompilation, _parse_arguments(&vec![]));
|
||||
assert_eq!(CompilerArguments::NotCompilation, parse_arguments_(vec![]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_arguments_not_compile() {
|
||||
assert_eq!(
|
||||
CompilerArguments::NotCompilation,
|
||||
_parse_arguments(&stringvec!["-o", "foo"])
|
||||
parse_arguments_(stringvec!["-o", "foo"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -579,7 +569,7 @@ mod test {
|
|||
fn test_parse_arguments_too_many_inputs() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("multiple input files", None),
|
||||
_parse_arguments(&stringvec!["-c", "foo.c", "-o", "foo.o", "bar.c"])
|
||||
parse_arguments_(stringvec!["-c", "foo.c", "-o", "foo.o", "bar.c"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -587,7 +577,7 @@ mod test {
|
|||
fn test_parse_arguments_link() {
|
||||
assert_eq!(
|
||||
CompilerArguments::NotCompilation,
|
||||
_parse_arguments(&stringvec!["-shared", "foo.o", "-o", "foo.so", "bar.o"])
|
||||
parse_arguments_(stringvec!["-shared", "foo.o", "-o", "foo.so", "bar.o"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -595,23 +585,23 @@ mod test {
|
|||
fn test_parse_dry_run() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-##", None),
|
||||
_parse_arguments(&stringvec!["-##", "-c", "foo.c"])
|
||||
parse_arguments_(stringvec!["-##", "-c", "foo.c"])
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-###", None),
|
||||
_parse_arguments(&stringvec!["-###", "-c", "foo.c"])
|
||||
parse_arguments_(stringvec!["-###", "-c", "foo.c"])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_at_signs() {
|
||||
let cannot_cache = CompilerArguments::CannotCache("-@", None);
|
||||
assert_eq!(_parse_arguments(&["-@@foo".into()]), cannot_cache);
|
||||
assert_eq!(_parse_arguments(&["-@E=foo".into()]), cannot_cache);
|
||||
assert_eq!(_parse_arguments(&["-@E+foo".into()]), cannot_cache);
|
||||
assert_eq!(_parse_arguments(&["-@O=foo".into()]), cannot_cache);
|
||||
assert_eq!(_parse_arguments(&["-@O+foo".into()]), cannot_cache);
|
||||
assert_eq!(parse_arguments_(vec!["-@@foo".into()]), cannot_cache);
|
||||
assert_eq!(parse_arguments_(vec!["-@E=foo".into()]), cannot_cache);
|
||||
assert_eq!(parse_arguments_(vec!["-@E+foo".into()]), cannot_cache);
|
||||
assert_eq!(parse_arguments_(vec!["-@O=foo".into()]), cannot_cache);
|
||||
assert_eq!(parse_arguments_(vec!["-@O+foo".into()]), cannot_cache);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -623,7 +613,7 @@ mod test {
|
|||
let arg = format!("-@{}", td.path().join("foo").display());
|
||||
// File foo doesn't exist.
|
||||
assert_eq!(
|
||||
_parse_arguments(&[arg]),
|
||||
parse_arguments_(vec![arg]),
|
||||
CompilerArguments::CannotCache("-@", None)
|
||||
);
|
||||
}
|
||||
|
@ -642,17 +632,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&[arg]) {
|
||||
} = match parse_arguments_(vec![arg]) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -681,7 +669,7 @@ mod test {
|
|||
let compiler = &f.bins[0];
|
||||
// Compiler invocation.
|
||||
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
|
||||
let mut path_transformer = dist::PathTransformer::new();
|
||||
let mut path_transformer = dist::PathTransformer::default();
|
||||
let (command, _, cacheable) = generate_compile_commands(
|
||||
&mut path_transformer,
|
||||
&compiler,
|
||||
|
|
|
@ -403,7 +403,7 @@ where
|
|||
cannot_cache!("multiple input files");
|
||||
}
|
||||
let input = match input_arg {
|
||||
Some(i) => i.to_owned(),
|
||||
Some(i) => i,
|
||||
// We can't cache compilation without an input.
|
||||
None => cannot_cache!("no input file"),
|
||||
};
|
||||
|
@ -418,7 +418,7 @@ where
|
|||
let output = match output_arg {
|
||||
// We can't cache compilation that doesn't go to a file
|
||||
None => PathBuf::from(Path::new(&input).with_extension("o").file_name().unwrap()),
|
||||
Some(o) => PathBuf::from(o),
|
||||
Some(o) => o,
|
||||
};
|
||||
if split_dwarf {
|
||||
let dwo = output.with_extension("dwo");
|
||||
|
@ -449,6 +449,7 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn preprocess<T>(
|
||||
creator: &T,
|
||||
executable: &Path,
|
||||
|
@ -511,10 +512,13 @@ pub fn generate_compile_commands(
|
|||
kind: CCompilerKind,
|
||||
rewrite_includes_only: bool,
|
||||
) -> Result<(CompileCommand, Option<dist::CompileCommand>, Cacheable)> {
|
||||
// Unused arguments
|
||||
#[cfg(not(feature = "dist-client"))]
|
||||
let _ = path_transformer;
|
||||
#[cfg(not(feature = "dist-client"))]
|
||||
let _ = kind;
|
||||
{
|
||||
let _ = path_transformer;
|
||||
let _ = kind;
|
||||
let _ = rewrite_includes_only;
|
||||
}
|
||||
|
||||
trace!("compile");
|
||||
|
||||
|
@ -568,11 +572,11 @@ pub fn generate_compile_commands(
|
|||
}
|
||||
let mut arguments: Vec<String> = vec![
|
||||
"-x".into(),
|
||||
language.into(),
|
||||
language,
|
||||
"-c".into(),
|
||||
path_transformer.to_dist(&parsed_args.input)?,
|
||||
path_transformer.as_dist(&parsed_args.input)?,
|
||||
"-o".into(),
|
||||
path_transformer.to_dist(out_file)?,
|
||||
path_transformer.as_dist(out_file)?,
|
||||
];
|
||||
if let CCompilerKind::GCC = kind {
|
||||
// From https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html:
|
||||
|
@ -595,10 +599,10 @@ pub fn generate_compile_commands(
|
|||
}
|
||||
arguments.extend(dist::osstrings_to_strings(&parsed_args.common_args)?);
|
||||
Some(dist::CompileCommand {
|
||||
executable: path_transformer.to_dist(&executable)?,
|
||||
executable: path_transformer.as_dist(&executable)?,
|
||||
arguments,
|
||||
env_vars: dist::osstring_tuples_to_strings(env_vars)?,
|
||||
cwd: path_transformer.to_dist_abs(cwd)?,
|
||||
cwd: path_transformer.as_dist_abs(cwd)?,
|
||||
})
|
||||
})();
|
||||
|
||||
|
@ -685,7 +689,7 @@ mod test {
|
|||
use crate::test::utils::*;
|
||||
use futures::Future;
|
||||
|
||||
fn _parse_arguments(arguments: &[String]) -> CompilerArguments<ParsedArguments> {
|
||||
fn parse_arguments_(arguments: Vec<String>) -> CompilerArguments<ParsedArguments> {
|
||||
let args = arguments.iter().map(OsString::from).collect::<Vec<_>>();
|
||||
parse_arguments(&args, ".".as_ref(), &ARGS[..])
|
||||
}
|
||||
|
@ -696,17 +700,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -723,17 +725,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -747,7 +747,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_parse_arguments_default_outputdir() {
|
||||
let args = stringvec!["-c", "/tmp/foo.c"];
|
||||
let ParsedArguments { outputs, .. } = match _parse_arguments(&args) {
|
||||
let ParsedArguments { outputs, .. } = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
|
@ -760,17 +760,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.cpp"), input.to_str());
|
||||
assert_eq!(Language::Cxx, language);
|
||||
assert_map_contains!(
|
||||
|
@ -803,17 +801,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -830,19 +826,16 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
extra_hash_files: _,
|
||||
profile_generate,
|
||||
color_mode: _,
|
||||
} = match _parse_arguments(&args) {
|
||||
..
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.cpp"), input.to_str());
|
||||
assert_eq!(Language::Cxx, language);
|
||||
assert_map_contains!(
|
||||
|
@ -864,19 +857,16 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
extra_hash_files: _,
|
||||
profile_generate,
|
||||
color_mode: _,
|
||||
} = match _parse_arguments(&args) {
|
||||
..
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.cpp"), input.to_str());
|
||||
assert_eq!(Language::Cxx, language);
|
||||
assert_map_contains!(
|
||||
|
@ -898,19 +888,16 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
extra_hash_files: _,
|
||||
profile_generate,
|
||||
color_mode: _,
|
||||
} = match _parse_arguments(&args) {
|
||||
..
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.cpp"), input.to_str());
|
||||
assert_eq!(Language::Cxx, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -928,17 +915,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.cc"), input.to_str());
|
||||
assert_eq!(Language::Cxx, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -957,17 +942,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.cxx"), input.to_str());
|
||||
assert_eq!(Language::Cxx, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -984,17 +967,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -1012,17 +993,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -1041,17 +1020,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -1069,7 +1046,7 @@ mod test {
|
|||
fn test_parse_arguments_diagnostics_color() {
|
||||
fn get_color_mode(color_flag: &str) -> ColorMode {
|
||||
let args = stringvec!["-c", "foo.c", color_flag];
|
||||
match _parse_arguments(&args) {
|
||||
match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args.color_mode,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
}
|
||||
|
@ -1085,7 +1062,7 @@ mod test {
|
|||
#[test]
|
||||
fn color_mode_preprocess() {
|
||||
let args = stringvec!["-c", "foo.c", "-fdiagnostics-color"];
|
||||
let args = match _parse_arguments(&args) {
|
||||
let args = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
|
@ -1099,17 +1076,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&args) {
|
||||
} = match parse_arguments_(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -1125,14 +1100,14 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_parse_arguments_empty_args() {
|
||||
assert_eq!(CompilerArguments::NotCompilation, _parse_arguments(&vec!()));
|
||||
assert_eq!(CompilerArguments::NotCompilation, parse_arguments_(vec!()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_arguments_not_compile() {
|
||||
assert_eq!(
|
||||
CompilerArguments::NotCompilation,
|
||||
_parse_arguments(&stringvec!["-o", "foo"])
|
||||
parse_arguments_(stringvec!["-o", "foo"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1140,7 +1115,7 @@ mod test {
|
|||
fn test_parse_arguments_too_many_inputs() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("multiple input files", None),
|
||||
_parse_arguments(&stringvec!["-c", "foo.c", "-o", "foo.o", "bar.c"])
|
||||
parse_arguments_(stringvec!["-c", "foo.c", "-o", "foo.o", "bar.c"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1123,7 @@ mod test {
|
|||
fn test_parse_arguments_link() {
|
||||
assert_eq!(
|
||||
CompilerArguments::NotCompilation,
|
||||
_parse_arguments(&stringvec!["-shared", "foo.o", "-o", "foo.so", "bar.o"])
|
||||
parse_arguments_(stringvec!["-shared", "foo.o", "-o", "foo.so", "bar.o"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1156,11 +1131,11 @@ mod test {
|
|||
fn test_parse_arguments_pgo() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-fprofile-use", None),
|
||||
_parse_arguments(&stringvec!["-c", "foo.c", "-fprofile-use", "-o", "foo.o"])
|
||||
parse_arguments_(stringvec!["-c", "foo.c", "-fprofile-use", "-o", "foo.o"])
|
||||
);
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-fprofile-use", None),
|
||||
_parse_arguments(&stringvec![
|
||||
parse_arguments_(stringvec![
|
||||
"-c",
|
||||
"foo.c",
|
||||
"-fprofile-use=file",
|
||||
|
@ -1174,11 +1149,11 @@ mod test {
|
|||
fn test_parse_arguments_response_file() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("@", None),
|
||||
_parse_arguments(&stringvec!["-c", "foo.c", "@foo", "-o", "foo.o"])
|
||||
parse_arguments_(stringvec!["-c", "foo.c", "@foo", "-o", "foo.o"])
|
||||
);
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("@", None),
|
||||
_parse_arguments(&stringvec!["-c", "foo.c", "-o", "@foo"])
|
||||
parse_arguments_(stringvec!["-c", "foo.c", "-o", "@foo"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1200,17 +1175,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match _parse_arguments(&[arg]) {
|
||||
} = match parse_arguments_(vec![arg]) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.o")));
|
||||
|
@ -1240,7 +1213,7 @@ mod test {
|
|||
let compiler = &f.bins[0];
|
||||
// Compiler invocation.
|
||||
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
|
||||
let mut path_transformer = dist::PathTransformer::new();
|
||||
let mut path_transformer = dist::PathTransformer::default();
|
||||
let (command, dist_command, cacheable) = generate_compile_commands(
|
||||
&mut path_transformer,
|
||||
&compiler,
|
||||
|
|
|
@ -92,7 +92,7 @@ impl CCompilerImpl for MSVC {
|
|||
}
|
||||
}
|
||||
|
||||
fn from_local_codepage(bytes: &Vec<u8>) -> io::Result<String> {
|
||||
fn from_local_codepage(bytes: &[u8]) -> io::Result<String> {
|
||||
Encoding::OEM.to_string(bytes)
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ where
|
|||
if path.exists() {
|
||||
// Everything from the beginning of the line
|
||||
// to this index is the prefix.
|
||||
return Ok(line[..i + 1].to_owned());
|
||||
return Ok(line[..=i].to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ pub fn parse_arguments(
|
|||
outputs.insert("obj", Path::new(&input).with_extension("obj"));
|
||||
}
|
||||
Some(o) => {
|
||||
outputs.insert("obj", PathBuf::from(o));
|
||||
outputs.insert("obj", o);
|
||||
}
|
||||
}
|
||||
// -Fd is not taken into account unless -Zi is given
|
||||
|
@ -619,11 +619,11 @@ fn generate_compile_commands(
|
|||
// http://releases.llvm.org/6.0.0/tools/clang/docs/UsersManual.html#clang-cl
|
||||
// TODO: Use /T... for language?
|
||||
let mut fo = String::from("-Fo");
|
||||
fo.push_str(&path_transformer.to_dist(out_file)?);
|
||||
fo.push_str(&path_transformer.as_dist(out_file)?);
|
||||
|
||||
let mut arguments: Vec<String> = vec![
|
||||
"-c".into(),
|
||||
path_transformer.to_dist(&parsed_args.input)?,
|
||||
path_transformer.as_dist(&parsed_args.input)?,
|
||||
fo,
|
||||
];
|
||||
// It's important to avoid preprocessor_args because of things like /FI which
|
||||
|
@ -633,10 +633,10 @@ fn generate_compile_commands(
|
|||
arguments.extend(dist::osstrings_to_strings(&parsed_args.common_args)?);
|
||||
|
||||
Some(dist::CompileCommand {
|
||||
executable: path_transformer.to_dist(&executable)?,
|
||||
executable: path_transformer.as_dist(&executable)?,
|
||||
arguments,
|
||||
env_vars: dist::osstring_tuples_to_strings(env_vars)?,
|
||||
cwd: path_transformer.to_dist(cwd)?,
|
||||
cwd: path_transformer.as_dist(cwd)?,
|
||||
})
|
||||
})();
|
||||
|
||||
|
@ -653,8 +653,8 @@ mod test {
|
|||
use futures::Future;
|
||||
use futures_cpupool::CpuPool;
|
||||
|
||||
fn parse_arguments(arguments: &[OsString]) -> CompilerArguments<ParsedArguments> {
|
||||
super::parse_arguments(arguments, &env::current_dir().unwrap(), false)
|
||||
fn parse_arguments(arguments: Vec<OsString>) -> CompilerArguments<ParsedArguments> {
|
||||
super::parse_arguments(&arguments, &env::current_dir().unwrap(), false)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -688,17 +688,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match parse_arguments(&args) {
|
||||
} = match parse_arguments(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.obj")));
|
||||
|
@ -715,17 +713,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match parse_arguments(&args) {
|
||||
} = match parse_arguments(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.obj")));
|
||||
|
@ -742,17 +738,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match parse_arguments(&args) {
|
||||
} = match parse_arguments(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.obj")));
|
||||
|
@ -769,17 +763,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match parse_arguments(&args) {
|
||||
} = match parse_arguments(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.obj")));
|
||||
|
@ -796,17 +788,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match parse_arguments(&args) {
|
||||
} = match parse_arguments(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(outputs, ("obj", PathBuf::from("foo.obj")));
|
||||
|
@ -823,17 +813,15 @@ mod test {
|
|||
let ParsedArguments {
|
||||
input,
|
||||
language,
|
||||
depfile: _,
|
||||
outputs,
|
||||
preprocessor_args,
|
||||
msvc_show_includes,
|
||||
common_args,
|
||||
..
|
||||
} = match parse_arguments(&args) {
|
||||
} = match parse_arguments(args) {
|
||||
CompilerArguments::Ok(args) => args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
assert!(true, "Parsed ok");
|
||||
assert_eq!(Some("foo.c"), input.to_str());
|
||||
assert_eq!(Language::C, language);
|
||||
assert_map_contains!(
|
||||
|
@ -850,14 +838,14 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_parse_arguments_empty_args() {
|
||||
assert_eq!(CompilerArguments::NotCompilation, parse_arguments(&vec!()));
|
||||
assert_eq!(CompilerArguments::NotCompilation, parse_arguments(vec!()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_arguments_not_compile() {
|
||||
assert_eq!(
|
||||
CompilerArguments::NotCompilation,
|
||||
parse_arguments(&ovec!["-Fofoo", "foo.c"])
|
||||
parse_arguments(ovec!["-Fofoo", "foo.c"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -865,7 +853,7 @@ mod test {
|
|||
fn test_parse_arguments_too_many_inputs() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("multiple input files", None),
|
||||
parse_arguments(&ovec!["-c", "foo.c", "-Fofoo.obj", "bar.c"])
|
||||
parse_arguments(ovec!["-c", "foo.c", "-Fofoo.obj", "bar.c"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -873,17 +861,17 @@ mod test {
|
|||
fn test_parse_arguments_unsupported() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-FA", None),
|
||||
parse_arguments(&ovec!["-c", "foo.c", "-Fofoo.obj", "-FA"])
|
||||
parse_arguments(ovec!["-c", "foo.c", "-Fofoo.obj", "-FA"])
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-Fa", None),
|
||||
parse_arguments(&ovec!["-Fa", "-c", "foo.c", "-Fofoo.obj"])
|
||||
parse_arguments(ovec!["-Fa", "-c", "foo.c", "-Fofoo.obj"])
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("-FR", None),
|
||||
parse_arguments(&ovec!["-c", "foo.c", "-FR", "-Fofoo.obj"])
|
||||
parse_arguments(ovec!["-c", "foo.c", "-FR", "-Fofoo.obj"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -891,7 +879,7 @@ mod test {
|
|||
fn test_parse_arguments_response_file() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("@", None),
|
||||
parse_arguments(&ovec!["-c", "foo.c", "@foo", "-Fofoo.obj"])
|
||||
parse_arguments(ovec!["-c", "foo.c", "@foo", "-Fofoo.obj"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -899,7 +887,7 @@ mod test {
|
|||
fn test_parse_arguments_missing_pdb() {
|
||||
assert_eq!(
|
||||
CompilerArguments::CannotCache("shared pdb", None),
|
||||
parse_arguments(&ovec!["-c", "foo.c", "-Zi", "-Fofoo.obj"])
|
||||
parse_arguments(ovec!["-c", "foo.c", "-Zi", "-Fofoo.obj"])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -922,7 +910,7 @@ mod test {
|
|||
let compiler = &f.bins[0];
|
||||
// Compiler invocation.
|
||||
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
|
||||
let mut path_transformer = dist::PathTransformer::new();
|
||||
let mut path_transformer = dist::PathTransformer::default();
|
||||
let (command, dist_command, cacheable) = generate_compile_commands(
|
||||
&mut path_transformer,
|
||||
&compiler,
|
||||
|
@ -950,7 +938,7 @@ mod test {
|
|||
input: "foo.c".into(),
|
||||
language: Language::C,
|
||||
depfile: None,
|
||||
outputs: vec![("obj", "foo.obj".into()), ("pdb", pdb.into())]
|
||||
outputs: vec![("obj", "foo.obj".into()), ("pdb", pdb)]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
preprocessor_args: vec![],
|
||||
|
@ -963,7 +951,7 @@ mod test {
|
|||
let compiler = &f.bins[0];
|
||||
// Compiler invocation.
|
||||
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
|
||||
let mut path_transformer = dist::PathTransformer::new();
|
||||
let mut path_transformer = dist::PathTransformer::default();
|
||||
let (command, dist_command, cacheable) = generate_compile_commands(
|
||||
&mut path_transformer,
|
||||
&compiler,
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
// limitations under the License.
|
||||
|
||||
use crate::compiler::args::*;
|
||||
#[cfg(feature = "dist-client")]
|
||||
use crate::compiler::OutputsRewriter;
|
||||
use crate::compiler::{
|
||||
Cacheable, ColorMode, Compilation, CompileCommand, Compiler, CompilerArguments, CompilerHasher,
|
||||
CompilerKind, HashResult,
|
||||
};
|
||||
#[cfg(feature = "dist-client")]
|
||||
use crate::compiler::{DistPackagers, OutputsRewriter};
|
||||
use crate::dist;
|
||||
#[cfg(feature = "dist-client")]
|
||||
use crate::dist::pkg;
|
||||
|
@ -182,7 +182,7 @@ lazy_static! {
|
|||
"link",
|
||||
"metadata",
|
||||
"dep-info",
|
||||
].iter().map(|s| *s).collect();
|
||||
].iter().copied().collect();
|
||||
}
|
||||
|
||||
/// Version number for cache key.
|
||||
|
@ -310,7 +310,7 @@ where
|
|||
fn get_compiler_outputs<T>(
|
||||
creator: &T,
|
||||
executable: &Path,
|
||||
arguments: &[OsString],
|
||||
arguments: Vec<OsString>,
|
||||
cwd: &Path,
|
||||
env_vars: &[(OsString, OsString)],
|
||||
) -> SFuture<Vec<String>>
|
||||
|
@ -389,7 +389,7 @@ impl Rust {
|
|||
.collect::<Vec<_>>();
|
||||
if let Some(path) = dist_archive {
|
||||
trace!("Hashing {:?} along with rustc libs.", path);
|
||||
libs.push(path.to_path_buf());
|
||||
libs.push(path);
|
||||
};
|
||||
libs.sort();
|
||||
Ok((sysroot, libs))
|
||||
|
@ -800,7 +800,7 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments<Pars
|
|||
let mut color_mode = ColorMode::Auto;
|
||||
let mut has_json = false;
|
||||
|
||||
for arg in ArgsIter::new(arguments.iter().map(|s| s.clone()), &ARGS[..]) {
|
||||
for arg in ArgsIter::new(arguments.iter().cloned(), &ARGS[..]) {
|
||||
let arg = try_or_cannot_cache!(arg, "argument parse");
|
||||
match arg.get_data() {
|
||||
Some(TooHardFlag) | Some(TooHard(_)) | Some(TooHardPath(_)) => {
|
||||
|
@ -829,7 +829,7 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments<Pars
|
|||
// We don't support passing --emit more than once.
|
||||
cannot_cache!("more than one --emit");
|
||||
}
|
||||
emit = Some(value.split(",").map(str::to_owned).collect())
|
||||
emit = Some(value.split(',').map(str::to_owned).collect())
|
||||
}
|
||||
Some(CrateType(ArgCrateTypes {
|
||||
rlib,
|
||||
|
@ -980,7 +980,7 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments<Pars
|
|||
externs.sort();
|
||||
CompilerArguments::Ok(ParsedArguments {
|
||||
arguments: args,
|
||||
output_dir: output_dir.into(),
|
||||
output_dir,
|
||||
crate_types,
|
||||
externs,
|
||||
crate_link_paths,
|
||||
|
@ -1054,7 +1054,7 @@ where
|
|||
}
|
||||
})
|
||||
.flat_map(|(arg, val)| Some(arg).into_iter().chain(val))
|
||||
.map(|a| a.clone())
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
// Find all the source files and hash them
|
||||
let source_hashes_pool = pool.clone();
|
||||
|
@ -1161,13 +1161,13 @@ where
|
|||
// Turn arguments into a simple Vec<OsString> to calculate outputs.
|
||||
let flat_os_string_arguments: Vec<OsString> = os_string_arguments
|
||||
.into_iter()
|
||||
.flat_map(|(arg, val)| iter::once(arg).into_iter().chain(val))
|
||||
.flat_map(|(arg, val)| iter::once(arg).chain(val))
|
||||
.collect();
|
||||
Box::new(
|
||||
get_compiler_outputs(
|
||||
&creator,
|
||||
&executable,
|
||||
&flat_os_string_arguments,
|
||||
flat_os_string_arguments,
|
||||
&cwd,
|
||||
&env_vars,
|
||||
)
|
||||
|
@ -1212,7 +1212,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
let output_dir = PathBuf::from(output_dir);
|
||||
// Convert output files into a map of basename -> full
|
||||
// path, and remove some unneeded / non-existing ones,
|
||||
// see https://github.com/rust-lang/rust/pull/68799.
|
||||
|
@ -1301,8 +1300,14 @@ impl Compilation for RustCompilation {
|
|||
ref sysroot,
|
||||
..
|
||||
} = *self;
|
||||
|
||||
// Ignore unused variables
|
||||
#[cfg(not(feature = "dist-client"))]
|
||||
let _ = path_transformer;
|
||||
{
|
||||
let _ = path_transformer;
|
||||
let _ = host;
|
||||
let _ = sysroot;
|
||||
}
|
||||
|
||||
trace!("[{}]: compile", crate_name);
|
||||
|
||||
|
@ -1337,7 +1342,7 @@ impl Compilation for RustCompilation {
|
|||
|
||||
// flat_map would be nice but the lifetimes don't work out
|
||||
for argument in arguments.iter() {
|
||||
let path_transformer_fn = &mut |p: &Path| path_transformer.to_dist(p);
|
||||
let path_transformer_fn = &mut |p: &Path| path_transformer.as_dist(p);
|
||||
if let Argument::Raw(input_path) = argument {
|
||||
// Need to explicitly handle the input argument as it's not parsed as a path
|
||||
let input_path = Path::new(input_path).to_owned();
|
||||
|
@ -1367,7 +1372,7 @@ impl Compilation for RustCompilation {
|
|||
match k.as_str() {
|
||||
// We round-tripped from path to string and back to path, but it should be lossless
|
||||
"OUT_DIR" => {
|
||||
let dist_out_dir = path_transformer.to_dist(Path::new(v))?;
|
||||
let dist_out_dir = path_transformer.as_dist(Path::new(v))?;
|
||||
if dist_out_dir != *v {
|
||||
changed_out_dir = Some(v.to_owned().into());
|
||||
}
|
||||
|
@ -1378,7 +1383,7 @@ impl Compilation for RustCompilation {
|
|||
*v = "".to_string();
|
||||
}
|
||||
"CARGO" | "CARGO_MANIFEST_DIR" => {
|
||||
*v = path_transformer.to_dist(Path::new(v))?
|
||||
*v = path_transformer.as_dist(Path::new(v))?
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -1414,10 +1419,10 @@ impl Compilation for RustCompilation {
|
|||
.with_extension(EXE_EXTENSION);
|
||||
|
||||
Some(dist::CompileCommand {
|
||||
executable: path_transformer.to_dist(&sysroot_executable)?,
|
||||
executable: path_transformer.as_dist(&sysroot_executable)?,
|
||||
arguments: dist_arguments,
|
||||
env_vars,
|
||||
cwd: path_transformer.to_dist_abs(cwd)?,
|
||||
cwd: path_transformer.as_dist_abs(cwd)?,
|
||||
})
|
||||
})();
|
||||
|
||||
|
@ -1428,11 +1433,7 @@ impl Compilation for RustCompilation {
|
|||
fn into_dist_packagers(
|
||||
self: Box<Self>,
|
||||
path_transformer: dist::PathTransformer,
|
||||
) -> Result<(
|
||||
Box<dyn pkg::InputsPackager>,
|
||||
Box<dyn pkg::ToolchainPackager>,
|
||||
Box<dyn OutputsRewriter>,
|
||||
)> {
|
||||
) -> Result<DistPackagers> {
|
||||
let RustCompilation {
|
||||
inputs,
|
||||
crate_link_paths,
|
||||
|
@ -1490,6 +1491,7 @@ struct RustInputsPackager {
|
|||
|
||||
#[cfg(feature = "dist-client")]
|
||||
impl pkg::InputsPackager for RustInputsPackager {
|
||||
#[allow(clippy::cognitive_complexity)] // TODO simplify this method.
|
||||
fn write_inputs(self: Box<Self>, wtr: &mut dyn io::Write) -> Result<dist::PathTransformer> {
|
||||
debug!("Packaging compile inputs for compile");
|
||||
let RustInputsPackager {
|
||||
|
@ -1537,7 +1539,7 @@ impl pkg::InputsPackager for RustInputsPackager {
|
|||
}
|
||||
}
|
||||
let dist_input_path = path_transformer
|
||||
.to_dist(&input_path)
|
||||
.as_dist(&input_path)
|
||||
.chain_err(|| format!("unable to transform input path {}", input_path.display()))?;
|
||||
tar_inputs.push((input_path, dist_input_path))
|
||||
}
|
||||
|
@ -1618,7 +1620,7 @@ impl pkg::InputsPackager for RustInputsPackager {
|
|||
|
||||
// This is a lib that may be of interest during compilation
|
||||
let dist_path = path_transformer
|
||||
.to_dist(&path)
|
||||
.as_dist(&path)
|
||||
.chain_err(|| format!("unable to transform lib path {}", path.display()))?;
|
||||
tar_crate_libs.push((path, dist_path))
|
||||
}
|
||||
|
@ -1736,7 +1738,7 @@ impl OutputsRewriter for RustOutputsRewriter {
|
|||
trace!("Pondering on rewriting dep file {:?}", self.dep_info);
|
||||
if let Some(dep_info) = self.dep_info {
|
||||
let extra_input_str = extra_inputs
|
||||
.into_iter()
|
||||
.iter()
|
||||
.fold(String::new(), |s, p| s + " " + &p.to_string_lossy());
|
||||
for dep_info_local_path in output_paths {
|
||||
trace!("Comparing with {}", dep_info_local_path.display());
|
||||
|
@ -1763,7 +1765,7 @@ impl OutputsRewriter for RustOutputsRewriter {
|
|||
let re = regex::Regex::new(&re_str).expect("Invalid regex");
|
||||
deps = re.replace_all(&deps, local_path_str).into_owned();
|
||||
}
|
||||
if extra_inputs.len() > 0 {
|
||||
if !extra_inputs.is_empty() {
|
||||
deps = deps.replace(": ", &format!(":{} ", extra_input_str));
|
||||
}
|
||||
// Write the depinfo file
|
||||
|
@ -1787,8 +1789,8 @@ fn test_rust_outputs_rewriter() {
|
|||
use crate::test::utils::create_file;
|
||||
use std::io::Write;
|
||||
|
||||
let mut pt = dist::PathTransformer::new();
|
||||
pt.to_dist(Path::new("c:\\")).unwrap();
|
||||
let mut pt = dist::PathTransformer::default();
|
||||
pt.as_dist(Path::new("c:\\")).unwrap();
|
||||
let mappings: Vec<_> = pt.disk_mappings().collect();
|
||||
assert!(mappings.len() == 1);
|
||||
let linux_prefix = &mappings[0].1;
|
||||
|
@ -2064,7 +2066,7 @@ fn parse_rustc_z_ls(stdout: &str) -> Result<Vec<&str>> {
|
|||
dep_names.push(libname);
|
||||
}
|
||||
|
||||
while let Some(line) = lines.next() {
|
||||
for line in lines {
|
||||
if line != "" {
|
||||
bail!("Trailing non-blank lines in rustc -Z ls output")
|
||||
}
|
||||
|
@ -2095,7 +2097,7 @@ mod test {
|
|||
( $( $s:expr ),* ) => {
|
||||
match _parse_arguments(&[ $( $s.to_string(), )* ]) {
|
||||
CompilerArguments::Ok(a) => a,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2105,12 +2107,13 @@ mod test {
|
|||
match _parse_arguments(&[ $( $s.to_string(), )* ]) {
|
||||
CompilerArguments::Ok(_) => panic!("Should not have parsed ok: `{}`", stringify!($( $s, )*)),
|
||||
|
||||
o @ _ => o,
|
||||
o => o,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn test_parse_arguments_simple() {
|
||||
let h = parses!(
|
||||
"--emit",
|
||||
|
@ -2501,7 +2504,7 @@ mod test {
|
|||
let outputs = get_compiler_outputs(
|
||||
&creator,
|
||||
"rustc".as_ref(),
|
||||
&ovec!("a", "b"),
|
||||
ovec!("a", "b"),
|
||||
"cwd".as_ref(),
|
||||
&[],
|
||||
)
|
||||
|
@ -2517,7 +2520,7 @@ mod test {
|
|||
assert!(get_compiler_outputs(
|
||||
&creator,
|
||||
"rustc".as_ref(),
|
||||
&ovec!("a", "b"),
|
||||
ovec!("a", "b"),
|
||||
"cwd".as_ref(),
|
||||
&[]
|
||||
)
|
||||
|
@ -2637,7 +2640,7 @@ c:/foo/bar.rs:
|
|||
// a dep-info file.
|
||||
let mut sorted_deps = dep_srcs
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.map(|s| (*s).to_string())
|
||||
.collect::<Vec<String>>();
|
||||
sorted_deps.sort();
|
||||
next_command_calls(creator, move |args| {
|
||||
|
@ -2675,7 +2678,7 @@ c:/foo/bar.rs:
|
|||
fn test_generate_hash_key() {
|
||||
drop(env_logger::try_init());
|
||||
let f = TestFixture::new();
|
||||
const FAKE_DIGEST: &'static str = "abcd1234";
|
||||
const FAKE_DIGEST: &str = "abcd1234";
|
||||
// We'll just use empty files for each of these.
|
||||
for s in ["foo.rs", "bar.rs", "bar.rlib", "libbaz.a"].iter() {
|
||||
f.touch(s).unwrap();
|
||||
|
@ -2694,13 +2697,13 @@ c:/foo/bar.rs:
|
|||
arguments: vec![
|
||||
Argument::Raw("a".into()),
|
||||
Argument::WithValue(
|
||||
"--cfg".into(),
|
||||
"--cfg",
|
||||
ArgData::PassThrough("xyz".into()),
|
||||
ArgDisposition::Separated,
|
||||
),
|
||||
Argument::Raw("b".into()),
|
||||
Argument::WithValue(
|
||||
"--cfg".into(),
|
||||
"--cfg",
|
||||
ArgData::PassThrough("abc".into()),
|
||||
ArgDisposition::Separated,
|
||||
),
|
||||
|
@ -2777,18 +2780,19 @@ c:/foo/bar.rs:
|
|||
assert_eq!(out, vec!["foo.a", "foo.rlib", "foo.rmeta"]);
|
||||
}
|
||||
|
||||
fn hash_key<'a, F>(
|
||||
fn hash_key<F>(
|
||||
f: &TestFixture,
|
||||
args: &[OsString],
|
||||
args: &[&'static str],
|
||||
env_vars: &[(OsString, OsString)],
|
||||
pre_func: F,
|
||||
) -> String
|
||||
where
|
||||
F: Fn(&Path) -> Result<()>,
|
||||
{
|
||||
let parsed_args = match parse_arguments(args, &f.tempdir.path()) {
|
||||
let oargs = args.iter().map(OsString::from).collect::<Vec<OsString>>();
|
||||
let parsed_args = match parse_arguments(&oargs, &f.tempdir.path()) {
|
||||
CompilerArguments::Ok(parsed_args) => parsed_args,
|
||||
o @ _ => panic!("Got unexpected parse result: {:?}", o),
|
||||
o => panic!("Got unexpected parse result: {:?}", o),
|
||||
};
|
||||
// Just use empty files for sources.
|
||||
for src in ["foo.rs"].iter() {
|
||||
|
@ -2846,7 +2850,7 @@ c:/foo/bar.rs:
|
|||
assert_eq!(
|
||||
hash_key(
|
||||
&f,
|
||||
&ovec![
|
||||
&[
|
||||
"--emit",
|
||||
"link",
|
||||
"foo.rs",
|
||||
|
@ -2861,12 +2865,12 @@ c:/foo/bar.rs:
|
|||
"--extern",
|
||||
"b=b.rlib"
|
||||
],
|
||||
&vec![],
|
||||
&[],
|
||||
&mk_files
|
||||
),
|
||||
hash_key(
|
||||
&f,
|
||||
&ovec![
|
||||
&[
|
||||
"--extern",
|
||||
"b=b.rlib",
|
||||
"--emit",
|
||||
|
@ -2881,7 +2885,7 @@ c:/foo/bar.rs:
|
|||
"--crate-type",
|
||||
"lib"
|
||||
],
|
||||
&vec![],
|
||||
&[],
|
||||
&mk_files
|
||||
)
|
||||
);
|
||||
|
@ -2893,7 +2897,7 @@ c:/foo/bar.rs:
|
|||
assert_eq!(
|
||||
hash_key(
|
||||
&f,
|
||||
&ovec![
|
||||
&[
|
||||
"--emit",
|
||||
"link",
|
||||
"-L",
|
||||
|
@ -2908,12 +2912,12 @@ c:/foo/bar.rs:
|
|||
"-L",
|
||||
"y=y"
|
||||
],
|
||||
&vec![],
|
||||
&[],
|
||||
nothing
|
||||
),
|
||||
hash_key(
|
||||
&f,
|
||||
&ovec![
|
||||
&[
|
||||
"-L",
|
||||
"y=y",
|
||||
"--emit",
|
||||
|
@ -2928,7 +2932,7 @@ c:/foo/bar.rs:
|
|||
"--crate-type",
|
||||
"lib"
|
||||
],
|
||||
&vec![],
|
||||
&[],
|
||||
nothing
|
||||
)
|
||||
);
|
||||
|
@ -2940,7 +2944,7 @@ c:/foo/bar.rs:
|
|||
assert_eq!(
|
||||
hash_key(
|
||||
&f,
|
||||
&ovec![
|
||||
&[
|
||||
"--emit",
|
||||
"link",
|
||||
"-L",
|
||||
|
@ -2957,12 +2961,12 @@ c:/foo/bar.rs:
|
|||
"-L",
|
||||
"y=y"
|
||||
],
|
||||
&vec![],
|
||||
&[],
|
||||
nothing
|
||||
),
|
||||
hash_key(
|
||||
&f,
|
||||
&ovec![
|
||||
&[
|
||||
"-L",
|
||||
"y=a",
|
||||
"--emit",
|
||||
|
@ -2979,7 +2983,7 @@ c:/foo/bar.rs:
|
|||
"--crate-type",
|
||||
"lib"
|
||||
],
|
||||
&vec![],
|
||||
&[],
|
||||
nothing
|
||||
)
|
||||
);
|
||||
|
@ -2991,7 +2995,7 @@ c:/foo/bar.rs:
|
|||
assert_eq!(
|
||||
hash_key(
|
||||
&f,
|
||||
&ovec![
|
||||
&[
|
||||
"--emit",
|
||||
"link",
|
||||
"--cfg",
|
||||
|
@ -3006,12 +3010,12 @@ c:/foo/bar.rs:
|
|||
"--cfg",
|
||||
"feature=b"
|
||||
],
|
||||
&vec![],
|
||||
&[],
|
||||
nothing
|
||||
),
|
||||
hash_key(
|
||||
&f,
|
||||
&ovec![
|
||||
&[
|
||||
"--cfg",
|
||||
"feature=b",
|
||||
"--emit",
|
||||
|
@ -3026,7 +3030,7 @@ c:/foo/bar.rs:
|
|||
"--crate-type",
|
||||
"lib"
|
||||
],
|
||||
&vec![],
|
||||
&[],
|
||||
nothing
|
||||
)
|
||||
);
|
||||
|
|
|
@ -78,7 +78,7 @@ pub fn parse_size(val: &str) -> Option<u64> {
|
|||
.and_then(|caps| {
|
||||
caps.get(1)
|
||||
.and_then(|size| u64::from_str(size.as_str()).ok())
|
||||
.and_then(|size| Some((size, caps.get(2))))
|
||||
.map(|size| (size, caps.get(2)))
|
||||
})
|
||||
.and_then(|(size, suffix)| match suffix.map(|s| s.as_str()) {
|
||||
Some("K") => Some(1024 * size),
|
||||
|
@ -477,7 +477,7 @@ fn config_from_env() -> EnvConfig {
|
|||
|
||||
let gcs = env::var("SCCACHE_GCS_BUCKET").ok().map(|bucket| {
|
||||
let url = env::var("SCCACHE_GCS_CREDENTIALS_URL").ok();
|
||||
let cred_path = env::var_os("SCCACHE_GCS_KEY_PATH").map(|p| PathBuf::from(p));
|
||||
let cred_path = env::var_os("SCCACHE_GCS_KEY_PATH").map(PathBuf::from);
|
||||
|
||||
if url.is_some() && cred_path.is_some() {
|
||||
warn!("Both SCCACHE_GCS_CREDENTIALS_URL and SCCACHE_GCS_KEY_PATH are set");
|
||||
|
@ -549,7 +549,7 @@ impl Config {
|
|||
let env_conf = config_from_env();
|
||||
|
||||
let file_conf_path = env::var_os("SCCACHE_CONF")
|
||||
.map(|p| PathBuf::from(p))
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| {
|
||||
let dirs = ProjectDirs::from("", ORGANIZATION, APP_NAME)
|
||||
.expect("Unable to get config directory");
|
||||
|
@ -856,9 +856,9 @@ fn test_gcs_credentials_url() {
|
|||
match env_cfg.cache.gcs {
|
||||
Some(GCSCacheConfig {
|
||||
ref bucket,
|
||||
cred_path: _,
|
||||
ref url,
|
||||
rw_mode,
|
||||
..
|
||||
}) => {
|
||||
assert_eq!(bucket, "my-bucket");
|
||||
match url {
|
||||
|
@ -867,6 +867,6 @@ fn test_gcs_credentials_url() {
|
|||
};
|
||||
assert_eq!(rw_mode, GCSCacheRWMode::ReadWrite);
|
||||
}
|
||||
None => assert!(false),
|
||||
None => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ mod client {
|
|||
// Load in toolchain configuration
|
||||
let mut custom_toolchain_paths = HashMap::new();
|
||||
let mut disabled_toolchains = HashSet::new();
|
||||
for ct in toolchain_configs.into_iter() {
|
||||
for ct in toolchain_configs.iter() {
|
||||
match ct {
|
||||
config::DistToolchainConfig::PathOverride {
|
||||
compiler_executable,
|
||||
|
@ -492,6 +492,10 @@ impl TcCache {
|
|||
self.inner.len()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
|
||||
pub fn remove(&mut self, tc: &Toolchain) -> LruResult<()> {
|
||||
self.inner.remove(make_lru_key_path(&tc.archive_id))
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ mod code_grant_pkce {
|
|||
}
|
||||
// Calculate ASAP the actual time at which the token will expire
|
||||
let expires_at = Instant::now() + Duration::from_secs(res.expires_in);
|
||||
Ok((token.to_owned(), expires_at))
|
||||
Ok((token, expires_at))
|
||||
}
|
||||
|
||||
const SUCCESS_AFTER_REDIRECT: &str = r##"<!doctype html>
|
||||
|
|
|
@ -101,13 +101,13 @@ mod path_transform {
|
|||
dist_to_local_path: HashMap::new(),
|
||||
}
|
||||
}
|
||||
pub fn to_dist_abs(&mut self, p: &Path) -> Option<String> {
|
||||
pub fn as_dist_abs(&mut self, p: &Path) -> Option<String> {
|
||||
if !p.is_absolute() {
|
||||
return None;
|
||||
}
|
||||
self.to_dist(p)
|
||||
self.as_dist(p)
|
||||
}
|
||||
pub fn to_dist(&mut self, p: &Path) -> Option<String> {
|
||||
pub fn as_dist(&mut self, p: &Path) -> Option<String> {
|
||||
let mut components = p.components();
|
||||
|
||||
// Extract the prefix (e.g. "C:/") if present
|
||||
|
@ -187,14 +187,14 @@ mod path_transform {
|
|||
|
||||
#[test]
|
||||
fn test_basic() {
|
||||
let mut pt = PathTransformer::new();
|
||||
assert_eq!(pt.to_dist(Path::new("C:/a")).unwrap(), "/prefix/disk-C/a");
|
||||
let mut pt = PathTransformer::default();
|
||||
assert_eq!(pt.as_dist(Path::new("C:/a")).unwrap(), "/prefix/disk-C/a");
|
||||
assert_eq!(
|
||||
pt.to_dist(Path::new(r#"C:\a\b.c"#)).unwrap(),
|
||||
pt.as_dist(Path::new(r#"C:\a\b.c"#)).unwrap(),
|
||||
"/prefix/disk-C/a/b.c"
|
||||
);
|
||||
assert_eq!(
|
||||
pt.to_dist(Path::new("X:/other.c")).unwrap(),
|
||||
pt.as_dist(Path::new("X:/other.c")).unwrap(),
|
||||
"/prefix/disk-X/other.c"
|
||||
);
|
||||
let mut disk_mappings: Vec<_> = pt.disk_mappings().collect();
|
||||
|
@ -219,20 +219,20 @@ mod path_transform {
|
|||
|
||||
#[test]
|
||||
fn test_relative_paths() {
|
||||
let mut pt = PathTransformer::new();
|
||||
assert_eq!(pt.to_dist(Path::new("a/b")).unwrap(), "a/b");
|
||||
assert_eq!(pt.to_dist(Path::new(r#"a\b"#)).unwrap(), "a/b");
|
||||
let mut pt = PathTransformer::default();
|
||||
assert_eq!(pt.as_dist(Path::new("a/b")).unwrap(), "a/b");
|
||||
assert_eq!(pt.as_dist(Path::new(r#"a\b"#)).unwrap(), "a/b");
|
||||
assert_eq!(pt.to_local("a/b").unwrap(), Path::new("a/b"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_verbatim_disks() {
|
||||
let mut pt = PathTransformer::new();
|
||||
let mut pt = PathTransformer::default();
|
||||
assert_eq!(
|
||||
pt.to_dist(Path::new("X:/other.c")).unwrap(),
|
||||
pt.as_dist(Path::new("X:/other.c")).unwrap(),
|
||||
"/prefix/disk-X/other.c"
|
||||
);
|
||||
pt.to_dist(Path::new(r#"\\?\X:\out\other.o"#));
|
||||
pt.as_dist(Path::new(r#"\\?\X:\out\other.o"#));
|
||||
assert_eq!(
|
||||
pt.to_local("/prefix/disk-X/other.c").unwrap(),
|
||||
Path::new("X:/other.c")
|
||||
|
@ -254,9 +254,9 @@ mod path_transform {
|
|||
|
||||
#[test]
|
||||
fn test_slash_directions() {
|
||||
let mut pt = PathTransformer::new();
|
||||
assert_eq!(pt.to_dist(Path::new("C:/a")).unwrap(), "/prefix/disk-C/a");
|
||||
assert_eq!(pt.to_dist(Path::new("C:\\a")).unwrap(), "/prefix/disk-C/a");
|
||||
let mut pt = PathTransformer::default();
|
||||
assert_eq!(pt.as_dist(Path::new("C:/a")).unwrap(), "/prefix/disk-C/a");
|
||||
assert_eq!(pt.as_dist(Path::new("C:\\a")).unwrap(), "/prefix/disk-C/a");
|
||||
assert_eq!(pt.to_local("/prefix/disk-C/a").unwrap(), Path::new("C:/a"));
|
||||
assert_eq!(pt.disk_mappings().count(), 1);
|
||||
}
|
||||
|
@ -267,20 +267,17 @@ mod path_transform {
|
|||
use std::iter;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PathTransformer;
|
||||
|
||||
impl PathTransformer {
|
||||
pub fn new() -> Self {
|
||||
PathTransformer
|
||||
}
|
||||
pub fn to_dist_abs(&mut self, p: &Path) -> Option<String> {
|
||||
pub fn as_dist_abs(&mut self, p: &Path) -> Option<String> {
|
||||
if !p.is_absolute() {
|
||||
return None;
|
||||
}
|
||||
self.to_dist(p)
|
||||
self.as_dist(p)
|
||||
}
|
||||
pub fn to_dist(&mut self, p: &Path) -> Option<String> {
|
||||
pub fn as_dist(&mut self, p: &Path) -> Option<String> {
|
||||
p.as_os_str().to_str().map(Into::into)
|
||||
}
|
||||
pub fn disk_mappings(&self) -> impl Iterator<Item = (PathBuf, String)> {
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// TODO error_chain needs to be upgraded, it uses deprecated APIs.
|
||||
#![allow(deprecated)]
|
||||
#![allow(renamed_and_removed_lints)]
|
||||
|
||||
use std::boxed::Box;
|
||||
|
|
|
@ -631,8 +631,8 @@ mod test {
|
|||
creator.next_command_spawns(Ok(MockChild::new(exit_status(0), "hello", "error")));
|
||||
let output = spawn_output_command(&mut creator, "foo").unwrap();
|
||||
assert_eq!(0, output.status.code().unwrap());
|
||||
assert_eq!("hello".as_bytes().to_vec(), output.stdout);
|
||||
assert_eq!("error".as_bytes().to_vec(), output.stderr);
|
||||
assert_eq!(b"hello".to_vec(), output.stdout);
|
||||
assert_eq!(b"error".to_vec(), output.stderr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -642,8 +642,8 @@ mod test {
|
|||
creator.next_command_calls(|_| Ok(MockChild::new(exit_status(0), "hello", "error")));
|
||||
let output = spawn_output_command(&mut creator, "foo").unwrap();
|
||||
assert_eq!(0, output.status.code().unwrap());
|
||||
assert_eq!("hello".as_bytes().to_vec(), output.stdout);
|
||||
assert_eq!("error".as_bytes().to_vec(), output.stderr);
|
||||
assert_eq!(b"hello".to_vec(), output.stdout);
|
||||
assert_eq!(b"error".to_vec(), output.stderr);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -675,6 +675,6 @@ mod test {
|
|||
&creator,
|
||||
Ok(MockChild::new(exit_status(0), "hello", "error")),
|
||||
);
|
||||
assert_eq!(exit_status(0), spawn_on_thread(creator.clone(), true));
|
||||
assert_eq!(exit_status(0), spawn_on_thread(creator, true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ pub enum Response {
|
|||
/// Response for `Request::Compile`.
|
||||
Compile(CompileResponse),
|
||||
/// Response for `Request::GetStats`, containing server statistics.
|
||||
Stats(ServerInfo),
|
||||
Stats(Box<ServerInfo>),
|
||||
/// Response for `Request::DistStatus`, containing client info.
|
||||
DistStatus(DistInfo),
|
||||
/// Response for `Request::Shutdown`, containing server statistics.
|
||||
ShuttingDown(ServerInfo),
|
||||
ShuttingDown(Box<ServerInfo>),
|
||||
/// Second response for `Request::Compile`, containing the results of the compilation.
|
||||
CompileFinished(CompileFinished),
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ use crate::compiler::{
|
|||
use crate::config;
|
||||
use crate::config::Config;
|
||||
use crate::dist;
|
||||
use crate::dist::Client as DistClient;
|
||||
use crate::jobserver::Client;
|
||||
use crate::mock_command::{CommandCreatorSync, ProcessCommandCreator};
|
||||
use crate::protocol::{Compile, CompileFinished, CompileResponse, Request, Response};
|
||||
|
@ -153,11 +152,11 @@ struct DistClientConfig {
|
|||
#[cfg(feature = "dist-client")]
|
||||
enum DistClientState {
|
||||
#[cfg(feature = "dist-client")]
|
||||
Some(DistClientConfig, Arc<dyn dist::Client>),
|
||||
Some(Box<DistClientConfig>, Arc<dyn dist::Client>),
|
||||
#[cfg(feature = "dist-client")]
|
||||
FailWithMessage(DistClientConfig, String),
|
||||
FailWithMessage(Box<DistClientConfig>, String),
|
||||
#[cfg(feature = "dist-client")]
|
||||
RetryCreateAt(DistClientConfig, Instant),
|
||||
RetryCreateAt(Box<DistClientConfig>, Instant),
|
||||
Disabled,
|
||||
}
|
||||
|
||||
|
@ -165,7 +164,7 @@ enum DistClientState {
|
|||
impl DistClientContainer {
|
||||
#[cfg(not(feature = "dist-client"))]
|
||||
fn new(config: &Config, _: &CpuPool) -> Self {
|
||||
if let Some(_) = config.dist.scheduler_url {
|
||||
if config.dist.scheduler_url.is_some() {
|
||||
warn!("Scheduler address configured but dist feature disabled, disabling distributed sccache")
|
||||
}
|
||||
Self {}
|
||||
|
@ -284,7 +283,7 @@ impl DistClientContainer {
|
|||
_ => unreachable!(),
|
||||
};
|
||||
info!("Attempting to recreate the dist client");
|
||||
*state = Self::create_state(config)
|
||||
*state = Self::create_state(*config)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,7 +297,7 @@ impl DistClientContainer {
|
|||
use error_chain::ChainedError;
|
||||
error!("{}", e.display_chain());
|
||||
return DistClientState::RetryCreateAt(
|
||||
config,
|
||||
Box::new(config),
|
||||
Instant::now() + DIST_CLIENT_RECREATE_TIMEOUT,
|
||||
);
|
||||
}
|
||||
|
@ -314,7 +313,10 @@ impl DistClientContainer {
|
|||
use error_chain::ChainedError;
|
||||
let errmsg = e.display_chain();
|
||||
error!("{}", errmsg);
|
||||
return DistClientState::FailWithMessage(config, errmsg.to_string());
|
||||
return DistClientState::FailWithMessage(
|
||||
Box::new(config),
|
||||
errmsg.to_string(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}};
|
||||
|
@ -347,18 +349,19 @@ impl DistClientContainer {
|
|||
let dist_client = try_or_retry_later!(
|
||||
dist_client.chain_err(|| "failure during dist client creation")
|
||||
);
|
||||
use crate::dist::Client;
|
||||
match dist_client.do_get_status().wait() {
|
||||
Ok(res) => {
|
||||
info!(
|
||||
"Successfully created dist client with {:?} cores across {:?} servers",
|
||||
res.num_cpus, res.num_servers
|
||||
);
|
||||
DistClientState::Some(config, Arc::new(dist_client))
|
||||
DistClientState::Some(Box::new(config), Arc::new(dist_client))
|
||||
}
|
||||
Err(_) => {
|
||||
warn!("Scheduler address configured, but could not communicate with scheduler");
|
||||
DistClientState::RetryCreateAt(
|
||||
config,
|
||||
Box::new(config),
|
||||
Instant::now() + DIST_CLIENT_RECREATE_TIMEOUT,
|
||||
)
|
||||
}
|
||||
|
@ -592,6 +595,9 @@ impl<C: CommandCreatorSync> SccacheServer<C> {
|
|||
}
|
||||
}
|
||||
|
||||
type CompilerMap<C> =
|
||||
HashMap<PathBuf, Option<(Box<dyn Compiler<C>>, FileTime, Option<(PathBuf, FileTime)>)>>;
|
||||
|
||||
/// Service implementation for sccache
|
||||
#[derive(Clone)]
|
||||
struct SccacheService<C: CommandCreatorSync> {
|
||||
|
@ -605,11 +611,7 @@ struct SccacheService<C: CommandCreatorSync> {
|
|||
storage: Arc<dyn Storage>,
|
||||
|
||||
/// A cache of known compiler info.
|
||||
compilers: Rc<
|
||||
RefCell<
|
||||
HashMap<PathBuf, Option<(Box<dyn Compiler<C>>, FileTime, Option<(PathBuf, FileTime)>)>>,
|
||||
>,
|
||||
>,
|
||||
compilers: Rc<RefCell<CompilerMap<C>>>,
|
||||
|
||||
/// Thread pool to execute work in
|
||||
pool: CpuPool,
|
||||
|
@ -670,7 +672,7 @@ where
|
|||
}
|
||||
Request::GetStats => {
|
||||
debug!("handle_client: get_stats");
|
||||
Box::new(self.get_info().map(Response::Stats))
|
||||
Box::new(self.get_info().map(|i| Response::Stats(Box::new(i))))
|
||||
}
|
||||
Request::DistStatus => {
|
||||
debug!("handle_client: dist_status");
|
||||
|
@ -679,7 +681,7 @@ where
|
|||
Request::ZeroStats => {
|
||||
debug!("handle_client: zero_stats");
|
||||
self.zero_stats();
|
||||
Box::new(self.get_info().map(Response::Stats))
|
||||
Box::new(self.get_info().map(|i| Response::Stats(Box::new(i))))
|
||||
}
|
||||
Request::Shutdown => {
|
||||
debug!("handle_client: shutdown");
|
||||
|
@ -689,11 +691,9 @@ where
|
|||
.send(ServerMessage::Shutdown)
|
||||
.then(|_| Ok(()));
|
||||
let info_future = self.get_info();
|
||||
return Box::new(
|
||||
future
|
||||
.join(info_future)
|
||||
.map(move |(_, info)| Message::WithoutBody(Response::ShuttingDown(info))),
|
||||
);
|
||||
return Box::new(future.join(info_future).map(move |(_, info)| {
|
||||
Message::WithoutBody(Response::ShuttingDown(Box::new(info)))
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ where
|
|||
let cache_size = options
|
||||
.as_ref()
|
||||
.and_then(|o| o.cache_size.as_ref())
|
||||
.map(|s| *s)
|
||||
.copied()
|
||||
.unwrap_or(u64::MAX);
|
||||
// Create a server on a background thread, get some useful bits from it.
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
@ -186,7 +186,7 @@ fn test_server_unsupported_compiler() {
|
|||
let path = Some(f.paths);
|
||||
let mut runtime = Runtime::new().unwrap();
|
||||
let res = do_compile(
|
||||
client_creator.clone(),
|
||||
client_creator,
|
||||
&mut runtime,
|
||||
conn,
|
||||
exe,
|
||||
|
@ -211,17 +211,14 @@ fn test_server_unsupported_compiler() {
|
|||
|
||||
#[test]
|
||||
fn test_server_compile() {
|
||||
match env_logger::try_init() {
|
||||
Ok(_) => {}
|
||||
Err(_) => {}
|
||||
}
|
||||
let _ = env_logger::try_init();
|
||||
let f = TestFixture::new();
|
||||
let (port, sender, server_creator, child) = run_server_thread(&f.tempdir.path(), None);
|
||||
// Connect to the server.
|
||||
const PREPROCESSOR_STDOUT: &'static [u8] = b"preprocessor stdout";
|
||||
const PREPROCESSOR_STDERR: &'static [u8] = b"preprocessor stderr";
|
||||
const STDOUT: &'static [u8] = b"some stdout";
|
||||
const STDERR: &'static [u8] = b"some stderr";
|
||||
const PREPROCESSOR_STDOUT: &[u8] = b"preprocessor stdout";
|
||||
const PREPROCESSOR_STDERR: &[u8] = b"preprocessor stderr";
|
||||
const STDOUT: &[u8] = b"some stdout";
|
||||
const STDERR: &[u8] = b"some stderr";
|
||||
let conn = connect_to_server(port).unwrap();
|
||||
{
|
||||
let mut c = server_creator.lock().unwrap();
|
||||
|
@ -258,7 +255,7 @@ fn test_server_compile() {
|
|||
assert_eq!(
|
||||
0,
|
||||
do_compile(
|
||||
client_creator.clone(),
|
||||
client_creator,
|
||||
&mut runtime,
|
||||
conn,
|
||||
exe,
|
||||
|
|
|
@ -119,8 +119,8 @@ pub struct TestFixture {
|
|||
pub bins: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
pub const SUBDIRS: &'static [&'static str] = &["a", "b", "c"];
|
||||
pub const BIN_NAME: &'static str = "bin";
|
||||
pub const SUBDIRS: &[&str] = &["a", "b", "c"];
|
||||
pub const BIN_NAME: &str = "bin";
|
||||
|
||||
pub fn create_file<F>(dir: &Path, path: &str, fill_contents: F) -> io::Result<PathBuf>
|
||||
where
|
||||
|
@ -207,9 +207,9 @@ impl TestFixture {
|
|||
paths.push(p);
|
||||
}
|
||||
TestFixture {
|
||||
tempdir: tempdir,
|
||||
tempdir,
|
||||
paths: env::join_paths(paths).unwrap(),
|
||||
bins: bins,
|
||||
bins,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ const BUILD_DIR_CONTAINER_PATH: &str = "/sccache-bits/build-dir";
|
|||
const SCHEDULER_PORT: u16 = 10500;
|
||||
const SERVER_PORT: u16 = 12345; // arbitrary
|
||||
|
||||
const TC_CACHE_SIZE: u64 = 1 * 1024 * 1024 * 1024; // 1 gig
|
||||
const TC_CACHE_SIZE: u64 = 1024 * 1024 * 1024; // 1 gig
|
||||
|
||||
pub fn start_local_daemon(cfg_path: &Path, cached_cfg_path: &Path) {
|
||||
// Don't run this with run() because on Windows `wait_with_output`
|
||||
|
|
|
@ -177,11 +177,7 @@ impl SeleniumContainer {
|
|||
|
||||
impl Drop for SeleniumContainer {
|
||||
fn drop(&mut self) {
|
||||
let Output {
|
||||
status: _,
|
||||
stdout,
|
||||
stderr,
|
||||
} = Command::new("docker")
|
||||
let Output { stdout, stderr, .. } = Command::new("docker")
|
||||
.args(&["logs", &self.cid])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
|
|
@ -49,11 +49,11 @@ struct Compiler {
|
|||
|
||||
// Test GCC + clang on non-OS X platforms.
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
const COMPILERS: &'static [&'static str] = &["gcc", "clang"];
|
||||
const COMPILERS: &[&str] = &["gcc", "clang"];
|
||||
|
||||
// OS X ships a `gcc` that's just a clang wrapper, so only test clang there.
|
||||
#[cfg(target_os = "macos")]
|
||||
const COMPILERS: &'static [&'static str] = &["clang"];
|
||||
const COMPILERS: &[&str] = &["clang"];
|
||||
|
||||
//TODO: could test gcc when targeting mingw.
|
||||
|
||||
|
@ -78,16 +78,16 @@ fn compile_cmdline<T: AsRef<OsStr>>(
|
|||
}
|
||||
}
|
||||
|
||||
const INPUT: &'static str = "test.c";
|
||||
const INPUT_ERR: &'static str = "test_err.c";
|
||||
const INPUT_MACRO_EXPANSION: &'static str = "test_macro_expansion.c";
|
||||
const INPUT_WITH_DEFINE: &'static str = "test_with_define.c";
|
||||
const OUTPUT: &'static str = "test.o";
|
||||
const INPUT: &str = "test.c";
|
||||
const INPUT_ERR: &str = "test_err.c";
|
||||
const INPUT_MACRO_EXPANSION: &str = "test_macro_expansion.c";
|
||||
const INPUT_WITH_DEFINE: &str = "test_with_define.c";
|
||||
const OUTPUT: &str = "test.o";
|
||||
|
||||
// Copy the source files into the tempdir so we can compile with relative paths, since the commandline winds up in the hash key.
|
||||
fn copy_to_tempdir(inputs: &[&str], tempdir: &Path) {
|
||||
for f in inputs {
|
||||
let original_source_file = Path::new(file!()).parent().unwrap().join(f.clone());
|
||||
let original_source_file = Path::new(file!()).parent().unwrap().join(&*f);
|
||||
let source_file = tempdir.join(f);
|
||||
trace!("fs::copy({:?}, {:?})", original_source_file, source_file);
|
||||
fs::copy(&original_source_file, &source_file).unwrap();
|
||||
|
@ -131,7 +131,7 @@ fn test_basic_compile(compiler: Compiler, tempdir: &Path) {
|
|||
sccache_command()
|
||||
.args(&compile_cmdline(name, &exe, INPUT, OUTPUT))
|
||||
.current_dir(tempdir)
|
||||
.envs(env_vars.clone())
|
||||
.envs(env_vars)
|
||||
.assert()
|
||||
.success();
|
||||
assert_eq!(
|
||||
|
@ -167,7 +167,7 @@ fn test_noncacheable_stats(compiler: Compiler, tempdir: &Path) {
|
|||
.arg("-E")
|
||||
.arg(INPUT)
|
||||
.current_dir(tempdir)
|
||||
.envs(env_vars.clone())
|
||||
.envs(env_vars)
|
||||
.assert()
|
||||
.success();
|
||||
trace!("request stats");
|
||||
|
@ -192,7 +192,7 @@ fn test_msvc_deps(compiler: Compiler, tempdir: &Path) {
|
|||
sccache_command()
|
||||
.args(&args)
|
||||
.current_dir(tempdir)
|
||||
.envs(env_vars.clone())
|
||||
.envs(env_vars)
|
||||
.assert()
|
||||
.success();
|
||||
// Check the contents
|
||||
|
@ -226,7 +226,7 @@ fn test_gcc_mp_werror(compiler: Compiler, tempdir: &Path) {
|
|||
sccache_command()
|
||||
.args(&args)
|
||||
.current_dir(tempdir)
|
||||
.envs(env_vars.clone())
|
||||
.envs(env_vars)
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(
|
||||
|
@ -307,7 +307,7 @@ int main(int argc, char** argv) {
|
|||
sccache_command()
|
||||
.args(&args)
|
||||
.current_dir(tempdir)
|
||||
.envs(env_vars.clone())
|
||||
.envs(env_vars)
|
||||
.assert()
|
||||
.success();
|
||||
get_stats(|info| {
|
||||
|
@ -338,7 +338,7 @@ fn test_gcc_clang_no_warnings_from_macro_expansion(compiler: Compiler, tempdir:
|
|||
.concat(),
|
||||
)
|
||||
.current_dir(tempdir)
|
||||
.envs(env_vars.clone())
|
||||
.envs(env_vars)
|
||||
.assert()
|
||||
.success()
|
||||
.stderr(predicates::str::contains("warning:").from_utf8().not());
|
||||
|
@ -364,7 +364,7 @@ fn test_compile_with_define(compiler: Compiler, tempdir: &Path) {
|
|||
.concat(),
|
||||
)
|
||||
.current_dir(tempdir)
|
||||
.envs(env_vars.clone())
|
||||
.envs(env_vars)
|
||||
.assert()
|
||||
.success()
|
||||
.stderr(predicates::str::contains("warning:").from_utf8().not());
|
||||
|
@ -381,7 +381,7 @@ fn run_sccache_command_tests(compiler: Compiler, tempdir: &Path) {
|
|||
test_gcc_fprofile_generate_source_changes(compiler.clone(), tempdir);
|
||||
}
|
||||
if compiler.name == "clang" || compiler.name == "gcc" {
|
||||
test_gcc_clang_no_warnings_from_macro_expansion(compiler.clone(), tempdir);
|
||||
test_gcc_clang_no_warnings_from_macro_expansion(compiler, tempdir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,10 +426,7 @@ fn find_compilers() -> Vec<Compiler> {
|
|||
#[test]
|
||||
#[cfg(any(unix, target_env = "msvc"))]
|
||||
fn test_sccache_command() {
|
||||
match env_logger::try_init() {
|
||||
Ok(_) => {}
|
||||
Err(_) => {}
|
||||
}
|
||||
let _ = env_logger::try_init();
|
||||
let tempdir = tempfile::Builder::new()
|
||||
.prefix("sccache_system_test")
|
||||
.tempdir()
|
||||
|
|
Загрузка…
Ссылка в новой задаче