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:
parent
e912132886
commit
2d2cb6434f
@ -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.6.0
|
||||
|
@ -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});
|
||||
|
||||
|
37
configure
vendored
37
configure
vendored
@ -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
|
||||
@ -3952,7 +3945,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)
|
||||
@ -4094,6 +4087,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"
|
||||
@ -6690,13 +6686,22 @@ echo "Done running configuration tests."
|
||||
# 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"
|
||||
;;
|
||||
|
@ -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
|
||||
|
@ -102,6 +102,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 \
|
||||
|
@ -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 \
|
||||
|
@ -41,11 +41,10 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define QT_VERSION_STR "5.6.0"
|
||||
/*
|
||||
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))
|
||||
*/
|
||||
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -198,20 +198,18 @@ Configure::Configure(int& argc, char** argv) : verbose(0)
|
||||
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())
|
||||
@ -3632,6 +3630,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 {
|
||||
@ -4031,7 +4035,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) {
|
||||
@ -4294,7 +4298,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
|
||||
|
Loading…
Reference in New Issue
Block a user