src: Centralize version number
As of this commit, the library's version number is defined in
src/version.hpp, and is propagated to waf/sphinx/doxygen.
Change-Id: I6513cc5a15f2c2afa7cf33844e85d199630fe559
Fixes: #1464
diff --git a/.waf-tools/sphinx_build.py b/.waf-tools/sphinx_build.py
index 32fd78a..bd3905b 100644
--- a/.waf-tools/sphinx_build.py
+++ b/.waf-tools/sphinx_build.py
@@ -8,7 +8,7 @@
class sphinx_build(Task.Task):
color = 'BLUE'
- run_str = '${SPHINX_BUILD} -q -b ${BUILDERNAME} -d ${DOCTREEDIR} ${SRCDIR} ${OUTDIR}'
+ run_str = '${SPHINX_BUILD} -D ${VERSION} -D ${RELEASE} -q -b ${BUILDERNAME} -d ${DOCTREEDIR} ${SRCDIR} ${OUTDIR}'
def __str__(self):
env = self.env
@@ -53,6 +53,8 @@
task.env['SRCDIR'] = srcdir
task.env['DOCTREEDIR'] = doctreedir
task.env['OUTDIR'] = outdir.abspath()
+ task.env['VERSION'] = "version=%s" % self.VERSION
+ task.env['RELEASE'] = "release=%s" % self.VERSION
import imp
confData = imp.load_source('sphinx_conf', conf.abspath())
diff --git a/docs/conf.py b/docs/conf.py
index 60baa9a..4d2b58c 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -14,6 +14,7 @@
import sys
import os
+import re
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -45,18 +46,9 @@
master_doc = 'index'
# General information about the project.
-project = u'NDN C++ library with eXperimental eXtensions'
+project = u'ndn-cxx: NDN C++ library with eXperimental eXtensions'
copyright = u'2014, Named Data Networking Project'
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = '0.1.0'
-# The full version, including alpha/beta/rc tags.
-release = '0.1.0'
-
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
diff --git a/docs/doxygen.conf b/docs/doxygen.conf.in
similarity index 99%
rename from docs/doxygen.conf
rename to docs/doxygen.conf.in
index 9998dd2..a25b2ec 100644
--- a/docs/doxygen.conf
+++ b/docs/doxygen.conf.in
@@ -32,13 +32,13 @@
# title of most generated pages and in a few other places.
# The default value is: My Project.
-PROJECT_NAME = "NDN C++ library with eXperimental eXtensions"
+PROJECT_NAME = "ndn-cxx: NDN C++ library with eXperimental eXtensions"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 0.1.0
+PROJECT_NUMBER = @VERSION@
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/docs/manpages.rst b/docs/manpages.rst
index af5501d..6907bee 100644
--- a/docs/manpages.rst
+++ b/docs/manpages.rst
@@ -15,6 +15,7 @@
ndnsec-export <manpages/ndnsec-export>
ndnsec-import <manpages/ndnsec-import>
ndnsec-unlock-tpm <manpages/ndnsec-unlock-tpm>
+ ndnsec-set-acl <manpages/ndnsec-set-acl>
manpages/tlvdump
:maxdepth: 1
diff --git a/docs/manpages/ndnsec-op-tool.rst b/docs/manpages/ndnsec-op-tool.rst
deleted file mode 100644
index e69de29..0000000
--- a/docs/manpages/ndnsec-op-tool.rst
+++ /dev/null
diff --git a/docs/manpages/ndnsec-sig-verify.rst b/docs/manpages/ndnsec-sig-verify.rst
deleted file mode 100644
index e69de29..0000000
--- a/docs/manpages/ndnsec-sig-verify.rst
+++ /dev/null
diff --git a/src/version.hpp b/src/version.hpp
new file mode 100644
index 0000000..2fa652c
--- /dev/null
+++ b/src/version.hpp
@@ -0,0 +1,45 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (c) 2013-2014, Regents of the University of California.
+ * All rights reserved.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * This file licensed under New BSD License. See COPYING for detailed information about
+ * ndn-cxx library copyright, permissions, and redistribution restrictions.
+ *
+ * Based on code originally written by Jeff Thompson <jefft0@remap.ucla.edu>
+ */
+
+#ifndef NDN_VERSION_HPP
+#define NDN_VERSION_HPP
+
+namespace nfd {
+
+/** ndn-cxx version follows Semantic Versioning 2.0.0 specification
+ * http://semver.org/
+ */
+
+/** \brief ndn-cxx version represented as an integer
+ *
+ * MAJOR*1000000 + MINOR*1000 + PATCH
+ */
+#define NDN_CXX_VERSION 1000
+
+/** \brief ndn-cxx version represented as a string
+ *
+ * MAJOR.MINOR.PATCH
+ */
+#define NDN_CXX_VERSION_STRING "0.1.0"
+
+/// MAJOR version
+#define NDN_CXX_VERSION_MAJOR (NDN_CXX_VERSION / 1000000)
+/// MINOR version
+#define NDN_CXX_VERSION_MINOR (NDN_CXX_VERSION % 1000000 / 1000)
+/// PATCH version
+#define NDN_CXX_VERSION_PATCH (NDN_CXX_VERSION % 1000)
+
+} // namespace nfd
+
+#endif // NDN_VERSION_HPP
diff --git a/tests/test-version.cpp b/tests/test-version.cpp
new file mode 100644
index 0000000..07afd95
--- /dev/null
+++ b/tests/test-version.cpp
@@ -0,0 +1,43 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (c) 2013-2014, Regents of the University of California.
+ * All rights reserved.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ *
+ * This file licensed under New BSD License. See COPYING for detailed information about
+ * ndn-cxx library copyright, permissions, and redistribution restrictions.
+ */
+
+#include "version.hpp"
+
+#include "boost-test.hpp"
+#include <stdio.h>
+
+namespace ndn {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(TestVersion)
+
+BOOST_AUTO_TEST_CASE(Version)
+{
+ BOOST_CHECK_EQUAL(NDN_CXX_VERSION, NDN_CXX_VERSION_MAJOR * 1000000 +
+ NDN_CXX_VERSION_MINOR * 1000 +
+ NDN_CXX_VERSION_PATCH);
+}
+
+BOOST_AUTO_TEST_CASE(VersionString)
+{
+ BOOST_STATIC_ASSERT(NDN_CXX_VERSION_MAJOR < 1000);
+ char buf[20];
+ snprintf(buf, sizeof(buf), "%d.%d.%d",
+ NDN_CXX_VERSION_MAJOR, NDN_CXX_VERSION_MINOR, NDN_CXX_VERSION_PATCH);
+
+ BOOST_CHECK_EQUAL(std::string(NDN_CXX_VERSION_STRING), std::string(buf));
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace ndn
diff --git a/wscript b/wscript
index 80e74f2..1ccfc88 100644
--- a/wscript
+++ b/wscript
@@ -1,12 +1,14 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-VERSION = '0.1.0'
+from waflib import Logs, Utils
+import re
+
+VERSION = re.search('^#define NDN_CXX_VERSION_STRING\\s+"(.*)"',
+ open("src/version.hpp").read(), re.M).group(1)
APPNAME = "ndn-cxx"
PACKAGE_BUGREPORT = "http://redmine.named-data.net/projects/ndn-cxx"
PACKAGE_URL = "https://github.com/named-data/ndn-cxx"
-from waflib import Logs, Utils
-
def options(opt):
opt.load(['compiler_cxx', 'gnu_dirs', 'c_osx'])
opt.load(['default-compiler-flags', 'coverage', 'osx-security', 'pch',
@@ -191,7 +193,8 @@
outdir="docs/manpages",
config="docs/conf.py",
source=bld.path.ant_glob('docs/manpages/**/*.rst'),
- install_path="${MANDIR}/")
+ install_path="${MANDIR}/",
+ VERSION=VERSION)
def docs(bld):
from waflib import Options
@@ -201,8 +204,16 @@
if not bld.env.DOXYGEN:
Logs.error("ERROR: cannot build documentation (`doxygen' is not found in $PATH)")
else:
+ bld(features="subst",
+ name="doxygen-conf",
+ source="docs/doxygen.conf.in",
+ target="docs/doxygen.conf",
+ VERSION=VERSION,
+ )
+
bld(features="doxygen",
- doxyfile='docs/doxygen.conf')
+ doxyfile='docs/doxygen.conf',
+ use="doxygen-conf")
def sphinx(bld):
if not bld.env.SPHINX_BUILD:
@@ -211,4 +222,5 @@
bld(features="sphinx",
outdir="docs",
source=bld.path.ant_glob("docs/**/*.rst"),
- config="docs/conf.py")
+ config="docs/conf.py",
+ VERSION=VERSION)