Changeset 7279748 in rtems-tools


Ignore:
Timestamp:
Dec 9, 2015, 8:36:26 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11
Children:
2244c9b
Parents:
5bd8121
Message:

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.

Files:
17 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    r5bd8121 r7279748  
    99.lock-waf*
    1010build
     11VERSION
  • linkers/rtems-ld.cpp

    r5bd8121 r7279748  
    213213        case 'V':
    214214          std::cout << "rtems-ld (RTEMS Linker) " << rld::version ()
     215                    << ", RTEMS revision " << rld::rtems::version ()
    215216                    << std::endl;
    216217          ::exit (0);
  • linkers/rtems-ra.cpp

    r5bd8121 r7279748  
    4343#include <rld-process.h>
    4444#include <rld-resolver.h>
     45#include <rld-rtems.h>
    4546
    4647#ifndef HAVE_KILL
     
    184185        case 'V':
    185186          std::cout << "rtems-ra (RTEMS Linker) " << rld::version ()
     187                    << ", RTEMS revision " << rld::rtems::version ()
    186188                    << std::endl;
    187189          ::exit (0);
  • linkers/rtems-rapper.cpp

    r5bd8121 r7279748  
    4545#include <rld-process.h>
    4646#include <rld-rap.h>
     47#include <rld-rtems.h>
    4748
    4849#include <rtems-utils.h>
     
    11731174        case 'V':
    11741175          std::cout << "rtems-rap (RTEMS RAP Manager) " << rld::version ()
     1176                    << ", RTEMS revision " << rld::rtems::version ()
    11751177                    << std::endl;
    11761178          ::exit (0);
  • linkers/rtems-syms.cpp

    r5bd8121 r7279748  
    4444#include <rld-process.h>
    4545#include <rld-symbols.h>
     46#include <rld-rtems.h>
    4647
    4748#ifndef HAVE_KILL
     
    330331        case 'V':
    331332          std::cout << "rtems-syms (RTEMS Symbols) " << rld::version ()
     333                    << ", RTEMS revision " << rld::rtems::version ()
    332334                    << std::endl;
    333335          ::exit (0);
  • linkers/rtems-tld.cpp

    r5bd8121 r7279748  
    17251725        case 'V':
    17261726          std::cout << "rtems-trace-ld (RTEMS Trace Linker) " << rld::version ()
     1727                    << ", RTEMS revision " << rld::rtems::version ()
    17271728                    << std::endl;
    17281729          ::exit (0);
  • linkers/wscript

    r5bd8121 r7279748  
    33#
    44import sys
    5 
    6 version_major = 1
    7 version_minor = 0
    8 version_revision = 0
    95
    106def options(opt):
     
    1612    conf.load('compiler_cxx')
    1713
    18     conf.env.C_OPTS = conf.options.c_opts.split(',')
    19     conf.env.RTEMS_VERSION = conf.options.rtems_version
    2014    conf.write_config_header('config.h')
    2115
     
    5650
    5751    #
     52    # The list of defines
     53    #
     54    defines = ['HAVE_CONFIG_H=1',
     55               'RTEMS_VERSION=\"%s\"' % (bld.env.RTEMS_VERSION),
     56               'RTEMS_RELEASE=\"%s\"' % (bld.env.RTEMS_RELEASE)]
     57
     58    #
    5859    # Build the linker.
    5960    #
    6061    bld.program(target = 'rtems-ld',
    6162                source = ['rtems-ld.cpp'],
    62                 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
     63                defines = defines,
    6364                includes = ['.'] + conf['includes'],
    6465                cflags = conf['cflags'] + conf['warningflags'],
     
    7273    bld.program(target = 'rtems-ra',
    7374                source = ['rtems-ra.cpp'],
    74                 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
     75                defines = defines,
    7576                includes = ['.'] + conf['includes'],
    7677                cflags = conf['cflags'] + conf['warningflags'],
     
    8485    bld.program(target = 'rtems-tld',
    8586                source = ['rtems-tld.cpp'],
    86                 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
     87                defines = defines,
    8788                includes = ['.'] + conf['includes'],
    8889                cflags = conf['cflags'] + conf['warningflags'],
     
    110111    bld.program(target = 'rtems-syms',
    111112                source = ['rtems-syms.cpp'],
    112                 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
     113                defines = defines,
    113114                includes = ['.'] + conf['includes'],
    114115                cflags = conf['cflags'] + conf['warningflags'],
     
    122123    bld.program(target = 'rtems-rap',
    123124                source = ['rtems-rapper.cpp'],
    124                 defines = ['HAVE_CONFIG_H=1', 'RTEMS_VERSION=' + bld.env.RTEMS_VERSION],
     125                defines = defines,
    125126                includes = ['.'] + conf['includes'],
    126127                cflags = conf['cflags'] + conf['warningflags'],
  • rtemstoolkit/git.py

    r5bd8121 r7279748  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
    66# This file is part of the RTEMS Tools package in 'rtems-tools'.
    7 #
    8 # Redistribution and use in source and binary forms, with or without
    9 # modification, are permitted provided that the following conditions are met:
    107#
    118# 1. Redistributions of source code must retain the above copyright notice,
     
    6259        return exit_code, output
    6360
    64     def __init__(self, _path, opts, macros = None):
     61    def __init__(self, _path, opts = None, macros = None):
    6562        self.path = _path
    6663        self.opts = opts
    67         if macros is None:
     64        if macros is None and opts is not None:
    6865            self.macros = opts.defaults
    6966        else:
    7067            self.macros = macros
    71         self.git = self.macros.expand('%{__git}')
     68        if self.macros is None:
     69            self.git = 'git'
     70        else:
     71            self.git = self.macros.expand('%{__git}')
    7272
    7373    def git_version(self):
     
    8787        ec, output = self._run(['fetch'], check = True)
    8888
     89    def merge(self):
     90        ec, output = self._run(['merge'], check = True)
     91
    8992    def pull(self):
    9093        ec, output = self._run(['pull'], check = True)
     
    105108    def checkout(self, branch = 'master'):
    106109        ec, output = self._run(['checkout', branch], check = True)
     110
     111    def submodule(self, module):
     112        ec, output = self._run(['submodule', 'update', '--init', module], check = True)
     113
     114    def clean(self, args = []):
     115        if type(args) == str:
     116            args = [args]
     117        ec, output = self._run(['clean'] + args, check = True)
    107118
    108119    def status(self):
     
    113124                state = 'none'
    114125                for l in output.split('\n'):
    115                     if l.startswith('# On branch '):
    116                         _status['branch'] = l[len('# On branch '):]
    117                     elif l.startswith('# Changes to be committed:'):
     126                    if l.startswith('# '):
     127                        l = l[2:]
     128                    if l.startswith('On branch '):
     129                        _status['branch'] = l[len('On branch '):]
     130                    elif l.startswith('Changes to be committed:'):
    118131                        state = 'staged'
    119                     elif l.startswith('# Changes not staged for commit:'):
     132                    elif l.startswith('Changes not staged for commit:'):
    120133                        state = 'unstaged'
    121                     elif l.startswith('# Untracked files:'):
     134                    elif l.startswith('Untracked files:'):
    122135                        state = 'untracked'
    123                     elif state != 'none' and l[0] == '#':
    124                         if l.strip() != '#' and not l.startswith('#   ('):
    125                             if state not in _status:
    126                                 _status[state] = []
    127                             l = l[1:]
    128                             if ':' in l:
    129                                 l = l.split(':')[1]
    130                             _status[state] += [l.strip()]
     136                    elif l.startswith('HEAD detached'):
     137                        state = 'detached'
     138                    elif state != 'none' and len(l.strip()) != 0:
     139                        if l[0].isspace():
     140                            l = l.strip()
     141                            if l[0] != '(':
     142                                if state not in _status:
     143                                    _status[state] = []
     144                                l = l[1:]
     145                                if ':' in l:
     146                                    l = l.split(':')[1]
     147                                _status[state] += [l.strip()]
    131148        return _status
    132149
    133     def clean(self):
     150    def dirty(self):
    134151        _status = self.status()
    135         return len(_status) == 1 and 'branch' in _status
     152        return not (len(_status) == 1 and 'branch' in _status)
    136153
    137154    def valid(self):
  • rtemstoolkit/options.py

    r5bd8121 r7279748  
    354354            repo_valid = '1'
    355355            repo_head = repo.head()
    356             repo_clean = repo.clean()
     356            repo_clean = not repo.dirty()
    357357            repo_id = repo_head
    358358            if not repo_clean:
  • rtemstoolkit/rld-rtems.cpp

    r5bd8121 r7279748  
    2525  namespace rtems
    2626  {
    27     static std::string _version = "4.11";
     27    static std::string _version = RTEMS_VERSION;
    2828    static std::string _path;
    2929    static std::string _arch_bsp;
  • rtemstoolkit/rld.cpp

    r5bd8121 r7279748  
    3333#include <rld.h>
    3434
    35 #define RLD_VERSION_MAJOR   (1)
    36 #define RLD_VERSION_MINOR   (0)
    37 #define RLD_VERSION_RELEASE (0)
    38 
    3935namespace rld
    4036{
     
    203199  version ()
    204200  {
    205     std::string v = (rld::to_string (RLD_VERSION_MAJOR) + '.' +
    206                      rld::to_string (RLD_VERSION_MINOR) + '.' +
    207                      rld::to_string (RLD_VERSION_RELEASE));
    208     return v;
     201    return RTEMS_RELEASE;
    209202  }
    210203
     
    212205  rtems_version ()
    213206  {
    214     return rld::to_string (RTEMS_VERSION);
     207    return RTEMS_VERSION;
    215208  }
    216209
  • rtemstoolkit/version.py

    r5bd8121 r7279748  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3030
    3131#
    32 # Manage paths locally. The internally the path is in Unix or shell format and
    33 # we convert to the native format when performing operations at the Python
    34 # level. This allows macro expansion to work.
     32# To release RTEMS Tools create a git archive and then add a suitable VERSION
     33# file to the top directory.
    3534#
    3635
    37 major = 0
    38 minor = 0
    39 revision = 0
     36import sys
     37
     38import error
     39import git
     40import path
     41
     42#
     43# Default to an internal string.
     44#
     45_version_str = '4.11.not_release'
     46_released = False
     47_git = False
     48
     49def _at():
     50    return path.dirname(__file__)
     51
     52def _load_released_version():
     53    global _released
     54    global _version_str
     55    at = _at()
     56    for ver in [at, path.join(at, '..')]:
     57        if path.exists(path.join(ver, 'VERSION')):
     58            try:
     59                with open(path.join(ver, 'VERSION')) as v:
     60                    _version_str = v.readline().strip()
     61                v.close()
     62                _released = True
     63            except:
     64                raise error.general('Cannot access the VERSION file')
     65    return _released
     66
     67def _load_git_version():
     68    global _git
     69    global _version_str
     70    repo = git.repo(_at())
     71    if repo.valid():
     72        head = repo.head()
     73        if repo.dirty():
     74            modified = ' modified'
     75        else:
     76            modified = ''
     77        _version_str = '%s (%s%s)' % (_version_str, head[0:12], modified)
     78        _git = True
     79    return _git
     80
     81def released():
     82    return _load_released_version()
     83
     84def version_control():
     85    return _load_git_version()
    4086
    4187def str():
    42     return '%d.%d.%d'% (major, minor, revision)
     88    if not _released and not _git:
     89        if not _load_released_version():
     90            _load_git_version()
     91    return _version_str
    4392
    4493if __name__ == '__main__':
    45     print 'major = %d' % (major)
    46     print 'minor = %d' % (minor)
    47     print 'revision = %d' % (revision)
    4894    print 'Version: %s' % (str())
  • rtemstoolkit/wscript

    r5bd8121 r7279748  
    33#
    44import sys
    5 
    6 version_major = 1
    7 version_minor = 0
    8 version_revision = 0
    95
    106#
     
    2824                  features = 'c', mandatory = False)
    2925    conf.write_config_header('config.h')
     26
     27    conf.load('python')
     28    conf.check_python_version((2,6,6))
     29    conf.env['PYO'] = 0
     30    conf.env['PYC'] = 0
    3031
    3132def build(bld):
     
    9495              source = rld_source + rtems_utils + compression,
    9596              defines = ['HAVE_CONFIG_H=1',
    96                          'RTEMS_VERSION=' + bld.env.RTEMS_VERSION,
     97                         'RTEMS_VERSION=\"%s\"' % (bld.env.RTEMS_VERSION),
     98                         'RTEMS_RELEASE=\"%s\"' % (bld.env.RTEMS_RELEASE),
    9799                         'FASTLZ_LEVEL=1'],
    98100              includes = ['.'] + conf['includes'],
     
    122124                  'version.py',
    123125                  'windows.py'],
    124         install_path = '${PREFIX}/share/rtems/rtemstoolkit')
     126        install_path = '${PREFIX}/share/rtems')
    125127
    126128def rebuild(ctx):
  • tester/rt/test.py

    r5bd8121 r7279748  
    4040from rtemstoolkit import path
    4141from rtemstoolkit import stacktraces
     42from rtemstoolkit import version
    4243
    4344import bsps
     
    4647import options
    4748import report
    48 import version
    4949import fnmatch
    5050
     
    202202                            optargs = optargs,
    203203                            command_path = command_path)
    204         log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
     204        log.notice('RTEMS Testing - Tester, %s' % (version.str()))
    205205        if opts.find_arg('--list-bsps'):
    206206            bsps.list(opts)
  • tester/rtems-test

    r5bd8121 r7279748  
    22#
    33# RTEMS Tools Project (http://www.rtems.org/)
    4 # Copyright 2013 Chris Johns (chrisj@rtems.org)
     4# Copyright 2013, 2015 Chris Johns (chrisj@rtems.org)
    55# All rights reserved.
    66#
     
    3434parent = os.path.dirname(base)
    3535rtems = os.path.join(parent, 'share', 'rtems')
    36 sys.path = [base, parent, rtems] + sys.path
     36sys.path = [rtems, os.path.join(rtems, 'tester')] + sys.path
    3737
    3838try:
  • tester/wscript

    r5bd8121 r7279748  
    4343    conf.load('python')
    4444    conf.check_python_version((2,6,6))
     45    conf.env['PYO'] = 0
     46    conf.env['PYC'] = 0
    4547
    4648def build(bld):
     
    6163                  'rt/test.py',
    6264                  'rt/version.py'],
    63         install_path = '${PREFIX}/share/rtems/rt')
     65        install_path = '${PREFIX}/share/rtems')
    6466    bld(features = 'py',
    6567        source = ['rt/pygdb/__init__.py',
    6668                  'rt/pygdb/mi_parser.py',
    6769                  'rt/pygdb/spark.py'],
    68         install_path = '${PREFIX}/share/rtems/rt/pygdb')
     70        install_path = '${PREFIX}/share/rtems')
    6971    bld.install_files('${PREFIX}/bin', ['rtems-test'], chmod = 0o755)
    7072
  • wscript

    r5bd8121 r7279748  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2014-2015 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    2929#
    3030
     31import os.path
     32
    3133subdirs = ['rtemstoolkit',
    3234           'linkers',
    3335           'tester',
    3436           'tools/gdb/python']
     37
     38def get_version(ctx):
     39    release = '4.11.not_released'
     40    if os.path.exists('VERSION'):
     41        try:
     42            with open('VERSION') as v:
     43                release = v.readline().strip()
     44            v.close()
     45        except:
     46            ctx.fatal('cannot access the VERSION file')
     47    last_dot = release.rfind('.')
     48    if last_dot == -1:
     49        ctx.fatal('invalid VERSION file')
     50    revision = release[0:last_dot]
     51    return revision, release
    3552
    3653def recurse(ctx):
     
    3956
    4057def options(ctx):
    41     ctx.add_option('--rtems-version',
    42                    default = '4.11',
    43                    dest='rtems_version',
    44                    help = 'Set the RTEMS version')
    4558    ctx.add_option('--c-opts',
    4659                   default = '-O2',
     
    7083    except:
    7184        pass
     85    ctx.env.RTEMS_VERSION, ctx.env.RTEMS_RELEASE = get_version(ctx)
    7286    ctx.env.C_OPTS = ctx.options.c_opts.split(',')
    73     ctx.env.RTEMS_VERSION = ctx.options.rtems_version
    7487    check_options(ctx, ctx.options.host)
    7588    recurse(ctx)
    7689
    7790def build(ctx):
     91    if os.path.exists('VERSION'):
     92        ctx.install_files('${PREFIX}/share/rtems/rtemstoolkit', ['VERSION'])
    7893    recurse(ctx)
    7994
Note: See TracChangeset for help on using the changeset viewer.