add auto-generated Version module to main lib

This commit is contained in:
Simon Cruanes 2026-03-06 11:32:08 -05:00
parent b92159c11e
commit ba264c7094
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
4 changed files with 19 additions and 0 deletions

View file

@ -1,3 +1,10 @@
(rule
(target version.ml)
(deps (universe) gen_version.sh)
(action
(with-stdout-to version.ml
(run sh gen_version.sh))))
(library
(name opentelemetry)
(public_name opentelemetry)

6
src/lib/gen_version.sh Normal file
View file

@ -0,0 +1,6 @@
#!/bin/sh
v=$(git describe --exact-match HEAD 2>/dev/null | sed 's/^v//')
[ -z "$v" ] && v=dev
h=$(git rev-parse HEAD 2>/dev/null)
[ -z "$h" ] && h=unknown
printf 'let version = "%s"\nlet git_hash = "%s"\n' "$v" "$h"

View file

@ -100,6 +100,7 @@ type key_value = Key_value.t
(** {2 Global settings} *)
module Globals = Globals
module Version = Version
(** {2 Traces and Spans} *)

5
src/lib/version.mli Normal file
View file

@ -0,0 +1,5 @@
val version : string
(** Version of the library, e.g. ["0.12"]. ["dev"] if not built from a release tag. *)
val git_hash : string
(** Full git commit hash at build time, e.g. ["b92159c1..."]. ["unknown"] if git was unavailable. *)