serpent-os / boulder-d-legacy

Replaced by Rust tooling
https://serpentos.com
21 stars 7 forks source link

Add compiled version & git hash to version command #88

Closed tarkah closed 1 year ago

tarkah commented 1 year ago

Resolves #84

I'm not super familiar with meson, so I'm not sure if this is the best way to pass these values in.

This adds a new environment module which contains two new environment variables that are populated during compile by meson.

GIT_VERSION won't be present when compiling from a tarball / archive, only from the repo. Formatted version takes this into account and only includes it if available. The git hash also includes -dirty if the repo is dirty.

See output below of compiling on clean branch, dirty branch and after removing .git folder.

image

livingsilver94 commented 1 year ago

Serpent OS supports both Meson and Dub as build systems. It is my understanding here that you only addressed Meson.

tarkah commented 1 year ago

Ahh right, thanks for pointing that out.

I'll need to think on this some more and familiarize myself with both build systems. I'm moving this to draft for the meantime.

If anyone knows a more idiomatic way to do this, please let me know!

tarkah commented 1 year ago

I've landed on an implementation that works for both dub and meson.

I'm not 100% thrilled with the implementation but I couldn't figure out a better way to handle this within the constraints of both build systems.

Note there seems to be an issue with meson where if ./build/environment file exists, it'll use that as the string import instead of the file placed under build. I couldn't figure out how to prevent this with meson.

image

ermo commented 1 year ago

@tarkah Any chance for a rebase?

@Ikey I think we should get this in as soon as the rebase is done?

tarkah commented 1 year ago

@ermo I've rebased and made a change to exclude tags, since it's overly verbose as we already show version:

Before

boulder, version 1.0.1 (v1.0.1-6-gf879fb5)

After

boulder, version 1.0.1 (52c8064) boulder, version 1.0.1 (f879fb5-dirty)