Ejemplo n.º 1
0
    def process(self, progress):
        if "build_path" not in self._context:
            logging.error("source path not known for {},"
                          " are you missing a matching retrieval script?".format(self._context.name))
            return False

        # prepare for out-of-source build
        build_path = os.path.join(self._context["build_path"], "build")
        #if os.path.exists(build_path):
        #    shutil.rmtree(build_path)
        try:
            os.mkdir(build_path)
        except:
            pass

        soutpath = os.path.join(self._context["build_path"], "stdout.log")
        serrpath = os.path.join(self._context["build_path"], "stderr.log")

        try:
            with on_exit(lambda: progress.finish()):
                with open(soutpath, "w") as sout:
                    with open(serrpath, "w") as serr:
                        with os_utils.Chdir(self.build_path):
                            os_utils.cmd([config["paths"]["cmake"], "-G", "NMake Makefiles", ".."] + self.__arguments, echo=True, show_output=True, critical=True)
                        proc = Popen([config['tools']['make'], "verbose=1"],
                                     shell=True,
                                     env=config["__environment"],
                                     cwd=build_path,
                                     stdout=PIPE, stderr=serr)
                        progress.job = "Compiling"
                        progress.maximum = 100
                        while proc.poll() is None:
                            while True:
                                line = proc.stdout.readline()
                                if line != '':
                                    match = re.search("^\\[([0-9 ][0-9 ][0-9])%\\]", line)
                                    if match is not None:
                                        progress.value = int(match.group(1))
                                    sout.write(line)
                                else:
                                    break

                        if proc.returncode != 0:
                            raise Exception("failed to build (returncode %s), see %s and %s" %
                                            (proc.returncode, soutpath, serrpath))

                        if self.__install:
                            proc = Popen([config['tools']['make'], "install"],
                                         shell=True,
                                         env=config["__environment"],
                                         cwd=build_path,
                                         stdout=sout, stderr=serr)
                            proc.communicate()
                            if proc.returncode != 0:
                                raise Exception("failed to install (returncode %s), see %s and %s" %
                                                (proc.returncode, soutpath, serrpath))
                                return False
        except Exception, e:
            logging.error(e.message)
            return False
Ejemplo n.º 2
0
    def process(self, progress):
        if "build_path" not in self._context:
            logging.error(
                "source path not known for {},"
                " are you missing a matching retrieval script?".format(
                    self._context.name))
            return False

        # prepare for out-of-source vs build
        build_path = os.path.join(self._context["build_path"], "vsbuild")
        if os.path.exists(build_path):
            shutil.rmtree(build_path)
        try:
            os.mkdir(build_path)
        except Exception:
            pass

        soutpath = os.path.join(self._context["build_path"], "vs_stdout.log")
        serrpath = os.path.join(self._context["build_path"], "vs_stderr.log")

        vs_generator = "Visual Studio {0} {1}".format(
            config['vc_version'].split(".", 1)[0],
            vc_year(config['vc_version']))
        # Updated for latest versions of CMake > 3.1 - VS 2019 does not allow use of the deprecated method
        vs_generator_arch = "x64"
        if config["architecture"] == "x86":
            vs_generator_arch = "Win32"

        try:
            with on_exit(lambda: progress.finish()):
                with open(soutpath, "w") as sout:
                    with open(serrpath, "w") as serr:
                        proc = Popen([
                            config["paths"]["cmake"], "-G", vs_generator, "-A",
                            vs_generator_arch, ".."
                        ] + self.__arguments,
                                     cwd=build_path,
                                     env=config["__environment"],
                                     stdout=sout,
                                     stderr=serr)
                        proc.communicate()
                        if proc.returncode != 0:
                            raise Exception(
                                "failed to generate vs project (returncode %s), see %s and %s"
                                % (proc.returncode, soutpath, serrpath))

        except Exception as e:
            logging.exception(e)
            return False

        return True
