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-* waf3-*
.lock-waf* .lock-waf*
build build
VERSION

View File

@@ -212,6 +212,7 @@ main (int argc, char* argv[])
{ {
case 'V': case 'V':
std::cout << "rtems-ld (RTEMS Linker) " << rld::version () std::cout << "rtems-ld (RTEMS Linker) " << rld::version ()
<< ", RTEMS revision " << rld::rtems::version ()
<< std::endl; << std::endl;
::exit (0); ::exit (0);
break; break;

View File

@@ -42,6 +42,7 @@
#include <rld-outputter.h> #include <rld-outputter.h>
#include <rld-process.h> #include <rld-process.h>
#include <rld-resolver.h> #include <rld-resolver.h>
#include <rld-rtems.h>
#ifndef HAVE_KILL #ifndef HAVE_KILL
#define kill(p,s) raise(s) #define kill(p,s) raise(s)
@@ -183,6 +184,7 @@ main (int argc, char* argv[])
{ {
case 'V': case 'V':
std::cout << "rtems-ra (RTEMS Linker) " << rld::version () std::cout << "rtems-ra (RTEMS Linker) " << rld::version ()
<< ", RTEMS revision " << rld::rtems::version ()
<< std::endl; << std::endl;
::exit (0); ::exit (0);
break; break;

View File

@@ -44,6 +44,7 @@
#include <rld-files.h> #include <rld-files.h>
#include <rld-process.h> #include <rld-process.h>
#include <rld-rap.h> #include <rld-rap.h>
#include <rld-rtems.h>
#include <rtems-utils.h> #include <rtems-utils.h>
@@ -1172,6 +1173,7 @@ main (int argc, char* argv[])
{ {
case 'V': case 'V':
std::cout << "rtems-rap (RTEMS RAP Manager) " << rld::version () std::cout << "rtems-rap (RTEMS RAP Manager) " << rld::version ()
<< ", RTEMS revision " << rld::rtems::version ()
<< std::endl; << std::endl;
::exit (0); ::exit (0);
break; break;

View File

@@ -43,6 +43,7 @@
#include <rld-outputter.h> #include <rld-outputter.h>
#include <rld-process.h> #include <rld-process.h>
#include <rld-symbols.h> #include <rld-symbols.h>
#include <rld-rtems.h>
#ifndef HAVE_KILL #ifndef HAVE_KILL
#define kill(p,s) raise(s) #define kill(p,s) raise(s)
@@ -329,6 +330,7 @@ main (int argc, char* argv[])
{ {
case 'V': case 'V':
std::cout << "rtems-syms (RTEMS Symbols) " << rld::version () std::cout << "rtems-syms (RTEMS Symbols) " << rld::version ()
<< ", RTEMS revision " << rld::rtems::version ()
<< std::endl; << std::endl;
::exit (0); ::exit (0);
break; break;

View File

@@ -1736,6 +1736,7 @@ main (int argc, char* argv[])
{ {
case 'V': case 'V':
std::cout << "rtems-trace-ld (RTEMS Trace Linker) " << rld::version () std::cout << "rtems-trace-ld (RTEMS Trace Linker) " << rld::version ()
<< ", RTEMS revision " << rld::rtems::version ()
<< std::endl; << std::endl;
::exit (0); ::exit (0);
break; break;

View File

@@ -33,10 +33,6 @@
# #
import sys import sys
version_major = 1
version_minor = 0
version_revision = 0
def options(opt): def options(opt):
opt.load('compiler_c') opt.load('compiler_c')
opt.load('compiler_cxx') opt.load('compiler_cxx')
@@ -45,8 +41,6 @@ def configure(conf):
conf.load('compiler_c') conf.load('compiler_c')
conf.load('compiler_cxx') 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') conf.write_config_header('config.h')
def build(bld): def build(bld):
@@ -84,12 +78,19 @@ def build(bld):
# #
modules = ['rld', 'elf', 'iberty'] 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. # Build the linker.
# #
bld.program(target = 'rtems-ld', bld.program(target = 'rtems-ld',
source = ['rtems-ld.cpp'], source = ['rtems-ld.cpp'],
defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], defines = defines,
includes = ['.'] + conf['includes'], includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'], cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'], cxxflags = conf['cxxflags'] + conf['warningflags'],
@@ -101,7 +102,7 @@ def build(bld):
# #
bld.program(target = 'rtems-ra', bld.program(target = 'rtems-ra',
source = ['rtems-ra.cpp'], source = ['rtems-ra.cpp'],
defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], defines = defines,
includes = ['.'] + conf['includes'], includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'], cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'], cxxflags = conf['cxxflags'] + conf['warningflags'],
@@ -113,7 +114,7 @@ def build(bld):
# #
bld.program(target = 'rtems-tld', bld.program(target = 'rtems-tld',
source = ['rtems-tld.cpp'], source = ['rtems-tld.cpp'],
defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], defines = defines,
includes = ['.'] + conf['includes'], includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'], cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'], cxxflags = conf['cxxflags'] + conf['warningflags'],
@@ -139,7 +140,7 @@ def build(bld):
# #
bld.program(target = 'rtems-syms', bld.program(target = 'rtems-syms',
source = ['rtems-syms.cpp'], source = ['rtems-syms.cpp'],
defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], defines = defines,
includes = ['.'] + conf['includes'], includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'], cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'], cxxflags = conf['cxxflags'] + conf['warningflags'],
@@ -151,7 +152,7 @@ def build(bld):
# #
bld.program(target = 'rtems-rap', bld.program(target = 'rtems-rap',
source = ['rtems-rapper.cpp'], source = ['rtems-rapper.cpp'],
defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION], defines = defines,
includes = ['.'] + conf['includes'], includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'], cflags = conf['cflags'] + conf['warningflags'],
cxxflags = conf['cxxflags'] + conf['warningflags'], cxxflags = conf['cxxflags'] + conf['warningflags'],

View File

@@ -1,13 +1,10 @@
# #
# RTEMS Tools Project (http://www.rtems.org/) # 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. # All rights reserved.
# #
# This file is part of the RTEMS Tools package in 'rtems-tools'. # 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, # 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer. # this list of conditions and the following disclaimer.
# #
@@ -61,14 +58,17 @@ class repo:
self._git_exit_code(exit_code) self._git_exit_code(exit_code)
return exit_code, output return exit_code, output
def __init__(self, _path, opts, macros = None): def __init__(self, _path, opts = None, macros = None):
self.path = _path self.path = _path
self.opts = opts self.opts = opts
if macros is None: if macros is None and opts is not None:
self.macros = opts.defaults self.macros = opts.defaults
else: else:
self.macros = macros 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): def git_version(self):
ec, output = self._run(['--version'], True) ec, output = self._run(['--version'], True)
@@ -86,6 +86,9 @@ class repo:
def fetch(self): def fetch(self):
ec, output = self._run(['fetch'], check = True) ec, output = self._run(['fetch'], check = True)
def merge(self):
ec, output = self._run(['merge'], check = True)
def pull(self): def pull(self):
ec, output = self._run(['pull'], check = True) ec, output = self._run(['pull'], check = True)
@@ -105,6 +108,14 @@ class repo:
def checkout(self, branch = 'master'): def checkout(self, branch = 'master'):
ec, output = self._run(['checkout', branch], check = True) 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): def status(self):
_status = {} _status = {}
if path.exists(self.path): if path.exists(self.path):
@@ -112,27 +123,33 @@ class repo:
if ec == 0: if ec == 0:
state = 'none' state = 'none'
for l in output.split('\n'): for l in output.split('\n'):
if l.startswith('# On branch '): if l.startswith('# '):
_status['branch'] = l[len('# On branch '):] l = l[2:]
elif l.startswith('# Changes to be committed:'): if l.startswith('On branch '):
_status['branch'] = l[len('On branch '):]
elif l.startswith('Changes to be committed:'):
state = 'staged' state = 'staged'
elif l.startswith('# Changes not staged for commit:'): elif l.startswith('Changes not staged for commit:'):
state = 'unstaged' state = 'unstaged'
elif l.startswith('# Untracked files:'): elif l.startswith('Untracked files:'):
state = 'untracked' state = 'untracked'
elif state != 'none' and l[0] == '#': elif l.startswith('HEAD detached'):
if l.strip() != '#' and not l.startswith('# ('): state = 'detached'
if state not in _status: elif state != 'none' and len(l.strip()) != 0:
_status[state] = [] if l[0].isspace():
l = l[1:] l = l.strip()
if ':' in l: if l[0] != '(':
l = l.split(':')[1] if state not in _status:
_status[state] += [l.strip()] _status[state] = []
l = l[1:]
if ':' in l:
l = l.split(':')[1]
_status[state] += [l.strip()]
return _status return _status
def clean(self): def dirty(self):
_status = self.status() _status = self.status()
return len(_status) == 1 and 'branch' in _status return not (len(_status) == 1 and 'branch' in _status)
def valid(self): def valid(self):
if path.exists(self.path): if path.exists(self.path):

View File

@@ -353,7 +353,7 @@ class command_line(object):
if repo.valid(): if repo.valid():
repo_valid = '1' repo_valid = '1'
repo_head = repo.head() repo_head = repo.head()
repo_clean = repo.clean() repo_clean = not repo.dirty()
repo_id = repo_head repo_id = repo_head
if not repo_clean: if not repo_clean:
repo_id += '-modified' repo_id += '-modified'

View File

@@ -24,7 +24,7 @@ namespace rld
{ {
namespace rtems namespace rtems
{ {
static std::string _version = "4.12"; static std::string _version = RTEMS_VERSION;
static std::string _path; static std::string _path;
static std::string _arch_bsp; static std::string _arch_bsp;

View File

@@ -32,10 +32,6 @@
#include <rld.h> #include <rld.h>
#define RLD_VERSION_MAJOR (1)
#define RLD_VERSION_MINOR (0)
#define RLD_VERSION_RELEASE (0)
namespace rld namespace rld
{ {
static int verbose_level = 0; static int verbose_level = 0;
@@ -202,16 +198,13 @@ namespace rld
const std::string const std::string
version () version ()
{ {
std::string v = (rld::to_string (RLD_VERSION_MAJOR) + '.' + return RTEMS_RELEASE;
rld::to_string (RLD_VERSION_MINOR) + '.' +
rld::to_string (RLD_VERSION_RELEASE));
return v;
} }
const std::string const std::string
rtems_version () rtems_version ()
{ {
return rld::to_string (RTEMS_VERSION); return RTEMS_VERSION;
} }
void void

View File

@@ -1,6 +1,6 @@
# #
# RTEMS Tools Project (http://www.rtems.org/) # 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. # All rights reserved.
# #
# This file is part of the RTEMS Tools package in 'rtems-tools'. # 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 # To release RTEMS Tools create a git archive and then add a suitable VERSION
# we convert to the native format when performing operations at the Python # file to the top directory.
# level. This allows macro expansion to work.
# #
major = 0 import sys
minor = 0
revision = 0 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(): 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__': if __name__ == '__main__':
print('major = %d' % (major)) print 'Version: %s' % (str())
print('minor = %d' % (minor))
print('revision = %d' % (revision))
print('Version: %s' % (str()))

View File

@@ -33,10 +33,6 @@
# #
import sys import sys
version_major = 1
version_minor = 0
version_revision = 0
# #
# Waf system setup. Allow more than one build in the same tree. # Waf system setup. Allow more than one build in the same tree.
# #
@@ -60,6 +56,11 @@ def configure(conf):
features = 'c', mandatory = False) features = 'c', mandatory = False)
conf.write_config_header('config.h') 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): def build(bld):
# #
# The local configuration. # The local configuration.
@@ -125,7 +126,8 @@ def build(bld):
install_path = None, install_path = None,
source = rld_source + rtems_utils + compression, source = rld_source + rtems_utils + compression,
defines = ['HAVE_CONFIG_H=1', 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'], 'FASTLZ_LEVEL=1'],
includes = ['.'] + conf['includes'], includes = ['.'] + conf['includes'],
cflags = conf['cflags'] + conf['warningflags'], cflags = conf['cflags'] + conf['warningflags'],
@@ -153,7 +155,7 @@ def build(bld):
'stacktraces.py', 'stacktraces.py',
'version.py', 'version.py',
'windows.py'], 'windows.py'],
install_path = '${PREFIX}/share/rtems/rtemstoolkit') install_path = '${PREFIX}/share/rtems')
def rebuild(ctx): def rebuild(ctx):
import waflib.Options import waflib.Options

View File

@@ -39,13 +39,13 @@ from rtemstoolkit import error
from rtemstoolkit import log from rtemstoolkit import log
from rtemstoolkit import path from rtemstoolkit import path
from rtemstoolkit import stacktraces from rtemstoolkit import stacktraces
from rtemstoolkit import version
import bsps import bsps
import config import config
import console import console
import options import options
import report import report
import version
import fnmatch import fnmatch
class test(object): class test(object):
@@ -201,7 +201,7 @@ def run(command_path = None):
opts = options.load(sys.argv, opts = options.load(sys.argv,
optargs = optargs, optargs = optargs,
command_path = command_path) 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'): if opts.find_arg('--list-bsps'):
bsps.list(opts) bsps.list(opts)
exe_filter = opts.find_arg('--filter') exe_filter = opts.find_arg('--filter')

View File

@@ -1,7 +1,7 @@
#! /usr/bin/env python #! /usr/bin/env python
# #
# RTEMS Tools Project (http://www.rtems.org/) # 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. # All rights reserved.
# #
# This file is part of the RTEMS Tools package in 'rtems-tools'. # 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])) base = os.path.dirname(os.path.abspath(sys.argv[0]))
parent = os.path.dirname(base) parent = os.path.dirname(base)
rtems = os.path.join(parent, 'share', 'rtems') rtems = os.path.join(parent, 'share', 'rtems')
tester = os.path.join(parent, 'share', 'rtems', 'tester') sys.path = [rtems, os.path.join(rtems, 'tester')] + sys.path
sys.path = [parent, rtems, tester] + sys.path
try: try:
import rt.test import rt.test

View File

@@ -42,6 +42,8 @@ def configure(conf):
recurse(conf) recurse(conf)
conf.load('python') conf.load('python')
conf.check_python_version((2,6,6)) conf.check_python_version((2,6,6))
conf.env['PYO'] = 0
conf.env['PYC'] = 0
def build(bld): def build(bld):
recurse(bld) recurse(bld)
@@ -60,12 +62,12 @@ def build(bld):
'rt/stty.py', 'rt/stty.py',
'rt/test.py', 'rt/test.py',
'rt/version.py'], 'rt/version.py'],
install_path = '${PREFIX}/share/rtems/tester') install_path = '${PREFIX}/share/rtems')
bld(features = 'py', bld(features = 'py',
source = ['rt/pygdb/__init__.py', source = ['rt/pygdb/__init__.py',
'rt/pygdb/mi_parser.py', 'rt/pygdb/mi_parser.py',
'rt/pygdb/spark.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) bld.install_files('${PREFIX}/bin', ['rtems-test'], chmod = 0o755)
# #

27
wscript
View File

@@ -1,6 +1,6 @@
# #
# RTEMS Tools Project (http://www.rtems.org/) # 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. # All rights reserved.
# #
# This file is part of the RTEMS Tools package in 'rtems-tools'. # This file is part of the RTEMS Tools package in 'rtems-tools'.
@@ -28,20 +28,33 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
# #
import os.path
subdirs = ['rtemstoolkit', subdirs = ['rtemstoolkit',
'linkers', 'linkers',
'tester', 'tester',
'tools/gdb/python'] '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): def recurse(ctx):
for sd in subdirs: for sd in subdirs:
ctx.recurse(sd) ctx.recurse(sd)
def options(ctx): def options(ctx):
ctx.add_option('--rtems-version',
default = '4.11',
dest='rtems_version',
help = 'Set the RTEMS version')
ctx.add_option('--c-opts', ctx.add_option('--c-opts',
default = '-O2', default = '-O2',
dest='c_opts', dest='c_opts',
@@ -69,12 +82,14 @@ def configure(ctx):
ctx.load("doxygen", tooldir = 'waf-tools') ctx.load("doxygen", tooldir = 'waf-tools')
except: except:
pass pass
ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx)
ctx.env.C_OPTS = ctx.options.c_opts.split(',') ctx.env.C_OPTS = ctx.options.c_opts.split(',')
ctx.env.RTEMS_VERSION = ctx.options.rtems_version
check_options(ctx, ctx.options.host) check_options(ctx, ctx.options.host)
recurse(ctx) recurse(ctx)
def build(ctx): def build(ctx):
if os.path.exists('VERSION'):
ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION'])
recurse(ctx) recurse(ctx)
def install(ctx): def install(ctx):