Skip to content

Commit

Permalink
Modularize the new configure system (infrastructure part)
Browse files Browse the repository at this point in the history
This change implements the required infrastructure to modularize the new
configuration system.

This requires a hierarchy of configuration files, both for handling
multiple repositories and for individual modules inside the same
repository.

When configuring, they all need to get loaded first, as command line
processing needs to know about all possible command line options.

When the command line has been processed, the individual configuration
files need to get processed one after the other and independently from
each other.

Configure is now automatically invoked when building the a project
tree's "root" project; this works with both modular and top-level builds
of Qt (the latter with an according change in the super repo). As an
immediate consequence, the -skip option moves to the super repo with a
different implementation, as configuration is now done after the repo
list is determined. The option belongs there anyway.

This commit also adds an optional testDir entry to the json file. Like
this, we can still have all configure tests in qtbase/config.tests and
the configuration file in, e.g., corelib can reference those.

The files section can now be left out as long as a 'module' entry is
present, specifying the module name. The names of the files to generate
can then be deduced from that name. We still need to be able to specify
names directly for the global configuration files.

qtConfig() now also queries features which are module-specific. As it is
sometimes necessary to query the configuration of modules which should
not be actually linked (and cannot in the case of subdirs projects), the
new variable QT_FOR_CONFIG which allows specifying configuration-only
dependencies is introduced.

