示例#1
0
    def _devenv_compile(options, solution, version):
        proj_extension = MsvcCompiler._get_project_file_ext(version)
        devenv = MsvcCompiler._get_devenv_path(version)
        compiler_version = MsvcCompiler._get_compiler_version(
            version, options.build_platform)

        project = os.path.normpath(
            os.path.join(options.build_dir, 'ALL_BUILD' + proj_extension))
        solutionConfig = '%s|%s' % (options.build_config.capitalize(),
                                    options.build_platform)

        if options.verbose:
            print('Compiler       : %s' % compiler_version)
            print('Compile type   : %s' % options.compile_type)
            print('Devenv         : %s' % devenv)
            print('Solution       : %s' % solution)
            print('Project        : %s' % project)
            print('Solution Config: %s' % solutionConfig)
            print('Configuration  : %s' % options.build_config)
            print('Platform       : %s' % options.build_platform)

        with TempDir() as temp_dir:
            output = MsvcCompiler._create_log_filename(temp_dir.path,
                                                       options.compile_type,
                                                       options.build_config)

            command = 'devenv.exe "%s" /%s "%s" /project "%s" /projectconfig %s /out "%s"' % \
                      (solution, options.compile_type.capitalize(), \
                       solutionConfig, project, \
                       options.build_config.capitalize(), output)

            if options.verbose:
                print('Command: %s' % command)

            process = subprocess.Popen(command, \
                                       stdout=subprocess.PIPE, stderr=subprocess.STDOUT, \
                                       shell=True, bufsize=1, cwd=os.path.dirname(devenv))

            # Wait a max of 10secs to see if the output file will open
            total_time = 0.0
            while not os.path.isfile(output) and total_time < 10.0:
                total_time += .5
                time.sleep(total_time)

            # Tail the output from the log file to the console
            with open(output) as build_output:
                tailer = Tailer(build_output)
                for line in tailer.follow(terminate=process.poll):
                    print(line)
                    if process.poll() != None:
                        break

        return process.returncode
示例#2
0
    def _create_tailer_thread(self) -> FuncThread:
        from tailer import Tailer

        tailer = Tailer(open(self.file_path), end=True)

        def _run_follow(*_):
            try:
                self.started.set()
                for line in tailer.follow(delay=0.25):
                    try:
                        self.callback(line)
                    except Exception:
                        pass
            finally:
                tailer.close()

        return FuncThread(func=_run_follow, on_stop=lambda *_: tailer.close())