Changeset 846 for trunk/bin/syncqt
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/bin/syncqt
r769 r846 4 4 # Synchronizes Qt header files - internal development tool. 5 5 # 6 # Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).6 # Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 7 7 # Contact: Nokia Corporation (qt-info@nokia.com) 8 8 # … … 43 43 "QtScriptTools" => "$basedir/src/scripttools", 44 44 "Qt3Support" => "$basedir/src/qt3support", 45 "ActiveQt" => "$basedir/src/activeqt /container;$basedir/src/activeqt/control;$basedir/src/activeqt/shared",45 "ActiveQt" => "$basedir/src/activeqt", 46 46 "QtTest" => "$basedir/src/testlib", 47 "QtAssistant" => "$basedir/tools/assistant/compat/lib",48 47 "QtHelp" => "$basedir/tools/assistant/lib", 49 48 "QtDesigner" => "$basedir/tools/designer/src/lib", … … 53 52 "phonon" => "$basedir/src/phonon", 54 53 "QtMultimedia" => "$basedir/src/multimedia", 54 "QtMeeGoGraphicsSystemHelper" => "$basedir/tools/qmeegographicssystemhelper", 55 55 ); 56 56 my %moduleheaders = ( # restrict the module headers to those found in relative path … … 64 64 my $module = 0; 65 65 my $showonly = 0; 66 my $quiet = 0; 66 67 my $remove_stale = 1; 67 68 my $force_win = 0; … … 94 95 print " -showonly Show action but not perform (default: " . ($showonly ? "yes" : "no") . ")\n"; 95 96 print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n"; 97 print " -quiet Only report problems, not activity (default: " . ($quiet ? "yes" : "no") . ")\n"; 96 98 print " -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR> Create headers for <NAME> with original headers in <HEADERDIR> relative to <PROFILEDIR> \n"; 97 99 print " -help This help\n"; … … 146 148 if(open(F, "<$iheader")) { 147 149 while(<F>) { 148 149 150 151 150 chomp; 151 return 0 if(/^\#pragma qt_no_master_include$/); 152 } 153 close(F); 152 154 } else { 153 155 return 0; 154 156 } 155 157 return 1; … … 168 170 my ($iheader) = @_; 169 171 if(basename($iheader) eq "qglobal.h") { 170 172 push @ret, "QtGlobal"; 171 173 } elsif(basename($iheader) eq "qendian.h") { 172 174 push @ret, "QtEndian"; 173 175 } elsif(basename($iheader) eq "qconfig.h") { 174 176 push @ret, "QtConfig"; 175 177 } elsif(basename($iheader) eq "qplugin.h") { 176 178 push @ret, "QtPlugin"; 177 179 } elsif(basename($iheader) eq "qalgorithms.h") { 178 180 push @ret, "QtAlgorithms"; 179 181 } elsif(basename($iheader) eq "qcontainerfwd.h") { 180 182 push @ret, "QtContainerFwd"; 181 183 } elsif(basename($iheader) eq "qdebug.h") { 182 184 push @ret, "QtDebug"; … … 186 188 push @ret, "Qt" 187 189 } elsif(basename($iheader) eq "qssl.h") { 188 190 push @ret, "QSsl"; 189 191 } elsif(basename($iheader) eq "qtest.h") { 190 192 push @ret, "QTest" … … 204 206 my $line = $_; 205 207 chomp $line; 206 208 chop $line if ($line =~ /\r$/); 207 209 if($line =~ /^\#/) { 208 210 if($line =~ /\\$/) { … … 212 214 } 213 215 } 214 215 push(@ret, "$1") if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/);216 217 } 218 216 return @ret if($line =~ m/^#pragma qt_sync_stop_processing/); 217 push(@ret, $1) if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/); 218 $line = 0; 219 } 220 if($line) { 219 221 $line =~ s,//.*$,,; #remove c++ comments 220 221 222 223 222 $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro 223 $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro 224 $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro 225 $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro 224 226 $parsable .= " " . $line; 225 227 } 226 228 } 227 229 close(F); … … 259 261 $last_definition = $i + 1; 260 262 last BLOCK; 261 263 } 262 264 } 263 265 } … … 267 269 $definition = substr($parsable, $last_definition, $i - $last_definition + 1); 268 270 $last_definition = $i + 1; 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 271 } elsif($character eq "}") { 272 # a naked } must be a namespace ending 273 # if it's not a namespace, it's eaten by the loop above 274 pop @namespaces; 275 $last_definition = $i + 1; 276 } 277 278 if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) / 279 && substr($parsable, $i+1, 1) eq "{") { 280 push @namespaces, $1; 281 282 # Eat the opening { so that the condensing loop above doesn't see it 283 $i++; 284 $last_definition = $i + 1; 285 } 284 286 285 287 if($definition) { 286 288 $definition =~ s=[\n\r]==g; 287 289 my @symbols; 288 290 if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) { 289 291 push @symbols, $1; 290 292 } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) { 291 293 push @symbols, $2; 292 294 } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) { 293 295 push @symbols, $4; 294 296 } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) { 295 push @symbols, "Q" . $1 . "Iterator"; 296 push @symbols, "QMutable" . $1 . "Iterator"; 297 } 298 299 foreach (@symbols) { 300 my $symbol = $_; 301 $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces); 302 push @ret, $symbol 303 if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q 304 || $symbol =~ /^Phonon::/); # or in the Phonon namespace 297 push @symbols, "Q" . $1 . "Iterator"; 298 push @symbols, "QMutable" . $1 . "Iterator"; 299 } 300 301 foreach my $symbol (@symbols) { 302 $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces); 303 push @ret, $symbol 304 if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q 305 || $symbol =~ /^Phonon::/); # or in the Phonon namespace 305 306 } 306 307 } … … 310 311 311 312 ###################################################################### 312 # Syntax: syncHeader(header, iheader, copy )313 # Syntax: syncHeader(header, iheader, copy, timestamp) 313 314 # Params: header, string, filename to create "symlink" for 314 315 # iheader, string, destination name of symlink 315 316 # copy, forces header to be a copy of iheader 317 # timestamp, the requested modification time if copying 316 318 # 317 319 # Purpose: Syncronizes header to iheader … … 319 321 ###################################################################### 320 322 sub syncHeader { 321 my ($header, $iheader, $copy ) = @_;323 my ($header, $iheader, $copy, $ts) = @_; 322 324 $iheader =~ s=\\=/=g; 323 325 $header =~ s=\\=/=g; 324 326 return copyFile($iheader, $header) if($copy); 325 327 326 unless(-e "$header") {328 unless(-e $header) { 327 329 my $header_dir = dirname($header); 328 mkpath $header_dir, 0777;330 mkpath $header_dir, !$quiet; 329 331 330 332 #write it … … 333 335 print HEADER "#include \"$iheader_out\"\n"; 334 336 close HEADER; 337 utime(time, $ts, $header) or die "$iheader, $header"; 335 338 return 1; 336 339 } … … 356 359 #setup 357 360 my $ret = $file; 361 $ret =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; 358 362 my $file_dir = dirname($file); 359 363 if($file_dir eq ".") { … … 361 365 $file_dir =~ s=\\=/=g; 362 366 } 363 $file_dir =~ s,/cygdrive/([a-zA-Z])/,$1: ,g;367 $file_dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; 364 368 if($dir eq ".") { 365 369 $dir = getcwd(); … … 367 371 } 368 372 $dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; 369 return basename($file) if( "$file_dir" eq "$dir");373 return basename($file) if($file_dir eq $dir); 370 374 371 375 #guts … … 429 433 if (! -e $file1) { return 1; } 430 434 if (! -e $file2) { return -1; } 431 return $file1contents ne $file2contents ? (stat( "$file2"))[9] <=> (stat("$file1"))[9] : 0;435 return $file1contents ne $file2contents ? (stat($file2))[9] <=> (stat($file1))[9] : 0; 432 436 } 433 437 … … 452 456 close I; 453 457 if ( open(I, "< " . $ifile) ) { 454 455 456 457 458 459 458 local $/; 459 binmode I; 460 $ifilecontents = <I>; 461 close I; 462 $copy = fileCompare($file, $ifile); 463 $knowdiff = 0, 460 464 } else { 461 462 465 $copy = -1; 466 $knowdiff = 1; 463 467 } 464 468 465 469 if ( $knowdiff || ($filecontents ne $ifilecontents) ) { 466 if ( $copy > 0 ) { 467 my $file_dir = dirname($file); 468 mkpath $file_dir, 0777 unless(-e "$file_dir"); 469 open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; 470 local $/; 471 binmode O; 472 print O $ifilecontents; 473 close O; 474 return 1; 475 } elsif ( $copy < 0 ) { 476 my $ifile_dir = dirname($ifile); 477 mkpath $ifile_dir, 0777 unless(-e "$ifile_dir"); 478 open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)"; 479 local $/; 480 binmode O; 481 print O $filecontents; 482 close O; 483 return 1; 484 } 470 if ( $copy > 0 ) { 471 my $file_dir = dirname($file); 472 mkpath $file_dir, !$quiet unless(-e $file_dir); 473 open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; 474 local $/; 475 binmode O; 476 print O $ifilecontents; 477 close O; 478 utime time, (stat($ifile))[9], $file; 479 return 1; 480 } elsif ( $copy < 0 ) { 481 my $ifile_dir = dirname($ifile); 482 mkpath $ifile_dir, !$quiet unless(-e $ifile_dir); 483 open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)"; 484 local $/; 485 binmode O; 486 print O $filecontents; 487 close O; 488 utime time, (stat($file))[9], $ifile; 489 return 1; 490 } 485 491 } 486 492 return 0; … … 501 507 502 508 if ($isunix) { 503 print "symlink created for $file " ;509 print "symlink created for $file " unless $quiet; 504 510 if ( $force_relative && ($ifile =~ /^$basedir/)) { 505 511 my $t = getcwd(); … … 509 515 $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 ); 510 516 $file =~ s-^$basedir/-$p-; 511 print " ($file)\n" ;512 } 513 print "\n" ;517 print " ($file)\n" unless $quiet; 518 } 519 print "\n" unless $quiet; 514 520 return symlink($file, $ifile); 515 521 } … … 566 572 #parse 567 573 my $arg = shift @ARGV; 568 if ("$arg" eq "-h" || "$arg" eq "-help" || "$arg" eq "?") { 569 $var = "show_help"; 570 $val = "yes"; 571 } elsif("$arg" eq "-copy") { 572 $var = "copy"; 573 $val = "yes"; 574 } elsif("$arg" eq "-o" || "$arg" eq "-outdir") { 575 $var = "output"; 576 $val = shift @ARGV; 577 } elsif("$arg" eq "-showonly" || "$arg" eq "-remove-stale" || "$arg" eq "-windows" || 578 "$arg" eq "-relative" || "$arg" eq "-check-includes") { 579 $var = substr($arg, 1); 580 $val = "yes"; 581 } elsif("$arg" =~ /^-no-(.*)$/) { 582 $var = $1; 583 $val = "no"; 584 #these are for commandline compat 585 } elsif("$arg" eq "-inc") { 586 $var = "output"; 587 $val = shift @ARGV; 588 } elsif("$arg" eq "-module") { 589 $var = "module"; 590 $val = shift @ARGV; 591 } elsif("$arg" eq "-separate-module") { 592 $var = "separate-module"; 593 $val = shift @ARGV; 594 } elsif("$arg" eq "-show") { 595 $var = "showonly"; 596 $val = "yes"; 597 } elsif("$arg" eq "-base-dir") { 574 if ($arg eq "-h" || $arg eq "-help" || $arg eq "?") { 575 $var = "show_help"; 576 $val = "yes"; 577 } elsif($arg eq "-copy") { 578 $var = "copy"; 579 $val = "yes"; 580 } elsif($arg eq "-o" || $arg eq "-outdir") { 581 $var = "output"; 582 $val = shift @ARGV; 583 } elsif($arg eq "-showonly" || $arg eq "-remove-stale" || $arg eq "-windows" || 584 $arg eq "-relative" || $arg eq "-check-includes") { 585 $var = substr($arg, 1); 586 $val = "yes"; 587 } elsif($arg =~ /^-no-(.*)$/) { 588 $var = $1; 589 $val = "no"; 590 #these are for commandline compat 591 } elsif($arg eq "-inc") { 592 $var = "output"; 593 $val = shift @ARGV; 594 } elsif($arg eq "-module") { 595 $var = "module"; 596 $val = shift @ARGV; 597 } elsif($arg eq "-separate-module") { 598 $var = "separate-module"; 599 $val = shift @ARGV; 600 } elsif($arg eq "-show") { 601 $var = "showonly"; 602 $val = "yes"; 603 } elsif($arg eq "-quiet") { 604 $var = "quiet"; 605 $val = "yes"; 606 } elsif($arg eq "-base-dir") { 598 607 # skip, it's been dealt with at the top of the file 599 608 shift @ARGV; 600 609 next; 601 } elsif("$arg" eq '*') {602 # workaround for windows 9x where "%*" expands to "*"603 $var = 1;604 610 } 605 611 606 612 #do something 607 if(!$var || "$var" eq "show_help") { 608 print "Unknown option: $arg\n\n" if(!$var); 609 showUsage(); 610 } elsif ("$var" eq "copy") { 611 if("$val" eq "yes") { 612 $copy_headers++; 613 } elsif($showonly) { 614 $copy_headers--; 615 } 616 } elsif ("$var" eq "showonly") { 617 if("$val" eq "yes") { 618 $showonly++; 619 } elsif($showonly) { 620 $showonly--; 621 } 622 } elsif ("$var" eq "check-includes") { 623 if("$val" eq "yes") { 624 $check_includes++; 625 } elsif($check_includes) { 626 $check_includes--; 627 } 628 } elsif ("$var" eq "remove-stale") { 629 if("$val" eq "yes") { 630 $remove_stale++; 631 } elsif($remove_stale) { 632 $remove_stale--; 633 } 634 } elsif ("$var" eq "windows") { 635 if("$val" eq "yes") { 636 $force_win++; 637 } elsif($force_win) { 638 $force_win--; 639 } 640 } elsif ("$var" eq "relative") { 641 if("$val" eq "yes") { 642 $force_relative++; 643 } elsif($force_relative) { 644 $force_relative--; 645 } 646 } elsif ("$var" eq "module") { 647 print "module :$val:\n"; 648 die "No such module: $val" unless(defined $modules{$val}); 649 push @modules_to_sync, $val; 650 } elsif ("$var" eq "separate-module") { 613 if(!$var || $var eq "show_help") { 614 print "Unknown option: $arg\n\n" if(!$var); 615 showUsage(); 616 } elsif ($var eq "copy") { 617 if($val eq "yes") { 618 $copy_headers++; 619 } elsif($showonly) { 620 $copy_headers--; 621 } 622 } elsif ($var eq "showonly") { 623 if($val eq "yes") { 624 $showonly++; 625 } elsif($showonly) { 626 $showonly--; 627 } 628 } elsif ($var eq "quiet") { 629 if($val eq "yes") { 630 $quiet++; 631 } elsif($quiet) { 632 $quiet--; 633 } 634 } elsif ($var eq "check-includes") { 635 if($val eq "yes") { 636 $check_includes++; 637 } elsif($check_includes) { 638 $check_includes--; 639 } 640 } elsif ($var eq "remove-stale") { 641 if($val eq "yes") { 642 $remove_stale++; 643 } elsif($remove_stale) { 644 $remove_stale--; 645 } 646 } elsif ($var eq "windows") { 647 if($val eq "yes") { 648 $force_win++; 649 } elsif($force_win) { 650 $force_win--; 651 } 652 } elsif ($var eq "relative") { 653 if($val eq "yes") { 654 $force_relative++; 655 } elsif($force_relative) { 656 $force_relative--; 657 } 658 } elsif ($var eq "module") { 659 print "module :$val:\n" unless $quiet; 660 die "No such module: $val" unless(defined $modules{$val}); 661 push @modules_to_sync, $val; 662 } elsif ($var eq "separate-module") { 651 663 my ($module, $prodir, $headerdir) = split(/:/, $val); 652 664 $modules{$module} = $prodir; … … 655 667 $create_uic_class_map = 0; 656 668 $create_private_headers = 0; 657 } elsif ( "$var"eq "output") {658 659 660 661 662 663 664 665 666 667 669 } elsif ($var eq "output") { 670 my $outdir = $val; 671 if(checkRelative($outdir)) { 672 $out_basedir = getcwd(); 673 chomp $out_basedir; 674 $out_basedir .= "/" . $outdir; 675 } else { 676 $out_basedir = $outdir; 677 } 678 # \ -> / 679 $out_basedir =~ s=\\=/=g; 668 680 } 669 681 } … … 673 685 674 686 # create path 675 mkpath "$out_basedir/include", 0777; 687 mkpath "$out_basedir/include", !$quiet; 688 mkpath "$out_basedir/include/Qt", !$quiet; 676 689 677 690 my @ignore_headers = (); … … 681 694 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" ); 682 695 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" ); 683 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}" ); 684 685 foreach (@modules_to_sync) { 696 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}" ); 697 my %colliding_headers = (); 698 my %inject_headers = ( "$basedir/src/corelib/global" => ( "qconfig.h" ) ); # all from build dir 699 700 foreach my $lib (@modules_to_sync) { 686 701 #iteration info 687 my $lib = $_; 688 my $dir = "$modules{$lib}"; 702 my $dir = $modules{$lib}; 689 703 my $pathtoheaders = ""; 690 $pathtoheaders = "$moduleheaders{$lib}"if ($moduleheaders{$lib});704 $pathtoheaders = $moduleheaders{$lib} if ($moduleheaders{$lib}); 691 705 692 706 #information used after the syncing … … 701 715 #get dependencies 702 716 if(-e "$dir/" . basename($dir) . ".pro") { 703 if(open(F, "<$dir/" . basename($dir) . ".pro")) { 704 while(<F>) { 705 my $line = $_; 706 chomp $line; 707 if($line =~ /^ *QT *\+?= *([^\r\n]*)/) { 708 foreach(split(/ /, "$1")) { 709 $master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core"); 710 $master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui"); 711 $master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network"); 712 $master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg"); 713 $master_contents .= "#include <QtDeclarative/QtDeclarative>\n" if("$_" eq "declarative"); 714 $master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script"); 715 $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools"); 716 $master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support"); 717 $master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql"); 718 $master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml"); 719 $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns"); 720 $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl"); 721 $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg"); 722 } 723 } 724 } 725 close(F); 726 } 717 if(open(F, "<$dir/" . basename($dir) . ".pro")) { 718 while(my $line = <F>) { 719 chomp $line; 720 if($line =~ /^ *QT *\+?= *([^\r\n]*)/) { 721 foreach(split(/ /, $1)) { 722 $master_contents .= "#include <QtCore/QtCore>\n" if($_ eq "core"); 723 $master_contents .= "#include <QtGui/QtGui>\n" if($_ eq "gui"); 724 $master_contents .= "#include <QtNetwork/QtNetwork>\n" if($_ eq "network"); 725 $master_contents .= "#include <QtSvg/QtSvg>\n" if($_ eq "svg"); 726 $master_contents .= "#include <QtDeclarative/QtDeclarative>\n" if($_ eq "declarative"); 727 $master_contents .= "#include <QtScript/QtScript>\n" if($_ eq "script"); 728 $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if($_ eq "scripttools"); 729 $master_contents .= "#include <Qt3Support/Qt3Support>\n" if($_ eq "qt3support"); 730 $master_contents .= "#include <QtSql/QtSql>\n" if($_ eq "sql"); 731 $master_contents .= "#include <QtXml/QtXml>\n" if($_ eq "xml"); 732 $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if($_ eq "xmlpatterns"); 733 $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if($_ eq "opengl"); 734 $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if($_ eq "openvg"); 735 } 736 } 737 } 738 close(F); 739 } 727 740 } 728 741 729 742 #remove the old files 730 743 if($remove_stale) { 731 my @subdirs = ("$out_basedir/include/$lib"); 732 foreach (@subdirs) { 733 my $subdir = "$_"; 734 if (opendir DIR, "$subdir") { 735 while(my $t = readdir(DIR)) { 736 my $file = "$subdir/$t"; 737 if(-d "$file") { 738 push @subdirs, "$file" unless($t eq "." || $t eq ".."); 739 } else { 740 my @files = ("$file"); 741 #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t"); 742 foreach (@files) { 743 my $file = $_; 744 my $remove_file = 0; 745 if(open(F, "<$file")) { 746 while(<F>) { 747 my $line = $_; 748 chomp $line; 749 if($line =~ /^\#include \"([^\"]*)\"$/) { 750 my $include = $1; 751 $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); 752 $remove_file = 1 unless(-e "$include"); 753 } else { 754 $remove_file = 0; 755 last; 756 } 757 } 758 close(F); 759 unlink "$file" if($remove_file); 760 } 761 } 762 } 763 } 764 closedir DIR; 765 } 766 767 } 744 my @subdirs = ("$out_basedir/include/$lib"); 745 foreach my $subdir (@subdirs) { 746 if (opendir DIR, $subdir) { 747 while(my $t = readdir(DIR)) { 748 my $file = "$subdir/$t"; 749 if(-d $file) { 750 push @subdirs, $file unless($t eq "." || $t eq ".."); 751 } else { 752 my @files = ($file); 753 #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t"); 754 foreach my $file (@files) { 755 my $remove_file = 0; 756 if(open(F, "<$file")) { 757 while(my $line = <F>) { 758 chomp $line; 759 if($line =~ /^\#include \"([^\"]*)\"$/) { 760 my $include = $1; 761 $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); 762 $remove_file = 1 unless(-e $include); 763 } else { 764 $remove_file = 0; 765 last; 766 } 767 } 768 close(F); 769 unlink $file if($remove_file); 770 } 771 } 772 } 773 } 774 closedir DIR; 775 } 776 777 } 768 778 } 769 779 770 780 #create the new ones 771 foreach (split(/;/, $dir)) { 772 my $current_dir = "$_"; 773 my $headers_dir = $current_dir; 781 foreach my $current_dir (split(/;/, $dir)) { 782 my $headers_dir = $current_dir; 774 783 $headers_dir .= "/$pathtoheaders" if ($pathtoheaders); 775 784 #calc subdirs 776 785 my @subdirs = ($headers_dir); 777 foreach (@subdirs) { 778 my $subdir = "$_"; 779 opendir DIR, "$subdir" or next; 786 foreach my $subdir (@subdirs) { 787 opendir DIR, $subdir or next; 780 788 while(my $t = readdir(DIR)) { 781 789 push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && 782 790 !($t eq "..") && !($t eq ".obj") && 783 791 !($t eq ".moc") && !($t eq ".rcc") && 784 792 !($t eq ".uic") && !($t eq "build")); … … 788 796 789 797 #calc files and "copy" them 790 foreach (@subdirs) { 791 my $subdir = "$_"; 792 my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0); 793 foreach (@headers) { 794 my $header = "$_"; 795 $header = 0 if("$header" =~ /^ui_.*.h/); 798 foreach my $subdir (@subdirs) { 799 my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0); 800 if (defined $inject_headers{$subdir}) { 801 foreach my $if ($inject_headers{$subdir}) { 802 @headers = grep(!/^\Q$if\E$/, @headers); #in case we configure'd previously 803 push @headers, "*".$if; 804 } 805 } 806 foreach my $header (@headers) { 807 my $shadow = ($header =~ s/^\*//); 808 $header = 0 if($header =~ /^ui_.*.h/); 796 809 foreach (@ignore_headers) { 797 $header = 0 if( "$header" eq "$_");810 $header = 0 if($header eq $_); 798 811 } 799 812 if($header) { 800 801 802 803 804 805 806 807 $public_header = 0 if("$header" eq "$_");808 809 813 my $header_copies = 0; 814 #figure out if it is a public header 815 my $public_header = $header; 816 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { 817 $public_header = 0; 818 } else { 819 foreach (@ignore_for_master_contents) { 820 $public_header = 0 if($header eq $_); 821 } 822 } 810 823 811 824 my $iheader = $subdir . "/" . $header; 812 my @classes = $public_header ? classNames($iheader) : (); 825 $iheader =~ s/^\Q$basedir\E/$out_basedir/ if ($shadow); 826 my @classes = $public_header ? classNames($iheader) : (); 813 827 if($showonly) { 814 828 print "$header [$lib]\n"; 815 816 817 829 foreach(@classes) { 830 print "SYMBOL: $_\n"; 831 } 818 832 } else { 819 #find out all the places it goes.. 820 my @headers; 821 if ($public_header) { 822 @headers = ( "$out_basedir/include/$lib/$header" ); 823 push @headers, "$out_basedir/include/Qt/$header" 824 if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/); 825 826 foreach(@classes) { 827 my $header_base = basename($header); 828 my $class = $_; 829 # Strip namespaces: 830 $class =~ s/^.*:://; 831 # if ($class =~ m/::/) { 832 # class =~ s,::,/,g; 833 # } 834 $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n"; 835 $header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0)); 836 837 # KDE-Compat headers for Phonon 838 if ($lib eq "phonon") { 839 $header_copies++ if (syncHeader("$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0)); 840 } 841 } 842 } elsif ($create_private_headers) { 843 @headers = ( "$out_basedir/include/$lib/private/$header" ); 844 push @headers, "$out_basedir/include/Qt/private/$header" 845 if ("$lib" ne "phonon"); 846 } 847 foreach(@headers) { #sync them 848 $header_copies++ if(syncHeader($_, $iheader, $copy_headers)); 849 } 850 851 if($public_header) { 852 #put it into the master file 853 $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude($iheader)); 854 855 #deal with the install directives 856 if($public_header) { 857 my $pri_install_iheader = fixPaths($iheader, $current_dir); 858 foreach(@classes) { 859 my $class = $_; 860 # Strip namespaces: 861 $class =~ s/^.*:://; 862 # if ($class =~ m/::/) { 863 # $class =~ s,::,/,g; 864 # } 865 my $class_header = fixPaths("$out_basedir/include/$lib/$class", 866 $current_dir) . " "; 867 $pri_install_classes .= $class_header 868 unless($pri_install_classes =~ $class_header); 869 } 870 $pri_install_files.= "$pri_install_iheader ";; 871 } 872 } 873 else { 874 my $pri_install_iheader = fixPaths($iheader, $current_dir); 875 $pri_install_pfiles.= "$pri_install_iheader ";; 876 } 833 my $ts = (stat($iheader))[9]; 834 #find out all the places it goes.. 835 my @headers; 836 if ($public_header) { 837 @headers = ( "$out_basedir/include/$lib/$header" ); 838 839 # write forwarding headers to include/Qt 840 if ($lib ne "phonon" && $subdir =~ /^$basedir\/src/) { 841 my $file_name = "$out_basedir/include/Qt/$header"; 842 my $file_op = '>'; 843 my $header_content = ''; 844 if (exists $colliding_headers{$file_name}) { 845 $file_op = '>>'; 846 } else { 847 $colliding_headers{$file_name} = 1; 848 my $warning_msg = 'Inclusion of header files from include/Qt is deprecated.'; 849 $header_content = "#ifndef QT_NO_QT_INCLUDE_WARN\n" . 850 " #if defined(__GNUC__)\n" . 851 " #warning \"$warning_msg\"\n" . 852 " #elif defined(_MSC_VER)\n" . 853 " #pragma message(\"WARNING: $warning_msg\")\n" . 854 " #endif\n". 855 "#endif\n\n"; 856 } 857 $header_content .= '#include "' . "../$lib/$header" . "\"\n"; 858 open HEADERFILE, $file_op, $file_name or die "unable to open '$file_name' : $!\n"; 859 print HEADERFILE $header_content; 860 close HEADERFILE; 861 } 862 863 foreach my $full_class (@classes) { 864 my $header_base = basename($header); 865 # Strip namespaces: 866 my $class = $full_class; 867 $class =~ s/^.*:://; 868 # if ($class =~ m/::/) { 869 # class =~ s,::,/,g; 870 # } 871 $class_lib_map_contents .= "QT_CLASS_LIB($full_class, $lib, $header_base)\n"; 872 $header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0, $ts)); 873 874 # KDE-Compat headers for Phonon 875 if ($lib eq "phonon") { 876 $header_copies++ if (syncHeader("$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0, $ts)); 877 } 878 } 879 } elsif ($create_private_headers) { 880 @headers = ( "$out_basedir/include/$lib/private/$header" ); 881 } 882 foreach(@headers) { #sync them 883 $header_copies++ if(syncHeader($_, $iheader, $copy_headers && !$shadow, $ts)); 884 } 885 886 if($public_header) { 887 #put it into the master file 888 $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude($iheader)); 889 890 #deal with the install directives 891 if($public_header) { 892 my $pri_install_iheader = fixPaths($iheader, $current_dir); 893 foreach my $class (@classes) { 894 # Strip namespaces: 895 $class =~ s/^.*:://; 896 # if ($class =~ m/::/) { 897 # $class =~ s,::,/,g; 898 # } 899 my $class_header = fixPaths("$out_basedir/include/$lib/$class", 900 $current_dir) . " "; 901 $pri_install_classes .= $class_header 902 unless($pri_install_classes =~ $class_header); 903 } 904 $pri_install_files.= "$pri_install_iheader ";; 905 } 906 } 907 else { 908 my $pri_install_iheader = fixPaths($iheader, $current_dir); 909 $pri_install_pfiles.= "$pri_install_iheader ";; 910 } 877 911 } 878 print "header created for $iheader ($header_copies)\n" if($header_copies > 0);912 print "header created for $iheader ($header_copies)\n" if($header_copies > 0 && !$quiet); 879 913 } 880 914 } … … 887 921 unless($showonly) { 888 922 my @master_includes; 889 890 923 push @master_includes, "$out_basedir/include/$lib/$lib"; 924 push @master_includes, "$out_basedir/include/phonon_compat/Phonon/Phonon" if ($lib eq "phonon"); 891 925 foreach my $master_include (@master_includes) { 892 926 #generate the "master" include file 893 $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too 894 if($master_include && -e "$master_include") { 927 my @tmp = split(/;/,$modules{$lib}); 928 $pri_install_files .= fixPaths($master_include, $tmp[0]) . " "; #get the master file installed too 929 if($master_include && -e $master_include) { 895 930 open MASTERINCLUDE, "<$master_include"; 896 931 local $/; … … 903 938 if($master_include && $master_contents) { 904 939 my $master_dir = dirname($master_include); 905 mkpath $master_dir, 0777;906 print "header (master) created for $lib\n" ;940 mkpath $master_dir, !$quiet; 941 print "header (master) created for $lib\n" unless $quiet; 907 942 open MASTERINCLUDE, ">$master_include"; 908 print MASTERINCLUDE "$master_contents";943 print MASTERINCLUDE $master_contents; 909 944 close MASTERINCLUDE; 910 945 } … … 912 947 913 948 #handle the headers.pri for each module 914 915 916 917 949 my $headers_pri_contents = ""; 950 $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n"; 951 $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n"; 952 $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n"; 918 953 my $headers_pri_file = "$out_basedir/include/$lib/headers.pri"; 919 if(-e "$headers_pri_file") {954 if(-e $headers_pri_file) { 920 955 open HEADERS_PRI_FILE, "<$headers_pri_file"; 921 956 local $/; … … 928 963 if($headers_pri_file && $master_contents) { 929 964 my $headers_pri_dir = dirname($headers_pri_file); 930 mkpath $headers_pri_dir, 0777;931 print "headers.pri file created for $lib\n" ;965 mkpath $headers_pri_dir, !$quiet; 966 print "headers.pri file created for $lib\n" unless $quiet; 932 967 open HEADERS_PRI_FILE, ">$headers_pri_file"; 933 print HEADERS_PRI_FILE "$headers_pri_contents";968 print HEADERS_PRI_FILE $headers_pri_contents; 934 969 close HEADERS_PRI_FILE; 935 970 } … … 938 973 unless($showonly || !$create_uic_class_map) { 939 974 my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h"; 940 if(-e "$class_lib_map") {941 942 943 944 945 946 947 975 if(-e $class_lib_map) { 976 open CLASS_LIB_MAP, "<$class_lib_map"; 977 local $/; 978 binmode CLASS_LIB_MAP; 979 my $old_class_lib_map_contents = <CLASS_LIB_MAP>; 980 close CLASS_LIB_MAP; 981 $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms 982 $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents); 948 983 } 949 984 if($class_lib_map) { 950 951 mkpath $class_lib_map_dir, 0777;952 953 print CLASS_LIB_MAP "$class_lib_map_contents";954 985 my $class_lib_map_dir = dirname($class_lib_map); 986 mkpath $class_lib_map_dir, !$quiet; 987 open CLASS_LIB_MAP, ">$class_lib_map"; 988 print CLASS_LIB_MAP $class_lib_map_contents; 989 close CLASS_LIB_MAP; 955 990 } 956 991 } 957 992 958 993 if($check_includes) { 959 for (keys(%modules)) { 960 #iteration info 961 my $lib = $_; 962 my $dir = "$modules{$lib}"; 963 foreach (split(/;/, $dir)) { 964 my $current_dir = "$_"; 965 #calc subdirs 966 my @subdirs = ($current_dir); 967 foreach (@subdirs) { 968 my $subdir = "$_"; 969 opendir DIR, "$subdir"; 970 while(my $t = readdir(DIR)) { 994 for my $lib (keys(%modules)) { 995 #calc subdirs 996 my @subdirs = ($modules{$lib}); 997 foreach my $subdir (@subdirs) { 998 opendir DIR, $subdir or die "Huh, directory ".$subdir." cannot be opened."; 999 while(my $t = readdir(DIR)) { 971 1000 push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && 972 1001 !($t eq "..") && !($t eq ".obj") && 973 1002 !($t eq ".moc") && !($t eq ".rcc") && 974 1003 !($t eq ".uic") && !($t eq "build")); 975 } 976 closedir DIR; 977 } 978 979 foreach (@subdirs) { 980 my $subdir = "$_"; 1004 } 1005 closedir DIR; 1006 } 1007 1008 foreach my $subdir (@subdirs) { 981 1009 my $header_skip_qt_module_test = 0; 982 1010 foreach(@ignore_for_qt_module_check) { 983 1011 foreach (split(/;/, $_)) { 984 $header_skip_qt_module_test = 1 if ( "$subdir"=~ /^$_/);1012 $header_skip_qt_module_test = 1 if ($subdir =~ /^$_/); 985 1013 } 986 1014 } 987 my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0); 988 foreach (@headers) { 989 my $header = "$_"; 1015 my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0); 1016 foreach my $header (@headers) { 990 1017 my $header_skip_qt_begin_header_test = 0; 991 1018 my $header_skip_qt_begin_namespace_test = 0; 992 $header = 0 if("$header"=~ /^ui_.*.h/);993 994 $header = 0 if("$header" eq "$_");995 996 997 998 999 1000 1001 1002 $public_header = 0 if("$header" eq "$_");1003 1004 1005 1006 $public_header = 0 if("$header" eq "$_");1007 1019 $header = 0 if($header =~ /^ui_.*.h/); 1020 foreach (@ignore_headers) { 1021 $header = 0 if($header eq $_); 1022 } 1023 if($header) { 1024 my $public_header = $header; 1025 if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { 1026 $public_header = 0; 1027 } else { 1028 foreach (@ignore_for_master_contents) { 1029 $public_header = 0 if($header eq $_); 1030 } 1031 if($public_header) { 1032 foreach (@ignore_for_include_check) { 1033 $public_header = 0 if($header eq $_); 1034 } 1008 1035 foreach(@ignore_for_qt_begin_header_check) { 1009 $header_skip_qt_begin_header_test = 1 if ( "$header" eq "$_");1036 $header_skip_qt_begin_header_test = 1 if ($header eq $_); 1010 1037 } 1011 1038 foreach(@ignore_for_qt_begin_namespace_check) { 1012 $header_skip_qt_begin_namespace_test = 1 if ( "$header" eq "$_");1039 $header_skip_qt_begin_namespace_test = 1 if ($header eq $_); 1013 1040 } 1014 1015 1016 1017 1018 1019 1041 } 1042 } 1043 1044 my $iheader = $subdir . "/" . $header; 1045 if($public_header) { 1046 if(open(F, "<$iheader")) { 1020 1047 my $qt_module_found = 0; 1021 1022 1023 1024 1025 1026 1027 1028 1048 my $qt_begin_header_found = 0; 1049 my $qt_end_header_found = 0; 1050 my $qt_begin_namespace_found = 0; 1051 my $qt_end_namespace_found = 0; 1052 my $line; 1053 while($line = <F>) { 1054 chomp $line; 1055 my $output_line = 1; 1029 1056 if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) { 1030 last; 1031 } elsif($line =~ /^ *\# *include/) { 1032 my $include = $line; 1033 if($line =~ /<.*>/) { 1034 $include =~ s,.*<(.*)>.*,$1,; 1035 } elsif($line =~ /".*"/) { 1036 $include =~ s,.*"(.*)".*,$1,; 1037 } else { 1038 $include = 0; 1039 } 1040 if($include) { 1041 for (keys(%modules)) { 1042 my $trylib = $_; 1043 if(-e "$out_basedir/include/$trylib/$include") { 1044 print "WARNING: $iheader includes $include when it should include $trylib/$include\n"; 1045 } 1046 } 1047 } 1048 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) { 1049 $qt_begin_header_found = 1; 1050 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) { 1051 $qt_end_header_found = 1; 1052 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) { 1053 $qt_begin_namespace_found = 1; 1054 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) { 1055 $qt_end_namespace_found = 1; 1057 last; 1058 } elsif($line =~ /^ *\# *include/) { 1059 my $include = $line; 1060 if($line =~ /<.*>/) { 1061 $include =~ s,.*<(.*)>.*,$1,; 1062 } elsif($line =~ /".*"/) { 1063 $include =~ s,.*"(.*)".*,$1,; 1064 } else { 1065 $include = 0; 1066 } 1067 if($include) { 1068 for my $trylib (keys(%modules)) { 1069 if(-e "$out_basedir/include/$trylib/$include") { 1070 print "WARNING: $iheader includes $include when it should include $trylib/$include\n"; 1071 } 1072 } 1073 } 1074 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) { 1075 $qt_begin_header_found = 1; 1076 } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) { 1077 $qt_end_header_found = 1; 1078 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) { 1079 $qt_begin_namespace_found = 1; 1080 } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) { 1081 $qt_end_namespace_found = 1; 1056 1082 } elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) { 1057 1083 $qt_module_found = 1; 1058 1084 } 1059 1085 } 1060 1086 if ($header_skip_qt_begin_header_test == 0) { 1061 1087 if ($qt_begin_header_found == 0) { … … 1083 1109 } 1084 1110 } 1085 close(F); 1086 } 1087 } 1088 } 1089 } 1090 } 1091 } 1111 close(F); 1112 } 1113 } 1114 } 1115 } 1116 } 1092 1117 } 1093 1118 }
Note:
See TracChangeset
for help on using the changeset viewer.