Beispiel #1
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # Change current directory
        c = cfg.get('force', False)
        if c:
            args.append('--force')

        c = make_list(cfg.get('filters'))
        if len(c):
            args.append('--filters="%s"' % ','.join(c))

        c_basedir = cfg.get('basedir', None)
        c = cfg.get('name', None)
        if c and c_basedir is not None:
            args.append('--name="%s"' % c)

        c = make_list(cfg.get('include'))
        for o in c:
            args.append('--include="%s"' % expand_resource(self.group, o))

        c = make_list(cfg.get('exclude'))
        for o in c:
            args.append('--exclude="%s"' % expand_resource(self.group, o))
Beispiel #2
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        args.append('--force')

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        output_dir = expand_resource(self.group, cfg['output_dir'])
        if output_dir is None:
            self.bld.fatal(cfg['output_dir'] + ' not found.')
        args.append('-o ' + output_dir)

        project_dir = expand_resource(self.group, cfg['project_dir'])
        if project_dir is None:
            self.bld.fatal(cfg['project_dir'] + ' not found.')
        args.append(project_dir)

        for fname in make_list(cfg.get('exclude')):
            exclude_files = expand_wildcard(self.group, fname)
            if exclude_files is None:
                self.bld.fatal(fname + ' not found.')
            args.extend(exclude_files)
Beispiel #3
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        args.append('--force')

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        output_dir = expand_resource(self.group, cfg['output_dir'])
        if output_dir is None:
            self.bld.fatal(cfg['output_dir'] + ' not found.')
        args.append('-o ' + output_dir)

        project_dir = expand_resource(self.group, cfg['project_dir'])
        if project_dir is None:
            self.bld.fatal(cfg['project_dir'] + ' not found.')
        args.append(project_dir)

        for fname in make_list(cfg.get('exclude')):
            exclude_files = expand_wildcard(self.group, fname)
            if exclude_files is None:
                self.bld.fatal(fname + ' not found.')
            args.extend(exclude_files)
Beispiel #4
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # Change current directory
        c = cfg.get('force', False)
        if c:
            args.append('--force')

        c = make_list(cfg.get('filters'))
        if len(c):
            args.append('--filters="%s"' % ','.join(c))

        c_basedir = cfg.get('basedir', None)
        c = cfg.get('name', None)
        if c and c_basedir is not None:
            args.append('--name="%s"' % c)

        c = make_list(cfg.get('include'))
        for o in c:
            args.append('--include="%s"' % expand_resource(self.group, o))

        c = make_list(cfg.get('exclude'))
        for o in c:
            args.append('--exclude="%s"' % expand_resource(self.group, o))
Beispiel #5
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        self.add_bool_args('binary', 'json', 'cpp', 'go', 'java', 'js',
                'csharp', 'python', 'php', 'strict_json', 'allow_non_utf8',
                'defaults_json', 'unknown_json', 'no_prefix', 'scoped_enums',
                'no_includes', 'gen_mutable', 'gen_onefile', 'gen_name_strings',
                'escape_proto_ids', 'gen_object_api', 'no_js_exports',
                'goog_js_export', 'raw_binary', 'proto', 'grpc', 'schema',
                'bfbs_comments')

        self.add_path_args('conform', 'conform_includes', 'include_prefix')

        self.add_str_args('cpp_ptr_type')

        c = cfg.get('output_dir')
        if c is None:
            self.bld.fatal('Option output_dir is required.')
        else:
            output_dir = expand_resource(self.group, c)
            if output_dir is None:
                self.bld.fatal(c + ' was not found.')
            args.append('-o')
            args.append(output_dir)

        c = cfg.get('include_dir')
        if c:
            include_dir = expand_resource(self.group, c)
            if include_dir is None:
                self.bld.fatal(c + ' was not found.')
            args.append('-I')
            args.append(include_dir)
Beispiel #6
0
    def prepare(self):
        cfg = self.conf

        # Change current directory
        c = cfg.get('work_dir', None)
        if c:
            self.prefix.append('cd %s;' \
                % expand_resource(self.group, c))

        self.args.append('-o %s' %
                         expand_resource(self.group, cfg['config_file']))
Beispiel #7
0
    def prepare(self):
        cfg = self.conf

        # Change current directory
        c = cfg.get('work_dir', None)
        if c:
            self.prefix.append('cd %s;' \
                % expand_resource(self.group, c))

        self.args.append('-o %s' % expand_resource(self.group,
            cfg['config_file']))
