fix: build on windows

This commit is contained in:
Lucas Nogueira 2021-10-17 12:29:59 -03:00 committed by Lucas Nogueira
parent 7209fdf732
commit dd83217301
No known key found for this signature in database
GPG Key ID: 2714B66BCFB01F7F
2 changed files with 16 additions and 7 deletions

View File

@ -73,6 +73,7 @@ pub fn target_triple() -> crate::Result<String> {
/// `${exe_dir}/../lib/${exe_name}`.
///
/// On MacOS, it's `${exe_dir}../Resources` (inside .app).
#[allow(unused_variables)]
pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<PathBuf> {
let exe = std::env::current_exe()?;
let exe_dir = exe.parent().expect("failed to get exe directory");
@ -86,8 +87,12 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<Path
return Ok(exe_dir.to_path_buf());
}
if cfg!(target_os = "linux") {
if curr_dir.ends_with("/data/usr/bin") {
#[allow(unused_mut)]
let mut res = Err(crate::Error::UnsupportedPlatform);
#[cfg(target_os = "linux")]
{
res = if curr_dir.ends_with("/data/usr/bin") {
// running from the deb bundle dir
Ok(exe_dir.join(format!("../lib/{}", package_info.package_name())))
} else if let Some(appdir) = &env.appdir {
@ -103,10 +108,13 @@ pub fn resource_dir(package_info: &PackageInfo, env: &Env) -> crate::Result<Path
"/usr/lib/{}",
package_info.package_name()
)))
}
} else if cfg!(target_os = "macos") {
Ok(exe_dir.join("../Resources"))
} else {
Err(crate::Error::UnsupportedPlatform)
};
}
#[cfg(target_os = "macos")]
{
res = Ok(exe_dir.join("../Resources"));
}
res
}

View File

@ -677,6 +677,7 @@ impl<R: Runtime> WindowManager<R> {
let local_app_data = resolve_path(
&self.inner.config,
&self.inner.package_info,
self.inner.state.get::<crate::Env>().inner(),
&self.inner.config.tauri.bundle.identifier,
Some(BaseDirectory::LocalData),
);