mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-22 03:51:15 -03:00
Remove embed-data feature flag
This mode still has some problems (see the next commit) but having it behind a feature flag doesn't serve us. Let's commit to the parts we want to keep and drop anything that we don't want. To reduce diff noise, use "if false" in the code paths used by man pages; a following commit will use them.
This commit is contained in:
@@ -86,7 +86,7 @@ bitflags.workspace = true
|
||||
cfg-if.workspace = true
|
||||
errno.workspace = true
|
||||
fish-build-helper.workspace = true
|
||||
fish-build-man-pages = { workspace = true, optional = true }
|
||||
fish-build-man-pages.workspace = true
|
||||
fish-gettext-extraction = { workspace = true, optional = true }
|
||||
fish-gettext-maps = { workspace = true, optional = true }
|
||||
fish-printf.workspace = true
|
||||
@@ -107,14 +107,14 @@ widestring.workspace = true
|
||||
portable-atomic.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
rust-embed = { workspace = true, optional = true, features = [
|
||||
rust-embed = { workspace = true, features = [
|
||||
"deterministic-timestamps",
|
||||
"debug-embed",
|
||||
"include-exclude",
|
||||
"interpolate-folder-path",
|
||||
] }
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
rust-embed = { workspace = true, optional = true, features = [
|
||||
rust-embed = { workspace = true, features = [
|
||||
"deterministic-timestamps",
|
||||
"include-exclude",
|
||||
"interpolate-folder-path",
|
||||
@@ -150,9 +150,8 @@ name = "fish_key_reader"
|
||||
path = "src/bin/fish_key_reader.rs"
|
||||
|
||||
[features]
|
||||
default = ["embed-data", "localize-messages"]
|
||||
default = ["localize-messages"]
|
||||
benchmark = []
|
||||
embed-data = ["dep:rust-embed", "dep:fish-build-man-pages"]
|
||||
# Enable gettext localization at runtime. Requires the `msgfmt` tool to generate catalog data at
|
||||
# build time.
|
||||
localize-messages = ["dep:phf", "dep:fish-gettext-maps"]
|
||||
|
||||
@@ -185,7 +185,7 @@ You can also install Sphinx another way and drop the ``uv run --no-managed-pytho
|
||||
|
||||
This will place standalone binaries in ``~/.cargo/bin/``, but you can move them wherever you want.
|
||||
|
||||
To disable translations, disable the ``localize-messages`` feature by passing ``--no-default-features --features=embed-data`` to cargo.
|
||||
To disable translations, disable the ``localize-messages`` feature by passing ``--no-default-features`` to cargo.
|
||||
|
||||
You can also link this build statically (but not against glibc) and move it to other computers.
|
||||
|
||||
|
||||
23
build.rs
23
build.rs
@@ -42,7 +42,6 @@ fn main() {
|
||||
|
||||
// These are necessary if built with embedded functions,
|
||||
// but only in release builds (because rust-embed in debug builds reads from the filesystem).
|
||||
#[cfg(feature = "embed-data")]
|
||||
#[cfg(any(windows, not(debug_assertions)))]
|
||||
rsconf::rebuild_if_path_changed("share");
|
||||
|
||||
@@ -215,32 +214,18 @@ fn join_if_relative(parent_if_relative: &Path, path: String) -> PathBuf {
|
||||
overridable_path("SYSCONFDIR", |env_sysconfdir| {
|
||||
Some(join_if_relative(
|
||||
&prefix,
|
||||
env_sysconfdir.unwrap_or(
|
||||
// Embedded builds use "/etc," not "$PREFIX/etc".
|
||||
if cfg!(feature = "embed-data") {
|
||||
"/etc/"
|
||||
} else {
|
||||
"etc/"
|
||||
}
|
||||
.to_string(),
|
||||
),
|
||||
env_sysconfdir.unwrap_or("/etc/".to_string()),
|
||||
))
|
||||
});
|
||||
|
||||
let default_ok = !cfg!(feature = "embed-data");
|
||||
let datadir = overridable_path("DATADIR", |env_datadir| {
|
||||
let default = default_ok.then_some("share/".to_string());
|
||||
env_datadir
|
||||
.or(default)
|
||||
.map(|p| join_if_relative(&prefix, p))
|
||||
env_datadir.map(|p| join_if_relative(&prefix, p))
|
||||
});
|
||||
overridable_path("BINDIR", |env_bindir| {
|
||||
let default = default_ok.then_some("bin/".to_string());
|
||||
env_bindir.or(default).map(|p| join_if_relative(&prefix, p))
|
||||
env_bindir.map(|p| join_if_relative(&prefix, p))
|
||||
});
|
||||
overridable_path("DOCDIR", |env_docdir| {
|
||||
let default = default_ok.then_some("doc/fish".to_string());
|
||||
env_docdir.or(default).map(|p| {
|
||||
env_docdir.map(|p| {
|
||||
join_if_relative(
|
||||
&datadir
|
||||
.expect("Setting DOCDIR without setting DATADIR is not currently supported"),
|
||||
|
||||
@@ -3,8 +3,6 @@ find_package(Rust REQUIRED)
|
||||
|
||||
set(FISH_RUST_BUILD_DIR "${CMAKE_BINARY_DIR}/cargo/build")
|
||||
|
||||
list(APPEND FISH_CARGO_FEATURES_LIST "embed-data")
|
||||
|
||||
if(DEFINED ASAN)
|
||||
list(APPEND CARGO_FLAGS "-Z" "build-std")
|
||||
list(APPEND FISH_CARGO_FEATURES_LIST "asan")
|
||||
|
||||
@@ -22,16 +22,6 @@ if not status --is-interactive
|
||||
end
|
||||
end
|
||||
|
||||
# N.B. can't load __fish_is_standalone.fish this early in non-embedded builds, so reimplement it.
|
||||
# We still want it as a separate file for --no-config.
|
||||
set -l is_standalone (
|
||||
if status get-file config.fish &>/dev/null
|
||||
echo true
|
||||
else
|
||||
echo false
|
||||
end
|
||||
)
|
||||
|
||||
#
|
||||
# Set default search paths for completions and shellscript functions
|
||||
# unless they already exist
|
||||
@@ -42,12 +32,7 @@ set -l is_standalone (
|
||||
set -l __extra_completionsdir
|
||||
set -l __extra_functionsdir
|
||||
set -l __extra_confdir
|
||||
# N.B. can't load __fish_data_with_file this early in non-embedded builds, so reimplement it.
|
||||
if $is_standalone
|
||||
status get-file __fish_build_paths.fish | source
|
||||
else if path is -f -- $__fish_data_dir/__fish_build_paths.fish
|
||||
source $__fish_data_dir/__fish_build_paths.fish
|
||||
end
|
||||
__fish_data_with_file __fish_build_paths.fish source
|
||||
|
||||
# Compute the directories for vendor configuration. We want to include
|
||||
# all of XDG_DATA_DIRS, as well as the __extra_* dirs defined above.
|
||||
@@ -55,8 +40,6 @@ set -l xdg_data_dirs
|
||||
if set -q XDG_DATA_DIRS
|
||||
set --path xdg_data_dirs $XDG_DATA_DIRS
|
||||
set xdg_data_dirs (string replace -r '([^/])/$' '$1' -- $xdg_data_dirs)/fish
|
||||
else if not $is_standalone
|
||||
set xdg_data_dirs $__fish_data_dir
|
||||
end
|
||||
|
||||
set -g __fish_vendor_completionsdirs
|
||||
@@ -85,21 +68,11 @@ end
|
||||
|
||||
if not set -q fish_function_path
|
||||
set fish_function_path $__fish_config_dir/functions $__fish_sysconf_dir/functions $__fish_vendor_functionsdirs
|
||||
if not $is_standalone
|
||||
set -a fish_function_path $__fish_data_dir/functions
|
||||
end
|
||||
else if not $is_standalone; and not contains -- $__fish_data_dir/functions $fish_function_path
|
||||
set -a fish_function_path $__fish_data_dir/functions
|
||||
end
|
||||
|
||||
if not set -q fish_complete_path
|
||||
set fish_complete_path $__fish_config_dir/completions $__fish_sysconf_dir/completions $__fish_vendor_completionsdirs
|
||||
if not $is_standalone
|
||||
set -a fish_complete_path $__fish_data_dir/completions
|
||||
end
|
||||
set -a fish_complete_path $__fish_cache_dir/generated_completions
|
||||
else if not $is_standalone; and not contains -- $__fish_data_dir/completions $fish_complete_path
|
||||
set -a fish_complete_path $__fish_data_dir/completions
|
||||
end
|
||||
|
||||
# Add a handler for when fish_user_path changes, so we can apply the same changes to PATH
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# localization: skip(private)
|
||||
function __fish_data_list_files
|
||||
set -l dir $argv[1]
|
||||
if not __fish_is_standalone
|
||||
# Construct a directory prefix without trailing slash.
|
||||
if test -n "$dir"
|
||||
set dir $__fish_data_dir/$dir
|
||||
else
|
||||
set dir $__fish_data_dir
|
||||
end
|
||||
set -l files $dir/**
|
||||
string replace -- $__fish_data_dir/ '' $files
|
||||
else
|
||||
status list-files $dir
|
||||
end
|
||||
end
|
||||
@@ -5,7 +5,7 @@ function __fish_data_with_directory
|
||||
set -l cmd $argv[3..]
|
||||
set -l temp
|
||||
set -l directory_ref
|
||||
if not __fish_is_standalone
|
||||
if false
|
||||
set directory_ref $__fish_data_dir/$relative_directory
|
||||
else
|
||||
set temp (__fish_mktemp_relative -d fish-data)
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
function __fish_data_with_file
|
||||
set -l path $argv[1]
|
||||
set -l cmd $argv[2..]
|
||||
if string match -rq -- ^/ $path; or begin
|
||||
not __fish_is_standalone
|
||||
and set path $__fish_data_dir/$path
|
||||
end
|
||||
if string match -rq -- ^/ $path
|
||||
$cmd $path
|
||||
else
|
||||
status get-file $path | $cmd
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# localization: skip(private)
|
||||
set -l is_standalone (
|
||||
if status get-file config.fish &>/dev/null
|
||||
echo true
|
||||
else
|
||||
echo false
|
||||
end
|
||||
)
|
||||
function __fish_is_standalone -V is_standalone
|
||||
$is_standalone
|
||||
end
|
||||
@@ -286,11 +286,7 @@ fish_pager_color_secondary_description
|
||||
set -l theme_path (__fish_config_list_themes $argv[1])[1]
|
||||
if not set -q theme_path[1]
|
||||
echo >&2 "No such theme: $argv[1]"
|
||||
echo >&2 Searched (__fish_config_theme_dirs) (
|
||||
if __fish_is_standalone
|
||||
echo "and `status list-files tools/web_config/themes`"
|
||||
end
|
||||
)
|
||||
echo >&2 Searched (__fish_config_theme_dir) "and `status list-files tools/web_config/themes`"
|
||||
return 1
|
||||
end
|
||||
|
||||
@@ -332,10 +328,7 @@ fish_pager_color_secondary_description
|
||||
end
|
||||
|
||||
function __fish_config_list_prompts
|
||||
set -lx dirs
|
||||
if not __fish_is_standalone
|
||||
set dirs $__fish_data_dir/tools/web_config/sample_prompts
|
||||
end
|
||||
set -lx dir
|
||||
set -l prompt_paths (__fish_config_matching tools/web_config/sample_prompts .fish $argv)
|
||||
if [ (count $argv) = 1 ] && set -q prompt_paths[2]
|
||||
echo >&2 "fish_config: internal error: multiple prompts matching '$argv' ??"
|
||||
@@ -345,15 +338,12 @@ function __fish_config_list_prompts
|
||||
end
|
||||
|
||||
function __fish_config_list_themes
|
||||
set -lx dirs (__fish_config_theme_dirs)
|
||||
set -lx dir (__fish_config_theme_dir)
|
||||
__fish_config_matching tools/web_config/themes .theme $argv
|
||||
end
|
||||
|
||||
function __fish_config_theme_dirs
|
||||
printf %s\n $__fish_config_dir/themes
|
||||
if not __fish_is_standalone
|
||||
printf %s\n $__fish_data_dir/tools/web_config/themes
|
||||
end
|
||||
function __fish_config_theme_dir
|
||||
echo $__fish_config_dir/themes
|
||||
end
|
||||
|
||||
function __fish_config_list_theme_names
|
||||
@@ -368,16 +358,14 @@ function __fish_config_matching
|
||||
set -e argv[1..2]
|
||||
set -l paths
|
||||
if not set -q argv[1]
|
||||
set paths $dirs/*$suffix
|
||||
set paths $dir/*$suffix
|
||||
else
|
||||
set paths (path filter $dirs/$argv$suffix)
|
||||
set paths (path filter $dir/$argv$suffix)
|
||||
end
|
||||
if __fish_is_standalone
|
||||
if not set -q argv[1]
|
||||
set -a paths (status list-files $prefix)
|
||||
else
|
||||
set -a paths (status list-files "$prefix/"$argv$suffix)
|
||||
end
|
||||
if not set -q argv[1]
|
||||
set -a paths (status list-files $prefix)
|
||||
else
|
||||
set -a paths (status list-files "$prefix/"$argv$suffix)
|
||||
end
|
||||
string join \n $paths
|
||||
end
|
||||
|
||||
@@ -21,15 +21,9 @@ function fish_delta
|
||||
|
||||
# TODO: Do we want to keep the vendor dirs in here?
|
||||
set -l default_function_path
|
||||
if not __fish_is_standalone
|
||||
set default_function_path $__fish_data_dir/functions
|
||||
end
|
||||
test "$vendormode" = default && set -a default_function_path $__fish_vendor_functionsdirs
|
||||
|
||||
set -l default_complete_path
|
||||
if not __fish_is_standalone
|
||||
set default_complete_path $__fish_data_dir/completions
|
||||
end
|
||||
test "$vendormode" = default && set -a default_complete_path $__fish_vendor_completionsdirs
|
||||
|
||||
set -l default_conf_path
|
||||
@@ -117,7 +111,7 @@ function fish_delta
|
||||
for file in $files
|
||||
set -l bn (path basename -- $file)
|
||||
set -l default_exists false
|
||||
if set -q dir[1]; and contains $dir/$bn (__fish_data_list_files $dir)
|
||||
if set -q dir[1]; and contains $dir/$bn (status list-files $dir)
|
||||
set default_exists true
|
||||
else if test $all_changed = 0
|
||||
set -ql _flag_n
|
||||
|
||||
@@ -15,7 +15,7 @@ function man
|
||||
end
|
||||
|
||||
set -l manpath
|
||||
if not __fish_is_standalone
|
||||
if false
|
||||
and set -l fish_manpath (path filter -d $__fish_data_dir/man)
|
||||
# Prepend fish's man directory if available.
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The classes responsible for autoloading functions and completions.
|
||||
|
||||
use crate::FLOGF;
|
||||
#[cfg(feature = "embed-data")]
|
||||
use crate::common::wcs2bytes;
|
||||
use crate::common::{ScopeGuard, escape};
|
||||
use crate::env::Environment;
|
||||
@@ -10,9 +9,7 @@
|
||||
use crate::wchar::{L, WString, wstr};
|
||||
use crate::wchar_ext::WExt;
|
||||
use crate::wutil::{FileId, INVALID_FILE_ID, file_id_for_path};
|
||||
use cfg_if::cfg_if;
|
||||
use lru::LruCache;
|
||||
#[cfg(feature = "embed-data")]
|
||||
use rust_embed::RustEmbed;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::num::NonZeroUsize;
|
||||
@@ -40,23 +37,14 @@ pub struct Autoload {
|
||||
cache: AutoloadFileCache,
|
||||
}
|
||||
|
||||
#[cfg(feature = "embed-data")]
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "share"]
|
||||
#[exclude = "__fish_build_paths.fish.in"]
|
||||
pub struct Asset;
|
||||
|
||||
cfg_if!(
|
||||
if #[cfg(feature = "embed-data")] {
|
||||
pub fn has_asset(cmd: &str) -> bool {
|
||||
Asset::get(cmd).is_some()
|
||||
}
|
||||
} else {
|
||||
pub fn has_asset(_cmd: &str) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
);
|
||||
pub fn has_asset(cmd: &str) -> bool {
|
||||
Asset::get(cmd).is_some()
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
enum AssetDir {
|
||||
@@ -65,7 +53,6 @@ enum AssetDir {
|
||||
}
|
||||
|
||||
pub enum AutoloadPath {
|
||||
#[cfg(feature = "embed-data")]
|
||||
Embedded(String),
|
||||
Path(WString),
|
||||
}
|
||||
@@ -114,7 +101,6 @@ pub fn resolve_command(&mut self, cmd: &wstr, env: &dyn Environment) -> Option<A
|
||||
) {
|
||||
AutoloadResult::Path(path) => {
|
||||
match &path {
|
||||
#[cfg(feature = "embed-data")]
|
||||
AutoloadPath::Embedded(_) => {
|
||||
FLOGF!(autoload, "Embedded: %s", cmd);
|
||||
}
|
||||
@@ -148,7 +134,6 @@ pub fn perform_autoload(path: &AutoloadPath, parser: &Parser) {
|
||||
let script_source = L!("source ").to_owned() + &escape(p)[..];
|
||||
parser.eval(&script_source, &IoChain::new());
|
||||
}
|
||||
#[cfg(feature = "embed-data")]
|
||||
AutoloadPath::Embedded(name) => {
|
||||
use crate::common::bytes2wcstring;
|
||||
use std::sync::Arc;
|
||||
@@ -236,7 +221,6 @@ fn resolve_command_impl(&mut self, cmd: &wstr, paths: &[WString]) -> AutoloadRes
|
||||
|
||||
let file_id = match &file {
|
||||
AutoloadableFileInfo::FileInfo(file) => &file.file_id,
|
||||
#[cfg(feature = "embed-data")]
|
||||
AutoloadableFileInfo::EmbeddedPath(_) => &INVALID_FILE_ID,
|
||||
};
|
||||
|
||||
@@ -254,7 +238,6 @@ fn resolve_command_impl(&mut self, cmd: &wstr, paths: &[WString]) -> AutoloadRes
|
||||
.insert(cmd.to_owned(), file_id.clone());
|
||||
AutoloadResult::Path(match file {
|
||||
AutoloadableFileInfo::FileInfo(path) => AutoloadPath::Path(path.path),
|
||||
#[cfg(feature = "embed-data")]
|
||||
AutoloadableFileInfo::EmbeddedPath(path) => AutoloadPath::Embedded(path),
|
||||
})
|
||||
}
|
||||
@@ -277,7 +260,6 @@ enum AutoloadableFileInfo {
|
||||
/// An on-disk file.
|
||||
FileInfo(FileInfo),
|
||||
/// An embedded file.
|
||||
#[cfg(feature = "embed-data")]
|
||||
EmbeddedPath(String),
|
||||
}
|
||||
|
||||
@@ -340,24 +322,15 @@ fn check(
|
||||
cmd: &wstr,
|
||||
allow_stale: bool,
|
||||
) -> Option<AutoloadableFileInfo> {
|
||||
let asset_dir =
|
||||
cfg!(feature = "embed-data")
|
||||
.then_some(())
|
||||
.and_then(|()| match env_var_name {
|
||||
s if s == "fish_function_path" => Some(AssetDir::Functions),
|
||||
s if s == "fish_complete_path" => Some(AssetDir::Completions),
|
||||
_ => None,
|
||||
});
|
||||
let asset_dir = match env_var_name {
|
||||
s if s == "fish_function_path" => Some(AssetDir::Functions),
|
||||
s if s == "fish_complete_path" => Some(AssetDir::Completions),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
// Check hits.
|
||||
if let Some(value) = self.known_files.get(cmd) {
|
||||
cfg_if!(
|
||||
if #[cfg(feature = "embed-data")] {
|
||||
let embedded = matches!(value.file, AutoloadableFileInfo::EmbeddedPath(_));
|
||||
} else {
|
||||
let embedded = false;
|
||||
}
|
||||
);
|
||||
let embedded = matches!(value.file, AutoloadableFileInfo::EmbeddedPath(_));
|
||||
if allow_stale
|
||||
|| embedded
|
||||
|| Self::is_fresh(value.last_checked, Self::current_timestamp())
|
||||
@@ -465,11 +438,6 @@ fn locate_file(
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "embed-data"))]
|
||||
fn locate_asset(&self, _cmd: &wstr, _asset_dir: AssetDir) -> Option<AutoloadableFileInfo> {
|
||||
None
|
||||
}
|
||||
#[cfg(feature = "embed-data")]
|
||||
fn locate_asset(&self, cmd: &wstr, asset_dir: AssetDir) -> Option<AutoloadableFileInfo> {
|
||||
// HACK: In cargo tests, this used to never load functions
|
||||
// It will hang for reasons unrelated to this.
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use fish::{
|
||||
ast,
|
||||
builtins::{
|
||||
@@ -164,36 +163,16 @@ fn source_config_in_directory(parser: &Parser, dir: &wstr) -> bool {
|
||||
|
||||
/// Parse init files. exec_path is the path of fish executable as determined by argv[0].
|
||||
fn read_init(parser: &Parser, paths: &ConfigPaths) {
|
||||
cfg_if!(
|
||||
if #[cfg(feature = "embed-data")] {
|
||||
use fish::autoload::Asset;
|
||||
let emfile = Asset::get("config.fish").expect("Embedded file not found");
|
||||
let src = bytes2wcstring(&emfile.data);
|
||||
parser.libdata_mut().within_fish_init = true;
|
||||
let fname: Arc<WString> = Arc::new(L!("embedded:config.fish").into());
|
||||
let ret = parser.eval_file_wstr(src, fname, &IoChain::new(), None);
|
||||
parser.libdata_mut().within_fish_init = false;
|
||||
if let Err(msg) = ret {
|
||||
eprintf!("%s", msg);
|
||||
}
|
||||
} else {
|
||||
let datapath = bytes2wcstring(paths.data.as_ref().unwrap().as_os_str().as_bytes());
|
||||
if !source_config_in_directory(parser, &datapath) {
|
||||
// If we cannot read share/config.fish, our internal configuration,
|
||||
// something is wrong.
|
||||
// That also means that our functions won't be found,
|
||||
// and so any config we get would almost certainly be broken.
|
||||
let escaped_pathname = escape(&datapath);
|
||||
FLOGF!(
|
||||
error,
|
||||
"Fish cannot find its asset files in '%s'.\n\
|
||||
Refusing to read configuration because of this.",
|
||||
escaped_pathname,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
);
|
||||
use fish::autoload::Asset;
|
||||
let emfile = Asset::get("config.fish").expect("Embedded file not found");
|
||||
let src = bytes2wcstring(&emfile.data);
|
||||
parser.libdata_mut().within_fish_init = true;
|
||||
let fname: Arc<WString> = Arc::new(L!("embedded:config.fish").into());
|
||||
let ret = parser.eval_file_wstr(src, fname, &IoChain::new(), None);
|
||||
parser.libdata_mut().within_fish_init = false;
|
||||
if let Err(msg) = ret {
|
||||
eprintf!("%s", msg);
|
||||
}
|
||||
|
||||
source_config_in_directory(
|
||||
parser,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
use crate::wutil::{Error, waccess, wbasename, wdirname, wrealpath};
|
||||
use cfg_if::cfg_if;
|
||||
use libc::F_OK;
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
macro_rules! str_enum {
|
||||
($name:ident, $(($val:ident, $str:expr)),* $(,)?) => {
|
||||
@@ -332,10 +333,6 @@ fn parse_cmd_opts(
|
||||
return Ok(SUCCESS);
|
||||
}
|
||||
|
||||
#[cfg(feature = "embed-data")]
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
#[cfg(feature = "embed-data")]
|
||||
cfg_if!(
|
||||
if #[cfg(use_prebuilt_docs)] {
|
||||
#[derive(RustEmbed)]
|
||||
@@ -350,7 +347,7 @@ fn parse_cmd_opts(
|
||||
}
|
||||
);
|
||||
|
||||
#[cfg(all(using_cmake, feature = "embed-data"))]
|
||||
#[cfg(using_cmake)]
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "$FISH_CMAKE_BINARY_DIR/share"]
|
||||
#[include = "__fish_build_paths.fish"]
|
||||
@@ -491,76 +488,58 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
|
||||
));
|
||||
return Err(STATUS_INVALID_ARGS);
|
||||
}
|
||||
let arg = crate::common::wcs2bytes(args[0]);
|
||||
let arg = std::str::from_utf8(&arg).unwrap();
|
||||
cfg_if!(
|
||||
if #[cfg(not(feature = "embed-data"))] {
|
||||
streams
|
||||
.err
|
||||
.appendln(sprintf!(NO_EMBEDDED_FILES_MSG.localize(), cmd));
|
||||
return Err(STATUS_CMD_ERROR);
|
||||
if #[cfg(using_cmake)] {
|
||||
let emfile = CMakeBinaryDir::get(arg);
|
||||
} else {
|
||||
let arg = crate::common::wcs2bytes(args[0]);
|
||||
let arg = std::str::from_utf8(&arg).unwrap();
|
||||
cfg_if!(
|
||||
if #[cfg(using_cmake)] {
|
||||
let emfile = CMakeBinaryDir::get(arg);
|
||||
} else {
|
||||
let emfile = None;
|
||||
}
|
||||
);
|
||||
let Some(emfile) = emfile
|
||||
.or_else(|| crate::autoload::Asset::get(arg))
|
||||
.or_else(|| Docs::get(arg))
|
||||
else {
|
||||
return Err(STATUS_CMD_ERROR);
|
||||
};
|
||||
let src = bytes2wcstring(&emfile.data);
|
||||
streams.out.append(src);
|
||||
return Ok(SUCCESS);
|
||||
let emfile = None;
|
||||
}
|
||||
);
|
||||
let Some(emfile) = emfile
|
||||
.or_else(|| crate::autoload::Asset::get(arg))
|
||||
.or_else(|| Docs::get(arg))
|
||||
else {
|
||||
return Err(STATUS_CMD_ERROR);
|
||||
};
|
||||
let src = bytes2wcstring(&emfile.data);
|
||||
streams.out.append(src);
|
||||
return Ok(SUCCESS);
|
||||
}
|
||||
STATUS_LIST_FILES => {
|
||||
cfg_if!(
|
||||
if #[cfg(not(feature = "embed-data"))] {
|
||||
streams
|
||||
.err
|
||||
.appendln(sprintf!(NO_EMBEDDED_FILES_MSG.localize(), cmd));
|
||||
return Err(STATUS_CMD_ERROR);
|
||||
} else {
|
||||
use crate::util::wcsfilecmp_glob;
|
||||
let mut paths = vec![];
|
||||
let mut add = |arg| {
|
||||
let arg = crate::common::wcs2bytes(arg);
|
||||
let arg = std::str::from_utf8(&arg).unwrap();
|
||||
let embedded_files = crate::autoload::Asset::iter().chain(Docs::iter());
|
||||
#[cfg(using_cmake)]
|
||||
let embedded_files = embedded_files.chain(CMakeBinaryDir::iter());
|
||||
for path in embedded_files {
|
||||
if arg.is_empty() || path.starts_with(arg) {
|
||||
paths.push(bytes2wcstring(path.as_bytes()));
|
||||
}
|
||||
}
|
||||
};
|
||||
if args.is_empty() {
|
||||
add(L!(""));
|
||||
} else {
|
||||
for arg in args {
|
||||
add(arg);
|
||||
}
|
||||
}
|
||||
|
||||
paths.sort_by(|a, b| wcsfilecmp_glob(a, b));
|
||||
for path in &paths {
|
||||
streams.out.appendln(path);
|
||||
}
|
||||
|
||||
if !paths.is_empty() {
|
||||
return Ok(SUCCESS);
|
||||
} else {
|
||||
return Err(STATUS_CMD_ERROR);
|
||||
use crate::util::wcsfilecmp_glob;
|
||||
let mut paths = vec![];
|
||||
let mut add = |arg| {
|
||||
let arg = crate::common::wcs2bytes(arg);
|
||||
let arg = std::str::from_utf8(&arg).unwrap();
|
||||
let embedded_files = crate::autoload::Asset::iter().chain(Docs::iter());
|
||||
#[cfg(using_cmake)]
|
||||
let embedded_files = embedded_files.chain(CMakeBinaryDir::iter());
|
||||
for path in embedded_files {
|
||||
if arg.is_empty() || path.starts_with(arg) {
|
||||
paths.push(bytes2wcstring(path.as_bytes()));
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
if args.is_empty() {
|
||||
add(L!(""));
|
||||
} else {
|
||||
for arg in args {
|
||||
add(arg);
|
||||
}
|
||||
}
|
||||
|
||||
paths.sort_by(|a, b| wcsfilecmp_glob(a, b));
|
||||
for path in &paths {
|
||||
streams.out.appendln(path);
|
||||
}
|
||||
|
||||
if !paths.is_empty() {
|
||||
return Ok(SUCCESS);
|
||||
} else {
|
||||
return Err(STATUS_CMD_ERROR);
|
||||
}
|
||||
}
|
||||
c @ STATUS_TEST_TERMINAL_FEATURE => {
|
||||
if args.len() != 1 {
|
||||
@@ -624,8 +603,6 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
|
||||
streams.out.appendln(profile);
|
||||
streams.out.append(L!("Features: "));
|
||||
let features: &[&str] = &[
|
||||
#[cfg(feature = "embed-data")]
|
||||
"embed-data",
|
||||
#[cfg(feature = "localize-messages")]
|
||||
"localize-messages",
|
||||
#[cfg(target_feature = "crt-static")]
|
||||
@@ -758,7 +735,6 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B
|
||||
streams.out.appendln(result);
|
||||
}
|
||||
STATUS_HELP_SECTIONS => {
|
||||
#[cfg(feature = "embed-data")]
|
||||
streams
|
||||
.out
|
||||
.append_narrow(fish_build_man_pages::HELP_SECTIONS);
|
||||
|
||||
8
src/env/config_paths.rs
vendored
8
src/env/config_paths.rs
vendored
@@ -9,12 +9,10 @@
|
||||
/// A struct of configuration directories, determined in main() that fish will optionally pass to
|
||||
/// env_init.
|
||||
pub struct ConfigPaths {
|
||||
pub sysconf: PathBuf, // e.g., /usr/local/etc
|
||||
pub bin: Option<PathBuf>, // e.g., /usr/local/bin
|
||||
/// Always present if "embed-data" is disabled.
|
||||
pub sysconf: PathBuf, // e.g., /usr/local/etc
|
||||
pub bin: Option<PathBuf>, // e.g., /usr/local/bin
|
||||
pub data: Option<PathBuf>, // e.g., /usr/local/share
|
||||
/// Always present if "embed-data" is disabled.
|
||||
pub doc: Option<PathBuf>, // e.g., /usr/local/share/doc/fish
|
||||
pub doc: Option<PathBuf>, // e.g., /usr/local/share/doc/fish
|
||||
}
|
||||
|
||||
const SYSCONF_DIR: &str = env!("SYSCONFDIR");
|
||||
|
||||
8
src/env/environment.rs
vendored
8
src/env/environment.rs
vendored
@@ -646,13 +646,7 @@ pub fn env_init(paths: Option<&ConfigPaths>, do_uvars: bool, default_paths: bool
|
||||
set_path(FISH_SYSCONFDIR_VAR, Some(&paths.sysconf));
|
||||
set_path(FISH_BIN_DIR, paths.bin.as_ref());
|
||||
|
||||
let datadir = paths.data.as_ref();
|
||||
set_path(FISH_DATADIR_VAR, datadir);
|
||||
if !cfg!(feature = "embed-data") && default_paths {
|
||||
let mut scstr = datadir.unwrap().clone();
|
||||
scstr.push("functions");
|
||||
set_path(L!("fish_function_path"), Some(&scstr));
|
||||
}
|
||||
set_path(FISH_DATADIR_VAR, paths.data.as_ref());
|
||||
set_path(FISH_HELPDIR_VAR, paths.doc.as_ref());
|
||||
}
|
||||
|
||||
|
||||
@@ -336,7 +336,6 @@ pub fn get_names(get_hidden: bool, vars: &dyn Environment) -> Vec<WString> {
|
||||
names.insert(name.clone());
|
||||
}
|
||||
|
||||
#[cfg(feature = "embed-data")]
|
||||
for name in crate::autoload::Asset::iter() {
|
||||
let Some(bname) = name.strip_prefix("functions/") else {
|
||||
continue;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Test all completions where the command exists
|
||||
|
||||
# No output is good output
|
||||
for f in (__fish_data_list_files completions | string match 'completions/*.fish')
|
||||
for f in (status list-files completions | string match 'completions/*.fish')
|
||||
if type -q (string replace -r '.*/([^/]+).fish' '$1' $f)
|
||||
set -l out (__fish_data_with_file $f source 2>&1 | string collect)
|
||||
test -n "$out"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# RUN: %fish -d config | grep -v ^Debug.enabled.for.category
|
||||
# REQUIRES: %fish -c 'status build-info' | grep '^Features:.*embed-data'
|
||||
# REQUIRES: %fish -d config -c '' 2>| grep 'Running out of build directory'
|
||||
|
||||
# CHECKERR: config: executable path: {{.*}}/fish
|
||||
@@ -6,7 +6,6 @@ __fish_data_with_file functions/__fish_print_help.fish source
|
||||
# REQUIRES: command -v sphinx-build
|
||||
# REQUIRES: command -v man
|
||||
# REQUIRES: test "$FISH_BUILD_DOCS" != "0"
|
||||
# REQUIRES: %fish -c 'status build-info' | grep '^Features:.*embed-data'
|
||||
|
||||
set -l deroff col -b -p -x
|
||||
|
||||
|
||||
Reference in New Issue
Block a user