aboutsummaryrefslogtreecommitdiff
path: root/helix-loader/src/lib.rs
diff options
context:
space:
mode:
authorSkyler Hawthorne2023-10-25 16:08:01 +0000
committerGitHub2023-10-25 16:08:01 +0000
commitb5d691a5d7e791f9b9581d96217f80ea10a6f2ca (patch)
treecef2e95ab880b281b8b26a407273545f4c9beba1 /helix-loader/src/lib.rs
parent68c7537de522cf6b38705a7af51eeaac260fdc98 (diff)
Add optional runtime fallback directory (#8610)
Diffstat (limited to 'helix-loader/src/lib.rs')
-rw-r--r--helix-loader/src/lib.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/helix-loader/src/lib.rs b/helix-loader/src/lib.rs
index 82ed2ede..5337d602 100644
--- a/helix-loader/src/lib.rs
+++ b/helix-loader/src/lib.rs
@@ -60,7 +60,8 @@ pub fn initialize_log_file(specified_file: Option<PathBuf>) {
/// 1. sibling directory to `CARGO_MANIFEST_DIR` (if environment variable is set)
/// 2. subdirectory of user config directory (always included)
/// 3. `HELIX_RUNTIME` (if environment variable is set)
-/// 4. subdirectory of path to helix executable (always included)
+/// 4. `HELIX_DEFAULT_RUNTIME` (if environment variable is set *at build time*)
+/// 5. subdirectory of path to helix executable (always included)
///
/// Postcondition: returns at least two paths (they might not exist).
fn prioritize_runtime_dirs() -> Vec<PathBuf> {
@@ -81,6 +82,14 @@ fn prioritize_runtime_dirs() -> Vec<PathBuf> {
rt_dirs.push(dir.into());
}
+ // If this variable is set during build time, it will always be included
+ // in the lookup list. This allows downstream packagers to set a fallback
+ // directory to a location that is conventional on their distro so that they
+ // need not resort to a wrapper script or a global environment variable.
+ if let Some(dir) = std::option_env!("HELIX_DEFAULT_RUNTIME") {
+ rt_dirs.push(dir.into());
+ }
+
// fallback to location of the executable being run
// canonicalize the path in case the executable is symlinked
let exe_rt_dir = std::env::current_exe()