Use Core library for qmake instead of the Bootstrap library

Move the qmake-specific logic of the QLibraryInfo class to
qmake internals. 'qconfig.cpp.in' now stores information about
the library info entries to keep them consistent between qmake
and the Core library. qmake requires specific features enabled
in the Core library, so building qmake will be skipped if the
features are not enabled.

All flags directly related to the qmake have been removed from
Core lib.

Remove all bootstrap related sections from qmake CMakeLists.txt

Task-number: QTBUG-89369
Change-Id: I26de157d3bfd4a5526699296e9d46e1c180b89ae
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
Alexey Edelev 2021-01-28 16:06:26 +01:00
parent 5a3bbb5585
commit 43c28aa904
25 changed files with 550 additions and 565 deletions

View File

@ -476,7 +476,6 @@ set(__qt_add_plugin_multi_args
set(__qt_internal_add_executable_optional_args
GUI
BOOTSTRAP
NO_QT
NO_INSTALL
EXCEPTIONS
DELAY_RC

View File

@ -83,7 +83,7 @@ function(qt_internal_add_executable name)
qt_skip_warnings_are_errors_when_repo_unclean("${name}")
set(extra_libraries "")
if(NOT arg_BOOTSTRAP AND NOT arg_NO_QT)
if(NOT arg_BOOTSTRAP)
set(extra_libraries "Qt::Core")
endif()

View File

@ -20,7 +20,7 @@ macro(qt_add_string_to_qconfig_cpp str)
math(EXPR QT_CONFIG_STR_OFFSET "${QT_CONFIG_STR_OFFSET}+${length}+1")
endmacro()
function(qt_generate_qconfig_cpp)
function(qt_generate_qconfig_cpp in_file out_file)
set(QT_CONFIG_STR_OFFSET "0")
set(QT_CONFIG_STR_OFFSETS "")
set(QT_CONFIG_STRS "")
@ -92,7 +92,7 @@ function(qt_generate_qconfig_cpp)
set(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH "${from_bin_dir_to_prefix}")
set(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH "${from_bin_dir_to_prefix}")
configure_file(global/qconfig.cpp.in global/qconfig.cpp @ONLY)
configure_file(${in_file} ${out_file} @ONLY)
endfunction()
# In the cross-compiling case, creates a wrapper around the host Qt's

View File

@ -22,7 +22,7 @@ function(qt_internal_add_tool target_name)
qt_tool_target_to_name(name ${target_name})
set(one_value_keywords TOOLS_TARGET EXTRA_CMAKE_FILES INSTALL_DIR
${__default_target_info_args})
qt_parse_all_arguments(arg "qt_add_tool" "BOOTSTRAP;NO_QT;NO_INSTALL"
qt_parse_all_arguments(arg "qt_add_tool" "BOOTSTRAP;NO_INSTALL"
"${one_value_keywords}"
"${__default_private_args}" ${ARGN})
@ -109,19 +109,11 @@ function(qt_internal_add_tool target_name)
endif()
set(disable_autogen_tools "${arg_DISABLE_AUTOGEN_TOOLS}")
if (arg_NO_QT)
# FIXME: Remove NO_QT again once qmake can use a "normal" Qt!
if (arg_BOOTSTRAP)
message(FATAL_ERROR "Tool can not be NO_QT and BOOTSTRAP at the same time!")
endif()
set(corelib "")
if (arg_BOOTSTRAP)
set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Bootstrap)
list(APPEND disable_autogen_tools "uic" "moc" "rcc")
else()
if (arg_BOOTSTRAP)
set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Bootstrap)
list(APPEND disable_autogen_tools "uic" "moc" "rcc")
else()
set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Core)
endif()
set(corelib ${QT_CMAKE_EXPORT_NAMESPACE}::Core)
endif()
set(bootstrap "")
@ -129,11 +121,6 @@ function(qt_internal_add_tool target_name)
set(bootstrap BOOTSTRAP)
endif()
set(no_qt "")
if(arg_NO_QT)
set(no_qt NO_QT)
endif()
set(install_dir "${INSTALL_BINDIR}")
if(arg_INSTALL_DIR)
set(install_dir "${arg_INSTALL_DIR}")
@ -141,7 +128,6 @@ function(qt_internal_add_tool target_name)
qt_internal_add_executable("${target_name}" OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${install_dir}"
${bootstrap}
${no_qt}
NO_INSTALL
SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES
@ -178,7 +164,7 @@ function(qt_internal_add_tool target_name)
if(TARGET host_tools)
add_dependencies(host_tools "${target_name}")
if(bootstrap OR no_qt)
if(bootstrap)
add_dependencies(bootstrap_tools "${target_name}")
endif()
endif()

View File

@ -4,131 +4,27 @@
## qmake Tool:
#####################################################################
# TODO: Probably it's time to introduce QT_FEATURE_qmake?
if(NOT (QT_FEATURE_settings AND QT_FEATURE_alloca AND (QT_FEATURE_alloca_malloc_h OR NOT WIN32) AND
QT_FEATURE_cborstreamwriter AND QT_FEATURE_datestring AND QT_FEATURE_regularexpression AND
QT_FEATURE_temporaryfile))
message(WARNING "Skip building qmake in specified configuration.\
Required features:
QT_FEATURE_settings ${QT_FEATURE_settings}
QT_FEATURE_alloca ${QT_FEATURE_alloca}
QT_FEATURE_cborstreamwriter ${QT_FEATURE_cborstreamwriter}
QT_FEATURE_datestring ${QT_FEATURE_datestring}
QT_FEATURE_getauxval ${QT_FEATURE_getauxval}
QT_FEATURE_regularexpression ${QT_FEATURE_regularexpression}
QT_FEATURE_temporaryfile ${QT_FEATURE_temporaryfile}
")
return()
endif()
qt_get_tool_target_name(target_name qmake)
qt_internal_add_tool(${target_name}
NO_QT # special case
TOOLS_TARGET Core # special case
# GUI # special case: remove this
SOURCES
../src/3rdparty/pcre2/src/config.h
../src/3rdparty/pcre2/src/pcre2.h
../src/3rdparty/pcre2/src/pcre2_auto_possess.c
../src/3rdparty/pcre2/src/pcre2_chartables.c
../src/3rdparty/pcre2/src/pcre2_compile.c
../src/3rdparty/pcre2/src/pcre2_config.c
../src/3rdparty/pcre2/src/pcre2_context.c
../src/3rdparty/pcre2/src/pcre2_dfa_match.c
../src/3rdparty/pcre2/src/pcre2_error.c
../src/3rdparty/pcre2/src/pcre2_extuni.c
../src/3rdparty/pcre2/src/pcre2_find_bracket.c
../src/3rdparty/pcre2/src/pcre2_internal.h
../src/3rdparty/pcre2/src/pcre2_intmodedep.h
../src/3rdparty/pcre2/src/pcre2_jit_compile.c
../src/3rdparty/pcre2/src/pcre2_maketables.c
../src/3rdparty/pcre2/src/pcre2_match.c
../src/3rdparty/pcre2/src/pcre2_match_data.c
../src/3rdparty/pcre2/src/pcre2_newline.c
../src/3rdparty/pcre2/src/pcre2_ord2utf.c
../src/3rdparty/pcre2/src/pcre2_pattern_info.c
../src/3rdparty/pcre2/src/pcre2_script_run.c
../src/3rdparty/pcre2/src/pcre2_serialize.c
../src/3rdparty/pcre2/src/pcre2_string_utils.c
../src/3rdparty/pcre2/src/pcre2_study.c
../src/3rdparty/pcre2/src/pcre2_substitute.c
../src/3rdparty/pcre2/src/pcre2_substring.c
../src/3rdparty/pcre2/src/pcre2_tables.c
../src/3rdparty/pcre2/src/pcre2_ucd.c
../src/3rdparty/pcre2/src/pcre2_ucp.h
../src/3rdparty/pcre2/src/pcre2_valid_utf.c
../src/3rdparty/pcre2/src/pcre2_xclass.c
../src/corelib/global/qcontainerinfo.h
../src/corelib/global/qendian.cpp # special case
../src/corelib/global/qglobal.cpp ../src/corelib/global/qglobal.h
../src/corelib/global/qlibraryinfo.cpp
../src/corelib/global/qlogging.cpp
../src/corelib/global/qmalloc.cpp
../src/corelib/global/qnumeric.cpp ../src/corelib/global/qnumeric.h
../src/corelib/global/qoperatingsystemversion.cpp # special case
../src/corelib/global/qrandom.cpp # special case
../src/corelib/io/qabstractfileengine.cpp ../src/corelib/io/qabstractfileengine_p.h
../src/corelib/io/qbuffer.cpp ../src/corelib/io/qbuffer.h
../src/corelib/io/qdebug.cpp # special case
../src/corelib/io/qdir.cpp ../src/corelib/io/qdir.h ../src/corelib/io/qdir_p.h
../src/corelib/io/qdiriterator.cpp ../src/corelib/io/qdiriterator.h
../src/corelib/io/qfile.cpp ../src/corelib/io/qfile.h
../src/corelib/io/qfiledevice.cpp
../src/corelib/io/qfileinfo.cpp ../src/corelib/io/qfileinfo.h
../src/corelib/io/qfilesystemengine.cpp
../src/corelib/io/qfilesystementry.cpp
../src/corelib/io/qfsfileengine.cpp
../src/corelib/io/qfsfileengine_iterator.cpp
../src/corelib/io/qiodevicebase.h
../src/corelib/io/qiodevice.cpp ../src/corelib/io/qiodevice.h
../src/corelib/io/qsettings.cpp
../src/corelib/io/qtemporaryfile.cpp ../src/corelib/io/qtemporaryfile.h
../src/corelib/kernel/qiterable.cpp ../src/corelib/kernel/qiterable.h
../src/corelib/kernel/qmetacontainer.cpp ../src/corelib/kernel/qmetacontainer.h
../src/corelib/kernel/qmetatype.cpp ../src/corelib/kernel/qmetatype.h
../src/corelib/kernel/qsystemerror.cpp ../src/corelib/kernel/qsystemerror_p.h
../src/corelib/kernel/qvariant.cpp
../src/corelib/plugin/quuid.cpp ../src/corelib/plugin/quuid.h
../src/corelib/serialization/qcborstreamwriter.cpp ../src/corelib/serialization/qcborstreamwriter.h
../src/corelib/serialization/qcborvalue.cpp ../src/corelib/serialization/qcborvalue.h ../src/corelib/serialization/qcborvalue_p.h
../src/corelib/serialization/qdatastream.cpp ../src/corelib/serialization/qdatastream.h
../src/corelib/serialization/qjson_p.h
../src/corelib/serialization/qjsonarray.cpp ../src/corelib/serialization/qjsonarray.h
../src/corelib/serialization/qjsoncbor.cpp
../src/corelib/serialization/qjsondocument.cpp ../src/corelib/serialization/qjsondocument.h
../src/corelib/serialization/qjsonobject.cpp ../src/corelib/serialization/qjsonobject.h
../src/corelib/serialization/qjsonparser.cpp ../src/corelib/serialization/qjsonparser_p.h
../src/corelib/serialization/qjsonvalue.cpp ../src/corelib/serialization/qjsonvalue.h
../src/corelib/serialization/qjsonwriter_p.h
../src/corelib/serialization/qtextstream.cpp ../src/corelib/serialization/qtextstream.h
../src/corelib/text/qbytearray.cpp ../src/corelib/text/qbytearray.h
../src/corelib/text/qbytearraylist.cpp ../src/corelib/text/qbytearraylist.h # special case
../src/corelib/text/qbytearraymatcher.cpp ../src/corelib/text/qbytearraymatcher.h
../src/corelib/text/qchar.h
../src/corelib/text/qlocale.cpp ../src/corelib/text/qlocale.h
../src/corelib/text/qlocale_tools.cpp ../src/corelib/text/qlocale_tools_p.h
../src/corelib/text/qregularexpression.cpp ../src/corelib/text/qregularexpression.h
../src/corelib/text/qstring.cpp ../src/corelib/text/qstring.h
../src/corelib/text/qstringbuilder.cpp ../src/corelib/text/qstringbuilder.h
../src/corelib/text/qstringconverter.cpp ../src/corelib/text/qstringconverter.h ../src/corelib/text/qstringconverter_p.h
../src/corelib/text/qstringlist.cpp ../src/corelib/text/qstringlist.h
../src/corelib/text/qstringmatcher.h
../src/corelib/text/qvsnprintf.cpp
../src/corelib/time/qcalendar.cpp ../src/corelib/time/qcalendar.h
../src/corelib/time/qcalendarbackend_p.h
../src/corelib/time/qcalendarmath_p.h
../src/corelib/time/qdatetime.cpp ../src/corelib/time/qdatetime.h ../src/corelib/time/qdatetime_p.h
../src/corelib/time/qgregoriancalendar.cpp ../src/corelib/time/qgregoriancalendar_p.h
../src/corelib/time/qromancalendar.cpp ../src/corelib/time/qromancalendar_p.h
../src/corelib/tools/qarraydata.cpp ../src/corelib/tools/qarraydata.h
../src/corelib/tools/qarraydataops.h
../src/corelib/tools/qarraydatapointer.h
../src/corelib/tools/qbitarray.cpp ../src/corelib/tools/qbitarray.h
../src/corelib/tools/qcryptographichash.cpp ../src/corelib/tools/qcryptographichash.h
../src/corelib/time/qcalendar.cpp ../src/corelib/time/qcalendar.h # special case
../src/corelib/time/qcalendarbackend_p.h ../src/corelib/time/qcalendarmath_p.h # special case
../src/corelib/time/qgregoriancalendar.cpp ../src/corelib/time/qgregoriancalendar_p.h # special case
../src/corelib/time/qromancalendar.cpp ../src/corelib/time/qromancalendar_p.h # special case
../src/corelib/time/qdatetime.cpp ../src/corelib/time/qdatetime.h ../src/corelib/time/qdatetime_p.h # special case
../src/corelib/tools/qduplicatetracker_p.h
../src/corelib/tools/qhash.cpp ../src/corelib/tools/qhash.h
../src/corelib/tools/qlist.h
../src/corelib/tools/qmap.h
../src/corelib/text/qlocale.cpp ../src/corelib/text/qlocale.h
../src/corelib/text/qlocale_tools.cpp ../src/corelib/text/qlocale_tools_p.h
../src/corelib/text/qregularexpression.cpp ../src/corelib/text/qregularexpression.h
../src/corelib/tools/qringbuffer.cpp # special case
../src/corelib/text/qstring.cpp ../src/corelib/text/qstring.h
../src/corelib/text/qstringbuilder.cpp ../src/corelib/text/qstringbuilder.h
../src/corelib/text/qstringconverter.cpp ../src/corelib/text/qstringconverter.h ../src/corelib/text/qstringconverter_p.h
../src/corelib/text/qstringlist.cpp ../src/corelib/text/qstringlist.h
../src/corelib/text/qstringmatcher.h
../src/corelib/tools/qvector.h
../src/corelib/tools/qversionnumber.cpp ../src/corelib/tools/qversionnumber.h
../src/corelib/text/qvsnprintf.cpp
cachekeys.h
generators/mac/pbuilder_pbx.cpp generators/mac/pbuilder_pbx.h
generators/makefile.cpp generators/makefile.h
@ -153,6 +49,7 @@ qt_internal_add_tool(${target_name}
library/qmakeglobals.cpp library/qmakeglobals.h
library/qmakeparser.cpp library/qmakeparser.h
library/qmakevfs.cpp library/qmakevfs.h
qmakelibraryinfo.cpp qmakelibraryinfo.h
main.cpp
meta.cpp meta.h
option.cpp option.h
@ -160,9 +57,7 @@ qt_internal_add_tool(${target_name}
property.cpp property.h
DEFINES
HAVE_CONFIG_H
PCRE2_DISABLE_JIT
PROEVALUATOR_FULL
QT_BOOTSTRAPPED
QT_BUILD_QMAKE
QT_USE_QSTRINGBUILDER
QT_NO_FOREACH
@ -170,95 +65,38 @@ qt_internal_add_tool(${target_name}
QT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} # special case
QT_VERSION_MINOR=${PROJECT_VERSION_MINOR} # special case
QT_VERSION_PATCH=${PROJECT_VERSION_PATCH} # special case
PCRE2_CODE_UNIT_WIDTH=16
PCRE2_DISABLE_JIT
HAVE_CONFIG_H
INCLUDE_DIRECTORIES
# . # special case remove
generators
generators/mac
generators/unix
generators/win32
library
$<TARGET_PROPERTY:Qt::Core,INCLUDE_DIRECTORIES> # special case
"${PROJECT_BINARY_DIR}/src/corelib/global" # special case: for qconfig.cpp
"${CMAKE_CURRENT_BINARY_DIR}/library" # for qmakeconfig.cpp
PRECOMPILED_HEADER
"qmake_pch.h"
LIBRARIES
Qt::CorePrivate
)
qt_generate_qconfig_cpp(../src/corelib/global/qconfig.cpp.in library/qmakeconfig.cpp)
#### Keys ignored in scope 1:.:.:qmake.pro:<TRUE>:
# _OPTION = "host_build"
## Scopes:
#####################################################################
qt_internal_extend_target(${target_name} CONDITION WIN32
SOURCES
../src/corelib/global/qoperatingsystemversion_win.cpp
../src/corelib/io/qfilesystemengine_win.cpp
../src/corelib/io/qfilesystemiterator_win.cpp
../src/corelib/io/qfsfileengine_win.cpp
../src/corelib/io/qsettings_win.cpp
../src/corelib/plugin/qsystemlibrary.cpp
../src/corelib/text/qlocale_win.cpp
library/registry.cpp
DEFINES
UNICODE
_CRT_SECURE_NO_WARNINGS
_ENABLE_EXTENDED_ALIGNED_STORAGE
_SCL_SECURE_NO_WARNINGS
PUBLIC_DEFINES
PCRE2_STATIC
PUBLIC_LIBRARIES
advapi32
kernel32
netapi32
ole32
)
qt_internal_extend_target(${target_name} CONDITION UNIX
SOURCES
../src/corelib/io/qfilesystemengine_unix.cpp
../src/corelib/io/qfilesystemiterator_unix.cpp
../src/corelib/io/qfsfileengine_unix.cpp
../src/corelib/kernel/qcore_unix.cpp
../src/corelib/text/qlocale_unix.cpp
)
qt_internal_extend_target(${target_name} CONDITION MACOS
SOURCES
../src/corelib/kernel/qcore_foundation.mm # special case
../src/corelib/kernel/qcore_mac.mm # special case
../src/corelib/global/qoperatingsystemversion_darwin.mm # special case
../src/corelib/io/qsettings_mac.cpp # special case
PUBLIC_LIBRARIES
${FWApplicationServices}
${FWCoreServices}
${FWFoundation}
COMPILE_OPTIONS
"-fconstant-cfstrings"
)
# special case big
qt_internal_extend_target(qmake CONDITION WIN32
qt_internal_extend_target(${target_name} CONDITION WIN32
SOURCES
../src/corelib/io/qfilesystemengine_win.cpp
../src/corelib/io/qfilesystemiterator_win.cpp
../src/corelib/io/qfsfileengine_win.cpp
../src/corelib/text/qlocale_win.cpp
../src/corelib/io/qsettings_win.cpp
# ../src/corelib/global/qoperatingsystemversion.cpp special case: remove this
../src/corelib/plugin/qsystemlibrary.cpp
library/registry.cpp
DEFINES
UNICODE _ENABLE_EXTENDED_ALIGNED_STORAGE _CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS
LIBRARIES
ole32 advapi32 kernel32 netapi32
)
qt_internal_extend_target(${target_name} CONDITION MINGW AND WIN32
PUBLIC_LIBRARIES
uuid
_SCL_SECURE_NO_WARNINGS
)
qt_internal_extend_target(${target_name} CONDITION CLANG AND WIN32
@ -275,10 +113,7 @@ set_target_properties(${target_name} PROPERTIES
)
qt_internal_apply_gc_binaries(${target_name} PRIVATE) # special case
qt_set_msvc_cplusplus_options(${target_name} PUBLIC) # special case
qt_skip_warnings_are_errors(${target_name}) # special case
qt_internal_apply_intel_cet(Bootstrap PUBLIC) # special case
# special case begin
qt_internal_add_docs(${target_name}

View File

@ -33,7 +33,7 @@
#include <qregularexpression.h>
#include <qhash.h>
#include <qdebug.h>
#include <qlibraryinfo.h>
#include <qmakelibraryinfo.h>
#include <stdlib.h>
#include <stdarg.h>
@ -218,7 +218,9 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
"QMake version %s\n"
"Using Qt version %s in %s\n",
QMAKE_VERSION_STR, QT_VERSION_STR,
QLibraryInfo::path(QLibraryInfo::LibrariesPath).toLatin1().constData());
QMakeLibraryInfo::path(QLibraryInfo::LibrariesPath)
.toLatin1()
.constData());
#ifdef QMAKE_OPENSOURCE_VERSION
fprintf(stdout, "QMake is Open Source software from The Qt Company Ltd and/or its subsidiary(-ies).\n");
#endif
@ -353,9 +355,9 @@ Option::init(int argc, char **argv)
}
if (Q_UNLIKELY(globals->qmake_abslocation.isNull())) {
// This is rather unlikely to ever happen on a modern system ...
globals->qmake_abslocation = QLibraryInfo::rawLocation(
QLibraryInfo::HostBinariesPath,
QLibraryInfo::EffectivePaths)
globals->qmake_abslocation =
QMakeLibraryInfo::rawLocation(QMakeLibraryInfo::HostBinariesPath,
QMakeLibraryInfo::EffectivePaths)
#ifdef Q_OS_WIN
+ "/qmake.exe";
#else

View File

@ -31,7 +31,7 @@
#include <qdir.h>
#include <qsettings.h>
#include <qlibraryinfo.h>
#include <qmakelibraryinfo.h>
#include <qstringlist.h>
#include <stdio.h>
@ -39,11 +39,11 @@ QT_BEGIN_NAMESPACE
static const struct {
const char *name;
QLibraryInfo::LibraryPath loc;
int loc;
bool raw;
bool singular;
} propList[] = {
{ "QT_SYSROOT", QLibraryInfo::SysrootPath, true, true },
{ "QT_SYSROOT", QMakeLibraryInfo::SysrootPath, true, true },
{ "QT_INSTALL_PREFIX", QLibraryInfo::PrefixPath, false, false },
{ "QT_INSTALL_ARCHDATA", QLibraryInfo::ArchDataPath, false, false },
{ "QT_INSTALL_DATA", QLibraryInfo::DataPath, false, false },
@ -59,13 +59,13 @@ static const struct {
{ "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath, false, false },
{ "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath, false, false },
{ "QT_INSTALL_DEMOS", QLibraryInfo::ExamplesPath, false, false }, // Just backwards compat
{ "QT_HOST_PREFIX", QLibraryInfo::HostPrefixPath, true, false },
{ "QT_HOST_DATA", QLibraryInfo::HostDataPath, true, false },
{ "QT_HOST_BINS", QLibraryInfo::HostBinariesPath, true, false },
{ "QT_HOST_LIBS", QLibraryInfo::HostLibrariesPath, true, false },
{ "QT_HOST_LIBEXECS", QLibraryInfo::HostLibraryExecutablesPath, true, false },
{ "QMAKE_SPEC", QLibraryInfo::HostSpecPath, true, true },
{ "QMAKE_XSPEC", QLibraryInfo::TargetSpecPath, true, true },
{ "QT_HOST_PREFIX", QMakeLibraryInfo::HostPrefixPath, true, false },
{ "QT_HOST_DATA", QMakeLibraryInfo::HostDataPath, true, false },
{ "QT_HOST_BINS", QMakeLibraryInfo::HostBinariesPath, true, false },
{ "QT_HOST_LIBEXECS", QMakeLibraryInfo::HostLibraryExecutablesPath, true, false },
{ "QT_HOST_LIBS", QMakeLibraryInfo::HostLibrariesPath, true, false },
{ "QMAKE_SPEC", QMakeLibraryInfo::HostSpecPath, true, true },
{ "QMAKE_XSPEC", QMakeLibraryInfo::TargetSpecPath, true, true },
};
QMakeProperty::QMakeProperty() : settings(nullptr)
@ -75,17 +75,20 @@ QMakeProperty::QMakeProperty() : settings(nullptr)
void QMakeProperty::reload()
{
QLibraryInfo::reload();
QMakeLibraryInfo::reload();
for (unsigned i = 0; i < sizeof(propList)/sizeof(propList[0]); i++) {
QString name = QString::fromLatin1(propList[i].name);
if (!propList[i].singular) {
m_values[ProKey(name + "/src")] = QLibraryInfo::rawLocation(propList[i].loc, QLibraryInfo::EffectiveSourcePaths);
m_values[ProKey(name + "/get")] = QLibraryInfo::rawLocation(propList[i].loc, QLibraryInfo::EffectivePaths);
m_values[ProKey(name + "/src")] = QMakeLibraryInfo::rawLocation(
propList[i].loc, QMakeLibraryInfo::EffectiveSourcePaths);
m_values[ProKey(name + "/get")] = QMakeLibraryInfo::rawLocation(
propList[i].loc, QMakeLibraryInfo::EffectivePaths);
}
QString val = QLibraryInfo::rawLocation(propList[i].loc, QLibraryInfo::FinalPaths);
QString val = QMakeLibraryInfo::rawLocation(propList[i].loc, QMakeLibraryInfo::FinalPaths);
if (!propList[i].raw) {
m_values[ProKey(name + "/dev")] = QLibraryInfo::rawLocation(propList[i].loc, QLibraryInfo::DevicePaths);
m_values[ProKey(name)] = QLibraryInfo::path(propList[i].loc);
m_values[ProKey(name + "/dev")] =
QMakeLibraryInfo::rawLocation(propList[i].loc, QMakeLibraryInfo::DevicePaths);
m_values[ProKey(name)] = QMakeLibraryInfo::path(propList[i].loc);
name += "/raw";
}
m_values[ProKey(name)] = val;

313
qmake/qmakelibraryinfo.cpp Normal file
View File

@ -0,0 +1,313 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qmakelibraryinfo.h"
#include <qdir.h>
#include <qfile.h>
#include <qglobalstatic.h>
#include <qsettings.h>
#include <qscopedpointer.h>
#include <qstringlist.h>
#include <qmakeconfig.cpp>
QT_BEGIN_NAMESPACE
// qmake_libraryInfoFile and qmake_abslocation are defined in option.cpp
QString qmake_libraryInfoFile();
QString qmake_abslocation();
struct QMakeLibrarySettings
{
QMakeLibrarySettings() { load(); }
void load();
QScopedPointer<QSettings> settings;
bool haveDevicePaths;
bool haveEffectiveSourcePaths;
bool haveEffectivePaths;
bool havePaths;
bool reloadOnQAppAvailable;
};
Q_GLOBAL_STATIC(QMakeLibrarySettings, qmake_library_settings)
QSettings *QMakeLibraryInfo::findConfiguration()
{
QString qtconfig = qmake_libraryInfoFile();
if (!qtconfig.isEmpty())
return new QSettings(qtconfig, QSettings::IniFormat);
return nullptr; // no luck
}
QSettings *QMakeLibraryInfo::configuration()
{
QMakeLibrarySettings *ls = qmake_library_settings();
return ls ? ls->settings.data() : nullptr;
}
void QMakeLibraryInfo::reload()
{
if (qmake_library_settings.exists())
qmake_library_settings->load();
}
bool QMakeLibraryInfo::haveGroup(PathGroup group)
{
QMakeLibrarySettings *ls = qmake_library_settings();
return ls
&& (group == EffectiveSourcePaths ? ls->haveEffectiveSourcePaths
: group == EffectivePaths ? ls->haveEffectivePaths
: group == DevicePaths ? ls->haveDevicePaths
: ls->havePaths);
}
void QMakeLibrarySettings::load()
{
settings.reset(QMakeLibraryInfo::findConfiguration());
if (settings) {
QStringList children = settings->childGroups();
haveDevicePaths = children.contains(QLatin1String("DevicePaths"));
haveEffectiveSourcePaths = children.contains(QLatin1String("EffectiveSourcePaths"));
haveEffectivePaths =
haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths"));
// Backwards compat: an existing but empty file is claimed to contain the Paths section.
havePaths = (!haveDevicePaths && !haveEffectivePaths
&& !children.contains(QLatin1String(platformsSection)))
|| children.contains(QLatin1String("Paths"));
} else {
haveDevicePaths = false;
haveEffectiveSourcePaths = false;
haveEffectivePaths = false;
havePaths = false;
}
}
void QMakeLibraryInfo::sysrootify(QString &path)
{
// Acceptable values for SysrootifyPrefixPath are "true" and "false"
if (!QVariant::fromValue(rawLocation(SysrootifyPrefixPath, FinalPaths)).toBool())
return;
const QString sysroot = rawLocation(SysrootPath, FinalPaths);
if (sysroot.isEmpty())
return;
if (path.length() > 2 && path.at(1) == QLatin1Char(':')
&& (path.at(2) == QLatin1Char('/') || path.at(2) == QLatin1Char('\\'))) {
path.replace(0, 2, sysroot); // Strip out the drive on Windows targets
} else {
path.prepend(sysroot);
}
}
static QString getPrefixFromHostBinDir(const char *hostBinDirToPrefixPath)
{
const QString canonicalQMakePath = QFileInfo(qmake_abslocation()).canonicalPath();
return QDir::cleanPath(canonicalQMakePath + QLatin1Char('/')
+ QLatin1String(hostBinDirToPrefixPath));
}
static QString getExtPrefixFromHostBinDir()
{
return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH);
}
static QString getHostPrefixFromHostBinDir()
{
return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH);
}
static QString getPrefix(QMakeLibraryInfo::PathGroup group)
{
#if QT_CONFIGURE_CROSSBUILD
if (group == QMakeLibraryInfo::DevicePaths)
return QString::fromLocal8Bit(QT_CONFIGURE_PREFIX_PATH);
#else
Q_UNUSED(group);
#endif
return getExtPrefixFromHostBinDir();
}
QString QMakeLibraryInfo::path(int loc)
{
QString ret = rawLocation(loc, QMakeLibraryInfo::FinalPaths);
// Automatically prepend the sysroot to target paths
if (loc < QMakeLibraryInfo::SysrootPath || loc > QMakeLibraryInfo::LastHostPath)
sysrootify(ret);
return ret;
}
QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group)
{
QString ret;
bool fromConf = false;
// Logic for choosing the right data source: if EffectivePaths are requested
// and qt.conf with that section is present, use it, otherwise fall back to
// FinalPaths. For FinalPaths, use qt.conf if present and contains not only
// [EffectivePaths], otherwise fall back to builtins.
// EffectiveSourcePaths falls back to EffectivePaths.
// DevicePaths falls back to FinalPaths.
PathGroup orig_group = group;
if (QMakeLibraryInfo::haveGroup(group)
|| (group == EffectiveSourcePaths
&& (group = EffectivePaths, QMakeLibraryInfo::haveGroup(group)))
|| ((group == EffectivePaths || group == DevicePaths)
&& (group = FinalPaths, QMakeLibraryInfo::haveGroup(group)))
|| (group = orig_group, false)) {
fromConf = true;
QString key;
QString defaultValue;
if (unsigned(loc) < sizeof(qtConfEntries) / sizeof(qtConfEntries[0])) {
key = QLatin1String(qtConfEntries[loc].key);
defaultValue = QLatin1String(qtConfEntries[loc].value);
}
#ifndef Q_OS_WIN // On Windows we use the registry
else if (loc == QLibraryInfo::SettingsPath) {
key = QLatin1String("Settings");
defaultValue = QLatin1String(".");
}
#endif
if (!key.isNull()) {
QSettings *config = QMakeLibraryInfo::configuration();
config->beginGroup(QLatin1String(group == DevicePaths ? "DevicePaths"
: group == EffectiveSourcePaths
? "EffectiveSourcePaths"
: group == EffectivePaths ? "EffectivePaths"
: "Paths"));
ret = config->value(key, defaultValue).toString();
if (ret.isEmpty()) {
if (loc == HostPrefixPath)
ret = config->value(QLatin1String(qtConfEntries[QLibraryInfo::PrefixPath].key),
QLatin1String(
qtConfEntries[QLibraryInfo::PrefixPath].value))
.toString();
else if (loc == TargetSpecPath || loc == HostSpecPath
|| loc == SysrootifyPrefixPath)
fromConf = false;
// The last case here is SysrootPath, which can be legitimately empty.
// All other keys have non-empty fallbacks to start with.
}
// TODO: Might be replaced by common for qmake and qtcore function
int startIndex = 0;
forever {
startIndex = ret.indexOf(QLatin1Char('$'), startIndex);
if (startIndex < 0)
break;
if (ret.length() < startIndex + 3)
break;
if (ret.at(startIndex + 1) != QLatin1Char('(')) {
startIndex++;
continue;
}
int endIndex = ret.indexOf(QLatin1Char(')'), startIndex + 2);
if (endIndex < 0)
break;
auto envVarName =
QStringView { ret }.mid(startIndex + 2, endIndex - startIndex - 2);
QString value =
QString::fromLocal8Bit(qgetenv(envVarName.toLocal8Bit().constData()));
ret.replace(startIndex, endIndex - startIndex + 1, value);
startIndex += value.length();
}
config->endGroup();
ret = QDir::fromNativeSeparators(ret);
}
}
if (!fromConf) {
// "volatile" here is a hack to prevent compilers from doing a
// compile-time strlen() on "path". The issue is that Qt installers
// will binary-patch the Qt installation paths -- in such scenarios, Qt
// will be built with a dummy path, thus the compile-time result of
// strlen is meaningless.
const char *volatile path = nullptr;
if (loc == QLibraryInfo::PrefixPath) {
ret = getPrefix(group);
} 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 == QLibraryInfo::SettingsPath) {
path = QT_CONFIGURE_SETTINGS_PATH;
#endif
} else if (loc == HostPrefixPath) {
static const QByteArray hostPrefixPath = getHostPrefixFromHostBinDir().toLatin1();
path = hostPrefixPath.constData();
}
if (path)
ret = QString::fromLocal8Bit(path);
}
// These values aren't actually paths and thus need to be returned verbatim.
if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath)
return ret;
if (!ret.isEmpty() && QDir::isRelativePath(ret)) {
QString baseDir;
if (loc == HostPrefixPath || loc == QLibraryInfo::PrefixPath || loc == SysrootPath) {
// We make the prefix/sysroot path absolute to the executable's directory.
// loc == PrefixPath while a sysroot is set would make no sense here.
// loc == SysrootPath only makes sense if qmake lives inside the sysroot itself.
baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath();
} else if (loc > SysrootPath && loc <= LastHostPath) {
// We make any other host path absolute to the host prefix directory.
baseDir = rawLocation(HostPrefixPath, group);
} else {
// we make any other path absolute to the prefix directory
baseDir = rawLocation(QLibraryInfo::PrefixPath, group);
if (group == EffectivePaths)
sysrootify(baseDir);
}
ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret);
}
return ret;
}
QT_END_NAMESPACE

82
qmake/qmakelibraryinfo.h Normal file
View File

@ -0,0 +1,82 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QMAKELIBRARYINFO_H
#define QMAKELIBRARYINFO_H
#include <qlibraryinfo.h>
#include <qstring.h>
#include <qstringlist.h>
QT_BEGIN_NAMESPACE
class QSettings;
struct QMakeLibraryInfo
{
static QSettings *findConfiguration();
static QSettings *configuration();
static QString path(int loc);
static QStringList platformPluginArguments(const QString &platformName);
/* This enum has to start after the last value in QLibraryInfo::LibraryPath(NOT SettingsPath!).
* See qconfig.cpp.in and QLibraryInfo for details.
*/
enum LibraryPathQMakeExtras {
SysrootPath = QLibraryInfo::TestsPath + 1,
SysrootifyPrefixPath,
HostBinariesPath,
HostLibraryExecutablesPath,
HostLibrariesPath,
HostDataPath,
TargetSpecPath,
HostSpecPath,
HostPrefixPath,
LastHostPath = HostPrefixPath,
};
enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths, DevicePaths };
static QString rawLocation(int loc, PathGroup group);
static void reload();
static bool haveGroup(PathGroup group);
static void sysrootify(QString &path);
};
QT_END_NAMESPACE
#endif // QMAKELIBRARYINFO_H

View File

@ -276,7 +276,7 @@ else()
target_compile_definitions(Core PUBLIC "QT_NAMESPACE=${QT_NAMESPACE}")
endif()
qt_generate_qconfig_cpp()
qt_generate_qconfig_cpp(global/qconfig.cpp.in global/qconfig.cpp)
set_target_properties(Core PROPERTIES INTERFACE_QT_COORD_TYPE "${QT_COORD_TYPE}")
set_property(TARGET Core APPEND PROPERTY COMPATIBLE_INTERFACE_STRING QT_COORD_TYPE)

View File

@ -66,9 +66,7 @@
#define QT_NO_USING_NAMESPACE
#define QT_NO_DEPRECATED
#ifndef QT_BUILD_QMAKE
#define QT_NO_REGEXP
#endif
// Keep feature-test macros in alphabetic order by feature name:
#define QT_FEATURE_alloca 1
@ -139,15 +137,7 @@
#define QT_FEATURE_zstd -1
#endif
#ifdef QT_BUILD_QMAKE
#define QT_FEATURE_commandlineparser -1
#define QT_NO_COMPRESS
#define QT_JSON_READONLY
#define QT_FEATURE_settings 1
#define QT_NO_STANDARDPATHS
#else
#define QT_FEATURE_commandlineparser 1
#define QT_FEATURE_settings -1
#endif
#endif // QT_BOOTSTRAPPED

View File

@ -1,3 +1,19 @@
/* This file is used to generate the Qt configuration info for the Core library
* and the qmake executable. The 'qt_generate_qconfig_cpp' cmake routine
* contains variables that replace '@' entires in this file. It's important to
* align these values with the following:
*
* - QLibraryInfo::LibraryPath enum in qtbase/src/corelib/global/qlibraryinfo.h
* - qtConfEntries in this file
* - QMakeLibraryInfo::LibraryPathQMakeExtras enum in
* qtbase/qmake/library/qmakelibraryinfo.h
*
* The reason for this is pointer mathematics in the QMakeLibraryInfo and
* QLibraryInfo implementation when iterating qt_configure_strs. Also
* qtConfEntries are strongly bound to QLibraryInfo::LibraryPath and
* QMakeLibraryInfo::LibraryPathQMakeExtras enums.
*/
/* Installation date */
static const char qt_configure_installation [12+11] = "qt_instdate=2012-12-20";
/* Installation Info */
@ -31,3 +47,58 @@ static const char qt_configure_strs[] =
# define QT_CONFIGURE_EXT_PREFIX_PATH qt_configure_ext_prefix_path_str + 12
# define QT_CONFIGURE_HOST_PREFIX_PATH qt_configure_host_prefix_path_str + 12
#endif
/* Entries below are shared between qmake and the Core library. Please pay
* attention and read the adding rules here and inside QLibraryInfo header.
*
* To add a new entry in QLibraryInfo::LibraryPath, add it to the enum
* in qtbase/src/corelib/global/qlibraryinfo.h and:
* - add its relative path in the qtConfEntries[] array below
* (the key is what appears in a qt.conf file)
* - add a property name in qmake/property.cpp propList[] array
* (it's used with qmake -query)
* - add to qt_config.prf, qt_module.prf, qt_module_fwdpri.prf
*/
#ifdef QT_BUILD_QMAKE
constexpr size_t qtConfEntriesKeySize = 23;
#else
constexpr size_t qtConfEntriesKeySize = 19;
#endif
static const struct {
char key[qtConfEntriesKeySize], value[13];
} qtConfEntries[] = {
{ "Prefix", "." },
{ "Documentation", "doc" }, // should be ${Data}/doc
{ "Headers", "include" },
{ "Libraries", "lib" },
#ifdef Q_OS_WIN
{ "LibraryExecutables", "bin" },
#else
{ "LibraryExecutables", "libexec" }, // should be ${ArchData}/libexec
#endif
{ "Binaries", "bin" },
{ "Plugins", "plugins" }, // should be ${ArchData}/plugins
{ "Qml2Imports", "qml" }, // should be ${ArchData}/qml
{ "ArchData", "." },
{ "Data", "." },
{ "Translations", "translations" }, // should be ${Data}/translations
{ "Examples", "examples" },
{ "Tests", "tests" },
// Put new entries above this line ONLY!
#ifdef QT_BUILD_QMAKE
{ "Sysroot", "" },
{ "SysrootifyPrefix", "" },
{ "HostBinaries", "bin" },
{ "HostLibraryExecutables", "libexec" },
{ "HostLibraries", "lib" },
{ "HostData", "." },
{ "TargetSpec", "" },
{ "HostSpec", "" },
{ "HostPrefix", "" },
#endif
};
static const char platformsSection[] = "Platforms";

View File

@ -1903,12 +1903,6 @@ bool qSharedBuild() noexcept
\sa QT_DISABLE_DEPRECATED_BEFORE
*/
#if defined(QT_BUILD_QMAKE)
// needed to bootstrap qmake
static const unsigned int qt_one = 1;
const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian);
#endif
#if defined(Q_OS_MAC)
QT_BEGIN_INCLUDE_NAMESPACE
@ -1982,13 +1976,8 @@ Q_GLOBAL_STATIC(QWindowsSockInit, winsockInit)
static QString readVersionRegistryString(const wchar_t *subKey)
{
#if !defined(QT_BUILD_QMAKE)
return QWinRegistryKey(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)")
return QWinRegistryKey(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)")
.stringValue(subKey);
#else
Q_UNUSED(subKey);
return QString();
#endif
}
static inline QString windows10ReleaseId()

View File

@ -47,13 +47,7 @@
#include "qlibraryinfo.h"
#include "qscopedpointer.h"
#ifdef QT_BUILD_QMAKE
QT_BEGIN_NAMESPACE
extern QString qmake_libraryInfoFile();
QT_END_NAMESPACE
#else
# include "qcoreapplication.h"
#endif
#include "qcoreapplication.h"
#include "private/qglobal_p.h"
#include "qconfig.cpp"
@ -64,12 +58,12 @@ QT_END_NAMESPACE
#include "archdetect.cpp"
#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable) && QT_CONFIG(dlopen) && !QT_CONFIG(framework)
# include <dlfcn.h>
#if QT_CONFIG(relocatable) && QT_CONFIG(dlopen) && !QT_CONFIG(framework)
# include <dlfcn.h>
#endif
#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable) && defined(Q_OS_WIN)
# include <qt_windows.h>
#if QT_CONFIG(relocatable) && defined(Q_OS_WIN)
# include <qt_windows.h>
#endif
QT_BEGIN_NAMESPACE
@ -84,14 +78,7 @@ struct QLibrarySettings
void load();
QScopedPointer<QSettings> settings;
#ifdef QT_BUILD_QMAKE
bool haveDevicePaths;
bool haveEffectiveSourcePaths;
bool haveEffectivePaths;
bool havePaths;
#else
bool reloadOnQAppAvailable;
#endif
};
Q_GLOBAL_STATIC(QLibrarySettings, qt_library_settings)
@ -99,32 +86,12 @@ class QLibraryInfoPrivate
{
public:
static QSettings *findConfiguration();
#ifdef QT_BUILD_QMAKE
static void reload()
{
if (qt_library_settings.exists())
qt_library_settings->load();
}
static bool haveGroup(QLibraryInfo::PathGroup group)
{
QLibrarySettings *ls = qt_library_settings();
return ls ? (group == QLibraryInfo::EffectiveSourcePaths
? ls->haveEffectiveSourcePaths
: group == QLibraryInfo::EffectivePaths
? ls->haveEffectivePaths
: group == QLibraryInfo::DevicePaths
? ls->haveDevicePaths
: ls->havePaths) : false;
}
#endif
static QSettings *configuration()
{
QLibrarySettings *ls = qt_library_settings();
if (ls) {
#ifndef QT_BUILD_QMAKE
if (ls->reloadOnQAppAvailable && QCoreApplication::instance() != nullptr)
ls->load();
#endif
return ls->settings.data();
} else {
return nullptr;
@ -132,8 +99,6 @@ public:
}
};
static const char platformsSection[] = "Platforms";
QLibrarySettings::QLibrarySettings()
{
load();
@ -143,48 +108,29 @@ void QLibrarySettings::load()
{
// If we get any settings here, those won't change when the application shows up.
settings.reset(QLibraryInfoPrivate::findConfiguration());
#ifndef QT_BUILD_QMAKE
reloadOnQAppAvailable = (settings.data() == nullptr && QCoreApplication::instance() == nullptr);
bool haveDevicePaths;
bool haveEffectivePaths;
bool havePaths;
#endif
if (settings) {
// This code needs to be in the regular library, as otherwise a qt.conf that
// works for qmake would break things for dynamically built Qt tools.
QStringList children = settings->childGroups();
haveDevicePaths = children.contains(QLatin1String("DevicePaths"));
#ifdef QT_BUILD_QMAKE
haveEffectiveSourcePaths = children.contains(QLatin1String("EffectiveSourcePaths"));
#else
// EffectiveSourcePaths is for the Qt build only, so needs no backwards compat trickery.
bool haveEffectiveSourcePaths = false;
#endif
haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths"));
// Backwards compat: an existing but empty file is claimed to contain the Paths section.
havePaths = (!haveDevicePaths && !haveEffectivePaths
&& !children.contains(QLatin1String(platformsSection)))
|| children.contains(QLatin1String("Paths"));
#ifndef QT_BUILD_QMAKE
if (!havePaths)
settings.reset(nullptr);
#else
} else {
haveDevicePaths = false;
haveEffectiveSourcePaths = false;
haveEffectivePaths = false;
havePaths = false;
#endif
}
}
QSettings *QLibraryInfoPrivate::findConfiguration()
{
#ifdef QT_BUILD_QMAKE
QString qtconfig = qmake_libraryInfoFile();
if (!qtconfig.isEmpty())
return new QSettings(qtconfig, QSettings::IniFormat);
#else
QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
@ -212,7 +158,6 @@ QSettings *QLibraryInfoPrivate::findConfiguration()
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
}
#endif
return nullptr; //no luck
}
@ -236,8 +181,6 @@ QSettings *QLibraryInfoPrivate::findConfiguration()
\sa QSysInfo, {Using qt.conf}
*/
#ifndef QT_BUILD_QMAKE
/*!
\internal
@ -354,81 +297,6 @@ QVersionNumber QLibraryInfo::version() noexcept
}
#endif // QT_BOOTSTRAPPED
#endif // QT_BUILD_QMAKE
/*
* To add a new entry in QLibrary::LibraryPath, add it to the enum above the bootstrapped values and:
* - add its relative path in the qtConfEntries[] array below
* (the key is what appears in a qt.conf file)
* - add a property name in qmake/property.cpp propList[] array
* (it's used with qmake -query)
* - add to qt_config.prf, qt_module.prf, qt_module_fwdpri.prf
*/
#ifdef QT_BUILD_QMAKE
constexpr size_t qtConfEntriesKeySize = 23;
#else
constexpr size_t qtConfEntriesKeySize = 19;
#endif
static const struct {
char key[qtConfEntriesKeySize], value[13];
} qtConfEntries[] = {
{ "Prefix", "." },
{ "Documentation", "doc" }, // should be ${Data}/doc
{ "Headers", "include" },
{ "Libraries", "lib" },
#ifdef Q_OS_WIN
{ "LibraryExecutables", "bin" },
#else
{ "LibraryExecutables", "libexec" }, // should be ${ArchData}/libexec
#endif
{ "Binaries", "bin" },
{ "Plugins", "plugins" }, // should be ${ArchData}/plugins
{ "Qml2Imports", "qml" }, // should be ${ArchData}/qml
{ "ArchData", "." },
{ "Data", "." },
{ "Translations", "translations" }, // should be ${Data}/translations
{ "Examples", "examples" },
{ "Tests", "tests" },
#ifdef QT_BUILD_QMAKE
{ "Sysroot", "" },
{ "SysrootifyPrefix", "" },
{ "HostBinaries", "bin" },
{ "HostLibraryExecutables", "libexec" },
{ "HostLibraries", "lib" },
{ "HostData", "." },
{ "TargetSpec", "" },
{ "HostSpec", "" },
{ "HostPrefix", "" },
#endif
};
#ifdef QT_BUILD_QMAKE
void QLibraryInfo::reload()
{
QLibraryInfoPrivate::reload();
}
void QLibraryInfo::sysrootify(QString *path)
{
if (!QVariant::fromValue(rawLocation(SysrootifyPrefixPath, FinalPaths)).toBool())
return;
const QString sysroot = rawLocation(SysrootPath, FinalPaths);
if (sysroot.isEmpty())
return;
if (path->length() > 2 && path->at(1) == QLatin1Char(':')
&& (path->at(2) == QLatin1Char('/') || path->at(2) == QLatin1Char('\\'))) {
path->replace(0, 2, sysroot); // Strip out the drive on Windows targets
} else {
path->prepend(sysroot);
}
}
#endif // QT_BUILD_QMAKE
#ifndef QT_BUILD_QMAKE
static QString prefixFromAppDirHelper()
{
QString appDir;
@ -458,9 +326,8 @@ static QString prefixFromAppDirHelper()
return appDir;
}
#endif
#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(relocatable)
#if QT_CONFIG(relocatable)
#if !defined(QT_STATIC) && !(defined(Q_OS_DARWIN) && QT_CONFIG(framework)) \
&& (QT_CONFIG(dlopen) || defined(Q_OS_WIN))
static QString prefixFromQtCoreLibraryHelper(const QString &qtCoreLibraryPath)
@ -600,42 +467,9 @@ static QString getRelocatablePrefix()
}
#endif
#if defined(QT_BUILD_QMAKE)
QString qmake_abslocation();
static QString getPrefixFromHostBinDir(const char *hostBinDirToPrefixPath)
static QString getPrefix()
{
const QString canonicalQMakePath = QFileInfo(qmake_abslocation()).canonicalPath();
return QDir::cleanPath(canonicalQMakePath + QLatin1Char('/')
+ QLatin1String(hostBinDirToPrefixPath));
}
static QString getExtPrefixFromHostBinDir()
{
return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_EXTPREFIX_PATH);
}
static QString getHostPrefixFromHostBinDir()
{
return getPrefixFromHostBinDir(QT_CONFIGURE_HOSTBINDIR_TO_HOSTPREFIX_PATH);
}
#endif
static QString getPrefix(
#ifdef QT_BUILD_QMAKE
QLibraryInfo::PathGroup group
#endif
)
{
#if defined(QT_BUILD_QMAKE)
# if QT_CONFIGURE_CROSSBUILD
if (group == QLibraryInfo::DevicePaths)
return QString::fromLocal8Bit(QT_CONFIGURE_PREFIX_PATH);
# else
Q_UNUSED(group);
# endif
return getExtPrefixFromHostBinDir();
#elif QT_CONFIG(relocatable)
#if QT_CONFIG(relocatable)
return getRelocatablePrefix();
#else
return QString::fromLocal8Bit(QT_CONFIGURE_PREFIX_PATH);
@ -656,40 +490,10 @@ static QString getPrefix(
QString QLibraryInfo::path(LibraryPath p)
{
const LibraryPath loc = p;
#ifdef QT_BUILD_QMAKE // ends inside rawLocation !
QString ret = rawLocation(loc, FinalPaths);
// Automatically prepend the sysroot to target paths
if (loc < SysrootPath || loc > LastHostPath)
sysrootify(&ret);
return ret;
}
QString
QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
{
#endif // QT_BUILD_QMAKE, started inside path!
QString ret;
bool fromConf = false;
#if QT_CONFIG(settings)
#ifdef QT_BUILD_QMAKE
// Logic for choosing the right data source: if EffectivePaths are requested
// and qt.conf with that section is present, use it, otherwise fall back to
// FinalPaths. For FinalPaths, use qt.conf if present and contains not only
// [EffectivePaths], otherwise fall back to builtins.
// EffectiveSourcePaths falls back to EffectivePaths.
// DevicePaths falls back to FinalPaths.
PathGroup orig_group = group;
if (QLibraryInfoPrivate::haveGroup(group)
|| (group == EffectiveSourcePaths
&& (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group)))
|| ((group == EffectivePaths || group == DevicePaths)
&& (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))
|| (group = orig_group, false))
#else
if (QLibraryInfoPrivate::configuration())
#endif
{
fromConf = true;
@ -708,28 +512,9 @@ QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
if (!key.isNull()) {
QSettings *config = QLibraryInfoPrivate::configuration();
config->beginGroup(QLatin1String(
#ifdef QT_BUILD_QMAKE
group == DevicePaths ? "DevicePaths" :
group == EffectiveSourcePaths ? "EffectiveSourcePaths" :
group == EffectivePaths ? "EffectivePaths" :
#endif
"Paths"));
config->beginGroup(QLatin1String("Paths"));
ret = config->value(key, defaultValue).toString();
#ifdef QT_BUILD_QMAKE
if (ret.isEmpty()) {
if (loc == HostPrefixPath)
ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key),
QLatin1String(qtConfEntries[PrefixPath].value)).toString();
else if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath)
fromConf = false;
// The last case here is SysrootPath, which can be legitimately empty.
// All other keys have non-empty fallbacks to start with.
}
#endif
int startIndex = 0;
forever {
startIndex = ret.indexOf(QLatin1Char('$'), startIndex);
@ -765,59 +550,27 @@ QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
// strlen is meaningless.
const char * volatile path = nullptr;
if (loc == PrefixPath) {
ret = getPrefix(
#ifdef QT_BUILD_QMAKE
group
#endif
);
ret = getPrefix();
} 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) {
static const QByteArray hostPrefixPath = getHostPrefixFromHostBinDir().toLatin1();
path = hostPrefixPath.constData();
# endif
}
if (path)
ret = QString::fromLocal8Bit(path);
}
#ifdef QT_BUILD_QMAKE
// These values aren't actually paths and thus need to be returned verbatim.
if (loc == TargetSpecPath || loc == HostSpecPath || loc == SysrootifyPrefixPath)
return ret;
#endif
if (!ret.isEmpty() && QDir::isRelativePath(ret)) {
QString baseDir;
#ifdef QT_BUILD_QMAKE
if (loc == HostPrefixPath || loc == PrefixPath || loc == SysrootPath) {
// We make the prefix/sysroot path absolute to the executable's directory.
// loc == PrefixPath while a sysroot is set would make no sense here.
// loc == SysrootPath only makes sense if qmake lives inside the sysroot itself.
baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath();
} else if (loc > SysrootPath && loc <= LastHostPath) {
// We make any other host path absolute to the host prefix directory.
baseDir = rawLocation(HostPrefixPath, group);
} else {
// we make any other path absolute to the prefix directory
baseDir = rawLocation(PrefixPath, group);
if (group == EffectivePaths)
sysrootify(&baseDir);
}
#else
if (loc == PrefixPath) {
baseDir = prefixFromAppDirHelper();
} else {
// we make any other path absolute to the prefix directory
baseDir = path(PrefixPath);
}
#endif // QT_BUILD_QMAKE
ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret);
}
return ret;
@ -838,7 +591,7 @@ QLibraryInfo::rawLocation(LibraryPath loc, PathGroup group)
QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
{
#if !defined(QT_BUILD_QMAKE) && QT_CONFIG(settings)
#if QT_CONFIG(settings)
QScopedPointer<const QSettings> settings(QLibraryInfoPrivate::findConfiguration());
if (!settings.isNull()) {
const QString key = QLatin1String(platformsSection)
@ -849,7 +602,7 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
}
#else
Q_UNUSED(platformName);
#endif // !QT_BUILD_QMAKE && settings
#endif // settings
return QStringList();
}

