コード例 #1
0
def gdb(fips_dir, proj_dir, cfg_name, target=None, target_args=None):
    """debug a single target with gdb"""

    # prepare
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)

    # load the config(s)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    if configs:
        for cfg in configs:
            # check if config is valid
            config_valid, _ = config.check_config_valid(fips_dir,
                                                        proj_dir,
                                                        cfg,
                                                        print_errors=True)
            if config_valid:
                deploy_dir = util.get_deploy_dir(fips_dir, proj_name,
                                                 cfg['name'])
                log.colored(log.YELLOW, "=== gdb: {}".format(cfg['name']))
                cmdLine = ['gdb', "-ex", "run", "--args", target]
                if target_args:
                    cmdLine.extend(target_args)
                try:
                    subprocess.call(args=cmdLine, cwd=deploy_dir)
                except OSError:
                    log.error("Failed to execute gdb (not installed?)")
            else:
                log.error("Config '{}' not valid in this environment".format(
                    cfg['name']))
    else:
        log.error("No valid configs found for '{}'".format(cfg_name))

    return True
コード例 #2
0
ファイル: gdb.py プロジェクト: floooh/fips
def gdb(fips_dir, proj_dir, cfg_name, target=None, target_args=None) :
    """debug a single target with gdb"""

    # prepare
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)

    # load the config(s)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    if configs :
        for cfg in configs :
            # check if config is valid
            config_valid, _ = config.check_config_valid(fips_dir, proj_dir, cfg, print_errors = True)
            if config_valid :
                deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg['name'])
                log.colored(log.YELLOW, "=== gdb: {}".format(cfg['name']))
                cmdLine = ['gdb', "-ex", "run", "--args", target]
                if target_args :
                    cmdLine.extend(target_args)
                try:
                    subprocess.call(args = cmdLine, cwd = deploy_dir)
                except OSError :
                    log.error("Failed to execute gdb (not installed?)")
            else :
                log.error("Config '{}' not valid in this environment".format(cfg['name']))
    else :
        log.error("No valid configs found for '{}'".format(cfg_name))

    return True
コード例 #3
0
ファイル: project.py プロジェクト: mattiasljungstrom/fips
def build(fips_dir, proj_dir, cfg_name, target=None, build_tool_args=None):
    """perform a build of config(s) in project

    :param fips_dir:        absolute path of fips
    :param proj_dir:        absolute path of project dir
    :param cfg_name:        config name or pattern
    :param target:          optional target name (build all if None)
    :param build_tool_args: optional string array of cmdline args forwarded to the build tool
    :returns:               True if build was successful
    """

    # prepare
    dep.fetch_imports(fips_dir, proj_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)
    dep.gather_and_write_imports(fips_dir, proj_dir, cfg_name)

    # load the config(s)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    num_valid_configs = 0
    if configs:
        for cfg in configs:
            # check if config is valid
            config_valid, _ = config.check_config_valid(fips_dir,
                                                        proj_dir,
                                                        cfg,
                                                        print_errors=True)
            if config_valid:
                log.colored(log.YELLOW, "=== building: {}".format(cfg['name']))

                if not gen_project(fips_dir, proj_dir, cfg, False):
                    log.error("Failed to generate '{}' of project '{}'".format(
                        cfg['name'], proj_name))

                # select and run build tool
                build_dir = util.get_build_dir(fips_dir, proj_name,
                                               cfg['name'])
                num_jobs = settings.get(proj_dir, 'jobs')
                result = cmake.run_build(fips_dir, target, cfg['build_type'],
                                         build_dir, num_jobs, build_tool_args)
                if result:
                    num_valid_configs += 1
                else:
                    log.error(
                        "Failed to build config '{}' of project '{}'".format(
                            cfg['name'], proj_name))
            else:
                log.error("Config '{}' not valid in this environment".format(
                    cfg['name']))
    else:
        log.error("No valid configs found for '{}'".format(cfg_name))

    if num_valid_configs != len(configs):
        log.error('{} out of {} configs failed!'.format(
            len(configs) - num_valid_configs, len(configs)))
        return False
    else:
        log.colored(log.GREEN, '{} configs built'.format(num_valid_configs))
        return True
