[rtems-source-builder commit] sb: Support --dry-run --with-download for 3rd party RTEMS BSP packages.
Chris Johns
chrisj at rtems.org
Thu Mar 17 05:53:12 UTC 2016
Module: rtems-source-builder
Branch: 4.11
Commit: 0e22c3c7ffa47699530f43197ed70df172b80ba0
Changeset: http://git.rtems.org/rtems-source-builder/commit/?id=0e22c3c7ffa47699530f43197ed70df172b80ba0
Author: Chris Johns <chrisj at rtems.org>
Date: Thu Mar 17 16:39:57 2016 +1100
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.
---
rtems/config/rtems-bsp.cfg | 22 +++++++++--
source-builder/pkg-config | 2 +-
source-builder/sb/check.py | 2 +
source-builder/sb/config.py | 81 +++++++++++++++++++++++++++++++++++------
source-builder/sb/options.py | 9 ++++-
source-builder/sb/pkgconfig.py | 1 +
source-builder/sb/setbuilder.py | 2 +
source-builder/sb/version.py | 3 ++
8 files changed, 104 insertions(+), 18 deletions(-)
diff --git a/rtems/config/rtems-bsp.cfg b/rtems/config/rtems-bsp.cfg
index d5868ca..2664776 100644
--- a/rtems/config/rtems-bsp.cfg
+++ b/rtems/config/rtems-bsp.cfg
@@ -12,7 +12,18 @@
# (--with-tools) is not provided use the prefix.
#
-%if %{_target} == %{nil}
+#
+# If a dry-run and with download ignore errors and correct setting for tools
+# and BSPs. Only after the source to download.
+#
+%if %{_dry_run} && %{defined with_download}
+ %log BSP configuration errors ignored
+ %define rtems_bsp_error 0
+%else
+ %define rtems_bsp_error 1
+%endif
+
+%if %{_target} == %{nil} && %{rtems_bsp_error}
%error No RTEMS target specified: --rtems-bsp=arch/bsp (or --target=target)
%endif
@@ -21,7 +32,10 @@
%endif
%ifn %{defined with_rtems_bsp}
- %error No RTEMS BSP specified: --rtems-bsp=arch/bsp (or --with-rtems-bsp=bsp)
+ %if %{rtems_bsp_error}
+ %error No RTEMS BSP specified: --rtems-bsp=arch/bsp (or --with-rtems-bsp=bsp)
+ %endif
+ %define with_rtems_bsp sparc/erc32
%endif
%ifn %{defined with_tools}
@@ -56,12 +70,12 @@
%define rtems_bsp_ldflags %{pkgconfig ldflags %{_host}-%{rtems_bsp}}
%define rtems_bsp_libs %{pkgconfig libs %{_host}-%{rtems_bsp}}
-%if %{rtems_bsp_cflags} == %{nil}
+%if %{rtems_bsp_cflags} == %{nil} && %{rtems_bsp_error}
%error No RTEMS target CFLAGS found; Please check the --rtems-bsp option.
%endif
%if %{rtems_bsp_ccflags} == %{nil}
- %define rtems_bsp_ccflags %{rtems_bsp_cflags}
+ %define rtems_bsp_ccflags %{rtems_bsp_cflags}
%endif
#
diff --git a/source-builder/pkg-config b/source-builder/pkg-config
index a5dfba0..fa251e5 100755
--- a/source-builder/pkg-config
+++ b/source-builder/pkg-config
@@ -220,7 +220,7 @@ try:
except ImportError:
print("incorrect package config installation", file = sys.stderr)
sys.exit(1)
-except pkgconfig.error, e:
+except pkgconfig.error as e:
print('error: %s' % (e), file = sys.stderr)
sys.exit(1)
sys.exit(ec)
diff --git a/source-builder/sb/check.py b/source-builder/sb/check.py
index 3e847ce..85a1fbe 100644
--- a/source-builder/sb/check.py
+++ b/source-builder/sb/check.py
@@ -132,6 +132,7 @@ def host_setup(opts):
sane = True
+ log.trace('--- check host set up : start"')
for d in list(opts.defaults.keys()):
try:
(test, constraint, value) = opts.defaults.get(d)
@@ -152,6 +153,7 @@ def host_setup(opts):
log.trace('%c %15s: %r -> "%s"' % (tag, d, opts.defaults.get(d), value))
if sane and not ok:
sane = False
+ log.trace('--- check host set up : end"')
return sane
diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
index 8a0c01b..8fb9ac0 100644
--- a/source-builder/sb/config.py
+++ b/source-builder/sb/config.py
@@ -574,6 +574,14 @@ class file:
s = s.replace(m, '0')
expanded = True
mn = None
+ elif m.startswith('%{!defined'):
+ n = self._label(m[10:-1].strip())
+ if n in self.macros:
+ s = s.replace(m, '0')
+ else:
+ s = s.replace(m, '1')
+ expanded = True
+ mn = None
elif m.startswith('%{path '):
pl = m[7:-1].strip().split()
ok = False
@@ -752,13 +760,45 @@ class file:
def add(x, y):
return x + ' ' + str(y)
- istrue = False
- if isvalid:
- if len(ls) == 2:
- s = ls[1]
- else:
- s = (ls[1] + ' ' + ls[2])
- ifls = s.split()
+ if len(ls) == 1:
+ self._error('invalid if expression: ' + reduce(add, ls, ''))
+
+ cistrue = True # compound istrue
+ sls = reduce(add, ls[1:], '').split()
+ cls = sls
+
+ while len(cls) > 0 and isvalid:
+
+ join_op = 'none'
+
+ if cls[0] == '||' or cls[0] == '&&':
+ if cls[0] == '||':
+ join_op = 'or'
+ elif cls[0] == '&&':
+ join_op = 'and'
+ cls = cls[1:]
+ ori = 0
+ andi = 0
+ i = len(cls)
+ if '||' in cls:
+ ori = cls.index('||')
+ if '&&' in cls:
+ andi = cls.index('&&')
+ if ori > 0 or andi > 0:
+ if ori < andi:
+ i = ori
+ else:
+ i = andi
+ if ori == 0:
+ i = andi
+ ls = cls[:i]
+ if len(ls) == 0:
+ self._error('invalid if expression: ' + reduce(add, sls, ''))
+ cls = cls[i:]
+
+ istrue = False
+
+ ifls = ls
if len(ifls) == 1:
#
# Check if '%if %{x} == %{nil}' has both parts as nothing
@@ -835,10 +875,22 @@ class file:
istrue = False
else:
self._error('invalid %if operator: ' + reduce(add, ls, ''))
- if invert:
- istrue = not istrue
- log.trace('config: %s: _if: %s %s' % (self.name, ifls, str(istrue)))
- return self._ifs(config, ls, '%if', istrue, isvalid, dir, info)
+
+ if join_op == 'or':
+ if istrue:
+ cistrue = True
+ elif join_op == 'and':
+ if not istrue:
+ cistrue = False
+ else:
+ cistrue = istrue
+
+ log.trace('config: %s: _if: %s %s %s %s' % (self.name, ifls, str(cistrue),
+ join_op, str(istrue)))
+
+ if invert:
+ cistrue = not cistrue
+ return self._ifs(config, ls, '%if', cistrue, isvalid, dir, info)
def _ifos(self, config, ls, isvalid, dir, info):
isos = False
@@ -922,6 +974,9 @@ class file:
elif ls[0] == '%error':
if isvalid:
return ('data', ['%%error %s' % (self._name_line_msg(l[7:]))])
+ elif ls[0] == '%log':
+ if isvalid:
+ return ('data', ['%%log %s' % (self._name_line_msg(l[4:]))])
elif ls[0] == '%warning':
if isvalid:
return ('data', ['%%warning %s' % (self._name_line_msg(l[9:]))])
@@ -1019,9 +1074,11 @@ class file:
if l.startswith('%error'):
l = self._expand(l)
raise error.general('config error: %s' % (l[7:]))
+ elif l.startswith('%log'):
+ l = self._expand(l)
+ log.output(l[4:])
elif l.startswith('%warning'):
l = self._expand(l)
- log.stderr('warning: %s' % (l[9:]))
log.warning(l[9:])
if not directive:
l = self._expand(l)
diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py
index ba1eff0..7791329 100644
--- a/source-builder/sb/options.py
+++ b/source-builder/sb/options.py
@@ -254,6 +254,13 @@ class command_line:
else:
value = '='.join(los[1:])
long_opt[1](lo, long_opt[0], value)
+ else:
+ if a.startswith('--with'):
+ if len(los) != 1:
+ value = los[1]
+ else:
+ value = '1'
+ self.defaults[los[0][2:].replace('-', '_').lower()] = ('none', 'none', value)
else:
self.opts['params'].append(a)
arg += 1
@@ -548,7 +555,7 @@ class command_line:
raise error.general('invalid --rtems-bsp option')
rtems_version = self.parse_args('--rtems-version')
if rtems_version is None:
- rtems_version = '%d.%d' % (version.major, version.minor)
+ rtems_version = version.version()
else:
rtems_version = rtems_version[1]
self.args.append('--target=%s-rtems%s' % (ab[0], rtems_version))
diff --git a/source-builder/sb/pkgconfig.py b/source-builder/sb/pkgconfig.py
index c7cbbab..519e858 100755
--- a/source-builder/sb/pkgconfig.py
+++ b/source-builder/sb/pkgconfig.py
@@ -214,6 +214,7 @@ class package(object):
if prefix:
self._log('prefix: %s' % (prefix))
if type(prefix) is str:
+ self.prefix = []
for p in prefix.split(os.pathsep):
self.prefix += [path.shell(p)]
elif type(prefix) is list:
diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py
index 3d20b73..1b75cf3 100644
--- a/source-builder/sb/setbuilder.py
+++ b/source-builder/sb/setbuilder.py
@@ -60,6 +60,8 @@ class buildset:
self.macros = copy.copy(opts.defaults)
else:
self.macros = copy.copy(macros)
+ log.trace('_bset: %s: macro defaults' % (bset))
+ log.trace(str(self.macros))
self.bset = bset
_target = self.macros.expand('%{_target}')
if len(_target):
diff --git a/source-builder/sb/version.py b/source-builder/sb/version.py
index 7f8efea..d1daeec 100644
--- a/source-builder/sb/version.py
+++ b/source-builder/sb/version.py
@@ -111,5 +111,8 @@ def load_release_hashes(macros):
raise error.general('invalid release hash in VERSION')
sources.hash((hs[0], hash[0], hs[1]), macros, hash_error)
+def version():
+ return _version
+
if __name__ == '__main__':
print('Version: %s' % (str()))
More information about the vc
mailing list