68 my $force_relative = 0; |
68 my $force_relative = 0; |
69 my $check_includes = 0; |
69 my $check_includes = 0; |
70 my $copy_headers = 0; |
70 my $copy_headers = 0; |
71 my $create_uic_class_map = 1; |
71 my $create_uic_class_map = 1; |
72 my $create_private_headers = 1; |
72 my $create_private_headers = 1; |
|
73 my $oneway = 0; |
73 my @modules_to_sync ; |
74 my @modules_to_sync ; |
74 $force_relative = 1 if ( -d "/System/Library/Frameworks" ); |
75 $force_relative = 1 if ( -d "/System/Library/Frameworks" ); |
75 my $out_basedir = $basedir; |
76 my $out_basedir = $basedir; |
76 $out_basedir =~ s=\\=/=g; |
77 $out_basedir =~ s=\\=/=g; |
|
78 my $out_subdir = 'include'; |
77 |
79 |
78 # functions ---------------------------------------------------------- |
80 # functions ---------------------------------------------------------- |
79 |
81 |
80 ###################################################################### |
82 ###################################################################### |
81 # Syntax: showUsage() |
83 # Syntax: showUsage() |
91 print " -remove-stale Removes stale headers (default: " . ($remove_stale ? "yes" : "no") . ")\n"; |
93 print " -remove-stale Removes stale headers (default: " . ($remove_stale ? "yes" : "no") . ")\n"; |
92 print " -relative Force relative symlinks (default: " . ($force_relative ? "yes" : "no") . ")\n"; |
94 print " -relative Force relative symlinks (default: " . ($force_relative ? "yes" : "no") . ")\n"; |
93 print " -windows Force platform to Windows (default: " . ($force_win ? "yes" : "no") . ")\n"; |
95 print " -windows Force platform to Windows (default: " . ($force_win ? "yes" : "no") . ")\n"; |
94 print " -showonly Show action but not perform (default: " . ($showonly ? "yes" : "no") . ")\n"; |
96 print " -showonly Show action but not perform (default: " . ($showonly ? "yes" : "no") . ")\n"; |
95 print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n"; |
97 print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n"; |
|
98 print " -outsubdir <DIR> Target subdir under outdir (default: $out_subdir)\n"; |
|
99 print " -public Create only public headers (default: " . ($create_private_headers ? "no" : "yes") . ")\n"; |
|
100 print " -oneway Don't sync back from outdir (default: " . ($oneway ? "yes" : "no") . ")\n"; |
96 print " -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR> Create headers for <NAME> with original headers in <HEADERDIR> relative to <PROFILEDIR> \n"; |
101 print " -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR> Create headers for <NAME> with original headers in <HEADERDIR> relative to <PROFILEDIR> \n"; |
97 print " -help This help\n"; |
102 print " -help This help\n"; |
98 exit 0; |
103 exit 0; |
99 } |
104 } |
100 |
105 |
192 push @ret, "QtConcurrentMap" |
197 push @ret, "QtConcurrentMap" |
193 } elsif(basename($iheader) eq "qtconcurrentfilter.h") { |
198 } elsif(basename($iheader) eq "qtconcurrentfilter.h") { |
194 push @ret, "QtConcurrentFilter" |
199 push @ret, "QtConcurrentFilter" |
195 } elsif(basename($iheader) eq "qtconcurrentrun.h") { |
200 } elsif(basename($iheader) eq "qtconcurrentrun.h") { |
196 push @ret, "QtConcurrentRun" |
201 push @ret, "QtConcurrentRun" |
|
202 } elsif(basename($iheader) eq "qaudio.h") { |
|
203 push @ret, "QAudio" |
197 } |
204 } |
198 |
205 |
199 my $parsable = ""; |
206 my $parsable = ""; |
200 if(open(F, "<$iheader")) { |
207 if(open(F, "<$iheader")) { |
201 while(<F>) { |
208 while(<F>) { |
433 # Syntax: copyFile(file, ifile) |
440 # Syntax: copyFile(file, ifile) |
434 # Params: file, string, filename to create duplicate for |
441 # Params: file, string, filename to create duplicate for |
435 # ifile, string, destination name of duplicate |
442 # ifile, string, destination name of duplicate |
436 # |
443 # |
437 # Purpose: Keeps files in sync so changes in the newer file will be |
444 # Purpose: Keeps files in sync so changes in the newer file will be |
438 # written to the other. |
445 # written to the other. Don't sync back if $oneway is set. |
439 # Returns: 1 if files were synced, else 0. |
446 # Returns: 1 if files were synced, else 0. |
440 # Warning: Dies if script cannot get write access. |
447 # Warning: Dies if script cannot get write access. |
441 ###################################################################### |
448 ###################################################################### |
442 sub copyFile |
449 sub copyFile |
443 { |
450 { |
459 $copy = -1; |
466 $copy = -1; |
460 $knowdiff = 1; |
467 $knowdiff = 1; |
461 } |
468 } |
462 |
469 |
463 if ( $knowdiff || ($filecontents ne $ifilecontents) ) { |
470 if ( $knowdiff || ($filecontents ne $ifilecontents) ) { |
464 if ( $copy > 0 ) { |
471 if ( $copy > 0 && !$oneway) { |
465 my $file_dir = dirname($file); |
472 my $file_dir = dirname($file); |
466 mkpath $file_dir, 0777 unless(-e "$file_dir"); |
473 mkpath $file_dir, 0777 unless(-e "$file_dir"); |
|
474 print "$file $ifile $copy\n"; |
467 open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; |
475 open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; |
468 local $/; |
476 local $/; |
469 binmode O; |
477 binmode O; |
470 print O $ifilecontents; |
478 print O $ifilecontents; |
471 close O; |
479 close O; |
597 shift @ARGV; |
605 shift @ARGV; |
598 next; |
606 next; |
599 } elsif("$arg" eq '*') { |
607 } elsif("$arg" eq '*') { |
600 # workaround for windows 9x where "%*" expands to "*" |
608 # workaround for windows 9x where "%*" expands to "*" |
601 $var = 1; |
609 $var = 1; |
|
610 } elsif("$arg" eq "-outsubdir") { |
|
611 $var = "outsubdir"; |
|
612 $val = shift @ARGV; |
|
613 } elsif("$arg" eq "-public") { |
|
614 $var = "public"; |
|
615 $val = "yes"; |
|
616 } elsif("$arg" eq "-oneway") { |
|
617 $var = "oneway"; |
|
618 $val = "yes"; |
602 } |
619 } |
603 |
620 |
604 #do something |
621 #do something |
605 if(!$var || "$var" eq "show_help") { |
622 if(!$var || "$var" eq "show_help") { |
606 print "Unknown option: $arg\n\n" if(!$var); |
623 print "Unknown option: $arg\n\n" if(!$var); |
639 if("$val" eq "yes") { |
656 if("$val" eq "yes") { |
640 $force_relative++; |
657 $force_relative++; |
641 } elsif($force_relative) { |
658 } elsif($force_relative) { |
642 $force_relative--; |
659 $force_relative--; |
643 } |
660 } |
|
661 } elsif ("$var" eq "public") { |
|
662 $create_private_headers = ("$val" eq "yes" ? 0 : 1); |
|
663 } elsif ("$var" eq "oneway") { |
|
664 $oneway = ("$val" eq "yes" ? 1 : 0); |
|
665 } elsif ("$var" eq "outsubdir") { |
|
666 $out_subdir = $val; |
644 } elsif ("$var" eq "module") { |
667 } elsif ("$var" eq "module") { |
645 print "module :$val:\n"; |
668 print "module :$val:\n"; |
646 die "No such module: $val" unless(defined $modules{$val}); |
669 die "No such module: $val" unless(defined $modules{$val}); |
647 push @modules_to_sync, $val; |
670 push @modules_to_sync, $val; |
648 } elsif ("$var" eq "separate-module") { |
671 } elsif ("$var" eq "separate-module") { |
668 @modules_to_sync = keys(%modules) if($#modules_to_sync == -1); |
691 @modules_to_sync = keys(%modules) if($#modules_to_sync == -1); |
669 |
692 |
670 $isunix = checkUnix; #cache checkUnix |
693 $isunix = checkUnix; #cache checkUnix |
671 |
694 |
672 # create path |
695 # create path |
673 mkpath "$out_basedir/include", 0777; |
696 mkpath "$out_basedir/$out_subdir", 0777; |
674 |
697 |
675 my @ignore_headers = (); |
698 my @ignore_headers = (); |
676 my $class_lib_map_contents = ""; |
699 my $class_lib_map_contents = ""; |
677 my @ignore_for_master_contents = ( "qt.h", "qpaintdevicedefs.h" ); |
700 my @ignore_for_master_contents = ( "qt.h", "qpaintdevicedefs.h" ); |
678 my @ignore_for_include_check = ( "qatomic.h" ); |
701 my @ignore_for_include_check = ( "qatomic.h" ); |
724 } |
747 } |
725 } |
748 } |
726 |
749 |
727 #remove the old files |
750 #remove the old files |
728 if($remove_stale) { |
751 if($remove_stale) { |
729 my @subdirs = ("$out_basedir/include/$lib"); |
752 my @subdirs = ("$out_basedir/$out_subdir/$lib"); |
730 foreach (@subdirs) { |
753 foreach (@subdirs) { |
731 my $subdir = "$_"; |
754 my $subdir = "$_"; |
732 if (opendir DIR, "$subdir") { |
755 if (opendir DIR, "$subdir") { |
733 while(my $t = readdir(DIR)) { |
756 while(my $t = readdir(DIR)) { |
734 my $file = "$subdir/$t"; |
757 my $file = "$subdir/$t"; |
735 if(-d "$file") { |
758 if(-d "$file") { |
736 push @subdirs, "$file" unless($t eq "." || $t eq ".."); |
759 push @subdirs, "$file" unless($t eq "." || $t eq ".."); |
737 } else { |
760 } else { |
738 my @files = ("$file"); |
761 my @files = ("$file"); |
739 #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t"); |
762 #push @files, "$out_basedir/$out_subdir/Qt/$t" if(-e "$out_basedir/$out_subdir/Qt/$t"); |
740 foreach (@files) { |
763 foreach (@files) { |
741 my $file = $_; |
764 my $file = $_; |
742 my $remove_file = 0; |
765 my $remove_file = 0; |
743 if(open(F, "<$file")) { |
766 if(open(F, "<$file")) { |
744 while(<F>) { |
767 while(<F>) { |
815 } |
838 } |
816 } else { |
839 } else { |
817 #find out all the places it goes.. |
840 #find out all the places it goes.. |
818 my @headers; |
841 my @headers; |
819 if ($public_header) { |
842 if ($public_header) { |
820 @headers = ( "$out_basedir/include/$lib/$header" ); |
843 @headers = ( "$out_basedir/$out_subdir/$lib/$header" ); |
821 push @headers, "$out_basedir/include/Qt/$header" |
844 push @headers, "$out_basedir/$out_subdir/Qt/$header" |
822 if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/); |
845 if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/); |
823 |
846 |
824 foreach(@classes) { |
847 foreach(@classes) { |
825 my $header_base = basename($header); |
848 my $header_base = basename($header); |
826 my $class = $_; |
849 my $class = $_; |
828 $class =~ s/^.*:://; |
851 $class =~ s/^.*:://; |
829 # if ($class =~ m/::/) { |
852 # if ($class =~ m/::/) { |
830 # class =~ s,::,/,g; |
853 # class =~ s,::,/,g; |
831 # } |
854 # } |
832 $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n"; |
855 $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n"; |
833 $header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0)); |
856 $header_copies++ if(syncHeader("$out_basedir/$out_subdir/$lib/$class", "$out_basedir/$out_subdir/$lib/$header", 0)); |
834 |
857 |
835 # KDE-Compat headers for Phonon |
858 # KDE-Compat headers for Phonon |
836 if ($lib eq "phonon") { |
859 if ($lib eq "phonon") { |
837 $header_copies++ if (syncHeader("$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0)); |
860 $header_copies++ if (syncHeader("$out_basedir/$out_subdir/phonon_compat/Phonon/$class", "$out_basedir/$out_subdir/$lib/$header", 0)); |
838 } |
861 } |
839 } |
862 } |
840 } elsif ($create_private_headers) { |
863 } elsif ($create_private_headers) { |
841 @headers = ( "$out_basedir/include/$lib/private/$header" ); |
864 @headers = ( "$out_basedir/$out_subdir/$lib/private/$header" ); |
842 push @headers, "$out_basedir/include/Qt/private/$header" |
865 push @headers, "$out_basedir/$out_subdir/Qt/private/$header" |
843 if ("$lib" ne "phonon"); |
866 if ("$lib" ne "phonon"); |
844 } |
867 } |
845 foreach(@headers) { #sync them |
868 foreach(@headers) { #sync them |
846 $header_copies++ if(syncHeader($_, $iheader, $copy_headers)); |
869 $header_copies++ if(syncHeader($_, $iheader, $copy_headers)); |
847 } |
870 } |
858 # Strip namespaces: |
881 # Strip namespaces: |
859 $class =~ s/^.*:://; |
882 $class =~ s/^.*:://; |
860 # if ($class =~ m/::/) { |
883 # if ($class =~ m/::/) { |
861 # $class =~ s,::,/,g; |
884 # $class =~ s,::,/,g; |
862 # } |
885 # } |
863 my $class_header = fixPaths("$out_basedir/include/$lib/$class", |
886 my $class_header = fixPaths("$out_basedir/$out_subdir/$lib/$class", |
864 $current_dir) . " "; |
887 $current_dir) . " "; |
865 $pri_install_classes .= $class_header |
888 $pri_install_classes .= $class_header |
866 unless($pri_install_classes =~ $class_header); |
889 unless($pri_install_classes =~ $class_header); |
867 } |
890 } |
868 $pri_install_files.= "$pri_install_iheader ";; |
891 $pri_install_files.= "$pri_install_iheader ";; |
882 # close the master include: |
905 # close the master include: |
883 $master_contents .= "#endif\n"; |
906 $master_contents .= "#endif\n"; |
884 |
907 |
885 unless($showonly) { |
908 unless($showonly) { |
886 my @master_includes; |
909 my @master_includes; |
887 push @master_includes, "$out_basedir/include/$lib/$lib"; |
910 push @master_includes, "$out_basedir/$out_subdir/$lib/$lib"; |
888 push @master_includes, "$out_basedir/include/phonon_compat/Phonon/Phonon" if ($lib eq "phonon"); |
911 push @master_includes, "$out_basedir/$out_subdir/phonon_compat/Phonon/Phonon" if ($lib eq "phonon"); |
889 foreach my $master_include (@master_includes) { |
912 foreach my $master_include (@master_includes) { |
890 #generate the "master" include file |
913 #generate the "master" include file |
891 $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too |
914 $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too |
892 if($master_include && -e "$master_include") { |
915 if($master_include && -e "$master_include") { |
893 open MASTERINCLUDE, "<$master_include"; |
916 open MASTERINCLUDE, "<$master_include"; |
911 #handle the headers.pri for each module |
934 #handle the headers.pri for each module |
912 my $headers_pri_contents = ""; |
935 my $headers_pri_contents = ""; |
913 $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n"; |
936 $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n"; |
914 $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n"; |
937 $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n"; |
915 $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n"; |
938 $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n"; |
916 my $headers_pri_file = "$out_basedir/include/$lib/headers.pri"; |
939 my $headers_pri_file = "$out_basedir/$out_subdir/$lib/headers.pri"; |
917 if(-e "$headers_pri_file") { |
940 if(-e "$headers_pri_file") { |
918 open HEADERS_PRI_FILE, "<$headers_pri_file"; |
941 open HEADERS_PRI_FILE, "<$headers_pri_file"; |
919 local $/; |
942 local $/; |
920 binmode HEADERS_PRI_FILE; |
943 binmode HEADERS_PRI_FILE; |
921 my $old_headers_pri_contents = <HEADERS_PRI_FILE>; |
944 my $old_headers_pri_contents = <HEADERS_PRI_FILE>; |