Beispiel #8
0
    def prepare(self):
        cfg = self.conf

        # Change current directory
        c = cfg.get('search_dir', [])
        if c:
            if not is_non_string_iterable(c):
                c = [c]
            c = [x for x in (expand_resource(self.group, f) for f\
                    in c) if x]
        if c:
            self.search_dir = c
        else:
            self.bld.fatal(('"search_dir" is required configuration '
                'for %s') % tool_name.capitalize())

        # Yaml context
        c = cfg.get('context_yaml')
        if c:
            yaml_file = expand_resource(self.group, c)
            if yaml_file is None:
                self.bld.fatal('"context_yaml" for %s has invalid value' %\
                        tool_name.capitalize())
            with open(yaml_file, 'r') as f:
                self.context.update(yaml_load(f))

        # Python context
        c = cfg.get('context_python')
        if c:
            python_file = expand_resource(self.group, c)
            if python_file is None:
                self.bld.fatal('"context_python" for %s has invalid value' %\
                        tool_name.capitalize())
            dirname, filename = os.path.split(python_file)
            filebase, _ = os.path.splitext(filename)
            if os.path.exists(os.path.join(dirname, '__init__.py')):
                sys.path.append(dirname)
                mod = __import__(filebase)
            else:
                try:
                    from importlib.machinery import SourceFileLoader
                    mod = SourceFileLoader('context_python',
                            python_file).load_module()
                except ImportError:
                    import imp
                    mod = imp.load_source('context_python', python_file)
                python_export = mod.export
            self.context.update(python_export)

        self.context.update(cfg.get('context', {}))
Beispiel #9
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # Change current directory, before running pylint, helps module imports
        c = cfg.get('work_dir', None)
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        # Specify a configuration file
        c = cfg.get('config_file', None)
        if c:
            args.append(expand_resource(self.group, c))
Beispiel #10
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        source_dir = expand_resource(self.group, cfg['source_dir'])
        if source_dir is None:
            self.bld.fatal(cfg['source_dir'] + ' not found.')
        args.append(source_dir)

        output_dir = expand_resource(self.group, cfg['output_dir'])
        if output_dir is None:
            self.bld.fatal(cfg['output_dir'] + ' not found.')
        args.append(output_dir)

        c = cfg.get('temp_dir')
        if c:
            temp_dir = expand_resource(self.group, c)
            if temp_dir is None:
                self.bld.fatal(c + ' not found.')
            args.append('-d ' + temp_dir)

        c = cfg.get('conf_dir')
        if c:
            conf_dir = expand_resource(self.group, c)
            if conf_dir is None:
                self.bld.fatal(c + ' not found.')
            args.append('-c ' + conf_dir)

        c = cfg.get('builder', 'html')
        args.append('-b ' + c)

        c = cfg.get('jobs')
        if c:
            args.append('-j %i' % c)

        c = cfg.get('settings', {})
        for key, value in c.items():
            args.append('-D %s=%s' % (key, value))

        c = cfg.get('context', {})
        for key, value in c.items():
            args.append('-A %s=%s' % (key, value))
Beispiel #11
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        source_dir = expand_resource(self.group, cfg['source_dir'])
        if source_dir is None:
            self.bld.fatal(cfg['source_dir'] + ' not found.')
        args.append(source_dir)

        output_dir = expand_resource(self.group, cfg['output_dir'])
        if output_dir is None:
            self.bld.fatal(cfg['output_dir'] + ' not found.')
        args.append(output_dir)

        c = cfg.get('temp_dir')
        if c:
            temp_dir = expand_resource(self.group, c)
            if temp_dir is None:
                self.bld.fatal(c + ' not found.')
            args.append('-d ' + temp_dir)

        c = cfg.get('conf_dir')
        if c:
            conf_dir = expand_resource(self.group, c)
            if conf_dir is None:
                self.bld.fatal(c + ' not found.')
            args.append('-c ' + conf_dir)

        c = cfg.get('builder', 'html')
        args.append('-b ' + c)

        c = cfg.get('jobs')
        if c:
            args.append('-j %i' % c)

        c = cfg.get('settings', {})
        for key, value in c.items():
            args.append('-D %s=%s' % (key, value))

        c = cfg.get('context', {})
        for key, value in c.items():
            args.append('-A %s=%s' % (key, value))
Beispiel #12
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # Change current directory, before running pylint, helps module imports
        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        # Flags
        c = make_list(cfg.get('flags'))
        if len(c) == 0:
            # see:
            # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498809;msg=10
            c = [
                '-D__gnuc_va_list=va_list',
                '-warnposix',
                '+forcehints',
                '-formatcode',
                '-compdestroy',
            ]

        for flag in c:
            args.append(flag)
Beispiel #13
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # identity file
        c = cfg.get('identity_file', None)
        if c:
            args.append('-i %s' % expand_resource(self.group, c))

        # port
        c = cfg.get('port', None)
        if c:
            args.append('-P %s' % c)

        # host
        h = cfg.get('host', None)
        if h:
            u = cfg.get('username', None)
            if u:
                self.hoststr = '%s@%s' % (u, h)
            else:
                self.hoststr = h
        else:
            self.bld.fatal('configuration "%s" is required for %s' % (
                    'host', tool_name))
