171 ###################################################################### |
171 ###################################################################### |
172 sub classNames { |
172 sub classNames { |
173 my @ret; |
173 my @ret; |
174 my ($iheader) = @_; |
174 my ($iheader) = @_; |
175 if(basename($iheader) eq "qglobal.h") { |
175 if(basename($iheader) eq "qglobal.h") { |
176 push @ret, "QtGlobal"; |
176 push @ret, "QtGlobal"; |
177 } elsif(basename($iheader) eq "qendian.h") { |
177 } elsif(basename($iheader) eq "qendian.h") { |
178 push @ret, "QtEndian"; |
178 push @ret, "QtEndian"; |
179 } elsif(basename($iheader) eq "qconfig.h") { |
179 } elsif(basename($iheader) eq "qconfig.h") { |
180 push @ret, "QtConfig"; |
180 push @ret, "QtConfig"; |
181 } elsif(basename($iheader) eq "qplugin.h") { |
181 } elsif(basename($iheader) eq "qplugin.h") { |
182 push @ret, "QtPlugin"; |
182 push @ret, "QtPlugin"; |
183 } elsif(basename($iheader) eq "qalgorithms.h") { |
183 } elsif(basename($iheader) eq "qalgorithms.h") { |
184 push @ret, "QtAlgorithms"; |
184 push @ret, "QtAlgorithms"; |
185 } elsif(basename($iheader) eq "qcontainerfwd.h") { |
185 } elsif(basename($iheader) eq "qcontainerfwd.h") { |
186 push @ret, "QtContainerFwd"; |
186 push @ret, "QtContainerFwd"; |
187 } elsif(basename($iheader) eq "qdebug.h") { |
187 } elsif(basename($iheader) eq "qdebug.h") { |
188 push @ret, "QtDebug"; |
188 push @ret, "QtDebug"; |
189 } elsif(basename($iheader) eq "qevent.h") { |
189 } elsif(basename($iheader) eq "qevent.h") { |
190 push @ret, "QtEvents"; |
190 push @ret, "QtEvents"; |
191 } elsif(basename($iheader) eq "qnamespace.h") { |
191 } elsif(basename($iheader) eq "qnamespace.h") { |
192 push @ret, "Qt" |
192 push @ret, "Qt" |
193 } elsif(basename($iheader) eq "qssl.h") { |
193 } elsif(basename($iheader) eq "qssl.h") { |
194 push @ret, "QSsl"; |
194 push @ret, "QSsl"; |
195 } elsif(basename($iheader) eq "qtest.h") { |
195 } elsif(basename($iheader) eq "qtest.h") { |
196 push @ret, "QTest" |
196 push @ret, "QTest" |
197 } elsif(basename($iheader) eq "qtconcurrentmap.h") { |
197 } elsif(basename($iheader) eq "qtconcurrentmap.h") { |
198 push @ret, "QtConcurrentMap" |
198 push @ret, "QtConcurrentMap" |
199 } elsif(basename($iheader) eq "qtconcurrentfilter.h") { |
199 } elsif(basename($iheader) eq "qtconcurrentfilter.h") { |
262 if($end eq ";" || $end ne " ") { |
262 if($end eq ";" || $end ne " ") { |
263 $definition = substr($parsable, $last_definition, $block_start - $last_definition) . "}"; |
263 $definition = substr($parsable, $last_definition, $block_start - $last_definition) . "}"; |
264 $i = $i2 if($end eq ";"); |
264 $i = $i2 if($end eq ";"); |
265 $last_definition = $i + 1; |
265 $last_definition = $i + 1; |
266 last BLOCK; |
266 last BLOCK; |
267 } |
267 } |
268 } |
268 } |
269 } |
269 } |
270 } |
270 } |
271 } |
271 } |
272 } elsif($character eq ";") { |
272 } elsif($character eq ";") { |
273 $definition = substr($parsable, $last_definition, $i - $last_definition + 1); |
273 $definition = substr($parsable, $last_definition, $i - $last_definition + 1); |
274 $last_definition = $i + 1; |
274 $last_definition = $i + 1; |
275 } elsif($character eq "}") { |
275 } elsif($character eq "}") { |
276 # a naked } must be a namespace ending |
276 # a naked } must be a namespace ending |
277 # if it's not a namespace, it's eaten by the loop above |
277 # if it's not a namespace, it's eaten by the loop above |
278 pop @namespaces; |
278 pop @namespaces; |
279 $last_definition = $i + 1; |
279 $last_definition = $i + 1; |
280 } |
280 } |
281 |
281 |
282 if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) / |
282 if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) / |
283 && substr($parsable, $i+1, 1) eq "{") { |
283 && substr($parsable, $i+1, 1) eq "{") { |
284 push @namespaces, $1; |
284 push @namespaces, $1; |
285 |
285 |
286 # Eat the opening { so that the condensing loop above doesn't see it |
286 # Eat the opening { so that the condensing loop above doesn't see it |
287 $i++; |
287 $i++; |
288 $last_definition = $i + 1; |
288 $last_definition = $i + 1; |
289 } |
289 } |
290 |
290 |
291 if($definition) { |
291 if($definition) { |
292 $definition =~ s=[\n\r]==g; |
292 $definition =~ s=[\n\r]==g; |
293 my @symbols; |
293 my @symbols; |
294 if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) { |
294 if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) { |
295 push @symbols, $1; |
295 push @symbols, $1; |
296 } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) { |
296 } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) { |
297 push @symbols, $2; |
297 push @symbols, $2; |
298 } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) { |
298 } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) { |
299 push @symbols, $4; |
299 push @symbols, $4; |
300 } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) { |
300 } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) { |
301 push @symbols, "Q" . $1 . "Iterator"; |
301 push @symbols, "Q" . $1 . "Iterator"; |
302 push @symbols, "QMutable" . $1 . "Iterator"; |
302 push @symbols, "QMutable" . $1 . "Iterator"; |
303 } |
303 } |
304 |
304 |
305 foreach (@symbols) { |
305 foreach (@symbols) { |
306 my $symbol = $_; |
306 my $symbol = $_; |
307 $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces); |
307 $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces); |
308 push @ret, $symbol |
308 push @ret, $symbol |
309 if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q |
309 if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q |
310 || $symbol =~ /^Phonon::/); # or in the Phonon namespace |
310 || $symbol =~ /^Phonon::/); # or in the Phonon namespace |
311 } |
311 } |
312 } |
312 } |
313 } |
313 } |
314 return @ret; |
314 return @ret; |
315 } |
315 } |
571 my $val = 0; |
571 my $val = 0; |
572 |
572 |
573 #parse |
573 #parse |
574 my $arg = shift @ARGV; |
574 my $arg = shift @ARGV; |
575 if ("$arg" eq "-h" || "$arg" eq "-help" || "$arg" eq "?") { |
575 if ("$arg" eq "-h" || "$arg" eq "-help" || "$arg" eq "?") { |
576 $var = "show_help"; |
576 $var = "show_help"; |
577 $val = "yes"; |
577 $val = "yes"; |
578 } elsif("$arg" eq "-copy") { |
578 } elsif("$arg" eq "-copy") { |
579 $var = "copy"; |
579 $var = "copy"; |
580 $val = "yes"; |
580 $val = "yes"; |
581 } elsif("$arg" eq "-o" || "$arg" eq "-outdir") { |
581 } elsif("$arg" eq "-o" || "$arg" eq "-outdir") { |
582 $var = "output"; |
582 $var = "output"; |
583 $val = shift @ARGV; |
583 $val = shift @ARGV; |
584 } elsif("$arg" eq "-showonly" || "$arg" eq "-remove-stale" || "$arg" eq "-windows" || |
584 } elsif("$arg" eq "-showonly" || "$arg" eq "-remove-stale" || "$arg" eq "-windows" || |
585 "$arg" eq "-relative" || "$arg" eq "-check-includes") { |
585 "$arg" eq "-relative" || "$arg" eq "-check-includes") { |
586 $var = substr($arg, 1); |
586 $var = substr($arg, 1); |
587 $val = "yes"; |
587 $val = "yes"; |
588 } elsif("$arg" =~ /^-no-(.*)$/) { |
588 } elsif("$arg" =~ /^-no-(.*)$/) { |
589 $var = $1; |
589 $var = $1; |
590 $val = "no"; |
590 $val = "no"; |
591 #these are for commandline compat |
591 #these are for commandline compat |
592 } elsif("$arg" eq "-inc") { |
592 } elsif("$arg" eq "-inc") { |
593 $var = "output"; |
593 $var = "output"; |
594 $val = shift @ARGV; |
594 $val = shift @ARGV; |
595 } elsif("$arg" eq "-module") { |
595 } elsif("$arg" eq "-module") { |
596 $var = "module"; |
596 $var = "module"; |
597 $val = shift @ARGV; |
597 $val = shift @ARGV; |
598 } elsif("$arg" eq "-separate-module") { |
598 } elsif("$arg" eq "-separate-module") { |
599 $var = "separate-module"; |
599 $var = "separate-module"; |
600 $val = shift @ARGV; |
600 $val = shift @ARGV; |
601 } elsif("$arg" eq "-show") { |
601 } elsif("$arg" eq "-show") { |
602 $var = "showonly"; |
602 $var = "showonly"; |
603 $val = "yes"; |
603 $val = "yes"; |
604 } elsif("$arg" eq "-quiet") { |
604 } elsif("$arg" eq "-quiet") { |
605 $var = "quiet"; |
605 $var = "quiet"; |
606 $val = "yes"; |
606 $val = "yes"; |
607 } elsif("$arg" eq "-base-dir") { |
607 } elsif("$arg" eq "-base-dir") { |
608 # skip, it's been dealt with at the top of the file |
608 # skip, it's been dealt with at the top of the file |
609 shift @ARGV; |
609 shift @ARGV; |
610 next; |
610 next; |
611 } elsif("$arg" eq "-outsubdir") { |
611 } elsif("$arg" eq "-outsubdir") { |
619 $val = "yes"; |
619 $val = "yes"; |
620 } |
620 } |
621 |
621 |
622 #do something |
622 #do something |
623 if(!$var || "$var" eq "show_help") { |
623 if(!$var || "$var" eq "show_help") { |
624 print "Unknown option: $arg\n\n" if(!$var); |
624 print "Unknown option: $arg\n\n" if(!$var); |
625 showUsage(); |
625 showUsage(); |
626 } elsif ("$var" eq "copy") { |
626 } elsif ("$var" eq "copy") { |
627 if("$val" eq "yes") { |
627 if("$val" eq "yes") { |
628 $copy_headers++; |
628 $copy_headers++; |
629 } elsif($showonly) { |
629 } elsif($showonly) { |
630 $copy_headers--; |
630 $copy_headers--; |
631 } |
631 } |
632 } elsif ("$var" eq "showonly") { |
632 } elsif ("$var" eq "showonly") { |
633 if("$val" eq "yes") { |
633 if("$val" eq "yes") { |
634 $showonly++; |
634 $showonly++; |
635 } elsif($showonly) { |
635 } elsif($showonly) { |
636 $showonly--; |
636 $showonly--; |
637 } |
637 } |
638 } elsif ("$var" eq "quiet") { |
638 } elsif ("$var" eq "quiet") { |
639 if("$val" eq "yes") { |
639 if("$val" eq "yes") { |
640 $quiet++; |
640 $quiet++; |
641 } elsif($quiet) { |
641 } elsif($quiet) { |
642 $quiet--; |
642 $quiet--; |
643 } |
643 } |
644 } elsif ("$var" eq "check-includes") { |
644 } elsif ("$var" eq "check-includes") { |
645 if("$val" eq "yes") { |
645 if("$val" eq "yes") { |
646 $check_includes++; |
646 $check_includes++; |
647 } elsif($check_includes) { |
647 } elsif($check_includes) { |
648 $check_includes--; |
648 $check_includes--; |
649 } |
649 } |
650 } elsif ("$var" eq "remove-stale") { |
650 } elsif ("$var" eq "remove-stale") { |
651 if("$val" eq "yes") { |
651 if("$val" eq "yes") { |
652 $remove_stale++; |
652 $remove_stale++; |
653 } elsif($remove_stale) { |
653 } elsif($remove_stale) { |
654 $remove_stale--; |
654 $remove_stale--; |
655 } |
655 } |
656 } elsif ("$var" eq "windows") { |
656 } elsif ("$var" eq "windows") { |
657 if("$val" eq "yes") { |
657 if("$val" eq "yes") { |
658 $force_win++; |
658 $force_win++; |
659 } elsif($force_win) { |
659 } elsif($force_win) { |
660 $force_win--; |
660 $force_win--; |
661 } |
661 } |
662 } elsif ("$var" eq "relative") { |
662 } elsif ("$var" eq "relative") { |
663 if("$val" eq "yes") { |
663 if("$val" eq "yes") { |
664 $force_relative++; |
664 $force_relative++; |
665 } elsif($force_relative) { |
665 } elsif($force_relative) { |
666 $force_relative--; |
666 $force_relative--; |
667 } |
667 } |
668 } elsif ("$var" eq "public") { |
668 } elsif ("$var" eq "public") { |
669 $create_private_headers = ("$val" eq "yes" ? 0 : 1); |
669 $create_private_headers = ("$val" eq "yes" ? 0 : 1); |
670 } elsif ("$var" eq "oneway") { |
670 } elsif ("$var" eq "oneway") { |
671 $oneway = ("$val" eq "yes" ? 1 : 0); |
671 $oneway = ("$val" eq "yes" ? 1 : 0); |
672 } elsif ("$var" eq "outsubdir") { |
672 } elsif ("$var" eq "outsubdir") { |
673 $out_subdir = $val; |
673 $out_subdir = $val; |
674 } elsif ("$var" eq "module") { |
674 } elsif ("$var" eq "module") { |
675 print "module :$val:\n" unless $quiet; |
675 print "module :$val:\n" unless $quiet; |
676 die "No such module: $val" unless(defined $modules{$val}); |
676 die "No such module: $val" unless(defined $modules{$val}); |
677 push @modules_to_sync, $val; |
677 push @modules_to_sync, $val; |
678 } elsif ("$var" eq "separate-module") { |
678 } elsif ("$var" eq "separate-module") { |
679 my ($module, $prodir, $headerdir) = split(/:/, $val); |
679 my ($module, $prodir, $headerdir) = split(/:/, $val); |
680 $modules{$module} = $prodir; |
680 $modules{$module} = $prodir; |
681 push @modules_to_sync, $module; |
681 push @modules_to_sync, $module; |
682 $moduleheaders{$module} = $headerdir; |
682 $moduleheaders{$module} = $headerdir; |
683 $create_uic_class_map = 0; |
683 $create_uic_class_map = 0; |
684 $create_private_headers = 0; |
684 $create_private_headers = 0; |
685 } elsif ("$var" eq "output") { |
685 } elsif ("$var" eq "output") { |
686 my $outdir = $val; |
686 my $outdir = $val; |
687 if(checkRelative($outdir)) { |
687 if(checkRelative($outdir)) { |
688 $out_basedir = getcwd(); |
688 $out_basedir = getcwd(); |
689 chomp $out_basedir; |
689 chomp $out_basedir; |
690 $out_basedir .= "/" . $outdir; |
690 $out_basedir .= "/" . $outdir; |
691 } else { |
691 } else { |
692 $out_basedir = $outdir; |
692 $out_basedir = $outdir; |
693 } |
693 } |
694 # \ -> / |
694 # \ -> / |
695 $out_basedir =~ s=\\=/=g; |
695 $out_basedir =~ s=\\=/=g; |
696 } |
696 } |
697 } |
697 } |
698 @modules_to_sync = keys(%modules) if($#modules_to_sync == -1); |
698 @modules_to_sync = keys(%modules) if($#modules_to_sync == -1); |
699 |
699 |
700 $isunix = checkUnix; #cache checkUnix |
700 $isunix = checkUnix; #cache checkUnix |
701 |
701 |
702 # create path |
702 # create path |
703 mkpath "$out_basedir/$out_subdir", !$quiet; |
703 mkpath "$out_basedir/$out_subdir/Qt", !$quiet; |
704 |
704 |
705 my @ignore_headers = (); |
705 my @ignore_headers = (); |
706 my $class_lib_map_contents = ""; |
706 my $class_lib_map_contents = ""; |
707 my @ignore_for_master_contents = ( "qt.h", "qpaintdevicedefs.h" ); |
707 my @ignore_for_master_contents = ( "qt.h", "qpaintdevicedefs.h" ); |
708 my @ignore_for_include_check = ( "qatomic.h" ); |
708 my @ignore_for_include_check = ( "qatomic.h" ); |
709 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" ); |
709 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" ); |
710 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" ); |
710 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" ); |
711 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}" ); |
711 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}" ); |
|
712 my %colliding_headers = (); |
712 |
713 |
713 foreach (@modules_to_sync) { |
714 foreach (@modules_to_sync) { |
714 #iteration info |
715 #iteration info |
715 my $lib = $_; |
716 my $lib = $_; |
716 my $dir = "$modules{$lib}"; |
717 my $dir = "$modules{$lib}"; |
726 $libcapitals =~ y/a-z/A-Z/; |
727 $libcapitals =~ y/a-z/A-Z/; |
727 my $master_contents = "#ifndef QT_".$libcapitals."_MODULE_H\n#define QT_".$libcapitals."_MODULE_H\n"; |
728 my $master_contents = "#ifndef QT_".$libcapitals."_MODULE_H\n#define QT_".$libcapitals."_MODULE_H\n"; |
728 |
729 |
729 #get dependencies |
730 #get dependencies |
730 if(-e "$dir/" . basename($dir) . ".pro") { |
731 if(-e "$dir/" . basename($dir) . ".pro") { |
731 if(open(F, "<$dir/" . basename($dir) . ".pro")) { |
732 if(open(F, "<$dir/" . basename($dir) . ".pro")) { |
732 while(<F>) { |
733 while(<F>) { |
733 my $line = $_; |
734 my $line = $_; |
734 chomp $line; |
735 chomp $line; |
735 if($line =~ /^ *QT *\+?= *([^\r\n]*)/) { |
736 if($line =~ /^ *QT *\+?= *([^\r\n]*)/) { |
736 foreach(split(/ /, "$1")) { |
737 foreach(split(/ /, "$1")) { |
737 $master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core"); |
738 $master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core"); |
738 $master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui"); |
739 $master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui"); |
739 $master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network"); |
740 $master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network"); |
740 $master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg"); |
741 $master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg"); |
741 $master_contents .= "#include <QtDeclarative/QtDeclarative>\n" if("$_" eq "declarative"); |
742 $master_contents .= "#include <QtDeclarative/QtDeclarative>\n" if("$_" eq "declarative"); |
742 $master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script"); |
743 $master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script"); |
743 $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools"); |
744 $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools"); |
744 $master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support"); |
745 $master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support"); |
745 $master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql"); |
746 $master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql"); |
746 $master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml"); |
747 $master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml"); |
747 $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns"); |
748 $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns"); |
748 $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl"); |
749 $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl"); |
749 $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg"); |
750 $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg"); |
750 } |
751 } |
751 } |
752 } |
752 } |
753 } |
753 close(F); |
754 close(F); |
754 } |
755 } |
755 } |
756 } |
756 |
757 |
757 #remove the old files |
758 #remove the old files |
758 if($remove_stale) { |
759 if($remove_stale) { |
759 my @subdirs = ("$out_basedir/$out_subdir/$lib"); |
760 my @subdirs = ("$out_basedir/$out_subdir/$lib"); |
760 foreach (@subdirs) { |
761 foreach (@subdirs) { |
761 my $subdir = "$_"; |
762 my $subdir = "$_"; |
762 if (opendir DIR, "$subdir") { |
763 if (opendir DIR, "$subdir") { |
763 while(my $t = readdir(DIR)) { |
764 while(my $t = readdir(DIR)) { |
764 my $file = "$subdir/$t"; |
765 my $file = "$subdir/$t"; |
765 if(-d "$file") { |
766 if(-d "$file") { |
766 push @subdirs, "$file" unless($t eq "." || $t eq ".."); |
767 push @subdirs, "$file" unless($t eq "." || $t eq ".."); |
767 } else { |
768 } else { |
768 my @files = ("$file"); |
769 my @files = ("$file"); |
769 #push @files, "$out_basedir/$out_subdir/Qt/$t" if(-e "$out_basedir/$out_subdir/Qt/$t"); |
770 #push @files, "$out_basedir/$out_subdir/Qt/$t" if(-e "$out_basedir/$out_subdir/Qt/$t"); |
770 foreach (@files) { |
771 foreach (@files) { |
771 my $file = $_; |
772 my $file = $_; |
772 my $remove_file = 0; |
773 my $remove_file = 0; |
773 if(open(F, "<$file")) { |
774 if(open(F, "<$file")) { |
774 while(<F>) { |
775 while(<F>) { |
775 my $line = $_; |
776 my $line = $_; |
776 chomp $line; |
777 chomp $line; |
777 if($line =~ /^\#include \"([^\"]*)\"$/) { |
778 if($line =~ /^\#include \"([^\"]*)\"$/) { |
778 my $include = $1; |
779 my $include = $1; |
779 $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); |
780 $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); |
780 $remove_file = 1 unless(-e "$include"); |
781 $remove_file = 1 unless(-e "$include"); |
781 } else { |
782 } else { |
782 $remove_file = 0; |
783 $remove_file = 0; |
783 last; |
784 last; |
784 } |
785 } |
785 } |
786 } |
786 close(F); |
787 close(F); |
787 unlink "$file" if($remove_file); |
788 unlink "$file" if($remove_file); |
788 } |
789 } |
789 } |
790 } |
790 } |
791 } |
791 } |
792 } |
792 closedir DIR; |
793 closedir DIR; |
793 } |
794 } |
794 |
795 |
795 } |
796 } |
796 } |
797 } |
797 |
798 |
798 #create the new ones |
799 #create the new ones |
799 foreach (split(/;/, $dir)) { |
800 foreach (split(/;/, $dir)) { |
800 my $current_dir = "$_"; |
801 my $current_dir = "$_"; |
801 my $headers_dir = $current_dir; |
802 my $headers_dir = $current_dir; |
802 $headers_dir .= "/$pathtoheaders" if ($pathtoheaders); |
803 $headers_dir .= "/$pathtoheaders" if ($pathtoheaders); |
803 #calc subdirs |
804 #calc subdirs |
804 my @subdirs = ($headers_dir); |
805 my @subdirs = ($headers_dir); |
805 foreach (@subdirs) { |
806 foreach (@subdirs) { |
806 my $subdir = "$_"; |
807 my $subdir = "$_"; |
807 opendir DIR, "$subdir" or next; |
808 opendir DIR, "$subdir" or next; |
808 while(my $t = readdir(DIR)) { |
809 while(my $t = readdir(DIR)) { |
809 push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && |
810 push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && |
810 !($t eq "..") && !($t eq ".obj") && |
811 !($t eq "..") && !($t eq ".obj") && |
811 !($t eq ".moc") && !($t eq ".rcc") && |
812 !($t eq ".moc") && !($t eq ".rcc") && |
812 !($t eq ".uic") && !($t eq "build")); |
813 !($t eq ".uic") && !($t eq "build")); |
813 } |
814 } |
814 closedir DIR; |
815 closedir DIR; |
815 } |
816 } |
823 $header = 0 if("$header" =~ /^ui_.*.h/); |
824 $header = 0 if("$header" =~ /^ui_.*.h/); |
824 foreach (@ignore_headers) { |
825 foreach (@ignore_headers) { |
825 $header = 0 if("$header" eq "$_"); |
826 $header = 0 if("$header" eq "$_"); |
826 } |
827 } |
827 if($header) { |
828 if($header) { |
828 my $header_copies = 0; |
829 my $header_copies = 0; |
829 #figure out if it is a public header |
830 #figure out if it is a public header |
830 my $public_header = $header; |
831 my $public_header = $header; |
831 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { |
832 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { |
832 $public_header = 0; |
833 $public_header = 0; |
833 } else { |
834 } else { |
834 foreach (@ignore_for_master_contents) { |
835 foreach (@ignore_for_master_contents) { |
835 $public_header = 0 if("$header" eq "$_"); |
836 $public_header = 0 if("$header" eq "$_"); |
836 } |
837 } |
837 } |
838 } |
838 |
839 |
839 my $iheader = $subdir . "/" . $header; |
840 my $iheader = $subdir . "/" . $header; |
840 my @classes = $public_header ? classNames($iheader) : (); |
841 my @classes = $public_header ? classNames($iheader) : (); |
841 if($showonly) { |
842 if($showonly) { |
842 print "$header [$lib]\n"; |
843 print "$header [$lib]\n"; |
843 foreach(@classes) { |
844 foreach(@classes) { |
844 print "SYMBOL: $_\n"; |
845 print "SYMBOL: $_\n"; |
845 } |
846 } |
846 } else { |
847 } else { |
847 #find out all the places it goes.. |
848 #find out all the places it goes.. |
848 my @headers; |
849 my @headers; |
849 if ($public_header) { |
850 if ($public_header) { |
850 @headers = ( "$out_basedir/$out_subdir/$lib/$header" ); |
851 @headers = ( "$out_basedir/$out_subdir/$lib/$header" ); |
851 push @headers, "$out_basedir/$out_subdir/Qt/$header" |
852 |
852 if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/); |
853 # write forwarding headers to include/Qt |
853 |
854 if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/) { |
854 foreach(@classes) { |
855 my $file_name = "$out_basedir/$out_subdir/Qt/$header"; |
855 my $header_base = basename($header); |
856 my $file_op = '>'; |
856 my $class = $_; |
857 my $header_content = ''; |
857 # Strip namespaces: |
858 if (exists $colliding_headers{$file_name}) { |
858 $class =~ s/^.*:://; |
859 $file_op = '>>'; |
859 # if ($class =~ m/::/) { |
860 } else { |
860 # class =~ s,::,/,g; |
861 $colliding_headers{$file_name} = 1; |
861 # } |
862 my $warning_msg = 'Inclusion of header files from include/Qt is deprecated.'; |
862 $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n"; |
863 $header_content = "#ifndef QT_NO_QT_INCLUDE_WARN\n" . |
863 $header_copies++ if(syncHeader("$out_basedir/$out_subdir/$lib/$class", "$out_basedir/$out_subdir/$lib/$header", 0)); |
864 " #if defined(__GNUC__)\n" . |
864 |
865 " #pragma warning \"$warning_msg\"\n" . |
865 # KDE-Compat headers for Phonon |
866 " #elif defined(_MSC_VER)\n" . |
866 if ($lib eq "phonon") { |
867 " #pragma message \"WARNING: $warning_msg\"\n" . |
867 $header_copies++ if (syncHeader("$out_basedir/$out_subdir/phonon_compat/Phonon/$class", "$out_basedir/$out_subdir/$lib/$header", 0)); |
868 " #endif\n". |
868 } |
869 "#endif\n\n"; |
869 } |
870 } |
870 } elsif ($create_private_headers) { |
871 $header_content .= '#include "' . "../$lib/$header" . "\"\n"; |
871 @headers = ( "$out_basedir/$out_subdir/$lib/private/$header" ); |
872 open HEADERFILE, $file_op, $file_name or die "unable to open '$file_name' : $!\n"; |
872 push @headers, "$out_basedir/$out_subdir/Qt/private/$header" |
873 print HEADERFILE $header_content; |
873 if ("$lib" ne "phonon"); |
874 close HEADERFILE; |
874 } |
875 } |
875 foreach(@headers) { #sync them |
876 |
876 $header_copies++ if(syncHeader($_, $iheader, $copy_headers)); |
877 foreach(@classes) { |
877 } |
878 my $header_base = basename($header); |
878 |
879 my $class = $_; |
879 if($public_header) { |
880 # Strip namespaces: |
880 #put it into the master file |
881 $class =~ s/^.*:://; |
881 $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude($iheader)); |
882 # if ($class =~ m/::/) { |
882 |
883 # class =~ s,::,/,g; |
883 #deal with the install directives |
884 # } |
884 if($public_header) { |
885 $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n"; |
885 my $pri_install_iheader = fixPaths($iheader, $current_dir); |
886 $header_copies++ if(syncHeader("$out_basedir/$out_subdir/$lib/$class", "$out_basedir/$out_subdir/$lib/$header", 0)); |
886 foreach(@classes) { |
887 |
887 my $class = $_; |
888 # KDE-Compat headers for Phonon |
888 # Strip namespaces: |
889 if ($lib eq "phonon") { |
889 $class =~ s/^.*:://; |
890 $header_copies++ if (syncHeader("$out_basedir/$out_subdir/phonon_compat/Phonon/$class", "$out_basedir/$out_subdir/$lib/$header", 0)); |
890 # if ($class =~ m/::/) { |
891 } |
891 # $class =~ s,::,/,g; |
892 } |
892 # } |
893 } elsif ($create_private_headers) { |
|
894 @headers = ( "$out_basedir/$out_subdir/$lib/private/$header" ); |
|
895 } |
|
896 foreach(@headers) { #sync them |
|
897 $header_copies++ if(syncHeader($_, $iheader, $copy_headers)); |
|
898 } |
|
899 |
|
900 if($public_header) { |
|
901 #put it into the master file |
|
902 $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude($iheader)); |
|
903 |
|
904 #deal with the install directives |
|
905 if($public_header) { |
|
906 my $pri_install_iheader = fixPaths($iheader, $current_dir); |
|
907 foreach(@classes) { |
|
908 my $class = $_; |
|
909 # Strip namespaces: |
|
910 $class =~ s/^.*:://; |
|
911 # if ($class =~ m/::/) { |
|
912 # $class =~ s,::,/,g; |
|
913 # } |
893 my $class_header = fixPaths("$out_basedir/$out_subdir/$lib/$class", |
914 my $class_header = fixPaths("$out_basedir/$out_subdir/$lib/$class", |
894 $current_dir) . " "; |
915 $current_dir) . " "; |
895 $pri_install_classes .= $class_header |
916 $pri_install_classes .= $class_header |
896 unless($pri_install_classes =~ $class_header); |
917 unless($pri_install_classes =~ $class_header); |
897 } |
918 } |
898 $pri_install_files.= "$pri_install_iheader ";; |
919 $pri_install_files.= "$pri_install_iheader ";; |
899 } |
920 } |
900 } |
921 } |
901 else { |
922 else { |
902 my $pri_install_iheader = fixPaths($iheader, $current_dir); |
923 my $pri_install_iheader = fixPaths($iheader, $current_dir); |
903 $pri_install_pfiles.= "$pri_install_iheader ";; |
924 $pri_install_pfiles.= "$pri_install_iheader ";; |
904 } |
925 } |
905 } |
926 } |
906 print "header created for $iheader ($header_copies)\n" if($header_copies > 0 && !$quiet); |
927 print "header created for $iheader ($header_copies)\n" if($header_copies > 0 && !$quiet); |
907 } |
928 } |
908 } |
929 } |
909 } |
930 } |
910 } |
931 } |
911 |
932 |
965 } |
986 } |
966 } |
987 } |
967 unless($showonly || !$create_uic_class_map) { |
988 unless($showonly || !$create_uic_class_map) { |
968 my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h"; |
989 my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h"; |
969 if(-e "$class_lib_map") { |
990 if(-e "$class_lib_map") { |
970 open CLASS_LIB_MAP, "<$class_lib_map"; |
991 open CLASS_LIB_MAP, "<$class_lib_map"; |
971 local $/; |
992 local $/; |
972 binmode CLASS_LIB_MAP; |
993 binmode CLASS_LIB_MAP; |
973 my $old_class_lib_map_contents = <CLASS_LIB_MAP>; |
994 my $old_class_lib_map_contents = <CLASS_LIB_MAP>; |
974 close CLASS_LIB_MAP; |
995 close CLASS_LIB_MAP; |
975 $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms |
996 $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms |
976 $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents); |
997 $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents); |
977 } |
998 } |
978 if($class_lib_map) { |
999 if($class_lib_map) { |
979 my $class_lib_map_dir = dirname($class_lib_map); |
1000 my $class_lib_map_dir = dirname($class_lib_map); |
980 mkpath $class_lib_map_dir, !$quiet; |
1001 mkpath $class_lib_map_dir, !$quiet; |
981 open CLASS_LIB_MAP, ">$class_lib_map"; |
1002 open CLASS_LIB_MAP, ">$class_lib_map"; |
982 print CLASS_LIB_MAP "$class_lib_map_contents"; |
1003 print CLASS_LIB_MAP "$class_lib_map_contents"; |
983 close CLASS_LIB_MAP; |
1004 close CLASS_LIB_MAP; |
984 } |
1005 } |
985 } |
1006 } |
986 |
1007 |
987 if($check_includes) { |
1008 if($check_includes) { |
988 for (keys(%modules)) { |
1009 for (keys(%modules)) { |
989 #iteration info |
1010 #iteration info |
990 my $lib = $_; |
1011 my $lib = $_; |
991 my $dir = "$modules{$lib}"; |
1012 my $dir = "$modules{$lib}"; |
992 foreach (split(/;/, $dir)) { |
1013 foreach (split(/;/, $dir)) { |
993 my $current_dir = "$_"; |
1014 my $current_dir = "$_"; |
994 #calc subdirs |
1015 #calc subdirs |
995 my @subdirs = ($current_dir); |
1016 my @subdirs = ($current_dir); |
996 foreach (@subdirs) { |
1017 foreach (@subdirs) { |
997 my $subdir = "$_"; |
1018 my $subdir = "$_"; |
998 opendir DIR, "$subdir"; |
1019 opendir DIR, "$subdir"; |
999 while(my $t = readdir(DIR)) { |
1020 while(my $t = readdir(DIR)) { |
1000 push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && |
1021 push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && |
1001 !($t eq "..") && !($t eq ".obj") && |
1022 !($t eq "..") && !($t eq ".obj") && |
1002 !($t eq ".moc") && !($t eq ".rcc") && |
1023 !($t eq ".moc") && !($t eq ".rcc") && |
1003 !($t eq ".uic") && !($t eq "build")); |
1024 !($t eq ".uic") && !($t eq "build")); |
1004 } |
1025 } |
1005 closedir DIR; |
1026 closedir DIR; |
1006 } |
1027 } |
1007 |
1028 |
1008 foreach (@subdirs) { |
1029 foreach (@subdirs) { |
1009 my $subdir = "$_"; |
1030 my $subdir = "$_"; |
1010 my $header_skip_qt_module_test = 0; |
1031 my $header_skip_qt_module_test = 0; |
1011 foreach(@ignore_for_qt_module_check) { |
1032 foreach(@ignore_for_qt_module_check) { |
1012 foreach (split(/;/, $_)) { |
1033 foreach (split(/;/, $_)) { |
1013 $header_skip_qt_module_test = 1 if ("$subdir" =~ /^$_/); |
1034 $header_skip_qt_module_test = 1 if ("$subdir" =~ /^$_/); |
1014 } |
1035 } |
1015 } |
1036 } |
1016 my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0); |
1037 my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0); |
1017 foreach (@headers) { |
1038 foreach (@headers) { |
1018 my $header = "$_"; |
1039 my $header = "$_"; |
1019 my $header_skip_qt_begin_header_test = 0; |
1040 my $header_skip_qt_begin_header_test = 0; |
1020 my $header_skip_qt_begin_namespace_test = 0; |
1041 my $header_skip_qt_begin_namespace_test = 0; |
1021 $header = 0 if("$header" =~ /^ui_.*.h/); |
1042 $header = 0 if("$header" =~ /^ui_.*.h/); |
1022 foreach (@ignore_headers) { |
1043 foreach (@ignore_headers) { |
1023 $header = 0 if("$header" eq "$_"); |
1044 $header = 0 if("$header" eq "$_"); |
1024 } |
1045 } |
1025 if($header) { |
1046 if($header) { |
1026 my $public_header = $header; |
1047 my $public_header = $header; |
1027 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { |
1048 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { |
1028 $public_header = 0; |
1049 $public_header = 0; |
1029 } else { |
1050 } else { |
1030 foreach (@ignore_for_master_contents) { |
1051 foreach (@ignore_for_master_contents) { |
1031 $public_header = 0 if("$header" eq "$_"); |
1052 $public_header = 0 if("$header" eq "$_"); |
1032 } |
1053 } |
1033 if($public_header) { |
1054 if($public_header) { |
1034 foreach (@ignore_for_include_check) { |
1055 foreach (@ignore_for_include_check) { |
1035 $public_header = 0 if("$header" eq "$_"); |
1056 $public_header = 0 if("$header" eq "$_"); |
1036 } |
1057 } |
1037 foreach(@ignore_for_qt_begin_header_check) { |
1058 foreach(@ignore_for_qt_begin_header_check) { |
1038 $header_skip_qt_begin_header_test = 1 if ("$header" eq "$_"); |
1059 $header_skip_qt_begin_header_test = 1 if ("$header" eq "$_"); |
1039 } |
1060 } |
1040 foreach(@ignore_for_qt_begin_namespace_check) { |
1061 foreach(@ignore_for_qt_begin_namespace_check) { |
1041 $header_skip_qt_begin_namespace_test = 1 if ("$header" eq "$_"); |
1062 $header_skip_qt_begin_namespace_test = 1 if ("$header" eq "$_"); |
1042 } |
1063 } |
1043 } |
1064 } |
1044 } |
1065 } |
1045 |
1066 |
1046 my $iheader = $subdir . "/" . $header; |
1067 my $iheader = $subdir . "/" . $header; |
1047 if($public_header) { |
1068 if($public_header) { |
1048 if(open(F, "<$iheader")) { |
1069 if(open(F, "<$iheader")) { |
1049 my $qt_module_found = 0; |
1070 my $qt_module_found = 0; |
1050 my $qt_begin_header_found = 0; |
1071 my $qt_begin_header_found = 0; |
1051 my $qt_end_header_found = 0; |
1072 my $qt_end_header_found = 0; |
1052 my $qt_begin_namespace_found = 0; |
1073 my $qt_begin_namespace_found = 0; |
1053 my $qt_end_namespace_found = 0; |
1074 my $qt_end_namespace_found = 0; |
1054 my $line; |
1075 my $line; |
1055 while($line = <F>) { |
1076 while($line = <F>) { |
1056 chomp $line; |
1077 chomp $line; |
1057 my $output_line = 1; |
1078 my $output_line = 1; |
1058 if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) { |
1079 if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) { |
1059 last; |
1080 last; |
1060 } elsif($line =~ /^ *\# *include/) { |
1081 } elsif($line =~ /^ *\# *include/) { |
1061 my $include = $line; |
1082 my $include = $line; |
1062 if($line =~ /<.*>/) { |
1083 if($line =~ /<.*>/) { |
1063 $include =~ s,.*<(.*)>.*,$1,; |
1084 $include =~ s,.*<(.*)>.*,$1,; |
1064 } elsif($line =~ /".*"/) { |
1085 } elsif($line =~ /".*"/) { |
1065 $include =~ s,.*"(.*)".*,$1,; |
1086 $include =~ s,.*"(.*)".*,$1,; |
1066 } else { |
1087 } else { |
1067 $include = 0; |
1088 $include = 0; |
1068 } |
1089 } |
1069 if($include) { |
1090 if($include) { |
1070 for (keys(%modules)) { |
1091 for (keys(%modules)) { |
1071 my $trylib = $_; |
1092 my $trylib = $_; |
1072 if(-e "$out_basedir/$out_subdir/$trylib/$include") { |
1093 if(-e "$out_basedir/$out_subdir/$trylib/$include") { |
1073 print "WARNING: $iheader includes $include when it should include $trylib/$include\n"; |
1094 print "WARNING: $iheader includes $include when it should include $trylib/$include\n"; |
1074 } |
1095 } |
1075 } |
1096 } |
1076 } |
1097 } |
1077 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) { |
1098 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) { |
1078 $qt_begin_header_found = 1; |
1099 $qt_begin_header_found = 1; |
1079 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) { |
1100 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) { |
1080 $qt_end_header_found = 1; |
1101 $qt_end_header_found = 1; |
1081 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) { |
1102 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) { |
1082 $qt_begin_namespace_found = 1; |
1103 $qt_begin_namespace_found = 1; |
1083 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) { |
1104 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) { |
1084 $qt_end_namespace_found = 1; |
1105 $qt_end_namespace_found = 1; |
1085 } elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) { |
1106 } elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) { |
1086 $qt_module_found = 1; |
1107 $qt_module_found = 1; |
1087 } |
1108 } |
1088 } |
1109 } |
1089 if ($header_skip_qt_begin_header_test == 0) { |
1110 if ($header_skip_qt_begin_header_test == 0) { |
1090 if ($qt_begin_header_found == 0) { |
1111 if ($qt_begin_header_found == 0) { |
1091 print "WARNING: $iheader does not include QT_BEGIN_HEADER\n"; |
1112 print "WARNING: $iheader does not include QT_BEGIN_HEADER\n"; |
1092 } |
1113 } |
1093 |
1114 |