[rtems-docs commit] waf: Get the version numbers from the version file.

Chris Johns chrisj at rtems.org
Thu Mar 12 21:23:38 UTC 2020


Module:    rtems-docs
Branch:    master
Commit:    19af6b47d54b802da6a144dbf4008c75cd2fa073
Changeset: http://git.rtems.org/rtems-docs/commit/?id=19af6b47d54b802da6a144dbf4008c75cd2fa073

Author:    Chris Johns <chrisj at rtems.org>
Date:      Thu Mar 12 16:34:16 2020 +1100

waf: Get the version numbers from the version file.

---

 common/conf.py    | 15 ++++++++++++---
 common/version.py | 25 ++++++++++++++++++++++++-
 common/waf.py     |  5 ++++-
 wscript           |  3 +++
 4 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/common/conf.py b/common/conf.py
index fe44640..97f8dfa 100644
--- a/common/conf.py
+++ b/common/conf.py
@@ -1,7 +1,10 @@
+import version as rtems_version
+
 extensions = [
 	"sphinx.ext.autodoc",
 	"sphinx.ext.coverage",
 	"sphinx.ext.doctest",
+	"sphinx.ext.extlinks",
 	"sphinx.ext.graphviz",
 	"sphinx.ext.intersphinx",
 	"sphinx.ext.mathjax",
@@ -9,6 +12,8 @@ extensions = [
 	"rtemsdomain",
 ]
 
+extlinks = {'release_path': ('https://ftp.rtems.org/pub/rtems/releases', None) }
+
 # Add any paths that contain templates here, relative to this directory.
 #templates_path = ['build/_templates']
 
@@ -23,17 +28,21 @@ master_doc = 'index'
 
 # General information about the project.
 project = u'RTEMS Documentation Project'
-copyright = u'1988, 2019 RTEMS Project and contributors'
+copyright = u'1988, 2020 RTEMS Project and contributors'
 
 # 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 = '@VERSION@'
+version = rtems_version.version()
 
 # The full version, including alpha/beta/rc tags.
-#release = '@RELEASE@'
+release = rtems_version.string()
+
+major = rtems_version.major()
+minor = rtems_version.minor()
+revision = rtems_version.revision()
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/common/version.py b/common/version.py
index 9beb3e7..281c880 100644
--- a/common/version.py
+++ b/common/version.py
@@ -1,6 +1,6 @@
 #
 # RTEMS Documentation Project (http://www.rtems.org/)
-# Copyright 2019 Chris Johns (chrisj at rtems.org)
+# Copyright 2019, 2020 Chris Johns (chrisj at rtems.org)
 # Copyright (C) 2019 embedded brains GmbH
 # All rights reserved.
 #
@@ -66,6 +66,9 @@ from __future__ import print_function
 import os.path
 
 _version = 'invalid'
+_major = 0
+_minor = 0
+_revision = 0
 _date = 'unknown date'
 _released = False
 
@@ -155,6 +158,17 @@ def get(ctx, rtems_major_version):
         _version = version
         _date = date
         _release = released
+    if version != 'invalid':
+        vs = _version.split('.')
+        _major = vs[0]
+        if len(vs) == 3:
+            _minor = vs[1]
+            _revision = vs[2]
+        elif len(vs) == 2:
+            _minor = 0
+            _revision = vs[1]
+        else:
+            ctx.fatal('Invalid version format: %s' % (_version))
     return version, date, released
 
 def string():
@@ -163,6 +177,15 @@ def string():
 def version():
     return _version
 
+def major():
+    return _major
+
+def minor():
+    return _minor
+
+def revision():
+    return revision
+
 def date():
     return _date
 
diff --git a/common/waf.py b/common/waf.py
index 066048d..36feef5 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -19,7 +19,10 @@ import conf
 sphinx_min_version = (1, 3)
 
 def version_cmdline(ctx):
-    return '-Drelease="%s" -Dversion="%s"' % (ctx.env.RELEASE, ctx.env.VERSION)
+    return '-Drelease="%s" -Dversion="%s" -Drtems_major="%s" ' \
+           '-Drtems_minor="%s" -D rtems_revision="%s"' \
+        % (ctx.env.RELEASE, ctx.env.VERSION, ctx.env.RTEMS_MAJOR,
+           ctx.env.RTEMS_MINOR, ctx.env.RTEMS_REVISION)
 
 def sphinx_cmdline(ctx, build_type, conf_dir, doctrees,
                    source_dir, output_dir, configs = []):
diff --git a/wscript b/wscript
index 5f8464d..cdeea95 100644
--- a/wscript
+++ b/wscript
@@ -86,6 +86,9 @@ def build(ctx):
     ctx.env.DATE = ver_date
     ctx.env.RELEASE = ver_version + ' (' + ver_date + ')'
     ctx.env.VERSION = ver_version
+    ctx.env.RTEMS_MAJOR = version.major()
+    ctx.env.RTEMS_MINOR = version.minor()
+    ctx.env.RTEMS_REVISION = version.revision()
     ctx.to_log('Build: %s%s' % (ctx.env.RELEASE, os.linesep))
 
     #



More information about the vc mailing list