mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-26 03:35:17 +00:00
Add status buildinfo
This can be used to get some information on how fish was built - the version, the build system, the operating system and architecture, the features.
This commit is contained in:
parent
0083192fcb
commit
aadcb292b6
3 changed files with 51 additions and 1 deletions
5
build.rs
5
build.rs
|
@ -29,6 +29,11 @@ fn main() {
|
|||
.unwrap(),
|
||||
);
|
||||
|
||||
// Some build info
|
||||
rsconf::set_env_value("BUILD_TARGET_TRIPLE", &env::var("TARGET").unwrap());
|
||||
rsconf::set_env_value("BUILD_HOST_TRIPLE", &env::var("HOST").unwrap());
|
||||
rsconf::set_env_value("BUILD_PROFILE", &env::var("PROFILE").unwrap());
|
||||
|
||||
let version = &get_version(&env::current_dir().unwrap());
|
||||
// Per https://doc.rust-lang.org/cargo/reference/build-scripts.html#inputs-to-the-build-script,
|
||||
// the source directory is the current working directory of the build script
|
||||
|
|
|
@ -49,6 +49,8 @@ set(VARS_FOR_CARGO
|
|||
"PREFIX=${CMAKE_INSTALL_PREFIX}"
|
||||
# Temporary hack to propogate CMake flags/options to build.rs.
|
||||
"CMAKE_WITH_GETTEXT=${CMAKE_WITH_GETTEXT}"
|
||||
# Cheesy so we can tell cmake was used to build
|
||||
"CMAKE=1"
|
||||
"DOCDIR=${CMAKE_INSTALL_FULL_DOCDIR}"
|
||||
"DATADIR=${CMAKE_INSTALL_FULL_DATADIR}"
|
||||
"SYSCONFDIR=${CMAKE_INSTALL_FULL_SYSCONFDIR}"
|
||||
|
|
|
@ -57,12 +57,14 @@ enum StatusCmd {
|
|||
STATUS_STACK_TRACE,
|
||||
STATUS_TEST_FEATURE,
|
||||
STATUS_CURRENT_COMMANDLINE,
|
||||
STATUS_BUILDINFO,
|
||||
}
|
||||
|
||||
str_enum!(
|
||||
StatusCmd,
|
||||
(STATUS_BASENAME, "basename"),
|
||||
(STATUS_BASENAME, "current-basename"),
|
||||
(STATUS_BUILDINFO, "buildinfo"),
|
||||
(STATUS_CURRENT_CMD, "current-command"),
|
||||
(STATUS_CURRENT_COMMANDLINE, "current-commandline"),
|
||||
(STATUS_DIRNAME, "current-dirname"),
|
||||
|
@ -420,6 +422,44 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
|
|||
}
|
||||
return retval;
|
||||
}
|
||||
STATUS_BUILDINFO => {
|
||||
let version = str2wcstring(crate::BUILD_VERSION.as_bytes());
|
||||
let target = str2wcstring(env!("BUILD_TARGET_TRIPLE").as_bytes());
|
||||
let host = str2wcstring(env!("BUILD_HOST_TRIPLE").as_bytes());
|
||||
let profile = str2wcstring(env!("BUILD_PROFILE").as_bytes());
|
||||
streams.out.append(L!("Build system: "));
|
||||
let buildsystem = match option_env!("CMAKE") {
|
||||
Some("1") => "CMake",
|
||||
_ => "Cargo",
|
||||
};
|
||||
streams.out.appendln(str2wcstring(buildsystem.as_bytes()));
|
||||
streams.out.append(L!("Version: "));
|
||||
streams.out.appendln(version);
|
||||
if target == host {
|
||||
streams.out.append(L!("Target (and host): "));
|
||||
streams.out.appendln(target);
|
||||
} else {
|
||||
streams.out.append(L!("Target: "));
|
||||
streams.out.appendln(target);
|
||||
streams.out.append(L!("Host: "));
|
||||
streams.out.appendln(host);
|
||||
}
|
||||
streams.out.append(L!("Profile: "));
|
||||
streams.out.appendln(profile);
|
||||
streams.out.append(L!("Features: "));
|
||||
streams.out.appendln(str2wcstring(
|
||||
[
|
||||
#[cfg(gettext)]
|
||||
"gettext",
|
||||
#[cfg(feature = "installable")]
|
||||
"installable",
|
||||
]
|
||||
.join(" ")
|
||||
.as_bytes(),
|
||||
));
|
||||
streams.out.appendln("");
|
||||
return STATUS_CMD_OK;
|
||||
}
|
||||
ref s => {
|
||||
if !args.is_empty() {
|
||||
streams.err.append(wgettext_fmt!(
|
||||
|
@ -558,7 +598,10 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O
|
|||
streams.out.appendln(path);
|
||||
}
|
||||
}
|
||||
STATUS_SET_JOB_CONTROL | STATUS_FEATURES | STATUS_TEST_FEATURE => {
|
||||
STATUS_BUILDINFO
|
||||
| STATUS_SET_JOB_CONTROL
|
||||
| STATUS_FEATURES
|
||||
| STATUS_TEST_FEATURE => {
|
||||
unreachable!("")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue