feat: add features flag
This commit is contained in:
1 parent
6aa609144d
commit
d20e7ab508
3 files changed
+28
-1
No files matched your search
@@ -55,6 +55,12 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||||||
cmd.arg(custom_profile);
|
cmd.arg(custom_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.features.is_some() {
|
||||||
|
let features_str = config.features.as_ref().unwrap().join(" ");
|
||||||
|
cmd.arg("--features");
|
||||||
|
cmd.arg(features_str);
|
||||||
|
}
|
||||||
|
|
||||||
match executable {
|
match executable {
|
||||||
ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
|
ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
|
||||||
ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
|
ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
|
||||||
@@ -201,6 +207,12 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> {
|
|||||||
cmd.arg(custom_profile);
|
cmd.arg(custom_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.features.is_some() {
|
||||||
|
let features_str = config.features.as_ref().unwrap().join(" ");
|
||||||
|
cmd.arg("--features");
|
||||||
|
cmd.arg(features_str);
|
||||||
|
}
|
||||||
|
|
||||||
match &config.executable {
|
match &config.executable {
|
||||||
crate::ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
|
crate::ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
|
||||||
crate::ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
|
crate::ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ pub struct ConfigOptsBuild {
|
|||||||
/// Build platform: support Web & Desktop [default: "default_platform"]
|
/// Build platform: support Web & Desktop [default: "default_platform"]
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub platform: Option<String>,
|
pub platform: Option<String>,
|
||||||
|
|
||||||
|
/// Space separated list of features to activate
|
||||||
|
#[clap(long)]
|
||||||
|
pub features: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Parser)]
|
#[derive(Clone, Debug, Default, Deserialize, Parser)]
|
||||||
@@ -47,6 +51,10 @@ pub struct ConfigOptsServe {
|
|||||||
/// Build platform: support Web & Desktop [default: "default_platform"]
|
/// Build platform: support Web & Desktop [default: "default_platform"]
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub platform: Option<String>,
|
pub platform: Option<String>,
|
||||||
|
|
||||||
|
/// Space separated list of features to activate
|
||||||
|
#[clap(long)]
|
||||||
|
pub features: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensure the given value for `--public-url` is formatted correctly.
|
/// Ensure the given value for `--public-url` is formatted correctly.
|
||||||
|
|||||||
+8
-1
@@ -115,6 +115,7 @@ pub struct CrateConfig {
|
|||||||
pub dioxus_config: DioxusConfig,
|
pub dioxus_config: DioxusConfig,
|
||||||
pub release: bool,
|
pub release: bool,
|
||||||
pub custom_profile: Option<String>,
|
pub custom_profile: Option<String>,
|
||||||
|
pub features: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -163,8 +164,8 @@ impl CrateConfig {
|
|||||||
let executable = ExecutableType::Binary(output_filename);
|
let executable = ExecutableType::Binary(output_filename);
|
||||||
|
|
||||||
let release = false;
|
let release = false;
|
||||||
|
|
||||||
let custom_profile = None;
|
let custom_profile = None;
|
||||||
|
let features = None;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
out_dir,
|
out_dir,
|
||||||
@@ -177,6 +178,7 @@ impl CrateConfig {
|
|||||||
release,
|
release,
|
||||||
dioxus_config,
|
dioxus_config,
|
||||||
custom_profile,
|
custom_profile,
|
||||||
|
features
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +197,11 @@ impl CrateConfig {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_features(&mut self, features: Vec<String>) -> &mut Self {
|
||||||
|
self.features = Some(features);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
// pub fn with_build_options(&mut self, options: &BuildOptions) {
|
// pub fn with_build_options(&mut self, options: &BuildOptions) {
|
||||||
// if let Some(name) = &options.example {
|
// if let Some(name) = &options.example {
|
||||||
// self.as_example(name.clone());
|
// self.as_example(name.clone());
|
||||||
|
|||||||
Reference in new issue
Block a user