Beispiel #14
0
    def prepare(self):
        cfg = self.conf

        # Change current directory
        c = cfg.get('work_dir', None)
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(c + ' not found.')
        else:
            c = os.environ.get('ROOT_DIR')
            if c:
                self.workdir = c

        c = cfg.get('command')
        if c:
            self.cmd = c.format(**self.group.get_patterns())
        else:
            self.bld.fatal('command option is required.')

        # Shell environment
        self.environ = {}
        c = cfg.get('environ', None)
        if c:
            for key, value in c.items():
                self.environ[key] = value.format(**self.group.get_patterns())
Beispiel #15
0
    def perform(self):
        if len(self.file_in) != 1:
            self.bld.fatal('%s only need one input' % tool_name.capitalize())
        if len(self.file_out) != 1:
            self.bld.fatal('%s can only have one output' %\
                    tool_name.capitalize())

        file_in = self.file_in[0]
        basedir = self.conf.get('basedir', None)
        if basedir:
            basedir = expand_resource(self.group, basedir)
            if file_in.startswith(basedir):
                name = file_in[len(basedir) + 1:]
            else:
                name = os.path.basename(file_in)
            self.args.append('--name="%s"' % name)

        executable = self.env['%s_BIN' % tool_name.upper()]
        return self.exec_command(
            '{exe} {arg} {in_} > {out}'.format(
            exe=executable,
            arg=' '.join(self.args),
            in_=self.file_in[0],
            out=self.file_out[0]
        ))
Beispiel #16
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # Change current directory, before running pylint, helps module imports
        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        # Flags
        c = make_list(cfg.get('flags'))
        if len(c) == 0:
            # see:
            # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498809;msg=10
            c = [
                '-D__gnuc_va_list=va_list',
                '-warnposix',
                '+forcehints',
                '-formatcode',
                '-compdestroy',
            ]

        for flag in c:
            args.append(flag)
Beispiel #17
0
    def prepare(self):
        cfg = self.conf

        # Change current directory
        c = cfg.get('work_dir', None)
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(c + ' not found.')
        else:
            c = os.environ.get('ROOT_DIR')
            if c:
                self.workdir = c

        c = cfg.get('command')
        if c:
            self.cmd = c.format(**self.group.get_patterns())
        else:
            self.bld.fatal('command option is required.')

        # Shell environment
        self.environ = {}
        c = cfg.get('environ', None)
        if c:
            for key, value in c.items():
                self.environ[key] = value.format(**self.group.get_patterns())
Beispiel #18
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        c = cfg.get('target')
        if c is None:
            self.bld.fatal('"target" is required by %s' % tool_name)
        else:
            self.target = c.format(**self.group.get_patterns())

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)

        self.add_bool_args('verbose', 'msgs2stderr', 'quiet', 'checksum',
                'archive', 'recursive', 'relative', 'no_implied_dirs', 'backup',
                'update', 'inplace', 'append', 'append_verify', 'dirs', 'links',
                'copy_links', 'copy_unsafe_links', 'safe_links', 'munge_links',
                'copy_dirlinks', 'keep_dirlinks', 'hard_links', 'perms',
                'executability', 'acls', 'xattrs', 'owner', 'group', 'devices',
                'specials', 'times', 'omit_dir_times', 'omit_link_times',
                'super', 'fake_super', 'sparse', 'preallocate', 'dry_run',
                'whole_file', 'one_file_system', 'existing', 'ignore_existing',
                'remove_source_files', 'delete', 'delete_before',
                'delete_during', 'delete_delay', 'delete_after',
                'delete_excluded', 'ignore_missing_args', 'delete_missing_args',
                'ignore-errors', 'force', 'partial', 'delay_updates',
                'prune_empty_dirs', 'numeric_ids', 'ignore_times', 'size_only',
                'fuzzy', 'compress', 'cvs_exclude', 'from0', 'protect_args',
                'blocking_io', 'stats', '8_bit_output', 'human_readable',
                'progress', 'itemize_changes', 'list_only', 'ipv4', 'ipv6')

        self.add_int_args('block_size', 'max_delete', 'max_size', 'min_size',
                'timeout', 'contimeout', 'modify_window', 'compress_level',
                'port', 'bwlimit', 'protocol', 'checksum_seed')

        self.add_list_args_join(',', 'skip_compress')

        self.add_list_args_multi('filter', 'exclude', 'include')

        self.add_path_args('backup_dir', 'exclude_from', 'include_from',
                'files_from', 'password_file', 'read_batch')

        self.add_str_args('info', 'debug', 'suffix', 'chmod', 'rsh',
                'rsync_path', 'partial_dir', 'usermap', 'groupmap', 'chown',
                'remote_option', 'temp_dir', 'compare_dest', 'copy_dest',
                'link_dest', 'address', 'sockopts', 'out_format', 'log_file',
                'log_file_format', 'write_batch', 'only_write_batch', 'iconv')

        c = cfg.get('no_MOTD')
        if c:
            args.append('--no-motd')

        c = make_list(cfg.get('no_OPTION'))
        for option in c:
            args.append('--no-' + option)

        c = cfg.get('outbuf')
        if c:
            args.append('--outbuf=' + c[1].upper())
