2 ######################################################################
4 # Synchronizes Qt header files - internal development tool.
6 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 # Contact: Nokia Corporation (qt-info@nokia.com)
9 ######################################################################
11 # use packages -------------------------------------------------------
18 for (my $i = 0; $i < $#ARGV; $i++) {
19 if ($ARGV[$i] eq "-base-dir" && $i < $#ARGV - 1) {
20 $ENV{"QTDIR"} = $ARGV[$i + 1];
25 die "syncqt: QTDIR not defined" if ! $ENV{"QTDIR"}; # sanity check
29 my $basedir = $ENV{"QTDIR"};
31 my %modules = ( # path to module name map
32 "QtGui" => "$basedir/src/gui",
33 "QtOpenGL" => "$basedir/src/opengl",
34 "QtOpenVG" => "$basedir/src/openvg",
35 "QtCore" => "$basedir/src/corelib",
36 "QtXml" => "$basedir/src/xml",
37 "QtXmlPatterns" => "$basedir/src/xmlpatterns",
38 "QtSql" => "$basedir/src/sql",
39 "QtNetwork" => "$basedir/src/network",
40 "QtSvg" => "$basedir/src/svg",
41 "QtDeclarative" => "$basedir/src/declarative",
42 "QtScript" => "$basedir/src/script",
43 "QtScriptTools" => "$basedir/src/scripttools",
44 "Qt3Support" => "$basedir/src/qt3support",
45 "ActiveQt" => "$basedir/src/activeqt/container;$basedir/src/activeqt/control;$basedir/src/activeqt/shared",
46 "QtTest" => "$basedir/src/testlib",
47 "QtHelp" => "$basedir/tools/assistant/lib",
48 "QtDesigner" => "$basedir/tools/designer/src/lib",
49 "QtUiTools" => "$basedir/tools/designer/src/uitools",
50 "QtDBus" => "$basedir/src/dbus",
51 "QtWebKit" => "$basedir/src/3rdparty/webkit/WebCore",
52 "phonon" => "$basedir/src/phonon",
53 "QtMultimedia" => "$basedir/src/multimedia",
55 my %moduleheaders = ( # restrict the module headers to those found in relative path
56 "QtWebKit" => "../WebKit/qt/Api",
57 "phonon" => "../3rdparty/phonon/phonon",
60 #$modules{"QtCore"} .= ";$basedir/mkspecs/" . $ENV{"MKSPEC"} if defined $ENV{"MKSPEC"};
62 # global variables (modified by options)
67 my $force_relative = 0;
68 my $check_includes = 0;
70 my $create_uic_class_map = 1;
71 my $create_private_headers = 1;
73 $force_relative = 1 if ( -d
"/System/Library/Frameworks" );
74 my $out_basedir = $basedir;
75 $out_basedir =~ s
=\\=/=g
;
77 # functions ----------------------------------------------------------
79 ######################################################################
83 # Purpose: Show the usage of the script.
85 ######################################################################
89 print " -copy Copy headers instead of include-fwd(default: " . ($copy_headers ?
"yes" : "no") . ")\n";
90 print " -remove-stale Removes stale headers (default: " . ($remove_stale ?
"yes" : "no") . ")\n";
91 print " -relative Force relative symlinks (default: " . ($force_relative ?
"yes" : "no") . ")\n";
92 print " -windows Force platform to Windows (default: " . ($force_win ?
"yes" : "no") . ")\n";
93 print " -showonly Show action but not perform (default: " . ($showonly ?
"yes" : "no") . ")\n";
94 print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n";
95 print " -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR> Create headers for <NAME> with original headers in <HEADERDIR> relative to <PROFILEDIR> \n";
96 print " -help This help\n";
100 ######################################################################
101 # Syntax: checkUnix()
104 # Purpose: Check if script runs on a Unix system or not. Cygwin
105 # systems are _not_ detected as Unix systems.
106 # Returns: 1 if a unix system, else 0.
107 ######################################################################
110 if ( $force_win != 0) {
112 } elsif ( -f
"/bin/uname" ) {
114 (-f
"\\bin\\uname") && ($r = 0);
115 } elsif ( -f
"/usr/bin/uname" ) {
117 (-f
"\\usr\\bin\\uname") && ($r = 0);
120 $_ = $Config{'osname'};
121 $r = 0 if( /(ms)|(cyg)win/i );
128 return 0 if($dir =~ /^\//);
129 return 0 if(!checkUnix
() && $dir =~ /[a-zA-Z]:[\/\\]/);
133 ######################################################################
134 # Syntax: shouldMasterInclude(iheader)
135 # Params: iheader, string, filename to verify inclusion
137 # Purpose: Determines if header should be in the master include file.
138 # Returns: 0 if file contains "#pragma qt_no_master_include" or not
139 # able to open, else 1.
140 ######################################################################
141 sub shouldMasterInclude
{
143 return 0 if(basename
($iheader) =~ /_/);
144 return 0 if(basename
($iheader) =~ /qconfig/);
145 if(open(F
, "<$iheader")) {
148 return 0 if(/^\#pragma qt_no_master_include$/);
157 ######################################################################
158 # Syntax: classNames(iheader)
159 # Params: iheader, string, filename to parse for classname "symlinks"
161 # Purpose: Scans through iheader to find all classnames that should be
162 # synced into library's include structure.
163 # Returns: List of all class names in a file.
164 ######################################################################
168 if(basename
($iheader) eq "qglobal.h") {
169 push @ret, "QtGlobal";
170 } elsif(basename
($iheader) eq "qendian.h") {
171 push @ret, "QtEndian";
172 } elsif(basename
($iheader) eq "qconfig.h") {
173 push @ret, "QtConfig";
174 } elsif(basename
($iheader) eq "qplugin.h") {
175 push @ret, "QtPlugin";
176 } elsif(basename
($iheader) eq "qalgorithms.h") {
177 push @ret, "QtAlgorithms";
178 } elsif(basename
($iheader) eq "qcontainerfwd.h") {
179 push @ret, "QtContainerFwd";
180 } elsif(basename
($iheader) eq "qdebug.h") {
181 push @ret, "QtDebug";
182 } elsif(basename
($iheader) eq "qevent.h") {
183 push @ret, "QtEvents";
184 } elsif(basename
($iheader) eq "qnamespace.h") {
186 } elsif(basename
($iheader) eq "qssl.h") {
188 } elsif(basename
($iheader) eq "qtest.h") {
190 } elsif(basename
($iheader) eq "qtconcurrentmap.h") {
191 push @ret, "QtConcurrentMap"
192 } elsif(basename
($iheader) eq "qtconcurrentfilter.h") {
193 push @ret, "QtConcurrentFilter"
194 } elsif(basename
($iheader) eq "qtconcurrentrun.h") {
195 push @ret, "QtConcurrentRun"
199 if(open(F
, "<$iheader")) {
203 chop $line if ($line =~ /\r$/);
208 last unless($line =~ /\\$/);
211 return @ret if($line =~ m/^#pragma qt_sync_stop_processing/);
212 push(@ret, "$1") if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/);
216 $line =~ s
,//.*$,,; #remove c++ comments
217 $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro
218 $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro
219 $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro
220 $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro
221 $parsable .= " " . $line;
227 my $last_definition = 0;
229 for(my $i = 0; $i < length($parsable); $i++) {
231 my $character = substr($parsable, $i, 1);
232 if($character eq "/" && substr($parsable, $i+1, 1) eq "*") { #I parse like this for greedy reasons
233 for($i+=2; $i < length($parsable); $i++) {
234 my $end = substr($parsable, $i, 2);
236 $last_definition = $i+2;
241 } elsif($character eq "{") {
243 my $block_start = $i + 1;
244 BLOCK
: for($i+=1; $i < length($parsable); $i++) {
245 my $ignore = substr($parsable, $i, 1);
248 } elsif($ignore eq "}") {
250 unless($brace_depth) {
251 for(my $i2 = $i+1; $i2 < length($parsable); $i2++) {
252 my $end = substr($parsable, $i2, 1);
253 if($end eq ";" || $end ne " ") {
254 $definition = substr($parsable, $last_definition, $block_start - $last_definition) . "}";
255 $i = $i2 if($end eq ";");
256 $last_definition = $i + 1;
263 } elsif($character eq ";") {
264 $definition = substr($parsable, $last_definition, $i - $last_definition + 1);
265 $last_definition = $i + 1;
266 } elsif($character eq "}") {
267 # a naked } must be a namespace ending
268 # if it's not a namespace, it's eaten by the loop above
270 $last_definition = $i + 1;
273 if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) /
274 && substr($parsable, $i+1, 1) eq "{") {
275 push @namespaces, $1;
277 # Eat the opening { so that the condensing loop above doesn't see it
279 $last_definition = $i + 1;
283 $definition =~ s
=[\n\r]==g
;
285 if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) {
287 } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) {
289 } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) {
291 } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) {
292 push @symbols, "Q" . $1 . "Iterator";
293 push @symbols, "QMutable" . $1 . "Iterator";
298 $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces);
300 if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q
301 || $symbol =~ /^Phonon::/); # or in the Phonon namespace
308 ######################################################################
309 # Syntax: syncHeader(header, iheader, copy)
310 # Params: header, string, filename to create "symlink" for
311 # iheader, string, destination name of symlink
312 # copy, forces header to be a copy of iheader
314 # Purpose: Syncronizes header to iheader
315 # Returns: 1 if successful, else 0.
316 ######################################################################
318 my ($header, $iheader, $copy) = @_;
319 $iheader =~ s
=\\=/=g
;
321 return copyFile
($iheader, $header) if($copy);
323 unless(-e
"$header") {
324 my $header_dir = dirname
($header);
325 mkpath
$header_dir, 0777;
328 my $iheader_out = fixPaths
($iheader, $header_dir);
329 open HEADER
, ">$header" || die "Could not open $header for writing!\n";
330 print HEADER
"#include \"$iheader_out\"\n";
337 ######################################################################
338 # Syntax: fixPaths(file, dir)
339 # Params: file, string, filepath to be made relative to dir
340 # dir, string, dirpath for point of origin
342 # Purpose: file is made relative (if possible) of dir.
343 # Returns: String with the above applied conversion.
344 ######################################################################
346 my ($file, $dir) = @_;
347 $dir =~ s
=^$basedir/=$out_basedir/= if(!($basedir eq $out_basedir));
355 my $file_dir = dirname
($file);
356 if($file_dir eq ".") {
357 $file_dir = getcwd
();
358 $file_dir =~ s
=\\=/=g
;
360 $file_dir =~ s
,/cygdrive/([a
-zA
-Z
])/,$1:,g
;
365 $dir =~ s
,/cygdrive/([a
-zA
-Z
])/,$1:/,g
;
366 return basename
($file) if("$file_dir" eq "$dir");
370 for(my $i = 1; $i < length($file_dir); $i++) {
371 my $slash = index($file_dir, "/", $i);
372 last if($slash == -1);
373 my $tmp = substr($file_dir, 0, $slash);
374 last unless($dir =~ m
,^$tmp/,);
379 my $after = substr($dir, length($match_dir));
380 my $count = ($after =~ tr
,/,,);
382 for(my $i = 0; $i < $count; $i++) {
385 $ret =~ s
,^$match_dir,$dots,;
391 ######################################################################
392 # Syntax: fileContents(filename)
393 # Params: filename, string, filename of file to return contents
395 # Purpose: Get the contents of a file.
396 # Returns: String with contents of the file, or empty string if file
398 # Warning: Dies if it does exist but script cannot get read access.
399 ######################################################################
402 my $filecontents = "";
404 open(I
, "< $filename") || die "Could not open $filename for reading, read block?";
410 return $filecontents;
413 ######################################################################
414 # Syntax: fileCompare(file1, file2)
415 # Params: file1, string, filename of first file
416 # file2, string, filename of second file
418 # Purpose: Determines if files are equal, and which one is newer.
419 # Returns: 0 if files are equal no matter the timestamp, -1 if file1
420 # is newer, 1 if file2 is newer.
421 ######################################################################
423 my ($file1, $file2) = @_;
424 my $file1contents = fileContents
($file1);
425 my $file2contents = fileContents
($file2);
426 if (! -e
$file1) { return 1; }
427 if (! -e
$file2) { return -1; }
428 return $file1contents ne $file2contents ?
(stat("$file2"))[9] <=> (stat("$file1"))[9] : 0;
431 ######################################################################
432 # Syntax: copyFile(file, ifile)
433 # Params: file, string, filename to create duplicate for
434 # ifile, string, destination name of duplicate
436 # Purpose: Keeps files in sync so changes in the newer file will be
437 # written to the other.
438 # Returns: 1 if files were synced, else 0.
439 # Warning: Dies if script cannot get write access.
440 ######################################################################
443 my ($file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_;
444 # Bi-directional synchronization
445 open( I
, "< " . $file ) || die "Could not open $file for reading";
450 if ( open(I
, "< " . $ifile) ) {
453 $ifilecontents = <I
>;
455 $copy = fileCompare
($file, $ifile);
462 if ( $knowdiff || ($filecontents ne $ifilecontents) ) {
464 my $file_dir = dirname
($file);
465 mkpath
$file_dir, 0777 unless(-e
"$file_dir");
466 open(O
, "> " . $file) || die "Could not open $file for writing (no write permission?)";
469 print O
$ifilecontents;
472 } elsif ( $copy < 0 ) {
473 my $ifile_dir = dirname
($ifile);
474 mkpath
$ifile_dir, 0777 unless(-e
"$ifile_dir");
475 open(O
, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)";
478 print O
$filecontents;
486 ######################################################################
487 # Syntax: symlinkFile(file, ifile)
488 # Params: file, string, filename to create "symlink" for
489 # ifile, string, destination name of symlink
491 # Purpose: File is symlinked to ifile (or copied if filesystem doesn't
493 # Returns: 1 on success, else 0.
494 ######################################################################
497 my ($file,$ifile) = @_;
500 print "symlink created for $file ";
501 if ( $force_relative && ($ifile =~ /^$basedir/)) {
505 $t =~ s
-^$basedir/--;
506 $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 );
507 $file =~ s
-^$basedir/-$p-;
511 return symlink($file, $ifile);
513 return copyFile
($file, $ifile);
516 ######################################################################
517 # Syntax: findFiles(dir, match, descend)
518 # Params: dir, string, directory to search for name
519 # match, string, regular expression to match in dir
520 # descend, integer, 0 = non-recursive search
521 # 1 = recurse search into subdirectories
523 # Purpose: Finds files matching a regular expression.
524 # Returns: List of matching files.
527 # findFiles("/usr","\.cpp$",1) - finds .cpp files in /usr and below
528 # findFiles("/tmp","^#",0) - finds #* files in /tmp
529 ######################################################################
531 my ($dir,$match,$descend) = @_;
532 my ($file,$p,@files);
535 ($dir eq "") && ($dir = ".");
536 if ( opendir(D
,$dir) ) {
540 ($dir =~ /\/$/) || ($dir .= "/");
542 foreach $file ( sort readdir(D) ) {
543 next if ( $file =~ /^\.\.?$/ );
545 ($file =~ /$match/) && (push @files, $p);
546 if ( $descend && -d $p && ! -l $p ) {
547 push @files, &findFiles($p,$match,$descend);
555 # --------------------------------------------------------------------
557 # --------------------------------------------------------------------
564 my $arg = shift @ARGV;
565 if ("$arg" eq "-h
" || "$arg" eq "-help
" || "$arg" eq "?
") {
568 } elsif("$arg" eq "-copy
") {
571 } elsif("$arg" eq "-o
" || "$arg" eq "-outdir
") {
574 } elsif("$arg" eq "-showonly
" || "$arg" eq "-remove
-stale
" || "$arg" eq "-windows
" ||
575 "$arg" eq "-relative
" || "$arg" eq "-check
-includes
") {
576 $var = substr($arg, 1);
578 } elsif("$arg" =~ /^-no-(.*)$/) {
581 #these are for commandline compat
582 } elsif("$arg" eq "-inc
") {
585 } elsif("$arg" eq "-module
") {
588 } elsif("$arg" eq "-separate
-module
") {
589 $var = "separate
-module
";
591 } elsif("$arg" eq "-show
") {
594 } elsif("$arg" eq "-base
-dir
") {
595 # skip, it's been dealt with at the top of the file
601 if(!$var || "$var" eq "show_help
") {
602 print "Unknown option
: $arg\n\n" if(!$var);
604 } elsif ("$var" eq "copy
") {
605 if("$val" eq "yes
") {
610 } elsif ("$var" eq "showonly
") {
611 if("$val" eq "yes
") {
616 } elsif ("$var" eq "check
-includes
") {
617 if("$val" eq "yes
") {
619 } elsif($check_includes) {
622 } elsif ("$var" eq "remove
-stale
") {
623 if("$val" eq "yes
") {
625 } elsif($remove_stale) {
628 } elsif ("$var" eq "windows
") {
629 if("$val" eq "yes
") {
631 } elsif($force_win) {
634 } elsif ("$var" eq "relative
") {
635 if("$val" eq "yes
") {
637 } elsif($force_relative) {
640 } elsif ("$var" eq "module
") {
641 print "module
:$val:\n";
642 die "No such module
: $val" unless(defined $modules{$val});
643 push @modules_to_sync, $val;
644 } elsif ("$var" eq "separate
-module
") {
645 my ($module, $prodir, $headerdir) = split(/:/, $val);
646 $modules{$module} = $prodir;
647 push @modules_to_sync, $module;
648 $moduleheaders{$module} = $headerdir;
649 $create_uic_class_map = 0;
650 $create_private_headers = 0;
651 } elsif ("$var" eq "output
") {
653 if(checkRelative($outdir)) {
654 $out_basedir = getcwd();
656 $out_basedir .= "/" . $outdir;
658 $out_basedir = $outdir;
661 $out_basedir =~ s=\\=/=g;
664 @modules_to_sync = keys(%modules) if($#modules_to_sync == -1);
666 $isunix = checkUnix; #cache checkUnix
669 mkpath "$out_basedir/include
", 0777;
671 my @ignore_headers = ();
672 my $class_lib_map_contents = "";
673 my @ignore_for_master_contents = ( "qt
.h
", "qpaintdevicedefs
.h
" );
674 my @ignore_for_include_check = ( "qatomic
.h
" );
675 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
" );
676 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
" );
677 my @ignore_for_qt_module_check = ( "$modules{QtCore
}/arch", "$modules{QtCore}/global
", "$modules{QtSql
}/drivers
", "$modules{QtTest
}", "$modules{QtDesigner
}", "$modules{QtUiTools
}", "$modules{QtDBus
}", "$modules{phonon
}" );
679 foreach (@modules_to_sync) {
682 my $dir = "$modules{$lib}";
683 my $pathtoheaders = "";
684 $pathtoheaders = "$moduleheaders{$lib}" if ($moduleheaders{$lib});
686 #information used after the syncing
687 my $pri_install_classes = "";
688 my $pri_install_files = "";
689 my $pri_install_pfiles = "";
691 my $libcapitals = $lib;
692 $libcapitals =~ y/a-z/A-Z/;
693 my $master_contents = "#ifndef QT_".$libcapitals."_MODULE_H\n#define QT_".$libcapitals."_MODULE_H\n";
696 if(-e
"$dir/" . basename
($dir) . ".pro") {
697 if(open(F
, "<$dir/" . basename
($dir) . ".pro")) {
701 if($line =~ /^ *QT *\+?= *([^\r\n]*)/) {
702 foreach(split(/ /, "$1")) {
703 $master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core");
704 $master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui");
705 $master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network");
706 $master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg");
707 $master_contents .= "#include <QtDeclarative/QtDeclarative>\n" if("$_" eq "declarative");
708 $master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script");
709 $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools");
710 $master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support");
711 $master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql");
712 $master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml");
713 $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns");
714 $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl");
715 $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg");
723 #remove the old files
725 my @subdirs = ("$out_basedir/include/$lib");
728 if (opendir DIR
, "$subdir") {
729 while(my $t = readdir(DIR
)) {
730 my $file = "$subdir/$t";
732 push @subdirs, "$file" unless($t eq "." || $t eq "..");
734 my @files = ("$file");
735 #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t");
739 if(open(F
, "<$file")) {
743 if($line =~ /^\#include \"([^\"]*)\"$/) {
745 $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/");
746 $remove_file = 1 unless(-e
"$include");
753 unlink "$file" if($remove_file);
765 foreach (split(/;/, $dir)) {
766 my $current_dir = "$_";
767 my $headers_dir = $current_dir;
768 $headers_dir .= "/$pathtoheaders" if ($pathtoheaders);
770 my @subdirs = ($headers_dir);
773 opendir DIR
, "$subdir" or next;
774 while(my $t = readdir(DIR
)) {
775 push @subdirs, "$subdir/$t" if(-d
"$subdir/$t" && !($t eq ".") &&
776 !($t eq "..") && !($t eq ".obj") &&
777 !($t eq ".moc") && !($t eq ".rcc") &&
778 !($t eq ".uic") && !($t eq "build"));
783 #calc files and "copy" them
786 my @headers = findFiles
("$subdir", "^[-a-z0-9_]*\\.h\$" , 0);
789 $header = 0 if("$header" =~ /^ui_.*.h/);
790 foreach (@ignore_headers) {
791 $header = 0 if("$header" eq "$_");
794 my $header_copies = 0;
795 #figure out if it is a public header
796 my $public_header = $header;
797 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
800 foreach (@ignore_for_master_contents) {
801 $public_header = 0 if("$header" eq "$_");
805 my $iheader = $subdir . "/" . $header;
806 my @classes = $public_header ? classNames
($iheader) : ();
808 print "$header [$lib]\n";
810 print "SYMBOL: $_\n";
813 #find out all the places it goes..
815 if ($public_header) {
816 @headers = ( "$out_basedir/include/$lib/$header" );
817 push @headers, "$out_basedir/include/Qt/$header"
818 if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src
/);
821 my $header_base = basename
($header);
825 # if ($class =~ m/::/) {
828 $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n";
829 $header_copies++ if(syncHeader
("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0));
831 # KDE-Compat headers for Phonon
832 if ($lib eq "phonon") {
833 $header_copies++ if (syncHeader
("$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0));
836 } elsif ($create_private_headers) {
837 @headers = ( "$out_basedir/include/$lib/private/$header" );
838 push @headers, "$out_basedir/include/Qt/private/$header"
839 if ("$lib" ne "phonon");
841 foreach(@headers) { #sync them
842 $header_copies++ if(syncHeader
($_, $iheader, $copy_headers));
846 #put it into the master file
847 $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude
($iheader));
849 #deal with the install directives
851 my $pri_install_iheader = fixPaths
($iheader, $current_dir);
856 # if ($class =~ m/::/) {
857 # $class =~ s,::,/,g;
859 my $class_header = fixPaths
("$out_basedir/include/$lib/$class",
861 $pri_install_classes .= $class_header
862 unless($pri_install_classes =~ $class_header);
864 $pri_install_files.= "$pri_install_iheader ";;
868 my $pri_install_iheader = fixPaths
($iheader, $current_dir);
869 $pri_install_pfiles.= "$pri_install_iheader ";;
872 print "header created for $iheader ($header_copies)\n" if($header_copies > 0);
878 # close the master include:
879 $master_contents .= "#endif\n";
883 push @master_includes, "$out_basedir/include/$lib/$lib";
884 push @master_includes, "$out_basedir/include/phonon_compat/Phonon/Phonon" if ($lib eq "phonon");
885 foreach my $master_include (@master_includes) {
886 #generate the "master" include file
887 $pri_install_files .= fixPaths
($master_include, "$modules{$lib}") . " "; #get the master file installed too
888 if($master_include && -e
"$master_include") {
889 open MASTERINCLUDE
, "<$master_include";
891 binmode MASTERINCLUDE
;
892 my $oldmaster = <MASTERINCLUDE
>;
894 $oldmaster =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
895 $master_include = 0 if($oldmaster eq $master_contents);
897 if($master_include && $master_contents) {
898 my $master_dir = dirname
($master_include);
899 mkpath
$master_dir, 0777;
900 print "header (master) created for $lib\n";
901 open MASTERINCLUDE
, ">$master_include";
902 print MASTERINCLUDE
"$master_contents";
907 #handle the headers.pri for each module
908 my $headers_pri_contents = "";
909 $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n";
910 $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n";
911 $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n";
912 my $headers_pri_file = "$out_basedir/include/$lib/headers.pri";
913 if(-e
"$headers_pri_file") {
914 open HEADERS_PRI_FILE
, "<$headers_pri_file";
916 binmode HEADERS_PRI_FILE
;
917 my $old_headers_pri_contents = <HEADERS_PRI_FILE
>;
918 close HEADERS_PRI_FILE
;
919 $old_headers_pri_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
920 $headers_pri_file = 0 if($old_headers_pri_contents eq $headers_pri_contents);
922 if($headers_pri_file && $master_contents) {
923 my $headers_pri_dir = dirname
($headers_pri_file);
924 mkpath
$headers_pri_dir, 0777;
925 print "headers.pri file created for $lib\n";
926 open HEADERS_PRI_FILE
, ">$headers_pri_file";
927 print HEADERS_PRI_FILE
"$headers_pri_contents";
928 close HEADERS_PRI_FILE
;
932 unless($showonly || !$create_uic_class_map) {
933 my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h";
934 if(-e
"$class_lib_map") {
935 open CLASS_LIB_MAP
, "<$class_lib_map";
937 binmode CLASS_LIB_MAP
;
938 my $old_class_lib_map_contents = <CLASS_LIB_MAP
>;
940 $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
941 $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents);
944 my $class_lib_map_dir = dirname
($class_lib_map);
945 mkpath
$class_lib_map_dir, 0777;
946 open CLASS_LIB_MAP
, ">$class_lib_map";
947 print CLASS_LIB_MAP
"$class_lib_map_contents";
952 if($check_includes) {
953 for (keys(%modules)) {
956 my $dir = "$modules{$lib}";
957 foreach (split(/;/, $dir)) {
958 my $current_dir = "$_";
960 my @subdirs = ($current_dir);
963 opendir DIR
, "$subdir";
964 while(my $t = readdir(DIR
)) {
965 push @subdirs, "$subdir/$t" if(-d
"$subdir/$t" && !($t eq ".") &&
966 !($t eq "..") && !($t eq ".obj") &&
967 !($t eq ".moc") && !($t eq ".rcc") &&
968 !($t eq ".uic") && !($t eq "build"));
975 my $header_skip_qt_module_test = 0;
976 foreach(@ignore_for_qt_module_check) {
977 foreach (split(/;/, $_)) {
978 $header_skip_qt_module_test = 1 if ("$subdir" =~ /^$_/);
981 my @headers = findFiles
("$subdir", "^[-a-z0-9_]*\\.h\$" , 0);
984 my $header_skip_qt_begin_header_test = 0;
985 my $header_skip_qt_begin_namespace_test = 0;
986 $header = 0 if("$header" =~ /^ui_.*.h/);
987 foreach (@ignore_headers) {
988 $header = 0 if("$header" eq "$_");
991 my $public_header = $header;
992 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
995 foreach (@ignore_for_master_contents) {
996 $public_header = 0 if("$header" eq "$_");
999 foreach (@ignore_for_include_check) {
1000 $public_header = 0 if("$header" eq "$_");
1002 foreach(@ignore_for_qt_begin_header_check) {
1003 $header_skip_qt_begin_header_test = 1 if ("$header" eq "$_");
1005 foreach(@ignore_for_qt_begin_namespace_check) {
1006 $header_skip_qt_begin_namespace_test = 1 if ("$header" eq "$_");
1011 my $iheader = $subdir . "/" . $header;
1012 if($public_header) {
1013 if(open(F
, "<$iheader")) {
1014 my $qt_module_found = 0;
1015 my $qt_begin_header_found = 0;
1016 my $qt_end_header_found = 0;
1017 my $qt_begin_namespace_found = 0;
1018 my $qt_end_namespace_found = 0;
1020 while($line = <F
>) {
1022 my $output_line = 1;
1023 if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) {
1025 } elsif($line =~ /^ *\# *include/) {
1026 my $include = $line;
1027 if($line =~ /<.*>/) {
1028 $include =~ s
,.*<(.*)>.*,$1,;
1029 } elsif($line =~ /".*"/) {
1030 $include =~ s
,.*"(.*)".*,$1,;
1035 for (keys(%modules)) {
1037 if(-e
"$out_basedir/include/$trylib/$include") {
1038 print "WARNING: $iheader includes $include when it should include $trylib/$include\n";
1042 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) {
1043 $qt_begin_header_found = 1;
1044 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) {
1045 $qt_end_header_found = 1;
1046 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) {
1047 $qt_begin_namespace_found = 1;
1048 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) {
1049 $qt_end_namespace_found = 1;
1050 } elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) {
1051 $qt_module_found = 1;
1054 if ($header_skip_qt_begin_header_test == 0) {
1055 if ($qt_begin_header_found == 0) {
1056 print "WARNING: $iheader does not include QT_BEGIN_HEADER\n";
1059 if ($qt_begin_header_found && $qt_end_header_found == 0) {
1060 print "WARNING: $iheader has QT_BEGIN_HEADER but no QT_END_HEADER\n";
1064 if ($header_skip_qt_begin_namespace_test == 0) {
1065 if ($qt_begin_namespace_found == 0) {
1066 print "WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n";
1069 if ($qt_begin_namespace_found && $qt_end_namespace_found == 0) {
1070 print "WARNING: $iheader has QT_BEGIN_NAMESPACE but no QT_END_NAMESPACE\n";
1074 if ($header_skip_qt_module_test == 0) {
1075 if ($qt_module_found == 0) {
1076 print "WARNING: $iheader does not include QT_MODULE\n";