From 7d80719f7472debdf7d54a61f9ffc7fc31d57d13 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Thu, 5 May 2022 12:32:16 +1000 Subject: sb/setbuilder: Control buildsets using the --with-* command line option - Expand macros in buildset file names - Add support to buildsets for `%defineifnot` - Update 6 and 7 to support command line build overrides Closes #4646 --- rtems/config/6/rtems-default.bset | 23 ++++++++++++----------- rtems/config/7/rtems-default.bset | 26 +++++++++++++++----------- rtems/config/tools/rtems-default-tools.bset | 15 +++++++++++++++ source-builder/sb/setbuilder.py | 22 +++++++++++++++------- 4 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 rtems/config/tools/rtems-default-tools.bset diff --git a/rtems/config/6/rtems-default.bset b/rtems/config/6/rtems-default.bset index 731c9d8..cee9091 100644 --- a/rtems/config/6/rtems-default.bset +++ b/rtems/config/6/rtems-default.bset @@ -4,16 +4,17 @@ %include 6/rtems-base.bset # -# Build gdb first to raise the Python install error as early as possible. -# GDB needs expat so it needs to be built before. +# Default RTEMS build. Override on the command line to the +# the RSB. For example to test the latest version of gcc use: # +# --with-rtems-gcc=tools/rtems-gcc-head-newlib-head +# +%defineifnot with_rtems_dtc devel/dtc-1.6.1-1 +%defineifnot with_rtems_expat devel/expat-2.4.8-1 +%defineifnot with_rtems_gmp devel/gmp-6.2.1 +%defineifnot with_rtems_gdb tools/rtems-gdb-11.2 +%defineifnot with_rtems_binutils tools/rtems-binutils-2.38 +%defineifnot with_rtems_gcc tools/rtems-gcc-10-newlib-head +%defineifnot with_rtems_tools tools/rtems-tools-6 -devel/dtc-1.6.1-1 - -devel/expat-2.4.8-1 -devel/gmp-6.2.1 -tools/rtems-gdb-11.2 - -tools/rtems-binutils-2.38 -tools/rtems-gcc-10-newlib-head -tools/rtems-tools-6 +tools/rtems-default-tools.bset diff --git a/rtems/config/7/rtems-default.bset b/rtems/config/7/rtems-default.bset index e94cf21..0a8fcac 100644 --- a/rtems/config/7/rtems-default.bset +++ b/rtems/config/7/rtems-default.bset @@ -1,16 +1,20 @@ +# +# Default tools configuration. +# %include 7/rtems-base.bset # -# Build gdb first to raise the Python install error as early as possible. -# GDB needs expat so it needs to be built before. +# Default RTEMS build. Override on the command line to the +# the RSB. For example to test the latest version of gcc use: # +# --with-rtems-gcc=tools/rtems-gcc-head-newlib-head +# +%defineifnot with_rtems_dtc devel/dtc-1.6.1-1 +%defineifnot with_rtems_expat devel/expat-2.4.8-1 +%defineifnot with_rtems_gmp devel/gmp-6.2.1 +%defineifnot with_rtems_gdb tools/rtems-gdb-head +%defineifnot with_rtems_binutils tools/rtems-binutils-head +%defineifnot with_rtems_gcc tools/rtems-gcc-head-newlib-head +%defineifnot with_rtems_tools tools/rtems-tools-6 -devel/dtc-1.6.1-1 - -devel/expat-2.4.8-1 -devel/gmp-6.2.1 -tools/rtems-gdb-head - -tools/rtems-binutils-head -tools/rtems-gcc-head-newlib-head -tools/rtems-tools-6 +tools/rtems-default-tools.bset diff --git a/rtems/config/tools/rtems-default-tools.bset b/rtems/config/tools/rtems-default-tools.bset new file mode 100644 index 0000000..7d273cf --- /dev/null +++ b/rtems/config/tools/rtems-default-tools.bset @@ -0,0 +1,15 @@ +# +# Default tools build +# + +# +# Build gdb first to raise the Python install error as early as +# possible. GDB needs expat so it needs to be built before gdb. +# +%{with_rtems_dtc} +%{with_rtems_expat} +%{with_rtems_gmp} +%{with_rtems_gdb} +%{with_rtems_binutils} +%{with_rtems_gcc} +%{with_rtems_tools} diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py index 63392fe..4d6ca81 100644 --- a/source-builder/sb/setbuilder.py +++ b/source-builder/sb/setbuilder.py @@ -284,6 +284,7 @@ class buildset: line = line[1:b] return line.strip() + bset = macro_expand(self.macros, bset) bsetname = bset if not path.exists(bsetname): @@ -315,15 +316,22 @@ class buildset: if ls[0][-1] == ':' and ls[0][:-1] == 'package': self.bset_pkg = ls[1].strip() self.macros['package'] = self.bset_pkg - elif ls[0][0] == '%': + elif ls[0][0] == '%' and (len(ls[0]) > 1 and ls[0][1] != '{'): def err(msg): raise error.general('%s:%d: %s' % (self.bset, lc, msg)) - if ls[0] == '%define': + if ls[0] == '%define' or ls[0] == '%defineifnot' : + name = ls[1].strip() + value = None if len(ls) > 2: - self.macros.define(ls[1].strip(), - ' '.join([f.strip() for f in ls[2:]])) - else: - self.macros.define(ls[1].strip()) + value = ' '.join([f.strip() for f in ls[2:]]) + if ls[0] == '%defineifnot': + if self.macros.defined(name): + name = None + if name is not None: + if value is not None: + self.macros.define(name, value) + else: + self.macros.define(name) elif ls[0] == '%undefine': if len(ls) > 2: raise error.general('%s:%d: %undefine requires ' \ @@ -336,7 +344,7 @@ class buildset: elif ls[0] == '%hash': sources.hash(ls[1:], self.macros, err) else: - l = l.strip() + l = macro_expand(self.macros, l.strip()) c = build.find_config(l, self.configs) if c is None: raise error.general('%s:%d: cannot find file: %s' % (self.bset, -- cgit v1.2.3