[rtems-tools commit] VERSION as an INI format file.

Chris Johns chrisj at rtems.org
Fri Dec 11 06:17:16 UTC 2015


Module:    rtems-tools
Branch:    4.11
Commit:    2244c9bb36c15f89a13efc1858bdd621d955c10b
Changeset: http://git.rtems.org/rtems-tools/commit/?id=2244c9bb36c15f89a13efc1858bdd621d955c10b

Author:    Chris Johns <chrisj at rtems.org>
Date:      Fri Dec 11 17:01:51 2015 +1100

VERSION as an INI format file.

One section is supported [version] with a 'release' entry.

---

 rtemstoolkit/version.py | 19 +++++++++++--------
 wscript                 | 21 ++++++++++++++++-----
 2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/rtemstoolkit/version.py b/rtemstoolkit/version.py
index 16e9ad9..26ac655 100644
--- a/rtemstoolkit/version.py
+++ b/rtemstoolkit/version.py
@@ -42,7 +42,9 @@ import path
 #
 # Default to an internal string.
 #
-_version_str = '4.11.not_release'
+_version = '4.11'
+_revision = 'not_released'
+_version_str = '%s.%s' % (_version, _revision)
 _released = False
 _git = False
 
@@ -56,12 +58,13 @@ def _load_released_version():
     for ver in [at, path.join(at, '..')]:
         if path.exists(path.join(ver, 'VERSION')):
             try:
-                with open(path.join(ver, 'VERSION')) as v:
-                    _version_str = v.readline().strip()
-                v.close()
-                _released = True
-            except:
-                raise error.general('Cannot access the VERSION file')
+                import configparser
+            except ImportError:
+                import ConfigParser as configparser
+            v = configparser.SafeConfigParser()
+            v.read(path.join(ver, 'VERSION'))
+            _version_str = v.get('version', 'release')
+            _released = True
     return _released
 
 def _load_git_version():
@@ -74,7 +77,7 @@ def _load_git_version():
             modified = ' modified'
         else:
             modified = ''
-        _version_str = '%s (%s%s)' % (_version_str, head[0:12], modified)
+        _version_str = '%s (%s%s)' % (_version, head[0:12], modified)
         _git = True
     return _git
 
diff --git a/wscript b/wscript
index 9ed3e1b..e271f81 100644
--- a/wscript
+++ b/wscript
@@ -39,11 +39,22 @@ def get_version(ctx):
     release = '4.11.not_released'
     if os.path.exists('VERSION'):
         try:
-            with open('VERSION') as v:
-                release = v.readline().strip()
-            v.close()
-        except:
-            ctx.fatal('cannot access the VERSION file')
+            import configparser
+        except ImportError:
+            import ConfigParser as configparser
+        v = configparser.SafeConfigParser()
+        v.read('VERSION')
+        release = v.get('version', 'release')
+    else:
+        from rtemstoolkit import git
+        repo = git.repo('.')
+        if repo.valid():
+            head = repo.head()
+            if repo.dirty():
+                modified = '_modified'
+            else:
+                modified = ''
+            release = '%s.%s%s' % (version, head[0:12], modified)
     last_dot = release.rfind('.')
     if last_dot == -1:
         ctx.fatal('invalid VERSION file')




More information about the vc mailing list