def __getattr__(self, command): """Proxy getter for plumbum commands.""" from os import getenv from plumbum import local from benchbuild.settings import CFG from benchbuild.utils.path import list_to_path from benchbuild.utils.path import path_to_list check = [command] if command in self.__overrides__: check = self.__overrides__[command] if command in __ALIASES__: check = __ALIASES__[command] path = path_to_list(getenv("PATH", default="")) path = CFG["env"]["binary_path"].value() + path libs_path = path_to_list(getenv("LD_LIBRARY_PATH", default="")) libs_path = CFG["env"]["binary_ld_library_path"].value() + libs_path if self.__override_all__ is not None: check = [self.__override_all__] for alias_command in check: try: cmd = local[alias_command] cmd = cmd.with_env(PATH=list_to_path(path), LD_LIBRARY_PATH=list_to_path(libs_path)) return cmd except AttributeError: pass raise AttributeError(command)
def test_path_to_list(self): from benchbuild.utils.path import path_to_list p = path_to_list("a:b") self.assertEqual(p, ["a", "b"]) p = path_to_list("a") self.assertEqual(p, ["a"]) p = path_to_list("") self.assertEqual(p, [])
def __call__(self, compiler: cc, *args: tp.Any, **kwargs: tp.Any) -> tp.Any: if str(compiler).endswith("clang++"): wllvm = local["wllvm++"] else: wllvm = local["wllvm"] env = bb_cfg()["env"].value env_path_list = path_to_list(getenv("PATH", "")) env_path_list = env.get("PATH", []) + env_path_list libs_path = path_to_list(getenv("LD_LIBRARY_PATH", "")) libs_path = env.get("LD_LIBRARY_PATH", []) + libs_path wllvm = wllvm.with_env(LLVM_COMPILER="clang", PATH=list_to_path(env_path_list), LD_LIBRARY_PATH=list_to_path(libs_path)) return self.call_next(wllvm, *args, **kwargs)
def __getattr__(self, command): """Proxy getter for plumbum commands.""" from os import getenv from plumbum import local from benchbuild.settings import CFG from benchbuild.utils.path import list_to_path from benchbuild.utils.path import path_to_list check = [command] if command in self.__overrides__: check = self.__overrides__[command] if command in __ALIASES__: check = __ALIASES__[command] env = CFG["env"].value path = path_to_list(getenv("PATH", "")) path.extend(env.get("PATH", [])) libs_path = path_to_list(getenv("LD_LIBRARY_PATH", "")) libs_path.extend(env.get("LD_LIBRARY_PATH", [])) home = env.get("HOME", getenv("HOME", "")) if self.__override_all__ is not None: check = [self.__override_all__] for alias_command in check: try: alias_cmd = local[alias_command] alias_cmd = alias_cmd.with_env( PATH=list_to_path(path), LD_LIBRARY_PATH=list_to_path(libs_path), HOME=home) return alias_cmd except AttributeError: pass LOG.warning("'%s' cannot be found. Import failed.", command) return ERROR
def __getattr__(self, command): """Proxy getter for plumbum commands.""" from os import getenv from plumbum import local from benchbuild.settings import CFG from benchbuild.utils.path import list_to_path from benchbuild.utils.path import path_to_list check = [command] if command in self.__overrides__: check = self.__overrides__[command] if command in __ALIASES__: check = __ALIASES__[command] env = CFG["env"].value path = path_to_list(getenv("PATH", "")) path.extend(env.get("PATH", [])) libs_path = path_to_list(getenv("LD_LIBRARY_PATH", "")) libs_path.extend(env.get("LD_LIBRARY_PATH", [])) if self.__override_all__ is not None: check = [self.__override_all__] for alias_command in check: try: alias_cmd = local[alias_command] alias_cmd = alias_cmd.with_env( PATH=list_to_path(path), LD_LIBRARY_PATH=list_to_path(libs_path)) return alias_cmd except AttributeError: pass LOG.warning("'%s' cannot be found. Import failed.", command) return ERROR