2 ######################################################################
4 # Synchronizes Qt header files - internal development tool.
6 # Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
7 # Contact: Nokia Corporation (qt-info@nokia.com)
9 ######################################################################
11 # use packages -------------------------------------------------------
18 die "syncqt: QTDIR not defined" if ! $ENV{"QTDIR"}; # sanity check
22 my $basedir = $ENV{"QTDIR"};
24 my %modules = ( # path to module name map
25 "QtGui" => "$basedir/src/gui",
26 "QtOpenGL" => "$basedir/src/opengl",
27 "QtOpenVG" => "$basedir/src/openvg",
28 "QtCore" => "$basedir/src/corelib",
29 "QtXml" => "$basedir/src/xml",
30 "QtXmlPatterns" => "$basedir/src/xmlpatterns",
31 "QtSql" => "$basedir/src/sql",
32 "QtNetwork" => "$basedir/src/network",
33 "QtSvg" => "$basedir/src/svg",
34 "QtDeclarative" => "$basedir/src/declarative",
35 "QtScript" => "$basedir/src/script",
36 "QtScriptTools" => "$basedir/src/scripttools",
37 "Qt3Support" => "$basedir/src/qt3support",
38 "ActiveQt" => "$basedir/src/activeqt/container;$basedir/src/activeqt/control;$basedir/src/activeqt/shared",
39 "QtTest" => "$basedir/src/testlib",
40 "QtAssistant" => "$basedir/tools/assistant/compat/lib",
41 "QtHelp" => "$basedir/tools/assistant/lib",
42 "QtDesigner" => "$basedir/tools/designer/src/lib",
43 "QtUiTools" => "$basedir/tools/designer/src/uitools",
44 "QtDBus" => "$basedir/src/dbus",
45 "QtWebKit" => "$basedir/src/3rdparty/webkit/WebCore",
46 "phonon" => "$basedir/src/phonon",
47 "QtMultimedia" => "$basedir/src/multimedia",
49 my %moduleheaders = ( # restrict the module headers to those found in relative path
50 "QtWebKit" => "../WebKit/qt/Api",
51 "phonon" => "../3rdparty/phonon/phonon",
54 #$modules{"QtCore"} .= ";$basedir/mkspecs/" . $ENV{"MKSPEC"} if defined $ENV{"MKSPEC"};
56 # global variables (modified by options)
61 my $force_relative = 0;
62 my $check_includes = 0;
65 $force_relative = 1 if ( -d
"/System/Library/Frameworks" );
66 my $out_basedir = $basedir;
67 $out_basedir =~ s
=\\=/=g
;
69 # functions ----------------------------------------------------------
71 ######################################################################
75 # Purpose: Show the usage of the script.
77 ######################################################################
81 print " -copy Copy headers instead of include-fwd(default: " . ($copy_headers ?
"yes" : "no") . ")\n";
82 print " -remove-stale Removes stale headers (default: " . ($remove_stale ?
"yes" : "no") . ")\n";
83 print " -relative Force relative symlinks (default: " . ($force_relative ?
"yes" : "no") . ")\n";
84 print " -windows Force platform to Windows (default: " . ($force_win ?
"yes" : "no") . ")\n";
85 print " -showonly Show action but not perform (default: " . ($showonly ?
"yes" : "no") . ")\n";
86 print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n";
87 print " -help This help\n";
91 ######################################################################
95 # Purpose: Check if script runs on a Unix system or not. Cygwin
96 # systems are _not_ detected as Unix systems.
97 # Returns: 1 if a unix system, else 0.
98 ######################################################################
101 if ( $force_win != 0) {
103 } elsif ( -f
"/bin/uname" ) {
105 (-f
"\\bin\\uname") && ($r = 0);
106 } elsif ( -f
"/usr/bin/uname" ) {
108 (-f
"\\usr\\bin\\uname") && ($r = 0);
111 $_ = $Config{'osname'};
112 $r = 0 if( /(ms)|(cyg)win/i );
119 return 0 if($dir =~ /^\//);
120 return 0 if(!checkUnix
() && $dir =~ /[a-zA-Z]:[\/\\]/);
124 ######################################################################
125 # Syntax: shouldMasterInclude(iheader)
126 # Params: iheader, string, filename to verify inclusion
128 # Purpose: Determines if header should be in the master include file.
129 # Returns: 0 if file contains "#pragma qt_no_master_include" or not
130 # able to open, else 1.
131 ######################################################################
132 sub shouldMasterInclude
{
134 return 0 if(basename
($iheader) =~ /_/);
135 return 0 if(basename
($iheader) =~ /qconfig/);
136 if(open(F
, "<$iheader")) {
139 return 0 if(/^\#pragma qt_no_master_include$/);
148 ######################################################################
149 # Syntax: classNames(iheader)
150 # Params: iheader, string, filename to parse for classname "symlinks"
152 # Purpose: Scans through iheader to find all classnames that should be
153 # synced into library's include structure.
154 # Returns: List of all class names in a file.
155 ######################################################################
159 if(basename
($iheader) eq "qglobal.h") {
160 push @ret, "QtGlobal";
161 } elsif(basename
($iheader) eq "qendian.h") {
162 push @ret, "QtEndian";
163 } elsif(basename
($iheader) eq "qconfig.h") {
164 push @ret, "QtConfig";
165 } elsif(basename
($iheader) eq "qplugin.h") {
166 push @ret, "QtPlugin";
167 } elsif(basename
($iheader) eq "qalgorithms.h") {
168 push @ret, "QtAlgorithms";
169 } elsif(basename
($iheader) eq "qcontainerfwd.h") {
170 push @ret, "QtContainerFwd";
171 } elsif(basename
($iheader) eq "qdebug.h") {
172 push @ret, "QtDebug";
173 } elsif(basename
($iheader) eq "qevent.h") {
174 push @ret, "QtEvents";
175 } elsif(basename
($iheader) eq "qnamespace.h") {
177 } elsif(basename
($iheader) eq "qssl.h") {
179 } elsif(basename
($iheader) eq "qtest.h") {
181 } elsif(basename
($iheader) eq "qtconcurrentmap.h") {
182 push @ret, "QtConcurrentMap"
183 } elsif(basename
($iheader) eq "qtconcurrentfilter.h") {
184 push @ret, "QtConcurrentFilter"
185 } elsif(basename
($iheader) eq "qtconcurrentrun.h") {
186 push @ret, "QtConcurrentRun"
190 if(open(F
, "<$iheader")) {
194 chop $line if ($line =~ /\r$/);
199 last unless($line =~ /\\$/);
202 return @ret if($line =~ m/^#pragma qt_sync_stop_processing/);
203 push(@ret, "$1") if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/);
207 $line =~ s
,//.*$,,; #remove c++ comments
208 $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro
209 $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro
210 $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro
211 $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro
212 $parsable .= " " . $line;
218 my $last_definition = 0;
220 for(my $i = 0; $i < length($parsable); $i++) {
222 my $character = substr($parsable, $i, 1);
223 if($character eq "/" && substr($parsable, $i+1, 1) eq "*") { #I parse like this for greedy reasons
224 for($i+=2; $i < length($parsable); $i++) {
225 my $end = substr($parsable, $i, 2);
227 $last_definition = $i+2;
232 } elsif($character eq "{") {
234 my $block_start = $i + 1;
235 BLOCK
: for($i+=1; $i < length($parsable); $i++) {
236 my $ignore = substr($parsable, $i, 1);
239 } elsif($ignore eq "}") {
241 unless($brace_depth) {
242 for(my $i2 = $i+1; $i2 < length($parsable); $i2++) {
243 my $end = substr($parsable, $i2, 1);
244 if($end eq ";" || $end ne " ") {
245 $definition = substr($parsable, $last_definition, $block_start - $last_definition) . "}";
246 $i = $i2 if($end eq ";");
247 $last_definition = $i + 1;
254 } elsif($character eq ";") {
255 $definition = substr($parsable, $last_definition, $i - $last_definition + 1);
256 $last_definition = $i + 1;
257 } elsif($character eq "}") {
258 # a naked } must be a namespace ending
259 # if it's not a namespace, it's eaten by the loop above
261 $last_definition = $i + 1;
264 if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) /
265 && substr($parsable, $i+1, 1) eq "{") {
266 push @namespaces, $1;
268 # Eat the opening { so that the condensing loop above doesn't see it
270 $last_definition = $i + 1;
274 $definition =~ s
=[\n\r]==g
;
276 if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) {
278 } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) {
280 } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) {
282 } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) {
283 push @symbols, "Q" . $1 . "Iterator";
284 push @symbols, "QMutable" . $1 . "Iterator";
289 $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces);
291 if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q
292 || $symbol =~ /^Phonon::/); # or in the Phonon namespace
299 ######################################################################
300 # Syntax: syncHeader(header, iheader, copy)
301 # Params: header, string, filename to create "symlink" for
302 # iheader, string, destination name of symlink
303 # copy, forces header to be a copy of iheader
305 # Purpose: Syncronizes header to iheader
306 # Returns: 1 if successful, else 0.
307 ######################################################################
309 my ($header, $iheader, $copy) = @_;
310 $iheader =~ s
=\\=/=g
;
312 return copyFile
($iheader, $header) if($copy);
314 unless(-e
"$header") {
315 my $header_dir = dirname
($header);
316 mkpath
$header_dir, 0777;
319 my $iheader_out = fixPaths
($iheader, $header_dir);
320 open HEADER
, ">$header" || die "Could not open $header for writing!\n";
321 print HEADER
"#include \"$iheader_out\"\n";
328 ######################################################################
329 # Syntax: fixPaths(file, dir)
330 # Params: file, string, filepath to be made relative to dir
331 # dir, string, dirpath for point of origin
333 # Purpose: file is made relative (if possible) of dir.
334 # Returns: String with the above applied conversion.
335 ######################################################################
337 my ($file, $dir) = @_;
338 $dir =~ s
=^$basedir/=$out_basedir/= if(!($basedir eq $out_basedir));
346 my $file_dir = dirname
($file);
347 if($file_dir eq ".") {
348 $file_dir = getcwd
();
349 $file_dir =~ s
=\\=/=g
;
351 $file_dir =~ s
,/cygdrive/([a
-zA
-Z
])/,$1:,g
;
356 $dir =~ s
,/cygdrive/([a
-zA
-Z
])/,$1:/,g
;
357 return basename
($file) if("$file_dir" eq "$dir");
361 for(my $i = 1; $i < length($file_dir); $i++) {
362 my $slash = index($file_dir, "/", $i);
363 last if($slash == -1);
364 my $tmp = substr($file_dir, 0, $slash);
365 last unless($dir =~ m
,^$tmp/,);
370 my $after = substr($dir, length($match_dir));
371 my $count = ($after =~ tr
,/,,);
373 for(my $i = 0; $i < $count; $i++) {
376 $ret =~ s
,^$match_dir,$dots,;
382 ######################################################################
383 # Syntax: fileContents(filename)
384 # Params: filename, string, filename of file to return contents
386 # Purpose: Get the contents of a file.
387 # Returns: String with contents of the file, or empty string if file
389 # Warning: Dies if it does exist but script cannot get read access.
390 ######################################################################
393 my $filecontents = "";
395 open(I
, "< $filename") || die "Could not open $filename for reading, read block?";
401 return $filecontents;
404 ######################################################################
405 # Syntax: fileCompare(file1, file2)
406 # Params: file1, string, filename of first file
407 # file2, string, filename of second file
409 # Purpose: Determines if files are equal, and which one is newer.
410 # Returns: 0 if files are equal no matter the timestamp, -1 if file1
411 # is newer, 1 if file2 is newer.
412 ######################################################################
414 my ($file1, $file2) = @_;
415 my $file1contents = fileContents
($file1);
416 my $file2contents = fileContents
($file2);
417 if (! -e
$file1) { return 1; }
418 if (! -e
$file2) { return -1; }
419 return $file1contents ne $file2contents ?
(stat("$file2"))[9] <=> (stat("$file1"))[9] : 0;
422 ######################################################################
423 # Syntax: copyFile(file, ifile)
424 # Params: file, string, filename to create duplicate for
425 # ifile, string, destination name of duplicate
427 # Purpose: Keeps files in sync so changes in the newer file will be
428 # written to the other.
429 # Returns: 1 if files were synced, else 0.
430 # Warning: Dies if script cannot get write access.
431 ######################################################################
434 my ($file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_;
435 # Bi-directional synchronization
436 open( I
, "< " . $file ) || die "Could not open $file for reading";
441 if ( open(I
, "< " . $ifile) ) {
444 $ifilecontents = <I
>;
446 $copy = fileCompare
($file, $ifile);
453 if ( $knowdiff || ($filecontents ne $ifilecontents) ) {
455 my $file_dir = dirname
($file);
456 mkpath
$file_dir, 0777 unless(-e
"$file_dir");
457 open(O
, "> " . $file) || die "Could not open $file for writing (no write permission?)";
460 print O
$ifilecontents;
463 } elsif ( $copy < 0 ) {
464 my $ifile_dir = dirname
($ifile);
465 mkpath
$ifile_dir, 0777 unless(-e
"$ifile_dir");
466 open(O
, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)";
469 print O
$filecontents;
477 ######################################################################
478 # Syntax: symlinkFile(file, ifile)
479 # Params: file, string, filename to create "symlink" for
480 # ifile, string, destination name of symlink
482 # Purpose: File is symlinked to ifile (or copied if filesystem doesn't
484 # Returns: 1 on success, else 0.
485 ######################################################################
488 my ($file,$ifile) = @_;
491 print "symlink created for $file ";
492 if ( $force_relative && ($ifile =~ /^$basedir/)) {
496 $t =~ s
-^$basedir/--;
497 $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 );
498 $file =~ s
-^$basedir/-$p-;
502 return symlink($file, $ifile);
504 return copyFile
($file, $ifile);
507 ######################################################################
508 # Syntax: findFiles(dir, match, descend)
509 # Params: dir, string, directory to search for name
510 # match, string, regular expression to match in dir
511 # descend, integer, 0 = non-recursive search
512 # 1 = recurse search into subdirectories
514 # Purpose: Finds files matching a regular expression.
515 # Returns: List of matching files.
518 # findFiles("/usr","\.cpp$",1) - finds .cpp files in /usr and below
519 # findFiles("/tmp","^#",0) - finds #* files in /tmp
520 ######################################################################
522 my ($dir,$match,$descend) = @_;
523 my ($file,$p,@files);
526 ($dir eq "") && ($dir = ".");
527 if ( opendir(D
,$dir) ) {
531 ($dir =~ /\/$/) || ($dir .= "/");
533 foreach $file ( sort readdir(D) ) {
534 next if ( $file =~ /^\.\.?$/ );
536 ($file =~ /$match/) && (push @files, $p);
537 if ( $descend && -d $p && ! -l $p ) {
538 push @files, &findFiles($p,$match,$descend);
546 # --------------------------------------------------------------------
548 # --------------------------------------------------------------------
555 my $arg = shift @ARGV;
556 if ("$arg" eq "-h
" || "$arg" eq "-help
" || "$arg" eq "?
") {
559 } elsif("$arg" eq "-copy
") {
562 } elsif("$arg" eq "-o
" || "$arg" eq "-outdir
") {
565 } elsif("$arg" eq "-showonly
" || "$arg" eq "-remove
-stale
" || "$arg" eq "-windows
" ||
566 "$arg" eq "-relative
" || "$arg" eq "-check
-includes
") {
567 $var = substr($arg, 1);
569 } elsif("$arg" =~ /^-no-(.*)$/) {
572 #these are for commandline compat
573 } elsif("$arg" eq "-inc
") {
576 } elsif("$arg" eq "-module
") {
579 } elsif("$arg" eq "-show
") {
582 } elsif("$arg" eq '*') {
583 # workaround for windows 9x where "%*" expands to "*"
588 if(!$var || "$var" eq "show_help
") {
589 print "Unknown option
: $arg\n\n" if(!$var);
591 } elsif ("$var" eq "copy
") {
592 if("$val" eq "yes
") {
597 } elsif ("$var" eq "showonly
") {
598 if("$val" eq "yes
") {
603 } elsif ("$var" eq "check
-includes
") {
604 if("$val" eq "yes
") {
606 } elsif($check_includes) {
609 } elsif ("$var" eq "remove
-stale
") {
610 if("$val" eq "yes
") {
612 } elsif($remove_stale) {
615 } elsif ("$var" eq "windows
") {
616 if("$val" eq "yes
") {
618 } elsif($force_win) {
621 } elsif ("$var" eq "relative
") {
622 if("$val" eq "yes
") {
624 } elsif($force_relative) {
627 } elsif ("$var" eq "module
") {
628 print "module
:$val:\n";
629 die "No such module
: $val" unless(defined $modules{$val});
630 push @modules_to_sync, $val;
631 } elsif ("$var" eq "output
") {
633 if(checkRelative($outdir)) {
634 $out_basedir = getcwd();
636 $out_basedir .= "/" . $outdir;
638 $out_basedir = $outdir;
641 $out_basedir =~ s=\\=/=g;
644 @modules_to_sync = keys(%modules) if($#modules_to_sync == -1);
646 $isunix = checkUnix; #cache checkUnix
649 mkpath "$out_basedir/include
", 0777;
651 my @ignore_headers = ();
652 my $class_lib_map_contents = "";
653 my @ignore_for_master_contents = ( "qt
.h
", "qpaintdevicedefs
.h
" );
654 my @ignore_for_include_check = ( "qatomic
.h
" );
655 my @ignore_for_qt_begin_header_check = ( "qiconset
.h
", "qconfig
.h
", "qconfig
-dist
.h
", "qconfig
-large
.h
", "qconfig
-medium
.h
", "qconfig
-minimal
.h
", "qconfig
-small
.h
", "qfeatures
.h
", "qt_windows
.h
" );
656 my @ignore_for_qt_begin_namespace_check = ( "qconfig
.h
", "qconfig
-dist
.h
", "qconfig
-large
.h
", "qconfig
-medium
.h
", "qconfig
-minimal
.h
", "qconfig
-small
.h
", "qfeatures
.h
", "qatomic_arch
.h
", "qatomic_windowsce
.h
", "qt_windows
.h
", "qatomic_macosx
.h
" );
657 my @ignore_for_qt_module_check = ( "$modules{QtCore
}/arch", "$modules{QtCore}/global
", "$modules{QtSql
}/drivers
", "$modules{QtTest
}", "$modules{QtAssistant
}", "$modules{QtDesigner
}", "$modules{QtUiTools
}", "$modules{QtDBus
}", "$modules{phonon
}" );
659 foreach (@modules_to_sync) {
662 my $dir = "$modules{$lib}";
663 my $pathtoheaders = "";
664 $pathtoheaders = "$moduleheaders{$lib}" if ($moduleheaders{$lib});
666 #information used after the syncing
667 my $pri_install_classes = "";
668 my $pri_install_files = "";
670 my $libcapitals = $lib;
671 $libcapitals =~ y/a-z/A-Z/;
672 my $master_contents = "#ifndef QT_".$libcapitals."_MODULE_H\n#define QT_".$libcapitals."_MODULE_H\n";
675 if(-e
"$dir/" . basename
($dir) . ".pro") {
676 if(open(F
, "<$dir/" . basename
($dir) . ".pro")) {
680 if($line =~ /^ *QT *\+?= *([^\r\n]*)/) {
681 foreach(split(/ /, "$1")) {
682 $master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core");
683 $master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui");
684 $master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network");
685 $master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg");
686 $master_contents .= "#include <QtDeclarative/QtDeclarative>\n" if("$_" eq "declarative");
687 $master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script");
688 $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools");
689 $master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support");
690 $master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql");
691 $master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml");
692 $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns");
693 $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl");
694 $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg");
702 #remove the old files
704 my @subdirs = ("$out_basedir/include/$lib");
707 if (opendir DIR
, "$subdir") {
708 while(my $t = readdir(DIR
)) {
709 my $file = "$subdir/$t";
711 push @subdirs, "$file" unless($t eq "." || $t eq "..");
713 my @files = ("$file");
714 #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t");
718 if(open(F
, "<$file")) {
722 if($line =~ /^\#include \"([^\"]*)\"$/) {
724 $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/");
725 $remove_file = 1 unless(-e
"$include");
732 unlink "$file" if($remove_file);
744 foreach (split(/;/, $dir)) {
745 my $current_dir = "$_";
746 my $headers_dir = $current_dir;
747 $headers_dir .= "/$pathtoheaders" if ($pathtoheaders);
749 my @subdirs = ($headers_dir);
752 opendir DIR
, "$subdir" or next;
753 while(my $t = readdir(DIR
)) {
754 push @subdirs, "$subdir/$t" if(-d
"$subdir/$t" && !($t eq ".") &&
755 !($t eq "..") && !($t eq ".obj") &&
756 !($t eq ".moc") && !($t eq ".rcc") &&
757 !($t eq ".uic") && !($t eq "build"));
762 #calc files and "copy" them
765 my @headers = findFiles
("$subdir", "^[-a-z0-9_]*\\.h\$" , 0);
768 $header = 0 if("$header" =~ /^ui_.*.h/);
769 foreach (@ignore_headers) {
770 $header = 0 if("$header" eq "$_");
773 my $header_copies = 0;
774 #figure out if it is a public header
775 my $public_header = $header;
776 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
779 foreach (@ignore_for_master_contents) {
780 $public_header = 0 if("$header" eq "$_");
784 my $iheader = $subdir . "/" . $header;
785 my @classes = $public_header ? classNames
($iheader) : ();
787 print "$header [$lib]\n";
789 print "SYMBOL: $_\n";
792 #find out all the places it goes..
794 if ($public_header) {
795 @headers = ( "$out_basedir/include/$lib/$header" );
796 push @headers, "$out_basedir/include/Qt/$header"
797 if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src
/);
800 my $header_base = basename
($header);
802 if ($class =~ m/::/) {
805 $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n";
806 $header_copies++ if(syncHeader
("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0));
809 @headers = ( "$out_basedir/include/$lib/private/$header" );
810 push @headers, "$out_basedir/include/Qt/private/$header"
811 if ("$lib" ne "phonon");
813 foreach(@headers) { #sync them
814 $header_copies++ if(syncHeader
($_, $iheader, $copy_headers));
818 #put it into the master file
819 $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude
($iheader));
821 #deal with the install directives
823 my $pri_install_iheader = fixPaths
($iheader, $current_dir);
826 if ($class =~ m/::/) {
829 my $class_header = fixPaths
("$out_basedir/include/$lib/$class",
831 $pri_install_classes .= $class_header
832 unless($pri_install_classes =~ $class_header);
834 $pri_install_files.= "$pri_install_iheader ";;
838 print "header created for $iheader ($header_copies)\n" if($header_copies > 0);
844 # close the master include:
845 $master_contents .= "#endif\n";
849 if ($lib eq "phonon") {
850 push @master_includes, "$out_basedir/include/phonon_compat/phonon/phonon";
851 push @master_includes, "$out_basedir/include/phonon/Phonon/Phonon";
853 push @master_includes, "$out_basedir/include/$lib/$lib";
855 foreach my $master_include (@master_includes) {
856 #generate the "master" include file
857 $pri_install_files .= fixPaths
($master_include, "$modules{$lib}") . " "; #get the master file installed too
858 if($master_include && -e
"$master_include") {
859 open MASTERINCLUDE
, "<$master_include";
861 binmode MASTERINCLUDE
;
862 my $oldmaster = <MASTERINCLUDE
>;
864 $oldmaster =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
865 $master_include = 0 if($oldmaster eq $master_contents);
867 if($master_include && $master_contents) {
868 my $master_dir = dirname
($master_include);
869 mkpath
$master_dir, 0777;
870 print "header (master) created for $lib\n";
871 open MASTERINCLUDE
, ">$master_include";
872 print MASTERINCLUDE
"$master_contents";
877 #handle the headers.pri for each module
878 my $headers_pri_contents = "";
879 $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n";
880 $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n";
881 my $headers_pri_file = "$out_basedir/include/$lib/headers.pri";
882 if(-e
"$headers_pri_file") {
883 open HEADERS_PRI_FILE
, "<$headers_pri_file";
885 binmode HEADERS_PRI_FILE
;
886 my $old_headers_pri_contents = <HEADERS_PRI_FILE
>;
887 close HEADERS_PRI_FILE
;
888 $old_headers_pri_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
889 $headers_pri_file = 0 if($old_headers_pri_contents eq $headers_pri_contents);
891 if($headers_pri_file && $master_contents) {
892 my $headers_pri_dir = dirname
($headers_pri_file);
893 mkpath
$headers_pri_dir, 0777;
894 print "headers.pri file created for $lib\n";
895 open HEADERS_PRI_FILE
, ">$headers_pri_file";
896 print HEADERS_PRI_FILE
"$headers_pri_contents";
897 close HEADERS_PRI_FILE
;
902 my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h";
903 if(-e
"$class_lib_map") {
904 open CLASS_LIB_MAP
, "<$class_lib_map";
906 binmode CLASS_LIB_MAP
;
907 my $old_class_lib_map_contents = <CLASS_LIB_MAP
>;
909 $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
910 $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents);
913 my $class_lib_map_dir = dirname
($class_lib_map);
914 mkpath
$class_lib_map_dir, 0777;
915 open CLASS_LIB_MAP
, ">$class_lib_map";
916 print CLASS_LIB_MAP
"$class_lib_map_contents";
921 if($check_includes) {
922 for (keys(%modules)) {
925 my $dir = "$modules{$lib}";
926 foreach (split(/;/, $dir)) {
927 my $current_dir = "$_";
929 my @subdirs = ($current_dir);
932 opendir DIR
, "$subdir";
933 while(my $t = readdir(DIR
)) {
934 push @subdirs, "$subdir/$t" if(-d
"$subdir/$t" && !($t eq ".") &&
935 !($t eq "..") && !($t eq ".obj") &&
936 !($t eq ".moc") && !($t eq ".rcc") &&
937 !($t eq ".uic") && !($t eq "build"));
944 my $header_skip_qt_module_test = 0;
945 foreach(@ignore_for_qt_module_check) {
946 foreach (split(/;/, $_)) {
947 $header_skip_qt_module_test = 1 if ("$subdir" =~ /^$_/);
950 my @headers = findFiles
("$subdir", "^[-a-z0-9_]*\\.h\$" , 0);
953 my $header_skip_qt_begin_header_test = 0;
954 my $header_skip_qt_begin_namespace_test = 0;
955 $header = 0 if("$header" =~ /^ui_.*.h/);
956 foreach (@ignore_headers) {
957 $header = 0 if("$header" eq "$_");
960 my $public_header = $header;
961 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
964 foreach (@ignore_for_master_contents) {
965 $public_header = 0 if("$header" eq "$_");
968 foreach (@ignore_for_include_check) {
969 $public_header = 0 if("$header" eq "$_");
971 foreach(@ignore_for_qt_begin_header_check) {
972 $header_skip_qt_begin_header_test = 1 if ("$header" eq "$_");
974 foreach(@ignore_for_qt_begin_namespace_check) {
975 $header_skip_qt_begin_namespace_test = 1 if ("$header" eq "$_");
980 my $iheader = $subdir . "/" . $header;
982 if(open(F
, "<$iheader")) {
983 my $qt_module_found = 0;
984 my $qt_begin_header_found = 0;
985 my $qt_end_header_found = 0;
986 my $qt_begin_namespace_found = 0;
987 my $qt_end_namespace_found = 0;
992 if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) {
994 } elsif($line =~ /^ *\# *include/) {
996 if($line =~ /<.*>/) {
997 $include =~ s
,.*<(.*)>.*,$1,;
998 } elsif($line =~ /".*"/) {
999 $include =~ s
,.*"(.*)".*,$1,;
1004 for (keys(%modules)) {
1006 if(-e
"$out_basedir/include/$trylib/$include") {
1007 print "WARNING: $iheader includes $include when it should include $trylib/$include\n";
1011 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) {
1012 $qt_begin_header_found = 1;
1013 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) {
1014 $qt_end_header_found = 1;
1015 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) {
1016 $qt_begin_namespace_found = 1;
1017 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) {
1018 $qt_end_namespace_found = 1;
1019 } elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) {
1020 $qt_module_found = 1;
1023 if ($header_skip_qt_begin_header_test == 0) {
1024 if ($qt_begin_header_found == 0) {
1025 print "WARNING: $iheader does not include QT_BEGIN_HEADER\n";
1028 if ($qt_begin_header_found && $qt_end_header_found == 0) {
1029 print "WARNING: $iheader has QT_BEGIN_HEADER but no QT_END_HEADER\n";
1033 if ($header_skip_qt_begin_namespace_test == 0) {
1034 if ($qt_begin_namespace_found == 0) {
1035 print "WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n";
1038 if ($qt_begin_namespace_found && $qt_end_namespace_found == 0) {
1039 print "WARNING: $iheader has QT_BEGIN_NAMESPACE but no QT_END_NAMESPACE\n";
1043 if ($header_skip_qt_module_test == 0) {
1044 if ($qt_module_found == 0) {
1045 print "WARNING: $iheader does not include QT_MODULE\n";