source: rtems-source-builder/source-builder/sb/version.py @ 38ed59a

4.104.95
Last change on this file since 38ed59a was 38ed59a, checked in by Chris Johns <chrisj@…>, on 03/17/16 at 05:39:57

sb: Support --dry-run --with-download for 3rd party RTEMS BSP packages.

The building of 3rd party packages for an RTEMS BSP requires a valid
BSP so the standard method to download the source for releasing does
not work. This change adds support to allow this. The RTEMS BSP support
will not generate an error is no BSP or tools are provided or found.

The change addis logic operators to the %if statement so you can '
'

to 'or' and '&&' to 'and' logic expressions.

A new %log directive has been added to clean up the messages.

A new %{!define ...} has been added to aid checking within logic
expressions.

All command line --with/--without now appear as macros.

Add version.version to get just the RTEMS major and minor version.

Some pkg-config issues have been resolved.

Closes #2655.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# To release the RSB create a git archive and then add a suitable VERSION file
22# to the top directory.
23#
24
25from __future__ import print_function
26
27import sys
28
29import error
30import git
31import path
32import sources
33
34#
35# Default to an internal string.
36#
37_version = '4.12'
38_revision = 'not_released'
39_version_str = '%s.%s' % (_version, _revision)
40_released = False
41_git = False
42
43def _top():
44    top = path.dirname(sys.argv[0])
45    if len(top) == 0:
46        top = '.'
47    return top
48
49def _load_released_version_config():
50    top = _top()
51    for ver in [top, '..']:
52        if path.exists(path.join(ver, 'VERSION')):
53            try:
54                import configparser
55            except ImportError:
56                import ConfigParser as configparser
57            v = configparser.SafeConfigParser()
58            v.read(path.join(ver, 'VERSION'))
59            return v
60    return None
61
62def _load_released_version():
63    global _released
64    global _version_str
65    v = _load_released_version_config()
66    if v is not None:
67        _version_str = v.get('version', 'release')
68        _released = True
69    return _released
70
71def _load_git_version():
72    global _git
73    global _version_str
74    repo = git.repo(_top())
75    if repo.valid():
76        head = repo.head()
77        if repo.dirty():
78            modified = ' modified'
79        else:
80            modified = ''
81        _version_str = '%s (%s%s)' % (_version, head[0:12], modified)
82        _git = True
83    return _git
84
85def released():
86    return _load_released_version()
87
88def version_control():
89    return _load_git_version()
90
91def str():
92    if not _released and not _git:
93        if not _load_released_version():
94            _load_git_version()
95    return _version_str
96
97def load_release_hashes(macros):
98    def hash_error(msg):
99        raise error.general(msg)
100
101    if released():
102        v = _load_released_version_config()
103        if v is not None:
104            try:
105                hashes = v.items('hashes')
106            except:
107                hashes = []
108            for hash in hashes:
109                hs = hash[1].split()
110                if len(hs) != 2:
111                    raise error.general('invalid release hash in VERSION')
112                sources.hash((hs[0], hash[0], hs[1]), macros, hash_error)
113
114def version():
115    return _version
116
117if __name__ == '__main__':
118    print('Version: %s' % (str()))
Note: See TracBrowser for help on using the repository browser.