Move targets, hosts, and build triple into Build.
This commit is contained in:
parent
39cf1da81c
commit
5809a7d0b7
3 changed files with 44 additions and 27 deletions
|
@ -170,6 +170,11 @@ pub struct Build {
|
||||||
fail_fast: bool,
|
fail_fast: bool,
|
||||||
verbosity: usize,
|
verbosity: usize,
|
||||||
|
|
||||||
|
// Targets for which to build.
|
||||||
|
build: String,
|
||||||
|
hosts: Vec<String>,
|
||||||
|
targets: Vec<String>,
|
||||||
|
|
||||||
// Stage 0 (downloaded) compiler and cargo or their local rust equivalents.
|
// Stage 0 (downloaded) compiler and cargo or their local rust equivalents.
|
||||||
initial_rustc: PathBuf,
|
initial_rustc: PathBuf,
|
||||||
initial_cargo: PathBuf,
|
initial_cargo: PathBuf,
|
||||||
|
@ -243,6 +248,27 @@ impl Build {
|
||||||
let cargo_info = channel::GitInfo::new(&src.join("src/tools/cargo"));
|
let cargo_info = channel::GitInfo::new(&src.join("src/tools/cargo"));
|
||||||
let rls_info = channel::GitInfo::new(&src.join("src/tools/rls"));
|
let rls_info = channel::GitInfo::new(&src.join("src/tools/rls"));
|
||||||
|
|
||||||
|
let hosts = if !flags.host.is_empty() {
|
||||||
|
for host in flags.host.iter() {
|
||||||
|
if !config.host.contains(host) {
|
||||||
|
panic!("specified host `{}` is not in configuration", host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flags.host.clone()
|
||||||
|
} else {
|
||||||
|
config.host.clone()
|
||||||
|
};
|
||||||
|
let targets = if !flags.target.is_empty() {
|
||||||
|
for target in flags.target.iter() {
|
||||||
|
if !config.target.contains(target) {
|
||||||
|
panic!("specified target `{}` is not in configuration", target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flags.target.clone()
|
||||||
|
} else {
|
||||||
|
config.target.clone()
|
||||||
|
};
|
||||||
|
|
||||||
Build {
|
Build {
|
||||||
initial_rustc: config.initial_rustc.clone(),
|
initial_rustc: config.initial_rustc.clone(),
|
||||||
initial_cargo: config.initial_cargo.clone(),
|
initial_cargo: config.initial_cargo.clone(),
|
||||||
|
@ -250,6 +276,10 @@ impl Build {
|
||||||
fail_fast: flags.cmd.fail_fast(),
|
fail_fast: flags.cmd.fail_fast(),
|
||||||
verbosity: cmp::max(flags.verbose, config.verbose),
|
verbosity: cmp::max(flags.verbose, config.verbose),
|
||||||
|
|
||||||
|
build: config.host[0].clone(),
|
||||||
|
hosts: hosts,
|
||||||
|
targets: targets,
|
||||||
|
|
||||||
flags: flags,
|
flags: flags,
|
||||||
config: config,
|
config: config,
|
||||||
src: src,
|
src: src,
|
||||||
|
@ -269,6 +299,12 @@ impl Build {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_slice(&self) -> &[String] {
|
||||||
|
unsafe {
|
||||||
|
std::slice::from_raw_parts(&self.build, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Executes the entire build, as configured by the flags and configuration.
|
/// Executes the entire build, as configured by the flags and configuration.
|
||||||
pub fn build(&mut self) {
|
pub fn build(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -798,7 +834,7 @@ impl Build {
|
||||||
/// Returns the number of parallel jobs that have been configured for this
|
/// Returns the number of parallel jobs that have been configured for this
|
||||||
/// build.
|
/// build.
|
||||||
fn jobs(&self) -> u32 {
|
fn jobs(&self) -> u32 {
|
||||||
self.flags.jobs.unwrap_or(num_cpus::get() as u32)
|
self.flags.jobs.unwrap_or_else(|| num_cpus::get() as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the path to the C compiler for the target specified.
|
/// Returns the path to the C compiler for the target specified.
|
||||||
|
|
|
@ -194,17 +194,6 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for host in build.flags.host.iter() {
|
|
||||||
if !build.config.host.contains(host) {
|
|
||||||
panic!("specified host `{}` is not in configuration", host);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for target in build.flags.target.iter() {
|
|
||||||
if !build.config.target.contains(target) {
|
|
||||||
panic!("specified target `{}` is not in configuration", target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let run = |cmd: &mut Command| {
|
let run = |cmd: &mut Command| {
|
||||||
cmd.output().map(|output| {
|
cmd.output().map(|output| {
|
||||||
String::from_utf8_lossy(&output.stdout)
|
String::from_utf8_lossy(&output.stdout)
|
||||||
|
|
|
@ -1218,16 +1218,9 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
|
||||||
|
|
||||||
rules.into_iter().flat_map(|(rule, _)| {
|
rules.into_iter().flat_map(|(rule, _)| {
|
||||||
let hosts = if rule.only_host_build || rule.only_build {
|
let hosts = if rule.only_host_build || rule.only_build {
|
||||||
&self.build.config.host[..1]
|
self.build.build_slice()
|
||||||
} else if self.build.flags.host.len() > 0 {
|
|
||||||
&self.build.flags.host
|
|
||||||
} else {
|
} else {
|
||||||
&self.build.config.host
|
&self.build.hosts
|
||||||
};
|
|
||||||
let targets = if self.build.flags.target.len() > 0 {
|
|
||||||
&self.build.flags.target
|
|
||||||
} else {
|
|
||||||
&self.build.config.target
|
|
||||||
};
|
};
|
||||||
// Determine the actual targets participating in this rule.
|
// Determine the actual targets participating in this rule.
|
||||||
// NOTE: We should keep the full projection from build triple to
|
// NOTE: We should keep the full projection from build triple to
|
||||||
|
@ -1236,19 +1229,18 @@ invalid rule dependency graph detected, was a rule added and maybe typo'd?
|
||||||
// the original non-shadowed hosts array is used below.
|
// the original non-shadowed hosts array is used below.
|
||||||
let arr = if rule.host {
|
let arr = if rule.host {
|
||||||
// If --target was specified but --host wasn't specified,
|
// If --target was specified but --host wasn't specified,
|
||||||
// don't run any host-only tests. Also, respect any `--host`
|
// don't run any host-only tests.
|
||||||
// overrides as done for `hosts`.
|
|
||||||
if self.build.flags.host.len() > 0 {
|
if self.build.flags.host.len() > 0 {
|
||||||
&self.build.flags.host[..]
|
&self.build.hosts
|
||||||
} else if self.build.flags.target.len() > 0 {
|
} else if self.build.flags.target.len() > 0 {
|
||||||
&[]
|
&[]
|
||||||
} else if rule.only_build {
|
} else if rule.only_build {
|
||||||
&self.build.config.host[..1]
|
self.build.build_slice()
|
||||||
} else {
|
} else {
|
||||||
&self.build.config.host[..]
|
&self.build.hosts
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
targets
|
&self.build.targets
|
||||||
};
|
};
|
||||||
|
|
||||||
hosts.iter().flat_map(move |host| {
|
hosts.iter().flat_map(move |host| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue