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>
This commit is contained in:
Thiago Macieira 2015-09-17 18:17:40 -07:00
parent e912132886
commit 2d2cb6434f
10 changed files with 69 additions and 46 deletions

View File

@ -5,5 +5,4 @@ CONFIG += warning_clean
QT_SOURCE_TREE = $$PWD QT_SOURCE_TREE = $$PWD
QT_BUILD_TREE = $$shadowed($$PWD) QT_BUILD_TREE = $$shadowed($$PWD)
# In qtbase, all modules follow qglobal.h MODULE_VERSION = 5.6.0
MODULE_VERSION = $$QT_VERSION

View File

@ -786,6 +786,7 @@ while ( @ARGV ) {
# if we have no $basedir we cannot be sure which sources you want, so die # 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 "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_headers = ();
our @ignore_for_master_contents = (); our @ignore_for_master_contents = ();
@ -803,13 +804,6 @@ my %allmoduleheadersprivate = map { $_ => 1 } @allmoduleheadersprivate;
$isunix = checkUnix; #cache checkUnix $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) { foreach my $lib (@modules_to_sync) {
die "No such module: $lib" unless(defined $modules{$lib}); die "No such module: $lib" unless(defined $modules{$lib});

37
configure vendored
View File

@ -539,23 +539,16 @@ fi
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Qt version detection # Qt version detection
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
QT_VERSION=`grep '^# *define *QT_VERSION_STR' "$relpath"/src/corelib/global/qglobal.h` QT_VERSION=
QT_MAJOR_VERSION= QT_MAJOR_VERSION=
QT_MINOR_VERSION=0 QT_MINOR_VERSION=0
QT_PATCH_VERSION=0 QT_PATCH_VERSION=0
if [ -n "$QT_VERSION" ]; then eval `sed -n -e 's/^MODULE_VERSION = \(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*\)$/QT_VERSION=\1\
QT_VERSION=`echo $QT_VERSION | sed 's,^# *define *QT_VERSION_STR *"*\([^ ]*\)"$,\1,'` QT_MAJOR_VERSION=\2\
MAJOR=`echo $QT_VERSION | sed 's,^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*,\1,'` QT_MINOR_VERSION=\3\
if [ -n "$MAJOR" ]; then QT_PATCH_VERSION=\4/p' < "$relpath"/.qmake.conf`
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
if [ -z "$QT_MAJOR_VERSION" ]; then 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." echo "Cannot proceed."
exit 1 exit 1
fi fi
@ -3952,7 +3945,7 @@ if [ -e "$relpath/.git" ]; then
exit 1 exit 1
fi 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 fi
# $1: input variable name (awk regexp) # $1: input variable name (awk regexp)
@ -4094,6 +4087,9 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
fi fi
echo "QMAKESPEC = $adjqmakespec" >> "$mkfile" echo "QMAKESPEC = $adjqmakespec" >> "$mkfile"
echo "QT_VERSION = $QT_VERSION" >> "$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_CFLAGS = $EXTRA_CFLAGS" >> "$mkfile"
echo "EXTRA_CXXFLAGS = $EXTRA_CXXFLAGS" >> "$mkfile" echo "EXTRA_CXXFLAGS = $EXTRA_CXXFLAGS" >> "$mkfile"
echo "QTOBJS =" $EXTRA_OBJS >> "$mkfile" echo "QTOBJS =" $EXTRA_OBJS >> "$mkfile"
@ -6690,13 +6686,22 @@ echo "Done running configuration tests."
# part of configuration information goes into qconfig.h # 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 case "$CFG_QCONFIG" in
full) 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" tmpconfig="$outpath/src/corelib/global/qconfig.h.new"
echo "#ifndef QT_BOOTSTRAPPED" >"$tmpconfig" echo "#ifndef QT_BOOTSTRAPPED" >>"$tmpconfig"
cat "$CFG_QCONFIG_PATH" >>"$tmpconfig" cat "$CFG_QCONFIG_PATH" >>"$tmpconfig"
echo "#endif" >>"$tmpconfig" echo "#endif" >>"$tmpconfig"
;; ;;

View File

