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 8, 2021
1 parent bacae64 commit 8a4a85e
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
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 @@ -84,3 +84,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
17 changes: 17 additions & 0 deletions stdlib/sys.mli
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,23 @@ val ocaml_version : string
became mandatory from 3.08.0 (included) 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 8a4a85e

Please sign in to comment.