当前位置: 首页>>代码示例>>Python>>正文


Python util.get_host_platform函数代码示例

本文整理汇总了Python中mod.util.get_host_platform函数的典型用法代码示例。如果您正苦于以下问题:Python get_host_platform函数的具体用法?Python get_host_platform怎么用?Python get_host_platform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_host_platform函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_vs_header_paths

def get_vs_header_paths(fips_dir, proj_dir, cfg):
    '''hacky way to find the header search path in the latest installed
    Windows 10 Kit and Visual Studio instance
    '''
    if util.get_host_platform() != 'win':
        return []

    # Windows system headers are in 2 locations, first find the latest Windows Kit
    result = []
    kits = glob.glob('C:/Program Files (x86)/Windows Kits/10/Include/*/')
    if kits:
        latest = max(kits).replace('\\','/')
        subdirs = glob.glob(latest + '/*/')
        for d in subdirs:
            result.append(d.replace('\\','/'))

    # next get the used active Visual Studio instance from the cmake cache
    proj_name = util.get_project_name_from_dir(proj_dir)
    build_dir = util.get_build_dir(fips_dir, proj_name, cfg['name'])
    outp = subprocess.check_output(['cmake', '-LA', '.'], cwd=build_dir).decode("utf-8")
    for line in outp.splitlines():
        if line.startswith('CMAKE_LINKER:FILEPATH='):
            bin_index = line.find('/bin/')
            if bin_index > 0:
                result.append(line[22:bin_index+1]+'include')
    return result
开发者ID:floooh,项目名称:fips,代码行数:26,代码来源:vscode.py

示例2: serve_webpage

