class Copy(Task): def __init__(self, source, destination): super(Copy, self).__init__() if isinstance(source, str): source = [source] self.__source = Lazy(source) self.__destination = Lazy(destination) @property def name(self): if self.__source.type() == list: return "Copy {}...".format(self.__source()[0]) else: return "Copy {}".format(self.__source.peek()) def process(self, progress): if os.path.isabs(self.__destination()): full_destination = self.__destination() else: full_destination = os.path.join(self._context["build_path"], self.__destination()) for source in self.__source(): if not os.path.isabs(source): source = os.path.join(self._context["build_path"], source) if not os.path.exists(full_destination): os.makedirs(full_destination) shutil.copy(source, full_destination) return True
class Copy(Task): def __init__(self, source, destination): super(Copy, self).__init__() if isinstance(source, str): source = [source] self.__source = Lazy(source) self.__destination = Lazy(destination) @property def name(self): if self.__source.type() == list: src = self.__source()[0] else: src = self.__source.peek() return "Copy_{}_".format(os.path.basename(src)) def process(self, progress): if os.path.isabs(self.__destination()): full_destination = self.__destination() else: full_destination = os.path.join(self._context["build_path"], self.__destination()) for source in self.__source(): if not os.path.isabs(source): source = os.path.join(self._context["build_path"], source) if not os.path.exists(full_destination): os.makedirs(full_destination) if os.path.isfile(source): shutil.copy(source, full_destination) else: print "{} doesn't exist, Can't copy".format(source) return True
def __init__(self, source, destination): super(Copy, self).__init__() if isinstance(source, str): source = [source] self.__source = Lazy(source) self.__destination = Lazy(destination) self.__filename = ""
def __init__(self, command, fail_behaviour=Task.FailBehaviour.FAIL, environment=None, working_directory=None, name=None): super(Run_With_Output, self).__init__() self.__command = Lazy(command) self.__name = name self.__fail_behaviour = fail_behaviour self.__environment = Lazy(environment) self.__working_directory = Lazy(working_directory)
def __init__(self, make_tool=None, environment=None, working_directory=None): super(Make, self).__init__() self.__install = False self.__make_tool = Lazy(make_tool or config['tools']['make']) self.__environment = Lazy(environment) self.__working_directory = Lazy(working_directory)
def init_config(args): # some tools gets confused onto what constitutes . (OpenSSL and maybe CMake) args.destination = os.path.realpath(args.destination) for d in list(config['paths'].keys()): if isinstance(config['paths'][d], str): config['paths'][d] = config['paths'][d].format( base_dir=os.path.abspath(args.destination), build_dir=args.builddir, progress_dir=args.progressdir, install_dir=args.installdir) python = get_from_hklm( "HKEY_LOCAL_MACHINE", r"SOFTWARE\Python\PythonCore\{}\InstallPath".format( config['python_version']), "") if python is not None: config['paths']['python'] = Lazy( lambda: os.path.join(python, "python.exe")) else: config['paths']['python'] = Lazy(lambda: os.path.join( get_from_hklm( "HKEY_CURRENT_USER", r"SOFTWARE\Python\PythonCore\{}\InstallPath".format(config[ 'python_version']), ""), "python.exe")) # parse -s argument. Example -s paths.build=bin would set config[paths][build] to bin if args.set: for setting in args.set: key, value = setting.split('=', 2) path = key.split('.') cur = config for ele in path[:-1]: cur = cur.setdefault(ele, {}) cur[path[-1]] = value if config['architecture'] not in ['x86_64', 'x86']: raise ValueError("only architectures supported are x86 and x86_64") visual_studio(config["vc_version"]) # forced set after args are evaluated if config['prefer_binary_dependencies']: if os.environ.get('APPVEYOR') is not None: qt_install(config["qt_version_appveyor"], config["qt_version_minor_appveyor"], config["qt_vc_version"]) else: qt_install(config["qt_version"], config["qt_version_minor"], config["qt_vc_version"]) config['__Default_environment'] = os.environ config['__environment'] = visual_studio_environment() config['__build_base_path'] = os.path.abspath(args.destination) config['__Umbrella_path'] = os.getcwd() config['__Arguments'] = args if 'PYTHON' not in config['__environment']: config['__environment']['PYTHON'] = sys.executable
def __init__(self, command, fail_behaviour=Task.FailBehaviour.FAIL, environment=None, working_directory=None, name=None): super(Run, self).__init__() self.__command = Lazy(command) self.__name = name self.__fail_behaviour = fail_behaviour self.__environment = Lazy(environment) self.__working_directory = Lazy(working_directory)
def __init__(self, solution, project=None, working_directory=None, project_platform=None, reltarget=None, project_PlatformToolset=None, verbosity=None, environment=None): super(MSBuild, self).__init__() self.__solution = solution self.__project = project self.__working_directory = working_directory self.__project_platform = project_platform self.__reltarget = reltarget self.__project_platformtoolset = project_PlatformToolset self.__verbosity = verbosity self.__environment = Lazy(environment)
class Run(Builder): def __init__(self, command, fail_behaviour=Task.FailBehaviour.FAIL, environment=None, working_directory=None, name=None): super(Run, self).__init__() self.__command = Lazy(command) self.__name = name self.__fail_behaviour = fail_behaviour self.__environment = Lazy(environment) self.__working_directory = Lazy(working_directory) @property def name(self): if self.__name: return "run {}".format(self.__name) else: return "run {}".format(self.__command.peek().split()[0]).replace( "\\", "/") 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.name)) soutpath = os.path.join(self._context["build_path"], "stdout.log") serrpath = os.path.join(self._context["build_path"], "stderr.log") with open(soutpath, "w") as sout: with open(serrpath, "w") as serr: environment = dict(self.__environment() if self.__environment( ) is not None else config["__environment"]) cwd = str( self.__working_directory() if self.__working_directory( ) is not None else self._context["build_path"]) sout.write("running {} in {}".format(self.__command(), cwd)) proc = Popen(self.__command(), env=environment, cwd=cwd, shell=True, stdout=sout, stderr=serr) proc.communicate() if proc.returncode != 0: logging.error( "failed to run %s (returncode %s), see %s and %s", self.__command(), proc.returncode, soutpath, serrpath) return False return True
class Run(Builder): def __init__(self, command, fail_behaviour=Task.FailBehaviour.FAIL, environment=None, working_directory=None, name=None): super(Run, self).__init__() self.__command = Lazy(command) self.__name = name self.__fail_behaviour = fail_behaviour self.__environment = Lazy(environment) self.__working_directory = Lazy(working_directory) @property def name(self): if self.__name: return "run {}".format(self.__name) else: return "run {}".format(self.__command.peek().split()[0]).replace("\\", "/") 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.name)) soutpath = os.path.join(self._context["build_path"], "stdout.log") serrpath = os.path.join(self._context["build_path"], "stderr.log") with open(soutpath, "w") as sout: with open(serrpath, "w") as serr: environment = dict(self.__environment() if self.__environment() is not None else config["__environment"]) cwd = str(self.__working_directory() if self.__working_directory() is not None else self._context["build_path"]) sout.write("running {} in {}".format(self.__command(), cwd)) proc = Popen(self.__command(), env=environment, cwd=cwd, shell=True, stdout=sout, stderr=serr) proc.communicate() if proc.returncode != 0: logging.error("failed to run %s (returncode %s), see %s and %s", self.__command(), proc.returncode, soutpath, serrpath) return False return True
class Run_With_Output(Builder): def __init__(self, command, fail_behaviour=Task.FailBehaviour.FAIL, environment=None, working_directory=None, name=None): super(Run_With_Output, self).__init__() self.__command = Lazy(command) self.__name = name self.__fail_behaviour = fail_behaviour self.__environment = Lazy(environment) self.__working_directory = Lazy(working_directory) @property def name(self): if self.__name: return "run {}".format(self.__name) else: return "run {}".format(self.__command.peek().split()[0]).replace( "\\", "/") def process(self, progress): environment = dict(self.__environment() if self.__environment( ) is not None else config["__environment"]) cwd = str(self.__working_directory() if self.__working_directory( ) is not None else self._context["build_path"]) proc = Popen(self.__command(), env=environment, cwd=cwd, shell=True) proc.communicate() if proc.returncode != 0: if isinstance(proc.returncode, (str, unicode)): logging.error( "failed to run %s (returncode %s), see %s and %s", self.__command(), proc.returncode) return False else: logging.error("failed to run {} (returncode {})".format( self.__command(), proc.returncode)) return False return True
'install': "{base_dir}\\{install_dir}", # 'graphviz': path_or_default("dot.exe", "Graphviz2.38", "bin"), 'cmake': path_or_default("cmake.exe", "CMake", "bin"), 'git': path_or_default("git.exe", "Git", "bin"), #'perl': path_or_default("perl.exe", "StrawberryPerl", "bin"), #'ruby': path_or_default("ruby.exe", "Ruby22-x64", "bin"), #'svn': path_or_default("svn.exe", "SlikSvn", "bin"), '7z': path_or_default("7z.exe", "7-Zip"), # we need a python that matches the build architecture 'python': Lazy(lambda: os.path.join( get_from_hklm( r"SOFTWARE\Python\PythonCore\{}\InstallPath".format(config[ 'python_version']), "", config['architecture'] == "x86"), "python.exe")), 'visual_studio_base': "", 'qt_binary_install': "", 'visual_studio': "" # will be set in unimake.py after args are evaluated } if missing_prerequisites: print '\nMissing prerequisites listed above - cannot continue' exit(1)
path_or_default("dot.exe", "Graphviz2.38", "bin"), 'cmake': path_or_default("cmake.exe", "CMake", "bin"), 'git': path_or_default("git.exe", "Git", "bin"), 'perl': path_or_default("perl.exe", "StrawberryPerl", "bin"), 'ruby': path_or_default("ruby.exe", "Ruby22-x64", "bin"), 'svn': path_or_default("svn.exe", "SlikSvn", "bin"), '7z': path_or_default("7z.exe", "7-Zip"), # we need a python that matches the build architecture 'python': Lazy(lambda: os.path.join( get_from_hklm(r"SOFTWARE\Python\PythonCore\2.7\InstallPath", "", config['architecture'] == "x86"), "python.exe")), 'visual_studio': os.path.realpath( os.path.join( get_from_hklm( r"SOFTWARE\Microsoft\VisualStudio\{}".format( config['vc_version']), "InstallDir", True), "..", "..", "VC")) } if missing_prerequisites: print '\nMissing prerequisites listed above - cannot continue' exit(1)
def __init__(self, make_tool=None): super(Install, self).__init__() self.__make_tool = Lazy(make_tool or config['tools']['make'])
def __init__(self, filename, content): super(CreateFile, self).__init__() self.__filename = filename self.__content = Lazy(content)
def __init__(self, source, destination): super(Copy, self).__init__() if isinstance(source, str): source = [source] self.__source = Lazy(source) self.__destination = Lazy(destination)