Skip to content

Commit

Permalink
move generation of qconfig.cpp (and qt.conf) to qmake-based configure
Browse files Browse the repository at this point in the history
this moves us another step towards the "outer" configure doing just
minimal bootstrapping of qmake.

a challenge here was that so far, qmake itself needed qconfig.cpp. this
was replaced by usage of a qt.conf file instead of compiled-in values.
however, to make the executable still self-contained, that qt.conf is
embedded into it (by simple appending of a fixed signature and the text
file).

the qmake with the embedded qt.conf is not used for the qt build itself,
which instead relies on the qt.conf in bin/ as before. however, due to
the missing built-in values, this file now needs to contain more
information than before. but except for a minimal version that is needed
to start up qmake/configure at all, that file is now also generated with
qmake. as some of the newly set up properties are subsequently used by
configure itself, qmake gains a (deliberately undocumented) function to
reload the qt.conf after it's fully populated.

unlike the old implementations, this one doesn't emit redundant qt.conf
entries which match the hard-coded fallbacks. omitting them leads to
leaner files which are more comprehensible.

Started-by: Paolo Angelelli <[email protected]>
Change-Id: I4526ef64b3c89d9851e10f83965fe479ed7f39f6
Reviewed-by: Jake Petroules <[email protected]>
  • Loading branch information
ossilator committed Dec 13, 2016
1 parent 42196f4 commit 169a40d
Show file tree
Hide file tree
Showing 17 changed files with 397 additions and 848 deletions.
420 changes: 3 additions & 417 deletions configure

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion configure.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"files": {
"builtinQtConf": "qmake/builtin-qt.conf",
"qconfigSource": "src/corelib/global/qconfig.cpp",
"publicHeader": "src/corelib/global/qconfig.h",
"privateHeader": "src/corelib/global/qconfig_p.h",
"publicPro": "mkspecs/qconfig.pri",
Expand Down Expand Up @@ -43,7 +45,7 @@
"libexecdir": "string",
"plugindir": "string",
"qmldir": "string",
"settingsdir": "string",
"settingsdir": { "type": "string", "name": "sysconfdir" },
"sysconfdir": "string",
"testsdir": "string",
"translationdir": "string",
Expand Down Expand Up @@ -416,6 +418,9 @@
},

