summaryrefslogtreecommitdiff
path: root/rtemstoolkit
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2015-12-09 20:08:19 +1100
committerChris Johns <chrisj@rtems.org>2015-12-09 20:08:19 +1100
commitefc4f099b459833cc424f133716824bc0efc060e (patch)
tree683f0eb50e7bcb1f67175fc96d08228740b959ba /rtemstoolkit
parentc9fa1795616ed8e9e71e7922e0a3fa52aff465f0 (diff)
Add release versioning support.
Support a top level VERSION file that defines an RTEMS release. Fix the install of the python modules including thertems-test. Update the git python module to the RSB version. Fix the options to not call clean and to call dirty. Update the version python module. Fix the rtld C++ support to the VERSION file and the top level waf script.
Diffstat (limited to 'rtemstoolkit')
-rw-r--r--rtemstoolkit/git.py61
-rw-r--r--rtemstoolkit/options.py2
-rw-r--r--rtemstoolkit/rld-rtems.cpp2
-rw-r--r--rtemstoolkit/rld.cpp11
-rw-r--r--rtemstoolkit/version.py70
-rw-r--r--rtemstoolkit/wscript14
6 files changed, 109 insertions, 51 deletions
diff --git a/rtemstoolkit/git.py b/rtemstoolkit/git.py
index d00007c..20a1aa6 100644
--- a/rtemstoolkit/git.py
+++ b/rtemstoolkit/git.py
@@ -1,13 +1,10 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
@@ -61,14 +58,17 @@ class repo:
self._git_exit_code(exit_code)
return exit_code, output
- def __init__(self, _path, opts, macros = None):
+ def __init__(self, _path, opts = None, macros = None):
self.path = _path
self.opts = opts
- if macros is None:
+ if macros is None and opts is not None:
self.macros = opts.defaults
else:
self.macros = macros
- self.git = self.macros.expand('%{__git}')
+ if self.macros is None:
+ self.git = 'git'
+ else:
+ self.git = self.macros.expand('%{__git}')
def git_version(self):
ec, output = self._run(['--version'], True)
@@ -86,6 +86,9 @@ class repo:
def fetch(self):
ec, output = self._run(['fetch'], check = True)
+ def merge(self):
+ ec, output = self._run(['merge'], check = True)
+
def pull(self):
ec, output = self._run(['pull'], check = True)
@@ -105,6 +108,14 @@ class repo:
def checkout(self, branch = 'master'):
ec, output = self._run(['checkout', branch], check = True)
+ def submodule(self, module):
+ ec, output = self._run(['submodule', 'update', '--init', module], check = True)
+
+ def clean(self, args = []):
+ if type(args) == str:
+ args = [args]
+ ec, output = self._run(['clean'] + args, check = True)
+
def status(self):
_status = {}
if path.exists(self.path):
@@ -112,27 +123,33 @@ class repo:
if ec == 0:
state = 'none'
for l in output.split('\n'):
- if l.startswith('# On branch '):
- _status['branch'] = l[len('# On branch '):]
- elif l.startswith('# Changes to be committed:'):
+ if l.startswith('# '):
+ l = l[2:]
+ if l.startswith('On branch '):
+ _status['branch'] = l[len('On branch '):]
+ elif l.startswith('Changes to be committed:'):
state = 'staged'
- elif l.startswith('# Changes not staged for commit:'):
+ elif l.startswith('Changes not staged for commit:'):
state = 'unstaged'
- elif l.startswith('# Untracked files:'):
+ elif l.startswith('Untracked files:'):
state = 'untracked'
- elif state != 'none' and l[0] == '#':
- if l.strip() != '#' and not l.startswith('# ('):
- if state not in _status:
- _status[state] = []
- l = l[1:]
- if ':' in l:
- l = l.split(':')[1]
- _status[state] += [l.strip()]
+ elif l.startswith('HEAD detached'):
+ state = 'detached'
+ elif state != 'none' and len(l.strip()) != 0:
+ if l[0].isspace():
+ l = l.strip()
+ if l[0] != '(':
+ if state not in _status:
+ _status[state] = []
+ l = l[1:]
+ if ':' in l:
+ l = l.split(':')[1]
+ _status[state] += [l.strip()]
return _status
- def clean(self):
+ def dirty(self):
_status = self.status()
- return len(_status) == 1 and 'branch' in _status
+ return not (len(_status) == 1 and 'branch' in _status)
def valid(self):
if path.exists(self.path):
diff --git a/rtemstoolkit/options.py b/rtemstoolkit/options.py
index 75d8069..132445e 100644
--- a/rtemstoolkit/options.py
+++ b/rtemstoolkit/options.py
@@ -353,7 +353,7 @@ class command_line(object):
if repo.valid():
repo_valid = '1'
repo_head = repo.head()
- repo_clean = repo.clean()
+ repo_clean = not repo.dirty()
repo_id = repo_head
if not repo_clean:
repo_id += '-modified'
diff --git a/rtemstoolkit/rld-rtems.cpp b/rtemstoolkit/rld-rtems.cpp
index 1538cca..86351fd 100644
--- a/rtemstoolkit/rld-rtems.cpp
+++ b/rtemstoolkit/rld-rtems.cpp
@@ -24,7 +24,7 @@ namespace rld
{
namespace rtems
{
- static std::string _version = "4.12";
+ static std::string _version = RTEMS_VERSION;
static std::string _path;
static std::string _arch_bsp;
diff --git a/rtemstoolkit/rld.cpp b/rtemstoolkit/rld.cpp
index b3e6fdc..5168fe9 100644
--- a/rtemstoolkit/rld.cpp
+++ b/rtemstoolkit/rld.cpp
@@ -32,10 +32,6 @@
#include <rld.h>
-#define RLD_VERSION_MAJOR (1)
-#define RLD_VERSION_MINOR (0)
-#define RLD_VERSION_RELEASE (0)
-
namespace rld
{
static int verbose_level = 0;
@@ -202,16 +198,13 @@ namespace rld
const std::string
version ()
{
- std::string v = (rld::to_string (RLD_VERSION_MAJOR) + '.' +
- rld::to_string (RLD_VERSION_MINOR) + '.' +
- rld::to_string (RLD_VERSION_RELEASE));
- return v;
+ return RTEMS_RELEASE;
}
const std::string
rtems_version ()
{
- return rld::to_string (RTEMS_VERSION);
+ return RTEMS_VERSION;
}
void
diff --git a/rtemstoolkit/version.py b/rtemstoolkit/version.py
index 5b2a01a..df74510 100644
--- a/rtemstoolkit/version.py
+++ b/rtemstoolkit/version.py
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -29,20 +29,66 @@
#
#
-# Manage paths locally. The internally the path is in Unix or shell format and
-# we convert to the native format when performing operations at the Python
-# level. This allows macro expansion to work.
+# To release RTEMS Tools create a git archive and then add a suitable VERSION
+# file to the top directory.
#
-major = 0
-minor = 0
-revision = 0
+import sys
+
+import error
+import git
+import path
+
+#
+# Default to an internal string.
+#
+_version_str = '4.12.not_release'
+_released = False
+_git = False
+
+def _at():
+ return path.dirname(__file__)
+
+def _load_released_version():
+ global _released
+ global _version_str
+ at = _at()
+ 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')
+ return _released
+
+def _load_git_version():
+ global _git
+ global _version_str
+ repo = git.repo(_at())
+ if repo.valid():
+ head = repo.head()
+ if repo.dirty():
+ modified = ' modified'
+ else:
+ modified = ''
+ _version_str = '%s (%s%s)' % (_version_str, head[0:12], modified)
+ _git = True
+ return _git
+
+def released():
+ return _load_released_version()
+
+def version_control():
+ return _load_git_version()
def str():
- return '%d.%d.%d'% (major, minor, revision)
+ if not _released and not _git:
+ if not _load_released_version():
+ _load_git_version()
+ return _version_str
if __name__ == '__main__':
- print('major = %d' % (major))
- print('minor = %d' % (minor))
- print('revision = %d' % (revision))
- print('Version: %s' % (str()))
+ print 'Version: %s' % (str())
diff --git a/rtemstoolkit/wscript b/rtemstoolkit/wscript
index 9e9f047..930f55a 100644
--- a/rtemstoolkit/wscript
+++ b/rtemstoolkit/wscript
@@ -33,10 +33,6 @@
#
import sys
-version_major = 1
-version_minor = 0
-version_revision = 0
-
#
# Waf system setup. Allow more than one build in the same tree.
#
@@ -60,6 +56,11 @@ def configure(conf):
features = 'c', mandatory = False)
conf.write_config_header('config.h')
+ conf.load('python')
+ conf.check_python_version((2,6,6))
+ conf.env['PYO'] = 0
+ conf.env['PYC'] = 0
+
def build(bld):
#
# The local configuration.
@@ -125,7 +126,8 @@ def build(bld):
install_path = None,
source = rld_source + rtems_utils + compression,
defines = ['HAVE_CONFIG_H=1',
- 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION,
+ 'RTEMS_VERSION=\"%s\"' % (bld.env.RTEMS_VERSION),
+ 'RTEMS_RELEASE=\"%s\"' % (bld.env.RTEMS_RELEASE),
'FASTLZ_LEVEL=1'],
includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'],
@@ -153,7 +155,7 @@ def build(bld):
'stacktraces.py',
'version.py',
'windows.py'],
- install_path = '${PREFIX}/share/rtems/rtemstoolkit')
+ install_path = '${PREFIX}/share/rtems')
def rebuild(ctx):
import waflib.Options