View File

@ -73,20 +73,7 @@ public:
ExamplesPath,
TestsPath,
// Insert new values above this line
// Please read the comments in qlibraryinfo.cpp before adding
#ifdef QT_BUILD_QMAKE
// These are not subject to binary compatibility constraints
SysrootPath,
SysrootifyPrefixPath,
HostBinariesPath,
HostLibraryExecutablesPath,
HostLibrariesPath,
HostDataPath,
TargetSpecPath,
HostSpecPath,
HostPrefixPath,
LastHostPath = HostPrefixPath,
#endif
// Please read the comments in qconfig.cpp.in before adding
SettingsPath = 100
};
static QString path(LibraryPath p);
@ -96,13 +83,6 @@ public:
static QString location(LibraryLocation location)
{ return path(location); }
#endif
#ifdef QT_BUILD_QMAKE
enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths, DevicePaths };
static QString rawLocation(LibraryPath, PathGroup);
static void reload();
static void sysrootify(QString *path);
#endif
static QStringList platformPluginArguments(const QString &platformName);
private:

View File

@ -57,18 +57,9 @@ public:
WordSize = (sizeof(void *)<<3)
};
#if defined(QT_BUILD_QMAKE)
enum Endian {
BigEndian,
LittleEndian
};
/* needed to bootstrap qmake */
static const int ByteOrder;
#elif defined(Q_BYTE_ORDER)
enum Endian {
BigEndian,
LittleEndian
# ifdef Q_QDOC
, ByteOrder = BigEndian or LittleEndian
# elif Q_BYTE_ORDER == Q_BIG_ENDIAN
@ -79,7 +70,6 @@ public:
# error "Undefined byte order"
# endif
};
#endif
static QString buildCpuArchitecture();
static QString currentCpuArchitecture();

