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 "QtScript" => "$basedir/src/script",
35 "QtScriptTools" => "$basedir/src/scripttools",
36 "Qt3Support" => "$basedir/src/qt3support",
37 "ActiveQt" => "$basedir/src/activeqt/container;$basedir/src/activeqt/control;$basedir/src/activeqt/shared",
38 "QtTest" => "$basedir/src/testlib",
39 "QtAssistant" => "$basedir/tools/assistant/compat/lib",
40 "QtHelp" => "$basedir/tools/assistant/lib",
41 "QtDesigner" => "$basedir/tools/designer/src/lib",
42 "QtUiTools" => "$basedir/tools/designer/src/uitools",
43 "QtDBus" => "$basedir/src/dbus",
44 "QtWebKit" => "$basedir/src/3rdparty/webkit/WebCore",
45 "phonon" => "$basedir/src/phonon",
46 "QtMultimedia" => "$basedir/src/multimedia",
48 my %moduleheaders = ( # restrict the module headers to those found in relative path
49 "QtWebKit" => "../WebKit/qt/Api",
50 "phonon" => "../3rdparty/phonon/phonon",
53 #$modules{"QtCore"} .= ";$basedir/mkspecs/" . $ENV{"MKSPEC"} if defined $ENV{"MKSPEC"};
55 # global variables (modified by options)
60 my $force_relative = 0;
61 my $check_includes = 0;
64 $force_relative = 1 if ( -d
"/System/Library/Frameworks" );
65 my $out_basedir = $basedir;
66 $out_basedir =~ s
=\\=/=g
;
68 # functions ----------------------------------------------------------
70 ######################################################################
74 # Purpose: Show the usage of the script.
76 ######################################################################
80 print " -copy Copy headers instead of include-fwd(default: " . ($copy_headers ?
"yes" : "no") . ")\n";
81 print " -remove-stale Removes stale headers (default: " . ($remove_stale ?
"yes" : "no") . ")\n";
82 print " -relative Force relative symlinks (default: " . ($force_relative ?
"yes" : "no") . ")\n";
83 print " -windows Force platform to Windows (default: " . ($force_win ?
"yes" : "no") . ")\n";
84 print " -showonly Show action but not perform (default: " . ($showonly ?
"yes" : "no") . ")\n";
85 print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n";
86 print " -help This help\n";
90 ######################################################################
94 # Purpose: Check if script runs on a Unix system or not. Cygwin
95 # systems are _not_ detected as Unix systems.
96 # Returns: 1 if a unix system, else 0.
97 ######################################################################
100 if ( $force_win != 0) {
102 } elsif ( -f
"/bin/uname" ) {
104 (-f
"\\bin\\uname") && ($r = 0);
105 } elsif ( -f
"/usr/bin/uname" ) {
107 (-f
"\\usr\\bin\\uname") && ($r = 0);
110 $_ = $Config{'osname'};
111 $r = 0 if( /(ms)|(cyg)win/i );
118 return 0 if($dir =~ /^\//);
119 return 0 if(!checkUnix
() && $dir =~ /[a-zA-Z]:[\/\\]/);
123 ######################################################################
124 # Syntax: shouldMasterInclude(iheader)
125 # Params: iheader, string, filename to verify inclusion
127 # Purpose: Determines if header should be in the master include file.
128 # Returns: 0 if file contains "#pragma qt_no_master_include" or not
129 # able to open, else 1.
130 ######################################################################
131 sub shouldMasterInclude
{
133 return 0 if(basename
($iheader) =~ /_/);
134 return 0 if(basename
($iheader) =~ /qconfig/);
135 if(open(F
, "<$iheader")) {
138 return 0 if(/^\#pragma qt_no_master_include$/);
147 ######################################################################
148 # Syntax: classNames(iheader)
149 # Params: iheader, string, filename to parse for classname "symlinks"
151 # Purpose: Scans through iheader to find all classnames that should be
152 # synced into library's include structure.
153 # Returns: List of all class names in a file.
154 ######################################################################
158 if(basename
($iheader) eq "qglobal.h") {
159 push @ret, "QtGlobal";
160 } elsif(basename
($iheader) eq "qendian.h") {
161 push @ret, "QtEndian";
162 } elsif(basename
($iheader) eq "qconfig.h") {
163 push @ret, "QtConfig";
164 } elsif(basename
($iheader) eq "qplugin.h") {
165 push @ret, "QtPlugin";
166 } elsif(basename
($iheader) eq "qalgorithms.h") {
167 push @ret, "QtAlgorithms";
168 } elsif(basename
($iheader) eq "qcontainerfwd.h") {
169 push @ret, "QtContainerFwd";
170 } elsif(basename
($iheader) eq "qdebug.h") {
171 push @ret, "QtDebug";
172 } elsif(basename
($iheader) eq "qevent.h") {
173 push @ret, "QtEvents";
174 } elsif(basename
($iheader) eq "qnamespace.h") {
176 } elsif(basename
($iheader) eq "qssl.h") {
178 } elsif(basename
($iheader) eq "qtest.h") {
180 } elsif(basename
($iheader) eq "qtconcurrentmap.h") {
181 push @ret, "QtConcurrentMap"
182 } elsif(basename
($iheader) eq "qtconcurrentfilter.h") {
183 push @ret, "QtConcurrentFilter"
184 } elsif(basename
($iheader) eq "qtconcurrentrun.h") {
185 push @ret, "QtConcurrentRun"
189 if(open(F
, "<$iheader")) {
193 chop $line if ($line =~ /\r$/);
198 last unless($line =~ /\\$/);
201 return @ret if($line =~ m/^#pragma qt_sync_stop_processing/);
202 push(@ret, "$1") if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/);
206 $line =~ s
,//.*$,,; #remove c++ comments
207 $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro
208 $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro
209 $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro
210 $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro
211 $parsable .= " " . $line;
217 my $last_definition = 0;
219 for(my $i = 0; $i < length($parsable); $i++) {
221 my $character = substr($parsable, $i, 1);
222 if($character eq "/" && substr($parsable, $i+1, 1) eq "*") { #I parse like this for greedy reasons
223 for($i+=2; $i < length($parsable); $i++) {
224 my $end = substr($parsable, $i, 2);
226 $last_definition = $i+2;
231 } elsif($character eq "{") {
233 my $block_start = $i + 1;
234 BLOCK
: for($i+=1; $i < length($parsable); $i++) {
235 my $ignore = substr($parsable, $i, 1);
238 } elsif($ignore eq "}") {
240 unless($brace_depth) {
241 for(my $i2 = $i+1; $i2 < length($parsable); $i2++) {
242 my $end = substr($parsable, $i2, 1);
243 if($end eq ";" || $end ne " ") {
244 $definition = substr($parsable, $last_definition, $block_start - $last_definition) . "}";
245 $i = $i2 if($end eq ";");
246 $last_definition = $i + 1;
253 } elsif($character eq ";") {
254 $definition = substr($parsable, $last_definition, $i - $last_definition + 1);
255 $last_definition = $i + 1;
256 } elsif($character eq "}") {
257 # a naked } must be a namespace ending
258 # if it's not a namespace, it's eaten by the loop above
260 $last_definition = $i + 1;
263 if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) /
264 && substr($parsable, $i+1, 1) eq "{") {
265 push @namespaces, $1;
267 # Eat the opening { so that the condensing loop above doesn't see it
269 $last_definition = $i + 1;
273 $definition =~ s
=[\n\r]==g
;
275 if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) {
277 } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) {
279 } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) {
281 } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) {
282 push @symbols, "Q" . $1 . "Iterator";
283 push @symbols, "QMutable" . $1 . "Iterator";
288 $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces);
290 if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q
291 || $symbol =~ /^Phonon::/); # or in the Phonon namespace
298 ######################################################################
299 # Syntax: syncHeader(header, iheader, copy)
300 # Params: header, string, filename to create "symlink" for
301 # iheader, string, destination name of symlink
302 # copy, forces header to be a copy of iheader
304 # Purpose: Syncronizes header to iheader
305 # Returns: 1 if successful, else 0.
306 ######################################################################
308 my ($header, $iheader, $copy) = @_;
309 $iheader =~ s
=\\=/=g
;
311 return copyFile
($iheader, $header) if($copy);
313 unless(-e
"$header") {
314 my $header_dir = dirname
($header);
315 mkpath
$header_dir, 0777;
318 my $iheader_out = fixPaths
($iheader, $header_dir);
319 open HEADER
, ">$header" || die "Could not open $header for writing!\n";
320 print HEADER
"#include \"$iheader_out\"\n";
327 ######################################################################
328 # Syntax: fixPaths(file, dir)
329 # Params: file, string, filepath to be made relative to dir
330 # dir, string, dirpath for point of origin
332 # Purpose: file is made relative (if possible) of dir.
333 # Returns: String with the above applied conversion.
334 ######################################################################
336 my ($file, $dir) = @_;
337 $dir =~ s
=^$basedir/=$out_basedir/= if(!($basedir eq $out_basedir));
345 my $file_dir = dirname
($file);
346 if($file_dir eq ".") {
347 $file_dir = getcwd
();
348 $file_dir =~ s
=\\=/=g
;
350 $file_dir =~ s
,/cygdrive/([a
-zA
-Z
])/,$1:,g
;
355 $dir =~ s
,/cygdrive/([a
-zA
-Z
])/,$1:/,g
;
356 return basename
($file) if("$file_dir" eq "$dir");
360 for(my $i = 1; $i < length($file_dir); $i++) {
361 my $slash = index($file_dir, "/", $i);
362 last if($slash == -1);
363 my $tmp = substr($file_dir, 0, $slash);
364 last unless($dir =~ m
,^$tmp/,);
369 my $after = substr($dir, length($match_dir));
370 my $count = ($after =~ tr
,/,,);
372 for(my $i = 0; $i < $count; $i++) {
375 $ret =~ s
,^$match_dir,$dots,;
381 ######################################################################
382 # Syntax: fileContents(filename)
383 # Params: filename, string, filename of file to return contents
385 # Purpose: Get the contents of a file.
386 # Returns: String with contents of the file, or empty string if file
388 # Warning: Dies if it does exist but script cannot get read access.
389 ######################################################################
392 my $filecontents = "";
394 open(I
, "< $filename") || die "Could not open $filename for reading, read block?";
400 return $filecontents;
403 ######################################################################
404 # Syntax: fileCompare(file1, file2)
405 # Params: file1, string, filename of first file
406 # file2, string, filename of second file
408 # Purpose: Determines if files are equal, and which one is newer.
409 # Returns: 0 if files are equal no matter the timestamp, -1 if file1
410 # is newer, 1 if file2 is newer.
411 ######################################################################
413 my ($file1, $file2) = @_;
414 my $file1contents = fileContents
($file1);
415 my $file2contents = fileContents
($file2);
416 if (! -e
$file1) { return 1; }
417 if (! -e
$file2) { return -1; }
418 return $file1contents ne $file2contents ?
(stat("$file2"))[9] <=> (stat("$file1"))[9] : 0;
421 ######################################################################
422 # Syntax: copyFile(file, ifile)
423 # Params: file, string, filename to create duplicate for
424 # ifile, string, destination name of duplicate
426 # Purpose: Keeps files in sync so changes in the newer file will be
427 # written to the other.
428 # Returns: 1 if files were synced, else 0.
429 # Warning: Dies if script cannot get write access.
430 ######################################################################
433 my ($file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_;
434 # Bi-directional synchronization
435 open( I
, "< " . $file ) || die "Could not open $file for reading";
440 if ( open(I
, "< " . $ifile) ) {
443 $ifilecontents = <I
>;
445 $copy = fileCompare
($file, $ifile);
452 if ( $knowdiff || ($filecontents ne $ifilecontents) ) {
454 my $file_dir = dirname
($file);
455 mkpath
$file_dir, 0777 unless(-e
"$file_dir");
456 open(O
, "> " . $file) || die "Could not open $file for writing (no write permission?)";
459 print O
$ifilecontents;
462 } elsif ( $copy < 0 ) {
463 my $ifile_dir = dirname
($ifile);
464 mkpath
$ifile_dir, 0777 unless(-e
"$ifile_dir");
465 open(O
, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)";
468 print O
$filecontents;
476 ######################################################################
477 # Syntax: symlinkFile(file, ifile)
478 # Params: file, string, filename to create "symlink" for
479 # ifile, string, destination name of symlink
481 # Purpose: File is symlinked to ifile (or copied if filesystem doesn't
483 # Returns: 1 on success, else 0.
484 ######################################################################
487 my ($file,$ifile) = @_;
490 print "symlink created for $file ";
491 if ( $force_relative && ($ifile =~ /^$basedir/)) {
495 $t =~ s
-^$basedir/--;
496 $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 );
497 $file =~ s
-^$basedir/-$p-;
501 return symlink($file, $ifile);
503 return copyFile
($file, $ifile);
506 ######################################################################
507 # Syntax: findFiles(dir, match, descend)
508 # Params: dir, string, directory to search for name
509 # match, string, regular expression to match in dir
510 # descend, integer, 0 = non-recursive search
511 # 1 = recurse search into subdirectories
513 # Purpose: Finds files matching a regular expression.
514 # Returns: List of matching files.
517 # findFiles("/usr","\.cpp$",1) - finds .cpp files in /usr and below
518 # findFiles("/tmp","^#",0) - finds #* files in /tmp
519 ######################################################################
521 my ($dir,$match,$descend) = @_;
522 my ($file,$p,@files);
525 ($dir eq "") && ($dir = ".");
526 if ( opendir(D
,$dir) ) {
530 ($dir =~ /\/$/) || ($dir .= "/");
532 foreach $file ( sort readdir(D) ) {
533 next if ( $file =~ /^\.\.?$/ );
535 ($file =~ /$match/) && (push @files, $p);
536 if ( $descend && -d $p && ! -l $p ) {
537 push @files, &findFiles($p,$match,$descend);
545 # --------------------------------------------------------------------
547 # --------------------------------------------------------------------
554 my $arg = shift @ARGV;
555 if ("$arg" eq "-h
" || "$arg" eq "-help
" || "$arg" eq "?
") {
558 } elsif("$arg" eq "-copy
") {
561 } elsif("$arg" eq "-o
" || "$arg" eq "-outdir
") {
564 } elsif("$arg" eq "-showonly
" || "$arg" eq "-remove
-stale
" || "$arg" eq "-windows
" ||
565 "$arg" eq "-relative
" || "$arg" eq "-check
-includes
") {
566 $var = substr($arg, 1);
568 } elsif("$arg" =~ /^-no-(.*)$/) {
571 #these are for commandline compat
572 } elsif("$arg" eq "-inc
") {
575 } elsif("$arg" eq "-module
") {
578 } elsif("$arg" eq "-show
") {
581 } elsif("$arg" eq '*') {
582 # workaround for windows 9x where "%*" expands to "*"
587 if(!$var || "$var" eq "show_help
") {
588 print "Unknown option
: $arg\n\n" if(!$var);
590 } elsif ("$var" eq "copy
") {
591 if("$val" eq "yes
") {
596 } elsif ("$var" eq "showonly
") {
597 if("$val" eq "yes
") {
602 } elsif ("$var" eq "check
-includes
") {
603 if("$val" eq "yes
") {
605 } elsif($check_includes) {
608 } elsif ("$var" eq "remove
-stale
") {
609 if("$val" eq "yes
") {
611 } elsif($remove_stale) {
614 } elsif ("$var" eq "windows
") {
615 if("$val" eq "yes
") {
617 } elsif($force_win) {
620 } elsif ("$var" eq "relative
") {
621 if("$val" eq "yes
") {
623 } elsif($force_relative) {
626 } elsif ("$var" eq "module
") {
627 print "module
:$val:\n";
628 die "No such module
: $val" unless(defined $modules{$val});
629 push @modules_to_sync, $val;
630 } elsif ("$var" eq "output
") {
632 if(checkRelative($outdir)) {
633 $out_basedir = getcwd();
635 $out_basedir .= "/" . $outdir;
637 $out_basedir = $outdir;
640 $out_basedir =~ s=\\=/=g;
643 @modules_to_sync = keys(%modules) if($#modules_to_sync == -1);
645 $isunix = checkUnix; #cache checkUnix
648 mkpath "$out_basedir/include
", 0777;
650 my @ignore_headers = ();
651 my $class_lib_map_contents = "";
652 my @ignore_for_master_contents = ( "qt
.h
", "qpaintdevicedefs
.h
" );
653 my @ignore_for_include_check = ( "qatomic
.h
" );
654 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
" );
655 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
" );
656 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
}" );
658 foreach (@modules_to_sync) {
661 my $dir = "$modules{$lib}";
662 my $pathtoheaders = "";
663 $pathtoheaders = "$moduleheaders{$lib}" if ($moduleheaders{$lib});
665 #information used after the syncing
666 my $pri_install_classes = "";
667 my $pri_install_files = "";
669 my $libcapitals = $lib;
670 $libcapitals =~ y/a-z/A-Z/;
671 my $master_contents = "#ifndef QT_".$libcapitals."_MODULE_H\n#define QT_".$libcapitals."_MODULE_H\n";
674 if(-e
"$dir/" . basename
($dir) . ".pro") {
675 if(open(F
, "<$dir/" . basename
($dir) . ".pro")) {
679 if($line =~ /^ *QT *\+?= *([^\r\n]*)/) {
680 foreach(split(/ /, "$1")) {
681 $master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core");
682 $master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui");
683 $master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network");
684 $master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg");
685 $master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script");
686 $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools");
687 $master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support");
688 $master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql");
689 $master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml");
690 $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns");
691 $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl");
692 $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg");
700 #remove the old files
702 my @subdirs = ("$out_basedir/include/$lib");
705 if (opendir DIR
, "$subdir") {
706 while(my $t = readdir(DIR
)) {
707 my $file = "$subdir/$t";
709 push @subdirs, "$file" unless($t eq "." || $t eq "..");
711 my @files = ("$file");
712 #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t");
716 if(open(F
, "<$file")) {
720 if($line =~ /^\#include \"([^\"]*)\"$/) {
722 $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/");
723 $remove_file = 1 unless(-e
"$include");
730 unlink "$file" if($remove_file);
742 foreach (split(/;/, $dir)) {
743 my $current_dir = "$_";
744 my $headers_dir = $current_dir;
745 $headers_dir .= "/$pathtoheaders" if ($pathtoheaders);
747 my @subdirs = ($headers_dir);
750 opendir DIR
, "$subdir" or next;
751 while(my $t = readdir(DIR
)) {
752 push @subdirs, "$subdir/$t" if(-d
"$subdir/$t" && !($t eq ".") &&
753 !($t eq "..") && !($t eq ".obj") &&
754 !($t eq ".moc") && !($t eq ".rcc") &&
755 !($t eq ".uic") && !($t eq "build"));
760 #calc files and "copy" them
763 my @headers = findFiles
("$subdir", "^[-a-z0-9_]*\\.h\$" , 0);
766 $header = 0 if("$header" =~ /^ui_.*.h/);
767 foreach (@ignore_headers) {
768 $header = 0 if("$header" eq "$_");
771 my $header_copies = 0;
772 #figure out if it is a public header
773 my $public_header = $header;
774 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
777 foreach (@ignore_for_master_contents) {
778 $public_header = 0 if("$header" eq "$_");
782 my $iheader = $subdir . "/" . $header;
783 my @classes = $public_header ? classNames
($iheader) : ();
785 print "$header [$lib]\n";
787 print "SYMBOL: $_\n";
790 #find out all the places it goes..
792 if ($public_header) {
793 @headers = ( "$out_basedir/include/$lib/$header" );
794 push @headers, "$out_basedir/include/Qt/$header"
795 if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src
/);
798 my $header_base = basename
($header);
800 if ($class =~ m/::/) {
803 $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n";
804 $header_copies++ if(syncHeader
("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0));
807 @headers = ( "$out_basedir/include/$lib/private/$header" );
808 push @headers, "$out_basedir/include/Qt/private/$header"
809 if ("$lib" ne "phonon");
811 foreach(@headers) { #sync them
812 $header_copies++ if(syncHeader
($_, $iheader, $copy_headers));
816 #put it into the master file
817 $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude
($iheader));
819 #deal with the install directives
821 my $pri_install_iheader = fixPaths
($iheader, $current_dir);
824 if ($class =~ m/::/) {
827 my $class_header = fixPaths
("$out_basedir/include/$lib/$class",
829 $pri_install_classes .= $class_header
830 unless($pri_install_classes =~ $class_header);
832 $pri_install_files.= "$pri_install_iheader ";;
836 print "header created for $iheader ($header_copies)\n" if($header_copies > 0);
842 # close the master include:
843 $master_contents .= "#endif\n";
847 if ($lib eq "phonon") {
848 push @master_includes, "$out_basedir/include/phonon_compat/phonon/phonon";
849 push @master_includes, "$out_basedir/include/phonon/Phonon/Phonon";
851 push @master_includes, "$out_basedir/include/$lib/$lib";
853 foreach my $master_include (@master_includes) {
854 #generate the "master" include file
855 $pri_install_files .= fixPaths
($master_include, "$modules{$lib}") . " "; #get the master file installed too
856 if($master_include && -e
"$master_include") {
857 open MASTERINCLUDE
, "<$master_include";
859 binmode MASTERINCLUDE
;
860 my $oldmaster = <MASTERINCLUDE
>;
862 $oldmaster =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
863 $master_include = 0 if($oldmaster eq $master_contents);
865 if($master_include && $master_contents) {
866 my $master_dir = dirname
($master_include);
867 mkpath
$master_dir, 0777;
868 print "header (master) created for $lib\n";
869 open MASTERINCLUDE
, ">$master_include";
870 print MASTERINCLUDE
"$master_contents";
875 #handle the headers.pri for each module
876 my $headers_pri_contents = "";
877 $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n";
878 $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n";
879 my $headers_pri_file = "$out_basedir/include/$lib/headers.pri";
880 if(-e
"$headers_pri_file") {
881 open HEADERS_PRI_FILE
, "<$headers_pri_file";
883 binmode HEADERS_PRI_FILE
;
884 my $old_headers_pri_contents = <HEADERS_PRI_FILE
>;
885 close HEADERS_PRI_FILE
;
886 $old_headers_pri_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
887 $headers_pri_file = 0 if($old_headers_pri_contents eq $headers_pri_contents);
889 if($headers_pri_file && $master_contents) {
890 my $headers_pri_dir = dirname
($headers_pri_file);
891 mkpath
$headers_pri_dir, 0777;
892 print "headers.pri file created for $lib\n";
893 open HEADERS_PRI_FILE
, ">$headers_pri_file";
894 print HEADERS_PRI_FILE
"$headers_pri_contents";
895 close HEADERS_PRI_FILE
;
900 my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h";
901 if(-e
"$class_lib_map") {
902 open CLASS_LIB_MAP
, "<$class_lib_map";
904 binmode CLASS_LIB_MAP
;
905 my $old_class_lib_map_contents = <CLASS_LIB_MAP
>;
907 $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
908 $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents);
911 my $class_lib_map_dir = dirname
($class_lib_map);
912 mkpath
$class_lib_map_dir, 0777;
913 open CLASS_LIB_MAP
, ">$class_lib_map";
914 print CLASS_LIB_MAP
"$class_lib_map_contents";
919 if($check_includes) {
920 for (keys(%modules)) {
923 my $dir = "$modules{$lib}";
924 foreach (split(/;/, $dir)) {
925 my $current_dir = "$_";
927 my @subdirs = ($current_dir);
930 opendir DIR
, "$subdir";
931 while(my $t = readdir(DIR
)) {
932 push @subdirs, "$subdir/$t" if(-d
"$subdir/$t" && !($t eq ".") &&
933 !($t eq "..") && !($t eq ".obj") &&
934 !($t eq ".moc") && !($t eq ".rcc") &&
935 !($t eq ".uic") && !($t eq "build"));
942 my $header_skip_qt_module_test = 0;
943 foreach(@ignore_for_qt_module_check) {
944 foreach (split(/;/, $_)) {
945 $header_skip_qt_module_test = 1 if ("$subdir" =~ /^$_/);
948 my @headers = findFiles
("$subdir", "^[-a-z0-9_]*\\.h\$" , 0);
951 my $header_skip_qt_begin_header_test = 0;
952 my $header_skip_qt_begin_namespace_test = 0;
953 $header = 0 if("$header" =~ /^ui_.*.h/);
954 foreach (@ignore_headers) {
955 $header = 0 if("$header" eq "$_");
958 my $public_header = $header;
959 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
962 foreach (@ignore_for_master_contents) {
963 $public_header = 0 if("$header" eq "$_");
966 foreach (@ignore_for_include_check) {
967 $public_header = 0 if("$header" eq "$_");
969 foreach(@ignore_for_qt_begin_header_check) {
970 $header_skip_qt_begin_header_test = 1 if ("$header" eq "$_");
972 foreach(@ignore_for_qt_begin_namespace_check) {
973 $header_skip_qt_begin_namespace_test = 1 if ("$header" eq "$_");
978 my $iheader = $subdir . "/" . $header;
980 if(open(F
, "<$iheader")) {
981 my $qt_module_found = 0;
982 my $qt_begin_header_found = 0;
983 my $qt_end_header_found = 0;
984 my $qt_begin_namespace_found = 0;
985 my $qt_end_namespace_found = 0;
990 if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) {
992 } elsif($line =~ /^ *\# *include/) {
994 if($line =~ /<.*>/) {
995 $include =~ s
,.*<(.*)>.*,$1,;
996 } elsif($line =~ /".*"/) {
997 $include =~ s
,.*"(.*)".*,$1,;
1002 for (keys(%modules)) {
1004 if(-e
"$out_basedir/include/$trylib/$include") {
1005 print "WARNING: $iheader includes $include when it should include $trylib/$include\n";
1009 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) {
1010 $qt_begin_header_found = 1;
1011 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) {
1012 $qt_end_header_found = 1;
1013 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) {
1014 $qt_begin_namespace_found = 1;
1015 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) {
1016 $qt_end_namespace_found = 1;
1017 } elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) {
1018 $qt_module_found = 1;
1021 if ($header_skip_qt_begin_header_test == 0) {
1022 if ($qt_begin_header_found == 0) {
1023 print "WARNING: $iheader does not include QT_BEGIN_HEADER\n";
1026 if ($qt_begin_header_found && $qt_end_header_found == 0) {
1027 print "WARNING: $iheader has QT_BEGIN_HEADER but no QT_END_HEADER\n";
1031 if ($header_skip_qt_begin_namespace_test == 0) {
1032 if ($qt_begin_namespace_found == 0) {
1033 print "WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n";
1036 if ($qt_begin_namespace_found && $qt_end_namespace_found == 0) {
1037 print "WARNING: $iheader has QT_BEGIN_NAMESPACE but no QT_END_NAMESPACE\n";
1041 if ($header_skip_qt_module_test == 0) {
1042 if ($qt_module_found == 0) {
1043 print "WARNING: $iheader does not include QT_MODULE\n";