bin/syncqt
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 8 3f74d0d4af4c
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 #!/usr/bin/perl -w
     1 #!/usr/bin/perl -w
     2 ######################################################################
     2 ######################################################################
     3 #
     3 #
     4 # Synchronizes Qt header files - internal development tool.
     4 # Synchronizes Qt header files - internal development tool.
     5 #
     5 #
     6 # Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     6 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     7 # Contact: Nokia Corporation (qt-info@nokia.com)
     7 # Contact: Nokia Corporation (qt-info@nokia.com)
     8 #
     8 #
     9 ######################################################################
     9 ######################################################################
    10 
    10 
    11 # use packages -------------------------------------------------------
    11 # use packages -------------------------------------------------------
    12 use File::Basename;
    12 use File::Basename;
    13 use File::Path;
    13 use File::Path;
    14 use Cwd;
    14 use Cwd;
    15 use Config;
    15 use Config;
    16 use strict;
    16 use strict;
       
    17 
       
    18 for (my $i = 0; $i < $#ARGV; $i++) {
       
    19     if ($ARGV[$i] eq "-base-dir" && $i < $#ARGV - 1) {
       
    20         $ENV{"QTDIR"} = $ARGV[$i + 1];
       
    21         last;
       
    22     }
       
    23 }
    17 
    24 
    18 die "syncqt: QTDIR not defined" if ! $ENV{"QTDIR"}; # sanity check
    25 die "syncqt: QTDIR not defined" if ! $ENV{"QTDIR"}; # sanity check
    19 
    26 
    20 # global variables
    27 # global variables
    21 my $isunix = 0;
    28 my $isunix = 0;
    59 my $remove_stale = 1;
    66 my $remove_stale = 1;
    60 my $force_win = 0;
    67 my $force_win = 0;
    61 my $force_relative = 0;
    68 my $force_relative = 0;
    62 my $check_includes = 0;
    69 my $check_includes = 0;
    63 my $copy_headers = 0;
    70 my $copy_headers = 0;
       
    71 my $create_uic_class_map = 1;
       
    72 my $create_private_headers = 1;
    64 my @modules_to_sync ;
    73 my @modules_to_sync ;
    65 $force_relative = 1 if ( -d "/System/Library/Frameworks" );
    74 $force_relative = 1 if ( -d "/System/Library/Frameworks" );
    66 my $out_basedir = $basedir;
    75 my $out_basedir = $basedir;
    67 $out_basedir =~ s=\\=/=g;
    76 $out_basedir =~ s=\\=/=g;
    68 
    77 
    82     print "  -remove-stale         Removes stale headers              (default: " . ($remove_stale ? "yes" : "no") . ")\n";
    91     print "  -remove-stale         Removes stale headers              (default: " . ($remove_stale ? "yes" : "no") . ")\n";
    83     print "  -relative             Force relative symlinks            (default: " . ($force_relative ? "yes" : "no") . ")\n";
    92     print "  -relative             Force relative symlinks            (default: " . ($force_relative ? "yes" : "no") . ")\n";
    84     print "  -windows              Force platform to Windows          (default: " . ($force_win ? "yes" : "no") . ")\n";
    93     print "  -windows              Force platform to Windows          (default: " . ($force_win ? "yes" : "no") . ")\n";
    85     print "  -showonly             Show action but not perform        (default: " . ($showonly ? "yes" : "no") . ")\n";
    94     print "  -showonly             Show action but not perform        (default: " . ($showonly ? "yes" : "no") . ")\n";
    86     print "  -outdir <PATH>        Specify output directory for sync  (default: $out_basedir)\n";
    95     print "  -outdir <PATH>        Specify output directory for sync  (default: $out_basedir)\n";
       
    96     print "  -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR> Create headers for <NAME> with original headers in <HEADERDIR> relative to <PROFILEDIR> \n";
    87     print "  -help                 This help\n";
    97     print "  -help                 This help\n";
    88     exit 0;
    98     exit 0;
    89 }
    99 }
    90 
   100 
    91 ######################################################################
   101 ######################################################################
   574 	$var = "output";
   584 	$var = "output";
   575 	$val = shift @ARGV;
   585 	$val = shift @ARGV;
   576     } elsif("$arg" eq "-module") {
   586     } elsif("$arg" eq "-module") {
   577 	$var = "module";
   587 	$var = "module";
   578 	$val = shift @ARGV;
   588 	$val = shift @ARGV;
       
   589     } elsif("$arg" eq "-separate-module") {
       
   590 	$var = "separate-module";
       
   591 	$val = shift @ARGV;
   579     } elsif("$arg" eq "-show") {
   592     } elsif("$arg" eq "-show") {
   580 	$var = "showonly";
   593 	$var = "showonly";
   581 	$val = "yes";
   594 	$val = "yes";
       
   595     } elsif("$arg" eq "-base-dir") {
       
   596         # skip, it's been dealt with at the top of the file
       
   597         shift @ARGV;
       
   598         next;
   582     } elsif("$arg" eq '*') {
   599     } elsif("$arg" eq '*') {
   583         # workaround for windows 9x where "%*" expands to "*"
   600         # workaround for windows 9x where "%*" expands to "*"
   584         $var = 1;
   601         $var = 1;
   585     }
   602     }
   586 
   603 
   626 	}
   643 	}
   627     } elsif ("$var" eq "module") {
   644     } elsif ("$var" eq "module") {
   628 	print "module :$val:\n";
   645 	print "module :$val:\n";
   629 	die "No such module: $val" unless(defined $modules{$val});
   646 	die "No such module: $val" unless(defined $modules{$val});
   630 	push @modules_to_sync, $val;
   647 	push @modules_to_sync, $val;
       
   648     } elsif ("$var" eq "separate-module") {
       
   649         my ($module, $prodir, $headerdir) = split(/:/, $val);
       
   650         $modules{$module} = $prodir;
       
   651         push @modules_to_sync, $module;
       
   652         $moduleheaders{$module} = $headerdir;
       
   653         $create_uic_class_map = 0;
       
   654         $create_private_headers = 0;
   631     } elsif ("$var" eq "output") {
   655     } elsif ("$var" eq "output") {
   632 	my $outdir = $val;
   656 	my $outdir = $val;
   633 	if(checkRelative($outdir)) {
   657 	if(checkRelative($outdir)) {
   634 	    $out_basedir = getcwd();
   658 	    $out_basedir = getcwd();
   635 	    chomp $out_basedir;
   659 	    chomp $out_basedir;
   798 			      if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/);
   822 			      if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/);
   799 
   823 
   800 			    foreach(@classes) {
   824 			    foreach(@classes) {
   801 				my $header_base = basename($header);
   825 				my $header_base = basename($header);
   802 				my $class = $_;
   826 				my $class = $_;
   803 				if ($class =~ m/::/) {
   827 				# Strip namespaces:
   804 				    $class =~ s,::,/,g;
   828 				$class =~ s/^.*:://;
   805 				}
   829 #				if ($class =~ m/::/) {
       
   830 #				   class =~ s,::,/,g;
       
   831 #				}
   806 				$class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n";
   832 				$class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n";
   807 				$header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0));
   833 				$header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0));
       
   834 
       
   835 				# KDE-Compat headers for Phonon
       
   836 				if ($lib eq "phonon") {
       
   837 				    $header_copies++ if (syncHeader("$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0));
       
   838 				}
   808 			    }
   839 			    }
   809 			} else {
   840 			} elsif ($create_private_headers) {
   810 			    @headers = ( "$out_basedir/include/$lib/private/$header" );
   841 			    @headers = ( "$out_basedir/include/$lib/private/$header" );
   811 			    push @headers, "$out_basedir/include/Qt/private/$header"
   842 			    push @headers, "$out_basedir/include/Qt/private/$header"
   812                               if ("$lib" ne "phonon");
   843                               if ("$lib" ne "phonon");
   813 			}
   844 			}
   814 			foreach(@headers) { #sync them
   845 			foreach(@headers) { #sync them
   822 			    #deal with the install directives
   853 			    #deal with the install directives
   823 			    if($public_header) {
   854 			    if($public_header) {
   824 				my $pri_install_iheader = fixPaths($iheader, $current_dir);
   855 				my $pri_install_iheader = fixPaths($iheader, $current_dir);
   825 				foreach(@classes) {
   856 				foreach(@classes) {
   826 				    my $class = $_;
   857 				    my $class = $_;
   827 				    if ($class =~ m/::/) {
   858 				    # Strip namespaces:
   828 					$class =~ s,::,/,g;
   859 				    $class =~ s/^.*:://;
   829 				    }
   860 #				    if ($class =~ m/::/) {
       
   861 #					$class =~ s,::,/,g;
       
   862 #				    }
   830 				    my $class_header = fixPaths("$out_basedir/include/$lib/$class",
   863 				    my $class_header = fixPaths("$out_basedir/include/$lib/$class",
   831 								$current_dir) . " ";
   864 								$current_dir) . " ";
   832 				    $pri_install_classes .= $class_header
   865 				    $pri_install_classes .= $class_header
   833 								unless($pri_install_classes =~ $class_header);
   866 								unless($pri_install_classes =~ $class_header);
   834 				}
   867 				}
   849     # close the master include:
   882     # close the master include:
   850     $master_contents .= "#endif\n";
   883     $master_contents .= "#endif\n";
   851 
   884 
   852     unless($showonly) {
   885     unless($showonly) {
   853         my @master_includes;
   886         my @master_includes;
   854         if ($lib eq "phonon") {
   887 	push @master_includes, "$out_basedir/include/$lib/$lib";
   855             push @master_includes, "$out_basedir/include/phonon_compat/phonon/phonon";
   888 	push @master_includes, "$out_basedir/include/phonon_compat/Phonon/Phonon" if ($lib eq "phonon");
   856             push @master_includes, "$out_basedir/include/phonon/Phonon/Phonon";
       
   857         } else {
       
   858             push @master_includes, "$out_basedir/include/$lib/$lib";
       
   859         }
       
   860         foreach my $master_include (@master_includes) {
   889         foreach my $master_include (@master_includes) {
   861             #generate the "master" include file
   890             #generate the "master" include file
   862             $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too
   891             $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too
   863             if($master_include && -e "$master_include") {
   892             if($master_include && -e "$master_include") {
   864                 open MASTERINCLUDE, "<$master_include";
   893                 open MASTERINCLUDE, "<$master_include";
   902             print HEADERS_PRI_FILE "$headers_pri_contents";
   931             print HEADERS_PRI_FILE "$headers_pri_contents";
   903             close HEADERS_PRI_FILE;
   932             close HEADERS_PRI_FILE;
   904         }
   933         }
   905     }
   934     }
   906 }
   935 }
   907 unless($showonly) {
   936 unless($showonly || !$create_uic_class_map) {
   908     my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h";
   937     my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h";
   909     if(-e "$class_lib_map") {
   938     if(-e "$class_lib_map") {
   910 	open CLASS_LIB_MAP, "<$class_lib_map";
   939 	open CLASS_LIB_MAP, "<$class_lib_map";
   911 	local $/;
   940 	local $/;
   912 	binmode CLASS_LIB_MAP;
   941 	binmode CLASS_LIB_MAP;