summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2015-12-09 19:36:26 +1100
committerChris Johns <chrisj@rtems.org>2015-12-09 19:36:26 +1100
commit72797480314ea1e57dce2e6569fa7c86d9ade975 (patch)
treecf1a936f4ad62b9017e697c49035fc2810b5d657
parentAdd gitattributes to aid releasing. (diff)
downloadrtems-tools-72797480314ea1e57dce2e6569fa7c86d9ade975.tar.bz2
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.
-rw-r--r--.gitignore1
-rw-r--r--linkers/rtems-ld.cpp1
-rw-r--r--linkers/rtems-ra.cpp2
-rw-r--r--linkers/rtems-rapper.cpp2
-rw-r--r--linkers/rtems-syms.cpp2
-rw-r--r--linkers/rtems-tld.cpp1
-rw-r--r--linkers/wscript23
-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.py68
-rw-r--r--rtemstoolkit/wscript14
-rw-r--r--tester/rt/test.py4
-rwxr-xr-xtester/rtems-test4
-rw-r--r--tester/wscript6
-rw-r--r--wscript27
17 files changed, 158 insertions, 73 deletions
diff --git a/.gitignore b/.gitignore
index 604ad4d..bc4eb73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ waf-*
waf3-*
.lock-waf*
build
+VERSION
diff --git a/linkers/rtems-ld.cpp b/linkers/rtems-ld.cpp
index e8d79db..92258df 100644
--- a/linkers/rtems-ld.cpp
+++ b/linkers/rtems-ld.cpp
@@ -212,6 +212,7 @@ main (int argc, char* argv[])
{
case 'V':
std::cout << "rtems-ld (RTEMS Linker) " << rld::version ()
+ << ", RTEMS revision " << rld::rtems::version ()
<< std::endl;
::exit (0);
break;
diff --git a/linkers/rtems-ra.cpp b/linkers/rtems-ra.cpp
index 7b7a98b..efd4cf9 100644
--- a/linkers/rtems-ra.cpp
+++ b/linkers/rtems-ra.cpp
@@ -42,6 +42,7 @@
#include <rld-outputter.h>
#include <rld-process.h>
#include <rld-resolver.h>
+#include <rld-rtems.h>
#ifndef HAVE_KILL
#define kill(p,s) raise(s)
@@ -183,6 +184,7 @@ main (int argc, char* argv[])
{
case 'V':
std::cout << "rtems-ra (RTEMS Linker) " << rld::version ()
+ << ", RTEMS revision " << rld::rtems::version ()
<< std::endl;
::exit (0);
break;
diff --git a/linkers/rtems-rapper.cpp b/linkers/rtems-rapper.cpp
index e0d27a0..afc301d 100644
--- a/linkers/rtems-rapper.cpp
+++ b/linkers/rtems-rapper.cpp
@@ -44,6 +44,7 @@
#include <rld-files.h>
#include <rld-process.h>
#include <rld-rap.h>
+#include <rld-rtems.h>
#include <rtems-utils.h>
@@ -1172,6 +1173,7 @@ main (int argc, char* argv[])
{
case 'V':
std::cout << "rtems-rap (RTEMS RAP Manager) " << rld::version ()
+ << ", RTEMS revision " << rld::rtems::version ()
<< std::endl;
::exit (0);
break;
diff --git a/linkers/rtems-syms.cpp b/linkers/rtems-syms.cpp
index 3fb7992..c8f54ae 100644
--- a/linkers/rtems-syms.cpp
+++ b/linkers/rtems-syms.cpp
@@ -43,6 +43,7 @@
#include <rld-outputter.h>
#include <rld-process.h>
#include <rld-symbols.h>
+#include <rld-rtems.h>
#ifndef HAVE_KILL
#define kill(p,s) raise(s)
@@ -329,6 +330,7 @@ main (int argc, char* argv[])
{
case 'V':
std::cout << "rtems-syms (RTEMS Symbols) " << rld::version ()
+ << ", RTEMS revision " << rld::rtems::version ()
<< std::endl;
::exit (0);
break;
diff --git a/linkers/rtems-tld.cpp b/linkers/rtems-tld.cpp
index 714c9ee..580c4c1 100644
--- a/linkers/rtems-tld.cpp
+++ b/linkers/rtems-tld.cpp
@@ -1724,6 +1724,7 @@ main (int argc, char* argv[])
{
case 'V':
std::cout << "rtems-trace-ld (RTEMS Trace Linker) " << rld::version ()
+ << ", RTEMS revision " << rld::rtems::version ()
<< std::endl;
::exit (0);
break;
diff --git a/linkers/wscript b/linkers/wscript
index e49358a..38298d1 100644
--- a/linkers/wscript
+++ b/linkers/wscript
@@ -3,10 +3,6 @@
#
import sys
-version_major = 1
-version_minor = 0
-version_revision = 0
-
def options(opt):
opt.load('compiler_c')
opt.load('compiler_cxx')
@@ -15,8 +11,6 @@ def configure(conf):
conf.load('compiler_c')
conf.load('compiler_cxx')
- conf.env.C_OPTS = conf.options.c_opts.split(',')
- conf.env.RTEMS_VERSION = conf.options.rtems_version
conf.write_config_header('config.h')
def build(bld):
@@ -55,11 +49,18 @@ def build(bld):
modules = ['rld', 'elf', 'iberty']
#
+ # The list of defines
+ #
+ defines = ['HAVE_CONFIG_H=1',
+ 'RTEMS_VERSION=\"%s\"' % (bld.env.RTEMS_VERSION),
+ 'RTEMS_RELEASE=\"%s\"' % (bld.env.RTEMS_RELEASE)]
+
+ #
# Build the linker.
#
bld.program(target = 'rtems-ld',
source = ['rtems-ld.cpp'],
- defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
+ defines = defines,
includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'],
@@ -71,7 +72,7 @@ def build(bld):
#
bld.program(target = 'rtems-ra',
source = ['rtems-ra.cpp'],
- defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
+ defines = defines,
includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'],
@@ -83,7 +84,7 @@ def build(bld):
#
bld.program(target = 'rtems-tld',
source = ['rtems-tld.cpp'],
- defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
+ defines = defines,
includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'],
@@ -109,7 +110,7 @@ def build(bld):
#
bld.program(target = 'rtems-syms',
source = ['rtems-syms.cpp'],
- defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
+ defines = defines,
includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'],
@@ -121,7 +122,7 @@ def build(bld):
#
bld.program(target = 'rtems-rap',
source = ['rtems-rapper.cpp'],
- defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
+ defines = defines,
includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'],
diff --git a/rtemstoolkit/git.py b/rtemstoolkit/git.py
index 2c23c05..c77347c 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 97b8ba7..657921d 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 d85f845..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.11";
+ 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 a3cf5a8..16e9ad9 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.11.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())
diff --git a/rtemstoolkit/wscript b/rtemstoolkit/wscript
index 229deeb..cf61f76 100644
--- a/rtemstoolkit/wscript
+++ b/rtemstoolkit/wscript
@@ -3,10 +3,6 @@
#
import sys
-version_major = 1
-version_minor = 0
-version_revision = 0
-
#
# Waf system setup. Allow more than one build in the same tree.
#
@@ -28,6 +24,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.
@@ -93,7 +94,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'],
@@ -121,7 +123,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
diff --git a/tester/rt/test.py b/tester/rt/test.py
index 551c8b5..b0e041a 100644
--- a/tester/rt/test.py
+++ b/tester/rt/test.py
@@ -39,13 +39,13 @@ from rtemstoolkit import error
from rtemstoolkit import log
from rtemstoolkit import path
from rtemstoolkit import stacktraces
+from rtemstoolkit import version
import bsps
import config
import console
import options
import report
-import version
import fnmatch
class test(object):
@@ -201,7 +201,7 @@ def run(command_path = None):
opts = options.load(sys.argv,
optargs = optargs,
command_path = command_path)
- log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
+ log.notice('RTEMS Testing - Tester, %s' % (version.str()))
if opts.find_arg('--list-bsps'):
bsps.list(opts)
exe_filter = opts.find_arg('--filter')
diff --git a/tester/rtems-test b/tester/rtems-test
index 1684abc..32ec563 100755
--- a/tester/rtems-test
+++ b/tester/rtems-test
@@ -1,7 +1,7 @@
#! /usr/bin/env python
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2013 Chris Johns (chrisj@rtems.org)
+# Copyright 2013, 2015 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -33,7 +33,7 @@ import sys, os
base = os.path.dirname(os.path.abspath(sys.argv[0]))
parent = os.path.dirname(base)
rtems = os.path.join(parent, 'share', 'rtems')
-sys.path = [base, parent, rtems] + sys.path
+sys.path = [rtems, os.path.join(rtems, 'tester')] + sys.path
try:
import rt.test
diff --git a/tester/wscript b/tester/wscript
index 8971529..56d0337 100644
--- a/tester/wscript
+++ b/tester/wscript
@@ -42,6 +42,8 @@ def configure(conf):
recurse(conf)
conf.load('python')
conf.check_python_version((2,6,6))
+ conf.env['PYO'] = 0
+ conf.env['PYC'] = 0
def build(bld):
recurse(bld)
@@ -60,12 +62,12 @@ def build(bld):
'rt/stty.py',
'rt/test.py',
'rt/version.py'],
- install_path = '${PREFIX}/share/rtems/rt')
+ install_path = '${PREFIX}/share/rtems')
bld(features = 'py',
source = ['rt/pygdb/__init__.py',
'rt/pygdb/mi_parser.py',
'rt/pygdb/spark.py'],
- install_path = '${PREFIX}/share/rtems/rt/pygdb')
+ install_path = '${PREFIX}/share/rtems')
bld.install_files('${PREFIX}/bin', ['rtems-test'], chmod = 0o755)
#
diff --git a/wscript b/wscript
index e289858..9ed3e1b 100644
--- a/wscript
+++ b/wscript
@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
-# Copyright 2014 Chris Johns (chrisj@rtems.org)
+# Copyright 2014-2015 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -28,20 +28,33 @@
# POSSIBILITY OF SUCH DAMAGE.
#
+import os.path
+
subdirs = ['rtemstoolkit',
'linkers',
'tester',
'tools/gdb/python']
+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')
+ last_dot = release.rfind('.')
+ if last_dot == -1:
+ ctx.fatal('invalid VERSION file')
+ revision = release[0:last_dot]
+ return revision, release
+
def recurse(ctx):
for sd in subdirs:
ctx.recurse(sd)
def options(ctx):
- ctx.add_option('--rtems-version',
- default = '4.11',
- dest='rtems_version',
- help = 'Set the RTEMS version')
ctx.add_option('--c-opts',
default = '-O2',
dest='c_opts',
@@ -69,12 +82,14 @@ def configure(ctx):
ctx.load("doxygen", tooldir = 'waf-tools')
except:
pass
+ ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx)
ctx.env.C_OPTS = ctx.options.c_opts.split(',')
- ctx.env.RTEMS_VERSION = ctx.options.rtems_version
check_options(ctx, ctx.options.host)
recurse(ctx)
def build(ctx):
+ if os.path.exists('VERSION'):
+ ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION'])
recurse(ctx)
def install(ctx):