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

Use git describe to display version #437

Merged
merged 2 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ audio = sdl# sdl, coreaudio
kvm = false
pcap = false

export MOROS_KEYBOARD = $(keyboard)
export MOROS_VERSION = $(shell git describe --tags | sed "s/^v//")
export MOROS_MEMORY = $(memory)
export MOROS_KEYBOARD = $(keyboard)

# Build userspace binaries
user-nasm:
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn init(boot_info: &'static BootInfo) {
sys::keyboard::init();
sys::time::init();

log!("MOROS v{}\n", env!("CARGO_PKG_VERSION"));
log!("MOROS v{}\n", option_env!("MOROS_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")));
sys::mem::init(boot_info);
sys::cpu::init();
sys::pci::init(); // Require MEM
Expand Down
6 changes: 6 additions & 0 deletions src/usr/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ fn cmd_unset(args: &[&str], config: &mut Config) -> Result<(), ExitCode> {
Ok(())
}

fn cmd_version(_args: &[&str]) -> Result<(), ExitCode> {
println!("MOROS v{}", option_env!("MOROS_VERSION").unwrap_or(env!("CARGO_PKG_VERSION")));
Ok(())
}

fn exec_with_config(cmd: &str, config: &mut Config) -> Result<(), ExitCode> {
#[cfg(test)] // FIXME: tests with `print foo => /bar` are failing without that
sys::console::print_fmt(format_args!(""));
Expand Down Expand Up @@ -483,6 +488,7 @@ fn exec_with_config(cmd: &str, config: &mut Config) -> Result<(), ExitCode> {
"time" => usr::time::main(&args),
"unalias" => cmd_unalias(&args, config),
"unset" => cmd_unset(&args, config),
"version" => cmd_version(&args),
"user" => usr::user::main(&args),
"vga" => usr::vga::main(&args),
"write" => usr::write::main(&args),
Expand Down