Ejemplo n.º 1
0
Archivo: run.py Proyecto: XoDeR/RE
def run(fips_dir, proj_dir, args) :
    """run fips project build targets"""
    if not util.is_valid_project_dir(proj_dir) :
        log.error('must be run in a project directory')
    cfg_name = settings.get(proj_dir, 'config')
    target_name = settings.get(proj_dir, 'target')
    target_args = []
    if '--' in args :
        idx = args.index('--')
        target_args = args[(idx + 1):]
        args = args[:idx]
    if len(args) > 0 :
        target_name = args[0]
    if len(args) > 1 :
        cfg_name = args[1]
    if target_name :
        target_cwd = util.lookup_target_cwd(proj_dir, target_name)
        retcode = project.run(fips_dir, proj_dir, cfg_name, target_name, target_args, target_cwd)
        sys.exit(retcode)
    else :
        log.error('no target provided')
Ejemplo n.º 2
0
def run(fips_dir, proj_dir, args):
    """run fips project build targets"""
    if not util.is_valid_project_dir(proj_dir):
        log.error("must be run in a project directory")
    cfg_name = settings.get(proj_dir, "config")
    target_name = settings.get(proj_dir, "target")
    target_args = []
    if "--" in args:
        idx = args.index("--")
        target_args = args[(idx + 1) :]
        args = args[:idx]
    if len(args) > 0:
        target_name = args[0]
    if len(args) > 1:
        cfg_name = args[1]
    if target_name:
        target_cwd = util.lookup_target_cwd(proj_dir, target_name)
        retcode = project.run(fips_dir, proj_dir, cfg_name, target_name, target_args, target_cwd)
        sys.exit(retcode)
    else:
        log.error("no target provided")
Ejemplo n.º 3
0
def write_launch_json(fips_dir, proj_dir, vscode_dir, cfg):
    '''write the .vscode/launch.json file'''
    proj_name = util.get_project_name_from_dir(proj_dir)
    exe_targets = read_cmake_targets(fips_dir, proj_dir, cfg, ['app'])
    deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg['name'])
    build_dir = util.get_build_dir(fips_dir, proj_name, cfg['name'])

    pre_launch_build_options = [('', True), (' [Skip Build]', False)]
    stop_at_entry_options = [('', False), (' [Stop At Entry]', True)]

    launch = {'version': '0.2.0', 'configurations': []}
    for tgt in exe_targets:
        for pre_launch_build in pre_launch_build_options:
            for stop_at_entry in stop_at_entry_options:
                path = deploy_dir + '/' + tgt
                if util.get_host_platform() == 'win':
                    path += '.exe'
                cwd = util.lookup_target_cwd(proj_dir, tgt)
                if cwd == None:
                    cwd = os.path.dirname(path)
                osx_path = path + '.app/Contents/MacOS/' + tgt
                osx_cwd = os.path.dirname(osx_path)
                if os.path.isdir(osx_cwd):
                    path = osx_path
                    cwd = osx_cwd
                if util.get_host_platform() == 'win':
                    c = {
                        'name': tgt + pre_launch_build[0] + stop_at_entry[0],
                        'type': 'cppvsdbg',
                        'request': 'launch',
                        'program': path,
                        'args': [],
                        'stopAtEntry': stop_at_entry[1],
                        'cwd': cwd,
                        'environment': [],
                        'externalConsole': False,
                        'preLaunchTask': tgt if pre_launch_build[1] else ''
                    }
                elif util.get_host_platform() == 'linux':
                    c = {
                        'name': tgt + pre_launch_build[0] + stop_at_entry[0],
                        'type': 'cppdbg',
                        'request': 'launch',
                        'program': path,
                        'args': [],
                        'stopAtEntry': stop_at_entry[1],
                        'cwd': cwd,
                        'externalConsole': False,
                        'MIMode': 'gdb',
                        'preLaunchTask': tgt if pre_launch_build[1] else ''
                    }
                else:
                    c = {
                        'name': tgt + pre_launch_build[0] + stop_at_entry[0],
                        'type': 'cppdbg',
                        'request': 'launch',
                        'program': path,
                        'args': [],
                        'stopAtEntry': stop_at_entry[1],
                        'cwd': cwd,
                        'externalConsole': False,
                        'MIMode': 'lldb',
                        'preLaunchTask': tgt if pre_launch_build[1] else ''
                    }
                launch['configurations'].append(c)

    # add a python code-generator debug config
    c = {
        'name':
        'fips codegen',
        'type':
        'python',
        'request':
        'launch',
        'stopOnEntry':
        True,
        'pythonPath':
        '${config:python.pythonPath}',
        'program':
        build_dir + '/fips-gen.py',
        'args': [build_dir + '/fips_codegen.yml'],
        "cwd":
        proj_dir,
        "debugOptions":
        ["WaitOnAbnormalExit", "WaitOnNormalExit", "RedirectOutput"]
    }
    launch['configurations'].append(c)

    # add a python debug config for each fips verb
    for verb_name, verb_mod in verb.verbs.items():
        # ignore standard verbs
        if fips_dir not in inspect.getfile(verb_mod):
            c = {
                'name':
                'fips {}'.format(verb_name),
                'type':
                'python',
                'request':
                'launch',
                'stopOnEntry':
                True,
                'pythonPath':
                '${config:python.pythonPath}',
                'program':
                proj_dir + '/fips',
                'args': [verb_name],
                'cwd':
                proj_dir,
                "debugOptions":
                ["WaitOnAbnormalExit", "WaitOnNormalExit", "RedirectOutput"]
            }
            launch['configurations'].append(c)
    launch_path = vscode_dir + '/launch.json'
    log.info('  writing {}'.format(launch_path))
    with open(launch_path, 'w') as f:
        json.dump(launch, f, indent=1, separators=(',', ':'))