Done-with: Oswald Buddenhagen <[email protected]>
Change-Id: Id1b518a3aa34044748b87fb8fac14d79653f6b18
Reviewed-by: Lars Knoll <[email protected]>
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
laknoll committed Sep 10, 2016
1 parent 137e690 commit 60e5a1c
Show file tree
Hide file tree
Showing 16 changed files with 486 additions and 276 deletions.
2 changes: 2 additions & 0 deletions bin/syncqt.pl
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ sub isQpaHeader
if (opendir DIR, $subdir) {
foreach my $t (sort { $b cmp $a } readdir(DIR)) {
next if ($t =~ /\.pri$/);
next if ($t =~ /^qt[a-z0-9]+-config(_p)?\.h$/);
my $file = "$subdir/$t";
if(-d $file) {
push @subdirs, $file unless($t eq "." || $t eq "..");
Expand Down Expand Up @@ -985,6 +986,7 @@ sub isQpaHeader
#calc files and "copy" them
foreach my $subdir (@subdirs) {
my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0);
@headers = grep(!/^qt[a-z0-9]+-config(_p)?\.h$/, @headers);
if (defined $inject_headers{$subdir}) {
foreach my $if (@{$inject_headers{$subdir}}) {
@headers = grep(!/^\Q$if\E$/, @headers); #in case we configure'd previously
Expand Down
32 changes: 14 additions & 18 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1911,31 +1911,15 @@ done
set +f
IFS=$SAVED_IFS

# redirect qmake's output to a dummy Makefile
$CFG_QMAKE_PATH -o Makefile.cfg -qtconf "$QTCONFFILE" $relpath/configure.pri -- "$@" || exit 101
rm Makefile.cfg

#-------------------------------------------------------------------------------
# give feedback on configuration
#-------------------------------------------------------------------------------

if [ -n "$PLATFORM_NOTES" ]; then
echo
echo "Platform notes:"
echo "$PLATFORM_NOTES"
else
echo
fi

#-------------------------------------------------------------------------------
# build makefiles based on the configuration
# configure and build top-level makefile
#-------------------------------------------------------------------------------

if [ -n "$CFG_TOPLEVEL" ]; then
cd ..
fi

"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" "$relpathMangled" || exit
"$CFG_QMAKE_PATH" -qtconf "$QTCONFFILE" "$relpathMangled" -- "$@" || exit

#-------------------------------------------------------------------------------
# finally save the executed command to another script
Expand All @@ -1955,6 +1939,18 @@ if [ $CFG_REDO = no ]; then
chmod +x config.status
fi

#-------------------------------------------------------------------------------
# final notes for the user
#-------------------------------------------------------------------------------

if [ -n "$PLATFORM_NOTES" ]; then
echo
echo "Platform notes:"
echo "$PLATFORM_NOTES"
else
echo
fi

if [ -n "$PREFIX_COMPLAINTS" ]; then
echo
echo "$PREFIX_COMPLAINTS"
Expand Down
7 changes: 0 additions & 7 deletions configure.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
"separate-debug-info": { "type": "boolean", "name": "separate_debug_info" },
"shared": "boolean",
"silent": "void",
"skip": "addString",
"slog2": "boolean",
"sm": { "type": "boolean", "name": "sessionmanager" },
"sql-db2": "boolean",
Expand Down Expand Up @@ -857,9 +856,6 @@
"type": "compile",
"test": "unix/reduce_relocs"
},
"skip_modules": {
"type": "skipModules"
},
"build_parts": {
"type": "buildParts"
},
Expand Down Expand Up @@ -2096,9 +2092,6 @@
"condition": "libs.host_dbus",
"output": [ { "type": "varAppend", "name": "QT_HOST_CFLAGS_DBUS", "value": "libs.host_dbus.cflags", "eval": "true" } ]
},
"skip_modules": {
"output": [ { "type": "varAssign", "name": "QT_SKIP_MODULES", "value": "tests.skip_modules.value" } ]
},
"build_parts": {
"output": [ { "type": "varAppend", "name": "QT_BUILD_PARTS", "value": "tests.build_parts.value" } ]
},
Expand Down
96 changes: 36 additions & 60 deletions configure.pri
Original file line number Diff line number Diff line change
Expand Up @@ -195,34 +195,10 @@ defineTest(qtConfTest_detectPkgConfig) {
}

defineTest(qtConfTest_neon) {
contains(config.tests.architecture.subarch, "neon"): return(true)
contains($${currentConfig}.tests.architecture.subarch, "neon"): return(true)
return(false)
}

defineTest(qtConfTest_skipModules) {
$${1}.cache = -
export($${1}.cache)

skip =
uikit {
skip += qtdoc qtmacextras qtserialport qtwebkit qtwebkit-examples
!ios: skip += qtscript
}

for (m, config.input.skip) {
# normalize the command line input
m ~= s/^(qt)?/qt/
!exists($$_PRO_FILE_PWD_/../$$m) {
qtConfAddError("-skip command line argument called with non-existent module '$$m'.")
return(false)
}
skip += $$m
}
$${1}.value = $$unique(skip)
export($${1}.value)
return(true)
}

defineTest(qtConfTest_buildParts) {
parts = $$config.input.make
isEmpty(parts) {
Expand Down Expand Up @@ -491,10 +467,10 @@ defineTest(qtConfOutput_architecture) {
"QT_ARCH = $$arch"
}

config.output.publicPro += $$publicPro
export(config.output.publicPro)
config.output.privatePro += $$privatePro
export(config.output.privatePro)
$${currentConfig}.output.publicPro += $$publicPro
export($${currentConfig}.output.publicPro)
$${currentConfig}.output.privatePro += $$privatePro
export($${currentConfig}.output.privatePro)

# setup QT_ARCH variable used by qtConfEvaluate
QT_ARCH = $$arch
Expand Down Expand Up @@ -522,15 +498,15 @@ defineTest(qtConfOutput_qreal) {
defineTest(qtConfOutput_pkgConfig) {
!$${2}: return()

PKG_CONFIG = $$eval(config.tests.pkg-config.pkgConfig)
PKG_CONFIG = $$eval($${currentConfig}.tests.pkg-config.pkgConfig)
export(PKG_CONFIG)
# this method also exports PKG_CONFIG_(LIB|SYSROOT)DIR, so that tests using pkgConfig will work correctly
PKG_CONFIG_SYSROOT_DIR = $$eval(config.tests.pkg-config.pkgConfigSysrootDir)
PKG_CONFIG_SYSROOT_DIR = $$eval($${currentConfig}.tests.pkg-config.pkgConfigSysrootDir)
!isEmpty(PKG_CONFIG_SYSROOT_DIR) {
qtConfOutputVar(assign, "publicPro", "PKG_CONFIG_SYSROOT_DIR", $$PKG_CONFIG_SYSROOT_DIR)
export(PKG_CONFIG_SYSROOT_DIR)
}
PKG_CONFIG_LIBDIR = $$eval(config.tests.pkg-config.pkgConfigLibdir)
PKG_CONFIG_LIBDIR = $$eval($${currentConfig}.tests.pkg-config.pkgConfigLibdir)
!isEmpty(PKG_CONFIG_LIBDIR) {
qtConfOutputVar(assign, "publicPro", "PKG_CONFIG_LIBDIR", $$PKG_CONFIG_LIBDIR)
export(PKG_CONFIG_LIBDIR)
Expand Down Expand Up @@ -560,47 +536,47 @@ defineTest(qtConfOutput_debugAndRelease) {
defineTest(qtConfOutput_compilerVersion) {
!$${2}: return()

name = $$upper($$config.tests.compiler.compilerId)
version = $$config.tests.compiler.compilerVersion
name = $$upper($$eval($${currentConfig}.tests.compiler.compilerId))
version = $$eval($${currentConfig}.tests.compiler.compilerVersion)
major = $$section(version, '.', 0, 0)
minor = $$section(version, '.', 1, 1)
patch = $$section(version, '.', 2, 2)
isEmpty(minor): minor = 0
isEmpty(patch): patch = 0

config.output.publicPro += \
$${currentConfig}.output.publicPro += \
"QT_$${name}_MAJOR_VERSION = $$major" \
"QT_$${name}_MINOR_VERSION = $$minor" \
"QT_$${name}_PATCH_VERSION = $$patch"

export(config.output.publicPro)
export($${currentConfig}.output.publicPro)
}

# should go away when qfeatures.txt is ported
defineTest(qtConfOutput_extraFeatures) {
isEmpty(config.input.extra_features): return()

# write to qconfig.pri
config.output.publicPro += "$${LITERAL_HASH}ifndef QT_BOOTSTRAPPED"
$${currentConfig}.output.publicPro += "$${LITERAL_HASH}ifndef QT_BOOTSTRAPPED"
for (f, config.input.extra_features) {
feature = $$replace(f, "^no-", "")
FEATURE = $$upper($$replace(feature, -, _))
contains(f, "^no-.*") {
config.output.publicPro += \
$${currentConfig}.output.publicPro += \
"$${LITERAL_HASH}ifndef QT_NO_$$FEATURE" \
"$${LITERAL_HASH}define QT_NO_$$FEATURE" \
"$${LITERAL_HASH}endif"
} else {
config.output.publicPro += \
$${currentConfig}.output.publicPro += \
"$${LITERAL_HASH}if defined(QT_$$FEATURE) && defined(QT_NO_$$FEATURE)" \
"$${LITERAL_HASH}undef QT_$$FEATURE" \
"$${LITERAL_HASH}elif !defined(QT_$$FEATURE) && !defined(QT_NO_$$FEATURE)" \
"$${LITERAL_HASH}define QT_$$FEATURE" \
"$${LITERAL_HASH}endif"
}
}
config.output.publicPro += "$${LITERAL_HASH}endif"
export(config.output.publicPro)
$${currentConfig}.output.publicPro += "$${LITERAL_HASH}endif"
export($${currentConfig}.output.publicPro)

# write to qmodule.pri
disabled_features =
Expand Down Expand Up @@ -649,8 +625,8 @@ defineTest(qtConfOutput_compilerFlags) {
output += "EXTRA_FRAMEWORKPATH += $$val_escape(config.input.fpaths)"
}

config.output.privatePro += $$output
export(config.output.privatePro)
$${currentConfig}.output.privatePro += $$output
export($${currentConfig}.output.privatePro)
}

defineTest(qtConfOutput_gccSysroot) {
Expand All @@ -670,21 +646,21 @@ defineTest(qtConfOutput_gccSysroot) {
" QMAKE_CXXFLAGS += --sysroot=\$\$[QT_SYSROOT]" \
" QMAKE_LFLAGS += --sysroot=\$\$[QT_SYSROOT]" \
"}"
config.output.publicPro += $$output
export(config.output.publicPro)
$${currentConfig}.output.publicPro += $$output
export($${currentConfig}.output.publicPro)
}

defineTest(qtConfOutput_qmakeArgs) {
!$${2}: return()

config.output.privatePro = "!host_build {"
$${currentConfig}.output.privatePro = "!host_build {"
for (a, config.input.qmakeArgs) {
config.output.privatePro += " $$a"
$${currentConfig}.output.privatePro += " $$a"
EXTRA_QMAKE_ARGS += $$system_quote($$a)
}
config.output.privatePro += "}"
$${currentConfig}.output.privatePro += "}"
export(EXTRA_QMAKE_ARGS)
export(config.output.privatePro)
export($${currentConfig}.output.privatePro)
}

defineTest(qtConfOutputPostProcess_publicPro) {
Expand All @@ -706,8 +682,8 @@ defineTest(qtConfOutputPostProcess_publicPro) {
"QT_RELEASE_DATE = $$config.input.qt_release_date"
}

config.output.publicPro += $$output
export(config.output.publicPro)
$${currentConfig}.output.publicPro += $$output
export($${currentConfig}.output.publicPro)
}

defineTest(qtConfOutputPostProcess_publicHeader) {
Expand All @@ -729,8 +705,8 @@ defineTest(qtConfOutputPostProcess_publicHeader) {
!isEmpty(config.input.qt_libinfix): \
output += "$${LITERAL_HASH}define QT_LIBINFIX \"$$eval(config.input.qt_libinfix)\""

config.output.publicHeader += $$output
export(config.output.publicHeader)
$${currentConfig}.output.publicHeader += $$output
export($${currentConfig}.output.publicHeader)
}


Expand All @@ -748,7 +724,7 @@ defineTest(qtConfReport_buildTypeAndConfig) {
qtConfAddReport("Building for: $$qtConfEvaluate('tests.architecture.arch')")
}
qtConfAddReport()
qtConfAddReport("Configuration: $$config.output.privatePro.append.CONFIG $$config.output.publicPro.append.QT_CONFIG")
qtConfAddReport("Configuration: $$eval($${currentConfig}.output.privatePro.append.CONFIG) $$eval($${currentConfig}.output.publicPro.append.QT_CONFIG)")
qtConfAddReport()
}

Expand All @@ -775,10 +751,10 @@ defineTest(qtConfReport_buildMode) {
# ensure pristine environment for configuration
discard_from($$[QT_HOST_DATA/get]/mkspecs/qconfig.pri)
discard_from($$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)
# ... and cause them to be reloaded afterwards
QMAKE_POST_CONFIGURE += \
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qconfig.pri)" \
"include(\$\$[QT_HOST_DATA/get]/mkspecs/qmodule.pri)"

# load and process input from configure
exists("$$OUT_PWD/config.tests/configure.cfg") {
include("$$OUT_PWD/config.tests/configure.cfg")
}

load(qt_configure)
# load and process input from configure.sh/.exe
include($$shadowed($$PWD)/config.tests/configure.cfg)
2 changes: 2 additions & 0 deletions mkspecs/features/configure.prf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
load(configure_base)

isEmpty(QMAKE_CONFIG_TESTS_DIR): QMAKE_CONFIG_TESTS_DIR = $$_PRO_FILE_PWD_/config.tests

# Try to build the test project in $$QMAKE_CONFIG_TESTS_DIR/$$1
# ($$_PRO_FILE_PWD_/config.tests/$$1 by default).
#
Expand Down
2 changes: 0 additions & 2 deletions mkspecs/features/configure_base.prf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ defineTest(qtRunLoggedCommand) {
return(true)
}

isEmpty(QMAKE_CONFIG_TESTS_DIR): QMAKE_CONFIG_TESTS_DIR = $$_PRO_FILE_PWD_/config.tests

# Ensure that a cache is present. If none was found on startup, this will create
# one in the build directory of the project which loads this feature.
cache()
Expand Down
23 changes: 23 additions & 0 deletions mkspecs/features/qt_build_config.prf
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,26 @@ defineTest(qtNomakeTools) {
export($${d}.CONFIG)
}
}

# This overloads the same function from qt_functions.prf.
# This is not in qt_module.prf, as that gets loaded too late.
defineTest(qtConfig) {
modules = $$QT $$QT_PRIVATE $$QT_FOR_PRIVATE $$QT_FOR_CONFIG
modules ~= s,-private$,_private,g
modules = $$resolve_depends(modules, "QT.", ".depends")
isEmpty(MODULE): \
MODULE = $$section($$list($$basename(_PRO_FILE_)), ., 0, 0)
exists($$OUT_PWD/qt$${MODULE}-config.pri) {
include($$OUT_PWD/qt$${MODULE}-config.pri)
modules += $${MODULE} $${MODULE}_private
}
modules += global global_private
modules = $$reverse(modules)
for (module, modules) {
contains(QT.$${module}.enabled_features, $$1): \
return(true)
contains(QT.$${module}.disabled_features, $$1): \
return(false)
}
error("Could not find feature $${1}.")
}
Loading

0 comments on commit 60e5a1c

Please sign in to comment.