def get_qt_install(qt_version, qt_version_minor, vc_version): res = None # We only use the 64bit version of QT in MO2 so this should be fine. try: for baselocation in program_files_folders: # Offline installer default location p = os.path.join(baselocation, "Qt", "Qt{}".format(qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "{}".format(qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "msvc{0}_64".format(vc_year(vc_version))) f = os.path.join(p, "bin", "qmake.exe") if os.path.isfile(f): return os.path.realpath(p) # Online installer default location p = os.path.join(baselocation, "Qt", "{}".format(qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "msvc{0}_64".format(vc_year(vc_version))) f = os.path.join(p, "bin", "qmake.exe") if os.path.isfile(f): return os.path.realpath(p) except Exception: res = None # We should try the custom Qt install path as well if res is None: try: p = os.path.join(config['qt_CustomInstallPath'], "{}".format(qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "msvc{0}_64".format(vc_year(vc_version))) f = os.path.join(p, "bin", "qmake.exe") if os.path.isfile(f): return os.path.realpath(p) except Exception: res = None
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
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
def get_qt_install(qt_version, qt_version_minor, vc_version): # Start with the custom Qt install path, overrides automatic detection try: p = os.path.join( config['qt_CustomInstallPath'], "{}".format( qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "msvc{0}_64".format(vc_year(vc_version))) f = os.path.join(p, "bin", "qmake.exe") if os.path.isfile(f): return os.path.realpath(p) except Exception: pass try: for baselocation in program_files_folders: # Offline installer default location p = os.path.join( baselocation, "Qt", "Qt{}".format(qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "{}".format(qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "msvc{0}_64".format(vc_year(vc_version))) f = os.path.join(p, "bin", "qmake.exe") if os.path.isfile(f): return os.path.realpath(p) # Online installer default location p = os.path.join( baselocation, "Qt", "{}".format(qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "msvc{0}_64".format(vc_year(vc_version))) f = os.path.join(p, "bin", "qmake.exe") if os.path.isfile(f): return os.path.realpath(p) except Exception: pass # Look in the path try: f = shutil.which("qmake.exe") if f is not None and os.path.isfile(f): return os.path.realpath(f) except Exception: pass # Look for qtcreator.exe, which is in %qt%/Tools/QtCreator/bin, then walk # back up to the root from there try: f = shutil.which("qtcreator.exe") if f is not None and os.path.isfile(f): root = os.path.join(os.path.dirname(f), "..", "..", "..") p = os.path.join( root, "{}".format(qt_version + "." + qt_version_minor if qt_version_minor != '' else qt_version), "msvc{0}_64".format(vc_year(vc_version))) f = os.path.join(p, "bin", "qmake.exe") if os.path.isfile(f): return os.path.realpath(p) except Exception: pass return None