diff --git a/Makefile.generating b/Makefile.generating index a369e8ae688bdf5c7b4cf4707038da8b8b1b49a5..eece5c22c89475fbafcc4e7e782bbcb995f11924 100644 --- a/Makefile.generating +++ b/Makefile.generating @@ -41,6 +41,8 @@ tests/ptests_config: Makefile.generating share/Makefile.config $(CHMOD_RO) $@ ALL_LIBRARY_NAMES=$(shell ocamlfind query -r -p-format $(LIBRARY_NAMES) $(LIBRARY_NAMES_GUI)) +MAJOR_VERSION=$(shell $(SED) 's/^\([0-9]\+\)\..*/\1/' VERSION) +MINOR_VERSION=$(shell $(SED) 's/^[0-9]\+\.\([0-9]\+\).*/\1/' VERSION) $(CONFIG_FILE): $(CONFIG_FILE).in VERSION VERSION_CODENAME share/Makefile.config Makefile.generating configure.in $(SED) \ @@ -64,6 +66,8 @@ $(CONFIG_FILE): $(CONFIG_FILE).in VERSION VERSION_CODENAME share/Makefile.config -e "s|@OPTDOT@|$(OPTDOT)|" \ -e "s|@HAS_YOJSON@|$(if $(filter yes,$(HAS_YOJSON)),true,false)|" \ -e "s|@EXE@|$(EXE)|" \ + -e "s|@MAJOR_VERSION@|$(MAJOR_VERSION)|" \ + -e "s|@MINOR_VERSION@|$(MINOR_VERSION)|" \ $< > $@.tmp @touch -r $@.tmp $< $(CP_IF_DIFF) $@.tmp $@ diff --git a/src/kernel_internals/runtime/config.ml.in b/src/kernel_internals/runtime/config.ml.in index c51c4c0be3c415f1016b6ff4eed58d050191ac32..3ae6289122723981aef42c1fe98eb370b968339a 100644 --- a/src/kernel_internals/runtime/config.ml.in +++ b/src/kernel_internals/runtime/config.ml.in @@ -26,6 +26,10 @@ let version = "@VERSION@" let codename = "@VERSION_CODENAME@" let version_and_codename = version ^ " (" ^ codename ^ ")" +let major_version = @MAJOR_VERSION@ + +let minor_version = @MINOR_VERSION@ + let is_gui = ref false let ocamlc = "@OCAMLC@" diff --git a/src/kernel_internals/runtime/config.mli b/src/kernel_internals/runtime/config.mli index 2d49810b265d24d7e86ea0f63a62cf3e40ec605c..1b0e5313f475883982645d517506589dbe3ebb7e 100644 --- a/src/kernel_internals/runtime/config.mli +++ b/src/kernel_internals/runtime/config.mli @@ -34,6 +34,14 @@ val version_and_codename: string (** Frama-C version and codename. @since Frama-C+dev *) +val major_version: int +(** Frama-C major version number. + @since Frama-C+dev *) + +val minor_version: int +(** Frama-C minor version number. + @since Frama-C+dev *) + val is_gui: bool ref (** Is the Frama-C GUI running? @since Beryllium-20090601-beta1 *) diff --git a/tests/misc/oracle/version.res.oracle b/tests/misc/oracle/version.res.oracle new file mode 100644 index 0000000000000000000000000000000000000000..61e48a31ac52c036665f929dc09f396fce446ed5 --- /dev/null +++ b/tests/misc/oracle/version.res.oracle @@ -0,0 +1,2 @@ +[kernel] Parsing tests/misc/version.i (no preprocessing) +[kernel] version numbers match diff --git a/tests/misc/version.i b/tests/misc/version.i new file mode 100644 index 0000000000000000000000000000000000000000..cd0bcd0bf8696a3febda5e79680981cf9a2aed9d --- /dev/null +++ b/tests/misc/version.i @@ -0,0 +1,3 @@ +/* run.config + OPT: -load-script tests/misc/version.ml +*/ diff --git a/tests/misc/version.ml b/tests/misc/version.ml new file mode 100644 index 0000000000000000000000000000000000000000..2105830a936e06aa098150218820272fab0a82b7 --- /dev/null +++ b/tests/misc/version.ml @@ -0,0 +1,20 @@ +let re_version = Str.regexp "^\\([0-9]+\\)\\.\\([0-9]+\\)" + +let run () = + let version_str = Config.version in + if Str.string_match re_version version_str 0 then + let major = Str.matched_group 1 version_str in + let minor = Str.matched_group 2 version_str in + if major = string_of_int Config.major_version && + minor = string_of_int Config.minor_version + then + Kernel.feedback "version numbers match" + else + Kernel.abort + "error parsing major/minor version: expected %s.%s, got %d.%d" + major minor Config.major_version Config.minor_version + else + Kernel.abort + "could not parse Config.version" + +let () = Db.Main.extend run