summaryrefslogtreecommitdiffstats
path: root/source-builder/sb/options.py
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2013-04-13 10:34:04 +1000
committerChris Johns <chrisj@rtems.org>2013-04-13 10:34:04 +1000
commit014bfa95728b77f4345b3cbb886c61d1d0003d79 (patch)
treeea050189db6df40e1e0d4b0ccc5674ad923159dc /source-builder/sb/options.py
parentMacros updates to support multiple maps. (diff)
downloadrtems-source-builder-014bfa95728b77f4345b3cbb886c61d1d0003d79.tar.bz2
Add --macros option to load macro files.
Diffstat (limited to 'source-builder/sb/options.py')
-rw-r--r--source-builder/sb/options.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py
index 2a1df76..778a22f 100644
--- a/source-builder/sb/options.py
+++ b/source-builder/sb/options.py
@@ -51,6 +51,7 @@ class command_line:
'--jobs' : ('_jobs', self._lo_jobs, True, 'max', True),
'--log' : ('_logfile', self._lo_string, True, None, False),
'--url' : ('_url_base', self._lo_string, True, None, False),
+ '--macros' : ('_macros', self._lo_string, True, None, False),
'--targetcflags' : ('_targetcflags', self._lo_string, True, None, False),
'--targetcxxflags' : ('_targetcxxflags', self._lo_string, True, None, False),
'--libstdcxxflags' : ('_libstdcxxflags', self._lo_string, True, None, False),
@@ -196,8 +197,9 @@ class command_line:
print '--builddir path : Path to the build directory, default: ./build'
print '--sourcedir path : Path to the source directory, default: ./source'
print '--tmppath path : Path to the temp directory, default: ./tmp'
+ print '--macros file[,[file] : Macro format files to load after the defaults'
print '--log file : Log file where all build out is written too'
- print '--url url : URL to look for source'
+ print '--url url[,url] : URL to look for source'
print '--targetcflags flags : List of C flags for the target code'
print '--targetcxxflags flags : List of C++ flags for the target code'
print '--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code'
@@ -244,6 +246,13 @@ class command_line:
self.defaults['_smp_mflags'] = '-j %d' % (ncpus)
else:
self.defaults['_smp_mflags'] = self.defaults['nil']
+ um = self.user_macros()
+ if um:
+ checked = path.exists(um)
+ if False in checked:
+ raise general.error('macro file not found: %s' % (um[um.index(False)]))
+ for m in um:
+ self.defaults.load(m)
def command(self):
return path.join(self.command_path, self.command_name)
@@ -275,6 +284,28 @@ class command_line:
def always_clean(self):
return self.opts['always-clean'] != '0'
+ def user_macros(self):
+ #
+ # Return something even if it does not exist.
+ #
+ if self.opts['macros'] is None:
+ return None
+ um = []
+ configs = self.defaults.expand('%{_configdir}').split(':')
+ for m in self.opts['macros'].split(','):
+ if path.exists(m):
+ um += [m]
+ else:
+ # Get the expanded config macros then check them.
+ cm = path.expand(m, configs)
+ ccm = path.exists(cm)
+ if True in ccm:
+ # Pick the first found
+ um += [cm[ccm.index(True)]]
+ else:
+ um += [m]
+ return um if len(um) else None
+
def jobs(self, cpus):
cpus = int(cpus)
if self.opts['jobs'] == 'none':