Beispiel #19
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # Change current directory, before running pylint, helps module imports
        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        # Specify a configuration file
        c = cfg.get('config_file')
        if c:
            args.append("--rcfile='%s'" % expand_resource(self.group, c))

        # Set the output format. Available formats are text,
        # parseable, colorized, msvs (visual studio) and html.
        # You can also give a reporter class, eg
        # mypackage.mymodule.MyReporterClass. [current: text]
        c = cfg.get('reporter', None)
        if c:
            args.append("--output-format='%s'" % c)

        # In error mode, checkers without error messages are
        # disabled and for others, only the ERROR messages are
        # displayed, and no reports are done by default
        c = cfg.get('error_only', False)
        if c:
            args.append('--errors-only')

        # Tells whether to display a full report or only the
        # messages [current: yes]
        c = cfg.get('full_report', False)
        if c:
            args.append('--reports=y')
        else:
            args.append('--reports=n')

        # Plugins
        plugins = make_list(cfg.get('plugins'))
        if len(plugins):
            args.append('--load-plugins=%s' % ','.join(plugins))
Beispiel #20
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # Change current directory, before running pylint, helps module imports
        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        # Specify a configuration file
        c = cfg.get('config_file')
        if c:
            args.append("--rcfile='%s'" % expand_resource(self.group, c))

        # Set the output format. Available formats are text,
        # parseable, colorized, msvs (visual studio) and html.
        # You can also give a reporter class, eg
        # mypackage.mymodule.MyReporterClass. [current: text]
        c = cfg.get('reporter', None)
        if c:
            args.append("--output-format='%s'" % c)

        # In error mode, checkers without error messages are
        # disabled and for others, only the ERROR messages are
        # displayed, and no reports are done by default
        c = cfg.get('error_only', False)
        if c:
            args.append('--errors-only')

        # Tells whether to display a full report or only the
        # messages [current: yes]
        c = cfg.get('full_report', False)
        if c:
            args.append('--reports=y')
        else:
            args.append('--reports=n')

        # Plugins
        plugins = make_list(cfg.get('plugins'))
        if len(plugins):
            args.append('--load-plugins=%s' % ','.join(plugins))
Beispiel #21
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        # Change current directory
        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        # Output
        c = cfg.get('output')
        if c:
            args.append('--output=' + c)

        # Filters
        c = make_list(cfg.get('filter'))
        if len(c):
            args.append('--filter=' + ','.join(c))

        # Counting
        c = cfg.get('counting')
        if c:
            args.append('--counting=' + c)

        # Root
        c = cfg.get('root_dir')
        if c:
            args.append('--root=' + expand_resource(self.group, c))

        # Line length
        c = cfg.get('line_length')
        if c:
            args.append('--linelength=%i' % c)

        # Extensions
        c = make_list(cfg.get('extensions', ['c', 'cpp', 'h']))
        args.append('--extensions=' + ','.join(c))
Beispiel #22
0
    def prepare(self):
        cfg = self.conf
        self.args = ['--print']

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)

        self.add_bool_args('inline', 'compress', 'firebug', 'line_numbers',
                'sourcemap', 'sourcemap_inline', 'include_css', 'deps',
                'disable_cache', 'hoist_atrules', 'resolve_url',
                'resolve_url_nocheck')

        self.add_path_args('sourcemap_base', opt_val_sep=' ')

        self.add_path_list_args_multi('use', 'include', 'import',
                opt_val_sep=' ')

        self.add_str_args('sourcemap_root', 'prefix', opt_val_sep=' ')
Beispiel #23
0
    def prepare(self):
        # Update files, create if necessary
        self.args = ['-uo']

        c = self.conf.get('extract_dir')
        if c is None:
            self.bld.fatal('"extract_dir" configuration is required')

        path = c.format(**self.group.get_patterns())
        if not os.path.exists(path):
            os.makedirs(path)
        elif not os.path.isdir(path):
            os.remove(path)
            os.makedirs(path)
        self.args.append('-d ' + expand_resource(self.group, c))

        c = self.conf.get('quiet')
        if c:
            self.args.append('-q')
Beispiel #24
0
    def prepare(self):
        cfg = self.conf
        self.args = ['--print']

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)

        self.add_bool_args('inline', 'compress', 'firebug', 'line_numbers',
                           'sourcemap', 'sourcemap_inline', 'include_css',
                           'deps', 'disable_cache', 'hoist_atrules',
                           'resolve_url', 'resolve_url_nocheck')

        self.add_path_args('sourcemap_base', opt_val_sep=' ')

        self.add_path_list_args_multi('use',
                                      'include',
                                      'import',
                                      opt_val_sep=' ')

        self.add_str_args('sourcemap_root', 'prefix', opt_val_sep=' ')
