qt5base-lts/mkspecs/features/exclusive_builds.prf
Tor Arne Vestbø c760d2dbfd Rewrite qmake's exclusive-build feature
We used to compute the default exclusive build directory, eg 'debug', at
configure time, and then set OBJECTS_DIR, MOC_DIR, etc to include this
hard-coded default exclusive build directory. We then had to run a post-
process step where we replaced the 'debug' part with the current actual
exclusive build pass, eg 'release', resulting in long-standing bugs such
as QTBUG-491 where we end up replacing parts of the build output dirs
that were not part of the original exclusive build directory.

We now set the OBJECTS_DIR, MOC_DIR, etc defaults in configure like
before, but they do not include any exclusive-build information. The
exclusive build directory is handled as a separate step in default_post
where we adjust all entries in QMAKE_DIR_REPLACE to be exclusive
directories.

For backwards compatibility the new exclusive build behavior is only
enabled for variables named by QMAKE_DIR_REPLACE_SANE, which for Qt
itself applies globally to everything but DESTDIR, and for libs and
tools also applies to DESTDIR. The reason for leaving out DESTDIR in
the general case is because many tests and examples assume the old
behavior for DESTDIR. A side effect of including all the other
variables for Qt libs and tools is that the PCH output dir will be
uniformly set, which has been an issue on Windows in the past.

The addExclusiveBuilds function now takes two or more arguments,
each argument being the key for an exclusive build, which can be
customized eg. using $$key.{name,target,dir_affix}. Passing more
than two arguments results in three/four/etc-way exclusive builds,
eg debug/release/profile. Exclusive builds can also be combined, eg
static/shared + debug/release by making two calls to the function.

We also handle individual targets of combined exclusive builds,
eg static/shared + debug/release, meaning it is possible to run
'make debug' to build both static-debug and shared-debug.

Task-number: QTBUG-491
Change-Id: I02841dbbd065ac07d413dfb45cfcfe4c013674ac
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
2013-10-25 20:50:51 +02:00

38 lines
951 B
Plaintext

defineTest(addExclusiveBuilds) {
lessThan(ARGC, 2): \
error("addExclusiveBuilds() requires at least two arguments")
!$$join(ARGS, _and_):!fix_output_dirs: \
return(true)
for(build, ARGS) {
isEmpty($${build}.name) {
$${build}.name = $$title($$build)
export($${build}.name)
}
isEmpty($${build}.target) {
$${build}.target = $$lower($$build)
export($${build}.target)
}
isEmpty($${build}.dir_affix) {
$${build}.dir_affix = $$lower($$build)
export($${build}.dir_affix)
}
$${build}.exclusive = $$ARGS
export($${build}.exclusive)
QMAKE_EXCLUSIVE_BUILDS += $$build
}
CONFIG *= exclusive_builds
export(CONFIG)
export(QMAKE_EXCLUSIVE_BUILDS)
return(true)
}
# Default directories to process
QMAKE_DIR_REPLACE = OBJECTS_DIR MOC_DIR RCC_DIR PRECOMPILED_DIR DESTDIR