Mercurial > octave
changeset 21597:fe1447ae68cf
Add more info to version.m and store build info in the binary (bug #45659)
* build-info.in.cc, build-info.h: New files.
* mk-build-info-h.in.sh: New script.
* configure.ac, Makefile.am: Update.
* module.mk (update_hg_id, libinterp/build-info.cc): New rules.
* version.m: Also return release date. Add input argument.
* toplev.cc (F__octave_config_info__): New fields, builddate, buildtime,
hgid, releasedate.
author | mmuetzel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 08 Apr 2016 21:41:18 +0200 |
parents | 07d30e6fcfde |
children | cf552443c104 |
files | Makefile.am build-aux/mk-build-info-cc.in.sh configure.ac libinterp/build-info.h libinterp/build-info.in.cc libinterp/corefcn/toplev.cc libinterp/module.mk scripts/miscellaneous/version.m |
diffstat | 8 files changed, 203 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile.am Sat Apr 09 06:36:53 2016 +0200 +++ b/Makefile.am Fri Apr 08 21:41:18 2016 +0200 @@ -52,6 +52,7 @@ build-aux/mk-f77-def.in.sh \ build-aux/mk-mxarray-h.in.sh \ build-aux/mk-version-h.in.sh \ + build-aux/mk-build-info-cc.in.sh \ build-aux/mk-octave-config-h.sh \ build-aux/mk-opts.pl \ build-aux/move-if-change \ @@ -69,6 +70,7 @@ build-aux/mk-f77-def.sh \ build-aux/mk-mxarray-h.sh \ build-aux/mk-version-h.sh \ + build-aux/mk-build-info-cc.sh \ build-aux/subst-config-vals.sh \ build-aux/subst-cross-config-vals.sh \ build-aux/subst-default-vals.sh \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build-aux/mk-build-info-cc.in.sh Fri Apr 08 21:41:18 2016 +0200 @@ -0,0 +1,27 @@ +#! /bin/sh +# +# Copyright (C) 2016 M. Muetzel +# +# This file is part of Octave. +# +# Octave is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# Octave is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with Octave; see the file COPYING. If not, see +# <http://www.gnu.org/licenses/>. + +: ${SED=@SED@} + +OCTAVE_HG_ID=$(hg identify --id) + +$SED \ + -e "s|%NO_EDIT_WARNING%|DO NOT EDIT! Generated automatically by mk-build-info-cc.|" \ + -e "s|%OCTAVE_HG_ID%|${OCTAVE_HG_ID}|"
--- a/configure.ac Sat Apr 09 06:36:53 2016 +0200 +++ b/configure.ac Fri Apr 08 21:41:18 2016 +0200 @@ -3399,6 +3399,7 @@ build-aux/mk-f77-def.sh build-aux/mk-mxarray-h.sh build-aux/mk-version-h.sh + build-aux/mk-build-info-cc.sh build-aux/subst-config-vals.sh build-aux/subst-cross-config-vals.sh build-aux/subst-default-vals.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libinterp/build-info.h Fri Apr 08 21:41:18 2016 +0200 @@ -0,0 +1,34 @@ +// %NO_EDIT_WARNING% +/* + +Copyright (C) 2016 M. Muetzel + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <string> + +OCTAVE_API std::string oct_hg_id (void); + +OCTAVE_API std::string oct_build_date (void); + +OCTAVE_API std::string oct_build_time (void);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libinterp/build-info.in.cc Fri Apr 08 21:41:18 2016 +0200 @@ -0,0 +1,39 @@ +// %NO_EDIT_WARNING% +/* + +Copyright (C) 2016 M. Muetzel + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#include "build-info.h" + +std::string oct_hg_id (void) +{ + return "%OCTAVE_HG_ID%"; +} + +std::string oct_build_date (void) +{ + return __DATE__; +} + +std::string oct_build_time (void) +{ + return __TIME__; +}
--- a/libinterp/corefcn/toplev.cc Sat Apr 09 06:36:53 2016 +0200 +++ b/libinterp/corefcn/toplev.cc Fri Apr 08 21:41:18 2016 +0200 @@ -51,6 +51,7 @@ #include "str-vec.h" #include "build-env.h" +#include "build-info.h" #include "defaults.h" #include "defun.h" #include "error.h" @@ -1422,11 +1423,14 @@ { "api_version", OCTAVE_API_VERSION }, { "archlibdir", subst_octave_home (OCTAVE_ARCHLIBDIR) }, { "bindir", subst_octave_home (OCTAVE_BINDIR) }, + { "builddate", oct_build_date () }, + { "buildtime", oct_build_time () }, { "canonical_host_type", OCTAVE_CANONICAL_HOST_TYPE }, { "datadir", subst_octave_home (OCTAVE_DATADIR) }, { "datarootdir", subst_octave_home (OCTAVE_DATAROOTDIR) }, { "exec_prefix", subst_octave_home (OCTAVE_EXEC_PREFIX) }, { "fcnfiledir", subst_octave_home (OCTAVE_FCNFILEDIR) }, + { "hgid", oct_hg_id () }, { "imagedir", subst_octave_home (OCTAVE_IMAGEDIR) }, { "includedir", subst_octave_home (OCTAVE_INCLUDEDIR) }, { "infodir", subst_octave_home (OCTAVE_INFODIR) }, @@ -1453,6 +1457,7 @@ { "octlibdir", subst_octave_home (OCTAVE_OCTLIBDIR) }, { "octtestsdir", subst_octave_home (OCTAVE_OCTTESTSDIR) }, { "prefix", subst_octave_home (OCTAVE_PREFIX) }, + { "releasedate", OCTAVE_RELEASE_DATE }, { "startupfiledir", subst_octave_home (OCTAVE_STARTUPFILEDIR) }, { "version", OCTAVE_VERSION }, { 0, octave_value () }
--- a/libinterp/module.mk Sat Apr 09 06:36:53 2016 +0200 +++ b/libinterp/module.mk Fri Apr 08 21:41:18 2016 +0200 @@ -43,6 +43,8 @@ BUILT_SOURCES += \ $(GENERATED_MAKE_BUILTINS_INCS) \ libinterp/build-env.cc \ + update_hg_id \ + libinterp/build-info.cc \ libinterp/builtin-defun-decls.h \ libinterp/builtins.cc \ libinterp/corefcn/oct-errno.cc \ @@ -76,6 +78,7 @@ LIBINTERP_BUILT_NODISTFILES = \ libinterp/build-env.cc \ libinterp/build-env-features.cc \ + libinterp/build-info.cc \ libinterp/corefcn/mxarray.h \ libinterp/corefcn/oct-errno.cc \ libinterp/corefcn/defaults.h \ @@ -91,6 +94,7 @@ libinterp/DOCSTRINGS \ libinterp/build-env.in.cc \ libinterp/build-env-features.sh \ + libinterp/build-info.in.cc \ libinterp/find-defun-files.sh \ libinterp/gendoc.pl \ libinterp/genprops.awk \ @@ -164,6 +168,7 @@ libinterp/builtins.cc \ libinterp/build-env.cc \ libinterp/build-env-features.cc \ + libinterp/build-info.cc \ libinterp/version.h libinterp_liboctinterp_la_LIBADD = \ @@ -258,6 +263,15 @@ libinterp/version.h: libinterp/version.in.h build-aux/mk-version-h.sh | libinterp/$(octave-dirstamp) $(AM_V_GEN)$(call simple-filter-rule,build-aux/mk-version-h.sh) +update_hg_id: + @if [ "x$(shell cat libinterp/hg.id)" != "x$(shell hg identify --id)" ]; then \ + hg identify --id > libinterp/hg.id; \ + fi +.PHONY: update_hg_id + +libinterp/build-info.cc: libinterp/build-info.in.cc build-aux/mk-build-info-cc.sh libinterp/hg.id | libinterp/$(octave-dirstamp) + $(AM_V_GEN)$(call simple-filter-rule,build-aux/mk-build-info.sh) + libinterp/builtins.cc: $(DEF_FILES) libinterp/mkbuiltins | libinterp/$(octave-dirstamp) $(AM_V_GEN)rm -f $@-t && \ $(SHELL) $(srcdir)/libinterp/mkbuiltins --source $(DEF_FILES) > $@-t && \
--- a/scripts/miscellaneous/version.m Sat Apr 09 06:36:53 2016 +0200 +++ b/scripts/miscellaneous/version.m Fri Apr 08 21:41:18 2016 +0200 @@ -17,29 +17,100 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {} version () -## Return the version number of Octave as a string. +## @deftypefn {} {@var{v} =} version () +## @deftypefnx {} {[@var{v}, @var{d}] =} version () +## @deftypefnx {} {@var{v} =} version (@var{feature}) +## Get version information for Octave +## +## If called without input argument, the first return value @var{v} gives the +## version number of Octave as a string. The second return value @var{d} holds +## the release date as a string. +## +## The following options can be passed for @var{feature}: +## @table @asis +## @item @qcode{"-date"} +## for the release date of the running build, ## -## This is an alias for the function @w{@env{OCTAVE_VERSION}} provided for -## compatibility. +## @item @qcode{"-description"} +## for a description of the release (empty string), +## +## @item @qcode{"-release"} +## for the name of the running build, +## +## @item @qcode{"-java"} +## for version information of the Java VM, +## +## @item @qcode{"-blas"} +## for version information for the linked BLAS (not implemented), +## +## @item @qcode{"-lapack"} +## for version information for the linked LAPACK (not implemented). +## @end table +## +## The variant with no input and output argument is an alias for the function +## @w{@env{OCTAVE_VERSION}} provided for compatibility. ## @seealso{OCTAVE_VERSION, ver} ## @end deftypefn ## Author: jwe -function vs = version () +function [vs, d] = version (feature) - if (nargin != 0) - warning ("version: ignoring extra arguments"); + if (nargin > 1 || ((nargin != 0) && ((nargout > 1) || ! ischar (feature)))) + print_usage (); endif - vs = OCTAVE_VERSION; + if (nargin == 0) + vs = OCTAVE_VERSION; + + if (nargout > 1) + d = __octave_config_info__.releasedate; + end + else + switch (feature) + case "-date" + vs = __octave_config_info__.releasedate; + case "-description" + vs = ""; + case "-release" + vs = ""; + case "-java" + try + jversion = javaMethod ("getProperty", "java.lang.System", ... + "java.runtime.version"); + jvendor = javaMethod ("getProperty", "java.lang.System", ... + "java.vendor"); + jname = javaMethod ("getProperty", "java.lang.System", ... + "java.vm.name"); + jjitmode = javaMethod ("getProperty", "java.lang.System", ... + "java.vm.info"); + vs = ["Java " jversion " with " jvendor " " jname " " jjitmode]; + catch + vs = "no java available"; + end_try_catch + case "-blas" + vs = ""; + warning(["version: option '" feature "' not implemented"]) + case "-lapack" + vs = ""; + warning(["version: option '" feature "' not implemented"]) + otherwise + error ("version: Invalid input argument"); + endswitch + endif + endfunction %!assert (ischar (version ())) -%!assert (version (), OCTAVE_VERSION) -%!warning version (1); +%!test +%! [v, d] = version (); +%! assert (v, OCTAVE_VERSION) +%! assert (d, __octave_config_info__.releasedate) +%!assert (version ("-date"), __octave_config_info__.releasedate) + +%!error version (1); +