1
0
forked from pool/libqt5-qtbase
libqt5-qtbase/move-the-official-Qt-version-from-qglobal-to-qmake-conf.patch

333 lines
16 KiB
Diff
Raw Normal View History

From 2d2cb6434f1d6e00f421c98b20467ff3f4388319 Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Thu, 17 Sep 2015 18:17:40 -0700
Subject: Move the official Qt version from qglobal.h to .qmake.conf
It's easier to parse than qglobal.h. The objective is actually to have
macros with parts of the version number, so the major or minor numbers
could be used in other preprocessor macros.
Change-Id: I42e7ef1a481840699a8dffff1404eda1dd5c308d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
---
.qmake.conf | 3 +--
bin/syncqt.pl | 8 +-------
configure | 37 +++++++++++++++++++++----------------
configure.bat | 20 ++++++++++++++++++--
qmake/Makefile.unix | 1 +
qmake/Makefile.win32 | 1 +
src/corelib/global/qglobal.h | 4 ++--
tools/configure/Makefile.mingw | 2 +-
tools/configure/Makefile.win32 | 2 +-
tools/configure/configureapp.cpp | 37 ++++++++++++++++++++++---------------
10 files changed, 69 insertions(+), 46 deletions(-)
diff --git a/.qmake.conf b/.qmake.conf
index 481544b253daa7a41485c5eeddd6d2ef694a4b70..732b5da2621f2fc821404e7aef3ab7ed576dfc0c 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -5,5 +5,4 @@ CONFIG += warning_clean
QT_SOURCE_TREE = $$PWD
QT_BUILD_TREE = $$shadowed($$PWD)
-# In qtbase, all modules follow qglobal.h
-MODULE_VERSION = $$QT_VERSION
+MODULE_VERSION = 5.5.1
diff --git a/bin/syncqt.pl b/bin/syncqt.pl
index 3b3e127e86e664185a6b94829ac968673bf75651..c75390c561debf6558a4b7ae4b237b44a7c8f16b 100755
--- a/bin/syncqt.pl
+++ b/bin/syncqt.pl
@@ -786,6 +786,7 @@ while ( @ARGV ) {
# if we have no $basedir we cannot be sure which sources you want, so die
die "Could not find any sync.profile for your module!\nPass <module directory> to syncqt to sync your header files.\nsyncqt failed" if (!$basedir);
+die "The -version argument is mandatory" if (!$module_version);
our @ignore_headers = ();
our @ignore_for_master_contents = ();
@@ -803,13 +804,6 @@ my %allmoduleheadersprivate = map { $_ => 1 } @allmoduleheadersprivate;
$isunix = checkUnix; #cache checkUnix
-if (!$module_version) {
- my $filco = fileContents($basedir."/src/corelib/global/qglobal.h");
- if ($filco !~ m,.*^#[ \t]*define[ \t]+QT_VERSION_STR[ \t]+"([^"]+)".*,sm) {
- die "Cannot determine Qt/Module version. Use -version.\n";
- }
- $module_version = $1;
-}
foreach my $lib (@modules_to_sync) {
die "No such module: $lib" unless(defined $modules{$lib});
diff --git a/configure b/configure
index cea62fbc0c46ae54938df282fffbbfde5bf794d6..45c74a61dc04b3cb80452eec22fda6189fc29795 100755
--- a/configure
+++ b/configure
@@ -539,23 +539,16 @@ fi
#-----------------------------------------------------------------------------
# Qt version detection
#-----------------------------------------------------------------------------
-QT_VERSION=`grep '^# *define *QT_VERSION_STR' "$relpath"/src/corelib/global/qglobal.h`
+QT_VERSION=
QT_MAJOR_VERSION=
QT_MINOR_VERSION=0
QT_PATCH_VERSION=0
-if [ -n "$QT_VERSION" ]; then
- QT_VERSION=`echo $QT_VERSION | sed 's,^# *define *QT_VERSION_STR *"*\([^ ]*\)"$,\1,'`
- MAJOR=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\1,'`
- if [ -n "$MAJOR" ]; then
- MINOR=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\2,'`
- PATCH=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\3,'`
- QT_MAJOR_VERSION="$MAJOR"
- [ -z "$MINOR" ] || QT_MINOR_VERSION="$MINOR"
- [ -z "$PATCH" ] || QT_PATCH_VERSION="$PATCH"
- fi
-fi
+eval `sed -n -e 's/^MODULE_VERSION = \(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*\)$/QT_VERSION=\1\
+ QT_MAJOR_VERSION=\2\
+ QT_MINOR_VERSION=\3\
+ QT_PATCH_VERSION=\4/p' < "$relpath"/.qmake.conf`
if [ -z "$QT_MAJOR_VERSION" ]; then
- echo "Cannot process version from qglobal.h: $QT_VERSION"
+ echo "Cannot process version from .qmake.conf"
echo "Cannot proceed."
exit 1
fi
@@ -3896,7 +3889,7 @@ if [ -e "$relpath/.git" ]; then
exit 1
fi
- "$relpath/bin/syncqt.pl" -minimal -module QtCore "$relpath" || exit 1
+ "$relpath/bin/syncqt.pl" -version $QT_VERSION -minimal -module QtCore "$relpath" || exit 1
fi
# $1: input variable name (awk regexp)
@@ -4038,6 +4031,9 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
fi
echo "QMAKESPEC = $adjqmakespec" >> "$mkfile"
echo "QT_VERSION = $QT_VERSION" >> "$mkfile"
+ echo "QT_MAJOR_VERSION = $QT_MAJOR_VERSION" >> "$mkfile"
+ echo "QT_MINOR_VERSION = $QT_MINOR_VERSION" >> "$mkfile"
+ echo "QT_PATCH_VERSION = $QT_PATCH_VERSION" >> "$mkfile"
echo "EXTRA_CFLAGS = $EXTRA_CFLAGS" >> "$mkfile"
echo "EXTRA_CXXFLAGS = $EXTRA_CXXFLAGS" >> "$mkfile"
echo "QTOBJS =" $EXTRA_OBJS >> "$mkfile"
@@ -6514,13 +6510,22 @@ esac
# part of configuration information goes into qconfig.h
#-------------------------------------------------------------------------------
+# start with Qt's version number
+cat > "$outpath/src/corelib/global/qconfig.h.new" <<EOF
+#define QT_VERSION_MAJOR $QT_MAJOR_VERSION
+#define QT_VERSION_MINOR $QT_MINOR_VERSION
+#define QT_VERSION_PATCH $QT_PATCH_VERSION
+#define QT_VERSION_STR "$QT_VERSION"
+
+EOF
+
case "$CFG_QCONFIG" in
full)
- echo "/* Everything */" >"$outpath/src/corelib/global/qconfig.h.new"
+ echo "/* Everything */" >>"$outpath/src/corelib/global/qconfig.h.new"
;;
*)
tmpconfig="$outpath/src/corelib/global/qconfig.h.new"
- echo "#ifndef QT_BOOTSTRAPPED" >"$tmpconfig"
+ echo "#ifndef QT_BOOTSTRAPPED" >>"$tmpconfig"
cat "$CFG_QCONFIG_PATH" >>"$tmpconfig"
echo "#endif" >>"$tmpconfig"
;;
diff --git a/configure.bat b/configure.bat
index 1220bfedc2de5ad78edbd636f4af7e39dbfde27b..47acf26d6278d43e70d3d6369a4f1cf06b3a57f7 100644
--- a/configure.bat
+++ b/configure.bat
@@ -34,6 +34,7 @@
@echo off
set QTSRC=%~dp0
set QTDIR=%CD%
+
if not exist %QTSRC%.gitignore goto sconf
echo Please wait while bootstrapping configure ...
@@ -47,7 +48,18 @@ if not exist mkspecs (
md mkspecs
if errorlevel 1 goto exit
)
-perl %QTSRC%bin\syncqt.pl -minimal -module QtCore -outdir "%QTDIR%" %QTSRC%
+
+rem Extract Qt's version from .qmake.conf
+for /f "eol=# tokens=1,2,3,4 delims=.= " %%i in (%QTSRC%.qmake.conf) do (
+ if %%i == MODULE_VERSION (
+ set QTVERMAJ=%%j
+ set QTVERMIN=%%k
+ set QTVERPAT=%%l
+ )
+)
+set QTVERSION=%QTVERMAJ%.%QTVERMIN%.%QTVERPAT%
+
+perl %QTSRC%bin\syncqt.pl -minimal -version %QTVERSION% -module QtCore -outdir "%QTDIR%" %QTSRC%
if errorlevel 1 goto exit
if not exist tools\configure (
@@ -62,7 +74,11 @@ if not "%jom.exe%" == "" set make=jom
echo #### Generated by configure.bat - DO NOT EDIT! ####> Makefile
echo/>> Makefile
-for /f "tokens=3 usebackq" %%V in (`findstr QT_VERSION_STR %QTSRC%src\corelib\global\qglobal.h`) do @echo QTVERSION = %%~V>> Makefile
+echo QTVERSION = %QTVERSION%>> Makefile
+rem These must have trailing spaces to avoid misinterpretation as 5>>, etc.
+echo QT_VERSION_MAJOR = %QTVERMAJ% >> Makefile
+echo QT_VERSION_MINOR = %QTVERMIN% >> Makefile
+echo QT_VERSION_PATCH = %QTVERPAT% >> Makefile
if not "%icl.exe%" == "" (
echo CXX = icl>>Makefile
echo EXTRA_CXXFLAGS = /Zc:forScope>>Makefile
diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix
index 86f884fe209195d814e8037fd8e9352e3e585ad0..d2d7bf7e6327fa57576c5dfe803c335ef4b965ca 100644
--- a/qmake/Makefile.unix
+++ b/qmake/Makefile.unix
@@ -101,6 +101,7 @@ CPPFLAGS = -g $(EXTRA_CPPFLAGS) \
-I$(BUILD_PATH)/src/corelib/global -DHAVE_QCONFIG_CPP \
-I$(QMAKESPEC) \
-I$(SOURCE_PATH)/tools/shared \
+ -DQT_VERSION_STR=\"$(QT_VERSION)\" -DQT_VERSION_MAJOR=$(QT_MAJOR_VERSION) -DQT_VERSION_MINOR=$(QT_MINOR_VERSION) -DQT_VERSION_PATCH=$(QT_PATCH_VERSION) \
-DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \
-DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \
-DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \
diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32
index 9dda6ca1e7b7399e6179732b677824d624e745d0..fdbb9c8499a78a980cf3e0a7900567320aae9676 100644
--- a/qmake/Makefile.win32
+++ b/qmake/Makefile.win32
@@ -36,6 +36,7 @@ CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \
-I$(BUILD_PATH)\src\corelib\global -DHAVE_QCONFIG_CPP \
-I$(SOURCE_PATH)\mkspecs\$(QMAKESPEC) \
-I$(SOURCE_PATH)\tools\shared \
+ -DQT_VERSION_STR=\"$(QT_VERSION)\" -DQT_VERSION_MAJOR=$(QT_MAJOR_VERSION) -DQT_VERSION_MINOR=$(QT_MINOR_VERSION) -DQT_VERSION_PATCH=$(QT_PATCH_VERSION) \
-DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \
-DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \
-DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 97c5f37cab02c35bfdb75ec8ab58b97dc0a6b1de..15d9b6536a9f1ee85371fea6dc9115438eec32d1 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -41,11 +41,10 @@
#include <stddef.h>
-#define QT_VERSION_STR "5.5.1"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x050501
+#define QT_VERSION QT_VERSION_CHECK(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH)
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
@@ -55,6 +54,7 @@
#include <QtCore/qconfig.h>
#include <QtCore/qfeatures.h>
#endif
+
#ifdef _MSC_VER
# define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE)
#else
diff --git a/tools/configure/Makefile.mingw b/tools/configure/Makefile.mingw
index 9ac99fd678f46445771147d80542e9bba3b37acf..6ec77c8ab511c4375711964fbb41e9a817decf2e 100644
--- a/tools/configure/Makefile.mingw
+++ b/tools/configure/Makefile.mingw
@@ -4,7 +4,7 @@ CONFSRC = $(TOOLSRC)/configure
RAW_PCH = configure_pch.h
PCH = $(RAW_PCH).gch/c++
-DEFINES = -DUNICODE -DQT_NO_DATASTREAM -DQT_NO_CODECS -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE
+DEFINES = -DUNICODE -DQT_NO_DATASTREAM -DQT_NO_CODECS -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE -DQT_VERSION_STR=\"$(QTVERSION)\" -DQT_VERSION_MAJOR=$(QT_VERSION_MAJOR) -DQT_VERSION_MINOR=$(QT_VERSION_MINOR) -DQT_VERSION_PATCH=$(QT_VERSION_PATCH)
INCPATH = -I"../../include" -I"../../include/QtCore" -I"../../include/QtCore/$(QTVERSION)" -I"../../include/QtCore/$(QTVERSION)/QtCore" -I"$(TOOLSRC)/shared" -I"$(QTSRC)mkspecs/win32-g++"
CXXFLAGS_BARE = -fno-rtti -fno-exceptions -mthreads -Wall -Wextra $(DEFINES) $(INCPATH)
CXXFLAGS = -include $(RAW_PCH) $(CXXFLAGS_BARE)
diff --git a/tools/configure/Makefile.win32 b/tools/configure/Makefile.win32
index 8c6d213e4243b444357712cf6c0d8d4dcfa3ff36..456e441c6f548bc3e3c0ac0a8847bf965aeb5902 100644
--- a/tools/configure/Makefile.win32
+++ b/tools/configure/Makefile.win32
@@ -3,7 +3,7 @@ TOOLSRC = $(QTSRC)tools
CONFSRC = $(TOOLSRC)\configure
PCH = configure_pch.pch
-DEFINES = -DUNICODE -DQT_NO_CODECS -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE
+DEFINES = -DUNICODE -DQT_NO_CODECS -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -D_CRT_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE -DQT_VERSION_STR=\"$(QTVERSION)\" -DQT_VERSION_MAJOR=$(QT_VERSION_MAJOR) -DQT_VERSION_MINOR=$(QT_VERSION_MINOR) -DQT_VERSION_PATCH=$(QT_VERSION_PATCH)
INCPATH = -I"..\..\include" -I"..\..\include\QtCore" -I"..\..\include\QtCore\$(QTVERSION)" -I"..\..\include\QtCore\$(QTVERSION)\QtCore" -I"$(TOOLSRC)\shared" -I"$(QTSRC)mkspecs\win32-msvc2008"
CXXFLAGS_BARE = -nologo -Zc:wchar_t -W3 -GR -EHsc -w34100 -w34189 $(CFLAGS_CRT) $(EXTRA_CXXFLAGS) $(DEFINES) $(INCPATH)
CXXFLAGS = -FIconfigure_pch.h -Yuconfigure_pch.h -Fp$(PCH) -MP $(CXXFLAGS_BARE)
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 3bf0546ac1628e8ab51979526bb102d1e8db8de8..36cc8b03cd24ddb5d01d85fc57254059e76a49da 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -197,20 +197,18 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg";
QString version;
- QFile qglobal_h(sourcePath + "/src/corelib/global/qglobal.h");
- if (qglobal_h.open(QFile::ReadOnly)) {
- QTextStream read(&qglobal_h);
- QRegExp version_regexp("^# *define *QT_VERSION_STR *\"([^\"]*)\"");
- QString line;
- while (!read.atEnd()) {
- line = read.readLine();
- if (version_regexp.exactMatch(line)) {
- version = version_regexp.cap(1).trimmed();
- if (!version.isEmpty())
- break;
- }
+ QFile qmake_conf(sourcePath + "/.qmake.conf");
+ if (qmake_conf.open(QFile::ReadOnly)) {
+ while (!qmake_conf.atEnd()) {
+ static const char beginning[] = "MODULE_VERSION = ";
+ QByteArray line = qmake_conf.readLine();
+ if (!line.startsWith(beginning))
+ continue;
+
+ version = qMove(line).mid(int(strlen(beginning))).trimmed();
+ break;
}
- qglobal_h.close();
+ qmake_conf.close();
}
if (version.isEmpty())
@@ -3540,6 +3538,12 @@ void Configure::generateConfigfiles()
{
FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig.h");
+ tmpStream << "#define QT_VERSION_MAJOR " << dictionary["VERSION_MAJOR"] << endl
+ << "#define QT_VERSION_MINOR " << dictionary["VERSION_MINOR"] << endl
+ << "#define QT_VERSION_PATCH " << dictionary["VERSION_PATCH"] << endl
+ << "#define QT_VERSION_STR \"" << dictionary["VERSION"] << "\"\n"
+ << endl;
+
if (dictionary[ "QCONFIG" ] == "full") {
tmpStream << "/* Everything */" << endl;
} else {
@@ -3939,7 +3943,7 @@ void Configure::generateHeaders()
QStringList args;
args << "perl" << "-w";
args += sourcePath + "/bin/syncqt.pl";
- args << "-minimal" << "-module" << "QtCore";
+ args << "-version" << dictionary["VERSION"] << "-minimal" << "-module" << "QtCore";
args += sourcePath;
int retc = Environment::execute(args, QStringList(), QStringList());
if (retc) {
@@ -4202,7 +4206,10 @@ void Configure::buildQmake()
<< "INC_PATH = " << QDir::toNativeSeparators(
(QFile::exists(sourcePath + "/.git") ? ".." : sourcePath)
+ "/include") << endl;
- stream << "QT_VERSION = " << dictionary["VERSION"] << endl;
+ stream << "QT_VERSION = " << dictionary["VERSION"] << endl
+ << "QT_MAJOR_VERSION = " << dictionary["VERSION_MAJOR"] << endl
+ << "QT_MINOR_VERSION = " << dictionary["VERSION_MINOR"] << endl
+ << "QT_PATCH_VERSION = " << dictionary["VERSION_PATCH"] << endl;
if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {
stream << "QMAKESPEC = $(SOURCE_PATH)\\mkspecs\\win32-g++" << endl
<< "EXTRA_CFLAGS = -DUNICODE -ffunction-sections" << endl
--
2.6.0