Exemplo n.º 1
0
    def _install(self, target):
        self.path = ""
        if target.platform == "Windows":
            architecture_string = ""
            if target.architecture == "64":
                architecture_string = "-win64-x64"
            else:
                architecture_string = "-win32-x86"
            source_path = "CMake/cmake-3.12.3" + architecture_string + ".zip"
            zip_ref = zipfile.ZipFile(source_path, "r")
            self.path = "Build/cmake-3.12.3" + architecture_string + \
                        "/bin/cmake.exe"

            # TODO : the path we delete here doesn't seem right
            shutil.rmtree(self.path, ignore_errors=True)
            zip_ref.extractall("Build")
            zip_ref.close()
        elif target.platform == "Linux":
            download_url = "https://github.com/CodeSmithyIDE/CMake/archive/master.zip"
            download = Download("CMake", download_url, "Build")
            download.download(None)
            download.unzip()
            previous_working_dir = os.getcwd()
            os.chdir("Build/CMake")
            try:
                try:
                    subprocess.check_call(["chmod", "0774", "bootstrap"])
                except subprocess.CalledProcessError:
                    raise RuntimeError("chmod 0774 bootstrap failed.")
                try:
                    subprocess.check_call("./bootstrap")
                except subprocess.CalledProcessError:
                    raise RuntimeError("./bootstrap failed.")
                GNUmake().compile("Makefile", None, None)
                self.path = "Build/CMake/bin/cmake"
            finally:
                os.chdir(previous_working_dir)
        else:
            raise RuntimeError("Unsupported platform: " + target.platform)