diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-04-17 11:59:53 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-04-22 10:23:41 +0000 |
commit | e1350c56c14a5948830203023ed5d4d4221a0f87 (patch) | |
tree | f4a5e694c0ff7c8616a2941f79884f5ebaa81c51 /bin | |
parent | e0c83fb658bb352974f5485dd09df2de02ae8d92 (diff) | |
download | qtbase-e1350c56c14a5948830203023ed5d4d4221a0f87.tar.gz |
fixqt4headers.pl: Improve detection of Qt 5 location.
Obtain the location of the include files by querying
the qmake variable QT_INSTALL_HEADERS by default, which
can be overridden by the command line option.
Task-number: QTBUG-45662
Change-Id: I03a781e9b98f5e2980dbaef86eedd05aec0103ce
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fixqt4headers.pl | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/bin/fixqt4headers.pl b/bin/fixqt4headers.pl index b08deb0ba2..59daecae86 100755 --- a/bin/fixqt4headers.pl +++ b/bin/fixqt4headers.pl @@ -47,7 +47,8 @@ my $stripModule = 0; my $fixedFileCount = 0; my $fileCount = 0; my $verbose = 0; -my $qtdir = $ENV{'QTDIR'}; +my $qtdir; +my $qtIncludeDir; my $USAGE=<<EOF; This script replaces all Qt 4 style includes with Qt 5 includes. @@ -114,44 +115,54 @@ sub fixHeaders sub findQtHeaders { - my ($dirName,$baseDir) = @_; + my ($dirName,$includeDir) = @_; local (*DIR); - opendir(DIR, $baseDir . '/include/' . $dirName) || die ('Unable to open ' .$baseDir . '/include/' . $dirName . ': ' . $!); + my $moduleIncludeDir = $includeDir . '/' . $dirName; + opendir(DIR, $moduleIncludeDir) || die ('Unable to open ' . $moduleIncludeDir . ': ' . $!); my @headers = readdir(DIR); closedir(DIR); foreach my $header (@headers) { - next if (-d ($baseDir . '/include/' . $dirName . '/' . $header) || $header =~ /\.pri$/); + next if (-d ($moduleIncludeDir . '/' . $header) || $header =~ /\.pri$/); $headerSubst{$header} = $stripModule ? $header : ($dirName . '/' . $header); } } # -------- MAIN -die "This script requires the QTDIR environment variable pointing to Qt 5\n" unless $qtdir; +if ($qtdir) { + $qtIncludeDir = $qtdir . '/include'; +} else { + $qtIncludeDir = `qmake -query QT_INSTALL_HEADERS`; + chop($qtIncludeDir); +} + +die "The location of the Qt 5 include files could not be determined.\n" + ."Please ensure qmake can be found in PATH or pass the command line option --qtdir.\n" + unless -d $qtIncludeDir; -findQtHeaders('QtCore', $qtdir); -findQtHeaders('QtConcurrent', $qtdir); -findQtHeaders('QtWidgets', $qtdir); -findQtHeaders('QtPrintSupport', $qtdir); +findQtHeaders('QtCore', $qtIncludeDir); +findQtHeaders('QtConcurrent', $qtIncludeDir); +findQtHeaders('QtWidgets', $qtIncludeDir); +findQtHeaders('QtPrintSupport', $qtIncludeDir); -if (-d $qtdir . '/include/QtMultimedia') { - findQtHeaders('QtMultimedia', $qtdir); - findQtHeaders('QtMultimediaWidgets', $qtdir); -} elsif (-d $qtdir . '/../qtmultimedia' ) { +if (-d $qtIncludeDir . '/include/QtMultimedia') { + findQtHeaders('QtMultimedia', $qtIncludeDir); + findQtHeaders('QtMultimediaWidgets', $qtIncludeDir); +} elsif (-d $qtIncludeDir . '/../qtmultimedia' ) { # This is the case if QTDIR points to a source tree instead of an installed Qt - findQtHeaders('QtMultimedia', $qtdir . '/../qtmultimedia'); - findQtHeaders('QtMultimediaWidgets', $qtdir . '/../qtmultimedia'); + findQtHeaders('QtMultimedia', $qtIncludeDir . '/../qtmultimedia'); + findQtHeaders('QtMultimediaWidgets', $qtIncludeDir . '/../qtmultimedia'); } # Support porting from "Qt 4.99" QtDeclarative to QtQuick (QQuickItem et al) -if (-d $qtdir . '/include/QtQuick') { - findQtHeaders('QtQuick', $qtdir); -} elsif (-d $qtdir . '/../qtdeclarative' ) { +if (-d $qtIncludeDir . '/include/QtQuick') { + findQtHeaders('QtQuick', $qtIncludeDir); +} elsif (-d $qtIncludeDir . '/../qtdeclarative' ) { # This is the case if QTDIR points to a source tree instead of an installed Qt - findQtHeaders('QtQuick', $qtdir . '/../qtdeclarative'); + findQtHeaders('QtQuick', $qtIncludeDir . '/../qtdeclarative'); } # special case |