Ejemplo n.º 3
0
    def process(self, progress):
        if "build_path" not in self._context:
            logging.error(
                "source path not known for {},"
                " are you missing a matching retrieval script?".format(
                    self._context.name))
            return False

        if config['architecture'] == 'x86_64':
            suffix = ""
        else:
            suffix = "_32"

        # prepare for out-of-source build
        build_path = os.path.join(self._context["build_path"],
                                  "build" + suffix)
        # if os.path.exists(build_path):
        #    shutil.rmtree(build_path)
        try:
            os.mkdir(build_path)
        except Exception:
            pass
        soutpath = os.path.join(self._context["build_path"],
                                "stdout" + suffix + ".log")
        serrpath = os.path.join(self._context["build_path"],
                                "stderr" + suffix + ".log")

        try:
            with on_exit(lambda: progress.finish()):
                with open(soutpath, "w") as sout:
                    with open(serrpath, "w") as serr:
                        cmdline = [
                            config["paths"]["cmake"], "-G", "NMake Makefiles",
                            ".."
                        ] + self.__arguments
                        print("{}> {}".format(build_path, ' '.join(cmdline)))
                        proc = Popen(cmdline,
                                     cwd=build_path,
                                     env=config["__environment"],
                                     stdout=sout,
                                     stderr=serr)
                        proc.communicate()
                        if proc.returncode != 0:
                            raise Exception(
                                "failed to generate makefile (returncode %s), see %s and %s"
                                % (proc.returncode, soutpath, serrpath))

                        cmdline = [config['tools']['make'], "verbose=1"]
                        print("{}> {}".format(build_path, ' '.join(cmdline)))
                        proc = Popen(cmdline,
                                     shell=True,
                                     env=config["__environment"],
                                     cwd=build_path,
                                     stdout=PIPE,
                                     stderr=serr)
                        progress.job = "Compiling"
                        progress.maximum = 100
                        while proc.poll() is None:
                            while True:
                                line = proc.stdout.readline().decode("utf-8")
                                if line != '':
                                    match = re.search(
                                        "^\\[([0-9 ][0-9 ][0-9])%\\]", line)
                                    if match is not None:
                                        progress.value = int(match.group(1))
                                    sout.write(line)
                                else:
                                    break

                        if proc.returncode != 0:
                            raise Exception(
                                "failed to build (returncode %s), see %s and %s"
                                % (proc.returncode, soutpath, serrpath))

                        if self.__install:
                            cmdline = [config['tools']['make'], "install"]
                            print("{}> {}".format(build_path,
                                                  ' '.join(cmdline)))
                            proc = Popen(cmdline,
                                         shell=True,
                                         env=config["__environment"],
                                         cwd=build_path,
                                         stdout=sout,
                                         stderr=serr)
                            proc.communicate()
                            if proc.returncode != 0:
                                raise Exception(
                                    "failed to install (returncode %s), see %s and %s"
                                    % (proc.returncode, soutpath, serrpath))

        except Exception as e:
            logging.exception(e)
            return False
        return True
Ejemplo n.º 4
0
    def process(self, progress):
        if "build_path" not in self._context:
            logging.error(
                "source path not known for {},"
                " are you missing a matching retrieval script?".format(
                    self._context.name))
            return False

        if config['architecture'] == 'x86_64':
            suffix = ""
        else:
            suffix = "_32"

        soutpath = os.path.join(self._context["build_path"],
                                "stdout" + suffix + ".log")
        serrpath = os.path.join(self._context["build_path"],
                                "stderr" + suffix + ".log")

        try:
            with on_exit(lambda: progress.finish()):
                with open(soutpath, "w") as sout:
                    with open(serrpath, "w") as serr:
                        verbosity = "minimal" if self.__verbosity is None else self.__verbosity
                        lverbosity = "normal" if self.__verbosity is None else self.__verbosity
                        reltarget = "Release" if self.__reltarget is None else self.__reltarget
                        environment = dict(
                            self.__environment() if self.__environment(
                            ) is not None else config["__environment"])

                        args = [
                            "msbuild", self.__solution, "/maxcpucount",
                            "/property:Configuration=" + reltarget,
                            "/verbosity:" + verbosity,
                            "/consoleloggerparameters:Summary", "/fileLogger",
                            "/property:RunCodeAnalysis=false",
                            "/fileloggerparameters:Summary;Verbosity=" +
                            lverbosity
                        ]

                        if self.__project_platform is None:
                            args.append("/property:Platform={}".format(
                                "x64" if config['architecture'] ==
                                'x86_64' else "win32"))
                        else:
                            args.append("/property:Platform={}".format(
                                self.__project_platform))

                        if self.__project_platformtoolset is not None:
                            args.append("/property:PlatformToolset={}".format(
                                self.__project_platformtoolset))

                        if self.__project:
                            args.append("/target:{}".format(self.__project))

                        if self.__project_WindowsTargetPlatformVersion is None:
                            args.append(
                                "/p:WindowsTargetPlatformVersion={}".format(
                                    config['vc_TargetPlatformVersion']))
                        else:
                            args.append(
                                "/p:WindowsTargetPlatformVersion={}".format(
                                    self.__project_WindowsTargetPlatformVersion
                                ))

                        if self.__project_AdditionalParams:
                            for param in self.__project_AdditionalParams:
                                args.append(param)

                        wdir = str(self.__working_directory
                                   or self._context["build_path"])
                        print("{}> {}".format(wdir, ' '.join(args)))
                        proc = Popen(args,
                                     env=environment,
                                     shell=True,
                                     cwd=wdir,
                                     stdout=PIPE,
                                     stderr=serr)
                        progress.job = "Compiling"
                        progress.maximum = 100
                        while proc.poll() is None:
                            while True:
                                line = proc.stdout.readline().decode("utf-8")
                                if line != '':
                                    match = re.search(
                                        "^\\[([0-9 ][0-9 ][0-9])%\\]", line)
                                    if match is not None:
                                        progress.value = int(match.group(1))
                                    sout.write(line)
                                else:
                                    break

                        if proc.returncode != 0:
                            raise Exception(
                                "failed to build (returncode %s), see %s and %s"
                                % (proc.returncode, soutpath, serrpath))
        #proc.communicate()
        # if proc.returncode != 0:
        #     logging.error("failed to generate makefile (returncode %s), see %s",
        #                   proc.returncode, os.path.join(wdir, "msbuild.log"))
        #     return False

        except Exception as e:
            logging.exception(e)
            return False
        return True
