changeset 21598:cf552443c104

revise method of handling hg id for build info * Makefile.am (HG-ID): New target and file to distribute. * build-info.h: Don't include config.h. * build-info.in.cc: Strip CR from line endings. * build-info.h, build-info.in.cc (octave_hg_id): Rename from oct_hg_id. (octave_build_date): Rename from oct_build_date. (octave_build_time): Rename from oct_build_time. Change all callers. * toplev.cc (F__octave_config_info__): Rename fields: builddate to build_date, buildtime to build_time, hgid to hg_id, and releasedate to * libinterp/module.mk (upate_hg_id): Delete rule. (octinclude_HEADERS): Include build-info.h in the list. (BUILT_SOURCES): Remove update_hg_id from the list. (libinterp/build-info.cc): Don't depend on build-aux/mk-build-info.sh. Depend on HG-ID instead of libinterp/hg.id. Call sed directly here instead of using a shell script. * build-aux/mk-build-info-cc.in.sh: Delete. * Makefile.am (EXTRA_DIST): Remove build-aux/mk-build-info-cc.sh.in from the list. (GEN_CONFIG_SHELL): Remove build-aux/mk-build-info-cc.sh from the list. * configure.ac (OCTAVE_CONFIG_MOVE_IF_CHANGE_FILES): Remove build-aux/mk-build-info-cc.sh from the list.
author John W. Eaton <jwe@octave.org>
date Sat, 09 Apr 2016 18:58:28 -0400
parents fe1447ae68cf
children f29d68e24c5a
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
diffstat 7 files changed, 75 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.am	Fri Apr 08 21:41:18 2016 +0200
+++ b/Makefile.am	Sat Apr 09 18:58:28 2016 -0400
@@ -37,6 +37,7 @@
   AUTHORS \
   BUGS \
   ChangeLog \
+  HG-ID \
   INSTALL.OCTAVE
 
 EXTRA_DIST += \
@@ -52,7 +53,6 @@
   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 \
@@ -70,7 +70,6 @@
   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 \
@@ -287,6 +286,20 @@
 	$(AM_V_GEN)$(changelog-from-hg-log)
 .PHONY: ChangeLog
 
+HG-ID:
+	$(AM_V_GEN)rm -f $@-t && \
+	if [ -d $(srcdir)/.hg ]; then \
+	  ( cd $(srcdir) && hg identify --id ) > $@-t && \
+	  $(simple_move_if_change_rule); \
+	elif [ ! -f $(srcdir)/HG-ID ]; then \
+	  echo "$(srcdir)/HG-ID is missing!" 1>&2; \
+	  echo "unknown" >& $@-t && mv $@-t $@; \
+	else \
+	  echo "preserving existing HG-ID file" 1>&2; \
+	  $(cp_update_rule); \
+	fi
+.PHONY: HG-ID
+
 octetc_DATA += \
   CITATION \
   NEWS
--- a/build-aux/mk-build-info-cc.in.sh	Fri Apr 08 21:41:18 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#! /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	Fri Apr 08 21:41:18 2016 +0200
+++ b/configure.ac	Sat Apr 09 18:58:28 2016 -0400
@@ -3399,7 +3399,6 @@
   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
--- a/libinterp/build-info.h	Fri Apr 08 21:41:18 2016 +0200
+++ b/libinterp/build-info.h	Sat Apr 09 18:58:28 2016 -0400
@@ -21,14 +21,10 @@
 
 */
 
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
 #include <string>
 
-OCTAVE_API std::string oct_hg_id (void);
+extern OCTAVE_API std::string octave_hg_id (void);
 
-OCTAVE_API std::string oct_build_date (void);
+extern OCTAVE_API std::string octave_build_date (void);
 
-OCTAVE_API std::string oct_build_time (void);
+extern OCTAVE_API std::string octave_build_time (void);
--- a/libinterp/build-info.in.cc	Fri Apr 08 21:41:18 2016 +0200
+++ b/libinterp/build-info.in.cc	Sat Apr 09 18:58:28 2016 -0400
@@ -1,39 +1,46 @@
-// %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__;
-}
+// %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 "build-info.h"
+
+std::string
+octave_hg_id (void)
+{
+  return "%OCTAVE_HG_ID%";
+}
+
+std::string
+octave_build_date (void)
+{
+  return __DATE__;
+}
+
+std::string
+octave_build_time (void)
+{
+  return __TIME__;
+}
--- a/libinterp/corefcn/toplev.cc	Fri Apr 08 21:41:18 2016 +0200
+++ b/libinterp/corefcn/toplev.cc	Sat Apr 09 18:58:28 2016 -0400
@@ -1423,14 +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 () },
+      { "build_date", octave_build_date () },
+      { "build_time", octave_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 () },
+      { "hg_id", octave_hg_id () },
       { "imagedir", subst_octave_home (OCTAVE_IMAGEDIR) },
       { "includedir", subst_octave_home (OCTAVE_INCLUDEDIR) },
       { "infodir", subst_octave_home (OCTAVE_INFODIR) },
@@ -1457,7 +1457,7 @@
       { "octlibdir", subst_octave_home (OCTAVE_OCTLIBDIR) },
       { "octtestsdir", subst_octave_home (OCTAVE_OCTTESTSDIR) },
       { "prefix", subst_octave_home (OCTAVE_PREFIX) },
-      { "releasedate", OCTAVE_RELEASE_DATE },
+      { "release_date", OCTAVE_RELEASE_DATE },
       { "startupfiledir", subst_octave_home (OCTAVE_STARTUPFILEDIR) },
       { "version", OCTAVE_VERSION },
       { 0, octave_value () }
--- a/libinterp/module.mk	Fri Apr 08 21:41:18 2016 +0200
+++ b/libinterp/module.mk	Sat Apr 09 18:58:28 2016 -0400
@@ -43,7 +43,6 @@
 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 \
@@ -111,6 +110,7 @@
   libinterp/builtins.h \
   libinterp/builtin-defun-decls.h \
   libinterp/build-env.h \
+  libinterp/build-info.h \
   libinterp/octave.h \
   libinterp/options-usage.h \
   $(OCTAVE_VALUE_INC) \
@@ -263,14 +263,12 @@
 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/build-info.cc: libinterp/build-info.in.cc HG-ID | libinterp/$(octave-dirstamp)
+	$(AM_V_GEN)rm -f $@-t && \
+	$(SED) \
+	  -e "s|%NO_EDIT_WARNING%|DO NOT EDIT!  Generated automatically by Makefile|" \
+	  -e "s|%OCTAVE_HG_ID%|`cat $(builddir)/HG-ID`|" $< > $@-t && \
+	$(simple_move_if_change_rule)
 
 libinterp/builtins.cc: $(DEF_FILES) libinterp/mkbuiltins | libinterp/$(octave-dirstamp)
 	$(AM_V_GEN)rm -f $@-t && \