D99 Enable compiler caches

This commit is contained in:
Mat Sutcliffe
2019-02-08 20:27:56 +00:00
parent 08b1141072
commit bb59007656
6 changed files with 50 additions and 10 deletions

35
Jenkinsfile vendored
View File

@@ -1,5 +1,19 @@
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException 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() abortPreviousRunningBuilds()
def builders = [:] def builders = [:]
@@ -147,7 +161,9 @@ builders['Build swift Win32'] = {
throw error throw error
} finally { } finally {
notifyDiscord('Win32', buildResults['swift-win32']) notifyDiscord('Win32', buildResults['swift-win32'])
killDBusDaemon() killWindowsProcess('dbus-daemon.exe')
killWindowsProcess('clcache.exe')
killWindowsProcess('python.exe')
cleanWs deleteDirs: true, notFailBuild: true cleanWs deleteDirs: true, notFailBuild: true
} }
} }
@@ -192,7 +208,9 @@ builders['Build swift Win64'] = {
throw error throw error
} finally { } finally {
notifyDiscord('Win64', buildResults['swift-win64']) notifyDiscord('Win64', buildResults['swift-win64'])
killDBusDaemon() killWindowsProcess('dbus-daemon.exe')
killWindowsProcess('clcache.exe')
killWindowsProcess('python.exe')
cleanWs deleteDirs: true, notFailBuild: true cleanWs deleteDirs: true, notFailBuild: true
} }
} }
@@ -250,7 +268,6 @@ node('master') {
node('master') { node('master') {
try { try {
def regexDevBranch = /develop\/\d+\.\d+\.\d+/
if (env.BRANCH_NAME && env.BRANCH_NAME ==~ regexDevBranch) { if (env.BRANCH_NAME && env.BRANCH_NAME ==~ regexDevBranch) {
stage('Publish') { stage('Publish') {
unstash name: 'swift-linux-64' unstash name: 'swift-linux-64'
@@ -384,8 +401,6 @@ def notifyDiscord(nodeName, buildStatus = 'UNSTABLE') {
} }
def getEolInMonth() { def getEolInMonth() {
def regexDevBranch = /develop\/\d+\.\d+\.\d+/
def regexReleaseBranch = /release\/\d+\.\d+/
if (env.BRANCH_NAME && env.BRANCH_NAME ==~ regexDevBranch) { if (env.BRANCH_NAME && env.BRANCH_NAME ==~ regexDevBranch) {
// 6 month for dev builds // 6 month for dev builds
return 6 return 6
@@ -410,10 +425,10 @@ def shouldUploadSymbols() {
} }
} }
def killDBusDaemon() { def killWindowsProcess(name) {
bat ''' bat """
tasklist /FI "IMAGENAME eq dbus-daemon.exe" 2>NUL | find /I /N "dbus-daemon.exe">NUL tasklist /FI "IMAGENAME eq ${name}" 2>NUL | find /I /N "${name}">NUL
if "%ERRORLEVEL%"=="0" taskkill /f /im dbus-daemon.exe if "%ERRORLEVEL%"=="0" taskkill /f /im ${name}
EXIT 0 EXIT 0
''' """
} }

View File

@@ -53,6 +53,17 @@ include(wordsize.pri)
contains(TEMPLATE, "vc.*"): QMAKE_CXXFLAGS *= /MP 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 # Release build with debug info
################################ ################################

View File

@@ -37,6 +37,7 @@ class Builder:
""" """
print('Preparing environment ...') print('Preparing environment ...')
os.environ['PATH'] += os.pathsep + self._get_qt_binary_path() os.environ['PATH'] += os.pathsep + self._get_qt_binary_path()
self._ccache_prepare()
self._specific_prepare() self._specific_prepare()
print('Updating from datastore ...') print('Updating from datastore ...')
@@ -46,6 +47,15 @@ class Builder:
shared_path = os.path.abspath(os.path.join(source_path, 'resources', 'share')) shared_path = os.path.abspath(os.path.join(source_path, 'resources', 'share'))
datastore.update_shared(host, datastore_version, shared_path) 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): def build(self, jobs, qmake_args, dev_build, eolInMonth):
""" """
Run the build itself. Pass dev_build=True to enable a dev build 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')) print('Setting EOL date to ' + eolDate.strftime('%Y%m%d'))
qmake_call += ['SWIFT_CONFIG.endOfLife=' + 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] qmake_call += ['-r', os.pardir]
subprocess.check_call(qmake_call, env=dict(os.environ)) subprocess.check_call(qmake_call, env=dict(os.environ))

View File

@@ -16,6 +16,7 @@ INCLUDEPATH += ..
DEPENDPATH += . .. DEPENDPATH += . ..
PRECOMPILED_HEADER = pch/pch.h PRECOMPILED_HEADER = pch/pch.h
INCLUDEPATH += pch
DEFINES += LOG_IN_FILE BUILD_BLACKCORE_LIB DEFINES += LOG_IN_FILE BUILD_BLACKCORE_LIB

View File

@@ -28,6 +28,7 @@ else {
DEPENDPATH += . .. DEPENDPATH += . ..
PRECOMPILED_HEADER = pch/pch.h PRECOMPILED_HEADER = pch/pch.h
INCLUDEPATH += pch
DEFINES += LOG_IN_FILE BUILD_BLACKGUI_LIB QWT_DLL DEFINES += LOG_IN_FILE BUILD_BLACKGUI_LIB QWT_DLL

View File

@@ -14,6 +14,7 @@ INCLUDEPATH += ..
# DEPENDPATH += . .. // BlackMisc should be independent # DEPENDPATH += . .. // BlackMisc should be independent
PRECOMPILED_HEADER = pch/pch.h PRECOMPILED_HEADER = pch/pch.h
INCLUDEPATH += pch
DEFINES += LOG_IN_FILE BUILD_BLACKMISC_LIB DEFINES += LOG_IN_FILE BUILD_BLACKMISC_LIB
RESOURCES += blackmisc.qrc RESOURCES += blackmisc.qrc