Exemplo n.º 1
0
def _get_tool(name, version):
    # None: not cached yet
    # False = tool not available, legally skipped
    # True = tool not available, test error
    # (path, env) = tool available
    cached = _cached_tools.setdefault(name, {}).get(version)
    if cached is None:
        tool = tools_locations.get(name, {})
        if tool.get("disabled"):
            _cached_tools[name][version] = False
            return False

        tool_platform = platform.system()
        if tool.get("platform", tool_platform) != tool_platform:
            _cached_tools[name][version] = None, None
            return None, None

        exe = tool.get("exe", name)
        version = version or tool.get("default")
        tool_version = tool.get(version)
        if tool_version is not None:
            assert isinstance(tool_version, dict)
            if tool_version.get("disabled"):
                _cached_tools[name][version] = False
                return False
            tool_path = tool_version.get("path", {}).get(tool_platform)
        else:
            if version is not None:  # if the version is specified, it should be in the conf
                _cached_tools[name][version] = True
                return True
            tool_path = None

        try:
            tool_env = tools_environments[name][tool_platform]
        except KeyError:
            tool_env = None

        cached = tool_path, tool_env

        # Check this particular tool is installed
        if name == "visual_studio":
            if not vswhere():  # TODO: Missing version detection
                cached = True
        else:  # which based detection
            old_environ = None
            if tool_path is not None:
                old_environ = dict(os.environ)
                os.environ[
                    "PATH"] = tool_path + os.pathsep + os.environ["PATH"]
            if not which(
                    exe):  # TODO: This which doesn't detect version either
                cached = True
            if old_environ is not None:
                os.environ.clear()
                os.environ.update(old_environ)

        _cached_tools[name][version] = cached

    return cached
Exemplo n.º 2
0
    'file',
    'git',
    'svn',
    'compiler',
    'conan',  # Search the tool_conan test that needs conan itself
]

if not which("cmake"):
    tools_available.remove("cmake")

if not which("gcc"):
    tools_available.remove("gcc")
if not which("clang"):
    tools_available.remove("clang")
try:
    if not vswhere():
        tools_available.remove("visual_studio")
except ConanException:
    tools_available.remove("visual_studio")

if not any(
    [x for x in ("gcc", "clang", "visual_studio") if x in tools_available]):
    tools_available.remove("compiler")

if not which("xcodebuild"):
    tools_available.remove("xcode")

if not which("file"):
    tools_available.remove("file")

if not which("git"):