def unpackFile(downloaddir, filename, workdir): """unpack file specified by 'filename' from 'downloaddir' into 'workdir'""" CraftCore.log.debug(f"unpacking this file: {filename}") if not filename: return True (shortname, ext) = os.path.splitext(filename) if ext == "": CraftCore.log.warning( f"unpackFile called on invalid file extension {filename}") return True if OsUtils.isWin() and not OsUtils.supportsSymlinks(): CraftCore.log.warning( "Please enable Windows 10 development mode to enable support for symlinks.\n" "This will enable faster extractions.\n" "https://docs.microsoft.com/en-us/windows/uwp/get-started/enable-your-device-for-development" ) if CraftCore.cache.findApplication("7za"): # we use tar on linux not 7z, don't use tar on windows as it skips symlinks # test it with breeze-icons if (not OsUtils.isWin() or (OsUtils.supportsSymlinks() and CraftCore.cache.getVersion( "7za", versionCommand="-version") >= "16") or not re.match("(.*\.tar.*$|.*\.tgz$)", filename)): return un7zip(os.path.join(downloaddir, filename), workdir, ext) try: shutil.unpack_archive(os.path.join(downloaddir, filename), workdir) except Exception as e: CraftCore.log.error(f"Failed to unpack {filename}", exc_info=e) return False return True
def install(self): ret = CMakePackageBase.install(self) if OsUtils.isWin(): # Make installation movable, by providing rkward.ini with relative path to R rkward_ini = open( os.path.join(self.imageDir(), "bin", "rkward.ini"), "w") if CraftCore.compiler.isX64(): rkward_ini.write("R executable=../lib/R/bin/x64/R.exe\n") else: rkward_ini.write("R executable=../lib/R/bin/i386/R.exe\n") rkward_ini.close() elif OsUtils.isMac(): # Fix absolute library locations for R libs. Users may use RKWard with various versions of R (installed, separately), so # we cannot set a stable relative path, either. However, the rkward frontend makes sure to cd to the appropriate directory # when starting the backend, so the libs can be found by basename. rkward_rbackend = os.path.join(self.imageDir(), "lib", "libexec", "rkward.rbackend") for path in utils.getLibraryDeps(str(rkward_rbackend)): if path.startswith("/Library/Frameworks/R.framework"): utils.system([ "install_name_tool", "-change", path, os.path.join("@rpath", os.path.basename(path)), rkward_rbackend ]) # Finally tell the loader to look in the current working directory (as set by the frontend) utils.system( ["install_name_tool", "-add_rpath", ".", rkward_rbackend]) return ret
def configureOptions(self, defines=""): """returns default configure options""" options = BuildSystemBase.configureOptions(self) if OsUtils.isWin(): options += " -j" + os.getenv("NUMBER_OF_PROCESSORS") options += " --build-dir=" + self.buildDir() else: # TODO: real value options += " install --prefix=%s" % self.buildDir() options += " -j10" options += ( " --build-type=minimal" # " --debug-configuration" " threading=multi") if not self.subinfo.options.buildStatic: options += (" link=shared" " runtime-link=shared") else: options += (" link=static" " runtime-link=shared") if CraftCore.compiler.isX64(): options += " address-model=64 architecture=x86" else: options += " address-model=32 architecture=x86" if self.buildType() == "Debug": options += " variant=debug" else: options += " variant=release" options += " toolset=" if CraftCore.compiler.isClang(): options += "clang" if CraftCore.compiler.isGCC(): options += " threadapi=pthread" elif CraftCore.compiler.isMinGW(): options += "gcc" elif CraftCore.compiler.isMSVC(): platform = str(CraftCore.compiler.getMsvcPlatformToolset()) if CraftVersion(self.buildTarget) < CraftVersion( "1_65_1") and CraftCore.compiler.isMSVC2017(): options += f"msvc-{platform[:2]}.0" else: options += f"msvc-{platform[:2]}.{platform[2:]}" elif CraftCore.compiler.isIntel(): options += "intel" options += " -sINTEL_PATH=\"%s\"" % os.path.join( os.getenv("INTELDIR"), "bin", os.getenv("TARGET_ARCH")) options += " -sINTEL_BASE_MSVC_TOOLSET=vc-%s" % ({ "vs2008": "9_0", "vs2010": "10_0", "vs2012": "11_0" }[os.getenv("INTEL_VSSHELL")]) options += " -sINTEL_VERSION=%s" % os.getenv("PRODUCT_NAME")[-2:] craftUserConfig = os.path.join(CraftStandardDirs.craftRoot(), "etc", "craft-boost-config.jam") if os.path.exists(craftUserConfig): options += " --user-config=" + os.path.join(craftUserConfig) return options
def createPackage(self): """create 7z package with digest files located in the manifest subdir""" cacheMode = CraftCore.settings.getboolean("Packager", "CreateCache", False) if cacheMode: if self.subinfo.options.package.disableBinaryCache: return True dstpath = self.cacheLocation() else: dstpath = self.packageDestinationDir() extention = CraftCore.settings.get( "Packager", "7ZipArchiveType", "7z" if OsUtils.isWin() else "tar.xz") self._compress( self.binaryArchiveName(fileType=extention, includePackagePath=cacheMode, includeTimeStamp=cacheMode), self.imageDir(), dstpath) if not self.subinfo.options.package.packSources: return True if CraftCore.settings.getboolean("Packager", "PackageSrc", "True"): self._compress( self.binaryArchiveName("-src", fileType=extention, includePackagePath=cacheMode, includeTimeStamp=cacheMode), self.sourceDir(), dstpath) return True
def un7zip(fileName, destdir, flag=None): kw = {} progressFlags = [] type = [] resolveSymlinks = False app = utilsCache.findApplication("7za") if utilsCache.checkCommandOutputFor(app, "-bs"): progressFlags = ["-bso2", "-bsp1"] kw["stderr"] = subprocess.PIPE if flag == ".7z": # Actually this is not needed for a normal archive. # But git is an exe file renamed to 7z and we need to specify the type. # Yes it is an ugly hack. type = ["-t7z"] if re.match("(.*\.tar.*$|.*\.tgz$)", fileName): type = ["-ttar"] kw["pipeProcess"] = subprocess.Popen([app, "x", fileName, "-so"], stdout=subprocess.PIPE) if OsUtils.isWin(): resolveSymlinks = True command = [app, "x", "-si", f"-o{destdir}"] + type + progressFlags else: tar = utilsCache.findApplication("tar") command = [tar, "--directory", destdir, "-xvf", "-"] kw = {} else: command = [app, "x", "-r", "-y", f"-o{destdir}", fileName ] + type + progressFlags # While 7zip supports symlinks cmake 3.8.0 does not support symlinks return system( command, displayProgress=True, ** kw) and not resolveSymlinks or replaceSymlinksWithCopys(destdir)
def createShim(shim, target, args=None, guiApp=False, useAbsolutePath=False) -> bool: if not useAbsolutePath and os.path.isabs(target): target = os.path.relpath(target, os.path.dirname(shim)) createDir(os.path.dirname(shim)) if not OsUtils.isWin(): command = (f"#!/bin/bash\n" "parent_path=$(dirname \"${BASH_SOURCE[0]}\")\n" f"${{parent_path}}/{target} {args or ''} \"$@\"\n") CraftCore.log.info(f"Creating {shim}") CraftCore.log.debug(command) with open(shim, "wt+") as bash: bash.write(command) os.chmod( shim, os.stat(shim).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) return True else: app = CraftCore.cache.findApplication("shimgen") if not app: CraftCore.log.error( f"Failed to detect shimgen, please install dev-util/shimgen") return False command = [app, "--output", shim, "--path", target] if args: command += ["--command", args] if guiApp: command += ["--gui"] return system(command, stdout=subprocess.DEVNULL)
def install(self): # create post (un)install scripts if OsUtils.isWin(): scriptExt = ".cmd" elif OsUtils.isUnix(): scriptExt = ".sh" for pkgtype in ['bin', 'lib', 'doc', 'src', 'dbg']: script = os.path.join(self.packageDir(), "post-install-%s.%s") % (pkgtype, scriptExt) scriptName = "post-install-%s-%s.%s" % (self.package, pkgtype, scriptExt) # are there any cases there installDir should be honored ? destscript = os.path.join(self.imageDir(), "manifest", scriptName) if not os.path.exists(os.path.join(self.imageDir(), "manifest")): utils.createDir(os.path.join(self.imageDir(), "manifest")) if os.path.exists(script): utils.copyFile(script, destscript) script = os.path.join( self.packageDir(), "post-uninstall-%s.%s") % (pkgtype, scriptExt) scriptName = "post-uninstall-%s-%s.%s" % (self.package, pkgtype, scriptExt) # are there any cases there installDir should be honored ? destscript = os.path.join(self.imageDir(), "manifest", scriptName) if not os.path.exists(os.path.join(self.imageDir(), "manifest")): utils.createDir(os.path.join(self.imageDir(), "manifest")) if os.path.exists(script): utils.copyFile(script, destscript) return True
def unpackFile(downloaddir, filename, workdir): """unpack file specified by 'filename' from 'downloaddir' into 'workdir'""" CraftCore.log.debug(f"unpacking this file: {filename}") if not filename: return True (shortname, ext) = os.path.splitext(filename) if ext == "": CraftCore.log.warning( f"unpackFile called on invalid file extension {filename}") return True sevenZVersion = CraftCore.cache.getVersion("7za", versionCommand="-version") if sevenZVersion and sevenZVersion >= "16" and ( not OsUtils.isWin() or OsUtils.supportsSymlinks() or not re.match("(.*\.tar.*$|.*\.tgz$)", filename)): return un7zip(os.path.join(downloaddir, filename), workdir, ext) else: try: shutil.unpack_archive(os.path.join(downloaddir, filename), workdir) except Exception as e: CraftCore.log.error(f"Failed to unpack {filename}", exc_info=e) return False return True
def createShim(shim, target, args=None, guiApp=False, useAbsolutePath=False) -> bool: if not OsUtils.isWin(): return True app = CraftCore.cache.findApplication("shimgen") if not app: CraftCore.log.error( f"Failed to detect shimgen, please install dev-util/shimgen") return False if not useAbsolutePath and os.path.isabs(target): srcPath = shim if srcPath.endswith(".exe"): srcPath = os.path.dirname(srcPath) target = os.path.relpath(target, srcPath) if not os.path.exists(os.path.dirname(shim)): os.makedirs(os.path.dirname(shim)) command = [app, "--output", shim, "--path", target] if args: command += ["--command", args] if guiApp: command += ["--gui"] return system(command, stdout=subprocess.DEVNULL)
def subst(self): if not OsUtils.isWin(): return def _subst(path, drive): if not os.path.exists(path): os.makedirs(path) SetupHelper._getOutput( ["subst", CraftCore.settings.get("ShortPath", drive), path]) if CraftCore.settings.getboolean("ShortPath", "Enabled", False): with TemporaryUseShortpath(False): if ("ShortPath", "RootDrive") in CraftCore.settings: _subst(CraftStandardDirs.craftRoot(), "RootDrive") if ("ShortPath", "DownloadDrive") in CraftCore.settings: _subst(CraftStandardDirs.downloadDir(), "DownloadDrive") if ("ShortPath", "GitDrive") in CraftCore.settings: _subst(CraftStandardDirs.gitDir(), "GitDrive") if CraftCore.settings.getboolean("ShortPath", "EnableJunctions", False): with TemporaryUseShortpath(False): if ("ShortPath", "JunctionDrive") in CraftCore.settings: _subst(CraftCore.standardDirs._junctionDir.longPath, "JunctionDrive")
def findApplication(self, app, path=None, forceCache: bool = False) -> str: if app in self._nonPersistentCache.applicationLocations: appLocation = self._nonPersistentCache.applicationLocations[app] if os.path.exists(appLocation): return appLocation else: self._helpCache.clear() # don't look in the build dir etc _cwd = os.getcwd() os.chdir(CraftCore.standardDirs.craftRoot()) appLocation = shutil.which(app, path=path) os.chdir(_cwd) if appLocation: if OsUtils.isWin(): # prettify command path, ext = os.path.splitext(appLocation) appLocation = path + ext.lower() if forceCache or Path(CraftCore.standardDirs.craftRoot()) in Path( appLocation).parents: CraftCore.log.debug(f"Adding {app} to app cache {appLocation}") self._nonPersistentCache.applicationLocations[ app] = appLocation else: CraftCore.log.debug( f"Craft was unable to locate: {app}, in {path}") return None return appLocation
def notify(self, title, message, alertClass): try: snore = CraftCore.cache.findApplication("snoresend") if not snore: return command = [ snore, "-t", title, "-m", message, "-i", self.icon, "-a", "Craft", "--silent" ] if alertClass: command += ["-c", alertClass] if OsUtils.isWin(): command += [ "--bring-window-to-front", str(ctypes.windll.kernel32.GetConsoleWindow()) ] CraftCore.log.debug(command) subprocess.Popen( command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, cwd=CraftCore.standardDirs.craftRoot( )) # make sure that nothing is spawned in a build dir except Exception as e: CraftCore.log.debug(e) return
def setXDG(self): if OsUtils.isWin(): self.prependEnvVar( "XDG_DATA_DIRS", [os.path.join(CraftCore.standardDirs.craftRoot(), "bin/data")]) else: self.prependEnvVar( "XDG_DATA_DIRS", [os.path.join(CraftCore.standardDirs.craftRoot(), "share")]) user = os.getenv("USER", self._getOutput(["id", "-u", "-n"])[1]) self.prependEnvVar("XDG_CONFIG_DIRS", [ os.path.join(CraftCore.standardDirs.craftRoot(), "etc", "xdg") ]) self.addEnvVar( "XDG_DATA_HOME", os.path.join(CraftCore.standardDirs.craftRoot(), "home", user, ".local5", "share")) self.addEnvVar( "XDG_CONFIG_HOME", os.path.join(CraftCore.standardDirs.craftRoot(), "home", user, ".config")) self.addEnvVar( "XDG_CACHE_HOME", os.path.join(CraftCore.standardDirs.craftRoot(), "home", user, ".cache"))
def makeProgram(self) -> str: if self.subinfo.options.make.supportsMultijob: if self.supportsNinja and CraftCore.settings.getboolean( "Compile", "UseNinja", False) and CraftCore.cache.findApplication("ninja"): return "ninja" if ("Compile", "MakeProgram") in CraftCore.settings: makeProgram = CraftCore.settings.get("Compile", "MakeProgram") CraftCore.log.debug(f"set custom make program: {makeProgram}") makeProgram = CraftCore.cache.findApplication(makeProgram) if makeProgram: return makeProgram else: CraftCore.log.warning( f"Failed to find {CraftCore.settings.get('Compile', 'MakeProgram')}" ) elif not self.subinfo.options.make.supportsMultijob: if "MAKE" in os.environ: del os.environ["MAKE"] if OsUtils.isWin(): if CraftCore.compiler.isMSVC() or CraftCore.compiler.isIntel(): return "nmake" elif CraftCore.compiler.isMinGW(): return "mingw32-make" else: CraftCore.log.critical( f"unknown {CraftCore.compiler} compiler") elif OsUtils.isUnix(): return "make"
class CraftShortPath(object): _useShortpaths = OsUtils.isWin() _shortPaths = {} def __init__(self, path, createShortPath=None) -> None: self._longPath = path self._shortPath = None if not createShortPath: self._createShortPathLambda = CraftShortPath._createShortPath else: self._createShortPathLambda = createShortPath def path(self, condition): return self.shortPath if condition else self.longPath @property def longPath(self) -> str: return self._longPath() if callable(self._longPath) else self._longPath @property def shortPath(self) -> str: if self._shortPath: return self._shortPath self._shortPath = CraftShortPath._shortPaths.get(self.longPath, None) if not self._shortPath: self._shortPath = self._createShortPathLambda(self.longPath) CraftShortPath._shortPaths[self.longPath] = self._shortPath if self._shortPath != self.longPath: os.makedirs(self.longPath, exist_ok=True) CraftCore.debug.log.debug(f"Mapped \n" f"{self.longPath} to\n" f"{self._shortPath}, gained {len(self.longPath) - len(self._shortPath)}") return self._shortPath @staticmethod def _createShortPath(longPath) -> str: import utils longPath = OsUtils.toNativePath(longPath) if not CraftShortPath._useShortpaths: return longPath if not os.path.isdir(CraftCore.standardDirs.junctionsDir()): os.makedirs(CraftCore.standardDirs.junctionsDir()) path = OsUtils.toNativePath(os.path.join(CraftCore.standardDirs.junctionsDir(), hex(zlib.crc32(bytes(longPath, "UTF-8")))[2:])) if len(longPath) < len(path): CraftCore.debug.log.debug(f"Using junctions for {longPath} wouldn't save characters returning original path") CraftCore.debug.log.debug(f"{longPath}\n" f"{path}, gain:{len(longPath) - len(path)}") return longPath os.makedirs(longPath, exist_ok=True) if not os.path.isdir(path): # note: mklink is a CMD command => needs shell if not utils.system(["mklink", "/J", path, longPath], shell=True, stdout=subprocess.DEVNULL, logCommand=False): CraftCore.debug.log.critical(f"Could not create shortpath {path}, for {longPath}") return longPath else: if not os.path.samefile(path, longPath): CraftCore.debug.log.critical(f"Existing short path {path}, did not match {longPath}") return longPath return path
def _findBash(self): if OsUtils.isWin(): msysdir = CraftCore.standardDirs.msysDir() bash = CraftCore.cache.findApplication("bash", os.path.join(msysdir, "usr", "bin")) else: bash = CraftCore.cache.findApplication("bash") if not bash: CraftCore.log.critical("Failed to detect bash") return bash
def configureOptions(self, defines=""): """returns default configure options""" options = BuildSystemBase.configureOptions(self) ## \todo why is it required to replace \\ by / ? options += " -DCMAKE_INSTALL_PREFIX=\"%s\"" % self.mergeDestinationDir( ).replace("\\", "/") options += " -DCMAKE_PREFIX_PATH=\"%s\"" % \ self.mergeDestinationDir().replace("\\", "/") if (not self.buildType() == None): options += " -DCMAKE_BUILD_TYPE=%s" % self.buildType() if craftCompiler.isGCC() and not craftCompiler.isNative(): options += " -DCMAKE_TOOLCHAIN_FILE=%s" % os.path.join( CraftStandardDirs.craftRoot(), "craft", "bin", "toolchains", "Toolchain-cross-mingw32-linux-%s.cmake" % craftCompiler.architecture) if craftSettings.getboolean("CMake", "KDE_L10N_AUTO_TRANSLATIONS", False): options += " -DKDE_L10N_AUTO_TRANSLATIONS=ON" if OsUtils.isWin(): options += " -DKDE_INSTALL_USE_QT_SYS_PATHS=ON" if OsUtils.isMac(): options += " -DKDE_INSTALL_BUNDLEDIR=\"%s/Applications/KDE\" -DAPPLE_SUPPRESS_X11_WARNING=ON" % \ self.mergeDestinationDir().replace("\\", "/") if not self.buildTests: options += " -DBUILD_TESTING=OFF " if self.subinfo.options.buildTools: options += " " + self.subinfo.options.configure.toolsDefine + " " if self.subinfo.options.buildStatic and self.subinfo.options.configure.staticArgs: options += " " + self.subinfo.options.configure.staticArgs + " " if self.subinfo.options.configure.onlyBuildTargets: options += self.__onlyBuildDefines( self.subinfo.options.configure.onlyBuildTargets) if self.subinfo.options.cmake.useCTest: options += " -DCMAKE_PROGRAM_PATH=\"%s\" " % \ (os.path.join(self.mergeDestinationDir(), "dev-utils", "svn", "bin").replace("\\", "/")) if craftCompiler.isIntel(): # this is needed because otherwise it'll detect the MSVC environment options += " -DCMAKE_CXX_COMPILER=\"%s\" " % os.path.join( os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"), "icl.exe").replace("\\", "/") options += " -DCMAKE_C_COMPILER=\"%s\" " % os.path.join( os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"), "icl.exe").replace("\\", "/") options += " -DCMAKE_LINKER=\"%s\" " % os.path.join( os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"), "xilink.exe").replace("\\", "/") options += " \"%s\"" % self.configureSourceDir() return options
def __init__(self): SevenZipPackager.__init__(self) self.__resources = os.path.join(os.path.dirname(__file__), "QtIF") self.__packageDir = os.path.join(self.packageDestinationDir(), "qtif") self.__sdkMode = OsUtils.isWin() and CraftCore.settings.getboolean( "QtSDK", "Enabled", False) if self.__sdkMode: win = "win32" if CraftCore.compiler.isX86() else "win64" self.__depPrefix = f"qt.qt5.{CraftCore.settings.get('QtSDK', 'Version').replace('.', '')}.{win}_{CraftCore.settings.get('QtSDK', 'Compiler')}.kde"
def configureOptions(self, defines=""): """returns default configure options""" options = BuildSystemBase.configureOptions(self) prefix = self.shell.toNativePath(self.installPrefix()) options += [f"--prefix={prefix}"] if OsUtils.isWin() and not self.subinfo.options.configure.noDataRootDir: options += [f"--datarootdir={self.shell.toNativePath(CraftCore.standardDirs.locations.data)}"] options += self.platform return options
def install(self): if OsUtils.isWin(): utils.createShim(os.path.join(self.imageDir(), "bin", "doxyqml.exe"), os.path.join(self.imageDir(), "dev-utils", "bin", "python2.exe"), args=os.path.join( CraftCore.settings.get("Paths", "PYTHON27"), "Scripts", "doxyqml")) return PipBuildSystem.install(self)
def install(self): ret = CMakePackageBase.install(self) if OsUtils.isWin(): # Make installation movable, by providing rkward.ini with relative path to R rkward_ini = open(os.path.join(self.imageDir(), "bin", "rkward.ini"), "w") if CraftCore.compiler.isX64(): rkward_ini.write("R executable=../lib/R/bin/x64/R.exe\n") else: rkward_ini.write("R executable=../lib/R/bin/i386/R.exe\n") rkward_ini.close() return ret
def configureOptions(self, defines=""): """returns default configure options""" options = "-DBUILD_TESTING={testing} ".format( testing="ON" if self.buildTests else "OFF") options += BuildSystemBase.configureOptions(self) craftRoot = OsUtils.toUnixPath(CraftCore.standardDirs.craftRoot()) options += f" -DCMAKE_INSTALL_PREFIX=\"{craftRoot}\"" options += f" -DCMAKE_PREFIX_PATH=\"{craftRoot}\"" if (not self.buildType() == None): options += " -DCMAKE_BUILD_TYPE=%s" % self.buildType() if CraftCore.compiler.isGCC() and not CraftCore.compiler.isNative(): options += " -DCMAKE_TOOLCHAIN_FILE=%s" % os.path.join( CraftStandardDirs.craftRoot(), "craft", "bin", "toolchains", "Toolchain-cross-mingw32-linux-%s.cmake" % CraftCore.compiler.architecture) if CraftCore.settings.getboolean("CMake", "KDE_L10N_AUTO_TRANSLATIONS", False): options += " -DKDE_L10N_AUTO_TRANSLATIONS=ON" if OsUtils.isWin(): # people use InstallRequiredSystemLibraries.cmake wrong and unconditionally install the # msvc crt... options += " -DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=ON" if OsUtils.isMac(): options += f" -DKDE_INSTALL_BUNDLEDIR=\"{OsUtils.toUnixPath(CraftCore.standardDirs.craftRoot())}/Applications/KDE\" -DAPPLE_SUPPRESS_X11_WARNING=ON" if CraftCore.compiler.macUseSDK: # Ensure that we don't depend on SDK features only present on newer systems options += " -DCMAKE_OSX_DEPLOYMENT_TARGET=" + CraftCore.compiler.macOSDeploymentTarget if CraftCore.compiler.isWindows or CraftCore.compiler.isMacOS: options += " -DKDE_INSTALL_USE_QT_SYS_PATHS=ON" if self.subinfo.options.buildTools: options += " " + self.subinfo.options.configure.toolsDefine + " " if self.subinfo.options.buildStatic and self.subinfo.options.configure.staticArgs: options += " " + self.subinfo.options.configure.staticArgs + " " if CraftCore.compiler.isIntel(): # this is needed because otherwise it'll detect the MSVC environment options += " -DCMAKE_CXX_COMPILER=\"%s\" " % os.path.join( os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"), "icl.exe").replace("\\", "/") options += " -DCMAKE_C_COMPILER=\"%s\" " % os.path.join( os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"), "icl.exe").replace("\\", "/") options += " -DCMAKE_LINKER=\"%s\" " % os.path.join( os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"), "xilink.exe").replace("\\", "/") options += " \"%s\"" % self.configureSourceDir() return options
def install(self): if not CMakePackageBase.install(self): return False if OsUtils.isWin(): os.makedirs(os.path.join(self.installDir(), "bin")) shutil.move(os.path.join(self.installDir(), "quassel.exe"), os.path.join(self.installDir(), "bin", "quassel.exe")) shutil.move(os.path.join(self.installDir(), "quasselcore.exe"), os.path.join(self.installDir(), "bin", "quasselcore.exe")) shutil.move(os.path.join(self.installDir(), "quasselclient.exe"), os.path.join(self.installDir(), "bin", "quasselclient.exe")) return True
def copyToMsvcImportLib(self): if not OsUtils.isWin(): return True reDlla = re.compile(r"\.dll\.a$") reLib = re.compile(r"^lib") for f in glob.glob(f"{self.installDir()}/lib/*.dll.a"): path, name = os.path.split(f) name = re.sub(reDlla, ".lib", name) name = re.sub(reLib, "", name) if not utils.copyFile(f, os.path.join(path, name), linkOnly=False): return False return True
def __init__(self): CMakePackageBase.__init__(self) if OsUtils.isWin(): if CraftCore.compiler.isX64(): self.r_dir = os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "bin", "x64") else: self.r_dir = os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "bin", "i386") self.subinfo.options.configure.args = " -DR_EXECUTABLE=" + OsUtils.toUnixPath(os.path.join(self.r_dir, "R.exe")) elif OsUtils.isMac(): rhome = os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "R.framework", "Resources") self.subinfo.options.configure.args = " -DR_EXECUTABLE=" + os.path.join(rhome, "R") + " -DNO_CHECK_R=1 -DR_HOME=" + rhome + " -DR_INCLUDEDIR=" + os.path.join(rhome, "include") + " -DR_SHAREDLIBDIR=" + os.path.join(rhome, "lib")
def updateSharedMimeInfo(package) -> bool: if OsUtils.isWin(): dataDir = os.path.join("bin", "data", "mime") else: dataDir = os.path.join("share", "mime") # only check in imageDir, if installDir differs from imageDir it is irrelevant for us if not os.path.isdir(os.path.join(package.imageDir(), dataDir)): return True dataDir = os.path.join(CraftCore.standardDirs.craftRoot(), dataDir) flags = [] if CraftCore.debug.verbose() > 0: flags += ["-V"] return utils.system(["update-mime-database"] + flags + [dataDir])
def __makeFileGenerator(self): """return cmake related make file generator""" if self.makeProgram == "ninja": return "Ninja" if OsUtils.isWin(): if CraftCore.compiler.isMSVC() and not CraftCore.compiler.isIntel(): return "NMake Makefiles" if CraftCore.compiler.isMinGW(): return "MinGW Makefiles" elif OsUtils.isUnix(): return "Unix Makefiles" else: CraftCore.log.critical(f"unknown {CraftCore.compiler} compiler")
def setDependencies(self): self.buildDependencies["kde/frameworks/extra-cmake-modules"] = None self.buildDependencies["dev-utils/python2"] = None self.runtimeDependencies["libs/qt5/qtwebkit"] = None self.runtimeDependencies["virtual/base"] = None self.runtimeDependencies["kde/frameworks/tier1/kcoreaddons"] = None self.runtimeDependencies["kde/frameworks/tier1/kconfig"] = None self.runtimeDependencies["kde/frameworks/tier1/kwidgetsaddons"] = None self.runtimeDependencies["kde/frameworks/tier1/kguiaddons"] = None self.runtimeDependencies["kde/frameworks/tier1/breeze-icons"] = None # hard dependency for now self.runtimeDependencies["extragear/kproperty"] = None # TODO Windows/Mac: add marble libs (we only need marble widget), for now marble libs are disabled there if not OsUtils.isWin() and not OsUtils.isMac(): self.runtimeDependencies["kde/applications/marble"] = None
def __init__(self): CMakePackageBase.__init__(self) self.translations = CraftPackageObject.get("extragear/rkward/rkward-translations").instance if OsUtils.isWin(): if CraftCore.compiler.isX64(): self.r_dir = os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "bin", "x64") else: self.r_dir = os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "bin", "i386") self.subinfo.options.configure.args = " -DR_EXECUTABLE=" + OsUtils.toUnixPath(os.path.join(self.r_dir, "R.exe")) elif OsUtils.isMac(): self.subinfo.options.configure.args = " -DR_EXECUTABLE=" + os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "R.framework", "Resources", "R") if self.subinfo.hasSvnTarget: self.subinfo.options.configure.args += f" -DTRANSLATION_SRC_DIR={OsUtils.toUnixPath(self.translations.sourceDir())}"
def un7zip(fileName, destdir, flag=None): ciMode = CraftCore.settings.getboolean("ContinuousIntegration", "Enabled", False) createDir(destdir) kw = {} progressFlags = [] type = [] app = CraftCore.cache.findApplication("7za") if not ciMode and CraftCore.cache.checkCommandOutputFor(app, "-bs"): progressFlags = ["-bso2", "-bsp1"] kw["stderr"] = subprocess.PIPE if flag == ".7z": # Actually this is not needed for a normal archive. # But git is an exe file renamed to 7z and we need to specify the type. # Yes it is an ugly hack. type = ["-t7z"] if re.match("(.*\.tar.*$|.*\.tgz$)", fileName): if progressFlags: if ciMode: progressFlags = [] else: # print progress to stderr progressFlags = ["-bsp2"] kw["pipeProcess"] = subprocess.Popen([app, "x", fileName, "-so"] + progressFlags, stdout=subprocess.PIPE) if OsUtils.isWin(): if progressFlags: progressFlags = ["-bsp0"] command = [ sys.executable, "-u", Path(__file__).parent / "untar.py", destdir ] # we don't have progress, diesplay error messages if "stderr" in kw: del kw["stderr"] kw["stdout"] = subprocess.DEVNULL else: tar = CraftCore.cache.findApplication("tar") command = [tar, "--directory", destdir, "-xf", "-"] else: command = [app, "x", "-r", "-y", f"-o{destdir}", fileName ] + type + progressFlags # While 7zip supports symlinks cmake 3.8.0 does not support symlinks return system(command, **kw)