source: rtems-source-builder/source-builder/sb/options.py @ c799e04

5
Last change on this file since c799e04 was c799e04, checked in by Chris Johns <chrisj@…>, on 07/06/19 at 09:20:09

5/packages: Add curl and update all packages with RTEMS 5 and LibBSD

  • Update rtems-bsp support to correctly handle hosts for BSP.
  • Clean up the options for a BSP.
  • Check all RTEMS 5 packages and add 5/rtems-packages for all that build.
  • Update download locations and checksum of all packages.
  • The work requires the kernel and Libbsd hacve the same prefix.
  • Property mode set to 100644
File size: 27.7 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# Determine the defaults and load the specific file.
22#
23
24from __future__ import print_function
25
26import datetime
27import glob
28import pprint
29import re
30import os
31import string
32
33import error
34import execute
35import git
36import log
37import macros
38import path
39import sys
40
41import version
42
43basepath = 'sb'
44
45#
46# Save the host and POSIX state.
47#
48host_windows = False
49host_posix = True
50
51class command_line:
52    """Process the command line in a common way for all Tool Builder commands."""
53
54    def __init__(self, argv, optargs, _defaults, command_path):
55        self._long_opts = {
56            # key                       macro                handler            param  defs   init
57            '--prefix'               : ('_prefix',           self._lo_path,     True,  None,  False),
58            '--topdir'               : ('_topdir',           self._lo_path,     True,  None,  False),
59            '--configdir'            : ('_configdir',        self._lo_path,     True,  None,  False),
60            '--builddir'             : ('_builddir',         self._lo_path,     True,  None,  False),
61            '--sourcedir'            : ('_sourcedir',        self._lo_path,     True,  None,  False),
62            '--patchdir'             : ('_patchdir',         self._lo_path,     True,  None,  False),
63            '--tmppath'              : ('_tmppath',          self._lo_path,     True,  None,  False),
64            '--jobs'                 : ('_jobs',             self._lo_jobs,     True,  'max', True),
65            '--log'                  : ('_logfile',          self._lo_string,   True,  None,  False),
66            '--url'                  : ('_url_base',         self._lo_string,   True,  None,  False),
67            '--no-download'          : ('_disable_download', self._lo_bool,     False, '0',   True),
68            '--macros'               : ('_macros',           self._lo_string,   True,  None,  False),
69            '--source-only-download' : ('_source_download',  self._lo_bool,     False, '0',   True),
70            '--targetcflags'         : ('_targetcflags',     self._lo_string,   True,  None,  False),
71            '--targetcxxflags'       : ('_targetcxxflags',   self._lo_string,   True,  None,  False),
72            '--libstdcxxflags'       : ('_libstdcxxflags',   self._lo_string,   True,  None,  False),
73            '--force'                : ('_force',            self._lo_bool,     False, '0',   True),
74            '--quiet'                : ('_quiet',            self._lo_bool,     False, '0',   True),
75            '--trace'                : ('_trace',            self._lo_bool,     False, '0',   True),
76            '--dry-run'              : ('_dry_run',          self._lo_bool,     False, '0',   True),
77            '--warn-all'             : ('_warn_all',         self._lo_bool,     False, '0',   True),
78            '--no-clean'             : ('_no_clean',         self._lo_bool,     False, '0',   True),
79            '--keep-going'           : ('_keep_going',       self._lo_bool,     False, '0',   True),
80            '--always-clean'         : ('_always_clean',     self._lo_bool,     False, '0',   True),
81            '--no-install'           : ('_no_install',       self._lo_bool,     False, '0',   True),
82            '--regression'           : ('_regression',       self._lo_bool,     False, '0',   True),
83            '--host'                 : ('_host',             self._lo_triplets, True,  None,  False),
84            '--build'                : ('_build',            self._lo_triplets, True,  None,  False),
85            '--target'               : ('_target',           self._lo_triplets, True,  None,  False),
86            '--rtems-tools'          : ('_rtems_tools',      self._lo_string,   True,  None,  False),
87            '--rtems-bsp'            : ('_rtems_bsp',        self._lo_string,   True,  None,  False),
88            '--rtems-version'        : ('_rtems_version',    self._lo_string,   True,  None,  False),
89            '--help'                 : (None,                self._lo_help,     False, None,  False)
90            }
91
92        self.command_path = command_path
93        self.command_name = path.basename(argv[0])
94        self.argv = argv
95        self.args = argv[1:]
96        self.optargs = optargs
97        self.defaults = _defaults
98        self.opts = { 'params' : [] }
99        for lo in self._long_opts:
100            self.opts[lo[2:]] = self._long_opts[lo][3]
101            if self._long_opts[lo][4]:
102                self.defaults[self._long_opts[lo][0]] = ('none', 'none', self._long_opts[lo][3])
103
104    def __str__(self):
105        def _dict(dd):
106            s = ''
107            ddl = list(dd.keys())
108            ddl.sort()
109            for d in ddl:
110                s += '  ' + d + ': ' + str(dd[d]) + '\n'
111            return s
112
113        s = 'command: ' + self.command() + \
114            '\nargs: ' + str(self.args) + \
115            '\nopts:\n' + _dict(self.opts)
116
117        return s
118
119    def _lo_string(self, opt, macro, value):
120        if value is None:
121            raise error.general('option requires a value: %s' % (opt))
122        self.opts[opt[2:]] = value
123        self.defaults[macro] = value
124
125    def _lo_path(self, opt, macro, value):
126        if value is None:
127            raise error.general('option requires a path: %s' % (opt))
128        value = path.abspath(value)
129        self.opts[opt[2:]] = value
130        self.defaults[macro] = value
131
132    def _lo_jobs(self, opt, macro, value):
133        if value is None:
134            raise error.general('option requires a value: %s' % (opt))
135        ok = False
136        if value in ['max', 'none', 'half']:
137            ok = True
138        else:
139            try:
140                i = int(value)
141                ok = True
142            except:
143                pass
144            if not ok:
145                try:
146                    f = float(value)
147                    ok = True
148                except:
149                    pass
150        if not ok:
151            raise error.general('invalid jobs option: %s' % (value))
152        self.defaults[macro] = value
153        self.opts[opt[2:]] = value
154
155    def _lo_bool(self, opt, macro, value):
156        if value is not None:
157            raise error.general('option does not take a value: %s' % (opt))
158        self.opts[opt[2:]] = '1'
159        self.defaults[macro] = '1'
160
161    def _lo_triplets(self, opt, macro, value):
162        #
163        # This is a target triplet. Run it past config.sub to make make sure it
164        # is ok.  The target triplet is 'cpu-vendor-os'.
165        #
166        e = execute.capture_execution()
167        config_sub = path.join(self.command_path,
168                               basepath, 'config.sub')
169        exit_code, proc, output = e.shell(config_sub + ' ' + value)
170        if exit_code == 0:
171            value = output
172        self.defaults[macro] = ('triplet', 'none', value)
173        self.opts[opt[2:]] = value
174        _cpu = macro + '_cpu'
175        _arch = macro + '_arch'
176        _vendor = macro + '_vendor'
177        _os = macro + '_os'
178        _arch_value = ''
179        _vendor_value = ''
180        _os_value = ''
181        dash = value.find('-')
182        if dash >= 0:
183            _arch_value = value[:dash]
184            value = value[dash + 1:]
185        dash = value.find('-')
186        if dash >= 0:
187            _vendor_value = value[:dash]
188            value = value[dash + 1:]
189        if len(value):
190            _os_value = value
191        self.defaults[_cpu]    = _arch_value
192        self.defaults[_arch]   = _arch_value
193        self.defaults[_vendor] = _vendor_value
194        self.defaults[_os]     = _os_value
195
196    def _lo_help(self, opt, macro, value):
197        self.help()
198
199    def help(self):
200        print('%s: [options] [args]' % (self.command_name))
201        print('RTEMS Source Builder, an RTEMS Tools Project (c) 2012-2015 Chris Johns')
202        print('Options and arguments:')
203        print('--force                : Force the build to proceed')
204        print('--quiet                : Quiet output (not used)')
205        print('--trace                : Trace the execution')
206        print('--dry-run              : Do everything but actually run the build')
207        print('--warn-all             : Generate warnings')
208        print('--no-clean             : Do not clean up the build tree')
209        print('--always-clean         : Always clean the build tree, even with an error')
210        print('--keep-going           : Do not stop on an error.')
211        print('--regression           : Set --no-install, --keep-going and --always-clean')
212        print('--jobs                 : Run with specified number of jobs, default: num CPUs.')
213        print('--host                 : Set the host triplet')
214        print('--build                : Set the build triplet')
215        print('--target               : Set the target triplet')
216        print('--prefix path          : Tools build prefix, ie where they are installed')
217        print('--topdir path          : Top of the build tree, default is $PWD')
218        print('--configdir path       : Path to the configuration directory, default: ./config')
219        print('--builddir path        : Path to the build directory, default: ./build')
220        print('--sourcedir path       : Path to the source directory, default: ./source')
221        print('--patchdir path        : Path to the patches directory, default: ./patches')
222        print('--tmppath path         : Path to the temp directory, default: ./tmp')
223        print('--macros file[,[file]  : Macro format files to load after the defaults')
224        print('--log file             : Log file where all build out is written too')
225        print('--url url[,url]        : URL to look for source')
226        print('--no-download          : Disable the source downloader')
227        print('--no-install           : Do not install the packages to the prefix')
228        print('--targetcflags flags   : List of C flags for the target code')
229        print('--targetcxxflags flags : List of C++ flags for the target code')
230        print('--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code')
231        print('--source-only-download : Only download the source')
232        print('--with-<label>         : Add the --with-<label> to the build')
233        print('--without-<label>      : Add the --without-<label> to the build')
234        print('--rtems-tools path     : Path to an install RTEMS tool set')
235        print('--rtems-bsp arc/bsp    : Standard RTEMS architecure and BSP specifier')
236        print('--rtems-version ver    : The RTEMS major/minor version string')
237        if self.optargs:
238            for a in self.optargs:
239                print('%-22s : %s' % (a, self.optargs[a]))
240        raise error.exit()
241
242    def process(self):
243        for a in self.args:
244            if a == '-?' or a == '--help':
245                self.help()
246        arg = 0
247        while arg < len(self.args):
248            a = self.args[arg]
249            if a.startswith('--'):
250                los = a.split('=')
251                lo = los[0]
252                if lo in self._long_opts:
253                    long_opt = self._long_opts[lo]
254                    if len(los) == 1:
255                        if long_opt[2]:
256                            if arg == len(self.args) - 1:
257                                raise error.general('option requires a parameter: %s' % (lo))
258                            arg += 1
259                            value = self.args[arg]
260                        else:
261                            value = None
262                    else:
263                        value = '='.join(los[1:])
264                    long_opt[1](lo, long_opt[0], value)
265                else:
266                    if a.startswith('--with'):
267                        if len(los) != 1:
268                            value = los[1]
269                        else:
270                            value = '1'
271                        self.defaults[los[0][2:].replace('-', '_').lower()] = ('none', 'none', value)
272                    else:
273                        if lo not in self.optargs:
274                            raise error.general('unknown option: %s' % (lo))
275            else:
276                if a.startswith('-'):
277                    raise error.general('short options not supported; only "-?"')
278                self.opts['params'].append(a)
279            arg += 1
280
281    def pre_process(self):
282        arg = 0
283        while arg < len(self.args):
284            a = self.args[arg]
285            if a == '--source-only-download':
286                self.args += ['--dry-run',
287                              '--with-download',
288                              '--quiet',
289                              '--without-log',
290                              '--without-error-report',
291                              '--without-release-url']
292            arg += 1
293
294    def post_process(self, logfile = True):
295        # Handle the log first.
296        logctrl = self.parse_args('--without-log')
297        if logctrl is None:
298            if logfile:
299                logfiles = self.logfiles()
300            else:
301                logfiles = None
302            log.default = log.log(streams = logfiles)
303        if self.trace():
304            log.tracing = True
305        if self.quiet():
306            log.quiet = True
307        # Must have a host
308        if self.defaults['_host'] == self.defaults['nil']:
309            raise error.general('--host not set')
310        # Must have a host
311        if self.defaults['_build'] == self.defaults['nil']:
312            raise error.general('--build not set')
313        # Default prefix
314        prefix = self.parse_args('--prefix')
315        if prefix is None:
316            value = path.join(self.defaults['_prefix'], 'rtems', str(self.defaults['rtems_version']))
317            self.opts['prefix'] = value
318            self.defaults['_prefix'] = value
319        # Manage the regression option
320        if self.opts['regression'] != '0':
321            self.opts['no-install'] = '1'
322            self.defaults['_no_install'] = '1'
323            self.opts['keep-going'] = '1'
324            self.defaults['_keep_going'] = '1'
325            self.opts['always-clean'] = '1'
326            self.defaults['_always_clean'] = '1'
327        # Handle the jobs for make
328        if '_ncpus' not in self.defaults:
329            raise error.general('host number of CPUs not set')
330        ncpus = self.jobs(self.defaults['_ncpus'])
331        if ncpus > 1:
332            self.defaults['_smp_mflags'] = '-j %d' % (ncpus)
333        else:
334            self.defaults['_smp_mflags'] = self.defaults['nil']
335        # Load user macro files
336        um = self.user_macros()
337        if um:
338            checked = path.exists(um)
339            if False in checked:
340                raise error.general('macro file not found: %s' % (um[checked.index(False)]))
341            for m in um:
342                self.defaults.load(m)
343        # Check if the user has a private set of macros to load
344        if 'RSB_MACROS' in os.environ:
345            if path.exists(os.environ['RSB_MACROS']):
346                self.defaults.load(os.environ['RSB_MACROS'])
347        if 'HOME' in os.environ:
348            rsb_macros = path.join(os.environ['HOME'], '.rsb_macros')
349            if path.exists(rsb_macros):
350                self.defaults.load(rsb_macros)
351
352    def sb_released(self):
353        if version.released():
354            self.defaults['rsb_released'] = '1'
355        self.defaults['rsb_version'] = version.str()
356
357    def sb_git(self):
358        repo = git.repo(self.defaults.expand('%{_sbdir}'), self)
359        if repo.valid():
360            repo_valid = '1'
361            repo_head = repo.head()
362            repo_clean = not repo.dirty()
363            repo_remotes = '%{nil}'
364            remotes = repo.remotes()
365            if 'origin' in remotes:
366                repo_remotes = '%s/origin' % (remotes['origin']['url'])
367            repo_id = repo_head
368            if not repo_clean:
369                repo_id += '-modified'
370            repo_mail = repo.email()
371        else:
372            repo_valid = '0'
373            repo_head = '%{nil}'
374            repo_clean = '%{nil}'
375            repo_remotes = '%{nil}'
376            repo_id = 'no-repo'
377            repo_mail = None
378        self.defaults['_sbgit_valid'] = repo_valid
379        self.defaults['_sbgit_head']  = repo_head
380        self.defaults['_sbgit_clean'] = str(repo_clean)
381        self.defaults['_sbgit_remotes'] = str(repo_remotes)
382        self.defaults['_sbgit_id']    = repo_id
383        if repo_mail is not None:
384            self.defaults['_sbgit_mail'] = repo_mail
385
386    def command(self):
387        return path.join(self.command_path, self.command_name)
388
389    def force(self):
390        return self.opts['force'] != '0'
391
392    def dry_run(self):
393        return self.opts['dry-run'] != '0'
394
395    def set_dry_run(self):
396        self.opts['dry-run'] = '1'
397
398    def quiet(self):
399        return self.opts['quiet'] != '0'
400
401    def trace(self):
402        return self.opts['trace'] != '0'
403
404    def warn_all(self):
405        return self.opts['warn-all'] != '0'
406
407    def keep_going(self):
408        return self.opts['keep-going'] != '0'
409
410    def no_clean(self):
411        return self.opts['no-clean'] != '0'
412
413    def always_clean(self):
414        return self.opts['always-clean'] != '0'
415
416    def no_install(self):
417        return self.opts['no-install'] != '0'
418
419    def canadian_cross(self):
420        _host = self.defaults.expand('%{_host}')
421        _build = self.defaults.expand('%{_build}')
422        _target = self.defaults.expand('%{_target}')
423        #
424        # This has been removed to fix how RTEMS 3rd party libraries
425        # are built. This may break Cxc tools builds.
426        #
427        # if len(_target):
428        #     return len(_host) and len(_build) and (_target) and \
429        #         _host != _build and _host != _target
430        return len(_target) and len(_host) and len(_build) and _host != _build
431
432    def user_macros(self):
433        #
434        # Return something even if it does not exist.
435        #
436        if self.opts['macros'] is None:
437            return None
438        um = []
439        configs = self.defaults.expand('%{_configdir}').split(':')
440        for m in self.opts['macros'].split(','):
441            if path.exists(m):
442                um += [m]
443            else:
444                # Get the expanded config macros then check them.
445                cm = path.expand(m, configs)
446                ccm = path.exists(cm)
447                if True in ccm:
448                    # Pick the first found
449                    um += [cm[ccm.index(True)]]
450                else:
451                    um += [m]
452        return um if len(um) else None
453
454    def jobs(self, cpus):
455        cpus = int(cpus)
456        if self.opts['jobs'] == 'none':
457            cpus = 0
458        elif self.opts['jobs'] == 'max':
459            pass
460        elif self.opts['jobs'] == 'half':
461            cpus = cpus / 2
462        else:
463            ok = False
464            try:
465                i = int(self.opts['jobs'])
466                cpus = i
467                ok = True
468            except:
469                pass
470            if not ok:
471                try:
472                    f = float(self.opts['jobs'])
473                    cpus = f * cpus
474                    ok = True
475                except:
476                    pass
477                if not ok:
478                    raise error.internal('bad jobs option: %s' % (self.opts['jobs']))
479        if cpus <= 0:
480            cpu = 1
481        return cpus
482
483    def params(self):
484        return self.opts['params']
485
486    def parse_args(self, arg, error = True, extra = True):
487        for a in range(0, len(self.args)):
488            if self.args[a].startswith(arg):
489                lhs = None
490                rhs = None
491                if '=' in self.args[a]:
492                    eqs = self.args[a].split('=')
493                    lhs = eqs[0]
494                    if len(eqs) > 2:
495                        rhs = '='.join(eqs[1:])
496                    else:
497                        rhs = eqs[1]
498                elif extra:
499                    lhs = self.args[a]
500                    a += 1
501                    if a < len(self.args):
502                        rhs = self.args[a]
503                return [lhs, rhs]
504            a += 1
505        return None
506
507    def get_arg(self, arg):
508        if self.optargs is None or arg not in self.optargs:
509            return None
510        return self.parse_args(arg)
511
512    def with_arg(self, label, default = 'not-found'):
513        # the default if there is no option for without.
514        result = default
515        for pre in ['with', 'without']:
516            arg_str = '--%s-%s' % (pre, label)
517            arg_label = '%s_%s' % (pre, label)
518            arg = self.parse_args(arg_str, error = False, extra = False)
519            if arg is not None:
520                if arg[1] is  None:
521                    result = 'yes'
522                else:
523                    result = arg[1]
524                break
525        return [arg_label, result]
526
527    def get_config_files(self, config):
528        #
529        # Convert to shell paths and return shell paths.
530        #
531        # @fixme should this use a passed in set of defaults and not
532        #        not the initial set of values ?
533        #
534        config = path.shell(config)
535        if '*' in config or '?' in config:
536            print(config)
537            configdir = path.dirname(config)
538            configbase = path.basename(config)
539            if len(configbase) == 0:
540                configbase = '*'
541            if not configbase.endswith('.cfg'):
542                configbase = configbase + '.cfg'
543            if len(configdir) == 0:
544                configdir = self.macros.expand(self.defaults['_configdir'])
545            configs = []
546            for cp in configdir.split(':'):
547                hostconfigdir = path.host(cp)
548                for f in glob.glob(os.path.join(hostconfigdir, configbase)):
549                    configs += path.shell(f)
550        else:
551            configs = [config]
552        return configs
553
554    def config_files(self):
555        configs = []
556        for config in self.opts['params']:
557            configs.extend(self.get_config_files(config))
558        return configs
559
560    def logfiles(self):
561        if 'log' in self.opts and self.opts['log'] is not None:
562            return self.opts['log'].split(',')
563        return ['rsb-log-%s.txt' % (datetime.datetime.now().strftime('%Y%m%d-%H%M%S'))]
564
565    def urls(self):
566        if self.opts['url'] is not None:
567            return self.opts['url'].split(',')
568        return None
569
570    def download_disabled(self):
571        return self.opts['no-download'] != '0'
572
573    def disable_install(self):
574        self.opts['no-install'] = '1'
575
576    def info(self):
577        s = ' Command Line: %s%s' % (' '.join(self.argv), os.linesep)
578        s += ' Python: %s' % (sys.version.replace('\n', ''))
579        return s
580
581    def log_info(self):
582        log.output(self.info())
583
584    def rtems_options(self):
585        # Check for RTEMS specific helper options.
586        rtems_tools = self.parse_args('--rtems-tools')
587        if rtems_tools is not None:
588            if self.get_arg('--with-tools') is not None:
589                raise error.general('--rtems-tools and --with-tools cannot be used together')
590            self.args.append('--with-tools=%s' % (rtems_tools[1]))
591        rtems_version = self.parse_args('--rtems-version')
592        if rtems_version is None:
593            rtems_version = version.version()
594        else:
595            rtems_version = rtems_version[1]
596        self.defaults['rtems_version'] = rtems_version
597        rtems_arch_bsp = self.parse_args('--rtems-bsp')
598        if rtems_arch_bsp is not None:
599            if self.get_arg('--target') is not None:
600                raise error.general('--rtems-bsp and --target cannot be used together')
601            ab = rtems_arch_bsp[1].split('/')
602            if len(ab) != 2:
603                raise error.general('invalid --rtems-bsp option')
604            self.args.append('--target=%s-rtems%s' % (ab[0], rtems_version))
605            self.args.append('--with-rtems-bsp=%s' % (ab[1]))
606
607def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc', logfile = True):
608    """
609    Copy the defaults, get the host specific values and merge them overriding
610    any matching defaults, then create an options object to handle the command
611    line merging in any command line overrides. Finally post process the
612    command line.
613    """
614
615    global host_windows
616    global host_posix
617
618    #
619    # Adjust the args to remove the wrapper.
620    #
621    args = args[1:]
622
623    #
624    # The path to this command.
625    #
626    command_path = path.dirname(path.abspath(args[0]))
627    if len(command_path) == 0:
628        command_path = '.'
629
630    #
631    # The command line contains the base defaults object all build objects copy
632    # and modify by loading a configuration.
633    #
634    o = command_line(args,
635                     optargs,
636                     macros.macros(name = defaults,
637                                   sbdir = command_path),
638                     command_path)
639
640    overrides = None
641    if os.name == 'nt':
642        try:
643            import windows
644            overrides = windows.load()
645            host_windows = True
646            host_posix = False
647        except:
648            raise error.general('failed to load Windows host support')
649    elif os.name == 'posix':
650        uname = os.uname()
651        try:
652            if uname[0].startswith('MINGW64_NT'):
653                import windows
654                overrides = windows.load()
655                host_windows = True
656            elif uname[0].startswith('CYGWIN_NT'):
657                import windows
658                overrides = windows.load()
659            elif uname[0] == 'Darwin':
660                import darwin
661                overrides = darwin.load()
662            elif uname[0] == 'FreeBSD':
663                import freebsd
664                overrides = freebsd.load()
665            elif uname[0] == 'NetBSD':
666                import netbsd
667                overrides = netbsd.load()
668            elif uname[0] == 'Linux':
669                import linux
670                overrides = linux.load()
671            elif uname[0] == 'SunOS':
672                import solaris
673                overrides = solaris.load()
674        except error.general as ge:
675            raise error.general('failed to load %s host support: %s' % (uname[0], ge))
676        except:
677            raise error.general('failed to load %s host support' % (uname[0]))
678    else:
679        raise error.general('unsupported host type; please add')
680    if overrides is None:
681        raise error.general('no hosts defaults found; please add')
682    for k in overrides:
683        o.defaults[k] = overrides[k]
684
685    o.sb_released()
686    o.sb_git()
687    o.rtems_options()
688    o.pre_process()
689    o.process()
690    o.post_process(logfile)
691
692    #
693    # Load the release settings
694    #
695    version.load_release_settings(o.defaults)
696
697    return o
698
699def run(args):
700    try:
701        _opts = load(args = args, defaults = 'defaults.mc')
702        log.notice('RTEMS Source Builder - Defaults, %s' % (version.str()))
703        _opts.log_info()
704        log.notice('Options:')
705        log.notice(str(_opts))
706        log.notice('Defaults:')
707        log.notice(str(_opts.defaults))
708        log.notice('with-opt1: %r' % (_opts.with_arg('opt1')))
709        log.notice('without-opt2: %r' % (_opts.with_arg('opt2')))
710    except error.general as gerr:
711        print(gerr)
712        sys.exit(1)
713    except error.internal as ierr:
714        print(ierr)
715        sys.exit(1)
716    except error.exit as eerr:
717        pass
718    except KeyboardInterrupt:
719        _notice(opts, 'abort: user terminated')
720        sys.exit(1)
721    sys.exit(0)
722
723if __name__ == '__main__':
724    run(sys.argv)
Note: See TracBrowser for help on using the repository browser.