Exemplo n.º 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
Exemplo n.º 2
0
Arquivo: gdb.py Projeto: 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
Exemplo n.º 3
0
def clean(fips_dir, proj_dir, cfg_name):
    """clean build files

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute project path
    :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)
    if configs:
        num_cleaned_configs = 0
        for cfg in configs:
            build_dir = util.get_build_dir(fips_dir, proj_name, cfg['name'])
            build_dir_exists = os.path.isdir(build_dir)
            deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg['name'])
            deploy_dir_exists = os.path.isdir(deploy_dir)

            if build_dir_exists or deploy_dir_exists:
                log.colored(log.YELLOW, "=== clean: {}".format(cfg['name']))
                num_cleaned_configs += 1

            if build_dir_exists:
                shutil.rmtree(build_dir)
                log.info("  deleted '{}'".format(build_dir))

            if deploy_dir_exists:
                shutil.rmtree(deploy_dir)
                log.info("  deleted '{}'".format(deploy_dir))
        if num_cleaned_configs == 0:
            log.colored(log.YELLOW,
                        "=== clean: nothing to clean for {}".format(cfg_name))
    else:
        log.error("No valid configs found for '{}'".format(cfg_name))
Exemplo n.º 4
0
def run(fips_dir, proj_dir, args):
    """run the 'physx' verb"""
    if len(args) > 0:
        noun = args[0]
        if noun == 'build':

            # FIXME all of this only works on windows at the moment and is super hacky

            if len(args) != 2:
                log.error("expected compiler target (win-vs15, win-vs16)")

            preset = util.fix_path(os.path.dirname(os.path.abspath(
                __file__))) + "/physx-presets/" + "fips" + args[1] + ".xml"
            if not os.path.isfile(preset):
                log.error("unrecognized compiler target")
            shutil.copy2(preset,
                         proj_dir + "/../physx/physx/buildtools/presets/")
            subprocess.call(proj_dir +
                            "/../physx/physx/generate_projects.bat fips" +
                            args[1])

            # figure out a version number for vswhere
            version = args[1][6:]
            version_next = str(int(version) + 1)
            version = version + ".0," + version_next + ".0"
            #use vswhere to figure out where vs is
            devenvPath = subprocess.check_output(
                proj_dir + "/../physx/externals/vswhere/vswhere -version [" +
                version + "] -property productPath").decode("utf-8").rstrip()

            devenvPath = util.fix_path(devenvPath)
            if not os.path.isfile(devenvPath):
                log.error("could not detect visual studio installation")
            log.info("Using Visual Studio from" + devenvPath)
            log.info("Compiling PhysX, this might take a while")
            log.info("Building debug version")
            subprocess.call(devenvPath + " " + proj_dir +
                            "/../physx/physx/compiler/fips" + args[1] +
                            "/PhysXSDK.sln /Build debug /Project INSTALL")
            log.info("Building release version")
            subprocess.call(devenvPath + " " + proj_dir +
                            "/../physx/physx/compiler/fips" + args[1] +
                            "/PhysXSDK.sln /Build release /Project INSTALL")
        if noun == 'deploy':
            ps_deploy = util.get_workspace_dir(
                fips_dir) + "/fips-deploy/physx/bin/"
            cur_cfg = settings.get(proj_dir, "config")
            cfg = config.load(fips_dir, proj_dir, cur_cfg)[0]
            px_target = cfg['defines']['PX_TARGET']
            target_dir = util.get_deploy_dir(
                fips_dir, util.get_project_name_from_dir(proj_dir), cur_cfg)
            for dll in glob.glob(ps_deploy + px_target + "/debug/*.dll"):
                shutil.copy2(dll, target_dir)
            for dll in glob.glob(ps_deploy + px_target + "/release/*.dll"):
                shutil.copy2(dll, target_dir)
    else:

        def run(fips_dir, proj_dir, args):
            log.error("Not supported")
Exemplo n.º 5
0
def gen_project(fips_dir, proj_dir, cfg, force):
    """private: generate build files for one config"""

    proj_name = util.get_project_name_from_dir(proj_dir)
    deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg['name'])
    build_dir = util.get_build_dir(fips_dir, proj_name, cfg['name'])
    defines = {}
    defines['FIPS_USE_CCACHE'] = 'ON' if settings.get(proj_dir,
                                                      'ccache') else 'OFF'
    defines['FIPS_AUTO_IMPORT'] = 'OFF' if dep.get_policy(
        proj_dir, 'no_auto_import') else 'ON'
    if cfg['generator'] in ['Ninja', 'Unix Makefiles']:
        defines['CMAKE_EXPORT_COMPILE_COMMANDS'] = 'ON'
    if cfg['platform'] == 'ios':
        defines['CMAKE_OSX_SYSROOT'] = xcrun.get_ios_sdk_sysroot()
        ios_team_id = settings.get(proj_dir, 'iosteam')
        if ios_team_id:
            defines['FIPS_IOS_TEAMID'] = ios_team_id
    if cfg['platform'] == 'osx':
        defines['CMAKE_OSX_SYSROOT'] = xcrun.get_macos_sdk_sysroot()
    if cfg['platform'] == 'emscripten':
        defines['EMSCRIPTEN_ROOT'] = emsdk.get_emscripten_root(fips_dir)
    if cfg['platform'] == 'wasisdk':
        defines['WASISDK_ROOT'] = wasisdk.get_wasisdk_root(fips_dir)
    do_it = force
    if not os.path.isdir(build_dir):
        os.makedirs(build_dir)
    if not os.path.isfile(build_dir + '/CMakeCache.txt'):
        do_it = True
    if do_it:
        # if Ninja build tool and on Windows, need to copy
        # the precompiled ninja.exe to the build dir
        log.colored(log.YELLOW, "=== generating: {}".format(cfg['name']))
        log.info("config file: {}".format(cfg['path']))
        toolchain_path = config.get_toolchain(fips_dir, proj_dir, cfg)
        if toolchain_path:
            log.info("Using Toolchain File: {}".format(toolchain_path))
        is_local_build = settings.get(proj_dir, 'local')
        cmake_result = cmake.run_gen(cfg, fips_dir, proj_dir, build_dir,
                                     is_local_build, toolchain_path, defines)
        if vscode.match(cfg['build_tool']):
            vscode.write_workspace_settings(
                fips_dir, proj_dir, cfg, settings.get_all_settings(proj_dir))
        if clion.match(cfg['build_tool']):
            clion.write_workspace_settings(fips_dir, proj_dir, cfg)
        return cmake_result
    else:
        return True
Exemplo n.º 6
0
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
Exemplo n.º 7
0
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
Exemplo n.º 8
0
def clean(fips_dir, proj_dir, cfg_name) :
    """clean build files

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute project path
    :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)
    if configs :
        for cfg in configs :
            log.colored(log.YELLOW, "=== clean: {}".format(cfg['name']))

            build_dir = util.get_build_dir(fips_dir, proj_name, cfg)
            if os.path.isdir(build_dir) :
                shutil.rmtree(build_dir)
                log.info("  deleted '{}'".format(build_dir))

            deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg)
            if os.path.isdir(deploy_dir) :
                shutil.rmtree(deploy_dir)
                log.info("  deleted '{}'".format(deploy_dir))
    else :
        log.error("No valid configs found for '{}'".format(cfg_name))
