Skip to content

Commit

Permalink
add configure test result caching
Browse files Browse the repository at this point in the history
Started-by: Lars Knoll <[email protected]>
Change-Id: I29bafc5913cf95d9908dbcdd9597df2258b69837
Reviewed-by: Lars Knoll <[email protected]>
  • Loading branch information
ossilator authored and laknoll committed Aug 19, 2016
1 parent b62a42d commit ce7df6a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Configure meta:
-redo ................ Re-configure with previously used options.
Additional options may be passed, but will not be
saved for later use by -redo.
-recheck ............. Discard cached negative configure test results.
Use this after installing missing dependencies.
-recheck-all ......... Discard all cached configure test results.

Build options:

Expand Down
15 changes: 15 additions & 0 deletions configure.pri
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ defineTest(qtConfTest_architecture) {
export($${1}.subarch)
qtLog("Detected architecture: $$eval($${1}.arch) ($$eval($${1}.subarch))")

$${1}.cache += arch subarch
export($${1}.cache)
return(true)
}

Expand Down Expand Up @@ -182,9 +184,12 @@ defineTest(qtConfTest_detectPkgConfig) {
export($${1}.pkgConfigLibdir)
$${1}.pkgConfigSysrootDir = $$pkgConfigSysrootDir
export($${1}.pkgConfigSysrootDir)
$${1}.cache += pkgConfigLibdir pkgConfigSysrootDir
}
$${1}.pkgConfig = $$pkgConfig
export($${1}.pkgConfig)
$${1}.cache += pkgConfig
export($${1}.cache)

PKG_CONFIG = $$pkgConfig
export(PKG_CONFIG)
Expand Down Expand Up @@ -215,6 +220,8 @@ defineTest(qtConfTest_skipModules) {
}
$${1}.value = $$unique(skip)
export($${1}.value)
$${1}.cache += value
export($${1}.cache)
return(true)
}

Expand All @@ -236,6 +243,8 @@ defineTest(qtConfTest_buildParts) {

$${1}.value = $$parts
export($${1}.value)
$${1}.cache += value
export($${1}.cache)
return(true)
}

Expand Down Expand Up @@ -283,6 +292,8 @@ defineTest(qtConfTest_checkCompiler) {
export($${1}.compilerDescription)
export($${1}.compilerId)
export($${1}.compilerVersion)
$${1}.cache += compilerDescription compilerId compilerVersion
export($${1}.cache)
return(true)
}

Expand Down Expand Up @@ -409,6 +420,8 @@ defineTest(qtConfTest_xkbConfigRoot) {
exists($$dir) {
$${1}.value = $$dir
export($${1}.value)
$${1}.cache += value
export($${1}.cache)
return(true)
}
}
Expand All @@ -434,6 +447,8 @@ defineTest(qtConfTest_qpaDefaultPlatform) {
export($${1}.value)
export($${1}.plugin)
export($${1}.name)
$${1}.cache += value plugin name
export($${1}.cache)
return(true)
}

Expand Down
71 changes: 71 additions & 0 deletions mkspecs/features/qt_configure.prf
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
CONFIG -= qt debug_and_release
load(configure_base)

QMAKE_CONFIG_CACHE = $$dirname(_QMAKE_CACHE_)/config.cache
QMAKE_CONFIG_CACHE_USE = all

QT_CONFIGURE_REPORT =
QT_CONFIGURE_NOTES =
QT_CONFIGURE_WARNINGS =
Expand Down Expand Up @@ -198,6 +201,17 @@ defineTest(qtConfParseCommandLine) {
next()
}

contains(c, "^--?recheck") {
QMAKE_CONFIG_CACHE_USE = positive
export(QMAKE_CONFIG_CACHE_USE)
next()
}
contains(c, "^--?recheck-all") {
QMAKE_CONFIG_CACHE_USE = none
export(QMAKE_CONFIG_CACHE_USE)
next()
}