コード例 #4
0
ファイル: project.py プロジェクト: RobertoMalatesta/fips
def build(fips_dir, proj_dir, cfg_name, target=None) :
    """perform a build of config(s) in project

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute path of project dir
    :param cfg_name:    config name or pattern
    :param target:      optional target name (build all if None)
    :returns:           True if build was successful
    """

    # prepare
    dep.fetch_imports(fips_dir, proj_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)
    dep.gather_and_write_imports(fips_dir, proj_dir)

    # load the config(s)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    num_valid_configs = 0
    if configs :
        for cfg in configs :
            # check if config is valid
            config_valid, _ = config.check_config_valid(fips_dir, cfg, print_errors=True)
            if config_valid :
                log.colored(log.YELLOW, "=== building: {}".format(cfg['name']))

                if not gen_project(fips_dir, proj_dir, cfg, False) :
                    log.error("Failed to generate '{}' of project '{}'".format(cfg['name'], proj_name))

                # select and run build tool
                build_dir = util.get_build_dir(fips_dir, proj_name, cfg)
                num_jobs = settings.get(proj_dir, 'jobs')
                result = False
                if cfg['build_tool'] == make.name :
                    result = make.run_build(fips_dir, target, build_dir, num_jobs)
                elif cfg['build_tool'] == ninja.name :
                    result = ninja.run_build(fips_dir, target, build_dir, num_jobs)
                elif cfg['build_tool'] == xcodebuild.name :
                    result = xcodebuild.run_build(fips_dir, target, cfg['build_type'], build_dir, num_jobs)
                else :
                    result = cmake.run_build(fips_dir, target, cfg['build_type'], build_dir)
                
                if result :
                    num_valid_configs += 1
                else :
                    log.error("Failed to build config '{}' of project '{}'".format(cfg['name'], proj_name))
            else :
                log.error("Config '{}' not valid in this environment".format(cfg['name']))
    else :
        log.error("No valid configs found for '{}'".format(cfg_name))

    if num_valid_configs != len(configs) :
        log.error('{} out of {} configs failed!'.format(len(configs) - num_valid_configs, len(configs)))
        return False      
    else :
        log.colored(log.GREEN, '{} configs built'.format(num_valid_configs))
        return True
コード例 #5
0
def check_configs(fips_dir, proj_dir):
    """find configs and check if they are valid"""
    log.colored(log.YELLOW, '=== configs:')
    dirs = [fips_dir]
    configs = config.load(fips_dir, proj_dir, '*')
    for cfg in configs:
        log.colored(log.BLUE, cfg['name'])
        valid, errors = config.check_config_valid(fips_dir, proj_dir, cfg)
        if valid:
            log.colored(log.GREEN, '  ok')
        else:
            for error in errors:
                log.info('  {}'.format(error))
コード例 #6
0
ファイル: diag.py プロジェクト: RobertoMalatesta/fips
def check_configs(fips_dir, proj_dir) :
    """find configs and check if they are valid"""
    log.colored(log.YELLOW, '=== configs:')
    dirs = [ fips_dir ]
    configs = config.load(fips_dir, proj_dir, '*')
    for cfg in configs :
        log.colored(log.BLUE, cfg['name'])
        valid, errors = config.check_config_valid(fips_dir, cfg)
        if valid :
            log.colored(log.GREEN, '  ok')
        else :
            for error in errors :
                log.info('  {}'.format(error))
コード例 #7
0
ファイル: project.py プロジェクト: thomcc/fips
def make_clean(fips_dir, proj_dir, cfg_name):
    """perform a 'make clean' on the project

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute path of project dir
    :param cfg_name:    config name or pattern
    """

    proj_name = util.get_project_name_from_dir(proj_dir)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    num_valid_configs = 0
    if configs:
        for cfg in configs:
            config_valid, _ = config.check_config_valid(fips_dir,
                                                        proj_dir,
                                                        cfg,
                                                        print_errors=True)
            if config_valid:
                log.colored(log.YELLOW, "=== cleaning: {}".format(cfg['name']))

                build_dir = util.get_build_dir(fips_dir, proj_name,
                                               cfg['name'])
                result = False
                if cfg['build_tool'] == make.name:
                    result = make.run_clean(fips_dir, build_dir)
                elif cfg['build_tool'] == ninja.name:
                    result = ninja.run_clean(fips_dir, build_dir)
                elif cfg['build_tool'] == xcodebuild.name:
                    result = xcodebuild.run_clean(fips_dir, build_dir)
                else:
                    result = cmake.run_clean(fips_dir, build_dir)

                if result:
                    num_valid_configs += 1
                else:
                    log.error(
                        "Failed to clean config '{}' of project '{}'".format(
                            cfg['name'], proj_name))
            else:
                log.error("Config '{}' not valid in this environment".format(
                    cfg['name']))
    else:
        log.error("No valid configs found for '{}'".format(cfg_name))

    if num_valid_configs != len(configs):
        log.error('{} out of {} configs failed!'.format(
            len(configs) - num_valid_configs, len(configs)))
        return False
    else:
        log.colored(log.GREEN, '{} configs cleaned'.format(num_valid_configs))
        return True