Beispiel #25
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        c = cfg.get('wait_sec', None)
        if c is not None:
            args.append('-w' + c)

        command = cfg.get('command', None)
        if command is None:
            self.bld.fatal('command option is required.')

        c = cfg.get('force', False)
        if c:
            args.append('force-' + command)
        else:
            args.append(command)

        target = cfg.get('target', None)
        if target is None:
            self.bld.fatal('target option is required.')

        args.append(expand_resource(self.group, target))
Beispiel #26
0
    def perform(self):
        if len(self.file_in) != 1:
            self.bld.fatal('%s only need one input' % tool_name.capitalize())
        if len(self.file_out) != 1:
            self.bld.fatal('%s can only have one output' %\
                    tool_name.capitalize())

        file_in = self.file_in[0]
        basedir = self.conf.get('basedir', None)
        if basedir:
            basedir = expand_resource(self.group, basedir)
            if file_in.startswith(basedir):
                name = file_in[len(basedir) + 1:]
            else:
                name = os.path.basename(file_in)
            self.args.append('--name="%s"' % name)

        executable = self.env['%s_BIN' % tool_name.upper()]
        return self.exec_command('{exe} {arg} {in_} > {out}'.format(
            exe=executable,
            arg=' '.join(self.args),
            in_=self.file_in[0],
            out=self.file_out[0]))
Beispiel #27
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        c = cfg.get('wait_sec', None)
        if c is not None:
            args.append('-w' + c)

        command = cfg.get('command', None)
        if command is None:
            self.bld.fatal('command option is required.')

        c = cfg.get('force', False)
        if c:
            args.append('force-' + command)
        else:
            args.append(command)

        target = cfg.get('target', None)
        if target is None:
            self.bld.fatal('target option is required.')

        args.append(expand_resource(self.group, target))
Beispiel #28
0
    def prepare(self):
        c = self.conf.get('module')
        if c is None:
            self.bld.fatal('"module" option in required')
        elif os.path.sep in c:
            c = expand_resource(self.bld, c)
            dirname, basename = os.path.split(c)
            modulename, extname = os.path.splitext(basename)
            assert extname == '.py'
            self.args.append(('module_path', dirname))
            self.args.append(('module_name', modulename))
        else:
            self.args.append(('module_name', c))

        c = self.conf.get('args')
        if c:
            assert isinstance(c, dict)
            self.args.append(('complex_args', c))

        c = self.conf.get('free_form')
        if c:
            self.args.append(('module_args', c))

        c = self.conf.get('forks')
        if c:
            try:
                c = int(c)
            except ValueError:
                self.bld.fatal('"forks" option must be numeral')
            self.args.append(('forks', c))

        c = self.conf.get('connect_timeout')
        if c:
            try:
                c = int(c)
            except ValueError:
                self.bld.fatal('"timeout" option must be numeral')
            self.args.append(('timeout', c))

        c = self.conf.get('hosts_pattern', '*')
        self.args.append(('pattern', c))

        c = make_list(self.conf.get('hosts'))
        if c:
            self.args.append(('run_hosts', c))

        # do not run async
        self.args.append(('background', 0))

        ## context

        # Yaml context
        c = self.conf.get('context_yaml')
        if c:
            yaml_file = expand_resource(self.group, c)
            if yaml_file is None:
                self.bld.fatal('"context_yaml" for %s has invalid value' %\
                        tool_name.capitalize())
            with open(yaml_file, 'r') as f:
                self.context.update(yaml_load(f))

        # Python context
        c = self.conf.get('context_python')
        if c:
            python_file = expand_resource(self.group, c)
            if python_file is None:
                self.bld.fatal('"context_python" for %s has invalid value' %\
                        tool_name.capitalize())
            dirname, filename = os.path.split(python_file)
            filebase, _ = os.path.splitext(filename)
            if os.path.exists(os.path.join(dirname, '__init__.py')):
                sys.path.append(dirname)
                mod = __import__(filebase)
            else:
                try:
                    from importlib.machinery import SourceFileLoader
                    mod = SourceFileLoader('context_python',
                                           python_file).load_module()
                except ImportError:
                    import imp
                    mod = imp.load_source('context_python', python_file)
                python_export = mod.export
            self.context.update(python_export)

        self.context.update(self.conf.get('context', {}))
        self.args.append(('play_vars', self.context))

        # with_items
        c = self.conf.get('with_items')
        if isinstance(c, list):
            wi = list(c)
        elif c:
            c = c.split('.')
            wi_ctx = self.context
            for wi_idx in c:
                wi = wi_ctx[wi_idx]
            wi = make_list(wi, nodict=True)
        else:
            wi = []

        for wi_item in wi:
            if isinstance(wi_item, dict):
                self.items.append(wi_item)
            else:
                self.items.append({'item': wi_item})
