]> www.ginac.de Git - ginac.git/commitdiff
[build] Move archive version info into version.h (for non autotools build).
authorAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Sun, 29 May 2011 14:15:42 +0000 (17:15 +0300)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Tue, 17 Jul 2012 04:49:55 +0000 (07:49 +0300)
The canonical location for all version info is the ginac/version.h file
now (so we can have two build systems without duplicating the version info
in configure.ac and CMakeLists.txt).

configure.ac
ginac/archive.cpp
ginac/version.h

index 9cdf91282575a6ed709ae1d5a43fbf14154f97d1..edee0de838a5337c2ef7300b0b62287c2bb258ca 100644 (file)
@@ -37,23 +37,6 @@ AC_CONFIG_MACRO_DIR([m4])
 dnl This defines PACKAGE and VERSION.
 AM_INIT_AUTOMAKE([gnu 1.8 dist-bzip2])
 
 dnl This defines PACKAGE and VERSION.
 AM_INIT_AUTOMAKE([gnu 1.8 dist-bzip2])
 
-dnl GiNaC archive file version information.
-dnl
-dnl If properties have been added, ARCHIVE_VERSION += 1, ARCHIVE_AGE += 1.
-dnl If backwards compatibility has been broken, set ARCHIVE_AGE to 0.
-dnl
-dnl The version number in newly created archives will be ARCHIVE_VERSION.
-dnl Archives version (ARCHIVE_VERSION-ARCHIVE_AGE) thru ARCHIVE_VERSION can
-dnl be read by this version of the GiNaC library.
-
-ARCHIVE_VERSION=3
-ARCHIVE_AGE=3
-
-AC_SUBST(ARCHIVE_VERSION)
-AC_SUBST(ARCHIVE_AGE)
-AC_DEFINE_UNQUOTED(ARCHIVE_VERSION, $ARCHIVE_VERSION, [Current GiNaC archive file version number])
-AC_DEFINE_UNQUOTED(ARCHIVE_AGE, $ARCHIVE_AGE, [GiNaC archive file version age])
-
 dnl libtool versioning
 LT_VERSION_INFO="ginac_lt_current:ginac_lt_revision:ginac_lt_age"
 AC_SUBST(LT_VERSION_INFO)
 dnl libtool versioning
 LT_VERSION_INFO="ginac_lt_current:ginac_lt_revision:ginac_lt_age"
 AC_SUBST(LT_VERSION_INFO)
index d643e68bf31166933ae5830cfaaf66f927f2761f..6466834140a7e6e3a08b2ad40b5585b0646e20b4 100644 (file)
@@ -28,6 +28,7 @@
 #include "config.h"
 #endif
 #include "tostring.h"
 #include "config.h"
 #endif
 #include "tostring.h"
+#include "version.h"
 
 #include <iostream>
 #include <stdexcept>
 
 #include <iostream>
 #include <stdexcept>
@@ -220,7 +221,7 @@ std::ostream &operator<<(std::ostream &os, const archive &ar)
        os.put('A');
        os.put('R');
        os.put('C');
        os.put('A');
        os.put('R');
        os.put('C');
-       write_unsigned(os, ARCHIVE_VERSION);
+       write_unsigned(os, GINACLIB_ARCHIVE_VERSION);
 
        // Write atoms
        unsigned num_atoms = ar.atoms.size();
 
        // Write atoms
        unsigned num_atoms = ar.atoms.size();
@@ -267,9 +268,11 @@ std::istream &operator>>(std::istream &is, archive &ar)
        is.get(c1); is.get(c2); is.get(c3); is.get(c4);
        if (c1 != 'G' || c2 != 'A' || c3 != 'R' || c4 != 'C')
                throw (std::runtime_error("not a GiNaC archive (signature not found)"));
        is.get(c1); is.get(c2); is.get(c3); is.get(c4);
        if (c1 != 'G' || c2 != 'A' || c3 != 'R' || c4 != 'C')
                throw (std::runtime_error("not a GiNaC archive (signature not found)"));
+       static const unsigned max_version = GINACLIB_ARCHIVE_VERSION;
+       static const unsigned min_version = GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE;
        unsigned version = read_unsigned(is);
        unsigned version = read_unsigned(is);
-       if (version > ARCHIVE_VERSION || version < ARCHIVE_VERSION - ARCHIVE_AGE)
-               throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(ARCHIVE_VERSION-ARCHIVE_AGE) + " thru " + ToString(ARCHIVE_VERSION)));
+       if ((version > max_version) || (version < min_version))
+               throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(min_version) + " thru " + ToString(max_version)));
 
        // Read atoms
        unsigned num_atoms = read_unsigned(is);
 
        // Read atoms
        unsigned num_atoms = read_unsigned(is);
index b79b9fb5ae7cc035c7fa22a322d83f6af7224d9b..030b596f69c42c7b9e461dca7b4b6d0190376412 100644 (file)
 /* Micro version of GiNaC */
 #define GINACLIB_MICRO_VERSION 2
 
 /* Micro version of GiNaC */
 #define GINACLIB_MICRO_VERSION 2
 
+/*
+ * GiNaC archive file version information.
+ *
+ * The current archive version is GINACLIB_ARCHIVE_VERSION. This is
+ * the version of archives created by the current version of GiNaC.
+ * Archives version (GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE)
+ * thru * GINACLIB_ARCHIVE_VERSION can be read by current version
+ * of GiNaC.
+ *
+ * Backward compatibility notes:
+ * If new properties have been added:
+ *     GINACLIB_ARCHIVE_VERSION += 1
+ *     GINACLIB_ARCHIVE_AGE += 1
+ * If backwards compatibility has been broken, i.e. some properties
+ * has been removed, or their type and/or meaning changed:
+ *     GINACLIB_ARCHIVE_VERSION += 1
+ *     GINACLIB_ARCHIVE_AGE = 0
+ */
+#define GINACLIB_ARCHIVE_VERSION 3
+#define GINACLIB_ARCHIVE_AGE 3
+
 namespace GiNaC {
 
 extern const int version_major;
 namespace GiNaC {
 
 extern const int version_major;