Added support for ccache.
This commit is contained in:
parent
d6e3dfcbb3
commit
ea1195f9fa
qbs
|
@ -24,10 +24,16 @@ CppApplication {
|
|||
installDebugInformation: true
|
||||
type: base.concat("testSuit")
|
||||
|
||||
Properties {
|
||||
condition: qbs.targetOS.contains("unix") && buildconfig.buildWithCcache
|
||||
cpp.compilerWrapper: "ccache"
|
||||
}
|
||||
|
||||
Properties {
|
||||
condition: Qt.core.versionMajor >= 5 && Qt.core.versionMinor < 12
|
||||
cpp.cxxLanguageVersion: "c++11"
|
||||
}
|
||||
|
||||
// Since Qt 5.12 available support for C++17
|
||||
Properties {
|
||||
condition: Qt.core.versionMajor >= 5 && Qt.core.versionMinor >= 12
|
||||
|
|
|
@ -19,6 +19,11 @@ Library {
|
|||
cpp.rpaths: cpp.rpathOrigin
|
||||
}
|
||||
|
||||
Properties {
|
||||
condition: qbs.targetOS.contains("unix") && buildconfig.buildWithCcache
|
||||
cpp.compilerWrapper: "ccache"
|
||||
}
|
||||
|
||||
install: !buildconfig.staticBuild
|
||||
installDir: buildconfig.installLibraryPath
|
||||
installDebugInformation: !buildconfig.staticBuild
|
||||
|
|
|
@ -20,6 +20,14 @@ Module {
|
|||
// distributions which provides not enough space on build servers.
|
||||
property bool enablePCH: true
|
||||
|
||||
Depends { name: "ccache"; }
|
||||
|
||||
// Use this property to disable the use of ccache.
|
||||
property bool enableCcache: true
|
||||
readonly property bool ccachePresent: ccache.ccachePresent
|
||||
readonly property bool ccachePCHSupport: ccache.pchSupport
|
||||
readonly property bool buildWithCcache: enableCcache && (enablePCH && ccachePresent && ccachePCHSupport || (!enablePCH && ccachePresent))
|
||||
|
||||
property string libDirName: "lib"
|
||||
|
||||
property string appTarget
|
||||
|
|
65
qbs/modules/ccache/ccache.qbs
Normal file
65
qbs/modules/ccache/ccache.qbs
Normal file
|
@ -0,0 +1,65 @@
|
|||
import qbs.Process
|
||||
import qbs.Utilities
|
||||
|
||||
// Don't forget to edit ccache config:
|
||||
// ccache --set-config=sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime
|
||||
Module {
|
||||
readonly property bool ccachePresent: ccacheProbe.present
|
||||
readonly property bool pchSupport: ccachePCHProbe.pchSupport
|
||||
|
||||
// change to shell tool which supports key "-c" to excecute command line
|
||||
property string shellTool: "bash"
|
||||
|
||||
// ccache doesn't provide key to get only version number
|
||||
readonly property string command: "ccache --version | head -n 1 | grep -oE '[0-9]((\.)[0-9]){0,2}'"
|
||||
|
||||
Probe {
|
||||
id: ccacheProbe
|
||||
|
||||
property bool present
|
||||
property string tool: shellTool
|
||||
property string toolCommand: command
|
||||
|
||||
configure: {
|
||||
var detector = new Process();
|
||||
try {
|
||||
if (detector.exec(tool, ["-c", toolCommand]) === 0) {
|
||||
var version = detector.readStdOut().trim(); // we can read only one time
|
||||
present = Utilities.versionCompare(version, "0.0.0") >= 0;
|
||||
console.info("Found ccache version " + version + ".");
|
||||
}
|
||||
} finally {
|
||||
detector.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Probe {
|
||||
id: ccachePCHProbe
|
||||
condition: ccachePresent === true
|
||||
property string tool: shellTool
|
||||
property string toolCommand: command
|
||||
|
||||
property bool pchSupport
|
||||
|
||||
configure: {
|
||||
var detector = new Process();
|
||||
try {
|
||||
if (detector.exec(tool, ["-c", toolCommand]) === 0) {
|
||||
var version = detector.readStdOut().trim(); // we can read only one time
|
||||
|
||||
pchSupport = Utilities.versionCompare(version, "3.1.0") >= 0;
|
||||
if (!pchSupport && Utilities.versionCompare(version, "3.1.0") < 0){
|
||||
console.info("ccache is tool old, version >= 3.1.0 required to work with precompiled headers.");
|
||||
pchSupport = false;
|
||||
}
|
||||
|
||||
if (pchSupport)
|
||||
console.info("ccache supports compilation with precompiled headers.")
|
||||
}
|
||||
} finally {
|
||||
detector.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user