def serve_webpage(fips_dir, proj_dir) :
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir)
    p = util.get_host_platform()
    if p == 'osx' :
        try :
            subprocess.call(
                'open http://localhost:8000 ; python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt :
            pass
    elif p == 'win':
        try:
            subprocess.call(
                'cmd /c start http://localhost:8000 && python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt:
            pass
    elif p == 'linux':
        try:
            subprocess.call(
                'xdg-open http://localhost:8000; python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt:
            pass
开发者ID:UIKit0,项目名称:oryol,代码行数:25,代码来源:webpage.py

示例3: get_cc_header_paths

def get_cc_header_paths():
    '''runs "cc -E -xc++ -v dummy.cc" and extract the header search
    path from stdout, return these as array of strings.
    '''
    if util.get_host_platform() not in ['osx','linux']:
        return []
    
    # write a dummy C source file
    tmp = tempfile.NamedTemporaryFile(delete=False)
    tmp.write(b'int main() {return 0;}')
    tmp.close()

    # run clang in preprocessor mode
    outp = subprocess.check_output(['cc', '-E', '-xc++', '-v', tmp.name], stderr=subprocess.STDOUT).decode("utf-8")

    # delete the temp source file
    os.remove(tmp.name)

    # find the header search paths
    result = []
    capture = False
    for line in outp.splitlines():
        if line == '#include <...> search starts here:':
            # start capturing lines
            capture = True
            continue
        if line == 'End of search list.':
            # finish capturing
            break
        if capture:
            l = line.replace('(framework directory)', '').strip()
            result.append(l)
    return result
开发者ID:floooh,项目名称:fips,代码行数:33,代码来源:vscode.py

示例4: update_android_sdk

def update_android_sdk(fips_dir, proj_dir) :
    # FIXME: hardcoded version numbers should be configurable
    if util.get_host_platform() == 'win' :
        cmd = '{}/tools/android.bat update sdk -f -u --all --filter tools,platform-tools,build-tools-19.1.0,android-19'.format(get_androidsdk_dir(fips_dir))
    else :
        cmd = 'sh {}/tools/android update sdk -f -u --all --filter tools,platform-tools,build-tools-19.1.0,android-19'.format(get_androidsdk_dir(fips_dir))
    print cmd
    subprocess.call(cmd, cwd=fips_dir, shell=True)
开发者ID:AdrienFromToulouse,项目名称:fips,代码行数:8,代码来源:android.py

示例5: check_config_valid

def check_config_valid(fips_dir, cfg, print_errors=False) :
    """check if provided config is valid, and print errors if not

    :param cfg:     a loaded config object
    :returns:       (True, [ errors ]) tuple with result and error messages
    """
    errors = []
    valid = True

    # check whether all required fields are present
    # (NOTE: name and folder should always be present since they are appended
    # during loading)
    required_fields = ['name', 'folder', 'platform', 'generator', 'build_tool', 'build_type']
    for field in required_fields :
        if field not in cfg :
            errors.append("missing field '{}' in '{}'".format(field, cfg['path']))
            valid = False
    
    # check if the platform string is valid
    if not valid_platform(cfg['platform']) :
        errors.append("invalid platform name '{}' in '{}'".format(cfg['platform'], cfg['path']))
        valid = False

    # check if the platform can be built on current host platform
    if cfg['platform'] not in target_platforms[util.get_host_platform()] :
        errors.append("'{}' is not a valid target platform for host '{}'".format(cfg['platform'], util.get_host_platform()))
        valid = False

    # check if the target platform SDK is installed
    if not check_sdk(fips_dir, cfg['platform']) :
        errors.append("platform sdk for '{}' not installed (see './fips help setup')".format(cfg['platform']))
        valid = False

    # check if the generator name is valid
    if not valid_generator(cfg['generator']) :
        errors.append("invalid generator name '{}' in '{}'".format(cfg['generator'], cfg['path']))
        valid = False

    # check if build tool is valid
    if not valid_build_tool(cfg['build_tool']) :
        errors.append("invalid build_tool name '{}' in '{}'".format(cfg['build_tool'], cfg['path']))
        valid = False

    # check if the build tool can be found
    if not check_build_tool(fips_dir, cfg['build_tool']) :
        errors.append("build tool '{}' not found".format(cfg['build_tool']))
        valid = False

    # check if build type is valid (Debug, Release, Profiling)
    if not valid_build_type(cfg['build_type']) :
        errors.append("invalid build_type '{}' in '{}'".format(cfg['build_type'], cfg['path']))
        valid = False

    if print_errors :
        for error in errors :
            log.error(error, False)

    return (valid, errors)
开发者ID:RobertoMalatesta,项目名称:fips,代码行数:58,代码来源:config.py

示例6: view

def view(fips_dir, proj_dir):
    proj_name = util.get_project_name_from_dir(proj_dir)
    out_dir = util.get_workspace_dir(fips_dir)+'/fips-deploy/'+proj_name+'-markdeep'
    if os.path.isfile(out_dir+'/index.html'):
        p = util.get_host_platform()
        if p == 'osx':
            subprocess.call('open index.html', cwd=out_dir, shell=True)
        elif p == 'win':
            subprocess.call('start index.html', cwd=out_dir, shell=True)
        elif p == 'linux':
            subprocess.call('xdg-open index.html', cwd=out_dir, shell=True)
    else:
        log.error('no generated index.html found: {}'.format(out_dir+'/index.html'))
开发者ID:floooh,项目名称:fips,代码行数:13,代码来源:markdeep.py

示例7: check_tools

def check_tools(fips_dir) :
    """check whether required command line tools can be found"""
    log.colored(log.YELLOW, '=== tools:')
    tools = [ git, cmake, ccmake, cmake_gui, make, ninja, xcodebuild, java, ant, node, python2, ccache ]
    platform = util.get_host_platform()
    for tool in tools:
        if platform in tool.platforms :
            if tool.check_exists(fips_dir) :
                log.ok(tool.name, 'found')
            else :
                if tool.optional :
                    log.optional(tool.name, 'OPTIONAL, NOT FOUND ({})'.format(tool.not_found))
                else :
                    log.failed(tool.name, 'NOT FOUND ({})'.format(tool.not_found))
开发者ID:RobertoMalatesta,项目名称:fips,代码行数:14,代码来源:diag.py

示例8: finish

def finish(sdk_dir) :
    """finish setting up the emscripten SDK

    FIXME: the used SDK version should be configurable!
    """
    if util.get_host_platform() == 'win' :
        # on Windows use a stable SDK version which doesn't require clang to be compiled
        subprocess.call(args='emsdk.bat update', cwd=sdk_dir, shell=True)
        subprocess.call(args='emsdk.bat install {}'.format(get_sdk_version()), cwd=sdk_dir, shell=True)
        subprocess.call(args='emsdk.bat activate --embedded {}'.format(get_sdk_version()), cwd=sdk_dir, shell=True)
    else :
        subprocess.call(args='./emsdk update', cwd=sdk_dir, shell=True)
        subprocess.call(args='./emsdk install {}'.format(get_sdk_version()), cwd=sdk_dir, shell=True)
        subprocess.call(args='./emsdk activate --embedded {}'.format(get_sdk_version()), cwd=sdk_dir, shell=True)
开发者ID:fungos,项目名称:fips,代码行数:14,代码来源:emscripten.py

示例9: run

def run(proj_dir):
    host = util.get_host_platform()
    if host == 'linux':
        try:
            if find_executable("clion.sh") is not None:
                subprocess.Popen('clion.sh {}'.format(proj_dir), cwd=proj_dir, shell=True)
            else:
                subprocess.Popen('clion {}'.format(proj_dir), cwd=proj_dir, shell=True)
        except OSError:
            log.error("Failed to run JetBrains CLion as 'clion' or 'clion.sh'")
    elif host == 'osx':
        try:
            subprocess.Popen('open /Applications/CLion.app --args {}'.format(proj_dir), cwd=proj_dir, shell=True)
        except OSError:
            log.error("Failed to run JetBrains CLion as '/Applications/CLion.app'")
    else:
        log.error("Not supported on this platform")
开发者ID:floooh,项目名称:fips,代码行数:17,代码来源:clion.py

示例10: problem_matcher

def problem_matcher():
    # FIXME: an actual compiler identification would be better here!
    if util.get_host_platform() == 'win':
        # assume that Windows is always the Visual Studio compiler
        return "$msCompile"
    else:
        return {
            'owner': 'cpp',
            'fileLocation': 'absolute',
            'pattern': {
                'regexp': '^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$',
                'file': 1,
                'line': 2,
                'column': 3,
                'severity': 4,
                'message': 5
            }
        }
开发者ID:floooh,项目名称:fips,代码行数:18,代码来源:vscode.py

示例11: check_exists

def check_exists(fips_dir) :
    """test if 'clion' is in the path
    :returns:   True if clion is in the path
    """
    host = util.get_host_platform()
    if host == 'linux':
        # See if CLion was installed from a tar.gz and manually added to the path ("clion.sh"),
        # or added to the path using the "create launcher" command in CLion, which would by default
        # create a symlink from clion.sh to /usr/local/bin/clion.
        # This will also pick up CLion if it was installed using snap.
        if find_executable("clion.sh") is not None or find_executable("clion") is not None:
            return True
        else:
            return False
    elif host == 'osx':
        try:
            subprocess.check_output("mdfind -name CLion.app | grep 'CLion'", shell=True)
            return True
        except (OSError, subprocess.CalledProcessError):
            return False
    else:
        return False
开发者ID:floooh,项目名称:fips,代码行数:22,代码来源:clion.py

示例12: write_launch_json

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",
#.........这里部分代码省略.........
开发者ID:floooh,项目名称:fips,代码行数:101,代码来源:vscode.py

示例13: run

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))
开发者ID:RobertoMalatesta,项目名称:fips,代码行数:66,代码来源:project.py

示例14: get_default_config

def get_default_config() :
    """get the default config name for this platform

    :returns:   default config name for this host platform
    """
    return default_config[util.get_host_platform()]
开发者ID:AdrienFromToulouse,项目名称:fips,代码行数:6,代码来源:config.py

示例15: get_archive_name

def get_archive_name() :
    """return name of sdk archive"""
    return archives[util.get_host_platform()]
开发者ID:fungos,项目名称:fips,代码行数:3,代码来源:emscripten.py


注:本文中的mod.util.get_host_platform函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。