diff --git a/bin/base.py b/bin/base.py deleted file mode 100644 index 8b6f03c0b..000000000 --- a/bin/base.py +++ /dev/null @@ -1,597 +0,0 @@ -# -*- coding: utf-8 -*- -# this package contains the base class for all packages - -# copyright: -# Holger Schroeder -# Patrick Spendrin - -# pylint: disable=R0201,W0511 -# we want no warnings here, this is deprecated anyway - -import sys -import os - -import shutil - -# for get functions etc... -import utils -# for info header class -import info -# for the msys interface -import msys_build -# for the kde interface -import kde_build -#from utils import die -import datetime - -# portage tree related -import portage -import compiler - -ROOTDIR = os.getenv( "KDEROOT" ) -COMPILER = os.getenv( "KDECOMPILER" ) -DOWNLOADDIR = os.getenv( "DOWNLOADDIR" ) -if ( DOWNLOADDIR == None ): - DOWNLOADDIR = os.path.join( ROOTDIR, "distfiles" ) - -KDESVNDIR = os.getenv( "KDESVNDIR" ) -if ( KDESVNDIR == None ): - KDESVNDIR = os.path.join( DOWNLOADDIR, "svn-src", "kde" ) -KDESVNSERVER = os.getenv( "KDESVNSERVER" ) -if ( KDESVNSERVER == None ): - KDESVNSERVER = "svn://anonsvn.kde.org" -KDESVNUSERNAME = os.getenv( "KDESVNUSERNAME" ) -KDESVNPASSWORD = os.getenv( "KDESVNPASSWORD" ) - -EMERGE_MAKE_PROGRAM = os.getenv( "EMERGE_MAKE_PROGRAM" ) - -# ok, we have the following dirs: -# ROOTDIR: the root where all this is below -# DOWNLOADDIR: the dir under rootdir, where the downloaded files are put into -# WORKDIR: the directory, under which the files are unpacked and compiled. -# here rootdir/tmp/packagename/work -# IMAGEDIR: the directory, under which the compiled files are installed. -# here rootdir/tmp/packagename/image - - - -class baseclass: - """ - According to Patrick Spendrin: - this is deprecated code, it should be updated as soon as anyone - touches it (baseclass should become one of BinaryPackageBase, - CMakePackageBase etc.) - - methods of baseclass: - __init__ the baseclass constructor - execute called to run the derived class - fetch getting the package - unpack unpacking the source package - configure configure the package - make make the package - compile compiling (configure + make) the package - install installing the files into the normal - qmerge mergeing the local directory to the kderoot - unmerge unmergeing the local directory again - manifest getting the headers - make_package overload this function to make the packages themselves - setDirectories - svnFetch getting sources from a custom repo url - doPackaging - createImportLibs creating import libs for mingw and msvc - stripLibs stripping libs - system instead of using the os.system command, please use this one - it makes later changes easier - """ - - def __init__( self, SRC_URI="", **args ): - """ the baseclass constructor - args really should be documented""" - if "args" in list(args.keys()) and "argv0" in list(args["args"].keys()): - self.argv0 = args["args"]["argv0"] - else: - self.argv0 = sys.argv[ 0 ] - - self.SRC_URI = SRC_URI - self.instsrcdir = "" - self.instdestdir = "" - self.versioned = False - self.kdeCustomDefines = "" - self.createCombinedPackage = False - self._filenames = [] # will be set by self.execute() - - self.subinfo = info.infoclass() - self.buildTarget = self.subinfo.defaultTarget - self.Targets = self.subinfo.svnTargets - - self.isoDateToday = str( datetime.date.today() ).replace('-', '') - - self.msys = msys_build.msys_interface() - self.kde = kde_build.kde_interface() - - self.noFetch = utils.envAsBool( "EMERGE_OFFLINE" ) - self.noCopy = utils.envAsBool( "EMERGE_NOCOPY") - self.noFast = utils.envAsBool( "EMERGE_NOFAST", default=True ) - self.noClean = utils.envAsBool( "EMERGE_NOCLEAN" ) - self.forced = utils.envAsBool( "EMERGE_FORCED" ) - self.buildTests = utils.envAsBool( "EMERGE_BUILDTESTS" ) - - # Build type for kdeCompile() / kdeInstall() - packages - # "" -> debug and release - Type = os.getenv( "EMERGE_BUILDTYPE" ) - if ( not Type == None ): - utils.debug( "BuildType: %s" % Type, 1 ) - self.buildType = Type - else: - self.buildType = None - - self.setDirectories() - - if COMPILER == "msvc2005": - self.compiler = "msvc2005" - elif COMPILER == "msvc2008": - self.compiler = "msvc2008" - elif COMPILER == "msvc2010": - self.compiler = "msvc2010" - elif COMPILER == "msvc2011": - self.compiler = "msvc2011" - elif COMPILER == "mingw": - self.compiler = "mingw" - elif COMPILER == "mingw4": - self.compiler = "mingw4" - else: - print("emerge error: KDECOMPILER: %s not understood" % COMPILER, file=sys.stderr) - exit( 1 ) - - def execute( self, cmd=None ): - """called to run the derived class - this will be executed from the package if the package is started on its own - it shouldn't be called if the package is imported as a python module""" - utils.debug( "base exec called. args: %s" % sys.argv ) - - if not cmd: - command = sys.argv[ 1 ] - else: - command = cmd - - utils.debug( "command: %s" % command ) - - self.Targets.update( self.subinfo.svnTargets ) - self.Targets.update( self.subinfo.targets ) - - self.subinfo.buildTarget = self.subinfo.defaultTarget - self.buildTarget = self.subinfo.defaultTarget - - if os.getenv( "EMERGE_TARGET" ) in list(self.Targets.keys()): - self.subinfo.buildTarget = os.getenv( "EMERGE_TARGET" ) - self.buildTarget = os.getenv( "EMERGE_TARGET" ) - - if self.subinfo.buildTarget in list(self.subinfo.targets.keys()) and self.subinfo.buildTarget in list(self.subinfo.targetInstSrc.keys()): - self.instsrcdir = self.subinfo.targetInstSrc[ self.subinfo.buildTarget ] - - self.msys.setDirectories( self.rootdir, self.imagedir, self.workdir, self.instsrcdir, self.instdestdir ) - self.kde.setDirectories( self.rootdir, self.imagedir, self.workdir, self.instsrcdir, self.instdestdir, self.subinfo ) - - if self.subinfo.buildTarget in list(self.subinfo.targets.keys()) and not self.kdeSvnPath(): - filenames = [] - for uri in self.subinfo.targets[ self.subinfo.buildTarget ].split(): - filenames.append( os.path.basename( uri ) ) - self._filenames = filenames - functions = {"fetch": self.fetch, - "cleanimage": self.cleanup, - "unpack": self.unpack, - "compile": self.compile, - "configure": self.configure, - "make": self.make, - "install": self.install, - "test": self.unittest, - "qmerge": self.qmerge, - "unmerge": self.unmerge, - "manifest": self.manifest, - "package": self.make_package} - if command in functions: - ok = functions[command]() - else: - ok = utils.error( "command %s not understood" % command ) - - if ( not ok ): - utils.die( "command %s failed" % command ) - - def cleanup( self ): - """cleanup before install to imagedir""" - if ( os.path.exists( self.imagedir ) ): - utils.debug( "cleaning image dir: %s" % self.imagedir, 1 ) - utils.cleanDirectory( self.imagedir ) - return True - - def fetch( self ): - """getting normal tarballs from SRC_URI""" - utils.debug( "base fetch called", 1 ) - if ( self.noFetch ): - utils.debug( "skipping fetch (--offline)" ) - return True - if len( self.subinfo.targets ) and self.subinfo.buildTarget in list(self.subinfo.targets.keys()): - return utils.getFiles( self.subinfo.targets[ self.subinfo.buildTarget ], self.downloaddir ) - else: - return utils.getFiles( "", self.downloaddir ) - - def git_unpack( self, repoString ): - raise Exception('This function is deprecated. It calls undefined utils.replaceGitUrl.') - # pylint: disable=W0101 - # pylint should not warn about unreachable code here - svndir = os.path.join( self.downloaddir, "svn-src" ) - - ret = True - if ( not self.noFetch ): - safePath = os.environ["PATH"] - os.environ["PATH"] = os.path.join(self.rootdir, "dev-utils", "git", "bin") + ";" + safePath - if os.path.exists( self.svndir ): - # if directory already exists, simply do a pull but obey to offline - ret = self.msys.msysExecute( self.svndir, "git", "pull" ) - else: - # it doesn't exist so clone the repo - # first try to replace with a repo url from etc/portage/emergehosts.conf - # TODO: This fails: repoString = utils.replaceGitUrl( repoString ) - - repoUrl = utils.splitVCSUrl( repoString )[0] - ret = self.msys.msysExecute( svndir, "git", "clone %s %s" % ( repoUrl, self.package ) ) - dummyUrl2, repoBranch, repoTag = utils.splitVCSUrl( repoString ) - if ret and repoBranch: - ret = self.msys.msysExecute( self.svndir, "git", "checkout --track -b %s origin/%s" % ( repoBranch, repoBranch ) ) - if ret and repoTag: - ret = self.msys.msysExecute( self.svndir, "git", "checkout -b %s %s" % ( repoTag, repoTag ) ) - os.environ["PATH"] = safePath - else: - utils.debug( "skipping git fetch (--offline)" ) - return ret - - def unpack( self ): - """unpacking all zipped(gz, zip, bz2) tarballs""" - raise Exception('This function is deprecated. It calls undefined utils.applyPatches.') - # pylint: disable=W0101 - # pylint should not warn about unreachable code here - - utils.debug( "base unpack called", 1 ) - - if self.subinfo.buildTarget in list(self.subinfo.svnTargets.keys()): - if self.subinfo.svnTargets[ self.subinfo.buildTarget ] and utils.isGitUrl( self.subinfo.svnTargets[ self.subinfo.buildTarget ] ): - if ( not os.path.exists( self.workdir ) ): - os.makedirs( self.workdir ) - return self.git_unpack( self.subinfo.svnTargets[ self.subinfo.buildTarget ] ) - - if not utils.unpackFiles( self.downloaddir, self._filenames, self.workdir ): - return False - # if len( self.subinfo.targets ) and self.subinfo.buildTarget in self.subinfo.patchToApply.keys(): - # srcdir = os.path.join ( self.workdir, self.instsrcdir ) - # TODO: this would fail return utils.applyPatches(srcdir, self.subinfo.patchToApply[self.subinfo.buildTarget]) - return True - - def compile( self ): - """overload this function according to the packages needs""" - utils.debug( "base compile (configure + make) called, doing nothing...", 1 ) - return True - - def configure( self ): - """overload this function according to the packages needs""" - utils.debug( "base configure called, doing nothing...", 1 ) - return True - - def make( self ): - """overload this function according to the packages needs""" - utils.debug( "base configure called, doing nothing...", 1 ) - return True - - def install( self ): - """installing binary tarballs""" - if utils.verbose() > 1: - print("base install called") - srcdir = os.path.join( self.workdir, self.instsrcdir ) - destdir = os.path.join( self.imagedir, self.instdestdir ) - utils.copySrcDirToDestDir( srcdir, destdir ) - return True - - def unittest( self ): - """ run the unittests of the package """ - utils.debug( "currently only supported for some internal packages", 1 ) - return True - - def qmerge( self ): - """mergeing the imagedirectory into the filesystem""" - if utils.verbose() > 1: - print("base qmerge called") - for pkgtype in ['bin', 'lib', 'doc', 'src']: - script = os.path.join( self.packagedir, "post-install-%s.cmd" ) % pkgtype - scriptName = "post-install-%s-%s-%s.cmd" % ( self.package, self.version, pkgtype ) - destscript = os.path.join( self.imagedir, "manifest", scriptName ) - if not os.path.exists( os.path.join( self.imagedir, "manifest" ) ): - os.mkdir( os.path.join( self.imagedir, "manifest" ) ) - if os.path.exists( script ): - shutil.copyfile( script, destscript ) - - utils.mergeImageDirToRootDir( self.imagedir, self.rootdir ) - # run post-install scripts - for pkgtype in ['bin', 'lib', 'doc', 'src']: - scriptName = "post-install-%s-%s-%s.cmd" % ( self.package, self.version, pkgtype ) - script = os.path.join( self.rootdir, "manifest", scriptName ) - if os.path.exists( script ): - cmd = "cd %s && %s" % ( self.rootdir, script ) - if not utils.system(cmd): - utils.warning("%s failed!" % cmd ) - portage.addInstalled( self.category, self.package, self.version ) - return True - - def unmerge( self ): - """unmergeing the files from the filesystem""" - if utils.verbose() > 1: - print("base unmerge called") - utils.unmerge( self.rootdir, self.package, self.forced ) - portage.remInstalled( self.category, self.package, self.version ) - return True - - def manifest( self ): - """installer compatibility: make the manifest files that make up the installers - install database""" - if utils.verbose() > 1: - print("base manifest called") - utils.createManifestDir(self.imagedir, self.category, self.package, self.version ) - return True - - def make_package( self ): - """overload this function with the package specific packaging instructions""" - if utils.verbose() > 1: - print("currently only supported for some internal packages") - return True - - def setDirectories( self ): - """setting all important stuff that isn't coped with in the c'tor - parts will probably go to infoclass""" - utils.debug( "setdirectories called", 1 ) - - self.PV, dummyExt = os.path.splitext( os.path.basename( self.argv0 ) ) - - ( self.category, self.package, self.version ) = \ - portage.getCategoryPackageVersion( self.argv0 ) - - utils.debug( "setdir category: %s, package: %s" % ( self.category, self.package ) ) - - self.cmakeInstallPrefix = ROOTDIR.replace( "\\", "/" ) - utils.debug( "cmakeInstallPrefix: " + self.cmakeInstallPrefix ) - - if compiler.isMSVC(): - self.cmakeMakefileGenerator = "NMake Makefiles" - self.cmakeMakeProgramm = "nmake" - elif compiler.isMinGW(): - self.cmakeMakefileGenerator = "MinGW Makefiles" - if compiler.isMinGW_WXX(): - self.cmakeMakeProgramm = "gmake" - else: - self.cmakeMakeProgramm = "mingw32-make" - else: - utils.die( "KDECOMPILER: %s not understood" % COMPILER ) - - if EMERGE_MAKE_PROGRAM and self.subinfo.options.make.supportsMultijob: - self.cmakeMakeProgramm = EMERGE_MAKE_PROGRAM - utils.debug( "set custom make program: %s" % EMERGE_MAKE_PROGRAM, 1 ) - - self.rootdir = ROOTDIR - self.downloaddir = DOWNLOADDIR - self.workdir = os.path.join( ROOTDIR, "tmp", self.PV, "work" ) - self.imagedir = os.path.join( ROOTDIR, "tmp", self.PV, "image-" + COMPILER ) - - self.packagedir = os.path.join( portage.rootDirForPackage( self.category, self.package ), self.category, self.package ) - self.kdesvndir = KDESVNDIR - self.kdesvnserver = KDESVNSERVER - self.kdesvnuser = KDESVNUSERNAME - self.kdesvnpass = KDESVNPASSWORD - self.svndir = os.path.join( self.downloaddir, "svn-src", self.package ) - - self.strigidir = os.getenv( "STRIGI_HOME" ) - self.dbusdir = os.getenv( "DBUSDIR" ) - - - def svnFetch( self, repo ): - """getting sources from a custom svn repo""" - if utils.verbose() > 1: - print("base svnFetch called") - if ( self.noFetch ): - if utils.verbose() > 0: - print("skipping svn fetch/update (--offline)") - return True - - utils.svnFetch( repo, self.svndir ) - - def kdeGet( self ): - """TODO: unused""" - return self.kdeSvnPath() - - def __kdesinglecheckout( self, repourl, ownpath, codir, doRecursive = False ): - self.kde.kdesinglecheckout( repourl, ownpath, codir, doRecursive ) - - def kdeSvnFetch( self, svnpath, packagedir ): - return self.kde.kdeSvnFetch( svnpath, packagedir ) - - def kdeSvnPath( self ): - return self.kde.kdeSvnPath() - - def kdeSvnUnpack( self, svnpath=None, packagedir=None ): - if self.kde.kdeSvnPath(): - return self.kde.kdeSvnUnpack( svnpath, packagedir ) - else: - if not utils.unpackFiles( self.downloaddir, self._filenames, self.workdir ): - return False - if len( self.subinfo.targets ) and self.subinfo.buildTarget in list(self.subinfo.patchToApply.keys()): - ( fileName, patchdepth ) = self.subinfo.patchToApply[ self.subinfo.buildTarget ] - utils.debug( "patchesToApply: %s" % fileName, 0 ) - patchfile = os.path.join ( self.packagedir, fileName ) - srcdir = os.path.join ( self.workdir, self.instsrcdir ) - return utils.applyPatch( srcdir, patchfile, patchdepth ) - return True - - - def kdeDefaultDefines( self ): - return self.kde.kdeDefaultDefines() - - def kdeConfigureInternal( self, buildType ): - return self.kde.kdeConfigureInternal( buildType, self.kdeCustomDefines ) - - def kdeMakeInternal( self, buildType ): - return self.kde.kdeMakeInternal( buildType ) - - def kdeInstallInternal( self, buildType ): - return self.kde.kdeInstallInternal( buildType ) - - def kdeCompile( self ): - return self.kde.kdeCompile( self.kdeCustomDefines ) - - def kdeInstall( self ): - return self.kde.kdeInstall() - - def kdeTest( self ): - return self.kde.kdeTest() - - def doPackaging( self, pkg_name, pkg_version = str( datetime.date.today() ).replace('-', ''), packSources = True, special = False ): - """packaging according to the gnuwin32 packaging rules - this requires the kdewin-packager""" - - # FIXME: add a test for the installer later - dstpath = self.packageDestinationDir(withBuildType=False) - binpath = os.path.join( self.imagedir, self.instdestdir ) - tmp = os.path.join( binpath, "kde" ) - - patchlevel = os.getenv( "EMERGE_PKGPATCHLVL" ) - if patchlevel: - pkg_version += "-" + patchlevel - - if( os.path.exists( tmp ) ): - binpath = tmp - - if not utils.test4application( "kdewin-packager" ): - utils.die( "kdewin-packager not found - please make sure it is in your path" ) - - for pkgtype in ['bin', 'lib', 'doc', 'src']: - script = os.path.join( self.packagedir, "post-install-%s.cmd" ) % pkgtype - scriptName = "post-install-%s-%s-%s.cmd" % ( self.package, self.version, pkgtype ) - destscript = os.path.join( self.imagedir, "manifest", scriptName ) - if os.path.exists( script ): - if not os.path.exists( os.path.join( self.imagedir, "manifest" ) ): - os.mkdir( os.path.join( self.imagedir, "manifest" ) ) - shutil.copyfile( script, destscript ) - - if ( packSources and not ( self.noCopy and self.kde.kdeSvnPath() ) ): - srcpath = os.path.join( self.workdir, self.instsrcdir ) - cmd = "-name %s -root %s -srcroot %s -version %s -destdir %s" % \ - ( pkg_name, binpath, srcpath, pkg_version, dstpath ) - elif packSources and self.noCopy and self.kde.kdeSvnPath(): - srcpath = os.path.join( self.kde.kdesvndir, self.kde.kdeSvnPath() ).replace( "/", "\\" ) - if not os.path.exists( srcpath ): - srcpath = self.kde.sourcePath - cmd = "-name %s -root %s -srcroot %s -version %s -destdir %s" % \ - ( pkg_name, binpath, srcpath, pkg_version, dstpath ) - else: - cmd = "-name %s -root %s -version %s -destdir %s" % \ - ( pkg_name, binpath, pkg_version, dstpath ) - xmltemplate = os.path.join(self.packagedir, pkg_name+"-package.xml") - if os.path.exists(xmltemplate): - cmd = "kdewin-packager.exe " + cmd + " -template " + xmltemplate + " -notes " + \ - "%s/%s:%s:unknown " % ( self.category, self.package, self.version ) + "-compression 2 " - else: - cmd = "kdewin-packager.exe " + cmd + " -notes " + \ - "%s/%s:%s:unknown " % ( self.category, self.package, self.version ) + "-compression 2 " - - if( not self.createCombinedPackage ): - if( self.compiler == "mingw"): - cmd += " -type mingw " - elif self.compiler == "mingw4": - cmd += " -type mingw4 " - elif self.compiler == "msvc2005": - cmd += " -type msvc " - elif self.compiler == "msvc2008": - cmd += " -type vc90 " - elif self.compiler == "msvc2010": - cmd += " -type vc100 " - elif self.compiler == "msvc2011": - cmd += " -type vc110 " - else: - cmd += " -type unknown " - - if special: - cmd += " -special" - if utils.verbose(): - print("running %s" % cmd) - if not utils.system(cmd): - utils.die( "while packaging. cmd: %s" % cmd ) - return True - - def createImportLibs( self, pkg_name ): - """creating the import libraries for the other compiler(if ANSI-C libs)""" - basepath = os.path.join( self.imagedir, self.instdestdir ) - utils.createImportLibs( pkg_name, basepath ) - - def stripLibs( self, pkg_name ): - """stripping libraries""" - if not self.subinfo.options.package.disableStriping: - basepath = os.path.join( self.imagedir, self.instdestdir ) - dllpath = os.path.join( basepath, "bin", "%s.dll" % pkg_name ) - - cmd = "strip -s " + dllpath - self.system( cmd ) - return True - - def msysConfigureFlags( self ): - return self.msys.msysConfigureFlags() - - def msysCompile( self, bOutOfSource = True ): - return self.msys.msysCompile( bOutOfSource ) - - def msysInstall( self, bOutOfSource = True ): - return self.msys.msysInstall( bOutOfSource ) - - def system( self, command, **kw ): - """ - This function should be called instead of os.system it provides - an entry point to modifiy system calls globally. - The return value of the called command is checked and on failure - emerge exits accordingly. - For available keyword options please refer to the python - documentation of system.popen - """ - if not utils.system( command, **kw ): - utils.die( "os.system ( %s ) failed" % ( command ) ) - return True - - def packageDestinationDir( self, withBuildType=True ): - """return absolute path to the directory where binary packages are placed into. - Default is to optionally append build type subdirectory""" - - utils.debug( "base.packageDestinationDir called", 2 ) - dstpath = os.getenv( "EMERGE_PKGDSTDIR" ) - if not dstpath: - dstpath = os.path.join( self.rootdir, "tmp" ) - - if withBuildType: - if utils.envAsBool( "EMERGE_MERGE_ROOT_WITH_BUILD_TYPE" ): - dstpath = os.path.join( dstpath, self.buildType()) - - if not os.path.exists(dstpath): - utils.createDir(dstpath) - return dstpath - - -# ############################################################################################ -# for testing purpose only: -# ############################################################################################ - -def main(): - if utils.verbose() > 0: - print("KDEROOT: ", ROOTDIR) - print("KDECOMPILER: ", COMPILER) - print("DOWNLOADDIR: ", DOWNLOADDIR) - print("KDESVNDIR: ", KDESVNDIR) - print("KDESVNSERVER:", KDESVNSERVER) -# this would fail, MSYSDIR undefined. But this module is deprecated anyway. -# print "MSYSDIR:", MSYSDIR - - test = baseclass() - test.system( "dir" ) - -if __name__ == '__main__': - main() diff --git a/bin/kde_build.py b/bin/kde_build.py deleted file mode 100644 index 3cbbbcb47..000000000 --- a/bin/kde_build.py +++ /dev/null @@ -1,328 +0,0 @@ -# -*- coding: utf-8 -*- -# definitions for the kde build system (cmake and svn) -import os -import utils - -class kde_interface: - def __init__( self, env = dict( os.environ ) ): - # TODO: env as argument is never used, eliminate - for key in ["KDESVNUSERNAME", "KDESVNPASSWORD", "KDECOMPILER", "KDESVNDIR", "KDESVNSERVER", - "EMERGE_BUILDTYPE", "EMERGE_MAKE_PROGRAM", "DIRECTORY_LAYOUT" ]: - if not key in list(env.keys()): - env[ key ] = None - self.COMPILER = env[ "KDECOMPILER" ] - self.KDESVNUSERNAME = env[ "KDESVNUSERNAME" ] - self.KDESVNPASSWORD = env[ "KDESVNPASSWORD" ] - self.KDESVNDIR = env[ "KDESVNDIR" ] - self.KDESVNSERVER = env[ "KDESVNSERVER" ] - if ( self.KDESVNDIR == None ): - DOWNLOADDIR = os.getenv( "DOWNLOADDIR" ) - if ( DOWNLOADDIR == None ): - DOWNLOADDIR = os.path.join( env['KDEROOT'], "distfiles" ) - self.KDESVNDIR = os.path.join( DOWNLOADDIR, "svn-src", "kde" ) - if ( self.KDESVNSERVER == None ): - self.KDESVNSERVER = "svn://anonsvn.kde.org" - self.BUILDTYPE = env[ "EMERGE_BUILDTYPE" ] - if ( self.BUILDTYPE not in ["Debug", "Release", "RelWithDebInfo", "MinSizeRel"] ): - self.BUILDTYPE = None - self.DIRECTORY_LAYOUT = env[ "DIRECTORY_LAYOUT" ] - self.MAKE_PROGRAM = env[ "EMERGE_MAKE_PROGRAM" ] - - def setDirectories( self, rootdir, imagedir, workdir, instsrcdir, instdestdir, infoobject ): - self.subinfo = infoobject - - if self.COMPILER == "msvc2005" or self.COMPILER == "msvc2008" or self.COMPILER == "msvc2010": - self.cmakeMakefileGenerator = "NMake Makefiles" - self.cmakeMakeProgramm = "nmake" - elif self.COMPILER == "mingw" or self.COMPILER == "mingw4": - self.cmakeMakefileGenerator = "MinGW Makefiles" - self.cmakeMakeProgramm = "mingw32-make" - else: - utils.die( "KDECOMPILER: %s not understood" % self.COMPILER ) - - if self.MAKE_PROGRAM: - self.cmakeMakeProgramm = self.MAKE_PROGRAM - utils.debug( "set custom make program: %s" % self.MAKE_PROGRAM, 1 ) - - if utils.verbose() > 1: - print("BuildType: %s" % self.BUILDTYPE) - self.buildType = self.BUILDTYPE - - self.noFetch = utils.envAsBool( "EMERGE_OFFLINE" ) - self.noCopy = utils.envAsBool( "EMERGE_NOCOPY") - self.noFast = utils.envAsBool( "EMERGE_NOFAST", default=True ) - self.noClean = utils.envAsBool( "EMERGE_NOCLEAN" ) - self.forced = utils.envAsBool( "EMERGE_FORCED" ) - self.buildTests = utils.envAsBool( "EMERGE_BUILDTESTS" ) - - self.buildNameExt = None - - self.rootdir = rootdir - self.workdir = workdir - self.imagedir = imagedir - self.instsrcdir = instsrcdir - self.instdestdir = instdestdir - - self.kdesvndir = self.KDESVNDIR - self.kdesvnserver = self.KDESVNSERVER - self.kdesvnuser = self.KDESVNUSERNAME - self.kdesvnpass = self.KDESVNPASSWORD - self.svndir = None # set in self.kdeSvnFetch - - if utils.verbose() > 1 and self.kdeSvnPath(): - print("noCopy : %s" % self.noCopy) - print("kdeSvnPath() : %s" % self.kdeSvnPath().replace("/", "\\")) - - if not ( self.noCopy and self.kdeSvnPath() ) : - if self.kdeSvnPath(): - self.sourcePath = "..\\%s" % self.kdeSvnPath().split('/')[-1] - else: - self.sourcePath = "..\\%s" % self.instsrcdir - else: - self.sourcePath = "%s" % os.path.join(self.kdesvndir, self.kdeSvnPath() ).replace("/", "\\") - - def kdesinglecheckout( self, repourl, ownpath, codir, doRecursive = False ): - """in ownpath try to checkout codir from repourl - if codir exists and doRecursive is false, simply return, - if codir does not exist, but ownpath/.svn exists, - do a svn update codir - else do svn co repourl/codir - if doRecursive is false, add -N to the svn command """ - - if ( os.path.exists( os.path.join( ownpath, codir ) ) and not doRecursive ): - if utils.verbose() > 0: - print("ksco exists:", ownpath, codir) - return - - if ( doRecursive ): - recFlag = "" - else: - recFlag = "--depth=files" - - svnInstallDir = os.path.join(self.rootdir, 'dev-utils', 'svn', 'bin') - if not os.path.exists(svnInstallDir): - utils.die("required subversion package not installed") - - if ( os.path.exists( os.path.join( ownpath, codir, ".svn" ) ) ): - # svn up - svncmd = "%s/svn update %s %s" % (svnInstallDir, recFlag, codir ) - else: - #svn co - svncmd = "%s/svn checkout %s %s" % (svnInstallDir, recFlag, repourl + codir ) - - if utils.verbose() > 1: - print("kdesinglecheckout:pwd ", ownpath) - print("kdesinglecheckout: ", svncmd) - os.chdir( ownpath ) - with utils.LockFile(utils.LockFileName("SVN")): - if not utils.system(svncmd): - utils.die( "while checking out. cmd: %s" % svncmd ) - - def kdeSvnFetch( self, svnpath, packagedir ): - """svnpath is the part of the repo url after /home/kde, for example - ""trunk/kdesupport/", which leads to the package itself - without the package""" - - if utils.verbose() > 1: - print("kdeSvnFetch called. svnpath: %s dir: %s" % ( svnpath, packagedir )) - - if ( self.noFetch ): - if utils.verbose() > 0: - print("skipping svn fetch/update (--offline)") - return True - - svndir = self.kdesvndir - if ( not os.path.exists( svndir ) ): - os.mkdir( svndir ) - - repourl = self.kdesvnserver + "/home/kde/" - - for tmpdir in svnpath.split( "/" ): - if ( tmpdir == "" ): - continue - if utils.verbose() > 1: - print(" svndir: %s" % svndir) - print(" dir to checkout: %s" % tmpdir) - print(" repourl", repourl) - - self.kdesinglecheckout( repourl, svndir, tmpdir, False ) - svndir = os.path.join( svndir, tmpdir ) - repourl = repourl + tmpdir + "/" - - if utils.verbose() > 0: - print("dir in which to really checkout: %s" % svndir) - print("dir to really checkout: %s" % packagedir) - self.kdesinglecheckout( repourl, svndir, packagedir, True ) - - svndir = os.path.join( self.kdesvndir, svnpath ).replace( "/", "\\" ) - #repo = self.kdesvnserver + "/home/kde/" + svnpath + dir - #utils.svnFetch( repo, svndir, self.kdesvnuser, self.kdesvnpass ) - if utils.verbose() > 1: - print("kdesvndir", self.kdesvndir) - print("svndir", svndir) - self.svndir = os.path.join( svndir, packagedir ) - - return True - - def kdeSvnPath( self ): - """overload this function in kde packages to use the nocopy option - this function should return the full path seen from /home/KDE/""" - if self.subinfo.buildTarget in list(self.subinfo.svnTargets.keys()): - return self.subinfo.svnTargets[ self.subinfo.buildTarget ] - - def kdeSvnUnpack( self, svnpath=None, packagedir=None ): - """fetching and copying the sources from svn""" - if not svnpath and not packagedir: - if self.kdeSvnPath(): - svnpath = self.kdeSvnPath()[ :self.kdeSvnPath().rfind('/') ] - packagedir = self.kdeSvnPath()[ self.kdeSvnPath().rfind('/') + 1:] - else: - utils.die( "no svn repository information are available" ) - self.kdeSvnFetch( svnpath, packagedir ) - - if( not os.path.exists( self.workdir ) ): - os.makedirs( self.workdir ) - - if not ( self.noCopy and self.kdeSvnPath() ): - # now copy the tree to workdir - srcdir = os.path.join( self.kdesvndir, svnpath, packagedir ) - destdir = os.path.join( self.workdir, packagedir ) - utils.copySrcDirToDestDir( srcdir, destdir ) - return True - - def kdeDefaultDefines( self ): - """defining the default cmake cmd line""" - options = "\"%s\" -DCMAKE_INSTALL_PREFIX=\"%s\" " % \ - ( self.sourcePath, self.rootdir.replace( "\\", "/" ) ) - - options = options + "-DCMAKE_INCLUDE_PATH=\"%s\" " % \ - os.path.join( self.rootdir, "include" ).replace( "\\", "/" ) - - options = options + "-DCMAKE_LIBRARY_PATH=\"%s\" " % \ - os.path.join( self.rootdir, "lib" ).replace( "\\", "/" ) - - if self.buildTests: - options = options + " -DKDE4_BUILD_TESTS=1 " - - options = options + " -DKDE4_ENABLE_EXPERIMENTAL_LIB_EXPORT:BOOL=ON " - options = options + " -DKDEWIN_DIR:PATH=\"%s\" " % \ - os.path.join( self.rootdir ).replace( "\\", "/" ) - - return options - - def kdeConfigureInternal( self, buildType, kdeCustomDefines ): - """Using cmake""" - builddir = "%s" % ( self.COMPILER ) - - if( not buildType == None ): - buildtype = "-DCMAKE_BUILD_TYPE=%s" % buildType - builddir = "%s-%s" % ( builddir, buildType ) - - if( not self.buildNameExt == None ): - builddir = "%s-%s" % ( builddir, self.buildNameExt ) - - os.chdir( self.workdir ) - if ( not os.path.exists( builddir) ): - os.mkdir( builddir ) - - if not self.noClean: - utils.cleanDirectory( builddir ) - os.chdir( builddir ) - - command = r"""cmake -G "%s" %s %s %s""" % \ - ( self.cmakeMakefileGenerator, \ - self.kdeDefaultDefines(), \ - kdeCustomDefines, \ - buildtype ) - - if utils.verbose() > 0: - print("configuration command: %s" % command) - if not utils.system(command): - utils.die( "while CMake'ing. cmd: %s" % command ) - return True - - def kdeMakeInternal( self, buildType ): - """Using the *make program""" - builddir = "%s" % ( self.COMPILER ) - - if( not buildType == None ): - builddir = "%s-%s" % ( builddir, buildType ) - if( not self.buildNameExt == None ): - builddir = "%s-%s" % ( builddir, self.buildNameExt ) - - os.chdir( os.path.join( self.workdir, builddir ) ) - command = self.cmakeMakeProgramm - # adding Targets later - if utils.verbose() > 1: - command += " VERBOSE=1" - if not utils.system(command): - utils.die( "while Make'ing. cmd: %s" % command ) - return True - - def kdeInstallInternal( self, buildType ): - """Using *make install""" - builddir = "%s" % ( self.COMPILER ) - - if( not buildType == None ): - builddir = "%s-%s" % ( builddir, buildType ) - - if( not self.buildNameExt == None ): - builddir = "%s-%s" % ( builddir, self.buildNameExt ) - - os.chdir( self.workdir ) - os.chdir( builddir ) - - if utils.verbose() > 0: - print("builddir: " + builddir) - - fastString = "" - if not self.noFast: - fastString = "/fast" - if not utils.system( "%s DESTDIR=%s install%s" % ( self.cmakeMakeProgramm, self.imagedir, fastString ) ): - utils.die( "while installing. cmd: %s" % "%s DESTDIR=%s install" % ( self.cmakeMakeProgramm, self.imagedir ) ) - return True - - def kdeCompile( self, kdeCustomDefines ): - """making all required stuff for compiling cmake based modules""" - if( not self.buildType == None ) : - if( not ( self.kdeConfigureInternal( self.buildType, kdeCustomDefines ) and self.kdeMakeInternal( self.buildType ) ) ): - return False - else: - if( not ( self.kdeConfigureInternal( "Debug", kdeCustomDefines ) and self.kdeMakeInternal( "Debug" ) ) ): - return False - if( not ( self.kdeConfigureInternal( "Release", kdeCustomDefines ) and self.kdeMakeInternal( "Release" ) ) ): - return False - return True - - def kdeInstall( self ): - """making all required stuff for installing cmake based modules""" - if( not self.buildType == None ): - if( not self.kdeInstallInternal( self.buildType ) ): - return False - else: - if( not self.kdeInstallInternal( "debug" ) ): - return False - if( not self.kdeInstallInternal( "release" ) ): - return False - utils.fixCmakeImageDir( self.imagedir, self.rootdir ) - return True - - def kdeTest( self ): - """running cmake based unittests""" - builddir = "%s" % ( self.COMPILER ) - - if( not self.buildType == None ): - builddir = "%s-%s" % ( builddir, self.buildType ) - - if( not self.buildNameExt == None ): - builddir = "%s-%s" % ( builddir, self.buildNameExt ) - - os.chdir( self.workdir ) - os.chdir( builddir ) - - if utils.verbose() > 0: - print("builddir: " + builddir) - - if not utils.system( "%s test" % ( self.cmakeMakeProgramm ) ): - utils.die( "while testing. cmd: %s" % "%s test" % ( self.cmakeMakeProgramm ) ) - return True diff --git a/bin/msys_build.py b/bin/msys_build.py deleted file mode 100644 index 5138b9dd0..000000000 --- a/bin/msys_build.py +++ /dev/null @@ -1,93 +0,0 @@ -# -*- coding: utf-8 -*- -# definitions for the msys build system -import os -import utils - -class msys_interface: - def __init__( self, env = dict( os.environ ) ): - self.MSYSDIR = env[ "MSYSDIR" ] - - def setDirectories(self, rootdir, imagedir, workdir, instsrcdir, instdestdir): - self.rootdir = rootdir - self.imagedir = imagedir - self.workdir = workdir - self.instsrcdir = instsrcdir - self.instdestdir = instdestdir - self.msysdir = self.MSYSDIR - self.msysCustomDefines = "" - - def __toMSysPath( self, path ): - path = path.replace( '\\', '/' ) - if ( path[1] == ':' ): - path = '/' + path[0].lower() + '/' + path[3:] - return path - - def msysExecute( self, path, cmd, args ): - sh = os.path.join( self.msysdir, "bin", "sh.exe" ) - - cmd = "%s --login -c \"cd %s && %s %s" % \ - ( sh, self.__toMSysPath( path ), self.__toMSysPath( cmd ), args ) - - cmd += "\"" - if utils.verbose() > 0: - print("msys execute: %s" % cmd) - if not utils.system(cmd): - utils.die( "msys execute failed. cmd: %s" % cmd ) - return True - - def msysConfigureFlags ( self ): - """adding configure flags always used""" - flags = "--disable-nls " - flags += "--enable-shared " - flags += "--disable-static " - flags += "--prefix=/ " - flags += self.msysCustomDefines - return flags - - def msysCompile( self, bOutOfSource = True ): - """run configure and make for Autotools based stuff""" - config = os.path.join( self.workdir, self.instsrcdir, "configure" ) - build = os.path.join( self.workdir ) - if( bOutOfSource ): - # otherwise $srcdir is very long and a conftest may fail (like it's the - # case in libgmp-4.2.4) - config = os.path.join( "..", self.instsrcdir, "configure" ) - build = os.path.join( build, self.instsrcdir + "-build" ) - utils.cleanDirectory( build ) - else: - build = os.path.join( build, self.instsrcdir ) - - sh = os.path.join( self.msysdir, "bin", "sh.exe" ) - - # todo use msysexecute - cmd = "%s --login -c \"cd %s && %s %s && make -j2" % \ - ( sh, self.__toMSysPath( build ), self.__toMSysPath( config ), \ - self.msysConfigureFlags() ) - if utils.verbose() > 1: - cmd += " VERBOSE=1" - cmd += "\"" - if utils.verbose() > 0: - print("msys compile: %s" % cmd) - if not utils.system(cmd): - utils.die( "msys compile failed. cmd: %s" % cmd ) - return True - - def msysInstall( self, bOutOfSource = True ): - """run make install for Autotools based stuff""" - install = os.path.join( self.imagedir, self.instdestdir ) - build = os.path.join( self.workdir ) - if( bOutOfSource ): - build = os.path.join( build, self.instsrcdir + "-build" ) - else: - build = os.path.join( build, self.instsrcdir ) - - sh = os.path.join( self.msysdir, "bin", "sh.exe" ) - - # todo use msysexecute - cmd = "%s --login -c \"cd %s && make -j2 install DESTDIR=%s\"" % \ - ( sh, self.__toMSysPath( build ), self.__toMSysPath( install ) ) - if utils.verbose() > 0: - print("msys install: %s" % cmd) - if not utils.system(cmd): - utils.die( "msys install failed. cmd: %s" % cmd ) - return True