@ -34,6 +34,7 @@
@echo off @echo off
set QTSRC=%~dp0 set QTSRC=%~dp0
set QTDIR=%CD% set QTDIR=%CD%
if not exist %QTSRC%.gitignore goto sconf if not exist %QTSRC%.gitignore goto sconf
echo Please wait while bootstrapping configure ... echo Please wait while bootstrapping configure ...
@ -47,7 +48,18 @@ if not exist mkspecs (
md mkspecs md mkspecs
if errorlevel 1 goto exit 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 errorlevel 1 goto exit
if not exist tools\configure ( 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 #### Generated by configure.bat - DO NOT EDIT! ####> Makefile
echo/>> 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%" == "" ( if not "%icl.exe%" == "" (
echo CXX = icl>>Makefile echo CXX = icl>>Makefile
echo EXTRA_CXXFLAGS = /Zc:forScope>>Makefile echo EXTRA_CXXFLAGS = /Zc:forScope>>Makefile

View File

@ -102,6 +102,7 @@ CPPFLAGS = -g $(EXTRA_CPPFLAGS) \
-I$(BUILD_PATH)/src/corelib/global -DHAVE_QCONFIG_CPP \ -I$(BUILD_PATH)/src/corelib/global -DHAVE_QCONFIG_CPP \
-I$(QMAKESPEC) \ -I$(QMAKESPEC) \
-I$(SOURCE_PATH)/tools/shared \ -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_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \
-DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \ -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 \ -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \

View File

@ -36,6 +36,7 @@ CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \
-I$(BUILD_PATH)\src\corelib\global -DHAVE_QCONFIG_CPP \ -I$(BUILD_PATH)\src\corelib\global -DHAVE_QCONFIG_CPP \
-I$(SOURCE_PATH)\mkspecs\$(QMAKESPEC) \ -I$(SOURCE_PATH)\mkspecs\$(QMAKESPEC) \
-I$(SOURCE_PATH)\tools\shared \ -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_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \
-DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \ -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 \ -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \

View File

@ -41,11 +41,10 @@
#include <stddef.h> #include <stddef.h>
#define QT_VERSION_STR "5.6.0"
/* /*
QT_VERSION is (major << 16) + (minor << 8) + patch. QT_VERSION is (major << 16) + (minor << 8) + patch.
*/ */
#define QT_VERSION 0x050600 #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)) can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/ */
@ -55,6 +54,7 @@
#include <QtCore/qconfig.h> #include <QtCore/qconfig.h>
#include <QtCore/qfeatures.h> #include <QtCore/qfeatures.h>
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
# define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE) # define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE)
#else #else

View File

@ -4,7 +4,7 @@ CONFSRC = $(TOOLSRC)/configure
RAW_PCH = configure_pch.h RAW_PCH = configure_pch.h
PCH = $(RAW_PCH).gch/c++ 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++" 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_BARE = -fno-rtti -fno-exceptions -mthreads -Wall -Wextra $(DEFINES) $(INCPATH)
CXXFLAGS = -include $(RAW_PCH) $(CXXFLAGS_BARE) CXXFLAGS = -include $(RAW_PCH) $(CXXFLAGS_BARE)

View File

@ -3,7 +3,7 @@ TOOLSRC = $(QTSRC)tools
CONFSRC = $(TOOLSRC)\configure CONFSRC = $(TOOLSRC)\configure
PCH = configure_pch.pch 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" 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_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) CXXFLAGS = -FIconfigure_pch.h -Yuconfigure_pch.h -Fp$(PCH) -MP $(CXXFLAGS_BARE)

View File

@ -198,20 +198,18 @@ Configure::Configure(int& argc, char** argv) : verbose(0)
dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg"; dictionary[ "QT_INSTALL_SETTINGS" ] = "/etc/xdg";
QString version; QString version;
QFile qglobal_h(sourcePath + "/src/corelib/global/qglobal.h"); QFile qmake_conf(sourcePath + "/.qmake.conf");
if (qglobal_h.open(QFile::ReadOnly)) { if (qmake_conf.open(QFile::ReadOnly)) {
QTextStream read(&qglobal_h); while (!qmake_conf.atEnd()) {
QRegExp version_regexp("^# *define *QT_VERSION_STR *\"([^\"]*)\""); static const char beginning[] = "MODULE_VERSION = ";
QString line; QByteArray line = qmake_conf.readLine();
while (!read.atEnd()) { if (!line.startsWith(beginning))
line = read.readLine(); continue;
if (version_regexp.exactMatch(line)) {
version = version_regexp.cap(1).trimmed(); version = qMove(line).mid(int(strlen(beginning))).trimmed();
if (!version.isEmpty())
break; break;
} }
} qmake_conf.close();
qglobal_h.close();
} }
if (version.isEmpty()) if (version.isEmpty())
@ -3632,6 +3630,12 @@ void Configure::generateConfigfiles()
{ {
FileWriter tmpStream(buildPath + "/src/corelib/global/qconfig.h"); 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") { if (dictionary[ "QCONFIG" ] == "full") {
tmpStream << "/* Everything */" << endl; tmpStream << "/* Everything */" << endl;
} else { } else {
@ -4031,7 +4035,7 @@ void Configure::generateHeaders()
QStringList args; QStringList args;
args << "perl" << "-w"; args << "perl" << "-w";
args += sourcePath + "/bin/syncqt.pl"; args += sourcePath + "/bin/syncqt.pl";
args << "-minimal" << "-module" << "QtCore"; args << "-version" << dictionary["VERSION"] << "-minimal" << "-module" << "QtCore";
args += sourcePath; args += sourcePath;
int retc = Environment::execute(args, QStringList(), QStringList()); int retc = Environment::execute(args, QStringList(), QStringList());
if (retc) { if (retc) {
@ -4294,7 +4298,10 @@ void Configure::buildQmake()
<< "INC_PATH = " << QDir::toNativeSeparators( << "INC_PATH = " << QDir::toNativeSeparators(
(QFile::exists(sourcePath + "/.git") ? ".." : sourcePath) (QFile::exists(sourcePath + "/.git") ? ".." : sourcePath)
+ "/include") << endl; + "/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++")) { if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {
stream << "QMAKESPEC = $(SOURCE_PATH)\\mkspecs\\win32-g++" << endl stream << "QMAKESPEC = $(SOURCE_PATH)\\mkspecs\\win32-g++" << endl
<< "EXTRA_CFLAGS = -DUNICODE -ffunction-sections" << endl << "EXTRA_CFLAGS = -DUNICODE -ffunction-sections" << endl