View File

@ -644,7 +644,7 @@ static inline QByteArray fileId(HANDLE handle)
// File ID for Windows starting from version 8.
QByteArray fileIdWin8(HANDLE handle)
{
#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)
#if !defined(QT_BOOTSTRAPPED)
QByteArray result;
FILE_ID_INFO infoEx;
if (GetFileInformationByHandleEx(handle,
@ -658,7 +658,7 @@ QByteArray fileIdWin8(HANDLE handle)
result = fileId(handle); // GetFileInformationByHandleEx() is observed to fail for FAT32, QTBUG-74759
}
return result;
#else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
#else // !QT_BOOTSTRAPPED
return fileId(handle);
#endif
}

View File

@ -60,9 +60,7 @@
#include "qrect.h"
#endif // !QT_NO_GEOM_VARIANT
#ifndef QT_BUILD_QMAKE
# include "qcoreapplication.h"
#endif
#include "qcoreapplication.h"
#ifndef QT_BOOTSTRAPPED
#include "qsavefile.h"
@ -2661,7 +2659,6 @@ QSettings::QSettings(const QString &fileName, Format format)
d_ptr->q_ptr = this;
}
# ifndef QT_BUILD_QMAKE
QSettings::QSettings(Scope scope)
: d_ptr(QSettingsPrivate::create(globalDefaultFormat, scope,
# ifdef Q_OS_DARWIN
@ -2678,7 +2675,6 @@ QSettings::QSettings(Scope scope)
{
d_ptr->q_ptr = this;
}
# endif
#endif
/*!

View File

@ -138,9 +138,7 @@ public:
QSettings(Format format, Scope scope, const QString &organization,
const QString &application = QString());
QSettings(const QString &fileName, Format format);
# ifndef QT_BUILD_QMAKE
explicit QSettings(Scope scope = UserScope);
# endif
#endif
~QSettings();

View File

@ -201,7 +201,6 @@ QJsonValue qt_convertToJson(QCborContainerPrivate *d, qsizetype idx,
static QJsonValue convertExtendedTypeToJson(QCborContainerPrivate *d)
{
#ifndef QT_BUILD_QMAKE
qint64 tag = d->elements.at(0).value;
switch (tag) {
@ -222,7 +221,6 @@ static QJsonValue convertExtendedTypeToJson(QCborContainerPrivate *d)
return s;
}
}
#endif
// for all other tags, ignore it and return the converted tagged item
return qt_convertToJson(d, 1);

View File

@ -2999,7 +2999,7 @@ void QByteArray::clear()
d.clear();
}
#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
/*! \relates QByteArray

View File

@ -675,7 +675,7 @@ inline std::string QByteArray::toStdString() const
inline QByteArray QByteArray::fromStdString(const std::string &s)
{ return QByteArray(s.data(), qsizetype(s.size())); }
#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QByteArray &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QByteArray &);
#endif

View File

@ -595,7 +595,7 @@ QVariant QSystemLocalePrivate::uiLanguages()
{
unsigned long cnt = 0;
QVarLengthArray<wchar_t, 64> buf(64);
# if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE) // Not present in MinGW 4.9/bootstrap builds.
# if !defined(QT_BOOTSTRAPPED) // Not present in MinGW 4.9/bootstrap builds.
unsigned long size = buf.size();
if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
size = 0;
@ -606,7 +606,7 @@ QVariant QSystemLocalePrivate::uiLanguages()
return QStringList();
}
}
# endif // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
# endif // !QT_BOOTSTRAPPED
QStringList result;
result.reserve(cnt);
const wchar_t *str = buf.constData();

View File

@ -9735,7 +9735,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
equal to string \a s2; otherwise returns \c false.
*/
#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
/*!
\fn QDataStream &operator<<(QDataStream &stream, const QString &string)
\relates QString

View File

@ -1454,7 +1454,7 @@ inline std::u32string QString::toStdU32String() const
return u32str;
}
#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QString &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QString &);
#endif