summaryrefslogtreecommitdiffstats
path: root/source-builder/sb/config.py
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2013-03-02 15:20:28 +1100
committerChris Johns <chrisj@rtems.org>2013-03-02 15:20:28 +1100
commitc096c20d7bca279fb83462553be1e5c45a540e84 (patch)
treea43505319c71ad68de83dfe88e1f428f534e2f7c /source-builder/sb/config.py
parentFix %setup now the scripts have been cleaned up. (diff)
downloadrtems-source-builder-c096c20d7bca279fb83462553be1e5c45a540e84.tar.bz2
Fix %{?:} and %{!?:} conditional macros.
Building on Windows showed the --enable-plugin was being set yet it was disabled. The code was just checking if the macro was defined and not actually testing the value. The value is now being tested and it needs to be true to succeed.
Diffstat (limited to 'source-builder/sb/config.py')
-rw-r--r--source-builder/sb/config.py50
1 files changed, 29 insertions, 21 deletions
diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
index b21201a..24c00ab 100644
--- a/source-builder/sb/config.py
+++ b/source-builder/sb/config.py
@@ -35,6 +35,16 @@ import execute
import log
import path
+def _check_bool(value):
+ if value.isdigit():
+ if int(value) == 0:
+ istrue = False
+ else:
+ istrue = True
+ else:
+ istrue = None
+ return istrue
+
class package:
def __init__(self, name, arch):
@@ -368,19 +378,27 @@ class file:
mn = self._label(m[start:start + colon])
if mn:
if m.startswith('%{?'):
+ istrue = False
if mn in self.defines:
- if colon >= 0:
- s = s.replace(m, m[start + colon + 1:-1])
- expanded = True
- mn = None
+ istrue = _check_bool(self.defines[mn])
+ if istrue is None:
+ istrue = False
+ if colon >= 0 and istrue:
+ s = s.replace(m, m[start + colon + 1:-1])
+ expanded = True
+ mn = None
else:
mn = '%{nil}'
else:
- if mn not in self.defines:
- if colon >= 0:
- s = s.replace(m, m[start + colon + 1:-1])
- expanded = True
- mn = None
+ isfalse = True
+ if mn in self.defines:
+ istrue = _check_bool(self.defines[mn])
+ if istrue is not None and istrue == True:
+ isfalse = False
+ if colon >= 0 and isfalse:
+ s = s.replace(m, m[start + colon + 1:-1])
+ expanded = True
+ mn = None
else:
mn = '%{nil}'
if mn:
@@ -442,16 +460,6 @@ class file:
def add(x, y):
return x + ' ' + str(y)
- def check_bool(value):
- if value.isdigit():
- if int(value) == 0:
- istrue = False
- else:
- istrue = True
- else:
- istrue = None
- return istrue
-
istrue = False
if isvalid:
if len(ls) == 2:
@@ -469,13 +477,13 @@ class file:
elif ifls[0] == '!=':
istrue = False
else:
- istrue = check_bool(ifls[0])
+ istrue = _check_bool(ifls[0])
if istrue == None:
self._error('invalid if bool value: ' + reduce(add, ls, ''))
istrue = False
elif len(ifls) == 2:
if ifls[0] == '!':
- istrue = check_bool(ifls[1])
+ istrue = _check_bool(ifls[1])
if istrue == None:
self._error('invalid if bool value: ' + reduce(add, ls, ''))
istrue = False