Beispiel #29
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        args.append('--error-exitcode=-1')

        # Change current directory, before running cppcheck
        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)
            if self.workdir is None:
                self.bld.fatal(cfg['work_dir'] + ' not found.')

        # Build dir
        c = cfg.get('build_dir')
        if c:
            args.append('--cppcheck-build-dir=' + expand_resource(self.group,
                    c))

        # Check library
        c = cfg.get('check_library')
        if c:
            args.append('--check-library')

        # Config exclude directory
        for path in make_list(cfg.get('config_exclude')):
            args.append('--config-exclude=' + expand_resource(self.group, path))

        # Config excludes file
        c = cfg.get('config_exclude_file')
        if c:
            args.append('--config-excludes-file=' + expand_resource(self.group,
                    c))

        # Dump
        c = cfg.get('dump')
        if c:
            args.append('--dump')

        # Defines
        for define in make_list(cfg.get('define')):
            args.append('-D' + define)

        # Undefines
        for define in make_list(cfg.get('undefine')):
            args.append('-U' + define)

        # Enable additional checks
        c = make_list(cfg.get('enable_check'))
        if len(c):
            args.append('--enable=' + ','.join(c))

        # Exit code suppressions
        for path in make_list(cfg.get('ignore_files')):
            args.append('--exitcode-suppressions=' + expand_resource(self.group,
                    path))

        # Search directory for include files
        for path in make_list(cfg.get('include_path')):
            args.append('-I ' + expand_resource(self.group, path))

        # Include
        for path in make_list(cfg.get('include')):
            args.append('--include=' + expand_resource(self.group, path))

        # Exclude
        for path in make_list(cfg.get('exclude')):
            args.append('-i ' + expand_resource(self.group, path))

        # Inconclusive, allow false positives
        c = cfg.get('inconclusive')
        if c:
            args.append('--inconclusive')

        # Inline suppression
        c = cfg.get('inline_disable', True)
        if c:
            args.append('--inline-suppr')

        # Parallel
        c = cfg.get('jobs')
        if c:
            args.append('-j %i' % c)

        # Max processor usage
        c = cfg.get('load_average')
        if c:
            args.append('-l %f' % c)

        # Programming language
        c = cfg.get('proglang')
        if c:
            args.append('--language=' + c)

        # Library
        c = cfg.get('library')
        if c:
            args.append('--library=' + expand_resource(self.group, c))

        # Project file
        c = cfg.get('project')
        if c:
            args.append('--project=' + expand_resource(self.group, c))

        # Maximum configs
        c = cfg.get('max_configs')
        if c:
            args.append('--max-configs=%i' % c)

        # Platform
        c = cfg.get('platform')
        if c:
            args.append('--platform=' + c)

        # Quiet
        c = cfg.get('quiet', True)
        if c:
            args.append('--quiet')

        # Relative paths
        c = make_list(cfg.get('relative_paths'))
        if len(c):
            args.append('--relative-paths=' + ';'.join(c))

        # Rule
        c = cfg.get('rule')
        if c:
            args.append("--rule='%s'" % c)

        # Rule file
        c = cfg.get('rule_file')
        if c:
            args.append('--rule-file=' + expand_resource(self.group, c))

        # Standard
        for std in make_list(cfg.get('standard')):
            args.append('--std=' + std)

        # Suppress
        for dis in make_list(cfg.get('disable')):
            args.append('--suppress=' + dis)

        # Suppressions list
        c = cfg.get('disable_file')
        if c:
            args.append('--suppressions-list=' + expand_resource(self.group,
                    c))

        # Template
        c = cfg.get('template')
        if c:
            args.append("--template='%s'" % c)

        # Verbose
        c = cfg.get('verbose')
        if c:
            args.append('--verbose')

        # XML
        c = cfg.get('xml')
        if c:
            args.append('--xml')

        # XML version
        c = cfg.get('xml_version')
        if c:
            args.append('--xml-version=' + c)
Beispiel #30
0
    def prepare(self):
        cfg = self.conf
        arg = self.args

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)

        c = cfg.get('graph_attr')
        if isinstance(c, dict):
            for key in c:
                arg.append('-G%s=%s' % (key, c[key]))
        elif c is not None:
            self.bld.fatal('graph_attr must be a dictionary.')

        c = cfg.get('node_attr')
        if isinstance(c, dict):
            for key in c:
                arg.append('-N%s=%s' % (key, c[key]))
        elif c is not None:
            self.bld.fatal('node_attr must be a dictionary.')

        c = cfg.get('edge_attr')
        if isinstance(c, dict):
            for key in c:
                arg.append('-E%s=%s' % (key, c[key]))
        elif c is not None:
            self.bld.fatal('edge_attr must be a dictionary.')

        c = cfg.get('output_format')
        if c:
            arg.append('-T' + c)

        c = cfg.get('layout_engine')
        if c:
            arg.append('-K' + c)

        c = cfg.get('library', [])
        for lib in c:
            arg.append('-l' + lib)

        c = cfg.get('verbosity')
        if c is not None:
            arg.append('-q' + c)

        c = cfg.get('scale')
        if c:
            arg.append('-s' + c)

        c = cfg.get('v_flip')
        if c:
            arg.append('-y')

        c = cfg.get('no_layout')
        if c:
            arg.append('-n' + c)

        c = cfg.get('reduce_graph')
        if c:
            arg.append('-x')

        c = cfg.get('no_grid')
        if c:
            arg.append('-Lg')

        c = cfg.get('old_attract')
        if c:
            arg.append('-LO')

        c = cfg.get('iteration')
        if c:
            arg.append('-Ln' + c)

        c = cfg.get('unscaled_factor')
        if c:
            arg.append('-LU' + c)

        c = cfg.get('overlap_expansion_factor')
        if c:
            arg.append('-LC' + c)

        c = cfg.get('temperature_factor')
        if c:
            arg.append('-LT' + c)
