diff --git a/bin/compiler.py b/bin/compiler.py index a8242c8f7..1a9cf31b0 100644 --- a/bin/compiler.py +++ b/bin/compiler.py @@ -1,167 +1,176 @@ # -*- coding: utf-8 -*- # this package contains functions to check the current compiler # copyright: # Hannah von Reth import os import subprocess import re from CraftDebug import craftDebug import utils from CraftConfig import * _GCCTARGET = None _MINGW_VERSION = None def _getGCCTarget(): global _GCCTARGET # pylint: disable=W0603 if not _GCCTARGET: status, result = subprocess.getstatusoutput("gcc -dumpmachine") if status == 0: craftDebug.log.debug("GCC Target Processor:%s" % result) _GCCTARGET = result.strip() else: #if no mingw is installed return mingw-w32 it is part of base if isX64(): _GCCTARGET = "x86_64-w64-mingw32" else: _GCCTARGET = "i686-w64-mingw32" return _GCCTARGET def architecture(): return craftSettings.get("General", "Architecture" ) def isNative(): return craftSettings.getboolean("General", "Native", True) def isX64(): return architecture() == "x64" def isX86(): return architecture() == "x86" def _compiler(): return craftSettings.get("General","KDECOMPILER") def isGCC(): return isMinGW() or _compiler().endswith("-gcc") +def isClang(): + return _compiler().endswith("-clang") + +def isGCCLike(): + return (isGCC() or isClang()) + def isMinGW(): return _compiler().startswith("mingw") def isMinGW_W32(): return isMinGW() and _getGCCTarget() == "i686-w64-mingw32" def isMinGW_W64(): return isMinGW() and isX64() def isMSVC(): return _compiler().startswith("msvc") -def isClang(): - return craftSettings.getboolean("Compile","UseClang", False ) - def isMSVC2010(): return _compiler() == "msvc2010" def isMSVC2012(): return _compiler() == "msvc2012" def isMSVC2013(): return _compiler() == "msvc2013" def isMSVC2015(): return _compiler() == "msvc2015" def isMSVC2017(): return _compiler() == "msvc2017" def isIntel(): return _compiler() == "intel" def getCompilerName(): if isMinGW(): return "mingw-w64" elif isMSVC(): return _compiler() elif isIntel(): return "intel-%s-%s" % (os.getenv("TARGET_ARCH"), os.getenv("TARGET_VS")) elif isGCC(): return "gcc" + elif isClang(): + return "clang" else: craftDebug.log.critical("Unknown Compiler %s" % _compiler()) def getSimpleCompilerName(): if isMinGW(): return "mingw64" elif isMSVC(): return "msvc" elif isIntel(): return "intel" else: return getCompilerName() -def getGCCVersion(): +def getGCCLikeVersion(compilerExecutable): global _MINGW_VERSION # pylint: disable=W0603 if not _MINGW_VERSION: - status, result = subprocess.getstatusoutput("gcc --version") + status, result = subprocess.getstatusoutput(f"{compilerExecutable} --version") if status == 0: result = re.findall("\d+\.\d+\.?\d*",result)[0] - craftDebug.log.debug("GCC Version:%s" % result) + craftDebug.log.debug("{0} Version: {1}".format(compilerExecutable, result)) _MINGW_VERSION = result.strip() else: #if no mingw is installed return 0 _MINGW_VERSION = "0" return _MINGW_VERSION def getVersion(): - if isGCC(): - return "%s %s" % (getCompilerName(), getGCCVersion()) + if isGCCLike(): + return "%s %s" % (getCompilerName(), getGCCLikeVersion(getCompilerName())) elif isIntel(): return os.getenv("PRODUCT_NAME_FULL") - return "Microsoft Visual Studio 20%s" % _compiler()[len(_compiler())-2:] + elif isMSVC(): + return "Microsoft Visual Studio 20%s" % _compiler()[len(_compiler())-2:] + else: + return None def getShortName(): if not isMSVC(): return getCompilerName() return f"vc{internalVerison()}" def internalVerison(): if not isMSVC(): return getVersion() versions = { "msvc2010": 10, "msvc2012": 11, "msvc2013": 12, "msvc2015": 14, "msvc2017": 15 } if _compiler() not in versions: craftDebug.log.critical(f"Unknown MSVC Compiler {_compiler()}") return versions[_compiler()] def msvcPlatformToolset(): versions = { "msvc2010": 100, "msvc2012": 110, "msvc2013": 120, "msvc2015": 140, "msvc2017": 141 } if _compiler() not in versions: craftDebug.log.critical(f"Unknown MSVC Compiler {_compiler()}") return versions[_compiler()] if __name__ == '__main__': print("Testing Compiler.py") + print("Configured compiler (KDECOMPILER): %s" % _compiler()) print("Version: %s" % getVersion()) print("Compiler Name: %s" % getCompilerName()) print("Native compiler: %s" % ("No", "Yes")[isNative()]) - print("Compiler Version: %s" % getGCCVersion()) - + if isGCCLike(): + print("Compiler Version: %s" % getGCCLikeVersion(getCompilerName())) diff --git a/kdesettings.ini b/kdesettings.ini index 110754c31..d90915800 100644 --- a/kdesettings.ini +++ b/kdesettings.ini @@ -1,172 +1,174 @@ ## This is the settings file for use with powershell. ## Copy it to your craft/../etc and call ". .\kdeenv.ps1" or "kdeenv.bat" in your craft checkout. ## You can use cmake like variables for values in the same section. ## See Paths/${DOWNLOADDIR} [General] ## Here you set the compiler to be used. ## mingw4 - use the mingw gcc compiler (recommended) ## msvc2010, msvc2012, msvc2013 or msvc2015 - use the Microsoft Visual C++ compiler +## on macOS: use mac-clang +## on Linux: use linux-gcc or linux-clang KDECompiler = msvc2015 ## possible values x86 or x64 Architecture = x64 ## This option should be set to False if you use the msvc 201X Express Edition 64bit compiler ## in all other cases, simply keep this option commented out #Native=False ## This option can be used to enable a notification backend. ## As soon as the buildprocess of a project has finished a notification will be displayed. ## Possible Backends: ## Snore https://commits.kde.org/snorenotify. Snore supports multiple backends. ### To configure it call craft --snore-settings ### You might need to install snorenotify EMERGE_USE_NOTIFY = Snore ## Speed up the merging of packages by using hard links UseHardlinks = True [Paths] ## This is the location of your python installation. ## This value must be set. Python = C:\PROGRA~1\Python36 ## Some applications may need python 2.7 #Python27 = C:\python27 ## Here you change the download directory. ## If you want, so you can share the same download directory between ## mingw and msvc. ## The default value is craft/../download #DownloadDir = C:\kde\download ## This option defines the location for git checkouts. ## The default value is craft/../download/git #KDEGitDir = ${DOWNLOADDIR}\git ## This option defines the location for svn checkouts. ## The default value is craft/../download/svn #KDESVNDir = ${DOWNLOADDIR}\svn ## This option defines the location where the ccache files are stored. ## The default location is KDEROOT/build/ccache #CCACHE_DIR = C:\CCACHE\kf5 [Compile] ## Whether to build tests (default: True) #BuildTests = False ## the buildtype of this installation ## Possible Values: ## Release ## RelWithDebInfo ## Debug ## MinSizeRel BuildType = RelWithDebInfo ## Whether to use ninja (default: False) UseNinja = True ## Whether to use ccache (only avalible with mingw compiler) #UseCCache = True ## This option can be used to override the default make program ## change the value to the path of the executable you want to use instead. MakeProgram = jom [ShortPath] ## substitute pathes by drives ## This option is needed to avoid path limit problems in case of long base pathes ## and compiling big packages like qt ## If you disable it do _not_ use any paths longer than 6 letters in the ## directory settings EMERGE_USE_SHORT_PATH = True ## each drive could be commented out to skip substution EMERGE_ROOT_DRIVE = r: EMERGE_GIT_DRIVE = q: #EMERGE_DOWNLOAD_DRIVE = t: [Portage] ## This adds the possibility to disable cretin packages ## For portage recipes configure options can be added by ## "if self.subinfo.options.isActive("binary/mysql"):" ## Ignores = dev-util/git;dev-util/msys;kdesupport/kdewin;win32libs/boost/boost-python Ignores = [PortageVersions] ## Overide the default version for a package. ## For a normal package add category/package, like win32libs/libpng and set the Version ## For meta packages like Qt5 you can directly set the version for the whole package #libs/craft = master #Qt5 = 5.2.1 #KF5 = 5.2.0 #KDE = 4.89.0 #Boost = 1_55_0 #win32libs/libpng = 1.2.43 #binary/vlc = 3.0.0-git [Packager] ## The archive type for packages. ## Possible values are: zip, 7z ## Todo: rename 7ZipArchiveType = 7z ## If set this will override the default package type. ## Possible values are: SevenZipPackager, MSIFragmentPackager, ## InnoSetupPackager, NullsoftInstallerPackager #PackageType = SevenZipPackager ## Package the Source files too. PackageSrc=False ## A url to a Craft cache repository RepositoryUrl = https://files.kde.org/craft/unstable/ ## Enable to fatch packages from a Craft cache repository ## See --use-cache and --no-cache in the Craft help. #UseCache = True [CraftDebug] ## If you want to have verbose output, uncomment the following option ## and set it to positive integer for verbose output and to 0 ## (or disable it) for normal output. Currently the highest verbosity level ## is 3 (equal to 'craft -v -v -v'). level -1 equals 'craft -q' ## Default is Verbose = 0 #Verbose = 1 # Log environment, prints the current state of the environment befor an application is run LogEnvironment = True ## Prints time spend on various craft tasks MeasureTime = False ## Dump internal state of craftSettings to kdesettings.ini.dump #DumpSettings = True [Environment] ## All values defined here will be populated to the environment #GIT_COMMITTER_EMAIL = foo@bar.com ## Set the ssh client for git and svn. #GIT_SSH = plink #SVN_SSH = plink [QtSDK] ## This is higly experimental and you will miss certain features like dbus or mysql support. ## Whether to use prebuild Qt binaries. Enabled = False ## The path to the Qt sdk. Path = D:\Qt ## The version of Qt. Version = 5.3 ## The compiler version, if you are not sure what to use, have a look into the derectory set in QtSDK/Path. ## The compiler must be of the same type as General/KDECOMPILER. ## If you are using mingw please make sure you have installed the mingw using the Qt installer. Compiler = mingw482_32 [Version] EMERGE_SETTINGS_VERSION = 2