revert to building qmake with qconfig.cpp
turns out that just appending builtin-qt.conf isn't a good idea: executable-editing tools (objcopy, prelink, etc.) will happily drop the "attachment". a safe method would be adding a proper section to the executable, but there doesn't appear to be an objcopy equivalent in msvc, and using entirely different methods of embedding the file with different toolchains seems like a rather bad idea. so instead go back to the old method of building qmake with a generated qconfig.cpp. of course, as said file is now created by qmake itself, we have to compile qlibraryinfo.cpp a second time, and link a second qmake executable. Task-number: QTBUG-57803 Change-Id: I9e232693550aa870cec154e49cc06add13017cc2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
17b6967f68
commit
52d64fca66
@ -1,6 +1,5 @@
|
||||
{
|
||||
"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",
|
||||
|
@ -748,40 +748,56 @@ defineTest(qtConfOutput_preparePaths) {
|
||||
addConfStr($$config.rel_input.examplesdir)
|
||||
addConfStr($$config.rel_input.testsdir)
|
||||
|
||||
QT_CONFIGURE_STR_OFFSETS_ALL = $$QT_CONFIGURE_STR_OFFSETS
|
||||
QT_CONFIGURE_STRS_ALL = $$QT_CONFIGURE_STRS
|
||||
QT_CONFIGURE_STR_OFFSETS =
|
||||
QT_CONFIGURE_STRS =
|
||||
|
||||
addConfStr($$config.input.sysroot)
|
||||
addConfStr($$qmake_sysrootify)
|
||||
addConfStr($$config.rel_input.hostbindir)
|
||||
addConfStr($$config.rel_input.hostlibdir)
|
||||
addConfStr($$config.rel_input.hostdatadir)
|
||||
addConfStr($$XSPEC)
|
||||
addConfStr($$[QMAKE_SPEC])
|
||||
|
||||
$${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\";" \
|
||||
"$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \
|
||||
"static const char qt_configure_ext_prefix_path_str [12+256] = \"qt_epfxpath=$$config.input.extprefix\";" \
|
||||
"static const char qt_configure_host_prefix_path_str [12+256] = \"qt_hpfxpath=$$config.input.hostprefix\";" \
|
||||
"$${LITERAL_HASH}endif" \
|
||||
"" \
|
||||
"static const short qt_configure_str_offsets[] = {" \
|
||||
$$QT_CONFIGURE_STR_OFFSETS_ALL \
|
||||
"$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \
|
||||
$$QT_CONFIGURE_STR_OFFSETS \
|
||||
"$${LITERAL_HASH}endif" \
|
||||
"};" \
|
||||
"static const char qt_configure_strs[] =" \
|
||||
$$QT_CONFIGURE_STRS_ALL \
|
||||
"$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \
|
||||
$$QT_CONFIGURE_STRS \
|
||||
"$${LITERAL_HASH}endif" \
|
||||
";" \
|
||||
"" \
|
||||
"$${LITERAL_HASH}define QT_CONFIGURE_SETTINGS_PATH \"$$config.rel_input.sysconfdir\"" \
|
||||
"" \
|
||||
"$${LITERAL_HASH}define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12"
|
||||
"$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \
|
||||
"$${LITERAL_HASH} define QT_CONFIGURE_SYSROOTIFY_PREFIX $$qmake_sysrootify" \
|
||||
"$${LITERAL_HASH}endif" \
|
||||
"" \
|
||||
"$${LITERAL_HASH}define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12" \
|
||||
"$${LITERAL_HASH}ifdef QT_BUILD_QMAKE" \
|
||||
"$${LITERAL_HASH} define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12" \
|
||||
"$${LITERAL_HASH} define QT_CONFIGURE_HOST_PREFIX_PATH qt_configure_host_prefix_path_str + 12" \
|
||||
"$${LITERAL_HASH}endif"
|
||||
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.
|
||||
|
||||
|
@ -16,7 +16,7 @@ QOBJS=qtextcodec.o qutfcodec.o qstring.o qstring_compat.o qstringbuilder.o qtext
|
||||
qarraydata.o qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfiledevice.o qfile.o \
|
||||
qfilesystementry.o qfilesystemengine.o qfsfileengine.o qfsfileengine_iterator.o qregexp.o qvector.o \
|
||||
qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o qfileinfo.o qdatetime.o qstringlist.o \
|
||||
qabstractfileengine.o qtemporaryfile.o qmap.o qmetatype.o qsettings.o qsystemerror.o qlibraryinfo.o \
|
||||
qabstractfileengine.o qtemporaryfile.o qmap.o qmetatype.o qsettings.o qsystemerror.o \
|
||||
qvariant.o qvsnprintf.o qlocale.o qlocale_tools.o qlinkedlist.o qnumeric.o \
|
||||
qcryptographichash.o qxmlstream.o qxmlutils.o qlogging.o \
|
||||
qjson.o qjsondocument.o qjsonparser.o qjsonarray.o qjsonobject.o qjsonvalue.o \
|
||||
@ -109,19 +109,24 @@ LFLAGS = $(EXTRA_LFLAGS) $(CONFIG_LFLAGS)
|
||||
|
||||
first all: $(BUILD_PATH)/bin/qmake$(EXEEXT)
|
||||
qmake: $(BUILD_PATH)/bin/qmake$(EXEEXT)
|
||||
binary: $(BUILD_PATH)/qmake/qmake$(EXEEXT)
|
||||
|
||||
$(BUILD_PATH)/bin/qmake$(EXEEXT): $(OBJS) $(QOBJS)
|
||||
$(CXX) -o "$@" $(OBJS) $(QOBJS) $(LFLAGS)
|
||||
$(BUILD_PATH)/bin/qmake$(EXEEXT): $(OBJS) $(QOBJS) qlibraryinfo.o
|
||||
$(CXX) -o "$@" $(OBJS) $(QOBJS) qlibraryinfo.o $(LFLAGS)
|
||||
|
||||
$(BUILD_PATH)/qmake/qmake$(EXEEXT): $(OBJS) $(QOBJS) qlibraryinfo_final.o
|
||||
$(CXX) -o "$@" $(OBJS) $(QOBJS) qlibraryinfo_final.o $(LFLAGS)
|
||||
|
||||
Makefile: $(SOURCE_PATH)/qmake/Makefile.unix
|
||||
@echo "Out of date, please rerun configure"
|
||||
|
||||
clean::
|
||||
$(RM_F) $(OBJS) $(QOBJS)
|
||||
$(RM_F) $(OBJS) $(QOBJS) qlibraryinfo.o qlibraryinfo_final.o
|
||||
|
||||
distclean:: clean
|
||||
$(RM_RF) .deps
|
||||
$(RM_F) $(BUILD_PATH)/bin/qmake$(EXEEXT)
|
||||
$(RM_F) $(BUILD_PATH)/qmake/qmake$(EXEEXT)
|
||||
$(RM_F) Makefile
|
||||
|
||||
depend:
|
||||
@ -227,6 +232,9 @@ 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
|
||||
$(CXX) -c -o $@ $(CXXFLAGS) -DQT_BUILD_QMAKE_BOOTSTRAP $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp
|
||||
|
||||
qlibraryinfo_final.o: $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp $(BUILD_PATH)/src/corelib/global/qconfig.cpp
|
||||
$(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp
|
||||
|
||||
qnumeric.o: $(SOURCE_PATH)/src/corelib/global/qnumeric.cpp
|
||||
|
@ -108,7 +108,6 @@ QTOBJS= \
|
||||
quuid.obj \
|
||||
qvector.obj \
|
||||
qsettings.obj \
|
||||
qlibraryinfo.obj \
|
||||
qvariant.obj \
|
||||
qsettings_win.obj \
|
||||
qmetatype.obj \
|
||||
@ -124,12 +123,16 @@ QTOBJS= \
|
||||
qjsonvalue.obj
|
||||
|
||||
first all: $(BUILD_PATH)\bin\qmake.exe
|
||||
binary: $(BUILD_PATH)\qmake\qmake.exe
|
||||
|
||||
$(BUILD_PATH)\bin\qmake.exe: $(OBJS) $(QTOBJS)
|
||||
$(LINKER) $(LFLAGS) /OUT:$(BUILD_PATH)\bin\qmake.exe $(OBJS) $(QTOBJS) $(PCH_OBJECT) $(LIBS)
|
||||
$(BUILD_PATH)\bin\qmake.exe: $(OBJS) $(QTOBJS) qlibraryinfo.obj
|
||||
$(LINKER) $(LFLAGS) /OUT:$(BUILD_PATH)\bin\qmake.exe $(OBJS) $(QTOBJS) qlibraryinfo.obj $(PCH_OBJECT) $(LIBS)
|
||||
|
||||
$(BUILD_PATH)\qmake\qmake.exe: $(OBJS) $(QTOBJS) qlibraryinfo_final.obj
|
||||
$(LINKER) $(LFLAGS) /OUT:$(BUILD_PATH)\qmake\qmake.exe $(OBJS) $(QTOBJS) qlibraryinfo_final.obj $(PCH_OBJECT) $(LIBS)
|
||||
|
||||
clean::
|
||||
-del $(QTOBJS)
|
||||
-del $(QTOBJS) qlibraryinfo.obj qlibraryinfo_final.obj
|
||||
-del $(OBJS)
|
||||
-del qmake_pch.obj
|
||||
-del qmake_pch.pch
|
||||
@ -139,6 +142,7 @@ clean::
|
||||
|
||||
distclean:: clean
|
||||
-del $(BUILD_PATH)\bin\qmake.exe
|
||||
-del $(BUILD_PATH)\qmake\qmake.exe
|
||||
-del Makefile
|
||||
|
||||
.cpp.obj:
|
||||
@ -148,6 +152,9 @@ $(OBJS): $(PCH_OBJECT)
|
||||
|
||||
$(QTOBJS): $(PCH_OBJECT)
|
||||
|
||||
qlibraryinfo.obj: $(PCH_OBJECT)
|
||||
qlibraryinfo_final.obj: $(PCH_OBJECT)
|
||||
|
||||
qmake_pch.obj:
|
||||
$(CXX) $(CXXFLAGS_BARE) -c -Yc -Fpqmake_pch.pch -TP $(QMKSRC)\qmake_pch.h
|
||||
|
||||
@ -199,3 +206,9 @@ qmake_pch.obj:
|
||||
# Make sure qstring_compat.obj isn't compiled with PCH enabled
|
||||
qstring_compat.obj: $(SOURCE_PATH)\src\corelib\tools\qstring_compat.cpp
|
||||
$(CXX) -c $(CXXFLAGS_BARE) $(SOURCE_PATH)\src\corelib\tools\qstring_compat.cpp
|
||||
|
||||
qlibraryinfo.obj: $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp
|
||||
$(CXX) $(CXXFLAGS) -DQT_BUILD_QMAKE_BOOTSTRAP $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp
|
||||
|
||||
qlibraryinfo_final.obj: $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp $(BUILD_PATH)\src\corelib\global\qconfig.cpp
|
||||
$(CXX) $(CXXFLAGS) -Foqlibraryinfo_final.obj $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp
|
||||
|
@ -638,11 +638,6 @@ 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())
|
||||
|
@ -9,14 +9,10 @@ win32: EXTENSION = .exe
|
||||
|
||||
!build_pass {
|
||||
qmake_exe.target = $$OUT_PWD/qmake$$EXTENSION
|
||||
qmake_exe.depends = ../bin/qmake$$EXTENSION builtin-qt.conf
|
||||
equals(QMAKE_DIR_SEP, /): \
|
||||
qmake_exe.commands = cat ../bin/qmake$$EXTENSION builtin-qt.conf > qmake$$EXTENSION && chmod +x qmake$$EXTENSION
|
||||
else: \
|
||||
qmake_exe.commands = copy /B ..\bin\qmake$$EXTENSION + builtin-qt.conf qmake$$EXTENSION
|
||||
qmake_exe.commands = $(MAKE) binary
|
||||
qmake_exe.CONFIG = phony
|
||||
QMAKE_EXTRA_TARGETS += qmake_exe
|
||||
|
||||
QMAKE_CLEAN += builtin-qt.conf
|
||||
QMAKE_DISTCLEAN += qmake$$EXTENSION
|
||||
|
||||
first.depends += qmake_exe
|
||||
|
@ -41,18 +41,15 @@
|
||||
#include "qdir.h"
|
||||
#include "qstringlist.h"
|
||||
#include "qfile.h"
|
||||
#include "qtemporaryfile.h"
|
||||
#include "qsettings.h"
|
||||
#include "qlibraryinfo.h"
|
||||
#include "qscopedpointer.h"
|
||||
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
QT_BEGIN_NAMESPACE
|
||||
extern QString qmake_absoluteLocation();
|
||||
extern QString qmake_libraryInfoFile();
|
||||
QT_END_NAMESPACE
|
||||
#else
|
||||
# include "qconfig.cpp"
|
||||
# include "qcoreapplication.h"
|
||||
#endif
|
||||
|
||||
@ -60,6 +57,10 @@ QT_END_NAMESPACE
|
||||
# include "private/qcore_mac_p.h"
|
||||
#endif
|
||||
|
||||
#ifndef QT_BUILD_QMAKE_BOOTSTRAP
|
||||
# include "qconfig.cpp"
|
||||
#endif
|
||||
|
||||
#include "archdetect.cpp"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -72,16 +73,9 @@ struct QLibrarySettings
|
||||
{
|
||||
QLibrarySettings();
|
||||
void load();
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
void loadBuiltinValues(QSettings *config);
|
||||
#endif
|
||||
|
||||
QScopedPointer<QSettings> settings;
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
QString builtinValues[QLibraryInfo::LastHostPath + 1];
|
||||
# ifndef Q_OS_WIN
|
||||
QString builtinSettingsPath;
|
||||
# endif
|
||||
bool haveDevicePaths;
|
||||
bool haveEffectiveSourcePaths;
|
||||
bool haveEffectivePaths;
|
||||
@ -113,18 +107,6 @@ public:
|
||||
? ls->haveDevicePaths
|
||||
: ls->havePaths) : false;
|
||||
}
|
||||
static QString builtinValue(int loc)
|
||||
{
|
||||
QLibrarySettings *ls = qt_library_settings();
|
||||
return ls ? ls->builtinValues[loc] : QString();
|
||||
}
|
||||
# ifndef Q_OS_WIN
|
||||
static QString builtinSettingsPath()
|
||||
{
|
||||
QLibrarySettings *ls = qt_library_settings();
|
||||
return ls ? ls->builtinSettingsPath : QString();
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
static QSettings *configuration()
|
||||
{
|
||||
@ -148,20 +130,6 @@ QLibrarySettings::QLibrarySettings()
|
||||
load();
|
||||
}
|
||||
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
static QByteArray qtconfSeparator()
|
||||
{
|
||||
# ifdef Q_OS_WIN
|
||||
QByteArray header = QByteArrayLiteral("\r\n===========================================================\r\n");
|
||||
# else
|
||||
QByteArray header = QByteArrayLiteral("\n===========================================================\n");
|
||||
# endif
|
||||
QByteArray content = QByteArrayLiteral("==================== qt.conf beginning ====================");
|
||||
// Assemble from pieces to avoid that the string appears in a raw executable
|
||||
return header + content + header;
|
||||
}
|
||||
#endif
|
||||
|
||||
void QLibrarySettings::load()
|
||||
{
|
||||
// If we get any settings here, those won't change when the application shows up.
|
||||
@ -199,27 +167,6 @@ void QLibrarySettings::load()
|
||||
havePaths = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
// Try to use an embedded qt.conf appended to the QMake executable.
|
||||
QFile qmakeFile(qmake_absoluteLocation());
|
||||
if (!qmakeFile.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
qmakeFile.seek(qmakeFile.size() - 10000);
|
||||
QByteArray tail = qmakeFile.read(10000);
|
||||
QByteArray separator = qtconfSeparator();
|
||||
int qtconfOffset = tail.lastIndexOf(separator);
|
||||
if (qtconfOffset < 0)
|
||||
return;
|
||||
tail.remove(0, qtconfOffset + separator.size());
|
||||
// If QSettings had a c'tor taking a QIODevice, we'd pass a QBuffer ...
|
||||
QTemporaryFile tmpFile;
|
||||
tmpFile.open();
|
||||
tmpFile.write(tail);
|
||||
tmpFile.close();
|
||||
QSettings builtinSettings(tmpFile.fileName(), QSettings::IniFormat);
|
||||
loadBuiltinValues(&builtinSettings);
|
||||
#endif
|
||||
}
|
||||
|
||||
QSettings *QLibraryInfoPrivate::findConfiguration()
|
||||
@ -482,24 +429,11 @@ static const struct {
|
||||
{ "HostData", "." },
|
||||
{ "TargetSpec", "" },
|
||||
{ "HostSpec", "" },
|
||||
{ "ExtPrefix", "" },
|
||||
{ "HostPrefix", "" },
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
void QLibrarySettings::loadBuiltinValues(QSettings *config)
|
||||
{
|
||||
config->beginGroup(QLatin1String("Paths"));
|
||||
for (int i = 0; i <= QLibraryInfo::LastHostPath; i++)
|
||||
builtinValues[i] = config->value(QLatin1String(qtConfEntries[i].key),
|
||||
QLatin1String(qtConfEntries[i].value)).toString();
|
||||
# ifndef Q_OS_WIN
|
||||
builtinSettingsPath = config->value(QLatin1String("Settings")).toString();
|
||||
# endif
|
||||
config->endGroup();
|
||||
}
|
||||
|
||||
void QLibraryInfo::reload()
|
||||
{
|
||||
QLibraryInfoPrivate::reload();
|
||||
@ -613,34 +547,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
|
||||
}
|
||||
#endif // QT_NO_SETTINGS
|
||||
|
||||
#ifndef QT_BUILD_QMAKE_BOOTSTRAP
|
||||
if (!fromConf) {
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
if ((unsigned)loc <= (unsigned)LastHostPath) {
|
||||
if (loc == PrefixPath && group != DevicePaths)
|
||||
ret = QLibraryInfoPrivate::builtinValue(ExtPrefixPath);
|
||||
else
|
||||
ret = QLibraryInfoPrivate::builtinValue(loc);
|
||||
# ifndef Q_OS_WIN // On Windows we use the registry
|
||||
} else if (loc == SettingsPath) {
|
||||
ret = QLibraryInfoPrivate::builtinSettingsPath();
|
||||
# endif
|
||||
}
|
||||
#else // QT_BUILD_QMAKE
|
||||
const char * volatile path = 0;
|
||||
if (loc == PrefixPath) {
|
||||
path = QT_CONFIGURE_PREFIX_PATH;
|
||||
path =
|
||||
# ifdef QT_BUILD_QMAKE
|
||||
(group != DevicePaths) ?
|
||||
QT_CONFIGURE_EXT_PREFIX_PATH :
|
||||
# endif
|
||||
QT_CONFIGURE_PREFIX_PATH;
|
||||
} else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) {
|
||||
path = qt_configure_strs + qt_configure_str_offsets[loc - 1];
|
||||
#ifndef Q_OS_WIN // On Windows we use the registry
|
||||
} else if (loc == SettingsPath) {
|
||||
path = QT_CONFIGURE_SETTINGS_PATH;
|
||||
#endif
|
||||
# ifdef QT_BUILD_QMAKE
|
||||
} else if (loc == HostPrefixPath) {
|
||||
path = QT_CONFIGURE_HOST_PREFIX_PATH;
|
||||
# endif
|
||||
}
|
||||
|
||||
if (path)
|
||||
ret = QString::fromLocal8Bit(path);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef QT_BUILD_QMAKE
|
||||
// These values aren't actually paths and thus need to be returned verbatim.
|
||||
|
@ -97,7 +97,6 @@ public:
|
||||
HostDataPath,
|
||||
TargetSpecPath,
|
||||
HostSpecPath,
|
||||
ExtPrefixPath,
|
||||
HostPrefixPath,
|
||||
LastHostPath = HostPrefixPath,
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user