Skip to content

Commit ce617d5

Browse files
committed
config: Allow passing arbitrary arguments
to container runtimes using a new configuration key under `build.env`. This gives users the flexibility to work around issues such as #1012 without having to wait for a new release or creating their own forks of `cross`.
1 parent 37c681a commit ce617d5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ impl Environment {
101101
get_possible_image(self, "IMAGE", "IMAGE_TOOLCHAIN", get_target, get_target)
102102
}
103103

104+
fn extra_args(&self, target: &Target) -> (Option<Vec<String>>, Option<Vec<String>>) {
105+
self.get_values_for("EXTRA_ARGS", target, split_to_cloned_by_ws)
106+
}
107+
104108
fn dockerfile(&self, target: &Target) -> (Option<String>, Option<String>) {
105109
self.get_values_for("DOCKERFILE", target, ToOwned::to_owned)
106110
}
@@ -409,6 +413,10 @@ impl Config {
409413
)
410414
}
411415

416+
pub fn extra_args(&self, target: &Target) -> Result<Option<Vec<String>>> {
417+
self.get_from_ref(target, Environment::extra_args, CrossToml::extra_args)
418+
}
419+
412420
pub fn env_volumes(&self, target: &Target) -> Result<Option<Vec<String>>> {
413421
self.get_from_ref(target, Environment::volumes, CrossToml::env_volumes)
414422
}

src/cross_toml.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use std::str::FromStr;
1515
pub struct CrossEnvConfig {
1616
volumes: Option<Vec<String>>,
1717
passthrough: Option<Vec<String>>,
18+
/// Additional arguments to the underlying container engine
19+
extra_args: Option<Vec<String>>,
1820
}
1921

2022
/// Build configuration
@@ -362,6 +364,14 @@ impl CrossToml {
362364
)
363365
}
364366

367+
pub fn extra_args(&self, target: &Target) -> (Option<&[String]>, Option<&[String]>) {
368+
self.get_ref(
369+
target,
370+
|build| build.env.extra_args.as_deref(),
371+
|t| t.env.extra_args.as_deref(),
372+
)
373+
}
374+
365375
/// Returns the default target to build,
366376
pub fn default_target(&self, target_list: &TargetList) -> Option<Target> {
367377
self.build

0 commit comments

Comments
 (0)