Mercurial > octave
diff scripts/miscellaneous/version.m @ 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 | 516bb87ea72e |
children | 184b85b31e03 |
line wrap: on
line diff
--- 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); +