コード例 #8
0
def gen(fips_dir, proj_dir, cfg_name) :
    """generate build files with cmake

    :param fips_dir:    absolute path to fips
    :param proj_dir:    absolute path to project
    :param cfg_name:    config name or pattern (e.g. osx-make-debug)
    :returns:           True if successful
    """

    # prepare
    dep.fetch_imports(fips_dir, proj_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)
    dep.gather_and_write_imports(fips_dir, proj_dir, cfg_name)

    # load the config(s)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    fips_yml_defines = dep.get_fips_yml_defines(proj_dir)

    num_valid_configs = 0
    if configs :
        for cfg in configs :

            # Merge fips.yml defines into config defines
            if fips_yml_defines:
                if 'defines' in cfg and cfg['defines']:
                    cfg['defines'].update(fips_yml_defines)
                else:
                    cfg['defines'] = fips_yml_defines

            # check if config is valid
            config_valid, _ = config.check_config_valid(fips_dir, proj_dir, cfg, print_errors = True)
            if config_valid :
                if gen_project(fips_dir, proj_dir, cfg, True) :
                    num_valid_configs += 1
                else :
                    log.error("failed to generate build files for config '{}'".format(cfg['name']), False)
            else :
                log.error("'{}' is not a valid config".format(cfg['name']), False)
    else :
        log.error("No configs found for '{}'".format(cfg_name))

    if num_valid_configs != len(configs) :
        log.error('{} out of {} configs failed!'.format(len(configs) - num_valid_configs, len(configs)))
        return False      
    else :
        log.colored(log.GREEN, '{} configs generated'.format(num_valid_configs))
        return True
コード例 #9
0
ファイル: valgrind.py プロジェクト: fips-libs/fips-utils
def valgrind(fips_dir, proj_dir, cfg_name, target, target_args):
    """debug a single target with valgrind"""

    # prepare
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)

    # load the config(s)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    if configs:
        for cfg in configs:
            # check if config is valid
            config_valid, _ = config.check_config_valid(fips_dir,
                                                        proj_dir,
                                                        cfg,
                                                        print_errors=True)
            if config_valid:
                deploy_dir = util.get_deploy_dir(fips_dir, proj_name,
                                                 cfg['name'])
                valgrind_bin = settings.get(proj_dir, 'valgrind')
                if not valgrind_bin:
                    valgrind_bin = 'valgrind'
                log.colored(
                    log.YELLOW,
                    "=== valgrind: {} ({})".format(cfg['name'], valgrind_bin))
                cmd_line = valgrind_bin
                if target_args:
                    cmd_line += ' ' + ' '.join(target_args)
                else:
                    cmd_line += ' ' + '--leak-check=no'
                    cmd_line += ' ' + '--show-reachable=yes'
                    cmd_line += ' ' + '--track-fds=yes'
                    cmd_line += ' ' + '--run-libc-freeres=no'
                    cmd_line += ' ' + "--log-file={}/valgrind-{}.log".format(
                        proj_dir, target)
                cmd_line += ' ' + "./{}".format(target)
                #log.colored(log.GREEN, "cmdline: {}".format(cmd_line))
                subprocess.call(args=cmd_line, cwd=deploy_dir, shell=True)
            else:
                log.error("Config '{}' not valid in this environment".format(
                    cfg['name']))
    else:
        log.error("No valid configs found for '{}'".format(cfg_name))

    return True
