mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 14:18:27 +00:00
commit
79044f7503
5 changed files with 90 additions and 0 deletions
|
@ -48,6 +48,21 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
||||||
if config.release {
|
if config.release {
|
||||||
cmd.arg("--release");
|
cmd.arg("--release");
|
||||||
}
|
}
|
||||||
|
if config.verbose {
|
||||||
|
cmd.arg("--verbose");
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.custom_profile.is_some() {
|
||||||
|
let custom_profile = config.custom_profile.as_ref().unwrap();
|
||||||
|
cmd.arg("--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),
|
||||||
|
@ -188,6 +203,21 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> {
|
||||||
if config.release {
|
if config.release {
|
||||||
cmd.arg("--release");
|
cmd.arg("--release");
|
||||||
}
|
}
|
||||||
|
if config.verbose {
|
||||||
|
cmd.arg("--verbose");
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.custom_profile.is_some() {
|
||||||
|
let custom_profile = config.custom_profile.as_ref().unwrap();
|
||||||
|
cmd.arg("--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),
|
||||||
|
|
|
@ -14,11 +14,16 @@ impl Build {
|
||||||
|
|
||||||
// change the release state.
|
// change the release state.
|
||||||
crate_config.with_release(self.build.release);
|
crate_config.with_release(self.build.release);
|
||||||
|
crate_config.with_verbose(self.build.verbose);
|
||||||
|
|
||||||
if self.build.example.is_some() {
|
if self.build.example.is_some() {
|
||||||
crate_config.as_example(self.build.example.unwrap());
|
crate_config.as_example(self.build.example.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.build.profile.is_some() {
|
||||||
|
crate_config.set_profile(self.build.profile.unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
let platform = self.build.platform.unwrap_or_else(|| {
|
let platform = self.build.platform.unwrap_or_else(|| {
|
||||||
crate_config
|
crate_config
|
||||||
.dioxus_config
|
.dioxus_config
|
||||||
|
|
|
@ -12,13 +12,26 @@ pub struct ConfigOptsBuild {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub release: bool,
|
pub release: bool,
|
||||||
|
|
||||||
|
// Use verbose output [default: false]
|
||||||
|
#[clap(long)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub verbose: bool,
|
||||||
|
|
||||||
/// Build a example [default: ""]
|
/// Build a example [default: ""]
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub example: Option<String>,
|
pub example: Option<String>,
|
||||||
|
|
||||||
|
/// Build with custom profile
|
||||||
|
#[clap(long)]
|
||||||
|
pub profile: Option<String>,
|
||||||
|
|
||||||
/// 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)]
|
||||||
|
@ -36,9 +49,22 @@ pub struct ConfigOptsServe {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub release: bool,
|
pub release: bool,
|
||||||
|
|
||||||
|
// Use verbose output [default: false]
|
||||||
|
#[clap(long)]
|
||||||
|
#[serde(default)]
|
||||||
|
pub verbose: bool,
|
||||||
|
|
||||||
|
/// Build with custom profile
|
||||||
|
#[clap(long)]
|
||||||
|
pub profile: Option<String>,
|
||||||
|
|
||||||
/// 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.
|
||||||
|
|
|
@ -19,11 +19,16 @@ impl Serve {
|
||||||
|
|
||||||
// change the relase state.
|
// change the relase state.
|
||||||
crate_config.with_release(self.serve.release);
|
crate_config.with_release(self.serve.release);
|
||||||
|
crate_config.with_verbose(self.serve.verbose);
|
||||||
|
|
||||||
if self.serve.example.is_some() {
|
if self.serve.example.is_some() {
|
||||||
crate_config.as_example(self.serve.example.unwrap());
|
crate_config.as_example(self.serve.example.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.serve.profile.is_some() {
|
||||||
|
crate_config.set_profile(self.serve.profile.unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
let platform = self.serve.platform.unwrap_or_else(|| {
|
let platform = self.serve.platform.unwrap_or_else(|| {
|
||||||
crate_config
|
crate_config
|
||||||
.dioxus_config
|
.dioxus_config
|
||||||
|
|
|
@ -114,6 +114,9 @@ pub struct CrateConfig {
|
||||||
pub executable: ExecutableType,
|
pub executable: ExecutableType,
|
||||||
pub dioxus_config: DioxusConfig,
|
pub dioxus_config: DioxusConfig,
|
||||||
pub release: bool,
|
pub release: bool,
|
||||||
|
pub verbose: bool,
|
||||||
|
pub custom_profile: Option<String>,
|
||||||
|
pub features: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -162,6 +165,9 @@ impl CrateConfig {
|
||||||
let executable = ExecutableType::Binary(output_filename);
|
let executable = ExecutableType::Binary(output_filename);
|
||||||
|
|
||||||
let release = false;
|
let release = false;
|
||||||
|
let verbose = false;
|
||||||
|
let custom_profile = None;
|
||||||
|
let features = None;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
out_dir,
|
out_dir,
|
||||||
|
@ -173,6 +179,9 @@ impl CrateConfig {
|
||||||
executable,
|
executable,
|
||||||
release,
|
release,
|
||||||
dioxus_config,
|
dioxus_config,
|
||||||
|
custom_profile,
|
||||||
|
features,
|
||||||
|
verbose,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +195,21 @@ impl CrateConfig {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_verbose(&mut self, verbose: bool) -> &mut Self {
|
||||||
|
self.verbose = verbose;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_profile(&mut self, profile: String) -> &mut Self {
|
||||||
|
self.custom_profile = Some(profile);
|
||||||
|
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());
|
||||||
|
|
Loading…
Add table
Reference in a new issue