2011-04-27 10:05:43 +00:00
|
|
|
#!/usr/bin/perl -w
|
2011-09-09 08:37:30 +00:00
|
|
|
#############################################################################
|
|
|
|
##
|
|
|
|
## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
## All rights reserved.
|
|
|
|
## Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
##
|
|
|
|
## This file is part of the build configuration tools of the Qt Toolkit.
|
|
|
|
##
|
|
|
|
## $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
## GNU Lesser General Public License Usage
|
|
|
|
## This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
## License version 2.1 as published by the Free Software Foundation and
|
|
|
|
## appearing in the file LICENSE.LGPL included in the packaging of this
|
|
|
|
## file. Please review the following information to ensure the GNU Lesser
|
|
|
|
## General Public License version 2.1 requirements will be met:
|
|
|
|
## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
##
|
|
|
|
## In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
## rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
##
|
|
|
|
## GNU General Public License Usage
|
|
|
|
## Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
## Public License version 3.0 as published by the Free Software Foundation
|
|
|
|
## and appearing in the file LICENSE.GPL included in the packaging of this
|
|
|
|
## file. Please review the following information to ensure the GNU General
|
|
|
|
## Public License version 3.0 requirements will be met:
|
|
|
|
## http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
##
|
|
|
|
## Other Usage
|
|
|
|
## Alternatively, this file may be used in accordance with the terms and
|
|
|
|
## conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
##
|
|
|
|
## $QT_END_LICENSE$
|
|
|
|
##
|
|
|
|
#############################################################################
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#
|
|
|
|
# Synchronizes Qt header files - internal development tool.
|
|
|
|
#
|
|
|
|
|
|
|
|
# use packages -------------------------------------------------------
|
|
|
|
use File::Basename;
|
|
|
|
use File::Path;
|
|
|
|
use Cwd;
|
2010-11-15 19:55:17 +00:00
|
|
|
use Cwd 'abs_path';
|
2011-04-27 10:05:43 +00:00
|
|
|
use Config;
|
|
|
|
use strict;
|
2011-06-30 04:51:16 +00:00
|
|
|
use English qw(-no_match_vars );
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2010-11-15 19:55:17 +00:00
|
|
|
# set output basedir to be where ever syncqt is run from
|
|
|
|
our $out_basedir = getcwd();
|
|
|
|
$out_basedir =~ s=\\=/=g;
|
|
|
|
our $basedir;
|
|
|
|
our $quoted_basedir;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
|
2010-11-25 02:21:06 +00:00
|
|
|
# try to figure out where QtBase is located
|
|
|
|
# normally the script location should be enough, if not fall back to
|
|
|
|
# QTDIR environment variable. If that doesn't work, later ask the
|
|
|
|
# user to use the -qtdir option explicitly.
|
2011-05-10 08:30:30 +00:00
|
|
|
my $qtbasedir = $ENV{"QTDIR"};
|
|
|
|
$qtbasedir = dirname(dirname($0)) if (!$qtbasedir);
|
2010-11-25 02:21:06 +00:00
|
|
|
$qtbasedir =~ s=\\=/=g if (defined $qtbasedir);
|
|
|
|
|
2010-11-15 19:55:17 +00:00
|
|
|
# will be defined based on the modules sync.profile
|
Add deprecated headers support to syncqt
When renaming classes, or when moving classes from one module to
another, it's useful to have a simple way of supporting the old
API/location for some time. To this end, syncqt shall now recognize
a "deprecatedheaders" section in sync.profile. It looks like this:
%deprecatedheaders = (
"QtDeclarative" => {
"qquickcanvas.h" => "QtQuick2/qquickcanvas.h",
"qquickitem.h" => "QtQuick2/qquickitem.h",
"QQuickCanvas" => "QtQuick2/QQuickCanvas",
"QQuickItem" => "QtQuick2/QQuickItem",
}
);
In the above example, syncqt would generate a header called
qquickcanvas.h for the QtDeclarative module; when included, this
header will issue a warning and include <QtQuick2/qquickcanvas.h>.
And so on, for the other entries.
Deprecated headers are installed along with the module's normal
headers.
Change-Id: Ie2518b42275c2b2ff44216f07d376ccf5be6dc45
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
2011-11-25 13:53:39 +00:00
|
|
|
our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %mastercontent, %modulepris, %explicitheaders, %deprecatedheaders);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
# global variables (modified by options)
|
2010-11-15 19:55:17 +00:00
|
|
|
my $isunix = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
my $module = 0;
|
|
|
|
my $showonly = 0;
|
2011-07-07 18:05:49 +00:00
|
|
|
my $verbose_level = 1;
|
2011-04-27 10:05:43 +00:00
|
|
|
my $remove_stale = 1;
|
|
|
|
my $force_win = 0;
|
|
|
|
my $force_relative = 0;
|
|
|
|
my $check_includes = 0;
|
|
|
|
my $copy_headers = 0;
|
2011-01-03 19:09:28 +00:00
|
|
|
my $create_uic_class_map = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
my $create_private_headers = 1;
|
2011-05-18 13:23:51 +00:00
|
|
|
my $module_fwd = "";
|
|
|
|
my $cache_module_fwd = 0;
|
|
|
|
my $developer_build = 0;
|
2011-05-10 13:15:15 +00:00
|
|
|
my $no_module_version_header = 0;
|
2011-06-30 04:51:16 +00:00
|
|
|
my $makefile_generator = "";
|
2011-04-27 10:05:43 +00:00
|
|
|
my @modules_to_sync ;
|
|
|
|
$force_relative = 1 if ( -d "/System/Library/Frameworks" );
|
2010-11-15 19:55:17 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
# functions ----------------------------------------------------------
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: showUsage()
|
|
|
|
# Params: -none-
|
|
|
|
#
|
|
|
|
# Purpose: Show the usage of the script.
|
|
|
|
# Returns: -none-
|
|
|
|
######################################################################
|
|
|
|
sub showUsage
|
|
|
|
{
|
|
|
|
print "$0 usage:\n";
|
2010-11-15 19:55:17 +00:00
|
|
|
print " <module directory> Specifies which module to sync header files for (required for shadow builds!)\n\n";
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
print " -copy Copy headers instead of include-fwd(default: " . ($copy_headers ? "yes" : "no") . ")\n";
|
|
|
|
print " -remove-stale Removes stale headers (default: " . ($remove_stale ? "yes" : "no") . ")\n";
|
|
|
|
print " -relative Force relative symlinks (default: " . ($force_relative ? "yes" : "no") . ")\n";
|
|
|
|
print " -windows Force platform to Windows (default: " . ($force_win ? "yes" : "no") . ")\n";
|
|
|
|
print " -showonly Show action but not perform (default: " . ($showonly ? "yes" : "no") . ")\n";
|
|
|
|
print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n";
|
2011-05-18 13:23:51 +00:00
|
|
|
print " -qtdir <PATH> Set the path to QtBase (detected: " . (defined $qtbasedir ? $qtbasedir : "-none-") . ")\n";
|
2011-07-07 18:05:49 +00:00
|
|
|
print " -quiet Only report problems, not activity (same as -verbose 0)\n";
|
|
|
|
print " -v, -verbose <level> Sets the verbosity level (max. 4) (default: $verbose_level)\n";
|
|
|
|
print " The short form increases the level by +1\n";
|
2010-11-25 02:21:06 +00:00
|
|
|
print " -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR>\n";
|
2011-05-18 13:23:51 +00:00
|
|
|
print " Create headers for <NAME> with original headers in\n";
|
|
|
|
print " <HEADERDIR> relative to <PROFILEDIR> \n";
|
2010-11-15 15:43:22 +00:00
|
|
|
print " -private Force copy private headers (default: " . ($create_private_headers ? "yes" : "no") . ")\n";
|
2011-05-18 13:23:51 +00:00
|
|
|
print " -module-fwd <PATH> Create fwd includes for module pri files in the given\n";
|
|
|
|
print " path (default: none)\n";
|
|
|
|
print " -cache-module-fwd Create a .qmake.cache file to cache the location of the\n";
|
|
|
|
print " fwd includes\n";
|
|
|
|
print " -developer-build Point libraries and binaries to a common directory for\n";
|
|
|
|
print " easy development\n";
|
2011-05-10 13:15:15 +00:00
|
|
|
print " -no-module-version-header\n";
|
|
|
|
print " Don't create module version header file\n";
|
2011-06-30 04:51:16 +00:00
|
|
|
print " -generator <PATH> Specify the makefile generator setting (e.g. 'UNIX')\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
print " -help This help\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: checkUnix()
|
|
|
|
# Params: -none-
|
|
|
|
#
|
|
|
|
# Purpose: Check if script runs on a Unix system or not. Cygwin
|
|
|
|
# systems are _not_ detected as Unix systems.
|
|
|
|
# Returns: 1 if a unix system, else 0.
|
|
|
|
######################################################################
|
|
|
|
sub checkUnix {
|
|
|
|
my ($r) = 0;
|
|
|
|
if ( $force_win != 0) {
|
|
|
|
return 0;
|
|
|
|
} elsif ( -f "/bin/uname" ) {
|
|
|
|
$r = 1;
|
|
|
|
(-f "\\bin\\uname") && ($r = 0);
|
|
|
|
} elsif ( -f "/usr/bin/uname" ) {
|
|
|
|
$r = 1;
|
|
|
|
(-f "\\usr\\bin\\uname") && ($r = 0);
|
|
|
|
}
|
|
|
|
if($r) {
|
|
|
|
$_ = $Config{'osname'};
|
|
|
|
$r = 0 if( /(ms)|(cyg)win/i );
|
|
|
|
}
|
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub checkRelative {
|
|
|
|
my ($dir) = @_;
|
|
|
|
return 0 if($dir =~ /^\//);
|
|
|
|
return 0 if(!checkUnix() && $dir =~ /[a-zA-Z]:[\/\\]/);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: shouldMasterInclude(iheader)
|
|
|
|
# Params: iheader, string, filename to verify inclusion
|
|
|
|
#
|
|
|
|
# Purpose: Determines if header should be in the master include file.
|
|
|
|
# Returns: 0 if file contains "#pragma qt_no_master_include" or not
|
|
|
|
# able to open, else 1.
|
|
|
|
######################################################################
|
|
|
|
sub shouldMasterInclude {
|
|
|
|
my ($iheader) = @_;
|
|
|
|
return 0 if(basename($iheader) =~ /_/);
|
|
|
|
return 0 if(basename($iheader) =~ /qconfig/);
|
|
|
|
if(open(F, "<$iheader")) {
|
|
|
|
while(<F>) {
|
|
|
|
chomp;
|
|
|
|
return 0 if(/^\#pragma qt_no_master_include$/);
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: classNames(iheader)
|
|
|
|
# Params: iheader, string, filename to parse for classname "symlinks"
|
|
|
|
#
|
|
|
|
# Purpose: Scans through iheader to find all classnames that should be
|
|
|
|
# synced into library's include structure.
|
|
|
|
# Returns: List of all class names in a file.
|
|
|
|
######################################################################
|
|
|
|
sub classNames {
|
|
|
|
my @ret;
|
|
|
|
my ($iheader) = @_;
|
2010-11-15 19:55:17 +00:00
|
|
|
|
|
|
|
my $classname = $classnames{basename($iheader)};
|
|
|
|
push @ret, $classname if ($classname);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
my $parsable = "";
|
|
|
|
if(open(F, "<$iheader")) {
|
|
|
|
while(<F>) {
|
|
|
|
my $line = $_;
|
|
|
|
chomp $line;
|
|
|
|
chop $line if ($line =~ /\r$/);
|
|
|
|
if($line =~ /^\#/) {
|
|
|
|
if($line =~ /\\$/) {
|
|
|
|
while($line = <F>) {
|
|
|
|
chomp $line;
|
|
|
|
last unless($line =~ /\\$/);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return @ret if($line =~ m/^#pragma qt_sync_stop_processing/);
|
|
|
|
push(@ret, $1) if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/);
|
|
|
|
$line = 0;
|
|
|
|
}
|
|
|
|
if($line) {
|
|
|
|
$line =~ s,//.*$,,; #remove c++ comments
|
|
|
|
$line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro
|
|
|
|
$line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro
|
|
|
|
$line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro
|
|
|
|
$line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro
|
|
|
|
$parsable .= " " . $line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $last_definition = 0;
|
|
|
|
my @namespaces;
|
|
|
|
for(my $i = 0; $i < length($parsable); $i++) {
|
|
|
|
my $definition = 0;
|
|
|
|
my $character = substr($parsable, $i, 1);
|
|
|
|
if($character eq "/" && substr($parsable, $i+1, 1) eq "*") { #I parse like this for greedy reasons
|
|
|
|
for($i+=2; $i < length($parsable); $i++) {
|
|
|
|
my $end = substr($parsable, $i, 2);
|
|
|
|
if($end eq "*/") {
|
|
|
|
$last_definition = $i+2;
|
|
|
|
$i++;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elsif($character eq "{") {
|
|
|
|
my $brace_depth = 1;
|
|
|
|
my $block_start = $i + 1;
|
|
|
|
BLOCK: for($i+=1; $i < length($parsable); $i++) {
|
|
|
|
my $ignore = substr($parsable, $i, 1);
|
|
|
|
if($ignore eq "{") {
|
|
|
|
$brace_depth++;
|
|
|
|
} elsif($ignore eq "}") {
|
|
|
|
$brace_depth--;
|
|
|
|
unless($brace_depth) {
|
|
|
|
for(my $i2 = $i+1; $i2 < length($parsable); $i2++) {
|
|
|
|
my $end = substr($parsable, $i2, 1);
|
|
|
|
if($end eq ";" || $end ne " ") {
|
|
|
|
$definition = substr($parsable, $last_definition, $block_start - $last_definition) . "}";
|
|
|
|
$i = $i2 if($end eq ";");
|
|
|
|
$last_definition = $i + 1;
|
|
|
|
last BLOCK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elsif($character eq ";") {
|
|
|
|
$definition = substr($parsable, $last_definition, $i - $last_definition + 1);
|
|
|
|
$last_definition = $i + 1;
|
|
|
|
} elsif($character eq "}") {
|
|
|
|
# a naked } must be a namespace ending
|
|
|
|
# if it's not a namespace, it's eaten by the loop above
|
|
|
|
pop @namespaces;
|
|
|
|
$last_definition = $i + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) /
|
|
|
|
&& substr($parsable, $i+1, 1) eq "{") {
|
|
|
|
push @namespaces, $1;
|
|
|
|
|
|
|
|
# Eat the opening { so that the condensing loop above doesn't see it
|
|
|
|
$i++;
|
|
|
|
$last_definition = $i + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($definition) {
|
|
|
|
$definition =~ s=[\n\r]==g;
|
|
|
|
my @symbols;
|
|
|
|
if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) {
|
|
|
|
push @symbols, $1;
|
|
|
|
} elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) {
|
|
|
|
push @symbols, $2;
|
|
|
|
} elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) {
|
|
|
|
push @symbols, $4;
|
|
|
|
} elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) {
|
|
|
|
push @symbols, "Q" . $1 . "Iterator";
|
|
|
|
push @symbols, "QMutable" . $1 . "Iterator";
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $symbol (@symbols) {
|
|
|
|
$symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces);
|
|
|
|
push @ret, $symbol
|
|
|
|
if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q
|
|
|
|
|| $symbol =~ /^Phonon::/); # or in the Phonon namespace
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return @ret;
|
|
|
|
}
|
|
|
|
|
2011-07-07 18:48:02 +00:00
|
|
|
sub make_path {
|
|
|
|
my ($dir, $lib, $be_verbose) = @_;
|
|
|
|
unless(-e $dir) {
|
|
|
|
mkpath $dir;
|
|
|
|
$dir = "<outbase>" . substr($dir, length($out_basedir)) if ($be_verbose < 3);
|
|
|
|
print "$lib: mkpath $dir\n" if ($be_verbose > 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
######################################################################
|
|
|
|
# Syntax: syncHeader(header, iheader, copy, timestamp)
|
|
|
|
# Params: header, string, filename to create "symlink" for
|
|
|
|
# iheader, string, destination name of symlink
|
|
|
|
# copy, forces header to be a copy of iheader
|
|
|
|
# timestamp, the requested modification time if copying
|
|
|
|
#
|
|
|
|
# Purpose: Syncronizes header to iheader
|
|
|
|
# Returns: 1 if successful, else 0.
|
|
|
|
######################################################################
|
|
|
|
sub syncHeader {
|
2011-07-07 18:48:02 +00:00
|
|
|
my ($lib, $header, $iheader, $copy, $ts) = @_;
|
2011-04-27 10:05:43 +00:00
|
|
|
$iheader =~ s=\\=/=g;
|
|
|
|
$header =~ s=\\=/=g;
|
2011-07-07 18:48:02 +00:00
|
|
|
return copyFile($lib, $iheader, $header) if($copy);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
unless(-e $header) {
|
|
|
|
my $header_dir = dirname($header);
|
2011-07-07 18:48:02 +00:00
|
|
|
make_path($header_dir, $lib, $verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#write it
|
|
|
|
my $iheader_out = fixPaths($iheader, $header_dir);
|
|
|
|
open HEADER, ">$header" || die "Could not open $header for writing!\n";
|
|
|
|
print HEADER "#include \"$iheader_out\"\n";
|
|
|
|
close HEADER;
|
|
|
|
if(defined($ts)) {
|
|
|
|
utime(time, $ts, $header) or die "$iheader, $header";
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: fixPaths(file, dir)
|
|
|
|
# Params: file, string, filepath to be made relative to dir
|
|
|
|
# dir, string, dirpath for point of origin
|
|
|
|
#
|
|
|
|
# Purpose: file is made relative (if possible) of dir.
|
|
|
|
# Returns: String with the above applied conversion.
|
|
|
|
######################################################################
|
|
|
|
sub fixPaths {
|
|
|
|
my ($file, $dir) = @_;
|
|
|
|
$file =~ s=\\=/=g;
|
|
|
|
$dir =~ s=\\=/=g;
|
|
|
|
|
|
|
|
#setup
|
|
|
|
my $ret = $file;
|
|
|
|
$ret =~ s,/cygdrive/([a-zA-Z])/,$1:/,g;
|
|
|
|
my $file_dir = dirname($file);
|
|
|
|
if($file_dir eq ".") {
|
|
|
|
$file_dir = getcwd();
|
|
|
|
$file_dir =~ s=\\=/=g;
|
|
|
|
}
|
|
|
|
$file_dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g;
|
|
|
|
if($dir eq ".") {
|
|
|
|
$dir = getcwd();
|
|
|
|
$dir =~ s=\\=/=g;
|
|
|
|
}
|
|
|
|
$dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g;
|
|
|
|
return basename($file) if($file_dir eq $dir);
|
|
|
|
|
|
|
|
#guts
|
2011-01-03 18:19:39 +00:00
|
|
|
while ($file_dir =~ s,/[^/]+/\.\./,/,) {}
|
|
|
|
while ($dir =~ s,/[^/]+/\.\./,/,) {}
|
2011-04-27 10:05:43 +00:00
|
|
|
my $match_dir = 0;
|
|
|
|
for(my $i = 1; $i < length($file_dir); $i++) {
|
|
|
|
my $slash = index($file_dir, "/", $i);
|
|
|
|
last if($slash == -1);
|
|
|
|
my $tmp = substr($file_dir, 0, $slash);
|
|
|
|
last unless($dir =~ m,^\Q$tmp\E/,);
|
|
|
|
$match_dir = $tmp;
|
|
|
|
$i = $slash;
|
|
|
|
}
|
|
|
|
if($match_dir) {
|
|
|
|
my $after = substr($dir, length($match_dir));
|
|
|
|
my $count = ($after =~ tr,/,,);
|
|
|
|
my $dots = "";
|
|
|
|
for(my $i = 0; $i < $count; $i++) {
|
|
|
|
$dots .= "../";
|
|
|
|
}
|
|
|
|
$ret =~ s,^\Q$match_dir\E,$dots,;
|
|
|
|
}
|
|
|
|
$ret =~ s,/+,/,g;
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: fileContents(filename)
|
|
|
|
# Params: filename, string, filename of file to return contents
|
|
|
|
#
|
|
|
|
# Purpose: Get the contents of a file.
|
|
|
|
# Returns: String with contents of the file, or empty string if file
|
|
|
|
# doens't exist.
|
|
|
|
# Warning: Dies if it does exist but script cannot get read access.
|
|
|
|
######################################################################
|
|
|
|
sub fileContents {
|
|
|
|
my ($filename) = @_;
|
|
|
|
my $filecontents = "";
|
|
|
|
if (-e $filename) {
|
|
|
|
open(I, "< $filename") || die "Could not open $filename for reading, read block?";
|
|
|
|
local $/;
|
|
|
|
binmode I;
|
|
|
|
$filecontents = <I>;
|
|
|
|
close I;
|
|
|
|
}
|
|
|
|
return $filecontents;
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: fileCompare(file1, file2)
|
|
|
|
# Params: file1, string, filename of first file
|
|
|
|
# file2, string, filename of second file
|
|
|
|
#
|
|
|
|
# Purpose: Determines if files are equal, and which one is newer.
|
|
|
|
# Returns: 0 if files are equal no matter the timestamp, -1 if file1
|
|
|
|
# is newer, 1 if file2 is newer.
|
|
|
|
######################################################################
|
|
|
|
sub fileCompare {
|
|
|
|
my ($file1, $file2) = @_;
|
|
|
|
my $file1contents = fileContents($file1);
|
|
|
|
my $file2contents = fileContents($file2);
|
|
|
|
if (! -e $file1) { return 1; }
|
|
|
|
if (! -e $file2) { return -1; }
|
|
|
|
return $file1contents ne $file2contents ? (stat($file2))[9] <=> (stat($file1))[9] : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: copyFile(file, ifile)
|
|
|
|
# Params: file, string, filename to create duplicate for
|
|
|
|
# ifile, string, destination name of duplicate
|
|
|
|
#
|
|
|
|
# Purpose: Keeps files in sync so changes in the newer file will be
|
|
|
|
# written to the other.
|
|
|
|
# Returns: 1 if files were synced, else 0.
|
|
|
|
# Warning: Dies if script cannot get write access.
|
|
|
|
######################################################################
|
|
|
|
sub copyFile
|
|
|
|
{
|
2011-07-07 18:48:02 +00:00
|
|
|
my ($lib, $file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_;
|
2011-04-27 10:05:43 +00:00
|
|
|
# Bi-directional synchronization
|
|
|
|
open( I, "< " . $file ) || die "Could not open $file for reading";
|
|
|
|
local $/;
|
|
|
|
binmode I;
|
|
|
|
$filecontents = <I>;
|
|
|
|
close I;
|
|
|
|
if ( open(I, "< " . $ifile) ) {
|
|
|
|
local $/;
|
|
|
|
binmode I;
|
|
|
|
$ifilecontents = <I>;
|
|
|
|
close I;
|
|
|
|
$copy = fileCompare($file, $ifile);
|
|
|
|
$knowdiff = 0,
|
|
|
|
} else {
|
|
|
|
$copy = -1;
|
|
|
|
$knowdiff = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $knowdiff || ($filecontents ne $ifilecontents) ) {
|
|
|
|
if ( $copy > 0 ) {
|
|
|
|
my $file_dir = dirname($file);
|
2011-07-07 18:48:02 +00:00
|
|
|
make_path($file_dir, $lib, $verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)";
|
|
|
|
local $/;
|
|
|
|
binmode O;
|
|
|
|
print O $ifilecontents;
|
|
|
|
close O;
|
|
|
|
utime time, (stat($ifile))[9], $file;
|
|
|
|
return 1;
|
|
|
|
} elsif ( $copy < 0 ) {
|
|
|
|
my $ifile_dir = dirname($ifile);
|
2011-07-07 18:48:02 +00:00
|
|
|
make_path($ifile_dir, $lib, $verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)";
|
|
|
|
local $/;
|
|
|
|
binmode O;
|
|
|
|
print O $filecontents;
|
|
|
|
close O;
|
|
|
|
utime time, (stat($file))[9], $ifile;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: symlinkFile(file, ifile)
|
|
|
|
# Params: file, string, filename to create "symlink" for
|
|
|
|
# ifile, string, destination name of symlink
|
|
|
|
#
|
|
|
|
# Purpose: File is symlinked to ifile (or copied if filesystem doesn't
|
|
|
|
# support symlink).
|
|
|
|
# Returns: 1 on success, else 0.
|
|
|
|
######################################################################
|
|
|
|
sub symlinkFile
|
|
|
|
{
|
2011-07-07 18:48:02 +00:00
|
|
|
my ($lib, $file, $ifile) = @_;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if ($isunix) {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: symlink created for $file " if ($verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
if ( $force_relative && ($ifile =~ /^$quoted_basedir/)) {
|
|
|
|
my $t = getcwd();
|
|
|
|
my $c = -1;
|
|
|
|
my $p = "../";
|
|
|
|
$t =~ s-^$quoted_basedir/--;
|
|
|
|
$p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 );
|
|
|
|
$file =~ s-^$quoted_basedir/-$p-;
|
2011-07-07 18:05:49 +00:00
|
|
|
print " ($file)\n" if($verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-07-07 18:05:49 +00:00
|
|
|
print "\n" if($verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
return symlink($file, $ifile);
|
|
|
|
}
|
2011-07-07 18:48:02 +00:00
|
|
|
return copyFile($lib, $file, $ifile);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Syntax: findFiles(dir, match, descend)
|
|
|
|
# Params: dir, string, directory to search for name
|
|
|
|
# match, string, regular expression to match in dir
|
|
|
|
# descend, integer, 0 = non-recursive search
|
|
|
|
# 1 = recurse search into subdirectories
|
|
|
|
#
|
|
|
|
# Purpose: Finds files matching a regular expression.
|
|
|
|
# Returns: List of matching files.
|
|
|
|
#
|
|
|
|
# Examples:
|
|
|
|
# findFiles("/usr","\.cpp$",1) - finds .cpp files in /usr and below
|
|
|
|
# findFiles("/tmp","^#",0) - finds #* files in /tmp
|
|
|
|
######################################################################
|
|
|
|
sub findFiles {
|
|
|
|
my ($dir,$match,$descend) = @_;
|
|
|
|
my ($file,$p,@files);
|
|
|
|
local(*D);
|
|
|
|
$dir =~ s=\\=/=g;
|
|
|
|
($dir eq "") && ($dir = ".");
|
|
|
|
if ( opendir(D,$dir) ) {
|
|
|
|
if ( $dir eq "." ) {
|
|
|
|
$dir = "";
|
|
|
|
} else {
|
|
|
|
($dir =~ /\/$/) || ($dir .= "/");
|
|
|
|
}
|
|
|
|
foreach $file ( sort readdir(D) ) {
|
|
|
|
next if ( $file =~ /^\.\.?$/ );
|
|
|
|
$p = $file;
|
|
|
|
($file =~ /$match/) && (push @files, $p);
|
|
|
|
if ( $descend && -d $p && ! -l $p ) {
|
|
|
|
push @files, &findFiles($p,$match,$descend);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(D);
|
|
|
|
}
|
|
|
|
return @files;
|
|
|
|
}
|
|
|
|
|
2010-11-15 19:55:17 +00:00
|
|
|
######################################################################
|
|
|
|
# Syntax: loadSyncProfile()
|
|
|
|
#
|
|
|
|
# Purpose: Locates the sync.profile.
|
|
|
|
# Returns: Hashmap of module name -> directory.
|
|
|
|
######################################################################
|
|
|
|
sub loadSyncProfile {
|
|
|
|
my ($srcbase, $outbase) = @_;
|
2011-07-07 18:05:49 +00:00
|
|
|
if ($verbose_level) {
|
|
|
|
print("<srcbase> = $$srcbase \n");
|
|
|
|
print("<outbase> = $$outbase \n");
|
|
|
|
}
|
2010-11-15 19:55:17 +00:00
|
|
|
|
|
|
|
my $syncprofile = "$$srcbase/sync.profile";
|
|
|
|
my $result;
|
|
|
|
unless ($result = do "$syncprofile") {
|
|
|
|
die "syncqt couldn't parse $syncprofile: $@" if $@;
|
|
|
|
die "syncqt couldn't execute $syncprofile: $!" unless defined $result;
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub locateSyncProfile
|
|
|
|
{
|
|
|
|
my ($directory) = @_;
|
|
|
|
my $syncprofile;
|
|
|
|
$directory = abs_path($directory);
|
|
|
|
while(!defined $syncprofile) {
|
|
|
|
local(*D);
|
|
|
|
if (opendir(D, $directory)) {
|
|
|
|
foreach my $file (sort readdir(D)) {
|
|
|
|
next if ($file =~ /^\.\.?$/);
|
|
|
|
$syncprofile = "$directory/$file" if ($file =~ /^sync\.profile$/);
|
|
|
|
last if (defined $syncprofile);
|
|
|
|
}
|
|
|
|
closedir(D);
|
|
|
|
}
|
|
|
|
last if (defined $syncprofile || $directory eq "/" || $directory =~ /^?:[\/\\]$/);
|
|
|
|
$directory = dirname($directory);
|
|
|
|
}
|
|
|
|
return $syncprofile;
|
|
|
|
}
|
|
|
|
|
|
|
|
# check if this is an in-source build, and if so use that as the basedir too
|
|
|
|
$basedir = locateSyncProfile($out_basedir);
|
2011-04-07 14:40:33 +00:00
|
|
|
if ($basedir) {
|
|
|
|
$basedir = dirname($basedir) ;
|
|
|
|
$basedir =~ s=\\=/=g;
|
|
|
|
$quoted_basedir = "\Q$basedir";
|
|
|
|
}
|
2010-11-15 19:55:17 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# "main" function
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
|
|
|
while ( @ARGV ) {
|
|
|
|
my $var = 0;
|
|
|
|
my $val = 0;
|
|
|
|
|
|
|
|
#parse
|
|
|
|
my $arg = shift @ARGV;
|
2010-11-25 02:21:06 +00:00
|
|
|
if ($arg eq "-h" || $arg eq "-help" || $arg eq "-?" || $arg eq "?") {
|
2011-04-27 10:05:43 +00:00
|
|
|
$var = "show_help";
|
|
|
|
$val = "yes";
|
|
|
|
} elsif($arg eq "-copy") {
|
|
|
|
$var = "copy";
|
|
|
|
$val = "yes";
|
|
|
|
} elsif($arg eq "-o" || $arg eq "-outdir") {
|
|
|
|
$var = "output";
|
|
|
|
$val = shift @ARGV;
|
|
|
|
} elsif($arg eq "-showonly" || $arg eq "-remove-stale" || $arg eq "-windows" ||
|
|
|
|
$arg eq "-relative" || $arg eq "-check-includes") {
|
|
|
|
$var = substr($arg, 1);
|
|
|
|
$val = "yes";
|
2011-05-18 13:23:51 +00:00
|
|
|
} elsif($arg eq "-module-fwd") {
|
|
|
|
$var = "module_fwd";
|
|
|
|
$val = shift @ARGV;
|
|
|
|
} elsif($arg eq "-cache-module-fwd") {
|
|
|
|
$var = "cache_module_fwd";
|
|
|
|
$val = "yes";
|
|
|
|
} elsif($arg eq "-developer-build") {
|
|
|
|
$var = "developer_build";
|
2011-05-13 14:07:56 +00:00
|
|
|
$val = "yes";
|
|
|
|
} elsif($arg eq "-no-module-version-header") {
|
|
|
|
$var = "no_module_version_header";
|
|
|
|
$val = "yes";
|
2011-04-27 10:05:43 +00:00
|
|
|
} elsif($arg =~ /^-no-(.*)$/) {
|
|
|
|
$var = $1;
|
|
|
|
$val = "no";
|
|
|
|
#these are for commandline compat
|
|
|
|
} elsif($arg eq "-inc") {
|
|
|
|
$var = "output";
|
|
|
|
$val = shift @ARGV;
|
|
|
|
} elsif($arg eq "-module") {
|
|
|
|
$var = "module";
|
|
|
|
$val = shift @ARGV;
|
|
|
|
} elsif($arg eq "-separate-module") {
|
|
|
|
$var = "separate-module";
|
|
|
|
$val = shift @ARGV;
|
|
|
|
} elsif($arg eq "-show") {
|
|
|
|
$var = "showonly";
|
|
|
|
$val = "yes";
|
|
|
|
} elsif($arg eq "-quiet") {
|
2011-07-07 18:05:49 +00:00
|
|
|
$var = "verbose";
|
|
|
|
$val = "0";
|
|
|
|
} elsif($arg eq "-v") {
|
|
|
|
$var = "verbose";
|
2011-04-27 10:05:43 +00:00
|
|
|
$val = "yes";
|
2011-07-07 18:05:49 +00:00
|
|
|
} elsif($arg eq "-verbose") {
|
|
|
|
$var = "verbose";
|
|
|
|
$val = shift @ARGV;
|
2010-11-15 15:43:22 +00:00
|
|
|
} elsif($arg eq "-private") {
|
|
|
|
$var = "create_private_headers";
|
|
|
|
$val = "yes";
|
2010-11-25 02:21:06 +00:00
|
|
|
} elsif($arg eq "-qtdir") {
|
|
|
|
$var = "qtdir";
|
|
|
|
$val = shift @ARGV;
|
2011-04-27 10:05:43 +00:00
|
|
|
} elsif($arg eq "-base-dir") {
|
|
|
|
# skip, it's been dealt with at the top of the file
|
|
|
|
shift @ARGV;
|
|
|
|
next;
|
2011-06-30 04:51:16 +00:00
|
|
|
} elsif($arg eq "-generator") {
|
|
|
|
$var = "makefile_generator";
|
|
|
|
$val = shift @ARGV;
|
2010-11-15 19:55:17 +00:00
|
|
|
} elsif($arg =~/^-/) {
|
|
|
|
print "Unknown option: $arg\n\n" if(!$var);
|
|
|
|
showUsage();
|
|
|
|
} else {
|
|
|
|
$basedir = locateSyncProfile($arg);
|
|
|
|
die "Could not find a sync.profile for '$arg'\n" if (!$basedir);
|
|
|
|
$basedir = dirname($basedir);
|
|
|
|
$basedir =~ s=\\=/=g;
|
2011-04-07 14:40:33 +00:00
|
|
|
$quoted_basedir = "\Q$basedir";
|
2010-11-15 19:55:17 +00:00
|
|
|
$var = "ignore";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#do something
|
|
|
|
if(!$var || $var eq "show_help") {
|
|
|
|
print "Unknown option: $arg\n\n" if(!$var);
|
|
|
|
showUsage();
|
|
|
|
} elsif ($var eq "copy") {
|
|
|
|
if($val eq "yes") {
|
|
|
|
$copy_headers++;
|
|
|
|
} elsif($showonly) {
|
|
|
|
$copy_headers--;
|
|
|
|
}
|
|
|
|
} elsif ($var eq "showonly") {
|
|
|
|
if($val eq "yes") {
|
|
|
|
$showonly++;
|
|
|
|
} elsif($showonly) {
|
|
|
|
$showonly--;
|
|
|
|
}
|
2011-07-07 18:05:49 +00:00
|
|
|
} elsif ($var eq "verbose") {
|
2011-04-27 10:05:43 +00:00
|
|
|
if($val eq "yes") {
|
2011-07-07 18:05:49 +00:00
|
|
|
$verbose_level++;
|
|
|
|
} elsif($val eq "no" && $verbose_level) {
|
|
|
|
$verbose_level--;
|
|
|
|
} else {
|
|
|
|
$verbose_level = int($val);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
} elsif ($var eq "check-includes") {
|
|
|
|
if($val eq "yes") {
|
|
|
|
$check_includes++;
|
|
|
|
} elsif($check_includes) {
|
|
|
|
$check_includes--;
|
|
|
|
}
|
|
|
|
} elsif ($var eq "remove-stale") {
|
|
|
|
if($val eq "yes") {
|
|
|
|
$remove_stale++;
|
|
|
|
} elsif($remove_stale) {
|
|
|
|
$remove_stale--;
|
|
|
|
}
|
|
|
|
} elsif ($var eq "windows") {
|
|
|
|
if($val eq "yes") {
|
|
|
|
$force_win++;
|
|
|
|
} elsif($force_win) {
|
|
|
|
$force_win--;
|
|
|
|
}
|
|
|
|
} elsif ($var eq "relative") {
|
|
|
|
if($val eq "yes") {
|
|
|
|
$force_relative++;
|
|
|
|
} elsif($force_relative) {
|
|
|
|
$force_relative--;
|
|
|
|
}
|
|
|
|
} elsif ($var eq "module") {
|
2011-07-07 18:05:49 +00:00
|
|
|
print "module :$val:\n" if($verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
die "No such module: $val" unless(defined $modules{$val});
|
|
|
|
push @modules_to_sync, $val;
|
|
|
|
} elsif ($var eq "separate-module") {
|
|
|
|
my ($module, $prodir, $headerdir) = split(/:/, $val);
|
|
|
|
$modules{$module} = $prodir;
|
|
|
|
push @modules_to_sync, $module;
|
|
|
|
$moduleheaders{$module} = $headerdir;
|
|
|
|
$create_uic_class_map = 0;
|
2010-11-25 02:21:06 +00:00
|
|
|
} elsif ($var eq "qtdir") {
|
|
|
|
if($val) {
|
|
|
|
$qtbasedir = $val;
|
|
|
|
$qtbasedir =~ s=\\=/=g;
|
|
|
|
} else {
|
|
|
|
die "The -qtdir option requires an argument";
|
|
|
|
}
|
2011-05-18 13:23:51 +00:00
|
|
|
} elsif ($var eq "module_fwd") {
|
|
|
|
$module_fwd = $val;
|
|
|
|
} elsif ($var eq "cache_module_fwd") {
|
|
|
|
$cache_module_fwd = 1;
|
|
|
|
} elsif ($var eq "developer_build") {
|
|
|
|
$developer_build = 1;
|
2011-06-30 04:51:16 +00:00
|
|
|
} elsif ($var eq "makefile_generator") {
|
|
|
|
$makefile_generator = $val;
|
2011-05-10 13:15:15 +00:00
|
|
|
} elsif ($var eq "no_module_version_header") {
|
|
|
|
$no_module_version_header = 1;
|
2011-04-27 10:05:43 +00:00
|
|
|
} elsif ($var eq "output") {
|
|
|
|
my $outdir = $val;
|
|
|
|
if(checkRelative($outdir)) {
|
|
|
|
$out_basedir = getcwd();
|
|
|
|
chomp $out_basedir;
|
|
|
|
$out_basedir .= "/" . $outdir;
|
|
|
|
} else {
|
|
|
|
$out_basedir = $outdir;
|
|
|
|
}
|
|
|
|
# \ -> /
|
|
|
|
$out_basedir =~ s=\\=/=g;
|
|
|
|
}
|
|
|
|
}
|
2010-11-15 19:55:17 +00:00
|
|
|
|
2010-11-25 02:21:06 +00:00
|
|
|
# if the $qtbasedir neither has 'qtbase' somewhere in its path, nor a
|
|
|
|
# '.qmake.cache' file in its directory, we assume it's not a valid path
|
|
|
|
# (remember that a yet-to-be-built qtbase doesn't have this file either,
|
|
|
|
# thus the 'qtbase' path check!)
|
|
|
|
die "Cannot automatically detect/use provided path to QtBase's build directory!\n" .
|
|
|
|
"QTDIR detected/provided: " . (defined $qtbasedir ? $qtbasedir : "-none-") . "\n" .
|
|
|
|
"Please -qtdir option to provide the correct path.\nsyncqt failed"
|
2011-05-10 08:30:30 +00:00
|
|
|
if (!$qtbasedir || !-d "$qtbasedir/mkspecs");
|
2010-11-25 02:21:06 +00:00
|
|
|
|
2010-11-15 19:55:17 +00:00
|
|
|
# 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);
|
|
|
|
|
2011-03-10 15:23:01 +00:00
|
|
|
my $class_lib_map_contents = "";
|
2011-08-04 20:54:50 +00:00
|
|
|
our @ignore_headers = ();
|
2011-03-10 15:23:01 +00:00
|
|
|
our @ignore_for_master_contents = ();
|
|
|
|
our @ignore_for_include_check = ();
|
|
|
|
our @ignore_for_qt_begin_header_check = ();
|
|
|
|
our @ignore_for_qt_begin_namespace_check = ();
|
|
|
|
our @ignore_for_qt_module_check = ();
|
|
|
|
my %colliding_headers = ();
|
|
|
|
my %inject_headers = ( "$basedir/src/corelib/global" => ( "qconfig.h" ) ); # all from build dir
|
|
|
|
|
2010-11-15 19:55:17 +00:00
|
|
|
# load the module's sync.profile here, before we can
|
|
|
|
loadSyncProfile(\$basedir, \$out_basedir);
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
@modules_to_sync = keys(%modules) if($#modules_to_sync == -1);
|
|
|
|
|
2011-08-16 08:50:00 +00:00
|
|
|
my %allmoduleheadersprivate = map { $_ => 1 } @allmoduleheadersprivate;
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
$isunix = checkUnix; #cache checkUnix
|
|
|
|
|
|
|
|
foreach my $lib (@modules_to_sync) {
|
|
|
|
#iteration info
|
|
|
|
my $dir = $modules{$lib};
|
2011-04-20 18:57:51 +00:00
|
|
|
my $module_version = "";
|
2011-10-11 10:46:33 +00:00
|
|
|
my $module_major_version = 0;
|
|
|
|
my $module_minor_version = 0;
|
|
|
|
my $module_patch_version = 0;
|
2011-04-20 18:57:51 +00:00
|
|
|
|
|
|
|
if (-e "$modulepris{$lib}") {
|
|
|
|
my $content = fileContents($modulepris{$lib});
|
|
|
|
my @version_rows = grep(/QT\..*\.VERSION/, split('\n', $content));
|
|
|
|
if(@version_rows) {
|
|
|
|
# We only pick the first one, since each module need a separate .pri file
|
|
|
|
$module_version = $version_rows[0];
|
|
|
|
chomp $module_version;
|
|
|
|
$module_version =~ s/^\s*QT\..*\.VERSION\s*=\s*([^#]+).*$/$1/;
|
|
|
|
$module_version =~ s/\s+$//;
|
2011-05-10 13:15:15 +00:00
|
|
|
my @versions = split(/\./, $module_version);
|
2011-10-11 10:46:33 +00:00
|
|
|
$module_major_version = int($versions[0]);
|
2011-05-10 13:15:15 +00:00
|
|
|
chomp $module_major_version;
|
2011-10-11 10:46:33 +00:00
|
|
|
$module_minor_version = int($versions[1]);
|
2011-05-10 13:15:15 +00:00
|
|
|
chomp $module_minor_version;
|
2011-10-11 10:46:33 +00:00
|
|
|
$module_patch_version = int($versions[2]);
|
2011-05-10 13:15:15 +00:00
|
|
|
chomp $module_patch_version;
|
2011-04-20 18:57:51 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: Module\'s pri missing QT.<module>.VERSION variable! Private headers not versioned!\n" if (!$module_version);
|
2011-04-20 18:57:51 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
my $pathtoheaders = "";
|
|
|
|
$pathtoheaders = $moduleheaders{$lib} if ($moduleheaders{$lib});
|
|
|
|
|
2011-08-16 08:50:00 +00:00
|
|
|
my $allheadersprivate = 0;
|
|
|
|
$allheadersprivate = 1 if $allmoduleheadersprivate{$lib};
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#information used after the syncing
|
|
|
|
my $pri_install_classes = "";
|
|
|
|
my $pri_install_files = "";
|
|
|
|
my $pri_install_pfiles = "";
|
|
|
|
|
|
|
|
my $libcapitals = $lib;
|
|
|
|
$libcapitals =~ y/a-z/A-Z/;
|
|
|
|
my $master_contents = "#ifndef QT_".$libcapitals."_MODULE_H\n#define QT_".$libcapitals."_MODULE_H\n";
|
|
|
|
|
|
|
|
#get dependencies
|
|
|
|
if(-e "$dir/" . basename($dir) . ".pro") {
|
|
|
|
if(open(F, "<$dir/" . basename($dir) . ".pro")) {
|
|
|
|
while(my $line = <F>) {
|
|
|
|
chomp $line;
|
|
|
|
if($line =~ /^ *QT *\+?= *([^\r\n]*)/) {
|
|
|
|
foreach(split(/ /, $1)) {
|
2011-04-20 18:57:51 +00:00
|
|
|
$_ =~ s/-private$//;
|
2010-11-15 19:55:17 +00:00
|
|
|
my $content = $mastercontent{$_};
|
|
|
|
$master_contents .= $content if ($content);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#remove the old files
|
|
|
|
if($remove_stale) {
|
|
|
|
my @subdirs = ("$out_basedir/include/$lib");
|
|
|
|
foreach my $subdir (@subdirs) {
|
|
|
|
if (opendir DIR, $subdir) {
|
2011-07-20 15:42:26 +00:00
|
|
|
foreach my $t (sort readdir(DIR)) {
|
2011-04-27 10:05:43 +00:00
|
|
|
my $file = "$subdir/$t";
|
|
|
|
if(-d $file) {
|
|
|
|
push @subdirs, $file unless($t eq "." || $t eq "..");
|
|
|
|
} else {
|
|
|
|
my @files = ($file);
|
|
|
|
#push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t");
|
|
|
|
foreach my $file (@files) {
|
|
|
|
my $remove_file = 0;
|
|
|
|
if(open(F, "<$file")) {
|
|
|
|
while(my $line = <F>) {
|
|
|
|
chomp $line;
|
|
|
|
if($line =~ /^\#include \"([^\"]*)\"$/) {
|
|
|
|
my $include = $1;
|
|
|
|
$include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/");
|
|
|
|
$remove_file = 1 unless(-e $include);
|
|
|
|
} else {
|
|
|
|
$remove_file = 0;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
unlink $file if($remove_file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir DIR;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-11 08:05:43 +00:00
|
|
|
# create the version header files for each module
|
|
|
|
unless ($no_module_version_header) {
|
|
|
|
my $modulepri = $modulepris{$lib};
|
|
|
|
if (-e $modulepri) {
|
|
|
|
my $modulepriname = basename($modulepri);
|
2011-07-18 12:08:12 +00:00
|
|
|
# FIXME: this creates a file in the source location for shadow-builds
|
2011-05-11 08:05:43 +00:00
|
|
|
my $moduleversionheader = "$modules{$lib}/" . lc($lib) . "version.h";
|
2011-10-11 10:46:33 +00:00
|
|
|
my $modulehexstring = sprintf("0x%02X%02X%02X", $module_major_version, $module_minor_version, $module_patch_version);
|
2011-08-09 05:44:41 +00:00
|
|
|
open MODULE_VERSION_HEADER_FILE, ">$moduleversionheader" or die "Can't open $moduleversionheader for writing";
|
2011-05-11 08:05:43 +00:00
|
|
|
print MODULE_VERSION_HEADER_FILE "/* This file was generated by syncqt with the info from sync.profile. */\n";
|
|
|
|
print MODULE_VERSION_HEADER_FILE "#ifndef QT_". uc($lib) . "_VERSION_H\n";
|
|
|
|
print MODULE_VERSION_HEADER_FILE "#define QT_". uc($lib) . "_VERSION_H\n";
|
|
|
|
print MODULE_VERSION_HEADER_FILE "\n";
|
|
|
|
print MODULE_VERSION_HEADER_FILE "#define " .uc($lib) . "_VERSION_STR \"" . $module_version . "\"\n";
|
|
|
|
print MODULE_VERSION_HEADER_FILE "\n";
|
|
|
|
print MODULE_VERSION_HEADER_FILE "#define " .uc($lib) . "_VERSION $modulehexstring\n", ;
|
|
|
|
print MODULE_VERSION_HEADER_FILE "\n";
|
|
|
|
print MODULE_VERSION_HEADER_FILE "#endif // QT_". uc($lib) . "_VERSION_H\n";
|
2011-07-18 12:08:12 +00:00
|
|
|
close MODULE_VERSION_HEADER_FILE;
|
2011-07-07 18:05:49 +00:00
|
|
|
$moduleversionheader = "<srcbase>" . substr($moduleversionheader, length($basedir)) if ($verbose_level < 2);
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: created version header $moduleversionheader\n" if($verbose_level);
|
2011-05-11 08:05:43 +00:00
|
|
|
} elsif ($modulepri) {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: Module\'s pri file '$modulepri' not found.\n$lib: Skipped creating module version header.\n";
|
2011-05-11 08:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#create the new ones
|
|
|
|
foreach my $current_dir (split(/;/, $dir)) {
|
2011-10-20 13:45:20 +00:00
|
|
|
my @headers_paths = split(/;/, $pathtoheaders);
|
|
|
|
if (@headers_paths) {
|
|
|
|
@headers_paths = map { "$current_dir/$_" } @headers_paths;
|
|
|
|
} else {
|
|
|
|
push @headers_paths, $current_dir;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2011-10-20 13:45:20 +00:00
|
|
|
foreach my $headers_dir (@headers_paths) {
|
|
|
|
#calc subdirs
|
|
|
|
my @subdirs = ($headers_dir);
|
|
|
|
foreach my $subdir (@subdirs) {
|
|
|
|
opendir DIR, $subdir or next;
|
|
|
|
foreach my $t (sort readdir(DIR)) {
|
|
|
|
push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") &&
|
|
|
|
!($t eq "..") && !($t eq ".obj") &&
|
|
|
|
!($t eq ".moc") && !($t eq ".rcc") &&
|
|
|
|
!($t eq ".uic") && !($t eq "build"));
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
closedir DIR;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
|
|
|
|
#calc files and "copy" them
|
|
|
|
foreach my $subdir (@subdirs) {
|
|
|
|
my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0);
|
|
|
|
if (defined $inject_headers{$subdir}) {
|
|
|
|
foreach my $if ($inject_headers{$subdir}) {
|
|
|
|
@headers = grep(!/^\Q$if\E$/, @headers); #in case we configure'd previously
|
|
|
|
push @headers, "*".$if;
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
my $header_dirname = "";
|
|
|
|
foreach my $header (@headers) {
|
|
|
|
my $shadow = ($header =~ s/^\*//);
|
|
|
|
$header = 0 if($header =~ /^ui_.*.h/);
|
|
|
|
foreach (@ignore_headers) {
|
|
|
|
$header = 0 if($header eq $_);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
if($header) {
|
|
|
|
my $header_copies = 0;
|
|
|
|
#figure out if it is a public header
|
|
|
|
my $public_header = $header;
|
|
|
|
if($allheadersprivate || $public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
|
|
|
|
$public_header = 0;
|
|
|
|
} else {
|
|
|
|
foreach (@ignore_for_master_contents) {
|
|
|
|
$public_header = 0 if($header eq $_);
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
|
|
|
|
my $iheader = $subdir . "/" . $header;
|
|
|
|
$iheader =~ s/^\Q$basedir\E/$out_basedir/ if ($shadow);
|
|
|
|
my @classes = $public_header ? classNames($iheader) : ();
|
|
|
|
if($showonly) {
|
|
|
|
print "$header [$lib]\n";
|
|
|
|
foreach(@classes) {
|
|
|
|
print "SYMBOL: $_\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
} else {
|
|
|
|
my $ts = (stat($iheader))[9];
|
|
|
|
#find out all the places it goes..
|
|
|
|
my @headers;
|
|
|
|
if ($public_header) {
|
|
|
|
@headers = ( "$out_basedir/include/$lib/$header" );
|
|
|
|
foreach my $full_class (@classes) {
|
|
|
|
my $header_base = basename($header);
|
|
|
|
# Strip namespaces:
|
|
|
|
my $class = $full_class;
|
|
|
|
$class =~ s/^.*:://;
|
|
|
|
# if ($class =~ m/::/) {
|
|
|
|
# class =~ s,::,/,g;
|
|
|
|
# }
|
2011-11-04 11:20:49 +00:00
|
|
|
|
|
|
|
if (defined $explicitheaders{$lib}{$class}) {
|
|
|
|
$header_copies++ if(syncHeader($lib, "$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$explicitheaders{$lib}{$class}", 0, $ts));
|
|
|
|
} else {
|
|
|
|
$class_lib_map_contents .= "QT_CLASS_LIB($full_class, $lib, $header_base)\n";
|
|
|
|
$header_copies++ if(syncHeader($lib, "$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0, $ts));
|
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
|
|
|
|
# KDE-Compat headers for Phonon
|
|
|
|
if ($lib eq "phonon") {
|
|
|
|
$header_copies++ if (syncHeader($lib, "$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0, $ts));
|
|
|
|
}
|
|
|
|
}
|
2011-11-04 11:20:49 +00:00
|
|
|
|
|
|
|
if ($explicitheaders{$lib}{basename($header)}) {
|
|
|
|
$header_copies++ if(syncHeader($lib, "$out_basedir/include/$lib/$explicitheaders{$lib}{basename($header)}", "$out_basedir/include/$lib/$header", 0, $ts));
|
|
|
|
}
|
|
|
|
|
2011-10-20 13:45:20 +00:00
|
|
|
} elsif ($create_private_headers) {
|
|
|
|
if ($module_version) {
|
|
|
|
@headers = ( "$out_basedir/include/$lib/$module_version/$lib/private/$header" );
|
|
|
|
} else {
|
|
|
|
@headers = ( "$out_basedir/include/$lib/private/$header" );
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
foreach(@headers) { #sync them
|
|
|
|
$header_copies++ if(syncHeader($lib, $_, $iheader, $copy_headers && !$shadow, $ts));
|
2011-04-20 18:57:51 +00:00
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
if($public_header) {
|
2011-10-20 13:45:20 +00:00
|
|
|
#put it into the master file
|
|
|
|
$master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude($iheader));
|
|
|
|
|
|
|
|
#deal with the install directives
|
|
|
|
if($public_header) {
|
|
|
|
my $pri_install_iheader = fixPaths($iheader, $current_dir);
|
|
|
|
foreach my $class (@classes) {
|
|
|
|
# Strip namespaces:
|
|
|
|
$class =~ s/^.*:://;
|
|
|
|
# if ($class =~ m/::/) {
|
|
|
|
# $class =~ s,::,/,g;
|
|
|
|
# }
|
|
|
|
my $class_header = fixPaths("$out_basedir/include/$lib/$class",
|
|
|
|
$current_dir) . " ";
|
|
|
|
$pri_install_classes .= $class_header
|
|
|
|
unless($pri_install_classes =~ $class_header);
|
|
|
|
}
|
2011-11-04 11:20:49 +00:00
|
|
|
if ($explicitheaders{$lib}{basename($iheader)}) {
|
|
|
|
my $compat_header = fixPaths("$out_basedir/include/$lib/$explicitheaders{$lib}{basename($iheader)}", $current_dir) . " ";
|
|
|
|
$pri_install_files .= $compat_header unless($pri_install_files =~ $compat_header);
|
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
$pri_install_files.= "$pri_install_iheader ";;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
my $pri_install_iheader = fixPaths($iheader, $current_dir);
|
|
|
|
$pri_install_pfiles.= "$pri_install_iheader ";;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-07 18:05:49 +00:00
|
|
|
|
2011-10-20 13:45:20 +00:00
|
|
|
if ($verbose_level && $header_copies) {
|
|
|
|
my $new_header_dirname = dirname($iheader);
|
|
|
|
$new_header_dirname = "<srcbase>" . substr($new_header_dirname, length($basedir)) if ($new_header_dirname && $verbose_level < 2);
|
|
|
|
my $header_base = basename($iheader);
|
|
|
|
if ($verbose_level < 3) {
|
|
|
|
my $line_prefix = ",";
|
|
|
|
if ($new_header_dirname ne $header_dirname) {
|
|
|
|
$line_prefix = "$lib: created fwd-include header(s) for $new_header_dirname/ {";
|
|
|
|
$line_prefix = " }\n".$line_prefix if ($header_dirname);
|
|
|
|
$header_dirname = $new_header_dirname;
|
|
|
|
} else {
|
|
|
|
$line_prefix = ",";
|
|
|
|
}
|
|
|
|
print "$line_prefix $header_base ($header_copies)";
|
|
|
|
} else { # $verbose_level >= 3
|
|
|
|
$iheader = "<srcbase>" . substr($iheader, length($basedir)) if ($verbose_level == 3);
|
|
|
|
print "$lib: created $header_copies fwd-include headers for $iheader\n";
|
2011-07-07 18:05:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2011-10-20 13:45:20 +00:00
|
|
|
print " }\n" if ($header_dirname && $verbose_level > 0 && $verbose_level < 3);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# close the master include:
|
|
|
|
$master_contents .= "#endif\n";
|
|
|
|
|
|
|
|
unless($showonly) {
|
Add deprecated headers support to syncqt
When renaming classes, or when moving classes from one module to
another, it's useful to have a simple way of supporting the old
API/location for some time. To this end, syncqt shall now recognize
a "deprecatedheaders" section in sync.profile. It looks like this:
%deprecatedheaders = (
"QtDeclarative" => {
"qquickcanvas.h" => "QtQuick2/qquickcanvas.h",
"qquickitem.h" => "QtQuick2/qquickitem.h",
"QQuickCanvas" => "QtQuick2/QQuickCanvas",
"QQuickItem" => "QtQuick2/QQuickItem",
}
);
In the above example, syncqt would generate a header called
qquickcanvas.h for the QtDeclarative module; when included, this
header will issue a warning and include <QtQuick2/qquickcanvas.h>.
And so on, for the other entries.
Deprecated headers are installed along with the module's normal
headers.
Change-Id: Ie2518b42275c2b2ff44216f07d376ccf5be6dc45
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
2011-11-25 13:53:39 +00:00
|
|
|
# create deprecated headers
|
|
|
|
my $first = 1;
|
|
|
|
while (my ($header, $include) = each %{$deprecatedheaders{$lib}}) {
|
|
|
|
my $public_header = 0;
|
|
|
|
$public_header = 1 unless ($allheadersprivate || ($header =~ /_p\.h$/));
|
|
|
|
next unless ($public_header || $create_private_headers);
|
|
|
|
|
|
|
|
my $header_path = "$out_basedir/include/$lib/";
|
|
|
|
unless ($public_header) {
|
|
|
|
if ($module_version) {
|
|
|
|
$header_path .= "$module_version/$lib/private/";
|
|
|
|
} else {
|
|
|
|
$header_path .= "private/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$header_path .= "$header";
|
|
|
|
|
|
|
|
unless (-e $header_path) {
|
|
|
|
my $guard = "DEPRECATED_HEADER_" . $lib . "_" . $header;
|
|
|
|
$guard =~ s/([^a-zA-Z0-9_])/_/g;
|
|
|
|
|
|
|
|
open HEADER, ">$header_path" || die "Could not open $header_path for writing!\n";
|
|
|
|
print HEADER "#ifndef $guard\n";
|
|
|
|
print HEADER "#define $guard\n";
|
|
|
|
my $warning = "Header <$lib/";
|
|
|
|
$warning .= "private/" unless ($public_header);
|
|
|
|
$warning .= "$header> is deprecated. Please include <$include> instead.";
|
2011-11-30 12:51:16 +00:00
|
|
|
print HEADER "#if defined(__GNUC__)\n";
|
|
|
|
print HEADER "# warning $warning\n";
|
|
|
|
print HEADER "#elif defined(_MSC_VER)\n";
|
|
|
|
print HEADER "# pragma message (\"$warning\")\n";
|
|
|
|
print HEADER "#endif\n";
|
Add deprecated headers support to syncqt
When renaming classes, or when moving classes from one module to
another, it's useful to have a simple way of supporting the old
API/location for some time. To this end, syncqt shall now recognize
a "deprecatedheaders" section in sync.profile. It looks like this:
%deprecatedheaders = (
"QtDeclarative" => {
"qquickcanvas.h" => "QtQuick2/qquickcanvas.h",
"qquickitem.h" => "QtQuick2/qquickitem.h",
"QQuickCanvas" => "QtQuick2/QQuickCanvas",
"QQuickItem" => "QtQuick2/QQuickItem",
}
);
In the above example, syncqt would generate a header called
qquickcanvas.h for the QtDeclarative module; when included, this
header will issue a warning and include <QtQuick2/qquickcanvas.h>.
And so on, for the other entries.
Deprecated headers are installed along with the module's normal
headers.
Change-Id: Ie2518b42275c2b2ff44216f07d376ccf5be6dc45
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
2011-11-25 13:53:39 +00:00
|
|
|
print HEADER "#include <$include>\n";
|
|
|
|
if ($public_header) {
|
|
|
|
print HEADER "#if 0\n";
|
|
|
|
print HEADER "#pragma qt_no_master_include\n";
|
|
|
|
print HEADER "#endif\n";
|
|
|
|
}
|
|
|
|
print HEADER "#endif\n";
|
|
|
|
close HEADER;
|
|
|
|
|
|
|
|
if ($verbose_level < 3) {
|
|
|
|
my $line_prefix = ",";
|
|
|
|
$line_prefix = "$lib: created deprecated header(s) {" if ($first);
|
|
|
|
print "$line_prefix $header";
|
|
|
|
} else {
|
|
|
|
print "$lib: created deprecated header $header => $include\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $addendum = fixPaths($header_path, $dir) . " ";
|
|
|
|
if ($public_header) {
|
|
|
|
$pri_install_files .= $addendum;
|
|
|
|
} else {
|
|
|
|
$pri_install_pfiles .= $addendum;
|
|
|
|
}
|
|
|
|
$first = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($verbose_level < 3) {
|
|
|
|
print " }\n" unless ($first);
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
my @master_includes;
|
|
|
|
push @master_includes, "$out_basedir/include/$lib/$lib";
|
|
|
|
push @master_includes, "$out_basedir/include/phonon_compat/Phonon/Phonon" if ($lib eq "phonon");
|
|
|
|
foreach my $master_include (@master_includes) {
|
|
|
|
#generate the "master" include file
|
|
|
|
my @tmp = split(/;/,$modules{$lib});
|
|
|
|
$pri_install_files .= fixPaths($master_include, $tmp[0]) . " "; #get the master file installed too
|
|
|
|
if($master_include && -e $master_include) {
|
|
|
|
open MASTERINCLUDE, "<$master_include";
|
|
|
|
local $/;
|
|
|
|
binmode MASTERINCLUDE;
|
|
|
|
my $oldmaster = <MASTERINCLUDE>;
|
|
|
|
close MASTERINCLUDE;
|
|
|
|
$oldmaster =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
|
|
|
|
$master_include = 0 if($oldmaster eq $master_contents);
|
|
|
|
}
|
|
|
|
if($master_include && $master_contents) {
|
|
|
|
my $master_dir = dirname($master_include);
|
2011-07-07 18:48:02 +00:00
|
|
|
make_path($master_dir, $lib, $verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
open MASTERINCLUDE, ">$master_include";
|
|
|
|
print MASTERINCLUDE $master_contents;
|
|
|
|
close MASTERINCLUDE;
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: created header (master) file\n" if($verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#handle the headers.pri for each module
|
|
|
|
my $headers_pri_contents = "";
|
|
|
|
$headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n";
|
|
|
|
$headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n";
|
|
|
|
$headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n";
|
|
|
|
my $headers_pri_file = "$out_basedir/include/$lib/headers.pri";
|
|
|
|
if(-e $headers_pri_file) {
|
|
|
|
open HEADERS_PRI_FILE, "<$headers_pri_file";
|
|
|
|
local $/;
|
|
|
|
binmode HEADERS_PRI_FILE;
|
|
|
|
my $old_headers_pri_contents = <HEADERS_PRI_FILE>;
|
|
|
|
close HEADERS_PRI_FILE;
|
|
|
|
$old_headers_pri_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
|
|
|
|
$headers_pri_file = 0 if($old_headers_pri_contents eq $headers_pri_contents);
|
|
|
|
}
|
|
|
|
if($headers_pri_file && $master_contents) {
|
|
|
|
my $headers_pri_dir = dirname($headers_pri_file);
|
2011-07-07 18:48:02 +00:00
|
|
|
make_path($headers_pri_dir, $lib, $verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
open HEADERS_PRI_FILE, ">$headers_pri_file";
|
|
|
|
print HEADERS_PRI_FILE $headers_pri_contents;
|
|
|
|
close HEADERS_PRI_FILE;
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: created headers.pri file\n" if($verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2010-11-25 02:21:06 +00:00
|
|
|
|
|
|
|
# create forwarding module pri in qtbase/mkspecs/modules
|
2011-05-18 13:23:51 +00:00
|
|
|
if ($module_fwd) {
|
2010-11-25 02:21:06 +00:00
|
|
|
my $modulepri = $modulepris{$lib};
|
|
|
|
if (-e $modulepri) {
|
|
|
|
my $modulepriname = basename($modulepri);
|
2011-07-07 18:48:02 +00:00
|
|
|
make_path($module_fwd, $lib, $verbose_level);
|
2011-05-18 13:23:51 +00:00
|
|
|
my $moduleprifwd = "$module_fwd/$modulepriname";
|
2011-11-23 01:44:47 +00:00
|
|
|
my $mod_base = $basedir;
|
2011-05-18 13:23:51 +00:00
|
|
|
my $mod_component_base = $developer_build ? $qtbasedir : $out_basedir;
|
2011-05-13 14:22:09 +00:00
|
|
|
open MODULE_PRI_FILE, ">$moduleprifwd" or die("Could not open $moduleprifwd for writing");
|
2011-05-18 13:23:51 +00:00
|
|
|
print MODULE_PRI_FILE "QT_MODULE_BASE = $mod_base\n";
|
|
|
|
print MODULE_PRI_FILE "QT_MODULE_BIN_BASE = $mod_component_base/bin\n";
|
2010-11-25 02:21:06 +00:00
|
|
|
print MODULE_PRI_FILE "QT_MODULE_INCLUDE_BASE = $out_basedir/include\n";
|
2011-05-18 13:23:51 +00:00
|
|
|
print MODULE_PRI_FILE "QT_MODULE_IMPORT_BASE = $mod_component_base/imports\n";
|
|
|
|
print MODULE_PRI_FILE "QT_MODULE_LIB_BASE = $mod_component_base/lib\n";
|
|
|
|
print MODULE_PRI_FILE "QT_MODULE_PLUGIN_BASE = $mod_component_base/plugins\n";
|
2010-11-25 02:21:06 +00:00
|
|
|
print MODULE_PRI_FILE "include($modulepri)\n";
|
|
|
|
close MODULE_PRI_FILE;
|
|
|
|
utime(time, (stat($modulepri))[9], $moduleprifwd);
|
2011-05-18 13:23:51 +00:00
|
|
|
if ($cache_module_fwd) {
|
|
|
|
my $cacheStatement = "QMAKE_EXTRA_MODULE_FORWARDS = \"$module_fwd\"";
|
|
|
|
my $cacheFile = "$out_basedir/.qmake.cache";
|
|
|
|
my $existingQmakeCache = fileContents($cacheFile);
|
|
|
|
# Skip if it's already there.
|
|
|
|
if ($existingQmakeCache !~ $cacheStatement) {
|
|
|
|
open QMAKE_CACHE_FILE, ">>$cacheFile" or die("Could not open $cacheFile for writing");
|
|
|
|
print QMAKE_CACHE_FILE "$cacheStatement\n";
|
|
|
|
close(QMAKE_CACHE_FILE);
|
|
|
|
}
|
|
|
|
}
|
2010-11-25 02:21:06 +00:00
|
|
|
} elsif ($modulepri) {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: Module\'s pri file '$modulepri' not found.\n$lib: Skipped creating forwarding pri.\n";
|
2010-11-25 02:21:06 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
unless($showonly || !$create_uic_class_map) {
|
|
|
|
my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h";
|
|
|
|
if(-e $class_lib_map) {
|
|
|
|
open CLASS_LIB_MAP, "<$class_lib_map";
|
|
|
|
local $/;
|
|
|
|
binmode CLASS_LIB_MAP;
|
|
|
|
my $old_class_lib_map_contents = <CLASS_LIB_MAP>;
|
|
|
|
close CLASS_LIB_MAP;
|
|
|
|
$old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
|
|
|
|
$class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents);
|
|
|
|
}
|
|
|
|
if($class_lib_map) {
|
|
|
|
my $class_lib_map_dir = dirname($class_lib_map);
|
2011-07-07 18:48:02 +00:00
|
|
|
make_path($class_lib_map_dir, "<outdir>", $verbose_level);
|
2011-04-27 10:05:43 +00:00
|
|
|
open CLASS_LIB_MAP, ">$class_lib_map";
|
|
|
|
print CLASS_LIB_MAP $class_lib_map_contents;
|
|
|
|
close CLASS_LIB_MAP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($check_includes) {
|
|
|
|
for my $lib (keys(%modules)) {
|
|
|
|
#calc subdirs
|
|
|
|
my @subdirs = ($modules{$lib});
|
|
|
|
foreach my $subdir (@subdirs) {
|
|
|
|
opendir DIR, $subdir or die "Huh, directory ".$subdir." cannot be opened.";
|
2011-07-20 15:42:26 +00:00
|
|
|
foreach my $t (sort readdir(DIR)) {
|
2011-04-27 10:05:43 +00:00
|
|
|
push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") &&
|
|
|
|
!($t eq "..") && !($t eq ".obj") &&
|
|
|
|
!($t eq ".moc") && !($t eq ".rcc") &&
|
|
|
|
!($t eq ".uic") && !($t eq "build"));
|
|
|
|
}
|
|
|
|
closedir DIR;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $subdir (@subdirs) {
|
|
|
|
my $header_skip_qt_module_test = 0;
|
|
|
|
foreach(@ignore_for_qt_module_check) {
|
|
|
|
foreach (split(/;/, $_)) {
|
|
|
|
$header_skip_qt_module_test = 1 if ($subdir =~ /^$_/);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0);
|
|
|
|
foreach my $header (@headers) {
|
|
|
|
my $header_skip_qt_begin_header_test = 0;
|
|
|
|
my $header_skip_qt_begin_namespace_test = 0;
|
|
|
|
$header = 0 if($header =~ /^ui_.*.h/);
|
|
|
|
foreach (@ignore_headers) {
|
|
|
|
$header = 0 if($header eq $_);
|
|
|
|
}
|
|
|
|
if($header) {
|
|
|
|
my $public_header = $header;
|
|
|
|
if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
|
|
|
|
$public_header = 0;
|
|
|
|
} else {
|
|
|
|
foreach (@ignore_for_master_contents) {
|
|
|
|
$public_header = 0 if($header eq $_);
|
|
|
|
}
|
|
|
|
if($public_header) {
|
|
|
|
foreach (@ignore_for_include_check) {
|
|
|
|
$public_header = 0 if($header eq $_);
|
|
|
|
}
|
|
|
|
foreach(@ignore_for_qt_begin_header_check) {
|
|
|
|
$header_skip_qt_begin_header_test = 1 if ($header eq $_);
|
|
|
|
}
|
|
|
|
foreach(@ignore_for_qt_begin_namespace_check) {
|
|
|
|
$header_skip_qt_begin_namespace_test = 1 if ($header eq $_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $iheader = $subdir . "/" . $header;
|
|
|
|
if($public_header) {
|
|
|
|
if(open(F, "<$iheader")) {
|
|
|
|
my $qt_module_found = 0;
|
|
|
|
my $qt_begin_header_found = 0;
|
|
|
|
my $qt_end_header_found = 0;
|
|
|
|
my $qt_begin_namespace_found = 0;
|
|
|
|
my $qt_end_namespace_found = 0;
|
|
|
|
my $line;
|
|
|
|
while($line = <F>) {
|
|
|
|
chomp $line;
|
|
|
|
my $output_line = 1;
|
|
|
|
if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) {
|
|
|
|
last;
|
|
|
|
} elsif($line =~ /^ *\# *include/) {
|
|
|
|
my $include = $line;
|
|
|
|
if($line =~ /<.*>/) {
|
|
|
|
$include =~ s,.*<(.*)>.*,$1,;
|
|
|
|
} elsif($line =~ /".*"/) {
|
|
|
|
$include =~ s,.*"(.*)".*,$1,;
|
|
|
|
} else {
|
|
|
|
$include = 0;
|
|
|
|
}
|
|
|
|
if($include) {
|
|
|
|
for my $trylib (keys(%modules)) {
|
|
|
|
if(-e "$out_basedir/include/$trylib/$include") {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: $iheader includes $include when it should include $trylib/$include\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) {
|
|
|
|
$qt_begin_header_found = 1;
|
|
|
|
} elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) {
|
|
|
|
$qt_end_header_found = 1;
|
|
|
|
} elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) {
|
|
|
|
$qt_begin_namespace_found = 1;
|
|
|
|
} elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) {
|
|
|
|
$qt_end_namespace_found = 1;
|
|
|
|
} elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) {
|
|
|
|
$qt_module_found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($header_skip_qt_begin_header_test == 0) {
|
|
|
|
if ($qt_begin_header_found == 0) {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: $iheader does not include QT_BEGIN_HEADER\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($qt_begin_header_found && $qt_end_header_found == 0) {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: $iheader has QT_BEGIN_HEADER but no QT_END_HEADER\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($header_skip_qt_begin_namespace_test == 0) {
|
|
|
|
if ($qt_begin_namespace_found == 0) {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($qt_begin_namespace_found && $qt_end_namespace_found == 0) {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: $iheader has QT_BEGIN_NAMESPACE but no QT_END_NAMESPACE\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($header_skip_qt_module_test == 0) {
|
|
|
|
if ($qt_module_found == 0) {
|
2011-07-07 18:48:02 +00:00
|
|
|
print "$lib: WARNING: $iheader does not include QT_MODULE\n";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-30 04:51:16 +00:00
|
|
|
# Do configure tests now (pass some things along)
|
|
|
|
# fatal tests have a non zero return
|
2011-07-25 12:07:54 +00:00
|
|
|
# If the generator is not set (e.g. someone invoking syncqt as part of configure etc, then don't run tests either)
|
|
|
|
unless ($showonly || $makefile_generator eq '') {
|
2011-06-30 04:51:16 +00:00
|
|
|
my $configtests = dirname($0)."/qtmodule-configtests";
|
2011-07-25 12:07:54 +00:00
|
|
|
if (! -f $configtests) {
|
|
|
|
$configtests = $qtbasedir."/bin/qtmodule-configtests";
|
|
|
|
}
|
|
|
|
if (! -f $configtests) {
|
|
|
|
warn "Unable to locate qtmodule-configtests script - config tests disabled.\n";
|
|
|
|
} else {
|
|
|
|
if (system($EXECUTABLE_NAME, $configtests, $basedir, $out_basedir, $qtbasedir, $makefile_generator)) {
|
|
|
|
die "$configtests exited with status $?";
|
|
|
|
}
|
2011-06-30 04:51:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
exit 0;
|