!isEmpty(customCall) {
$${customCall}($$c): \
next()
Expand Down Expand Up @@ -499,6 +513,8 @@ defineTest(qtConfTest_getPkgConfigVariable) {
variable = $$eval($${1}.pkg-config-variable)
qtRunLoggedCommand("$$pkg_config --variable=$$variable $$args", $${1}.value)|return(false)
export($${1}.value)
$${1}.cache += value
export($${1}.cache)
return(true)
}

Expand Down Expand Up @@ -562,6 +578,11 @@ defineTest(qtConfHandleLibrary) {

qtConfEnsureTestTypeDeps("library")

qtConfLoadResult($${lpfx}, $$1) {
qtConfExportLibrary($${lpfx}.sources.$$eval($${lpfx}.source), $$eval($${lpfx}.export))
return()
}

qtLogTestIntro($${lpfx})
msg = "looking for library $${1}"
write_file($$QMAKE_CONFIG_LOG, msg, append)
Expand Down Expand Up @@ -596,6 +617,12 @@ defineTest(qtConfHandleLibrary) {
}
}

$${lpfx}.cache += source
for (v, $$list(libs includes cflags version export)): \
$${lpfx}.cache += sources.$${s}.$${v}
for (b, $${spfx}.builds._KEYS_): \
$${lpfx}.cache += sources.$${s}.builds.$${b}

# immediately output the library as well.
qtConfExportLibrary($${spfx}, $$eval($${lpfx}.export))

Expand All @@ -609,6 +636,7 @@ defineTest(qtConfHandleLibrary) {

$${lpfx}.result = $$result
export($${lpfx}.result)
qtConfSaveResult($${lpfx}, $$1)
}

# This is a fake test type for the test dependency system.
Expand Down Expand Up @@ -760,6 +788,28 @@ defineTest(qtLogTestResult) {
write_file($$QMAKE_CONFIG_LOG, msg, append)
}

defineTest(qtConfSaveResult) {
keys = result $$eval($${1}.cache)
cont = "cache.$${2}._KEYS_ = $$keys"
for (k, keys): \
cont += "cache.$${2}.$${k} = $$val_escape($${1}.$${k})"
write_file($$QMAKE_CONFIG_CACHE, cont, append)|error()
}

defineTest(qtConfLoadResult) {
equals(QMAKE_CONFIG_CACHE_USE, none): \
return(false)
isEmpty(cache.$${2}._KEYS_): \
return(false)
equals(QMAKE_CONFIG_CACHE_USE, positive):!$$eval(cache.$${2}.result): \
return(false)
for (k, cache.$${2}._KEYS_) {
$${1}.$${k} = $$eval(cache.$${2}.$${k})
export($${1}.$${k})
}
return(true)
}

defineTest(qtConfIsBoolean) {
equals(1, "true")|equals(1, "false"): \
return(true)
Expand Down Expand Up @@ -832,6 +882,12 @@ defineTest(qtRunSingleTest) {
!$${preCall}($${tpfx}): result = false

$$result {
# note: we do this only after resolving the dependencies and the
# preparation (which may resolve libraries), so that caching does
# not alter the execution order (and thus the output).
qtConfLoadResult($${tpfx}, $$1): \
return()

qtLogTestIntro($${tpfx})
msg = "executing config test $${1}"
write_file($$QMAKE_CONFIG_LOG, msg, append)
Expand All @@ -843,6 +899,7 @@ defineTest(qtRunSingleTest) {

$${tpfx}.result = $$result
export($${tpfx}.result)
qtConfSaveResult($${tpfx}, $$1)
}

defineReplace(qtConfEvaluate) {
Expand Down Expand Up @@ -1496,6 +1553,20 @@ defineTest(qtConfigure) {

qtConfParseCommandLine()

!equals(QMAKE_CONFIG_CACHE_USE, none) {
include($$QMAKE_CONFIG_CACHE, , true)
# this crudely determines when to discard the cache. this also catches the case
# of no cache being there in the first place.
!equals(cache.platform, $$[QMAKE_SPEC])|!equals(cache.xplatform, $$[QMAKE_XSPEC]): \
QMAKE_CONFIG_CACHE_USE = none
}
equals(QMAKE_CONFIG_CACHE_USE, none) {
cont = \
"cache.platform = $$[QMAKE_SPEC]" \
"cache.xplatform = $$[QMAKE_XSPEC]"
write_file($$QMAKE_CONFIG_CACHE, cont)
}

# do early checks, mainly to validate the command line
qtConfProcessEarlyChecks()

Expand Down
1 change: 1 addition & 0 deletions qtbase.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ DISTCLEAN_DEPS += qmake-clean
# config.status (and configure.cache, which is the same for Windows)
# are omitted for convenience of rebuilds.
QMAKE_DISTCLEAN += \
config.cache \
config.summary \
config.tests/.qmake.cache \
mkspecs/qconfig.pri \
Expand Down

0 comments on commit ce7df6a

Please sign in to comment.