Beispiel #31
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)

        self.add_bool_args(
            'debug', 'verbose', 'progress', 'output_pathinfo', 'cache',
            'watch_stdin', 'watch_poll', 'hot', 'labeled_modules', 'bail',
            'profile', 'optimize_minimize', 'color', 'hide_modules',
            'display_modules', 'display_chunks', 'display_entrypoints',
            'display_origins', 'display_cached', 'display_cached_assets',
            'display_reasons', 'display_depth', 'display_used_exports',
            'display_provided_exports', 'display_error_details')

        self.add_dict_args('module_bind',
                           'module_bind_pre',
                           'module_bind_post',
                           'define',
                           'provide',
                           'resolve_alias',
                           'resolve_loader_alias',
                           opt_val_sep=' ')

        self.add_int_args('watch_aggregate_timeout', 'optimize_max_chunks',
                          'optimize_min_chunk_size', 'display_max_modules')

        self.add_list_args_multi('devtool', 'plugin', 'display_exclude')

        self.add_list_args_multi('env', opt_val_sep='.')
        self.add_list_args_multi('resolve_extensions', opt_val_sep=' ')

        self.add_path_args('context', 'records_input_path')

        self.add_path_list_args_multi('prefetch')

        self.add_str_args(
            'output_path',
            'output_filename',
            'output_chunk_filename',
            'output_source_map_filename',
            'output_public_path',
            'output_jsonp_function',
            'output_library',
            'output_library_target',
            'records_output_path',
            'records_path',
            'target',
            'sort_modules_by',
            'sort_chunks_by',
            'sort_assets_by',
        )

        c = cfg.get('config_file')
        if c:
            args.append('--config=' + expand_resource(self.group, c))

        c = cfg.get('entry', {})
        for entry_name, entry_js_file in c.items():
            args.append(
                '--%s=%s' %
                (entry_name, expand_resource(self.group, entry_js_file)))
Beispiel #32
0
    def prepare(self):
        cfg = self.conf
        arg = self.args

        c = cfg.get('require_consent')
        if c:
            arg.append('-RequireConsent')

        c = cfg.get('project_to_project_timeout')
        if c:
            arg.append('-Project2ProjectTimeOut')
            arg.append('%i' % int(c))

        c = cfg.get('packages_directory')
        if c:
            arg.append('-PackagesDirectory')
            arg.append(c.format(**self.group.get_patterns()))

        c = cfg.get('solution_directory')
        if c:
            arg.append('-SolutionDirectory')
            arg.append(c.format(**self.group.get_patterns()))

        c = cfg.get('msbuild_version')
        if c:
            arg.append('-MSBuildVersion')
            arg.append('%i' % int(c))

        c = cfg.get('msbuild_path')
        if c:
            path = expand_resource(self.group, c)
            if path is None:
                self.bld.fatal('msbuild_path not found: ' + c)
            arg.append('-MSBuildPath')
            arg.append(path)

        c = cfg.get('recursive')
        if c:
            arg.append('-Recursive')

        sources = make_list(cfg.get('source'))
        for source in sources:
            path = expand_resource(self.group, source)
            if path is None:
                self.bld.fatal('source not found: ' + c)
            arg.append('-Source')
            arg.append(path)

        sources = make_list(cfg.get('fallback_source'))
        for source in sources:
            path = expand_resource(self.group, source)
            if path is None:
                self.bld.fatal('fallback_source not found: ' + c)
            arg.append('-FallbackSource')
            arg.append(path)

        c = cfg.get('no_cache')
        if c:
            arg.append('-NoCache')

        c = cfg.get('direct_download')
        if c:
            arg.append('-DirectDownload')

        c = cfg.get('disable_parallel_processing')
        if c:
            arg.append('-DisableParallelProcessing')

        c = cfg.get('package_save_mode')
        if c:
            arg.append('-PackageSaveMode')
            arg.append(c)

        c = cfg.get('verbosity')
        if c:
            arg.append('-Verbosity')
            arg.append(c)

        c = cfg.get('non_interactive')
        if c:
            arg.append('-NonInteractive')

        c = cfg.get('config_file')
        if c:
            path = expand_resource(self.group, c)
            if path is None:
                self.bld.fatal('config_file not found: ' + c)
            arg.append('-ConfigFile')
            arg.append(path)

        c = cfg.get('force_english_output')
        if c:
            arg.append('-ForceEnglishOutput')