"features": {
"prepare": {
"output": [ "preparePaths" ]
},
"android-style-assets": {
"label": "Android Style Assets",
"condition": "config.android",
Expand Down Expand Up @@ -967,6 +972,10 @@
},

"earlyReport": [
{
"condition": "!features.prepare",
"comment": "This is not an actual report - instead, it activates the early setup."
},
{
"type": "fatal",
"condition": "!call.licenseCheck",
Expand Down
231 changes: 231 additions & 0 deletions configure.pri
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,237 @@ defineTest(qtConfTest_checkCompiler) {

# custom outputs

# type (empty or 'host'), option name, default value
defineTest(processQtPath) {
out_var = config.rel_input.$${2}
path = $$eval(config.input.$${2})
isEmpty(path) {
$$out_var = $$3
} else {
path = $$absolute_path($$path, $$OUT_PWD)
rel = $$relative_path($$path, $$eval(config.input.$${1}prefix))
isEmpty(rel) {
$$out_var = .
} else: contains(rel, \.\..*) {
!equals(2, sysconfdir) {
PREFIX_COMPLAINTS += "-$$2 is not a subdirectory of -$${1}prefix."
export(PREFIX_COMPLAINTS)
!$$eval(have_$${1}prefix) {
PREFIX_REMINDER = true
export(PREFIX_REMINDER)
}
}
$$out_var = $$path
} else {
$$out_var = $$rel
}
}
export($$out_var)
}

defineTest(addConfStr) {
QT_CONFIGURE_STR_OFFSETS += " $$QT_CONFIGURE_STR_OFF,"
QT_CONFIGURE_STRS += " \"$$1\\0\""
QT_CONFIGURE_STR_OFF = $$num_add($$QT_CONFIGURE_STR_OFF, $$str_size($$1), 1)
export(QT_CONFIGURE_STR_OFFSETS)
export(QT_CONFIGURE_STRS)
export(QT_CONFIGURE_STR_OFF)
}

defineReplace(printInstallPath) {
val = $$eval(config.rel_input.$$2)
equals(val, $$3): return()
return("$$1=$$val")
}
defineReplace(printInstallPaths) {
ret = \
$$printInstallPath(Documentation, docdir, doc) \
$$printInstallPath(Headers, headerdir, include) \
$$printInstallPath(Libraries, libdir, lib) \
$$printInstallPath(LibraryExecutables, libexecdir, $$DEFAULT_LIBEXEC) \
$$printInstallPath(Binaries, bindir, bin) \
$$printInstallPath(Plugins, plugindir, plugins) \
$$printInstallPath(Imports, importdir, imports) \
$$printInstallPath(Qml2Imports, qmldir, qml) \
$$printInstallPath(ArchData, archdatadir, .) \
$$printInstallPath(Data, datadir, .) \
$$printInstallPath(Translations, translationdir, translations) \
$$printInstallPath(Examples, examplesdir, examples) \
$$printInstallPath(Tests, testsdir, tests)
return($$ret)
}
defineReplace(printHostPaths) {
ret = \
"HostPrefix=$$config.input.hostprefix" \
$$printInstallPath(HostBinaries, hostbindir, bin) \
$$printInstallPath(HostLibraries, hostlibdir, lib) \
$$printInstallPath(HostData, hostdatadir, .) \
"Sysroot=$$config.input.sysroot" \
"TargetSpec=$$[QMAKE_XSPEC]" \
"HostSpec=$$[QMAKE_SPEC]"
return($$ret)
}
defineTest(qtConfOutput_preparePaths) {
isEmpty(config.input.prefix) {
$$qtConfEvaluate("features.developer-build"): \
config.input.prefix = $$QT_BUILD_TREE # In Development, we use sandboxed builds by default
else: \
config.input.prefix = /usr/local/Qt-$$[QT_VERSION]
have_prefix = false
} else {
config.input.prefix = $$absolute_path($$config.input.prefix, $$OUT_PWD)
have_prefix = true
}
isEmpty(config.input.extprefix) {
config.input.extprefix = $$config.input.prefix
!isEmpty(config.input.sysroot): \
qmake_sysrootify = true
else: \
qmake_sysrootify = false
} else {
config.input.extprefix = $$absolute_path($$config.input.extprefix, $$OUT_PWD)
qmake_sysrootify = false
}
isEmpty(config.input.hostprefix) {
$$qmake_sysrootify: \
config.input.hostprefix = $$config.input.sysroot$$config.input.extprefix
else: \
config.input.hostprefix = $$config.input.extprefix
have_hostprefix = false
} else {
isEqual(config.input.hostprefix, yes): \
config.input.hostprefix = $$QT_BUILD_TREE
else: \
config.input.hostprefix = $$absolute_path($$config.input.hostprefix, $$OUT_PWD)
have_hostprefix = true
}
PREFIX_COMPLAINTS =
PREFIX_REMINDER = false
win32: \
DEFAULT_LIBEXEC = bin
else: \
DEFAULT_LIBEXEC = libexec
darwin: \
DEFAULT_SYSCONFDIR = /Library/Preferences/Qt
else: \
DEFAULT_SYSCONFDIR = etc/xdg
processQtPath("", headerdir, include)
processQtPath("", libdir, lib)
processQtPath("", bindir, bin)
processQtPath("", datadir, .)
!equals(config.rel_input.datadir, .): \
data_pfx = $$config.rel_input.datadir/
processQtPath("", docdir, $${data_pfx}doc)
processQtPath("", translationdir, $${data_pfx}translations)
processQtPath("", examplesdir, $${data_pfx}examples)
processQtPath("", testsdir, tests)
processQtPath("", archdatadir, .)
!equals(config.rel_input.archdatadir, .): \
archdata_pfx = $$config.rel_input.archdatadir/
processQtPath("", libexecdir, $${archdata_pfx}$$DEFAULT_LIBEXEC)
processQtPath("", plugindir, $${archdata_pfx}plugins)
processQtPath("", importdir, $${archdata_pfx}imports)
processQtPath("", qmldir, $${archdata_pfx}qml)
processQtPath("", sysconfdir, $$DEFAULT_SYSCONFDIR)
$$have_hostprefix {
processQtPath(host, hostbindir, bin)
processQtPath(host, hostlibdir, lib)
processQtPath(host, hostdatadir, .)
} else {
processQtPath(host, hostbindir, $$config.rel_input.bindir)
processQtPath(host, hostlibdir, $$config.rel_input.libdir)
processQtPath(host, hostdatadir, $$config.rel_input.archdatadir)
}
!isEmpty(PREFIX_COMPLAINTS) {
PREFIX_COMPLAINTS = "$$join(PREFIX_COMPLAINTS, "$$escape_expand(\\n)Note: ")"
$$PREFIX_REMINDER: \
PREFIX_COMPLAINTS += "Maybe you forgot to specify -prefix/-hostprefix?"
qtConfAddNote($$PREFIX_COMPLAINTS)
}
# populate qconfig.cpp (for qtcore)
QT_CONFIGURE_STR_OFF = 0
QT_CONFIGURE_STR_OFFSETS =
QT_CONFIGURE_STRS =
addConfStr($$config.rel_input.docdir)
addConfStr($$config.rel_input.headerdir)
addConfStr($$config.rel_input.libdir)
addConfStr($$config.rel_input.libexecdir)
addConfStr($$config.rel_input.bindir)
addConfStr($$config.rel_input.plugindir)
addConfStr($$config.rel_input.importdir)
addConfStr($$config.rel_input.qmldir)
addConfStr($$config.rel_input.archdatadir)
addConfStr($$config.rel_input.datadir)
addConfStr($$config.rel_input.translationdir)
addConfStr($$config.rel_input.examplesdir)
addConfStr($$config.rel_input.testsdir)
$${currentConfig}.output.qconfigSource = \
"/* Installation date */" \
"static const char qt_configure_installation [12+11] = \"qt_instdate=2012-12-20\";" \
"" \
"/* Installation Info */" \
"static const char qt_configure_prefix_path_str [12+256] = \"qt_prfxpath=$$config.input.prefix\";" \
"" \
"static const short qt_configure_str_offsets[] = {" \
$$QT_CONFIGURE_STR_OFFSETS \
"};" \
"static const char qt_configure_strs[] =" \
$$QT_CONFIGURE_STRS \
";" \
"" \
"$${LITERAL_HASH}define QT_CONFIGURE_SETTINGS_PATH \"$$config.rel_input.sysconfdir\"" \
"" \
"$${LITERAL_HASH}define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12"
export($${currentConfig}.output.qconfigSource)

# populate qmake/builtin-qt.conf

$${currentConfig}.output.builtinQtConf = \
" " \
"===========================================================" \
"==================== qt.conf beginning ====================" \
"===========================================================" \
"[Paths]" \
"ExtPrefix=$$config.input.extprefix" \
"Prefix=$$config.input.prefix" \
$$printInstallPaths() \
"Settings=$$config.rel_input.sysconfdir" \
$$printHostPaths()
export($${currentConfig}.output.builtinQtConf)

# create bin/qt.conf. this doesn't use the regular file output
# mechanism, as the file is relied upon by configure tests.

cont = \
"[EffectivePaths]" \
"Prefix=.." \
"[DevicePaths]" \
"Prefix=$$config.input.prefix" \
$$printInstallPaths() \
"[Paths]" \
"Prefix=$$config.input.extprefix" \
$$printInstallPaths() \
$$printHostPaths()
!equals(QT_SOURCE_TREE, $$QT_BUILD_TREE): \
cont += \
"[EffectiveSourcePaths]" \
"Prefix=$$QT_SOURCE_TREE"
write_file($$QT_BUILD_TREE/bin/qt.conf, cont)|error()
reload_properties()
}

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

Expand Down
2 changes: 1 addition & 1 deletion mkspecs/features/qt_configure.prf
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ defineTest(qtConfProcessOutput) {
$${currentConfig}.output.$$type += "$$k -= $$eval($${currentConfig}.output.$${type}.remove.$$k)"
for (k, $${currentConfig}.output.$${type}.append._KEYS_): \
$${currentConfig}.output.$$type += "$$k += $$eval($${currentConfig}.output.$${type}.append.$$k)"
} else {
} else: contains(type, ".*Header") {
for (define, $${currentConfig}.output.$${type}._KEYS_) {
value = $$eval($${currentConfig}.output.$${type}.$${define})
$${currentConfig}.output.$$type += "$${LITERAL_HASH}define $$define $$value"
Expand Down
3 changes: 1 addition & 2 deletions qmake/Makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ DEPEND_SRC = \
$(SOURCE_PATH)/src/corelib/io/qdir.cpp $(SOURCE_PATH)/src/corelib/plugin/quuid.cpp \
$(SOURCE_PATH)/src/corelib/io/qfileinfo.cpp $(SOURCE_PATH)/src/corelib/tools/qdatetime.cpp \
$(SOURCE_PATH)/src/corelib/tools/qstringlist.cpp $(SOURCE_PATH)/src/corelib/tools/qmap.cpp \
$(SOURCE_PATH)/src/corelib/global/qconfig.cpp \
$(SOURCE_PATH)/src/corelib/tools/qstringbuilder.cpp \
$(SOURCE_PATH)/src/corelib/tools/qlocale.cpp \
$(SOURCE_PATH)/src/corelib/tools/qlocale_tools.cpp \
Expand Down Expand Up @@ -225,7 +224,7 @@ qsettings.o: $(SOURCE_PATH)/src/corelib/io/qsettings.cpp
qsystemerror.o: $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp

qlibraryinfo.o: $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp $(BUILD_PATH)/src/corelib/global/qconfig.cpp
qlibraryinfo.o: $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp

qnumeric.o: $(SOURCE_PATH)/src/corelib/global/qnumeric.cpp
Expand Down
2 changes: 0 additions & 2 deletions qmake/Makefile.win32
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ $(OBJS): $(PCH_OBJECT)

$(QTOBJS): $(PCH_OBJECT)

qlibraryinfo.obj: $(BUILD_PATH)\src\corelib\global\qconfig.cpp

qmake_pch.obj:
$(CXX) $(CXXFLAGS_BARE) -c -Yc -Fpqmake_pch.pch -TP $(QMKSRC)\qmake_pch.h

Expand Down
8 changes: 7 additions & 1 deletion qmake/library/qmakebuiltins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ enum TestFunc {
T_EXISTS, T_EXPORT, T_CLEAR, T_UNSET, T_EVAL, T_CONFIG, T_SYSTEM,
T_DEFINED, T_DISCARD_FROM, T_CONTAINS, T_INFILE,
T_COUNT, T_ISEMPTY, T_PARSE_JSON, T_INCLUDE, T_LOAD, T_DEBUG, T_LOG, T_MESSAGE, T_WARNING, T_ERROR, T_IF,
T_MKPATH, T_WRITE_FILE, T_TOUCH, T_CACHE
T_MKPATH, T_WRITE_FILE, T_TOUCH, T_CACHE, T_RELOAD_PROPERTIES
};

void QMakeEvaluator::initFunctionStatics()
Expand Down Expand Up @@ -200,6 +200,7 @@ void QMakeEvaluator::initFunctionStatics()
{ "write_file", T_WRITE_FILE },
{ "touch", T_TOUCH },
{ "cache", T_CACHE },
{ "reload_properties", T_RELOAD_PROPERTIES },
};
statics.functions.reserve((int)(sizeof(testInits)/sizeof(testInits[0])));
for (unsigned i = 0; i < sizeof(testInits)/sizeof(testInits[0]); ++i)
Expand Down Expand Up @@ -2015,6 +2016,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
}
return writeFile(fL1S("cache "), fn, QIODevice::Append, false, varstr);
}
case T_RELOAD_PROPERTIES:
#ifdef QT_BUILD_QMAKE
m_option->reloadProperties();
#endif
return ReturnTrue;
default:
evalError(fL1S("Function '%1' is not implemented.").arg(function.toQString(m_tmp1)));
return ReturnFalse;
Expand Down
1 change: 1 addition & 0 deletions qmake/library/qmakeglobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class QMAKE_EXPORT QMakeGlobals
void setDirectories(const QString &input_dir, const QString &output_dir);
#ifdef QT_BUILD_QMAKE
void setQMakeProperty(QMakeProperty *prop) { property = prop; }
void reloadProperties() { property->reload(); }
ProString propertyValue(const ProKey &name) const { return property->value(name); }
#else
# ifdef PROEVALUATOR_INIT_PROPS
Expand Down
5 changes: 5 additions & 0 deletions qmake/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,11 @@ qmakeAddCacheClear(qmakeCacheClearFunc func, void **data)
cache_items.append(new QMakeCacheClearItem(func, data));
}

QString qmake_absoluteLocation()
{
return Option::globals->qmake_abslocation;
}

QString qmake_libraryInfoFile()
{
if (!Option::globals->qtconf.isEmpty())
Expand Down
6 changes: 6 additions & 0 deletions qmake/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ static const struct {

QMakeProperty::QMakeProperty() : settings(0)
{
reload();
}

void QMakeProperty::reload()
{
QLibraryInfo::reload();
for (unsigned i = 0; i < sizeof(propList)/sizeof(propList[0]); i++) {
QString name = QString::fromLatin1(propList[i].name);
if (!propList[i].singular) {
Expand Down
2 changes: 2 additions & 0 deletions qmake/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class QMakeProperty
QMakeProperty();
~QMakeProperty();

void reload();

bool hasValue(const ProKey &);
ProString value(const ProKey &);

Expand Down
Loading

0 comments on commit 169a40d

Please sign in to comment.