コード例 #10
0
ファイル: project.py プロジェクト: RobertoMalatesta/fips
def make_clean(fips_dir, proj_dir, cfg_name) :
    """perform a 'make clean' on the project

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute path of project dir
    :param cfg_name:    config name or pattern
    """

    proj_name = util.get_project_name_from_dir(proj_dir)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    num_valid_configs = 0
    if configs :
        for cfg in configs :
            config_valid, _ = config.check_config_valid(fips_dir, cfg, print_errors=True)
            if config_valid :
                log.colored(log.YELLOW, "=== cleaning: {}".format(cfg['name']))

                build_dir = util.get_build_dir(fips_dir, proj_name, cfg)
                result = False
                if cfg['build_tool'] == make.name :
                    result = make.run_clean(fips_dir, build_dir)
                elif cfg['build_tool'] == ninja.name :
                    result = ninja.run_clean(fips_dir, build_dir)
                elif cfg['build_tool'] == xcodebuild.name :
                    result = xcodebuild.run_clean(fips_dir, build_dir)
                else :
                    result = cmake.run_clean(fips_dir, build_dir)
                    
                if result :
                    num_valid_configs += 1
                else :
                    log.error("Failed to clean config '{}' of project '{}'".format(cfg['name'], proj_name))
            else :
                log.error("Config '{}' not valid in this environment".format(cfg['name']))
    else :
        log.error("No valid configs found for '{}'".format(cfg_name))

    if num_valid_configs != len(configs) :
        log.error('{} out of {} configs failed!'.format(len(configs) - num_valid_configs, len(configs)))
        return False      
    else :
        log.colored(log.GREEN, '{} configs cleaned'.format(num_valid_configs))
        return True
コード例 #11
0
ファイル: project.py プロジェクト: RobertoMalatesta/fips
def gen(fips_dir, proj_dir, cfg_name) :
    """generate build files with cmake

    :param fips_dir:    absolute path to fips
    :param proj_dir:    absolute path to project
    :param cfg_name:    config name or pattern (e.g. osx-make-debug)
    :returns:           True if successful
    """

    # prepare
    dep.fetch_imports(fips_dir, proj_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)
    dep.gather_and_write_imports(fips_dir, proj_dir)

    # load the config(s)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    num_valid_configs = 0
    if configs :
        for cfg in configs :
            # check if config is valid
            config_valid, _ = config.check_config_valid(fips_dir, cfg, print_errors = True)
            if config_valid :
                if gen_project(fips_dir, proj_dir, cfg, True) :
                    num_valid_configs += 1
                else :
                    log.error("failed to generate build files for config '{}'".format(cfg['name']), False)
            else :
                log.error("'{}' is not a valid config".format(cfg['name']), False)
    else :
        log.error("No configs found for '{}'".format(cfg_name))

    if num_valid_configs != len(configs) :
        log.error('{} out of {} configs failed!'.format(len(configs) - num_valid_configs, len(configs)))
        return False      
    else :
        log.colored(log.GREEN, '{} configs generated'.format(num_valid_configs))
        return True
コード例 #12
0
ファイル: valgrind.py プロジェクト: floooh/fips
def valgrind(fips_dir, proj_dir, cfg_name, target, target_args) :
    """debug a single target with valgrind"""

    # prepare
    proj_name = util.get_project_name_from_dir(proj_dir)
    util.ensure_valid_project_dir(proj_dir)

    # load the config(s)
    configs = config.load(fips_dir, proj_dir, cfg_name)
    if configs :
        for cfg in configs :
            # check if config is valid
            config_valid, _ = config.check_config_valid(fips_dir, proj_dir, cfg, print_errors = True)
            if config_valid :
                deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg['name'])
                valgrind_bin = settings.get(proj_dir, 'valgrind')
                if not valgrind_bin :
                    valgrind_bin = 'valgrind'
                log.colored(log.YELLOW, "=== valgrind: {} ({})".format(cfg['name'], valgrind_bin))
                cmd_line = valgrind_bin
                if target_args :
                    cmd_line += ' ' + ' '.join(target_args)
                else :
                    cmd_line += ' ' + '--leak-check=no'
                    cmd_line += ' ' + '--show-reachable=yes'
                    cmd_line += ' ' + '--track-fds=yes'
                    cmd_line += ' ' + '--run-libc-freeres=no'
                    cmd_line += ' ' + "--log-file={}/valgrind-{}.log".format(proj_dir, target)
                cmd_line += ' ' + "./{}".format(target)
                #log.colored(log.GREEN, "cmdline: {}".format(cmd_line))
                subprocess.call(args = cmd_line, cwd = deploy_dir, shell = True)
            else :
                log.error("Config '{}' not valid in this environment".format(cfg['name']))
    else :
        log.error("No valid configs found for '{}'".format(cfg_name))

    return True