Skip to content

Commit

Permalink
Add detailed information about the current version of OCaml to the Sy…
Browse files Browse the repository at this point in the history
…s module
  • Loading branch information
shindere committed Oct 11, 2021
1 parent 06e3964 commit b8dd296
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ Working version
(Nicolás Ojeda Bär, review by Daniel Bünzli, Jérémie Dimino, Damien Doligez
and Xavier Leroy)

- #10658: add detailed information about the current version of OCaml
to the Sys module of the standard library.
(Sébastien Hinderer, review by Damien Doligez, Gabriel Scherer, David
Allsopp, Nicolás Ojeda Bär, Vincent Laviron)

### Other libraries:

- #10192: Add support for Unix domain sockets on Windows and use them
Expand Down
5 changes: 5 additions & 0 deletions build-aux/ocaml_version.m4
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ m4_define([OCAML__VERSION_NUMBER],
OCAML__VERSION_MAJOR,
OCAML__VERSION_MINOR,
OCAML__VERSION_PATCHLEVEL)])

m4_define([OCAML__RELEASE_EXTRA],
m4_if(OCAML__VERSION_EXTRA,[],[None],
['Some (]m4_if(OCAML__VERSION_EXTRA_PREFIX,+,[Plus],
[Tilde])[, "]OCAML__VERSION_EXTRA[")']))]))
3 changes: 3 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ AC_SUBST([CONFIGURE_ARGS])
AC_SUBST([native_compiler])
AC_SUBST([VERSION], [AC_PACKAGE_VERSION])
AC_SUBST([OCAML_DEVELOPMENT_VERSION], [OCAML__DEVELOPMENT_VERSION])
AC_SUBST([OCAML_RELEASE_EXTRA], [OCAML__RELEASE_EXTRA])
AC_SUBST([OCAML_VERSION_MAJOR], [OCAML__VERSION_MAJOR])
AC_SUBST([OCAML_VERSION_MINOR], [OCAML__VERSION_MINOR])
AC_SUBST([OCAML_VERSION_PATCHLEVEL], [OCAML__VERSION_PATCHLEVEL])
Expand Down
20 changes: 20 additions & 0 deletions stdlib/sys.ml.in
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ external runtime_warnings_enabled: unit -> bool =

let ocaml_version = "@VERSION@"

let development_version = @OCAML_DEVELOPMENT_VERSION@

type extra_prefix = Plus | Tilde

type extra_info = extra_prefix * string

type ocaml_release_info = {
major : int;
minor : int;
patchlevel : int;
extra : extra_info option
}

let ocaml_release = {
major = @OCAML_VERSION_MAJOR@;
minor = @OCAML_VERSION_MINOR@;
patchlevel = @OCAML_VERSION_PATCHLEVEL@;
extra = @OCAML_RELEASE_EXTRA@
}

(* Optimization *)

external opaque_identity : 'a -> 'a = "%opaque"
Expand Down
19 changes: 18 additions & 1 deletion stdlib/sys.mli
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,26 @@ val ocaml_version : string
where [major], [minor], and [patchlevel] are integers, and
[additional-info] is an arbitrary string.
The [[.patchlevel]] part was absent before version 3.08.0 and
became mandatory from 3.08.0 (included) onwards.
became mandatory from 3.08.0 onwards.
The [[(+|~)additional-info]] part may be absent. *)

val development_version : bool
(** [true] if this is a development version, [false] otherwise.
@since 4.14.0
*)

type extra_prefix = Plus | Tilde

type extra_info = extra_prefix * string

type ocaml_release_info = {
major : int;
minor : int;
patchlevel : int;
extra : extra_info option
}

val ocaml_release : ocaml_release_info

val enable_runtime_warnings: bool -> unit
(** Control whether the OCaml runtime system can emit warnings
Expand Down

0 comments on commit b8dd296

Please sign in to comment.