PR#6406: Expose OCaml version in C headers

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15017 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Damien Doligez 2014-07-21 20:39:38 +00:00
parent 127c288ae5
commit 9ac64ba6a4
5 changed files with 27 additions and 14 deletions

View File

@ -152,7 +152,7 @@ OCamldoc:
(Maxence Guesdon, report by Anil Madhavapeddy)
Bug fixes:
- PR#2719: wrong scheduling of bound checks within a
- PR#2719: wrong scheduling of bound checks within a
try...with Invalid_argument -> _ ... (Xavier Leroy)
- PR#4719: Sys.executable_name wrong if executable name contains dots (Windows)
(Alain Frisch, report by Bart Jacobs)
@ -264,6 +264,8 @@ Features wishes:
(Hongbo Zhang)
- PR#5808: allow simple patterns, not just identifiers, in "let p : t = ..."
(Alain Frisch)
- PR#5899: a programmer-friendly access to backtrace information
(Jacques-Henri Jourdan and Gabriel Scherer)
- PR#6000 comment 9644: add a warning for non-principal coercions to format
(Jacques Garrigue, report by Damien Doligez)
- PR#6054: add support for M.[ foo ], M.[| foo |] etc.
@ -282,8 +284,8 @@ Features wishes:
(Josh Watzman, review by Xavier Clerc and Alain Frisch)
- PR#6358: obey DESTDIR in install targets
(Gabriel Scherer, request by François Berenger)
- PR#5899: a programmer-friendly access to backtrace information
(Jacques-Henri Jourdan and Gabriel Scherer)
- PR#6406: Expose OCaml version in C headers
(Peter Zotov and Romain Calascibetta)
- ocamllex: user-definable refill action
(Frédéric Bour, review by Gabriel Scherer and Luc Maranget)
- shorten syntax for functor signatures: "functor (M1:S1) (M2:S2) .. -> .."

View File

@ -1,4 +1,4 @@
4.03.0+dev0-2014-05-12
4.03.0+dev1-2014-07-21
# The version string is the first line of this file.
# It must be in the format described in stdlib/sys.mli

View File

@ -32,7 +32,8 @@ PRIMS=\
PUBLIC_INCLUDES=\
alloc.h callback.h config.h custom.h fail.h hash.h intext.h \
memory.h misc.h mlvalues.h printexc.h signals.h compatibility.h
memory.h misc.h mlvalues.h printexc.h signals.h compatibility.h \
version.h
all:: ocamlrun$(EXE) ld.conf libcamlrun.$(A) all-$(RUNTIMED)
@ -117,8 +118,8 @@ jumptbl.h : instruct.h
sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \
-e '/^}/q' instruct.h > jumptbl.h
version.h : ../VERSION
echo "#define OCAML_VERSION \"`sed -e 1q ../VERSION`\"" > version.h
version.h : ../VERSION ../tools/make-version-header.sh
../tools/make-version-header.sh ../VERSION > version.h
clean ::
rm -f ocamlrun$(EXE) ocamlrund$(EXE) *.$(O) *.$(A) *.$(SO)

View File

@ -246,10 +246,10 @@ static int parse_command_line(char **argv)
#endif
case 'v':
if (!strcmp (argv[i], "-version")){
printf ("The OCaml runtime, version " OCAML_VERSION "\n");
printf ("The OCaml runtime, version " OCAML_VERSION_STRING "\n");
exit (0);
}else if (!strcmp (argv[i], "-vnum")){
printf (OCAML_VERSION "\n");
printf (OCAML_VERSION_STRING "\n");
exit (0);
}else{
caml_verb_gc = 0x001+0x004+0x008+0x010+0x020;

View File

@ -13,9 +13,6 @@
# #
#########################################################################
# For maximal compatibility with older versions, we Use "ocamlc -v"
# instead of "ocamlc -vnum" or the VERSION file in .../lib/ocaml/.
# This script extracts the components from an OCaml version number
# and provides them as C defines:
# OCAML_VERSION_MAJOR: the major version number
@ -26,7 +23,18 @@
# Note that additional-info is always absent in officially-released
# versions of OCaml.
version="`ocamlc -v | sed -n -e 's/.*version //p'`"
# usage:
# make-version-header.sh [version-file]
# The argument is the VERSION file from the OCaml sources.
# If the argument is not given, the version number from "ocamlc -v" will
# be used.
case $# in
0) version="`ocamlc -v | sed -n -e 's/.*version //p'`";;
1) version="`sed -e 1q $1`";;
*) echo "usage: make-version-header.sh [version-file]" >&2
exit 2;;
esac
major="`echo "$version" | sed -n -e '1s/^\([0-9]*\)\..*/\1/p'`"
minor="`echo "$version" | sed -n -e '1s/^[0-9]*\.\([0-9]*\).*/\1/p'`"
@ -34,10 +42,12 @@ patchlvl="`echo "$version" | sed -n -e '1s/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/p'`"
suffix="`echo "$version" | sed -n -e '1s/^[^+]*+\(.*\)/\1/p'`"
echo "#define OCAML_VERSION_MAJOR $major"
echo "#define OCAML_VERSION_MINOR $minor"
printf "#define OCAML_VERSION_MINOR %d\n" $minor
case $patchlvl in "") patchlvl=0;; esac
echo "#define OCAML_VERSION_PATCHLEVEL $patchlvl"
case "$suffix" in
"") echo "#undef OCAML_VERSION_ADDITIONAL";;
*) echo "#define OCAML_VERSION_ADDITIONAL \"$suffix\"";;
esac
printf "#define OCAML_VERSION %d%02d%02d\n" $major $minor $patchlvl
echo "#define OCAML_VERSION_STRING \"$version\""