예제 #1
0
    def run(self, command, output=True, cwd=None, win_bash=False, subsystem=None, msys_mingw=True,
            ignore_errors=False, run_environment=False, with_login=True, env="conanbuildenv"):

        command = environment_wrap_command(env, command, cwd=self.generators_folder)

        def _run():
            if not win_bash:
                return self._conan_runner(command, output, os.path.abspath(RUN_LOG_NAME), cwd)
            # FIXME: run in windows bash is not using output
            return tools.run_in_windows_bash(self, bashcmd=command, cwd=cwd, subsystem=subsystem,
                                             msys_mingw=msys_mingw, with_login=with_login)
        if run_environment:
            # When using_build_profile the required environment is already applied through
            # 'conanfile.env' in the contextmanager 'get_env_context_manager'
            with tools.run_environment(self) if not self._conan_using_build_profile else no_op():
                if OSInfo().is_macos and isinstance(command, string_types):
                    # Security policy on macOS clears this variable when executing /bin/sh. To
                    # keep its value, set it again inside the shell when running the command.
                    command = 'DYLD_LIBRARY_PATH="%s" DYLD_FRAMEWORK_PATH="%s" %s' % \
                              (os.environ.get('DYLD_LIBRARY_PATH', ''),
                               os.environ.get("DYLD_FRAMEWORK_PATH", ''),
                               command)
                retcode = _run()
        else:
            retcode = _run()

        if not ignore_errors and retcode != 0:
            raise ConanException("Error %d while executing %s" % (retcode, command))

        return retcode
예제 #2
0
    def run(self,
            command,
            output=True,
            cwd=None,
            win_bash=False,
            subsystem=None,
            msys_mingw=True,
            ignore_errors=False,
            run_environment=False):
        def _run():
            if not win_bash:
                return self._conan_runner(command, output,
                                          os.path.abspath(RUN_LOG_NAME), cwd)
            # FIXME: run in windows bash is not using output
            return tools.run_in_windows_bash(self,
                                             bashcmd=command,
                                             cwd=cwd,
                                             subsystem=subsystem,
                                             msys_mingw=msys_mingw)

        if run_environment:
            with tools.run_environment(self):
                if OSInfo().is_macos:
                    command = 'DYLD_LIBRARY_PATH="%s" %s' % (os.environ.get(
                        'DYLD_LIBRARY_PATH', ''), command)
                retcode = _run()
        else:
            retcode = _run()

        if not ignore_errors and retcode != 0:
            raise ConanException("Error %d while executing %s" %
                                 (retcode, command))

        return retcode
예제 #3
0
    def run(self,
            command,
            output=True,
            cwd=None,
            win_bash=False,
            subsystem=None,
            msys_mingw=True,
            ignore_errors=False,
            run_environment=False,
            with_login=True,
            env=None):
        # NOTE: "self.win_bash" is the new parameter "win_bash" for Conan 2.0

        def _run(cmd, _env):
            # FIXME: run in windows bash is not using output
            if platform.system() == "Windows":
                if win_bash:
                    return tools.run_in_windows_bash(self,
                                                     bashcmd=cmd,
                                                     cwd=cwd,
                                                     subsystem=subsystem,
                                                     msys_mingw=msys_mingw,
                                                     with_login=with_login)
                elif self.win_bash:  # New, Conan 2.0
                    from conan.tools.microsoft.subsystems import run_in_windows_bash
                    return run_in_windows_bash(self,
                                               command=cmd,
                                               cwd=cwd,
                                               env=_env)
            if _env is None:
                _env = "conanbuild"
            wrapped_cmd = environment_wrap_command(self,
                                                   _env,
                                                   cmd,
                                                   cwd=self.generators_folder)
            return self._conan_runner(wrapped_cmd, output,
                                      os.path.abspath(RUN_LOG_NAME), cwd)

        if run_environment:
            # When using_build_profile the required environment is already applied through
            # 'conanfile.env' in the contextmanager 'get_env_context_manager'
            with tools.run_environment(
                    self) if not self._conan_using_build_profile else no_op():
                if OSInfo().is_macos and isinstance(command, string_types):
                    # Security policy on macOS clears this variable when executing /bin/sh. To
                    # keep its value, set it again inside the shell when running the command.
                    command = 'DYLD_LIBRARY_PATH="%s" DYLD_FRAMEWORK_PATH="%s" %s' % \
                              (os.environ.get('DYLD_LIBRARY_PATH', ''),
                               os.environ.get("DYLD_FRAMEWORK_PATH", ''),
                               command)
                retcode = _run(command, env)
        else:
            retcode = _run(command, env)

        if not ignore_errors and retcode != 0:
            raise ConanException("Error %d while executing %s" %
                                 (retcode, command))

        return retcode
예제 #4
0
    def run(self,
            command,
            output=True,
            cwd=None,
            win_bash=False,
            subsystem=None,
            msys_mingw=True,
            ignore_errors=False,
            run_environment=False,
            with_login=True):
        def _run():
            if not win_bash:
                return self._conan_runner(command, output,
                                          os.path.abspath(RUN_LOG_NAME), cwd)
            # FIXME: run in windows bash is not using output
            return tools.run_in_windows_bash(self,
                                             bashcmd=command,
                                             cwd=cwd,
                                             subsystem=subsystem,
                                             msys_mingw=msys_mingw,
                                             with_login=with_login)

        if run_environment:
            # When using_build_profile the required environment is already applied through 'conanfile.env'
            # in the contextmanager 'get_env_context_manager'
            with tools.run_environment(
                    self) if not self._conan_using_build_profile else no_op():
                if OSInfo().is_macos:
                    command = 'DYLD_LIBRARY_PATH="%s" DYLD_FRAMEWORK_PATH="%s" %s' % \
                              (os.environ.get('DYLD_LIBRARY_PATH', ''),
                               os.environ.get("DYLD_FRAMEWORK_PATH", ''),
                               command)
                retcode = _run()
        else:
            retcode = _run()

        if not ignore_errors and retcode != 0:
            raise ConanException("Error %d while executing %s" %
                                 (retcode, command))

        return retcode