Ejemplo n.º 5
0
class CMakeVS(Builder):
    def __init__(self):
        super(CMakeVS, self).__init__()
        self.__arguments = []
        self.__install = False

    @property
    def name(self):
        if self._context is None:
            return "cmake"

        return "cmake {0}".format(self._context.name)

    def applies(self, parameters):
        return True

    def fulfilled(self):
        return False

    def arguments(self, arguments):
        self.__arguments = arguments
        return self

    def install(self):
        self.__install = True
        return self

    def process(self, progress):
        if "build_path" not in self._context:
            logging.error(
                "source path not known for {},"
                " are you missing a matching retrieval script?".format(
                    self._context.name))
            return False

        # prepare for out-of-source build
        # if os.path.exists(build_path):
        #    shutil.rmtree(build_path)
        build_path = os.path.join(self._context["build_path"], "build")
        try:
            os.mkdir(build_path)
        except Exception:
            pass

        soutpath = os.path.join(self._context["build_path"], "stdout.log")
        serrpath = os.path.join(self._context["build_path"], "stderr.log")

        try:
            with on_exit(lambda: progress.finish()):
                with open(soutpath, "w") as sout:
                    with open(serrpath, "w") as serr:
                        proc = Popen([
                            config["paths"]["cmake"], "-G", "NMake Makefiles",
                            ".."
                        ] + self.__arguments,
                                     cwd=build_path,
                                     env=config["__environment"],
                                     stdout=sout,
                                     stderr=serr)
                        proc.communicate()
                        if proc.returncode != 0:
                            raise Exception(
                                "failed to generate makefile (returncode %s), see %s and %s"
                                % (proc.returncode, soutpath, serrpath))

                        proc = Popen([config['tools']['make'], "verbose=1"],
                                     shell=True,
                                     env=config["__environment"],
                                     cwd=build_path,
                                     stdout=PIPE,
                                     stderr=serr)
                        progress.job = "Compiling"
                        progress.maximum = 100
                        while proc.poll() is None:
                            while True:
                                line = proc.stdout.readline()
                                if line != '':
                                    match = re.search(
                                        "^\\[([0-9 ][0-9 ][0-9])%\\]", line)
                                    if match is not None:
                                        progress.value = int(match.group(1))
                                    sout.write(line)
                                else:
                                    break

                        if proc.returncode != 0:
                            raise Exception(
                                "failed to build (returncode %s), see %s and %s"
                                % (proc.returncode, soutpath, serrpath))

                        if self.__install:
                            proc = Popen([config['tools']['make'], "install"],
                                         shell=True,
                                         env=config["__environment"],
                                         cwd=build_path,
                                         stdout=sout,
                                         stderr=serr)
                            proc.communicate()
                            if proc.returncode != 0:
                                raise Exception(
                                    "failed to install (returncode %s), see %s and %s"
                                    % (proc.returncode, soutpath, serrpath))

        except Exception, e:
            logging.error(e.message)
            return False

        # prepare for out-of-source vs build
        # if os.path.exists(build_path):
        #    shutil.rmtree(build_path)
        build_path = os.path.join(self._context["build_path"], "vsbuild")
        try:
            os.mkdir(build_path)
        except Exception:
            pass

        soutpath = os.path.join(self._context["build_path"], "vs_stdout.log")
        serrpath = os.path.join(self._context["build_path"], "vs_stderr.log")

        vs_generator = "Visual Studio {0} {1}".format(
            config['vc_version'].split(".", 1)[0],
            vc_year(config['vc_version']))
        if config["architecture"] == "x86_64":
            vs_generator += " Win64"

        try:
            with on_exit(lambda: progress.finish()):
                with open(soutpath, "w") as sout:
                    with open(serrpath, "w") as serr:
                        proc = Popen([
                            config["paths"]["cmake"], "-G", vs_generator, ".."
                        ] + self.__arguments,
                                     cwd=build_path,
                                     env=config["__environment"],
                                     stdout=sout,
                                     stderr=serr)
                        proc.communicate()
                        if proc.returncode != 0:
                            raise Exception(
                                "failed to generate vs project (returncode %s), see %s and %s"
                                % (proc.returncode, soutpath, serrpath))

        except Exception, e:
            logging.error(e.message)
            return False