Fix asset location for linux bundles (#4460)
* fix linux bundle * fix release mode * fix resource path * only use asset dir if it exists * add comment about directory structure * don't unwrap parent
This commit is contained in:
1 parent
66c2dac38f
commit
15d369f10f
3 files changed
+28
-2
No files matched your search
@@ -80,7 +80,7 @@ pub fn serve_asset(path: &str) -> Result<Response<Vec<u8>>, AssetServeError> {
|
||||
/// - [x] Windows
|
||||
/// - [x] Linux (appimage)
|
||||
/// - [ ] Linux (rpm)
|
||||
/// - [ ] Linux (deb)
|
||||
/// - [x] Linux (deb)
|
||||
/// - [ ] Android
|
||||
#[allow(unreachable_code)]
|
||||
fn get_asset_root() -> PathBuf {
|
||||
@@ -96,6 +96,25 @@ fn get_asset_root() -> PathBuf {
|
||||
.join("Resources");
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
// In linux bundles, the assets are placed in the lib/$product_name directory
|
||||
// bin/
|
||||
// main
|
||||
// lib/
|
||||
// $product_name/
|
||||
// assets/
|
||||
if let Some(product_name) = dioxus_cli_config::product_name() {
|
||||
let lib_asset_path = || {
|
||||
let path = cur_exe.parent()?.parent()?.join("lib").join(product_name);
|
||||
path.exists().then_some(path)
|
||||
};
|
||||
if let Some(asset_dir) = lib_asset_path() {
|
||||
return asset_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For all others, the structure looks like this:
|
||||
// app.(exe/appimage)
|
||||
// main.exe
|
||||
|
||||
@@ -64,6 +64,7 @@ pub const DEVSERVER_PORT_ENV: &str = "DIOXUS_DEVSERVER_PORT";
|
||||
pub const ALWAYS_ON_TOP_ENV: &str = "DIOXUS_ALWAYS_ON_TOP";
|
||||
pub const ASSET_ROOT_ENV: &str = "DIOXUS_ASSET_ROOT";
|
||||
pub const APP_TITLE_ENV: &str = "DIOXUS_APP_TITLE";
|
||||
pub const PRODUCT_NAME_ENV: &str = "DIOXUS_PRODUCT_NAME";
|
||||
|
||||
#[deprecated(since = "0.6.0", note = "The CLI currently does not set this.")]
|
||||
#[doc(hidden)]
|
||||
@@ -327,3 +328,8 @@ pub fn build_id() -> u64 {
|
||||
.unwrap_or(0)
|
||||
}
|
||||
}
|
||||
|
||||
/// The product name of the bundled application.
|
||||
pub fn product_name() -> Option<String> {
|
||||
read_env_config!("DIOXUS_PRODUCT_NAME")
|
||||
}
|
||||
@@ -323,7 +323,7 @@ use crate::{
|
||||
use anyhow::{bail, Context};
|
||||
use cargo_metadata::diagnostic::Diagnostic;
|
||||
use depinfo::RustcDepInfo;
|
||||
use dioxus_cli_config::format_base_path_meta_element;
|
||||
use dioxus_cli_config::{format_base_path_meta_element, PRODUCT_NAME_ENV};
|
||||
use dioxus_cli_config::{APP_TITLE_ENV, ASSET_ROOT_ENV};
|
||||
use dioxus_cli_opt::{process_file_to, AssetManifest};
|
||||
use itertools::Itertools;
|
||||
@@ -2423,6 +2423,7 @@ impl BuildRequest {
|
||||
env_vars.push((ASSET_ROOT_ENV.into(), base_path.to_string()));
|
||||
}
|
||||
env_vars.push((APP_TITLE_ENV.into(), self.config.web.app.title.clone()));
|
||||
env_vars.push((PRODUCT_NAME_ENV.into(), self.bundled_app_name()));
|
||||
}
|
||||
|
||||
// Assemble the rustflags by peering into the `.cargo/config.toml` file
|
||||
|
||||
Reference in new issue
Block a user