From 7385feb2748b9b722a41b23f908daa6f40725bad Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Mon, 20 Jul 2015 13:49:42 +1000 Subject: Canandian Cross Compiling and RTEMS 3rd party package building Fixes. The change fixes installing for RTEMS 3rd Party packages where the RSB considered them Canadian Cross Compiling (Cxc). Fixing the Cxc issue broke real Cxc builds. The change corrects the issue of macros being changed in the Cxc and the prep data not being udpated. The configuration is loaded again after the updated macros. The macros are also copied and restored to ensure a clean stable base. The change also introduces --rtems-tools and --rtems-bsp to align the command line with the waf configure process or RTEMS application. --- rtems/config/rtems-bsp.cfg | 31 +++++++---- rtems/config/tools/rtems-autoconf-2.69-1.cfg | 4 ++ rtems/config/tools/rtems-automake-1.12.6-1.cfg | 4 ++ source-builder/defaults.mc | 4 +- source-builder/sb/build.py | 74 ++++++++++++++++++++------ source-builder/sb/config.py | 68 ++++++++++++----------- source-builder/sb/options.py | 35 ++++++++++-- source-builder/sb/path.py | 6 ++- source-builder/sb/setbuilder.py | 56 +++++++++++-------- source-builder/sb/version.py | 4 +- 10 files changed, 198 insertions(+), 88 deletions(-) diff --git a/rtems/config/rtems-bsp.cfg b/rtems/config/rtems-bsp.cfg index 3b24ec8..d5868ca 100644 --- a/rtems/config/rtems-bsp.cfg +++ b/rtems/config/rtems-bsp.cfg @@ -3,27 +3,36 @@ # # -# The RTEMS BSP support requires the host turple, the RTEMS BSP -# and the path to the tools. The prefix is set to an installed -# RTEMS. The built package is installed into the prefix. +# The RTEMS BSP support requires the host turple, the RTEMS BSP and the path to +# the tools. The prefix is set to an installed RTEMS. The built package is +# installed into the prefix. # -# Keeping the package's installed path in the RTEMS install path -# and separate to the tools lets the tools version vary -# independently. If --with-tools is not provided use the prefix. +# Keeping the package's installed path in the RTEMS install path and separate +# to the tools lets the tools version vary independently. If --rtems-tools +# (--with-tools) is not provided use the prefix. # -%if %{_host} == %{nil} - %error No RTEMS target specified: --host=host +%if %{_target} == %{nil} + %error No RTEMS target specified: --rtems-bsp=arch/bsp (or --target=target) +%endif + +%if %{_host} != %{_build} + %error Canadian cross building for BSP is not supported. %endif %ifn %{defined with_rtems_bsp} - %error No RTEMS BSP specified: --with-rtems-bsp=bsp + %error No RTEMS BSP specified: --rtems-bsp=arch/bsp (or --with-rtems-bsp=bsp) %endif %ifn %{defined with_tools} %define with_tools %{_prefix} %endif +# +# Set the host to the target. +# +%define _host %{_target} + # # Set the path to the tools. # @@ -47,6 +56,10 @@ %define rtems_bsp_ldflags %{pkgconfig ldflags %{_host}-%{rtems_bsp}} %define rtems_bsp_libs %{pkgconfig libs %{_host}-%{rtems_bsp}} +%if %{rtems_bsp_cflags} == %{nil} + %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} %endif diff --git a/rtems/config/tools/rtems-autoconf-2.69-1.cfg b/rtems/config/tools/rtems-autoconf-2.69-1.cfg index 1db8746..71ef4ed 100644 --- a/rtems/config/tools/rtems-autoconf-2.69-1.cfg +++ b/rtems/config/tools/rtems-autoconf-2.69-1.cfg @@ -2,6 +2,10 @@ # Autoconf 2.69. # +%if %{rtems_arch} == none + %define _target %{_host} +%endif + %include %{_configdir}/checks.cfg %include %{_configdir}/base.cfg %include %{_configdir}/versions.cfg diff --git a/rtems/config/tools/rtems-automake-1.12.6-1.cfg b/rtems/config/tools/rtems-automake-1.12.6-1.cfg index 1585cf4..f844013 100644 --- a/rtems/config/tools/rtems-automake-1.12.6-1.cfg +++ b/rtems/config/tools/rtems-automake-1.12.6-1.cfg @@ -2,6 +2,10 @@ # Automake 1.12.6 # +%if %{rtems_arch} == none + %define _target %{_host} +%endif + %include %{_configdir}/checks.cfg %include %{_configdir}/base.cfg %include %{_configdir}/versions.cfg diff --git a/source-builder/defaults.mc b/source-builder/defaults.mc index ce81c35..d38d090 100644 --- a/source-builder/defaults.mc +++ b/source-builder/defaults.mc @@ -79,12 +79,14 @@ _sourcedir: dir, optional, '%{_topdir}/sources' _patchdir: dir, optional, '%{_topdir}/patches:%{_sbdir}/patches' _builddir: dir, optional, '%{_topdir}/build/%{buildname}' _buildcxcdir: dir, optional, '%{_topdir}/build/%{buildname}-cxc' +_buildxcdir: dir, optional, '%{_topdir}/build/%{buildname}-xc' _docdir: dir, none, '%{_defaultdocdir}' _tmppath: dir, none, '%{_topdir}/build/tmp' _tmproot: dir, none, '%{_tmppath}/sb-%{_uid}/%{_bset}' _tmpcxcroot: dir, none, '%{_tmppath}/sb-%{_uid}-cxc/%{_bset}' buildroot: dir, none, '%{_tmppath}/%{buildname}-%{_uid}' buildcxcroot: dir, none, '%{_tmppath}/%{buildname}-%{_uid}-cxc' +buildxcroot: dir, none, '%{_tmppath}/%{buildname}-%{_uid}-xx' _datadir: dir, none, '%{_prefix}/share' _defaultdocdir: dir, none, '%{_prefix}/share/doc' _exeext: none, none, '' @@ -301,7 +303,7 @@ fi''' # Host/build flags. host_build_flags: none, none, ''' # Host and build flags, Cross build if host and build are different and -# Cxc build idf target is deifned and also different. +# Cxc build if target is deifned and also different. # Note, gcc is not ready to be compiled with -std=gnu99 (this needs to be checked). if test "%{_build}" != "%{_host}" ; then # Cross build diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py index 630a1a0..3241133 100644 --- a/source-builder/sb/build.py +++ b/source-builder/sb/build.py @@ -22,6 +22,7 @@ # installed not to be package unless you run a packager around this. # +import copy import getopt import glob import os @@ -116,12 +117,12 @@ class build: def __init__(self, name, create_tar_files, opts, macros = None): try: self.opts = opts - if macros is None: - self.macros = opts.defaults - else: - self.macros = macros + self.init_name = name + self.init_macros = macros + self.config = None self.create_tar_files = create_tar_files log.notice('config: ' + name) + self.set_macros(macros) self.config = config.file(name, opts, self.macros) self.script = script() self.macros['buildname'] = self._name_(self.macros['name']) @@ -136,6 +137,20 @@ class build: except: raise + def copy_init_macros(self): + return copy.copy(self.init_macros) + + def copy_macros(self): + return copy.copy(self.macros) + + def set_macros(self, macros): + if macros is None: + self.macros = copy.copy(opts.defaults) + else: + self.macros = copy.copy(macros) + if self.config: + self.config.set_macros(self.macros) + def rmdir(self, rmpath): log.output('removing: %s' % (path.host(rmpath))) if not self.opts.dry_run(): @@ -151,9 +166,30 @@ class build: _host = self.config.expand('%{_host}') _build = self.config.expand('%{_build}') _target = self.config.expand('%{_target}') - return self.config.defined('%{allow_cxc}') and \ - len(_host) and len(_build) and (_target) and \ - _host != _build and _host != _target + _allowed = self.config.defined('%{allow_cxc}') + if len(_host) and len(_build) and (_target) and \ + _allowed and _host != _build and _host != _target: + return True + return False + + def installable(self): + _host = self.config.expand('%{_host}') + _build = self.config.expand('%{_build}') + _canadian_cross = self.canadian_cross() + if self.macros.get('_disable_installing') and \ + self.config.expand('%{_disable_installing}') == 'yes': + _disable_installing = True + else: + _disable_installing = False + _no_install = self.opts.no_install() + log.trace('_build: installable: host=%s build=%s ' \ + 'no-install=%r Cxc=%r disable_installing=%r disabled=%r' % \ + (_host, _build, _no_install, _canadian_cross, _disable_installing, \ + self.disabled())) + return len(_host) and len(_build) and \ + not self.disabled() and \ + not _disable_installing and \ + not _canadian_cross def source(self, name): # @@ -313,7 +349,8 @@ class build: raise error.general('%s: %s' % (package, msg)) if args[0] == '%setup': if len(args) == 1: - raise error.general('invalid %%setup directive: %s' % (' '.join(args))) + raise error.general('invalid %%setup directive: %s' % \ + (' '.join(args))) if args[1] == 'source': self.source_setup(package, args[1:]) elif args[1] == 'patch': @@ -371,6 +408,8 @@ class build: def build_package(self, package): if self.canadian_cross(): + if not self.config.defined('%{allow_cxc}'): + raise error.general('Canadian Cross is not allowed') self.script.append('echo "==> Candian-cross build/target:"') self.script.append('SB_CXC="yes"') else: @@ -402,6 +441,9 @@ class build: packages = self.config.packages() return packages['main'] + def reload(self): + self.config.load(self.init_name) + def make(self): package = self.main_package() if package.disabled(): @@ -410,12 +452,13 @@ class build: try: name = package.name() if self.canadian_cross(): - log.notice('package: (Cxc) %s' % (name)) + cxc_label = '(Cxc) ' else: - log.notice('package: %s' % (name)) - log.trace('---- macro maps %s' % ('-' * 55)) - log.trace('%s' % (str(self.config.macros))) - log.trace('-' * 70) + cxc_label = '' + log.notice('package: %s%s' % (cxc_label, name)) + log.trace('---- macro maps %s' % ('-' * 55)) + log.trace('%s' % (str(self.config.macros))) + log.trace('-' * 70) self.script.reset() self.script.append(self.config.expand('%{___build_template}')) self.script.append('echo "=> ' + name + ':"') @@ -426,10 +469,7 @@ class build: sn = path.join(self.config.expand('%{_builddir}'), 'doit') log.output('write script: ' + sn) self.script.write(sn) - if self.canadian_cross(): - log.notice('building: (Cxc) %s' % (name)) - else: - log.notice('building: %s' % (name)) + log.notice('building: %s%s' % (cxc_label, name)) self.run(sn) except error.general, gerr: log.notice(str(gerr)) diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py index 1687d06..127112b 100644 --- a/source-builder/sb/config.py +++ b/source-builder/sb/config.py @@ -236,35 +236,14 @@ class file: re.compile('%disable') ] def __init__(self, name, opts, macros = None): + log.trace('config: %s: initialising' % (name)) self.opts = opts - if macros is None: - self.macros = opts.defaults - else: - self.macros = macros self.init_name = name - log.trace('config: %s' % (name)) - self.disable_macro_reassign = False - self.configpath = [] self.wss = re.compile(r'\s+') self.tags = re.compile(r':+') self.sf = re.compile(r'%\([^\)]+\)') - for arg in self.opts.args: - if arg.startswith('--with-') or arg.startswith('--without-'): - if '=' in arg: - label, value = arg.split('=', 1) - else: - label = arg - value = None - label = label[2:].lower().replace('-', '_') - if value: - self.macros.define(label, value) - else: - self.macros.define(label) - self._includes = [] - self.load_depth = 0 - self.pkgconfig_prefix = None - self.pkgconfig_crosscompile = False - self.pkgconfig_filter_flags = False + self.set_macros(macros) + self._reset(name) self.load(name) def __str__(self): @@ -286,6 +265,34 @@ class file: s += str(self._packages[_package]) return s + def _reset(self, name): + self.name = name + self.load_depth = 0 + self.configpath = [] + self._includes = [] + self._packages = {} + self.in_error = False + self.lc = 0 + self.conditionals = {} + self._packages = {} + self.package = 'main' + self.disable_macro_reassign = False + self.pkgconfig_prefix = None + self.pkgconfig_crosscompile = False + self.pkgconfig_filter_flags = False + for arg in self.opts.args: + if arg.startswith('--with-') or arg.startswith('--without-'): + if '=' in arg: + label, value = arg.split('=', 1) + else: + label = arg + value = None + label = label[2:].lower().replace('-', '_') + if value: + self.macros.define(label, value) + else: + self.macros.define(label) + def _relative_path(self, p): sbdir = None if '_sbdir' in self.macros: @@ -1053,6 +1060,12 @@ class file: def _info_append(self, info, data): self._packages[self.package].info_append(info, data) + def set_macros(self, macros): + if macros is None: + self.macros = opts.defaults + else: + self.macros = macros + def load(self, name): def common_end(left, right): @@ -1066,12 +1079,7 @@ class file: return end if self.load_depth == 0: - self.in_error = False - self.lc = 0 - self.name = name - self.conditionals = {} - self._packages = {} - self.package = 'main' + self._reset(name) self._packages[self.package] = package(self.package, self.define('%{_arch}'), self) diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py index e4964f0..c611dfe 100644 --- a/source-builder/sb/options.py +++ b/source-builder/sb/options.py @@ -221,6 +221,9 @@ class command_line: print '--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code' print '--with-