Support custom Cargo profiles in xtask bundle
This commit is contained in:
parent
f3ead4caca
commit
3650311db8
|
@ -156,12 +156,16 @@ pub fn build(packages: &[String], args: &[String]) -> Result<()> {
|
||||||
/// the binary target has a different name) then this will also be copied into the `bundled`
|
/// the binary target has a different name) then this will also be copied into the `bundled`
|
||||||
/// directory.
|
/// directory.
|
||||||
pub fn bundle(package: &str, args: &[String]) -> Result<()> {
|
pub fn bundle(package: &str, args: &[String]) -> Result<()> {
|
||||||
let mut is_release_build = false;
|
let mut build_type_dir = "debug";
|
||||||
let mut cross_compile_target: Option<String> = None;
|
let mut cross_compile_target: Option<String> = None;
|
||||||
for arg_idx in (0..args.len()).rev() {
|
for arg_idx in (0..args.len()).rev() {
|
||||||
let arg = &args[arg_idx];
|
let arg = &args[arg_idx];
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--release" => is_release_build = true,
|
"--profile" => {
|
||||||
|
// Since Rust 1.57 you can have custom profiles
|
||||||
|
build_type_dir = args.get(arg_idx + 1).context("Missing profile name")?;
|
||||||
|
}
|
||||||
|
"--release" => build_type_dir = "release",
|
||||||
"--target" => {
|
"--target" => {
|
||||||
// When cross compiling we should generate the correct bundle type
|
// When cross compiling we should generate the correct bundle type
|
||||||
cross_compile_target = Some(
|
cross_compile_target = Some(
|
||||||
|
@ -170,6 +174,11 @@ pub fn bundle(package: &str, args: &[String]) -> Result<()> {
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
arg if arg.starts_with("--profile=") => {
|
||||||
|
build_type_dir = arg
|
||||||
|
.strip_prefix("--profile=")
|
||||||
|
.context("Missing profile name")?;
|
||||||
|
}
|
||||||
arg if arg.starts_with("--target=") => {
|
arg if arg.starts_with("--target=") => {
|
||||||
cross_compile_target = Some(
|
cross_compile_target = Some(
|
||||||
arg.strip_prefix("--target=")
|
arg.strip_prefix("--target=")
|
||||||
|
@ -184,11 +193,7 @@ pub fn bundle(package: &str, args: &[String]) -> Result<()> {
|
||||||
// We can bundle both library targets (for plugins) and binary targets (for standalone
|
// We can bundle both library targets (for plugins) and binary targets (for standalone
|
||||||
// applications)
|
// applications)
|
||||||
let compilation_target = compilation_target(cross_compile_target.as_deref())?;
|
let compilation_target = compilation_target(cross_compile_target.as_deref())?;
|
||||||
let target_base = target_base(cross_compile_target.as_deref())?.join(if is_release_build {
|
let target_base = target_base(cross_compile_target.as_deref())?.join(build_type_dir);
|
||||||
"release"
|
|
||||||
} else {
|
|
||||||
"debug"
|
|
||||||
});
|
|
||||||
let bin_path = target_base.join(binary_basename(package, compilation_target));
|
let bin_path = target_base.join(binary_basename(package, compilation_target));
|
||||||
let lib_path = target_base.join(library_basename(package, compilation_target));
|
let lib_path = target_base.join(library_basename(package, compilation_target));
|
||||||
if !bin_path.exists() && !lib_path.exists() {
|
if !bin_path.exists() && !lib_path.exists() {
|
||||||
|
|
Loading…
Reference in a new issue