logging: include version information
This commit is contained in:
parent
f35a7f691a
commit
14b344a1ae
5 changed files with 31 additions and 0 deletions
|
|
@ -1,5 +1,30 @@
|
||||||
|
use {
|
||||||
|
crate::open,
|
||||||
|
std::{fmt::Write as _, io::Write as _, process::Command},
|
||||||
|
};
|
||||||
|
|
||||||
pub fn main() -> anyhow::Result<()> {
|
pub fn main() -> anyhow::Result<()> {
|
||||||
|
create_bridge()?;
|
||||||
|
create_version()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_bridge() -> anyhow::Result<()> {
|
||||||
println!("cargo:rerun-if-changed=src/bridge.c");
|
println!("cargo:rerun-if-changed=src/bridge.c");
|
||||||
cc::Build::new().file("src/bridge.c").compile("bridge");
|
cc::Build::new().file("src/bridge.c").compile("bridge");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_version() -> anyhow::Result<()> {
|
||||||
|
let mut version_string = env!("CARGO_PKG_VERSION").to_string();
|
||||||
|
if let Ok(output) = Command::new("git").arg("rev-parse").arg("HEAD").output() {
|
||||||
|
if output.status.success() {
|
||||||
|
if let Ok(commit) = std::str::from_utf8(&output.stdout) {
|
||||||
|
write!(version_string, " ({})", commit.trim())?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut f = open("version.rs")?;
|
||||||
|
writeln!(f, "pub const VERSION: &str = \"{}\";", version_string)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ use {
|
||||||
oserror::OsError, queue::AsyncQueue, refcounted::RefCounted, run_toplevel::RunToplevel,
|
oserror::OsError, queue::AsyncQueue, refcounted::RefCounted, run_toplevel::RunToplevel,
|
||||||
tri::Try,
|
tri::Try,
|
||||||
},
|
},
|
||||||
|
version::VERSION,
|
||||||
video::drm::wait_for_sync_obj::WaitForSyncObj,
|
video::drm::wait_for_sync_obj::WaitForSyncObj,
|
||||||
wheel::{Wheel, WheelError},
|
wheel::{Wheel, WheelError},
|
||||||
xkbcommon::XkbContext,
|
xkbcommon::XkbContext,
|
||||||
|
|
@ -122,6 +123,7 @@ fn start_compositor2(
|
||||||
test_future: Option<TestFuture>,
|
test_future: Option<TestFuture>,
|
||||||
) -> Result<(), CompositorError> {
|
) -> Result<(), CompositorError> {
|
||||||
log::info!("pid = {}", uapi::getpid());
|
log::info!("pid = {}", uapi::getpid());
|
||||||
|
log::info!("version = {VERSION}");
|
||||||
init_fd_limit();
|
init_fd_limit();
|
||||||
leaks::init();
|
leaks::init();
|
||||||
clientmem::init()?;
|
clientmem::init()?;
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ mod tree;
|
||||||
mod udev;
|
mod udev;
|
||||||
mod user_session;
|
mod user_session;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
mod version;
|
||||||
mod video;
|
mod video;
|
||||||
mod wheel;
|
mod wheel;
|
||||||
mod wire;
|
mod wire;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ use {
|
||||||
run_toplevel::RunToplevel,
|
run_toplevel::RunToplevel,
|
||||||
xrd::xrd,
|
xrd::xrd,
|
||||||
},
|
},
|
||||||
|
version::VERSION,
|
||||||
video::dmabuf::DmaBufIds,
|
video::dmabuf::DmaBufIds,
|
||||||
wheel::Wheel,
|
wheel::Wheel,
|
||||||
wire_dbus::org,
|
wire_dbus::org,
|
||||||
|
|
@ -226,6 +227,7 @@ async fn init_dbus_session(dbus: &Dbus, logger: Arc<Logger>) -> Rc<DbusSocket> {
|
||||||
Ok(r) if r.get().rv == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER => {
|
Ok(r) if r.get().rv == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER => {
|
||||||
log::info!("Acquired unique name {}", UNIQUE_NAME);
|
log::info!("Acquired unique name {}", UNIQUE_NAME);
|
||||||
logger.redirect("portal");
|
logger.redirect("portal");
|
||||||
|
log::info!("version = {VERSION}");
|
||||||
let fork = match fork_with_pidfd(false) {
|
let fork = match fork_with_pidfd(false) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => fatal!("Could not fork: {}", ErrorFmt(e)),
|
Err(e) => fatal!("Could not fork: {}", ErrorFmt(e)),
|
||||||
|
|
|
||||||
1
src/version.rs
Normal file
1
src/version.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/version.rs"));
|
||||||
Loading…
Add table
Add a link
Reference in a new issue