Struct xtask_wasm::Dist
source · #[non_exhaustive]pub struct Dist {Show 20 fields
pub quiet: bool,
pub jobs: Option<String>,
pub profile: Option<String>,
pub release: bool,
pub features: Vec<String>,
pub all_features: bool,
pub no_default_features: bool,
pub verbose: bool,
pub color: Option<String>,
pub frozen: bool,
pub locked: bool,
pub offline: bool,
pub ignore_rust_version: bool,
pub example: Option<String>,
pub build_command: Command,
pub dist_dir_path: Option<PathBuf>,
pub static_dir_path: Option<PathBuf>,
pub app_name: Option<String>,
pub run_in_workspace: bool,
pub sass_options: Options,
}
Expand description
A helper to generate the distributed package.
§Usage
use std::process;
use xtask_wasm::{anyhow::Result, clap};
#[derive(clap::Parser)]
enum Opt {
Dist(xtask_wasm::Dist),
}
fn main() -> Result<()> {
let opt: Opt = clap::Parser::parse();
match opt {
Opt::Dist(dist) => {
log::info!("Generating package...");
dist
.static_dir_path("my-project/static")
.app_name("my-project")
.run_in_workspace(true)
.run("my-project")?;
}
}
Ok(())
}
In this example, we added a dist
subcommand to build and package the
my-project
crate. It will run the default_build_command
at the workspace root, copy the content of the project/static
directory,
generate JS bindings and output two files: project.js
and project.wasm
into the dist directory.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.quiet: bool
No output printed to stdout.
jobs: Option<String>
Number of parallel jobs, defaults to # of CPUs.
profile: Option<String>
Build artifacts with the specified profile.
release: bool
Build artifacts in release mode, with optimizations.
features: Vec<String>
Space or comma separated list of features to activate.
all_features: bool
Activate all available features.
no_default_features: bool
Do not activate the default
features.
verbose: bool
Use verbose output
color: Option<String>
Coloring: auto, always, never.
frozen: bool
Require Cargo.lock and cache are up to date.
locked: bool
Require Cargo.lock is up to date.
offline: bool
Run without accessing the network.
ignore_rust_version: bool
Ignore rust-version
specification in packages.
example: Option<String>
Name of the example target to run.
build_command: Command
Command passed to the build process.
dist_dir_path: Option<PathBuf>
Directory of all generated artifacts.
static_dir_path: Option<PathBuf>
Directory of all static artifacts.
app_name: Option<String>
Set the resulting app name, default to app
.
run_in_workspace: bool
Set the command’s current directory as the workspace root.
sass_options: Options
Output style for SASS/SCSS
Implementations§
source§impl Dist
impl Dist
sourcepub fn build_command(self, command: Command) -> Self
pub fn build_command(self, command: Command) -> Self
Set the command used by the build process.
The default command is the result of the default_build_command
.
sourcepub fn dist_dir_path(self, path: impl Into<PathBuf>) -> Self
pub fn dist_dir_path(self, path: impl Into<PathBuf>) -> Self
Set the directory for the generated artifacts.
The default for debug build is target/debug/dist
and
target/release/dist
for the release build.
sourcepub fn static_dir_path(self, path: impl Into<PathBuf>) -> Self
pub fn static_dir_path(self, path: impl Into<PathBuf>) -> Self
Set the directory for the static artifacts (like index.html
).
sourcepub fn app_name(self, app_name: impl Into<String>) -> Self
pub fn app_name(self, app_name: impl Into<String>) -> Self
Set the resulting package name.
The default is app
.
sourcepub fn run_in_workspace(self, res: bool) -> Self
pub fn run_in_workspace(self, res: bool) -> Self
Set the dist process current directory as the workspace root.
sourcepub fn sass_options(self, output_style: Options) -> Self
pub fn sass_options(self, output_style: Options) -> Self
Set the output style for SCSS/SASS
sourcepub fn run(self, package_name: &str) -> Result<PathBuf>
pub fn run(self, package_name: &str) -> Result<PathBuf>
Build the given package for Wasm.
This will generate JS bindings via wasm-bindgen
and copy files from a given static directory if any to finally return
the path of the generated artifacts.
Wasm optimizations can be achieved using crate::WasmOpt
if the
feature wasm-opt
is enabled.
Trait Implementations§
source§impl Args for Dist
impl Args for Dist
source§fn group_id() -> Option<Id>
fn group_id() -> Option<Id>
ArgGroup::id
][crate::ArgGroup::id] for this set of argumentssource§fn augment_args<'b>(__clap_app: Command) -> Command
fn augment_args<'b>(__clap_app: Command) -> Command
source§fn augment_args_for_update<'b>(__clap_app: Command) -> Command
fn augment_args_for_update<'b>(__clap_app: Command) -> Command
source§impl FromArgMatches for Dist
impl FromArgMatches for Dist
source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches
) -> Result<Self, Error>
fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches ) -> Result<Self, Error>
source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches
) -> Result<(), Error>
fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches ) -> Result<(), Error>
ArgMatches
to self
.source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches
) -> Result<(), Error>
fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches ) -> Result<(), Error>
ArgMatches
to self
.