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.
This commit is contained in:
Chris Johns
2015-12-09 20:08:19 +11:00
parent c9fa179561
commit efc4f099b4
17 changed files with 159 additions and 75 deletions

1
.gitignore vendored
View File

@@ -8,3 +8,4 @@ waf-*
waf3-*
.lock-waf*
build
VERSION

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -1736,6 +1736,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;

View File

@@ -33,10 +33,6 @@
#
import sys
version_major = 1
version_minor = 0
version_revision = 0
def options(opt):
opt.load('compiler_c')
opt.load('compiler_cxx')
@@ -45,8 +41,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):
@@ -84,12 +78,19 @@ 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'],
@@ -101,7 +102,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'],
@@ -113,7 +114,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'],
@@ -139,7 +140,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'],
@@ -151,7 +152,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'],

View File

@@ -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,13 +58,16 @@ 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
if self.macros is None:
self.git = 'git'
else:
self.git = self.macros.expand('%{__git}')
def git_version(self):
@@ -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,16 +123,22 @@ 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('# ('):
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:]
@@ -130,9 +147,9 @@ class repo:
_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):

View File

@@ -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'

View File

@@ -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;

View File

@@ -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

View File

@@ -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())

View File

@@ -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

View File

@@ -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')

View File

@@ -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,8 +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')
tester = os.path.join(parent, 'share', 'rtems', 'tester')
sys.path = [parent, rtems, tester] + sys.path
sys.path = [rtems, os.path.join(rtems, 'tester')] + sys.path
try:
import rt.test

View File

@@ -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/tester')
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/tester')
install_path = '${PREFIX}/share/rtems')
bld.install_files('${PREFIX}/bin', ['rtems-test'], chmod = 0o755)
#

27
wscript
View File

@@ -1,6 +1,6 @@
#
# RTEMS Tools Project (http://www.rtems.org/)
# Copyright 2014, 2015 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.12.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):