config_paths: embed-data has no doc dir

This makes no sense:

	$ target/debug/fish -d config
	config: paths.doc: .local/share/doc/fish

so remove it.

While at it, group config paths by whether they can be embedded.
This commit is contained in:
Johannes Altmanninger
2025-09-06 14:15:59 +02:00
parent f7a2d56046
commit 8640ce8148
2 changed files with 23 additions and 22 deletions

View File

@@ -7,11 +7,12 @@
/// env_init.
#[derive(Default)]
pub struct ConfigPaths {
pub sysconf: PathBuf, // e.g., /usr/local/etc
pub bin: Option<PathBuf>, // e.g., /usr/local/bin
#[cfg(not(feature = "embed-data"))]
pub data: PathBuf, // e.g., /usr/local/share
pub sysconf: PathBuf, // e.g., /usr/local/etc
pub doc: PathBuf, // e.g., /usr/local/share/doc/fish
pub bin: Option<PathBuf>, // e.g., /usr/local/bin
#[cfg(not(feature = "embed-data"))]
pub doc: PathBuf, // e.g., /usr/local/share/doc/fish
#[cfg(not(feature = "embed-data"))]
pub locale: PathBuf, // e.g., /usr/local/share/locale
}
@@ -31,14 +32,11 @@ pub struct ConfigPaths {
let paths = ConfigPaths::new(&argv0, exec_path);
#[cfg(not(feature = "embed-data"))]
FLOGF!(config, "paths.data: %ls", paths.data.display().to_string());
FLOGF!(
config,
"paths.sysconf: %ls",
paths.sysconf.display().to_string()
);
FLOGF!(config, "paths.doc: %ls", paths.doc.display().to_string());
FLOGF!(
config,
"paths.bin: %ls",
@@ -49,6 +47,10 @@ pub struct ConfigPaths {
.unwrap_or("|not found|".to_string()),
);
#[cfg(not(feature = "embed-data"))]
FLOGF!(config, "paths.data: %ls", paths.data.display().to_string());
#[cfg(not(feature = "embed-data"))]
FLOGF!(config, "paths.doc: %ls", paths.doc.display().to_string());
#[cfg(not(feature = "embed-data"))]
FLOGF!(
config,
"paths.locale: %ls",
@@ -59,6 +61,7 @@ pub struct ConfigPaths {
});
const SYSCONF_DIR: &str = env!("SYSCONFDIR");
#[cfg(not(feature = "embed-data"))]
const DOC_DIR: &str = env!("DOCDIR");
impl ConfigPaths {
@@ -67,10 +70,10 @@ fn static_paths() -> Self {
// Fall back to what got compiled in.
FLOG!(config, "Using compiled in paths:");
Self {
data: PathBuf::from(env!("DATADIR")).join("fish"),
sysconf: PathBuf::from(SYSCONF_DIR).join("fish"),
doc: DOC_DIR.into(),
bin: Some(PathBuf::from(env!("BINDIR"))),
data: PathBuf::from(env!("DATADIR")).join("fish"),
doc: DOC_DIR.into(),
locale: PathBuf::from(env!("LOCALEDIR")),
}
}
@@ -80,7 +83,6 @@ fn new(_argv0: &Path, exec_path: PathBuf) -> Self {
FLOG!(config, "embed-data feature is active, ignoring data paths");
ConfigPaths {
sysconf: PathBuf::from(SYSCONF_DIR).join("fish"),
doc: DOC_DIR.into(),
bin: exec_path.parent().map(|x| x.to_path_buf()),
}
}
@@ -105,10 +107,10 @@ fn new(argv0: &Path, exec_path: PathBuf) -> Self {
workspace_root.display()
);
return ConfigPaths {
data: workspace_root.join("share"),
sysconf: workspace_root.join("etc"),
doc: workspace_root.join("user_doc/html"),
bin: Some(exec_path.parent().unwrap().to_owned()),
data: workspace_root.join("share"),
doc: workspace_root.join("user_doc/html"),
locale: workspace_root.join("share/locale"),
};
}
@@ -118,10 +120,10 @@ fn new(argv0: &Path, exec_path: PathBuf) -> Self {
if exec_path.ends_with("bin/fish") {
let base_path = exec_path.parent().unwrap().parent().unwrap();
paths = ConfigPaths {
data: base_path.join("share/fish"),
sysconf: base_path.join("etc/fish"),
doc: base_path.join("share/doc/fish"),
bin: Some(base_path.join("bin")),
data: base_path.join("share/fish"),
doc: base_path.join("share/doc/fish"),
locale: base_path.join("share/locale"),
}
}

View File

@@ -668,15 +668,14 @@ pub fn env_init(paths: Option<&ConfigPaths>, do_uvars: bool, default_paths: bool
str2wcstring(paths.sysconf.as_os_str().as_bytes()),
);
if !cfg!(feature = "embed-data") {
vars.set_one(
FISH_HELPDIR_VAR,
EnvMode::GLOBAL,
str2wcstring(paths.doc.as_os_str().as_bytes()),
);
} else {
vars.set_empty(FISH_HELPDIR_VAR, EnvMode::GLOBAL);
}
#[cfg(feature = "embed-data")]
vars.set_empty(FISH_HELPDIR_VAR, EnvMode::GLOBAL);
#[cfg(not(feature = "embed-data"))]
vars.set_one(
FISH_HELPDIR_VAR,
EnvMode::GLOBAL,
str2wcstring(paths.doc.as_os_str().as_bytes()),
);
if let Some(bp) = &paths.bin {
vars.set_one(
FISH_BIN_DIR,