diff --git a/Jenkinsfile b/Jenkinsfile index 61a15ce68..74e9b104f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,19 @@ import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException +regexDevBranch = /develop\/\d+\.\d+\.\d+/ +regexReleaseBranch = /release\/\d+\.\d+/ +regexNocacheBranch = /nocache\/.+/ +regexRecacheBranches = [regexDevBranch, regexReleaseBranch] + +if (env.BRANCH_NAME && regexRecacheBranches.any{ env.BRANCH_NAME ==~ it }) { + env.CCACHE_RECACHE = 1 + env.CLCACHE_RECACHE = 1 +} +if (env.BRANCH_NAME && env.BRANCH_NAME ==~ regexNocacheBranch) { + env.CCACHE_DISABLE = 1 + env.CLCACHE_DISABLE = 1 +} + abortPreviousRunningBuilds() def builders = [:] @@ -147,7 +161,9 @@ builders['Build swift Win32'] = { throw error } finally { notifyDiscord('Win32', buildResults['swift-win32']) - killDBusDaemon() + killWindowsProcess('dbus-daemon.exe') + killWindowsProcess('clcache.exe') + killWindowsProcess('python.exe') cleanWs deleteDirs: true, notFailBuild: true } } @@ -192,7 +208,9 @@ builders['Build swift Win64'] = { throw error } finally { notifyDiscord('Win64', buildResults['swift-win64']) - killDBusDaemon() + killWindowsProcess('dbus-daemon.exe') + killWindowsProcess('clcache.exe') + killWindowsProcess('python.exe') cleanWs deleteDirs: true, notFailBuild: true } } @@ -250,7 +268,6 @@ node('master') { node('master') { try { - def regexDevBranch = /develop\/\d+\.\d+\.\d+/ if (env.BRANCH_NAME && env.BRANCH_NAME ==~ regexDevBranch) { stage('Publish') { unstash name: 'swift-linux-64' @@ -384,8 +401,6 @@ def notifyDiscord(nodeName, buildStatus = 'UNSTABLE') { } def getEolInMonth() { - def regexDevBranch = /develop\/\d+\.\d+\.\d+/ - def regexReleaseBranch = /release\/\d+\.\d+/ if (env.BRANCH_NAME && env.BRANCH_NAME ==~ regexDevBranch) { // 6 month for dev builds return 6 @@ -410,10 +425,10 @@ def shouldUploadSymbols() { } } -def killDBusDaemon() { - bat ''' - tasklist /FI "IMAGENAME eq dbus-daemon.exe" 2>NUL | find /I /N "dbus-daemon.exe">NUL - if "%ERRORLEVEL%"=="0" taskkill /f /im dbus-daemon.exe +def killWindowsProcess(name) { + bat """ + tasklist /FI "IMAGENAME eq ${name}" 2>NUL | find /I /N "${name}">NUL + if "%ERRORLEVEL%"=="0" taskkill /f /im ${name} EXIT 0 - ''' + """ } diff --git a/mkspecs/features/common_pre.prf b/mkspecs/features/common_pre.prf index d0da0e10e..ed90493ef 100644 --- a/mkspecs/features/common_pre.prf +++ b/mkspecs/features/common_pre.prf @@ -53,6 +53,17 @@ include(wordsize.pri) contains(TEMPLATE, "vc.*"): QMAKE_CXXFLAGS *= /MP +################################ +# Cache intermediate files to improve build times +################################ + +swiftConfig(ccache) { + swiftConfig(profileRelease):error(profileRelease is incompatible with clcache) + msvc: QMAKE_CXX = clcache + else:macx: QMAKE_CXX = /usr/local/bin/ccache $$QMAKE_CXX + else:gcc: QMAKE_CXX = ccache $$QMAKE_CXX +} + ################################ # Release build with debug info ################################ diff --git a/scripts/jenkins.py b/scripts/jenkins.py index 62c0df3c2..7261a89a5 100644 --- a/scripts/jenkins.py +++ b/scripts/jenkins.py @@ -37,6 +37,7 @@ class Builder: """ print('Preparing environment ...') os.environ['PATH'] += os.pathsep + self._get_qt_binary_path() + self._ccache_prepare() self._specific_prepare() print('Updating from datastore ...') @@ -46,6 +47,15 @@ class Builder: shared_path = os.path.abspath(os.path.join(source_path, 'resources', 'share')) datastore.update_shared(host, datastore_version, shared_path) + def _ccache_prepare(self): + os.environ['CCACHE_NODIRECT'] = '1' + os.environ['CLCACHE_NODIRECT'] = '1' + os.environ['CLCACHE_COMPRESS'] = '1' + os.environ['CLCACHE_OBJECT_CACHE_TIMEOUT_MS'] = str(10 * 60 * 1000) + os.environ['CLCACHE_DIR'] = 'C:\\clcache' # workaround https://github.com/frerich/clcache/issues/342 + os.environ['CLCACHE_BASEDIR'] = os.environ['WORKSPACE'] + os.environ['CCACHE_BASEDIR'] = os.environ['WORKSPACE'] + def build(self, jobs, qmake_args, dev_build, eolInMonth): """ Run the build itself. Pass dev_build=True to enable a dev build @@ -69,6 +79,7 @@ class Builder: print('Setting EOL date to ' + eolDate.strftime('%Y%m%d')) qmake_call += ['SWIFT_CONFIG.endOfLife=' + eolDate.strftime('%Y%m%d')] + qmake_call += ['SWIFT_CONFIG.ccache=true'] qmake_call += ['-r', os.pardir] subprocess.check_call(qmake_call, env=dict(os.environ)) diff --git a/src/blackcore/blackcore.pro b/src/blackcore/blackcore.pro index bb7bd7ba2..3811b6416 100644 --- a/src/blackcore/blackcore.pro +++ b/src/blackcore/blackcore.pro @@ -16,6 +16,7 @@ INCLUDEPATH += .. DEPENDPATH += . .. PRECOMPILED_HEADER = pch/pch.h +INCLUDEPATH += pch DEFINES += LOG_IN_FILE BUILD_BLACKCORE_LIB diff --git a/src/blackgui/blackgui.pro b/src/blackgui/blackgui.pro index 920ef7b89..4656571d4 100644 --- a/src/blackgui/blackgui.pro +++ b/src/blackgui/blackgui.pro @@ -28,6 +28,7 @@ else { DEPENDPATH += . .. PRECOMPILED_HEADER = pch/pch.h +INCLUDEPATH += pch DEFINES += LOG_IN_FILE BUILD_BLACKGUI_LIB QWT_DLL diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index 56f76f0a6..5eafb883b 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -14,6 +14,7 @@ INCLUDEPATH += .. # DEPENDPATH += . .. // BlackMisc should be independent PRECOMPILED_HEADER = pch/pch.h +INCLUDEPATH += pch DEFINES += LOG_IN_FILE BUILD_BLACKMISC_LIB RESOURCES += blackmisc.qrc