Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building fish as self-installable #10367

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -63,6 +63,7 @@ function(FISH_LINK_DEPS_AND_SIGN target)
build --bin ${target}
$<$<CONFIG:Release,RelWithDebInfo>:--release>
--target ${Rust_CARGO_TARGET}
--no-default-features
${CARGO_FLAGS}
${FEATURES_ARG}
&&
Expand Down
137 changes: 137 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Expand Up @@ -38,6 +38,7 @@ once_cell = "1.17.0"
rand = { version = "0.8.5", features = ["small_rng"] }
widestring = "1.0.2"
terminfo = { git = "https://github.com/meh/rust-terminfo", rev = "7259f5aa5786a9d396162da0d993e268f6163fb2" }
rust-embed = { version = "8.2.0", optional = true }

[dev-dependencies]
rand_pcg = "0.3.1"
Expand All @@ -64,8 +65,9 @@ name = "fish_key_reader"
path = "src/bin/fish_key_reader.rs"

[features]
default = []
default = ["installable"]
benchmark = []
installable = ["dep:rust-embed"]

# The following features are auto-detected by the build-script and should not be enabled manually.
asan = []
Expand Down
24 changes: 22 additions & 2 deletions build.rs
Expand Up @@ -176,7 +176,14 @@ fn setup_paths() {
var
}

let prefix = PathBuf::from(env::var("PREFIX").unwrap_or("/usr/local".to_string()));
let (prefix_from_home, prefix) = if let Ok(pre) = env::var("PREFIX") {
(false, PathBuf::from(pre))
} else if let Ok(home) = env::var("HOME") {
(true, PathBuf::from(home).join(".local/"))
} else {
panic!("Need either $PREFIX or $HOME");
};

if prefix.is_relative() {
panic!("Can't have relative prefix");
}
Expand All @@ -187,11 +194,24 @@ fn setup_paths() {
rsconf::set_env_value("DATADIR", datadir.to_str().unwrap());
rsconf::rebuild_if_env_changed("DATADIR");

let datadir_subdir = if prefix_from_home {
"fish/install"
} else {
"fish"
};
rsconf::set_env_value("DATADIR_SUBDIR", datadir_subdir);

let bindir = get_path("BINDIR", "bin/", prefix.clone());
rsconf::set_env_value("BINDIR", bindir.to_str().unwrap());
rsconf::rebuild_if_env_changed("BINDIR");

let sysconfdir = get_path("SYSCONFDIR", "etc/", datadir.clone());
let sysconfdir = get_path(
"SYSCONFDIR",
// If we get our prefix from $HOME, we should use the system's /etc/
// ~/.local/share/etc/ makes no sense
if prefix_from_home { "/etc/" } else { "etc/" },
datadir.clone(),
);
rsconf::set_env_value("SYSCONFDIR", sysconfdir.to_str().unwrap());
rsconf::rebuild_if_env_changed("SYSCONFDIR");

Expand Down
2 changes: 2 additions & 0 deletions share/functions/fish_config.fish
Expand Up @@ -17,6 +17,8 @@ function fish_config --description "Launch fish's web based configuration"
# Also opened with just `fish_config` or `fish_config browse`.
if contains -- $cmd browse
set -lx __fish_bin_dir $__fish_bin_dir
set -l fish_path (status fish-path)
and set __fish_bin_dir (path dirname -- $fish_path)
if set -l python (__fish_anypython)
$python "$__fish_data_dir/tools/web_config/webconfig.py" $argv

Expand Down