use some sneaky codegen to get the 'version' variable

This commit is contained in:
tali 2024-02-01 14:33:34 -05:00
parent b92d84f843
commit e355bac41c
2 changed files with 12 additions and 6 deletions

View File

@ -6,3 +6,10 @@
logging irc data)
(inline_tests)
(preprocess (pps ppx_expect)))
(rule
(package talircd)
(target "meta_server_info.ml")
(action
(with-stdout-to %{target}
(echo "let version = \"%{version:talircd}\";;"))))

View File

@ -1,4 +1,7 @@
open! Import
include (Meta_server_info : sig
val version : string
end)
let tz_offset_s = Ptime_clock.current_tz_offset_s ()
let pp_time = Ptime.pp_human () ?tz_offset_s
@ -37,15 +40,11 @@ let default_conf = {
init_cmode = Mode.Set.of_list [`n; `s; `t];
}
let admin_info = "the admin of this server is @iitalics@octodon.social"
let version = "0.0.0"
(* TODO: generate version string at build time? *)
let make ?(conf = default_conf) ~hostname ~motd () = {
version = version;
version;
created = Fmt.str "%a" pp_time (Ptime_clock.now ());
admin_info = "the admin of this server is @iitalics@octodon.social";
hostname;
admin_info;
motd;
conf;
}