Exemplo n.º 9
0
def clean(fips_dir, proj_dir, cfg_name):
    """clean build files

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute project path
    :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)
    if configs:
        for cfg in configs:
            log.colored(log.YELLOW, "=== clean: {}".format(cfg['name']))

            build_dir = util.get_build_dir(fips_dir, proj_name, cfg)
            if os.path.isdir(build_dir):
                shutil.rmtree(build_dir)
                log.info("  deleted '{}'".format(build_dir))

            deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg)
            if os.path.isdir(deploy_dir):
                shutil.rmtree(deploy_dir)
                log.info("  deleted '{}'".format(deploy_dir))
    else:
        log.error("No valid configs found for '{}'".format(cfg_name))
Exemplo n.º 10
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir):
    emsc_deploy_dir = util.get_deploy_dir(fips_dir, 'chips-test', BuildConfig)

    # build the thumbnail gallery
    content = ''
    for item in items:
        if item['type'] == 'test':
            continue
        title = item['title']
        system = item['system']
        url = item['url']
        ui_url = url.replace(".html", "-ui.html")
        image = to_webp_ext(item['img'])
        note = item['note']
        log.info('> adding thumbnail for {}'.format(url))
        content += '<div class="thumb-frame">\n'
        content += '  <div class="thumb-title">{}</div>\n'.format(title)
        if os.path.exists(emsc_deploy_dir + '/' + system + '-ui.js'):
            content += '<a class="ui-btn-link" href="{}"><div class="ui-btn">UI</div></a>'.format(
                ui_url)
        content += '  <a class="image-frame" href="{}"><img class="image" src="{}"></img></a>\n'.format(
            url, image)
        if note != '':
            content += '  <div class="thumb-footer">{}</div>\n'.format(note)
        content += '</div>\n'

    # populate the html template, and write to the build directory
    with open(proj_dir + '/webpage/index.html', 'r') as f:
        templ = Template(f.read())
    html = templ.safe_substitute(samples=content)
    with open(webpage_dir + '/index.html', 'w') as f:
        f.write(html)

    # and the same with the CSS template
    with open(proj_dir + '/webpage/style.css', 'r') as f:
        templ = Template(f.read())
    css = templ.safe_substitute()
    with open(webpage_dir + '/style.css', 'w') as f:
        f.write(css)

    # copy other required files
    for name in ['favicon.png', 'help.html']:
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/webpage/' + name, webpage_dir + '/' + name)

    # generate emu HTML pages
    for system in systems:
        log.info('> generate emscripten HTML page: {}'.format(system))
        for ext in ['wasm', 'js']:
            src_path = '{}/{}.{}'.format(emsc_deploy_dir, system, ext)
            if os.path.isfile(src_path):
                shutil.copy(src_path, '{}/'.format(webpage_dir))
        with open(proj_dir + '/webpage/emsc.html', 'r') as f:
            templ = Template(f.read())
        html = templ.safe_substitute(name=system, prog=system)
        with open('{}/{}.html'.format(webpage_dir, system), 'w') as f:
            f.write(html)

    # copy data files and images
    for asset_dir in asset_dirs:
        src_dir = proj_dir + '/webpage/' + asset_dir
        dst_dir = webpage_dir + '/' + asset_dir
        if os.path.isdir(src_dir):
            if os.path.isdir(dst_dir):
                shutil.rmtree(dst_dir)
            os.makedirs(dst_dir)
            for filename in os.listdir(src_dir):
                src_file = src_dir + '/' + filename
                dst_file = dst_dir + '/' + filename
                if filename.endswith('.jpg'):
                    dst_file = to_webp_ext(dst_file)
                    cwebp(src_file, dst_file)
                else:
                    print('> copy {} => {}'.format(src_file, dst_file))
                    shutil.copyfile(src_file, dst_file)
Exemplo n.º 11
0
def run(fips_dir, proj_dir, cfg_name, target_name, target_args, target_cwd) :
    """run a build target executable

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute path of project dir
    :param cfg_name:    config name or pattern
    :param target_name: the target name
    :param target_args: command line arguments for build target
    :param target_cwd:  working directory or None
    """

    retcode = 10
    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 :
            log.colored(log.YELLOW, "=== run '{}' (config: {}, project: {}):".format(target_name, cfg['name'], proj_name))

            # find deploy dir where executables live
            deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg)
            if not target_cwd :
                target_cwd = deploy_dir

            if cfg['platform'] in ['emscripten', 'pnacl'] : 
                # special case: emscripten app
                if cfg['platform'] == 'emscripten' :
                    html_name = target_name + '.html'
                else :
                    html_name = target_name + '_pnacl.html'
                if util.get_host_platform() == 'osx' :
                    try :
                        subprocess.call(
                            'open http://localhost:8000/{} ; python {}/mod/httpserver.py'.format(html_name, fips_dir),
                            cwd = target_cwd, shell=True)
                    except KeyboardInterrupt :
                        return 0
                elif util.get_host_platform() == 'win' :
                    try :
                        cmd = 'cmd /c start http://localhost:8000/{} && python {}/mod/httpserver.py'.format(html_name, fips_dir)
                        subprocess.call(cmd, cwd = target_cwd, shell=True)
                    except KeyboardInterrupt :
                        return 0
                elif util.get_host_platform() == 'linux' :
                    try :
                        subprocess.call(
                            'xdg-open http://localhost:8000/{}; python {}/mod/httpserver.py'.format(html_name, fips_dir),
                            cwd = target_cwd, shell=True)
                    except KeyboardInterrupt :
                        return 0
                else :
                    log.error("don't know how to start HTML app on this platform")
            elif os.path.isdir('{}/{}.app'.format(deploy_dir, target_name)) :
                # special case: Mac app
                cmd_line = '{}/{}.app/Contents/MacOS/{}'.format(deploy_dir, target_name, target_name)
            else :
                cmd_line = '{}/{}'.format(deploy_dir, target_name) 
            if cmd_line :
                if target_args :
                    cmd_line += ' ' + ' '.join(target_args)
                try:
                    retcode = subprocess.call(args=cmd_line, cwd=target_cwd, shell=True)
                except OSError, e:
                    log.error("Failed to execute '{}' with '{}'".format(target_name, e.strerror))
Exemplo n.º 12
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 = 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=(',', ':'))
Exemplo n.º 13
0
# HACK: Find fips-deploy dir the hard way
# TODO: Fips need pass to generators the fips-deploy dir ready to be used
os_name = platform.system().lower()
extension = ""
proj_path = os.path.normpath('{}/..'.format(
    os.path.dirname(os.path.abspath(__file__))))
items = settings.load(proj_path)
if not items:
    items = {'config': settings.get_default('config')}

# HACK: even setting PROJECT in fips_setup does not work here without a way to get the
# fips-deploy path, so we force to search in Project for windows as it is the default
if os_name == "windows":
    extension = ".exe"

deploy_path = util.get_deploy_dir("../fips", "fips-tests",
                                  {'name': items['config']})


#-------------------------------------------------------------------------------
def get_generator_path():
    """find util_generate_requires exectuable, fail if not exists"""

    bin_path = os.path.abspath('{}/util_generate_requires{}'.format(
        deploy_path, extension))
    print "TRY: " + bin_path
    if not os.path.isfile(bin_path):
        os_name = platform.system().lower()
        bin_path = '{}/util_generate_requires{}'.format(proj_path, extension)
        bin_path = os.path.normpath(bin_path)
        print "TRY: " + bin_path
Exemplo n.º 14
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 = 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=(',',':'))
Exemplo n.º 15
0
def run(fips_dir, proj_dir, cfg_name, target_name, target_args, target_cwd):
    """run a build target executable

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute path of project dir
    :param cfg_name:    config name or pattern
    :param target_name: the target name
    :param target_args: command line arguments for build target
    :param target_cwd:  working directory or None
    """

    retcode = 10
    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:
            log.colored(
                log.YELLOW, "=== run '{}' (config: {}, project: {}):".format(
                    target_name, cfg['name'], proj_name))

            # find deploy dir where executables live
            deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg['name'])
            if not target_cwd:
                target_cwd = deploy_dir

            if cfg['platform'] == 'emscripten':
                # special case: emscripten app
                html_name = target_name + '.html'
                if util.get_host_platform() == 'osx':
                    try:
                        subprocess.call(
                            'open http://localhost:8080/{} ; http-server -c-1 -g'
                            .format(html_name),
                            cwd=target_cwd,
                            shell=True)
                    except KeyboardInterrupt:
                        return 0
                elif util.get_host_platform() == 'win':
                    try:
                        cmd = 'cmd /c start http://localhost:8080/{} && http-server -c-1 -g'.format(
                            html_name)
                        subprocess.call(cmd, cwd=target_cwd, shell=True)
                    except KeyboardInterrupt:
                        return 0
                elif util.get_host_platform() == 'linux':
                    try:
                        subprocess.call(
                            'xdg-open http://localhost:8080/{}; http-server -c-1 -g'
                            .format(html_name),
                            cwd=target_cwd,
                            shell=True)
                    except KeyboardInterrupt:
                        return 0
                else:
                    log.error(
                        "don't know how to start HTML app on this platform")
            elif cfg['platform'] == 'android':
                try:
                    adb_path = android.get_adb_path(fips_dir)
                    pkg_name = android.target_to_package_name(target_name)
                    # Android: first re-install the apk...
                    cmd = '{} install -r {}.apk'.format(adb_path, target_name)
                    subprocess.call(cmd, shell=True, cwd=deploy_dir)
                    # ...then start the apk
                    cmd = '{} shell am start -n {}/android.app.NativeActivity'.format(
                        adb_path, pkg_name)
                    subprocess.call(cmd, shell=True)
                    # ...then run adb logcat
                    cmd = '{} logcat'.format(adb_path)
                    subprocess.call(cmd, shell=True)
                    return 0
                except KeyboardInterrupt:
                    return 0

            elif os.path.isdir('{}/{}.app'.format(deploy_dir, target_name)):
                # special case: Mac app
                cmd_line = '{}/{}.app/Contents/MacOS/{}'.format(
                    deploy_dir, target_name, target_name)
            else:
                cmd_line = '{}/{}'.format(deploy_dir, target_name)
            if cmd_line:
                if target_args:
                    cmd_line += ' ' + ' '.join(target_args)
                try:
                    retcode = subprocess.call(args=cmd_line,
                                              cwd=target_cwd,
                                              shell=True)
                except OSError as e:
                    log.error("Failed to execute '{}' with '{}'".format(
                        target_name, e.strerror))
    else:
        log.error("No valid configs found for '{}'".format(cfg_name))

    return retcode
Exemplo n.º 16
0
def write_workspace_settings(fips_dir, proj_dir, cfg):
    '''write the VSCode launch.json, tasks.json and
    c_cpp_properties.json files from cmake output files
    '''
    proj_name = util.get_project_name_from_dir(proj_dir)
    deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg)
    build_dir = util.get_build_dir(fips_dir, proj_name, cfg)
    vscode_dir = proj_dir + '/.vscode'
    if not os.path.isdir(vscode_dir):
        os.makedirs(vscode_dir)
    exe_targets = read_cmake_targets(fips_dir, proj_dir, cfg, ['app'])
    all_targets = read_cmake_targets(fips_dir, proj_dir, cfg, None)
    inc_paths = read_cmake_headerdirs(fips_dir, proj_dir, cfg)

    if util.get_host_platform() == 'win':
        fips_cmd = 'fips'
    else:
        fips_cmd = './fips'

    # write a tasks.json file
    tasks = {
        'version': '0.1.0',
        'command': fips_cmd,
        'isShellCommand': True,
        'showOutput': 'silent',
        'suppressTaskName': True,
        'echoCommand': True,
        'tasks': []
    }
    for tgt in all_targets:
        tasks['tasks'].append({
            'taskName': tgt,
            'args': ['make', tgt],
            'problemMatcher': problem_matcher(),
        })
    tasks['tasks'].append({
        'isBuildCommand': True,
        'taskName': 'ALL',
        'args': ['build'],
        'problemMatcher': problem_matcher()
    })
    with open(vscode_dir + '/tasks.json', 'w') as f:
        json.dump(tasks, f, indent=1, separators=(',', ':'))

    # write a launch.json with 1 config per build target
    launch = {'version': '0.2.0', 'configurations': []}
    for tgt in exe_targets:
        path = deploy_dir + '/' + tgt
        if util.get_host_platform() == 'win':
            path += '.exe'
        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,
                'type': 'cppvsdbg',
                'request': 'launch',
                'program': path,
                'args': [],
                'stopAtEntry': True,
                'cwd': cwd,
                'environment': [],
                'externalConsole': False
            }
        elif util.get_host_platform() == 'linux':
            c = {
                'name': tgt,
                'type': 'cppdbg',
                'request': 'launch',
                'program': path,
                'args': [],
                'stopAtEntry': True,
                'cwd': cwd,
                'externalConsole': False,
                'MIMode': 'gdb'
            }
        else:
            c = {
                'name': tgt,
                'type': 'cppdbg',
                'request': 'launch',
                'program': path,
                'args': [],
                'stopAtEntry': True,
                'cwd': cwd,
                'externalConsole': False,
                'MIMode': 'lldb'
            }
        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':
        proj_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)

    with open(vscode_dir + '/launch.json', 'w') as f:
        json.dump(launch, f, indent=1, separators=(',', ':'))

    # write a c_cpp_properties.json file with header-search paths
    props = {'configurations': []}
    for config_name in ['Mac', 'Linux', 'Win32']:
        c = {
            'name': config_name,
            'browse': {
                'limitSymbolsToIncludeHeaders': True,
                'databaseFilename': '{}/browse.VS.code'.format(build_dir)
            }
        }
        config_incl_paths = []
        if config_name == 'Mac':
            config_incl_paths = [
                '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1',
                '/usr/local/include',
                '/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/lib/clang/8.1.0/include',
                '/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/include',
                '/usr/include'
            ]
        elif config_name == 'Linux':
            config_incl_paths = ['/usr/include', '/usr/local/include']
        else:
            config_incl_paths = [
                # FIXME
                'C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*'
            ]
        for inc_path in inc_paths:
            config_incl_paths.append(inc_path)
        c['includePath'] = config_incl_paths
        c['browse']['path'] = config_incl_paths
        props['configurations'].append(c)
    with open(vscode_dir + '/c_cpp_properties.json', 'w') as f:
        json.dump(props, f, indent=1, separators=(',', ':'))
Exemplo n.º 17
0
def deploy_webpage(fips_dir, proj_dir, webpage_dir):
    wasm_deploy_dir = util.get_deploy_dir(fips_dir, 'sokol-samples',
                                          BuildConfig)

    # build the thumbnail gallery
    content = ''
    for sample in samples:
        name = sample[0]
        log.info('> adding thumbnail for {}'.format(name))
        url = "{}-sapp.html".format(name)
        ui_url = "{}-sapp-ui.html".format(name)
        img_name = name + '.jpg'
        img_path = proj_dir + '/webpage/' + img_name
        if not os.path.exists(img_path):
            img_name = 'dummy.jpg'
            img_path = proj_dir + 'webpage/dummy.jpg'
        content += '<div class="thumb">'
        content += '  <div class="thumb-title">{}</div>'.format(name)
        if os.path.exists(wasm_deploy_dir + '/' + name + '-sapp-ui.js'):
            content += '<a class="img-btn-link" href="{}"><div class="img-btn">UI</div></a>'.format(
                ui_url)
        content += '  <div class="img-frame"><a href="{}"><img class="image" src="{}"></img></a></div>'.format(
            url, img_name)
        content += '</div>\n'

    # populate the html template, and write to the build directory
    with open(proj_dir + '/webpage/index.html', 'r') as f:
        templ = Template(f.read())
    html = templ.safe_substitute(samples=content)
    with open(webpage_dir + '/index.html', 'w') as f:
        f.write(html)

    # copy other required files
    for name in ['dummy.jpg', 'favicon.png']:
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/webpage/' + name, webpage_dir + '/' + name)

    # generate WebAssembly HTML pages
    for sample in samples:
        name = sample[0]
        source = sample[1]
        glsl = sample[2]
        log.info('> generate wasm HTML page: {}'.format(name))
        for postfix in ['sapp', 'sapp-ui']:
            for ext in ['wasm', 'js']:
                src_path = '{}/{}-{}.{}'.format(wasm_deploy_dir, name, postfix,
                                                ext)
                if os.path.isfile(src_path):
                    shutil.copy(src_path, '{}/'.format(webpage_dir))
                with open(proj_dir + '/webpage/wasm.html', 'r') as f:
                    templ = Template(f.read())
                src_url = GitHubSamplesURL + source
                if glsl is None:
                    glsl_url = "."
                    glsl_hidden = "hidden"
                else:
                    glsl_url = GitHubSamplesURL + glsl
                    glsl_hidden = ""
                html = templ.safe_substitute(name=name,
                                             prog=name + '-' + postfix,
                                             source=src_url,
                                             glsl=glsl_url,
                                             hidden=glsl_hidden)
                with open('{}/{}-{}.html'.format(webpage_dir, name, postfix),
                          'w') as f:
                    f.write(html)

    # copy assets from deploy directory
    for asset in assets:
        log.info('> copy asset file: {}'.format(asset))
        src_path = '{}/{}'.format(wasm_deploy_dir, asset)
        if os.path.isfile(src_path):
            shutil.copy(src_path, webpage_dir)
        else:
            log.warn('!!! file {} not found!'.format(src_path))

    # copy the screenshots
    for sample in samples:
        img_name = sample[0] + '.jpg'
        img_path = proj_dir + '/webpage/' + img_name
        if os.path.exists(img_path):
            log.info('> copy screenshot: {}'.format(img_name))
            shutil.copy(img_path, webpage_dir + '/' + img_name)
Exemplo n.º 18
0
def write_workspace_settings(fips_dir, proj_dir, cfg):
    '''write the VSCode launch.json, tasks.json and
    c_cpp_properties.json files from cmake output files
    '''
    proj_name = util.get_project_name_from_dir(proj_dir)
    deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg)
    build_dir = util.get_build_dir(fips_dir, proj_name, cfg)
    vscode_dir = proj_dir + '/.vscode'
    if not os.path.isdir(vscode_dir):
        os.makedirs(vscode_dir)
    exe_targets = read_cmake_targets(fips_dir, proj_dir, cfg, ['app'])
    all_targets = read_cmake_targets(fips_dir, proj_dir, cfg, None)
    inc_paths = read_cmake_headerdirs(fips_dir, proj_dir, cfg)

    if util.get_host_platform() == 'win':
        fips_cmd = 'fips'
    else:
        fips_cmd = './fips'

    # write a tasks.json file
    tasks = {
        'version': '0.1.0',
        'command': fips_cmd,
        'isShellCommand': True,
        'showOutput': 'silent',
        'suppressTaskName': True,
        'echoCommand': True,
        'tasks': []
    }
    for tgt in all_targets:
        tasks['tasks'].append({
            'taskName': tgt,
            'args': ['make', tgt],
            'problemMatcher': problem_matcher(),
        })
    tasks['tasks'].append({
        'isBuildCommand': True,
        'taskName': 'ALL',
        'args': ['build'],
        'problemMatcher': problem_matcher()
    })
    with open(vscode_dir + '/tasks.json', 'w') as f:
        json.dump(tasks, f, indent=1, separators=(',', ':'))

    # write a launch.json with 1 config per build target
    launch = {'version': '0.2.0', 'configurations': []}
    for tgt in exe_targets:
        path = deploy_dir + '/' + tgt
        if util.get_host_platform() == 'win':
            path += '.exe'
        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,
                'type': 'cppvsdbg',
                'request': 'launch',
                'program': path,
                'stopAtEntry': True,
                'cwd': cwd,
                'environment': [],
                'externalConsole': False
            }
        else:
            c = {
                'name': tgt,
                'type': 'cppdbg',
                'request': 'launch',
                'program': path,
                'stopAtEntry': True,
                'cwd': cwd,
                'externalConsole': False,
                'linux': {
                    'MIMode':
                    'gdb',
                    'setupCommands': [{
                        'description': 'Enable pretty-printing for gdb',
                        'text': '--enable-pretty-printing',
                        'ignoreFailures': True
                    }]
                },
                'osx': {
                    'MIMode': 'lldb'
                }
            }
        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':
        proj_dir + '/.fips-gen.py',
        'args': [build_dir + '/fips_codegen.yml'],
        "cwd":
        proj_dir,
        "debugOptions":
        ["WaitOnAbnormalExit", "WaitOnNormalExit", "RedirectOutput"]
    }
    launch['configurations'].append(c)

    # TODO: add entries for local fips verbs?

    with open(vscode_dir + '/launch.json', 'w') as f:
        json.dump(launch, f, indent=1, separators=(',', ':'))

    # write a c_cpp_properties.json file with header-search paths
    props = {'configurations': []}
    for config_name in ['Mac', 'Linux', 'Win32']:
        c = {
            'name': config_name,
            'browse': {
                'limitSymbolsToIncludeHeaders': True,
                'databaseFilename': ''
            }
        }
        if config_name in ['Mac', 'Linux']:
            c['includePath'] = ['/usr/include', '/usr/local/include']
        else:
            c['includePath'] = [
                # FIXME
                'C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*'
            ]
        for inc_path in inc_paths:
            c['includePath'].append(inc_path)
        props['configurations'].append(c)
    with open(vscode_dir + '/c_cpp_properties.json', 'w') as f:
        json.dump(props, f, indent=1, separators=(',', ':'))
Exemplo n.º 19
0
def run(fips_dir, proj_dir, args):
    """run the 'physx' verb"""
    if len(args) > 0:
        noun = args[0]
        if noun == 'build':
            if sys.platform == "win32":
                # FIXME all of this only works on windows at the moment and is super hacky

                if len(args) != 2:
                    log.error("expected compiler target (win-vs15, win-vs16)")

                preset = util.fix_path(
                    os.path.dirname(os.path.abspath(__file__))
                ) + "/physx-presets/" + "fips" + args[1] + ".xml"
                if not os.path.isfile(preset):
                    log.error("Unrecognized compiler target")
                shutil.copy2(preset,
                             proj_dir + "/../physx/physx/buildtools/presets/")
                subprocess.call(proj_dir +
                                "/../physx/physx/generate_projects.bat fips" +
                                args[1])

                # figure out a version number for vswhere
                version = args[1][6:]
                version_next = str(int(version) + 1)
                version = version + ".0," + version_next + ".0"
                #use vswhere to figure out where vs is
                devenvPath = subprocess.check_output(
                    proj_dir +
                    "/../physx/externals/vswhere/vswhere -version [" +
                    version +
                    "] -property productPath").decode("utf-8").rstrip()
                devenvPath = util.fix_path(devenvPath)
                if not os.path.isfile(devenvPath):
                    #try to find msbuild
                    log.info(
                        "Could not find Visual Studio, trying to find lastest version of MSBuild..."
                        + devenvPath)
                    devenvPath = subprocess.check_output(
                        proj_dir +
                        "/../physx/externals/vswhere/vswhere -version [" +
                        version +
                        "] -products * -requires Microsoft.Component.MSBuild -property installationPath"
                    ).decode("utf-8").rstrip()
                    devenvPath = util.fix_path(
                        devenvPath + "/MSBuild/Current/Bin/MSBuild.exe")
                    if not os.path.isfile(devenvPath):
                        log.error(
                            "Could not detect Visual Studio installation.")
                    log.optional("Using MSBuild from", devenvPath)

                    log.info("Compiling PhysX, this might take a while.")
                    log.info("Building debug version...")
                    #-noConsoleLogger
                    retcode = subprocess.call(
                        devenvPath + " " + proj_dir +
                        "/../physx/physx/compiler/fips" + args[1] +
                        "/INSTALL.vcxproj /verbosity:quiet /noLogo /noConsoleLogger /property:Configuration=Debug"
                    )
                    if retcode == 0:
                        log.colored(log.GREEN, "PhysX debug build completed.")
                    else:
                        log.colored(log.RED, "PhysX debug build failed!")

                    log.info("Building release version...")
                    retcode = subprocess.call(
                        devenvPath + " " + proj_dir +
                        "/../physx/physx/compiler/fips" + args[1] +
                        "/INSTALL.vcxproj /verbosity:quiet /noLogo /noConsoleLogger /property:Configuration=Release"
                    )
                    if retcode == 0:
                        log.colored(log.GREEN,
                                    "PhysX release build completed.")
                    else:
                        log.colored(log.RED, "PhysX release build failed!")
                else:
                    log.optional("Using Visual Studio from", devenvPath)

                    log.info("Compiling PhysX, this might take a while...")
                    log.info("Building debug version...")
                    retcode = subprocess.call(
                        devenvPath + " " + proj_dir +
                        "/../physx/physx/compiler/fips" + args[1] +
                        "/PhysXSDK.sln /Build debug /Project INSTALL")
                    if retcode == 0:
                        log.colored(log.GREEN, "PhysX debug build completed.")
                    else:
                        log.colored(log.RED, "PhysX debug build failed!")

                    log.info("Building release version...")
                    retcode = subprocess.call(
                        devenvPath + " " + proj_dir +
                        "/../physx/physx/compiler/fips" + args[1] +
                        "/PhysXSDK.sln /Build release /Project INSTALL")
                    if retcode == 0:
                        log.colored(log.GREEN,
                                    "PhysX release build completed.")
                    else:
                        log.colored(log.RED, "PhysX release build failed!")
            else:
                preset = util.fix_path(
                    os.path.dirname(os.path.abspath(
                        __file__))) + "/physx-presets/fipslinux.xml"
                shutil.copy2(preset,
                             proj_dir + "/../physx/physx/buildtools/presets/")
                subprocess.run([
                    proj_dir + "/../physx/physx/generate_projects.sh",
                    "fipslinux"
                ])
                subprocess.run(["make", "-j", "10"],
                               cwd=proj_dir +
                               "/../physx/physx/compiler/fipslinux-checked")
                subprocess.run(["make", "install"],
                               cwd=proj_dir +
                               "/../physx/physx/compiler/fipslinux-checked")
        if noun == 'deploy':
            if sys.platform == "win32":
                cur_cfg = None
                if len(args) > 1:
                    cur_cfg = args[1]
                if not cur_cfg:
                    cur_cfg = settings.get(proj_dir, 'config')

                ps_deploy = util.get_workspace_dir(
                    fips_dir) + "/fips-deploy/physx/bin/"
                cfg = config.load(fips_dir, proj_dir, cur_cfg)[0]
                px_target = cfg['defines']['PX_TARGET']
                target_dir = util.get_deploy_dir(
                    fips_dir, util.get_project_name_from_dir(proj_dir),
                    cur_cfg)

                dllFiles = glob.glob(ps_deploy + px_target + "/debug/*.dll")
                log.info("Looking for PhysX dlls in '{}/'".format(ps_deploy +
                                                                  px_target))
                if not dllFiles:
                    log.error(
                        "PhysX debug dlls not found! Have you built them? (fips physx build [compiler target])"
                    )
                else:
                    for dll in dllFiles:
                        shutil.copy2(dll, target_dir)
                    log.colored(
                        log.GREEN,
                        "Deployed PhysX debug binaries to '{}'".format(
                            target_dir))

                dllFiles = glob.glob(ps_deploy + px_target + "/release/*.dll")
                if not dllFiles:
                    log.error(
                        "PhysX release dlls not found! Have you built them? (fips physx build [compiler target])"
                    )
                else:
                    for dll in dllFiles:
                        shutil.copy2(dll, target_dir)
                    log.colored(
                        log.GREEN,
                        "Deployed PhysX release binaries to '{}'".format(
                            target_dir))
    else:

        def run(fips_dir, proj_dir, args):
            log.error("Not supported")
Exemplo n.º 20
0
#-------------------------------------------------------------------------------
# HACK: Find fips-deploy dir the hard way
# TODO: Fips need pass to generators the fips-deploy dir ready to be used
os_name = platform.system().lower()
extension = ""
proj_path = os.path.normpath('{}/..'.format(os.path.dirname(os.path.abspath(__file__))))
items = settings.load(proj_path)
if not items:
    items = {'config': settings.get_default('config')}

# HACK: even setting PROJECT in fips_setup does not work here without a way to get the
# fips-deploy path, so we force to search in Project for windows as it is the default
if os_name == "windows":
    extension = ".exe"

deploy_path = util.get_deploy_dir("../fips", "fips-tests", {'name': items['config']})

#-------------------------------------------------------------------------------
def get_generator_path() :
    """find util_generate_requires exectuable, fail if not exists"""

    bin_path = os.path.abspath('{}/util_generate_requires{}'.format(deploy_path, extension))
    print "TRY: " + bin_path
    if not os.path.isfile(bin_path) :
        os_name = platform.system().lower()
        bin_path = '{}/util_generate_requires{}'.format(proj_path, extension)
        bin_path = os.path.normpath(bin_path)
        print "TRY: " + bin_path
        
        if not os.path.isfile(bin_path) :
            log.error("util_generate_requires executable not found")
Exemplo n.º 21
0
def run(fips_dir, proj_dir, cfg_name, target_name, target_args):
    """run a build target executable

    :param fips_dir:    absolute path of fips
    :param proj_dir:    absolute path of project dir
    :param cfg_name:    config name or pattern
    :param target_name: the target name
    :param target_args: command line arguments for build target
    """

    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:
            log.colored(
                log.YELLOW, "=== run '{}' (config: {}, project: {}):".format(
                    target_name, cfg['name'], proj_name))

            # find deploy dir where executables live
            deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg)

            cmd_line = []
            if cfg['platform'] in ['emscripten', 'pnacl']:
                # special case: emscripten app
                if cfg['platform'] == 'emscripten':
                    html_name = target_name + '.html'
                else:
                    html_name = target_name + '_pnacl.html'
                if util.get_host_platform() == 'osx':
                    try:
                        subprocess.call([
                            'open http://localhost:8000/{} ; python {}/mod/httpserver.py'
                            .format(html_name, fips_dir)
                        ],
                                        cwd=deploy_dir,
                                        shell=True)
                    except KeyboardInterrupt:
                        pass
                elif util.get_host_platform() == 'win':
                    try:
                        cmd = [
                            'cmd /c start http://localhost:8000/{} && python {}/mod/httpserver.py'
                            .format(html_name, fips_dir)
                        ]
                        subprocess.call(cmd, cwd=deploy_dir, shell=True)
                    except KeyboardInterrupt:
                        pass
                elif util.get_host_platform() == 'linux':
                    try:
                        subprocess.call([
                            'xdg-open http://localhost:8000/{}; python {}/mod/httpserver.py'
                            .format(html_name, fips_dir)
                        ],
                                        cwd=deploy_dir,
                                        shell=True)
                    except KeyboardInterrupt:
                        pass
                else:
                    log.error(
                        "don't know how to start HTML app on this platform")
            elif os.path.isdir('{}/{}.app'.format(deploy_dir, target_name)):
                # special case: Mac app
                cmd_line = [
                    'open', '{}/{}.app'.format(deploy_dir, target_name)
                ]
                if target_args:
                    cmd_line.append('--args')
            else:
                cmd_line = ['{}/{}'.format(deploy_dir, target_name)]
            if cmd_line:
                if target_args:
                    cmd_line.extend(target_args)
                try:
                    subprocess.call(args=cmd_line, cwd=deploy_dir)
                except OSError, e:
                    log.error("Failed to execute '{}' with '{}'".format(
                        target_name, e.strerror))
Exemplo n.º 22
0
# HACK: Find fips-deploy dir the hard way
# TODO: Fips need pass to generators the fips-deploy dir ready to be used
os_name = platform.system().lower()
extension = ""
proj_path = os.path.normpath('{}/..'.format(os.path.dirname(os.path.abspath(__file__))))
items = settings.load(proj_path)
if not items:
    items = {'config': settings.get_default('config')}

# HACK: even setting PROJECT in fips_setup does not work here without a way to get the
# fips-deploy path, so we force to search in Project for windows as it is the default
if os_name == "windows":
    extension = ".exe"

deploy_path = util.get_deploy_dir(proj_path + "/Third/fips", "Src", {'name': items['config']})

#-------------------------------------------------------------------------------
def get_shaderc_path() :
    """find shaderc compiler, fail if not exists"""

    shaderc_path = os.path.abspath('{}/shaderc{}'.format(deploy_path, extension))
    print "####shaderC path: %s" % (shaderc_path)
    # if not os.path.isfile(shaderc_path) :
        # os_name = platform.system().lower()
        # shaderc_path = '{}/bgfx/tools/bin/{}/shaderc{}'.format(proj_path, os_name, extension)
        # shaderc_path = os.path.normpath(shaderc_path)
        
        # if not os.path.isfile(shaderc_path) :
            # log.error("bgfx shaderc executable not found, please run 'make tools' in bgfx directory: ", shaderc_path)