Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion packages/asset-resolver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions packages/cli-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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")
}
3 changes: 2 additions & 1 deletion packages/cli/src/build/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Loading