Beispiel #33
0
    def prepare(self):
        cfg = self.conf
        arg = self.args

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)

        c = cfg.get('graph_attr')
        if isinstance(c, dict):
            for key in c:
                arg.append('-G%s=%s' % (key, c[key]))
        elif c is not None:
            self.bld.fatal('graph_attr must be a dictionary.')

        c = cfg.get('node_attr')
        if isinstance(c, dict):
            for key in c:
                arg.append('-N%s=%s' % (key, c[key]))
        elif c is not None:
            self.bld.fatal('node_attr must be a dictionary.')

        c = cfg.get('edge_attr')
        if isinstance(c, dict):
            for key in c:
                arg.append('-E%s=%s' % (key, c[key]))
        elif c is not None:
            self.bld.fatal('edge_attr must be a dictionary.')

        c = cfg.get('output_format')
        if c:
            arg.append('-T' + c)

        c = cfg.get('layout_engine')
        if c:
            arg.append('-K' + c)

        c = cfg.get('library', [])
        for lib in c:
            arg.append('-l' + lib)

        c = cfg.get('verbosity')
        if c is not None:
            arg.append('-q' + c)

        c = cfg.get('scale')
        if c:
            arg.append('-s' + c)

        c = cfg.get('v_flip')
        if c:
            arg.append('-y')

        c = cfg.get('no_layout')
        if c:
            arg.append('-n' + c)

        c = cfg.get('reduce_graph')
        if c:
            arg.append('-x')

        c = cfg.get('no_grid')
        if c:
            arg.append('-Lg')

        c = cfg.get('old_attract')
        if c:
            arg.append('-LO')

        c = cfg.get('iteration')
        if c:
            arg.append('-Ln' + c)

        c = cfg.get('unscaled_factor')
        if c:
            arg.append('-LU' + c)

        c = cfg.get('overlap_expansion_factor')
        if c:
            arg.append('-LC' + c)

        c = cfg.get('temperature_factor')
        if c:
            arg.append('-LT' + c)
Beispiel #34
0
    def prepare(self):
        cfg = self.conf
        args = self.args

        c = cfg.get('target')
        if c is None:
            self.bld.fatal('"target" is required by %s' % tool_name)
        else:
            self.target = c.format(**self.group.get_patterns())

        c = cfg.get('work_dir')
        if c:
            self.workdir = expand_resource(self.group, c)

        self.add_bool_args(
            'verbose', 'msgs2stderr', 'quiet', 'checksum', 'archive',
            'recursive', 'relative', 'no_implied_dirs', 'backup', 'update',
            'inplace', 'append', 'append_verify', 'dirs', 'links',
            'copy_links', 'copy_unsafe_links', 'safe_links', 'munge_links',
            'copy_dirlinks', 'keep_dirlinks', 'hard_links', 'perms',
            'executability', 'acls', 'xattrs', 'owner', 'group', 'devices',
            'specials', 'times', 'omit_dir_times', 'omit_link_times', 'super',
            'fake_super', 'sparse', 'preallocate', 'dry_run', 'whole_file',
            'one_file_system', 'existing', 'ignore_existing',
            'remove_source_files', 'delete', 'delete_before', 'delete_during',
            'delete_delay', 'delete_after', 'delete_excluded',
            'ignore_missing_args', 'delete_missing_args', 'ignore-errors',
            'force', 'partial', 'delay_updates', 'prune_empty_dirs',
            'numeric_ids', 'ignore_times', 'size_only', 'fuzzy', 'compress',
            'cvs_exclude', 'from0', 'protect_args', 'blocking_io', 'stats',
            '8_bit_output', 'human_readable', 'progress', 'itemize_changes',
            'list_only', 'ipv4', 'ipv6')

        self.add_int_args('block_size', 'max_delete', 'max_size', 'min_size',
                          'timeout', 'contimeout', 'modify_window',
                          'compress_level', 'port', 'bwlimit', 'protocol',
                          'checksum_seed')

        self.add_list_args_join(',', 'skip_compress')

        self.add_list_args_multi('filter', 'exclude', 'include')

        self.add_path_args('backup_dir', 'exclude_from', 'include_from',
                           'files_from', 'password_file', 'read_batch')

        self.add_str_args('info', 'debug', 'suffix', 'chmod', 'rsh',
                          'rsync_path', 'partial_dir', 'usermap', 'groupmap',
                          'chown', 'remote_option', 'temp_dir', 'compare_dest',
                          'copy_dest', 'link_dest', 'address', 'sockopts',
                          'out_format', 'log_file', 'log_file_format',
                          'write_batch', 'only_write_batch', 'iconv')

        c = cfg.get('no_MOTD')
        if c:
            args.append('--no-motd')

        c = make_list(cfg.get('no_OPTION'))
        for option in c:
            args.append('--no-' + option)

        c = cfg.get('outbuf')
        if c:
            args.append('--outbuf=' + c[1].upper())