Пример #1
0
def run(args):
    try:
        long_opts = {
            # key              macro         handler   param  defs   init
            '--test-path': ('_test_path', 'path', True, None, False),
            '--test-jobs': ('_test_jobs', 'jobs', True, 'max', True),
            '--test-bool': ('_test_bool', 'bool', False, '0', True)
        }
        opts = command_line(base_path='.',
                            argv=args,
                            optargs=None,
                            defaults=macros.macros(),
                            long_opts=long_opts,
                            command_path='.')
        load(opts)
        log.notice('RTEMS Tools Project - Defaults, v%s' % (version.str()))
        opts.log_info()
        log.notice('Options:')
        log.notice(str(opts))
        log.notice('Defaults:')
        log.notice(str(opts.defaults))
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        pass
    except KeyboardInterrupt:
        _notice(opts, 'abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Пример #2
0
def run(args):
    try:
        long_opts = {
            # key              macro         handler   param  defs   init
            '--test-path'  : ('_test_path',  'path',   True,  None,  False),
            '--test-jobs'  : ('_test_jobs',  'jobs',   True,  'max', True),
            '--test-bool'  : ('_test_bool',  'bool',   False, '0',   True)
        }
        opts = command_line(base_path = '.',
                            argv = args,
                            optargs = None,
                            defaults = macros.macros(),
                            long_opts = long_opts,
                            command_path = '.')
        load(opts)
        log.notice('RTEMS Tools Project - Defaults, v%s' % (version.str()))
        opts.log_info()
        log.notice('Options:')
        log.notice(str(opts))
        log.notice('Defaults:')
        log.notice(str(opts.defaults))
    except error.general as gerr:
        print(gerr)
        sys.exit(1)
    except error.internal as ierr:
        print(ierr)
        sys.exit(1)
    except error.exit:
        pass
    except KeyboardInterrupt:
        _notice(opts, 'abort: user terminated')
        sys.exit(1)
    sys.exit(0)
Пример #3
0
 def __init__(self, argv, argopts, defaults):
     command_path = path.dirname(path.abspath(argv[1]))
     if len(command_path) == 0:
         command_path = '.'
     self.command_path = command_path
     self.command_name = path.basename(argv[0])
     extras = ['--dry-run',
               '--with-download',
               '--quiet',
               '--without-log',
               '--without-error-report',
               '--without-release-url']
     self.argv = argv
     self.args = argv[1:] + extras
     self.defaults = macros.macros(name = defaults,
                                   sbdir = command_path)
     self.load_overrides()
     self.opts = { 'params' :  extras }
     self.sb_git()
     self.rtems_bsp()
     if argopts.download_dir is not None:
         self.defaults['_sourcedir'] = ('dir',
                                        'optional',
                                        path.abspath(argopts.download_dir))
         self.defaults['_patchdir'] = ('dir',
                                       'optional',
                                       path.abspath(argopts.download_dir))
Пример #4
0
 def __init__(self, argv, argopts, defaults):
     command_path = path.dirname(path.abspath(argv[1]))
     if len(command_path) == 0:
         command_path = '.'
     self.command_path = command_path
     self.command_name = path.basename(argv[0])
     extras = ['--dry-run',
               '--with-download',
               '--quiet',
               '--without-log',
               '--without-error-report',
               '--without-release-url']
     self.argv = argv
     self.args = argv[1:] + extras
     self.defaults = macros.macros(name = defaults,
                                   sbdir = command_path)
     self.opts = { 'params' :  extras }
     self.sb_git()
     if argopts.download_dir is not None:
         self.defaults['_sourcedir'] = ('dir', 'optional', path.abspath(argopts.download_dir))
         self.defaults['_patchdir'] = ('dir', 'optional', path.abspath(argopts.download_dir))
Пример #5
0
def run(args):
    try:
        long_opts = {
            # key              macro         handler   param  defs   init
            '--test-path'  : ('_test_path',  'path',   True,  None,  False),
            '--test-jobs'  : ('_test_jobs',  'jobs',   True,  'max', True),
            '--test-bool'  : ('_test_bool',  'bool',   False, '0',   True)
        }
        opts = command_line(base_path = '.',
                            argv = args,
                            optargs = None,
                            defaults = macros.macros(),
                            long_opts = long_opts,
                            command_path = '.')
        load(opts)
        log.notice('RTEMS Tools Project - Defaults, v%s' % (version.str()))
        opts.log_info()
        log.notice('Options:')
        log.notice(str(opts))
        log.notice('Defaults:')
        log.notice(str(opts.defaults))
    except error.general, gerr:
        print gerr
        sys.exit(1)
Пример #6
0
def load(args, optargs=None, defaults='%{_sbdir}/defaults.mc', logfile=True):
    """
    Copy the defaults, get the host specific values and merge them overriding
    any matching defaults, then create an options object to handle the command
    line merging in any command line overrides. Finally post process the
    command line.
    """

    global host_windows
    global host_posix

    #
    # The path to this command.
    #
    command_path = path.dirname(args[0])
    if len(command_path) == 0:
        command_path = '.'

    #
    # The command line contains the base defaults object all build objects copy
    # and modify by loading a configuration.
    #
    o = command_line(args, optargs,
                     macros.macros(name=defaults, sbdir=command_path),
                     command_path)

    overrides = None
    if os.name == 'nt':
        try:
            import windows
            overrides = windows.load()
            host_windows = True
            host_posix = False
        except:
            raise error.general('failed to load Windows host support')
    elif os.name == 'posix':
        uname = os.uname()
        try:
            if uname[0].startswith('MINGW64_NT'):
                import windows
                overrides = windows.load()
                host_windows = True
            elif uname[0].startswith('CYGWIN_NT'):
                import windows
                overrides = windows.load()
            elif uname[0] == 'Darwin':
                import darwin
                overrides = darwin.load()
            elif uname[0] == 'FreeBSD':
                import freebsd
                overrides = freebsd.load()
            elif uname[0] == 'NetBSD':
                import netbsd
                overrides = netbsd.load()
            elif uname[0] == 'Linux':
                import linux
                overrides = linux.load()
            elif uname[0] == 'SunOS':
                import solaris
                overrides = solaris.load()
        except error.general as ge:
            raise error.general('failed to load %s host support: %s' %
                                (uname[0], ge))
        except:
            raise error.general('failed to load %s host support' % (uname[0]))
    else:
        raise error.general('unsupported host type; please add')
    if overrides is None:
        raise error.general('no hosts defaults found; please add')
    for k in overrides:
        o.defaults[k] = overrides[k]

    o.sb_released()
    o.sb_git()
    o.rtems_options()
    o.pre_process()
    o.process()
    o.post_process(logfile)

    #
    # Load the release settings
    #
    version.load_release_settings(o.defaults)

    return o
Пример #7
0
    def __init__(self,
                 base_path=None,
                 argv=None,
                 optargs=None,
                 defaults=None,
                 long_opts=None,
                 long_opts_help=None,
                 command_path='',
                 log_default=None):

        if argv is None:
            return

        global basepath

        if long_opts == None:
            long_opts = {}

        basepath = base_path

        if log_default is not None and type(log_default) is not list:
            raise error.general('log default is a list')
        self.log_default = log_default

        if defaults is None:
            defaults = macros.macros()

        self.long_opts = {
            # key                 macro                handler            param  defs       init
            '--jobs': ('_jobs', self._lo_jobs, True, 'default', True),
            '--log': ('_logfile', self._lo_string, True, None, False),
            '--macros': ('_macros', self._lo_string, True, None, False),
            '--force': ('_force', self._lo_bool, False, '0', True),
            '--quiet': ('_quiet', self._lo_bool, False, '0', True),
            '--trace': ('_trace', self._lo_bool, False, '0', True),
            '--dry-run': ('_dry_run', self._lo_bool, False, '0', True),
            '--warn-all': ('_warn_all', self._lo_bool, False, '0', True),
            '--no-clean': ('_no_clean', self._lo_bool, False, '0', True),
            '--keep-going': ('_keep_going', self._lo_bool, False, '0', True),
            '--always-clean':
            ('_always_clean', self._lo_bool, False, '0', True),
            '--no-install': ('_no_install', self._lo_bool, False, '0', True),
            '--help': (None, self._lo_help, False, None, False)
        }
        self.long_opts_help = {
            '--force': 'Force the build to proceed',
            '--quiet': 'Quiet output (not used)',
            '--trace': 'Trace the execution',
            '--dry-run': 'Do everything but actually run the build',
            '--warn-all': 'Generate warnings',
            '--no-clean': 'Do not clean up the build tree',
            '--always-clean':
            'Always clean the build tree, even with an error',
            '--keep-going': 'Do not stop on an error.',
            '--jobs=[0..n,none,half,full]':
            'Run with specified number of jobs, default: num CPUs.',
            '--macros file[,file]':
            'Macro format files to load after the defaults',
            '--log file': 'Log file where all build output is written to',
        }
        self.opts = {'params': []}
        self.command_path = command_path
        self.command_name = path.basename(argv[0])
        self.argv = argv
        self.args = argv[1:]
        self.optargs = optargs
        self.defaults = defaults
        for lo in self.long_opts:
            self.opts[lo[2:]] = self.long_opts[lo][3]
            if self.long_opts[lo][4]:
                self.defaults[self.long_opts[lo][0]] = ('none', 'none',
                                                        self.long_opts[lo][3])
        for lo in long_opts:
            if lo in self.long_opts:
                raise error.general('suplicate option: %s' % (lo))
            self.opts[lo[2:]] = long_opts[lo][3]
            if long_opts[lo][4]:
                self.defaults[long_opts[lo][0]] = ('none', 'none',
                                                   long_opts[lo][3])
            if long_opts[lo][1] == 'int':
                handler = self._lo_int
            elif long_opts[lo][1] == 'string':
                handler = self._lo_string
            elif long_opts[lo][1] == 'path':
                handler = self._lo_path
            elif long_opts[lo][1] == 'jobs':
                handler = self._lo_jobs
            elif long_opts[lo][1] == 'bool':
                handler = self._lo_bool
            elif long_opts[lo][1] == 'triplet':
                handler = self._lo_triplets
            else:
                raise error.general('invalid option handler: %s: %s' %
                                    (lo, long_opts[lo][1]))
            self.long_opts[lo] = (long_opts[lo][0], handler, long_opts[lo][2],
                                  long_opts[lo][3], long_opts[lo][4])
            if long_opts_help is not None:
                if lo not in long_opts_help:
                    raise error.general('no help for option: %s' % (lo))
                self.long_opts_help[lo] = long_opts_help[lo]
Пример #8
0
    def __init__(self, base_path = None, argv = None, optargs = None,
                 defaults = None, long_opts = None, long_opts_help = None,
                 command_path = '', log_default = None):

        if argv is None:
            return

        global basepath

        if long_opts == None:
            long_opts = {}

        basepath = base_path

        if log_default is not None and type(log_default) is not list:
            raise error.general('log default is a list')
        self.log_default = log_default

        if defaults is None:
            defaults = macros.macros()

        self.long_opts = {
            # key                 macro                handler            param  defs       init
            '--jobs'           : ('_jobs',             self._lo_jobs,     True,  'default', True),
            '--log'            : ('_logfile',          self._lo_string,   True,  None,      False),
            '--macros'         : ('_macros',           self._lo_string,   True,  None,      False),
            '--force'          : ('_force',            self._lo_bool,     False, '0',       True),
            '--quiet'          : ('_quiet',            self._lo_bool,     False, '0',       True),
            '--trace'          : ('_trace',            self._lo_bool,     False, '0',       True),
            '--dry-run'        : ('_dry_run',          self._lo_bool,     False, '0',       True),
            '--warn-all'       : ('_warn_all',         self._lo_bool,     False, '0',       True),
            '--no-clean'       : ('_no_clean',         self._lo_bool,     False, '0',       True),
            '--keep-going'     : ('_keep_going',       self._lo_bool,     False, '0',       True),
            '--always-clean'   : ('_always_clean',     self._lo_bool,     False, '0',       True),
            '--no-install'     : ('_no_install',       self._lo_bool,     False, '0',       True),
            '--help'           : (None,                self._lo_help,     False, None,      False)
        }
        self.long_opts_help = {
            '--force':                      'Force the build to proceed',
            '--quiet':                      'Quiet output (not used)',
            '--trace':                      'Trace the execution',
            '--dry-run':                    'Do everything but actually run the build',
            '--warn-all':                   'Generate warnings',
            '--no-clean':                   'Do not clean up the build tree',
            '--always-clean':               'Always clean the build tree, even with an error',
            '--keep-going':                 'Do not stop on an error.',
            '--jobs=[0..n,none,half,full]': 'Run with specified number of jobs, default: num CPUs.',
            '--macros file[,file]':         'Macro format files to load after the defaults',
            '--log file':                   'Log file where all build output is written to',
        }
        self.opts = { 'params' : [] }
        self.command_path = command_path
        self.command_name = path.basename(argv[0])
        self.argv = argv
        self.args = argv[1:]
        self.optargs = optargs
        self.defaults = defaults
        for lo in self.long_opts:
            self.opts[lo[2:]] = self.long_opts[lo][3]
            if self.long_opts[lo][4]:
                self.defaults[self.long_opts[lo][0]] = ('none', 'none', self.long_opts[lo][3])
        for lo in long_opts:
            if lo in self.long_opts:
                raise error.general('suplicate option: %s' % (lo))
            self.opts[lo[2:]] = long_opts[lo][3]
            if long_opts[lo][4]:
                self.defaults[long_opts[lo][0]] = ('none', 'none', long_opts[lo][3])
            if long_opts[lo][1] == 'int':
                handler = self._lo_int
            elif long_opts[lo][1] == 'string':
                handler = self._lo_string
            elif long_opts[lo][1] == 'path':
                handler = self._lo_path
            elif long_opts[lo][1] == 'jobs':
                handler = self._lo_jobs
            elif long_opts[lo][1] == 'bool':
                handler = self._lo_bool
            elif long_opts[lo][1] == 'triplet':
                handler = self._lo_triplets
            else:
                raise error.general('invalid option handler: %s: %s' % (lo, long_opts[lo][1]))
            self.long_opts[lo] = (long_opts[lo][0], handler, long_opts[lo][2],
                                   long_opts[lo][3], long_opts[lo][4])
            if long_opts_help is not None:
                if lo not in long_opts_help:
                    raise error.general('no help for option: %s' % (lo))
                self.long_opts_help[lo] = long_opts_help[lo]
def load(args, optargs = None, defaults = '%{_sbdir}/defaults.mc'):
    """
    Copy the defaults, get the host specific values and merge them overriding
    any matching defaults, then create an options object to handle the command
    line merging in any command line overrides. Finally post process the
    command line.
    """

    global host_windows

    #
    # The path to this command.
    #
    command_path = path.dirname(args[0])
    if len(command_path) == 0:
        command_path = '.'

    #
    # The command line contains the base defaults object all build objects copy
    # and modify by loading a configuration.
    #
    o = command_line(args,
                     optargs,
                     macros.macros(name = defaults,
                                   sbdir = command_path),
                     command_path)

    overrides = None
    if os.name == 'nt':
        try:
            import windows
            overrides = windows.load()
            host_windows = True
        except:
            raise error.general('failed to load Windows host support')
    elif os.name == 'posix':
        uname = os.uname()
        try:
            if uname[0].startswith('CYGWIN_NT'):
                import windows
                overrides = windows.load()
            elif uname[0] == 'Darwin':
                import darwin
                overrides = darwin.load()
            elif uname[0] == 'FreeBSD':
                import freebsd
                overrides = freebsd.load()
            elif uname[0] == 'NetBSD':
                import netbsd
                overrides = netbsd.load()
            elif uname[0] == 'Linux':
                import linux
                overrides = linux.load()
            elif uname[0] == 'SunOS':
                import solaris
                overrides = solaris.load()
        except:
            raise error.general('failed to load %s host support' % (uname[0]))
    else:
        raise error.general('unsupported host type; please add')
    if overrides is None:
        raise error.general('no hosts defaults found; please add')
    for k in overrides:
        o.defaults[k] = overrides[k]

    o.sb_git()
    o.process()
    o.post_process()

    return o
Пример #10
0
def googlenet(n, auxiliary_classifier=True):
    return macros((
        (0, 64, 7, 2, 0, 0, {
            'layername': 'conv1/7x7_s2'
        }),
        (0, 0, 3, 2, 0, 0, {
            'maxpool': True,
            'layername': 'pool1/3x3_s2'
        }),
        (0, 0, 0, 0, 0, 0, {
            'lru': {
                'alpha': 0.00002,
                'k': 1
            },
            'layername': 'pool1/norm1'
        }),
        (0, 64, 1, 1, 0, 0, {
            'layername': 'conv2/3x3_reduce'
        }),
        (0, 192, 3, 1, 0, 0, {
            'layername': 'conv2/3x3'
        }),
        (0, 0, 0, 0, 0, 0, {
            'lru': {
                'alpha': 0.00002,
                'k': 1
            },
            'layername': 'conv2/norm2'
        }),
        (0, 0, 3, 2, 0, 0, {
            'maxpool': True,
            'layername': 'pool2/3x3_s2'
        }),
        (namespace, 'inception_3a/', ((inception, (
            32,
            64,
            96,
            128,
            16,
            32,
        )), )),
        (ln, 0, 'inception_3a'),
        (namespace, 'inception_3b/', ((inception, (
            64,
            128,
            128,
            192,
            32,
            96,
        )), )),
        (ln, 0, 'inception_3b'),
        (0, 0, 3, 2, 0, 0, {
            'maxpool': True,
            'layername': 'pool3/3x3_s2'
        }),
        (namespace, 'inception_4a/', ((inception, (
            64,
            192,
            96,
            208,
            16,
            48,
        )), )),
        (ln, 0, 'inception_4a'),
        (switch, auxiliary_classifier, (
            (0, 0, 5, 3, 0, 0, {
                'meanpool': True,
                'pad': 0,
                'layername': 'loss1/ave_pool'
            }),
            (0, 128, 1, 1, 0, 0, {
                'layername': 'loss1/conv'
            }),
            (0, 1024, 0, 0, 'loss1/fc', 0, {
                'dense': True,
                'layername': 'loss1/fc'
            }),
            (0, 0, 0, 0, 0, 0, {
                'dropout': 0.7,
                'layername': 'loss1/dropout'
            }),
            (0, n, 0, 0, 'loss1/classifier', 0, {
                'dense': True,
                'linear': True,
                'layername': 'loss1/classifier'
            }),
            (0, 0, 0, 0, 'loss1/prob', 0, {
                'nonlinearity': (lambda x: x, softmax),
                'layername': 'loss1/prob'
            }),
        ), ()),
        (ln, 'inception_4a'),
        (namespace, 'inception_4b/', ((inception, (
            64,
            160,
            112,
            224,
            24,
            64,
        )), )),
        (ln, 0, 'inception_4b'),
        (namespace, 'inception_4c/', ((inception, (
            64,
            128,
            128,
            256,
            24,
            64,
        )), )),
        (ln, 0, 'inception_4c'),
        (namespace, 'inception_4d/', ((inception, (
            64,
            112,
            144,
            288,
            32,
            64,
        )), )),
        (ln, 0, 'inception_4d'),
        (switch, auxiliary_classifier, (
            (0, 0, 5, 3, 0, 0, {
                'meanpool': True,
                'pad': 0,
                'layername': 'loss2/ave_pool'
            }),
            (0, 128, 1, 1, 0, 0, {
                'layername': 'loss2/conv'
            }),
            (0, 1024, 0, 0, 'loss2/fc', 0, {
                'dense': True,
                'layername': 'loss2/fc'
            }),
            (0, 0, 0, 0, 0, 0, {
                'dropout': 0.7,
                'layername': 'loss2/dropout'
            }),
            (0, n, 0, 0, 'loss2/classifier', 0, {
                'dense': True,
                'linear': True,
                'layername': 'loss2/classifier'
            }),
            (0, 0, 0, 0, 'loss2/prob', 0, {
                'nonlinearity': (lambda x: x, softmax),
                'layername': 'loss2/prob'
            }),
        ), ()),
        (ln, 'inception_4d'),
        (namespace, 'inception_4e/', ((inception, (
            128,
            256,
            160,
            320,
            32,
            128,
        )), )),
        (ln, 0, 'inception_4e'),
        (0, 0, 3, 2, 0, 0, {
            'maxpool': True,
            'layername': 'pool4/3x3_s2'
        }),
        (namespace, 'inception_5a/', ((inception, (
            128,
            256,
            160,
            320,
            32,
            128,
        )), )),
        (ln, 0, 'inception_5a'),
        (namespace, 'inception_5b/', ((inception, (
            128,
            384,
            192,
            384,
            48,
            128,
        )), )),
        (ln, 0, 'inception_5b'),
        (0, 0, 7, 1, 0, 0, {
            'meanpool': True,
            'pad': 0,
            'layername': 'pool5/7x7_s1'
        }),
        (0, 0, 0, 0, 0, 0, {
            'dropout': 0.7,
            'layername': 'pool5/dropout'
        }),
        (0, n, 0, 0, 'loss3/classifier', 0, {
            'dense': True,
            'linear': True,
            'layername': 'loss3/classifier'
        }),
        (0, 0, 0, 0, 'prob', 0, {
            'nonlinearity': (lambda x: x, softmax),
            'layername': 'prob'
        }),
    ))
def load(args, optargs=None, defaults='%{_sbdir}/defaults.mc', logfile=True):
    """
    Copy the defaults, get the host specific values and merge them overriding
    any matching defaults, then create an options object to handle the command
    line merging in any command line overrides. Finally post process the
    command line.
    """

    global host_windows
    global host_posix

    #
    # Adjust the args to remove the wrapper.
    #
    args = args[1:]

    #
    # The path to this command.
    #
    command_path = path.dirname(path.abspath(args[0]))
    if len(command_path) == 0:
        command_path = '.'

    #
    # The command line contains the base defaults object all build objects copy
    # and modify by loading a configuration.
    #
    o = command_line(args, optargs,
                     macros.macros(name=defaults, sbdir=command_path),
                     command_path)

    overrides = None
    if os.name == 'nt':
        try:
            import windows
            overrides = windows.load()
            host_windows = True
            host_posix = False
        except:
            raise error.general('failed to load Windows host support')
    elif os.name == 'posix':
        uname = os.uname()
        try:
            if uname[0].startswith('MINGW64_NT'):
                import windows
                overrides = windows.load()
                host_windows = True
            elif uname[0].startswith('CYGWIN_NT'):
                import windows
                overrides = windows.load()
            elif uname[0] == 'Darwin':
                import darwin
                overrides = darwin.load()
            elif uname[0] == 'FreeBSD':
                import freebsd
                overrides = freebsd.load()
            elif uname[0] == 'NetBSD':
                import netbsd
                overrides = netbsd.load()
            elif uname[0] == 'Linux':
                import linux
                overrides = linux.load()
            elif uname[0] == 'SunOS':
                import solaris
                overrides = solaris.load()
        except error.general as ge:
            raise error.general('failed to load %s host support: %s' %
                                (uname[0], ge))
        except:
            raise error.general('failed to load %s host support' % (uname[0]))
    else:
        raise error.general('unsupported host type; please add')
    if overrides is None:
        raise error.general('no hosts defaults found; please add')
    for k in overrides:
        o.defaults[k] = overrides[k]

    o.sb_released()
    o.sb_git()
    o.rtems_options()
    o.pre_process()
    o.process()
    o.post_process(logfile)

    #
    # Load the release settings
    #
    def setting_error(msg):
        raise error.general(msg)

    hashes = version.load_release_settings('hashes')
    for hash in hashes:
        hs = hash[1].split()
        if len(hs) != 2:
            raise error.general('invalid release hash in VERSION')
        sources.hash((hs[0], hash[0], hs[1]), o.defaults, setting_error)
    release_path = version.load_release_setting('version',
                                                'release_path',
                                                raw=True)
    if release_path is not None:
        try:
            release_path = ','.join(
                [rp.strip() for rp in release_path.split(',')])
        except:
            raise error.general('invalid release path in VERSION')
        download.set_release_path(release_path, o.defaults)
    return o