Merge pull request #2057 from ealmloff/fix-examples-assets
Fix Manganis assets overlapping between examples
This commit is contained in:
8 files changed
+96
-109
No files matched your search
Generated
+30
-23
@@ -2201,7 +2201,7 @@ version = "0.5.0-alpha.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"criterion 0.3.6",
|
"criterion 0.3.6",
|
||||||
"dioxus-config-macro",
|
"dioxus-config-macro",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-core-macro",
|
"dioxus-core-macro",
|
||||||
"dioxus-desktop",
|
"dioxus-desktop",
|
||||||
"dioxus-fullstack",
|
"dioxus-fullstack",
|
||||||
@@ -2268,7 +2268,7 @@ dependencies = [
|
|||||||
"dioxus-autofmt",
|
"dioxus-autofmt",
|
||||||
"dioxus-check",
|
"dioxus-check",
|
||||||
"dioxus-cli-config",
|
"dioxus-cli-config",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-hot-reload",
|
"dioxus-hot-reload",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
"dioxus-rsx",
|
"dioxus-rsx",
|
||||||
@@ -2356,6 +2356,20 @@ dependencies = [
|
|||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dioxus-core"
|
||||||
|
version = "0.5.0-alpha.0"
|
||||||
|
source = "git+https://github.com/DioxusLabs/dioxus#44d09fcd2de4af32c8a3a107cabdd3e6860baeeb"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-util",
|
||||||
|
"longest-increasing-subsequence",
|
||||||
|
"rustc-hash",
|
||||||
|
"slab",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dioxus-core-macro"
|
name = "dioxus-core-macro"
|
||||||
version = "0.5.0-alpha.0"
|
version = "0.5.0-alpha.0"
|
||||||
@@ -2386,7 +2400,7 @@ dependencies = [
|
|||||||
"core-foundation",
|
"core-foundation",
|
||||||
"dioxus",
|
"dioxus",
|
||||||
"dioxus-cli-config",
|
"dioxus-cli-config",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-hooks",
|
"dioxus-hooks",
|
||||||
"dioxus-hot-reload",
|
"dioxus-hot-reload",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
@@ -2487,7 +2501,7 @@ name = "dioxus-hooks"
|
|||||||
version = "0.5.0-alpha.0"
|
version = "0.5.0-alpha.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dioxus",
|
"dioxus",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-debug-cell",
|
"dioxus-debug-cell",
|
||||||
"dioxus-signals",
|
"dioxus-signals",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
@@ -2505,7 +2519,7 @@ name = "dioxus-hot-reload"
|
|||||||
version = "0.5.0-alpha.0"
|
version = "0.5.0-alpha.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
"dioxus-rsx",
|
"dioxus-rsx",
|
||||||
"execute",
|
"execute",
|
||||||
@@ -2522,7 +2536,7 @@ name = "dioxus-html"
|
|||||||
version = "0.5.0-alpha.0"
|
version = "0.5.0-alpha.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-html-internal-macro",
|
"dioxus-html-internal-macro",
|
||||||
"dioxus-rsx",
|
"dioxus-rsx",
|
||||||
"enumset",
|
"enumset",
|
||||||
@@ -2555,7 +2569,7 @@ dependencies = [
|
|||||||
name = "dioxus-interpreter-js"
|
name = "dioxus-interpreter-js"
|
||||||
version = "0.5.0-alpha.0"
|
version = "0.5.0-alpha.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"md5",
|
"md5",
|
||||||
@@ -2571,7 +2585,7 @@ name = "dioxus-lib"
|
|||||||
version = "0.5.0-alpha.0"
|
version = "0.5.0-alpha.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dioxus-config-macro",
|
"dioxus-config-macro",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-core-macro",
|
"dioxus-core-macro",
|
||||||
"dioxus-hooks",
|
"dioxus-hooks",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
@@ -2586,7 +2600,7 @@ dependencies = [
|
|||||||
"axum",
|
"axum",
|
||||||
"dioxus",
|
"dioxus",
|
||||||
"dioxus-cli-config",
|
"dioxus-cli-config",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-hot-reload",
|
"dioxus-hot-reload",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
"dioxus-interpreter-js",
|
"dioxus-interpreter-js",
|
||||||
@@ -2620,7 +2634,7 @@ dependencies = [
|
|||||||
"anymap 1.0.0-beta.2",
|
"anymap 1.0.0-beta.2",
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"dioxus",
|
"dioxus",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-native-core",
|
"dioxus-native-core",
|
||||||
"dioxus-native-core-macro",
|
"dioxus-native-core-macro",
|
||||||
"keyboard-types",
|
"keyboard-types",
|
||||||
@@ -2729,7 +2743,7 @@ dependencies = [
|
|||||||
name = "dioxus-rsx"
|
name = "dioxus-rsx"
|
||||||
version = "0.5.0-alpha.0"
|
version = "0.5.0-alpha.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"internment",
|
"internment",
|
||||||
"krates",
|
"krates",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2744,7 +2758,7 @@ name = "dioxus-signals"
|
|||||||
version = "0.5.0-alpha.0"
|
version = "0.5.0-alpha.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dioxus",
|
"dioxus",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"generational-box",
|
"generational-box",
|
||||||
@@ -2768,7 +2782,7 @@ dependencies = [
|
|||||||
"async-trait",
|
"async-trait",
|
||||||
"chrono",
|
"chrono",
|
||||||
"dioxus",
|
"dioxus",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
"dioxus-signals",
|
"dioxus-signals",
|
||||||
"fern",
|
"fern",
|
||||||
@@ -2799,7 +2813,7 @@ dependencies = [
|
|||||||
"criterion 0.3.6",
|
"criterion 0.3.6",
|
||||||
"crossterm 0.26.1",
|
"crossterm 0.26.1",
|
||||||
"dioxus",
|
"dioxus",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-hot-reload",
|
"dioxus-hot-reload",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
"dioxus-native-core",
|
"dioxus-native-core",
|
||||||
@@ -2817,7 +2831,7 @@ dependencies = [
|
|||||||
"async-trait",
|
"async-trait",
|
||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
"dioxus",
|
"dioxus",
|
||||||
"dioxus-core",
|
"dioxus-core 0.5.0-alpha.0",
|
||||||
"dioxus-html",
|
"dioxus-html",
|
||||||
"dioxus-interpreter-js",
|
"dioxus-interpreter-js",
|
||||||
"dioxus-ssr",
|
"dioxus-ssr",
|
||||||
@@ -5701,17 +5715,14 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "manganis"
|
name = "manganis"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d11b87b5222a0eb4c7b1e7a49cc78922aa82a7fa5aa614e07ace55ed74fcdf67"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"dioxus-core 0.5.0-alpha.0 (git+https://github.com/DioxusLabs/dioxus)",
|
||||||
"manganis-macro",
|
"manganis-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "manganis-cli-support"
|
name = "manganis-cli-support"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d9c40a20048742dfbb793fb93498640e128543bcf92588b4c3b25451957522d"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cargo-lock 9.0.0",
|
"cargo-lock 9.0.0",
|
||||||
@@ -5737,8 +5748,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "manganis-common"
|
name = "manganis-common"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "84166560d60366c4b4fe12e204f2fca78fe594382e13c02d75fab6e0d8f40184"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64",
|
"base64",
|
||||||
@@ -5753,8 +5762,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "manganis-macro"
|
name = "manganis-macro"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8b78150e016312c51841521a9dc7fb5ae994c163a325eb4c2aa0186efce9532e"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"manganis-common",
|
"manganis-common",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
|||||||
+2
-2
@@ -100,11 +100,11 @@ thiserror = "1.0.40"
|
|||||||
prettyplease = { package = "prettier-please", version = "0.2", features = [
|
prettyplease = { package = "prettier-please", version = "0.2", features = [
|
||||||
"verbatim",
|
"verbatim",
|
||||||
] }
|
] }
|
||||||
manganis-cli-support = { version = "0.1.0", features = [
|
manganis-cli-support = { version = "0.2.0", features = [
|
||||||
"webp",
|
"webp",
|
||||||
"html",
|
"html",
|
||||||
] }
|
] }
|
||||||
manganis = { version = "0.1.0" }
|
manganis = { version = "0.2.0" }
|
||||||
|
|
||||||
lru = "0.12.2"
|
lru = "0.12.2"
|
||||||
async-trait = "0.1.77"
|
async-trait = "0.1.77"
|
||||||
|
|||||||
@@ -370,6 +370,16 @@ pub enum ExecutableType {
|
|||||||
Example(String),
|
Example(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ExecutableType {
|
||||||
|
/// Get the name of the executable if it is a binary or an example.
|
||||||
|
pub fn executable(&self) -> Option<&str> {
|
||||||
|
match self {
|
||||||
|
Self::Binary(bin) | Self::Example(bin) => Some(bin),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl CrateConfig {
|
impl CrateConfig {
|
||||||
#[cfg(feature = "cli")]
|
#[cfg(feature = "cli")]
|
||||||
pub fn new(bin: Option<PathBuf>) -> Result<Self, CrateConfigError> {
|
pub fn new(bin: Option<PathBuf>) -> Result<Self, CrateConfigError> {
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ use crate::Result;
|
|||||||
use dioxus_cli_config::CrateConfig;
|
use dioxus_cli_config::CrateConfig;
|
||||||
use manganis_cli_support::{AssetManifest, AssetManifestExt};
|
use manganis_cli_support::{AssetManifest, AssetManifestExt};
|
||||||
|
|
||||||
pub fn asset_manifest(crate_config: &CrateConfig) -> AssetManifest {
|
pub fn asset_manifest(bin: Option<&str>, crate_config: &CrateConfig) -> AssetManifest {
|
||||||
AssetManifest::load_from_path(
|
AssetManifest::load_from_path(
|
||||||
|
bin,
|
||||||
crate_config.crate_dir.join("Cargo.toml"),
|
crate_config.crate_dir.join("Cargo.toml"),
|
||||||
crate_config.workspace_dir.join("Cargo.lock"),
|
crate_config.workspace_dir.join("Cargo.lock"),
|
||||||
)
|
)
|
||||||
|
|||||||
+38
-63
@@ -27,6 +27,7 @@ lazy_static! {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct BuildResult {
|
pub struct BuildResult {
|
||||||
pub warnings: Vec<Diagnostic>,
|
pub warnings: Vec<Diagnostic>,
|
||||||
|
pub executable: Option<PathBuf>,
|
||||||
pub elapsed_time: u128,
|
pub elapsed_time: u128,
|
||||||
pub assets: Option<AssetManifest>,
|
pub assets: Option<AssetManifest>,
|
||||||
}
|
}
|
||||||
@@ -117,7 +118,7 @@ pub fn build(
|
|||||||
.arg("build")
|
.arg("build")
|
||||||
.arg("--target")
|
.arg("--target")
|
||||||
.arg("wasm32-unknown-unknown")
|
.arg("wasm32-unknown-unknown")
|
||||||
.arg("--message-format=json");
|
.arg("--message-format=json-render-diagnostics");
|
||||||
|
|
||||||
// TODO: make the initial variable mutable to simplify all the expressions
|
// TODO: make the initial variable mutable to simplify all the expressions
|
||||||
// below. Look inside the `build_desktop()` as an example.
|
// below. Look inside the `build_desktop()` as an example.
|
||||||
@@ -159,28 +160,11 @@ pub fn build(
|
|||||||
// [2] Establish the output directory structure
|
// [2] Establish the output directory structure
|
||||||
let bindgen_outdir = out_dir.join("assets").join("dioxus");
|
let bindgen_outdir = out_dir.join("assets").join("dioxus");
|
||||||
|
|
||||||
let build_target = if config.custom_profile.is_some() {
|
let input_path = warning_messages
|
||||||
let build_profile = config.custom_profile.as_ref().unwrap();
|
.output_location
|
||||||
if build_profile == "dev" {
|
.as_ref()
|
||||||
"debug"
|
.unwrap()
|
||||||
} else {
|
.with_extension("wasm");
|
||||||
build_profile
|
|
||||||
}
|
|
||||||
} else if config.release {
|
|
||||||
"release"
|
|
||||||
} else {
|
|
||||||
"debug"
|
|
||||||
};
|
|
||||||
|
|
||||||
let input_path = match executable {
|
|
||||||
ExecutableType::Binary(name) | ExecutableType::Lib(name) => target_dir
|
|
||||||
.join(format!("wasm32-unknown-unknown/{}", build_target))
|
|
||||||
.join(format!("{}.wasm", name)),
|
|
||||||
|
|
||||||
ExecutableType::Example(name) => target_dir
|
|
||||||
.join(format!("wasm32-unknown-unknown/{}/examples", build_target))
|
|
||||||
.join(format!("{}.wasm", name)),
|
|
||||||
};
|
|
||||||
|
|
||||||
let bindgen_result = panic::catch_unwind(move || {
|
let bindgen_result = panic::catch_unwind(move || {
|
||||||
// [3] Bindgen the final binary for use easy linking
|
// [3] Bindgen the final binary for use easy linking
|
||||||
@@ -288,8 +272,8 @@ pub fn build(
|
|||||||
depth: 0,
|
depth: 0,
|
||||||
};
|
};
|
||||||
if asset_dir.is_dir() {
|
if asset_dir.is_dir() {
|
||||||
for entry in std::fs::read_dir(asset_dir)? {
|
for entry in std::fs::read_dir(config.asset_dir())?.flatten() {
|
||||||
let path = entry?.path();
|
let path = entry.path();
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
std::fs::copy(&path, out_dir.join(path.file_name().unwrap()))?;
|
std::fs::copy(&path, out_dir.join(path.file_name().unwrap()))?;
|
||||||
} else {
|
} else {
|
||||||
@@ -311,7 +295,7 @@ pub fn build(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let assets = if !skip_assets {
|
let assets = if !skip_assets {
|
||||||
let assets = asset_manifest(config);
|
let assets = asset_manifest(executable.executable(), config);
|
||||||
process_assets(config, &assets)?;
|
process_assets(config, &assets)?;
|
||||||
Some(assets)
|
Some(assets)
|
||||||
} else {
|
} else {
|
||||||
@@ -319,7 +303,8 @@ pub fn build(
|
|||||||
};
|
};
|
||||||
|
|
||||||
Ok(BuildResult {
|
Ok(BuildResult {
|
||||||
warnings: warning_messages,
|
warnings: warning_messages.warnings,
|
||||||
|
executable: warning_messages.output_location,
|
||||||
elapsed_time: t_start.elapsed().as_millis(),
|
elapsed_time: t_start.elapsed().as_millis(),
|
||||||
assets,
|
assets,
|
||||||
})
|
})
|
||||||
@@ -346,7 +331,7 @@ pub fn build_desktop(
|
|||||||
.env("CARGO_TARGET_DIR", &config.target_dir)
|
.env("CARGO_TARGET_DIR", &config.target_dir)
|
||||||
.cwd(&config.crate_dir)
|
.cwd(&config.crate_dir)
|
||||||
.arg("build")
|
.arg("build")
|
||||||
.arg("--message-format=json");
|
.arg("--message-format=json-render-diagnostics");
|
||||||
|
|
||||||
if config.release {
|
if config.release {
|
||||||
cmd = cmd.arg("--release");
|
cmd = cmd.arg("--release");
|
||||||
@@ -371,8 +356,6 @@ pub fn build_desktop(
|
|||||||
cmd = cmd.arg("--target").arg(target);
|
cmd = cmd.arg("--target").arg(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
let target_platform = config.target.as_deref().unwrap_or("");
|
|
||||||
|
|
||||||
cmd = cmd.args(&config.cargo_args);
|
cmd = cmd.args(&config.cargo_args);
|
||||||
|
|
||||||
let cmd = match &config.executable {
|
let cmd = match &config.executable {
|
||||||
@@ -383,34 +366,9 @@ pub fn build_desktop(
|
|||||||
|
|
||||||
let warning_messages = prettier_build(cmd)?;
|
let warning_messages = prettier_build(cmd)?;
|
||||||
|
|
||||||
let release_type = match config.release {
|
let file_name: String = config.executable.executable().unwrap().to_string();
|
||||||
true => "release",
|
|
||||||
false => "debug",
|
|
||||||
};
|
|
||||||
|
|
||||||
let file_name: String;
|
|
||||||
let mut res_path = match &config.executable {
|
|
||||||
ExecutableType::Binary(name) | ExecutableType::Lib(name) => {
|
|
||||||
file_name = name.clone();
|
|
||||||
config
|
|
||||||
.target_dir
|
|
||||||
.join(target_platform)
|
|
||||||
.join(release_type)
|
|
||||||
.join(name)
|
|
||||||
}
|
|
||||||
ExecutableType::Example(name) => {
|
|
||||||
file_name = name.clone();
|
|
||||||
config
|
|
||||||
.target_dir
|
|
||||||
.join(target_platform)
|
|
||||||
.join(release_type)
|
|
||||||
.join("examples")
|
|
||||||
.join(name)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let target_file = if cfg!(windows) {
|
let target_file = if cfg!(windows) {
|
||||||
res_path.set_extension("exe");
|
|
||||||
format!("{}.exe", &file_name)
|
format!("{}.exe", &file_name)
|
||||||
} else {
|
} else {
|
||||||
file_name
|
file_name
|
||||||
@@ -419,7 +377,10 @@ pub fn build_desktop(
|
|||||||
if !config.out_dir().is_dir() {
|
if !config.out_dir().is_dir() {
|
||||||
create_dir_all(config.out_dir())?;
|
create_dir_all(config.out_dir())?;
|
||||||
}
|
}
|
||||||
copy(res_path, config.out_dir().join(target_file))?;
|
let output_path = config.out_dir().join(target_file);
|
||||||
|
if let Some(res_path) = &warning_messages.output_location {
|
||||||
|
copy(res_path, &output_path)?;
|
||||||
|
}
|
||||||
|
|
||||||
// this code will copy all public file to the output dir
|
// this code will copy all public file to the output dir
|
||||||
if config.asset_dir().is_dir() {
|
if config.asset_dir().is_dir() {
|
||||||
@@ -432,8 +393,8 @@ pub fn build_desktop(
|
|||||||
depth: 0,
|
depth: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
for entry in std::fs::read_dir(config.asset_dir())? {
|
for entry in std::fs::read_dir(config.asset_dir())?.flatten() {
|
||||||
let path = entry?.path();
|
let path = entry.path();
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
std::fs::copy(&path, &config.out_dir().join(path.file_name().unwrap()))?;
|
std::fs::copy(&path, &config.out_dir().join(path.file_name().unwrap()))?;
|
||||||
} else {
|
} else {
|
||||||
@@ -455,7 +416,7 @@ pub fn build_desktop(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let assets = if !skip_assets {
|
let assets = if !skip_assets {
|
||||||
let assets = asset_manifest(config);
|
let assets = asset_manifest(config.executable.executable(), config);
|
||||||
// Collect assets
|
// Collect assets
|
||||||
process_assets(config, &assets)?;
|
process_assets(config, &assets)?;
|
||||||
// Create the __assets_head.html file for bundling
|
// Create the __assets_head.html file for bundling
|
||||||
@@ -473,13 +434,19 @@ pub fn build_desktop(
|
|||||||
println!("build desktop done");
|
println!("build desktop done");
|
||||||
|
|
||||||
Ok(BuildResult {
|
Ok(BuildResult {
|
||||||
warnings: warning_messages,
|
warnings: warning_messages.warnings,
|
||||||
|
executable: Some(output_path),
|
||||||
elapsed_time: t_start.elapsed().as_millis(),
|
elapsed_time: t_start.elapsed().as_millis(),
|
||||||
assets,
|
assets,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
|
struct CargoBuildResult {
|
||||||
|
warnings: Vec<Diagnostic>,
|
||||||
|
output_location: Option<PathBuf>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<CargoBuildResult> {
|
||||||
let mut warning_messages: Vec<Diagnostic> = vec![];
|
let mut warning_messages: Vec<Diagnostic> = vec![];
|
||||||
|
|
||||||
let mut pb = ProgressBar::new_spinner();
|
let mut pb = ProgressBar::new_spinner();
|
||||||
@@ -494,6 +461,7 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
|
|||||||
|
|
||||||
let stdout = cmd.detached().stream_stdout()?;
|
let stdout = cmd.detached().stream_stdout()?;
|
||||||
let reader = std::io::BufReader::new(stdout);
|
let reader = std::io::BufReader::new(stdout);
|
||||||
|
let mut output_location = None;
|
||||||
|
|
||||||
for message in cargo_metadata::Message::parse_stream(reader) {
|
for message in cargo_metadata::Message::parse_stream(reader) {
|
||||||
match message.unwrap() {
|
match message.unwrap() {
|
||||||
@@ -516,6 +484,9 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
|
|||||||
Message::CompilerArtifact(artifact) => {
|
Message::CompilerArtifact(artifact) => {
|
||||||
pb.set_message(format!("⚙️ Compiling {} ", artifact.package_id));
|
pb.set_message(format!("⚙️ Compiling {} ", artifact.package_id));
|
||||||
pb.tick();
|
pb.tick();
|
||||||
|
if let Some(executable) = artifact.executable {
|
||||||
|
output_location = Some(executable.into());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Message::BuildScriptExecuted(script) => {
|
Message::BuildScriptExecuted(script) => {
|
||||||
let _package_id = script.package_id.to_string();
|
let _package_id = script.package_id.to_string();
|
||||||
@@ -532,7 +503,11 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(warning_messages)
|
|
||||||
|
Ok(CargoBuildResult {
|
||||||
|
warnings: warning_messages,
|
||||||
|
output_location,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gen_page(config: &CrateConfig, manifest: Option<&AssetManifest>, serve: bool) -> String {
|
pub fn gen_page(config: &CrateConfig, manifest: Option<&AssetManifest>, serve: bool) -> String {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use crate::{
|
|||||||
BuildResult, Result,
|
BuildResult, Result,
|
||||||
};
|
};
|
||||||
use dioxus_cli_config::CrateConfig;
|
use dioxus_cli_config::CrateConfig;
|
||||||
use dioxus_cli_config::ExecutableType;
|
|
||||||
|
|
||||||
use dioxus_hot_reload::HotReloadMsg;
|
use dioxus_hot_reload::HotReloadMsg;
|
||||||
use dioxus_html::HtmlCtx;
|
use dioxus_html::HtmlCtx;
|
||||||
@@ -224,24 +223,19 @@ fn start_desktop(
|
|||||||
// Only used for the fullstack platform,
|
// Only used for the fullstack platform,
|
||||||
let result = crate::builder::build_desktop(config, true, skip_assets, rust_flags)?;
|
let result = crate::builder::build_desktop(config, true, skip_assets, rust_flags)?;
|
||||||
|
|
||||||
match &config.executable {
|
let active = "DIOXUS_ACTIVE";
|
||||||
ExecutableType::Binary(name)
|
let child = RAIIChild(
|
||||||
| ExecutableType::Lib(name)
|
Command::new(
|
||||||
| ExecutableType::Example(name) => {
|
result
|
||||||
let mut file = config.out_dir().join(name);
|
.executable
|
||||||
if cfg!(windows) {
|
.clone()
|
||||||
file.set_extension("exe");
|
.ok_or(anyhow::anyhow!("No executable found after desktop build"))?,
|
||||||
}
|
)
|
||||||
let active = "DIOXUS_ACTIVE";
|
.env(active, "true")
|
||||||
let child = RAIIChild(
|
.spawn()?,
|
||||||
Command::new(file.to_str().unwrap())
|
);
|
||||||
.env(active, "true")
|
|
||||||
.spawn()?,
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok((child, result))
|
Ok((child, result))
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct DesktopPlatform {
|
pub(crate) struct DesktopPlatform {
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ async fn setup_file_watcher<F: Fn() -> Result<BuildResult> + Send + 'static>(
|
|||||||
&config.crate_dir.join(sub_path),
|
&config.crate_dir.join(sub_path),
|
||||||
notify::RecursiveMode::Recursive,
|
notify::RecursiveMode::Recursive,
|
||||||
) {
|
) {
|
||||||
log::error!("Failed to watch path: {}", err);
|
log::warn!("Failed to watch path: {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(watcher)
|
Ok(watcher)
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ fn module_loader(root_id: &str, headless: bool) -> String {
|
|||||||
/// Defaults to the current directory if no asset directory is found, which is useful for development when the app
|
/// Defaults to the current directory if no asset directory is found, which is useful for development when the app
|
||||||
/// isn't bundled.
|
/// isn't bundled.
|
||||||
fn get_asset_root_or_default() -> PathBuf {
|
fn get_asset_root_or_default() -> PathBuf {
|
||||||
get_asset_root().unwrap_or_else(|| Path::new(".").to_path_buf())
|
get_asset_root().unwrap_or_else(|| std::env::current_dir().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the asset directory, following tauri/cargo-bundles directory discovery approach
|
/// Get the asset directory, following tauri/cargo-bundles directory discovery approach
|
||||||
|
|||||||
Reference in new issue
Block a user