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

Generate version.ml from satysfi.opam to make releasing easy #419

Merged
merged 2 commits into from
Feb 5, 2024
Merged
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
5 changes: 5 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
@@ -39,6 +39,11 @@
(modules parser dataParser)
(flags (--table --explain)))

(rule
(targets version.ml)
(deps ../tools/genversion/genversion.exe (:src ../satysfi.opam))
(action (with-stdout-to %{targets} (run %{deps}))))

(rule
(targets types.ml)
(deps (:src types.cppo.ml) __insttype.gen.ml __attype.gen.ml __codetype.gen.ml __unliftcode.gen.ml)
2 changes: 1 addition & 1 deletion src/frontend/main.ml
Original file line number Diff line number Diff line change
@@ -1006,7 +1006,7 @@ let error_log_environment suspended =

let arg_version () =
print_string (
" SATySFi version 0.0.10\n"
(Printf.sprintf " SATySFi version %s\n" Version.version)
(*
^ " (in the middle of the transition from Macrodown)\n"
^ " ____ ____ ________ _____ ______\n"
3 changes: 3 additions & 0 deletions tools/genversion/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(executable
(name genversion)
(libraries str))
1 change: 1 addition & 0 deletions tools/genversion/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 1.0)
21 changes: 21 additions & 0 deletions tools/genversion/genversion.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let version_regex = Str.regexp {|^version: ?"\([0-9]+\.[0-9]+\.[0-9]+\)"$|}

let () =
let version = ref "" in
let opam_file_path = Sys.argv.(1) in
let channel_in = open_in opam_file_path in
let search_version () =
let cond = ref true in
while !cond do
let line = input_line channel_in in
try
let _ = Str.search_forward version_regex line 0 in
version := Str.matched_group 1 line;
cond := false
with Not_found ->
()
done
in
search_version ();
close_in channel_in;
print_endline ("let version = \"" ^ !version ^ "\"")