diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/createpackage | 3 | ||||
-rwxr-xr-x | bin/createpackage.pl | 139 | ||||
-rwxr-xr-x | bin/elf2e32_qtwrapper | 145 | ||||
-rwxr-xr-x | bin/patch_capabilities | 3 | ||||
-rwxr-xr-x | bin/patch_capabilities.pl | 100 | ||||
-rwxr-xr-x | bin/syncqt | 801 |
6 files changed, 739 insertions, 452 deletions
diff --git a/bin/createpackage b/bin/createpackage new file mode 100755 index 0000000..fdd4eeb --- /dev/null +++ b/bin/createpackage @@ -0,0 +1,3 @@ +#!/bin/sh +scriptpath=`dirname $0` +perl $scriptpath/createpackage.pl "$@" diff --git a/bin/createpackage.pl b/bin/createpackage.pl index 7f803fd..8b787cb 100755 --- a/bin/createpackage.pl +++ b/bin/createpackage.pl @@ -68,16 +68,19 @@ Convenience script for creating signed packages you can install on your phone. Usage: createpackage.pl [options] templatepkg [target]-[platform] [certificate key [passphrase]] -Where supported optiobns are as follows: - [-i|install] = Install the package right away using PC suite +Where supported options are as follows: + [-i|install] = Install the package right away using PC suite. [-p|preprocess] = Only preprocess the template .pkg file. - [-c|certfile=<file>] = The file containing certificate information for signing. + [-c|certfile <file>] = The file containing certificate information for signing. The file can have several certificates, each specified in separate line. The certificate, key and passphrase in line must be ';' separated. Lines starting with '#' are treated as a comments. Also empty lines are ignored. The paths in <file> can be absolute or relative to <file>. - [-u|unsigned] = Preserves the unsigned package + [-u|unsigned] = Preserves the unsigned package. + [-o|only-unsigned] = Creates only unsigned package. + [-s|stub] = Generates stub sis for ROM. + [-n|sisname <name>] = Specifies the final sis name. Where parameters are as follows: templatepkg = Name of .pkg file template target = Either debug or release @@ -85,7 +88,7 @@ Where parameters are as follows: winscw | gcce | armv5 | armv6 | armv7 certificate = The certificate file used for signing key = The certificate's private key file - passphrase = The certificate's private key file's passphrase + passphrase = The passphrase of the certificate's private key file Example: createpackage.pl fluidlauncher_template.pkg release-armv5 @@ -101,6 +104,10 @@ Example with certfile: If no certificate and key files are provided, either a RnD certificate or a self-signed certificate from QtDir\\src\\s60installs directory is used. +In the latter case the resulting package will also be automatically patched +using patch_capabilities.pl script, which makes it unsuitable for distribution. +Always specify certificates explicitly if you wish to distribute your package. + ============================================================================================== ENDUSAGESTRING @@ -114,12 +121,16 @@ my $preprocessonly = ""; my $certfile = ""; my $preserveUnsigned = ""; my $stub = ""; +my $signed_sis_name = ""; +my $onlyUnsigned = ""; unless (GetOptions('i|install' => \$install, 'p|preprocess' => \$preprocessonly, 'c|certfile=s' => \$certfile, 'u|unsigned' => \$preserveUnsigned, - 's|stub' => \$stub,)){ + 'o|only-unsigned' => \$onlyUnsigned, + 's|stub' => \$stub, + 'n|sisname=s' => \$signed_sis_name,)) { Usage(); } @@ -130,16 +141,21 @@ my $templatepkg = $ARGV[0]; my $targetplatform = lc $ARGV[1]; my @tmpvalues = split('-', $targetplatform); -my $target = $tmpvalues[0]; -my $platform = $tmpvalues[1];; +my $target; +$target = $tmpvalues[0] or $target = ""; +my $platform; +$platform = $tmpvalues[1] or $platform = ""; # Convert visual target to real target (debug->udeb and release->urel) $target =~ s/debug/udeb/i; $target =~ s/release/urel/i; -my $certificate = $ARGV[2]; -my $key = $ARGV[3]; -my $passphrase = $ARGV[4]; +my $certificate; +$certificate = $ARGV[2] or $certificate = ""; +my $key; +$key = $ARGV[3] or $key = ""; +my $passphrase; +$passphrase = $ARGV[4] or $passphrase = ""; # Generate output pkg basename (i.e. file name without extension) my $pkgoutputbasename = $templatepkg; @@ -149,23 +165,32 @@ if ($pkgoutputbasename eq $templatepkg) { $preservePkgOutput = "1"; } $pkgoutputbasename =~ s/\.pkg//g; -$pkgoutputbasename = lc($pkgoutputbasename); +$pkgoutputbasename = $pkgoutputbasename; # Store output file names to variables -my $pkgoutput = lc($pkgoutputbasename.".pkg"); -my $sisoutputbasename = lc($pkgoutputbasename); -$sisoutputbasename =~ s/_$targetplatform//g; +my $pkgoutput = $pkgoutputbasename.".pkg"; +my $sisoutputbasename; +if ($signed_sis_name eq "") { + $sisoutputbasename = $pkgoutputbasename; + $sisoutputbasename =~ s/_$targetplatform//g; + $signed_sis_name = $sisoutputbasename.".sis"; +} else { + $sisoutputbasename = $signed_sis_name; + if ($sisoutputbasename =~ m/(\.sis$|\.sisx$)/i) { + $sisoutputbasename =~ s/$1//i; + } else { + $signed_sis_name = $signed_sis_name.".sis"; + } +} + my $unsigned_sis_name = $sisoutputbasename."_unsigned.sis"; -my $signed_sis_name = $sisoutputbasename.".sis"; -my $stub_sis_name = $sisoutputbasename."_stub.sis"; +my $stub_sis_name = $sisoutputbasename.".sis"; # Store some utility variables my $scriptpath = dirname(__FILE__); my $certtext = $certificate; -my $certpath = $scriptpath; -$certpath =~ s-^(.*[^\\])$-$1\\-o; # ensure path ends with a backslash -$certpath =~ s-/-\\-go; # for those working with UNIX shells -$certpath =~ s-bin\\$-src\\s60installs\\-; # certificates are one step up in hierarcy +# certificates are one step up in hierarchy +my $certpath = File::Spec->catdir($scriptpath, File::Spec->updir(), "src/s60installs/"); # Check some pre-conditions and print error messages if needed. unless (length($templatepkg)) { @@ -173,14 +198,6 @@ unless (length($templatepkg)) { Usage(); } -# If the pkg file is not actually a template, there is no need for plaform or target. -if ($templatepkg =~ m/_template\.pkg/i) { - unless (length($platform) && length($target)) { - print "\nError: Platform or target is not defined!\n"; - Usage(); - } -} - # Check template exist stat($templatepkg); unless( -e _ ) { @@ -197,14 +214,14 @@ if (length($certificate)) { } else { #If no certificate is given, check default options $certtext = "RnD"; - $certificate = $certpath."rd.cer"; - $key = $certpath."rd-key.pem"; + $certificate = File::Spec->catfile($certpath, "rd.cer"); + $key = File::Spec->catfile($certpath, "rd-key.pem"); stat($certificate); unless( -e _ ) { $certtext = "Self Signed"; - $certificate = $certpath."selfsigned.cer"; - $key = $certpath."selfsigned.key"; + $certificate = File::Spec->catfile($certpath, "selfsigned.cer"); + $key = File::Spec->catfile($certpath, "selfsigned.key"); } } @@ -242,12 +259,21 @@ if (!$preservePkgOutput) { } # Preprocess PKG + local $/; # read template file open( TEMPLATE, $templatepkg) or die "Error '$templatepkg': $!\n"; $_=<TEMPLATE>; close (TEMPLATE); +# If the pkg file does not contain macros, there is no need for platform or target. +if (m/\$\(PLATFORM\)/) { + unless (length($platform) && length($target)) { + print "\nError: Platform or target is not defined!\n"; + Usage(); + } +} + # replace the PKG variables s/\$\(PLATFORM\)/$platform/gm; s/\$\(TARGET\)/$target/gm; @@ -269,29 +295,56 @@ if($stub) { # Create stub SIS. system ("makesis -s $pkgoutput $stub_sis_name"); } else { + if ($certtext eq "Self Signed" + && !@certificates + && $templatepkg !~ m/_installer\.pkg$/i + && !$onlyUnsigned) { + print("Auto-patching capabilities for self signed package.\n"); + system ("patch_capabilities $pkgoutput"); + } + # Create SIS. - system ("makesis $pkgoutput $unsigned_sis_name"); + # The 'and' is because system uses 0 to indicate success. + system ("makesis $pkgoutput $unsigned_sis_name") and die ("makesis failed"); print("\n"); + my $targetInsert = ""; + if ($targetplatform ne "-") { + $targetInsert = " for $targetplatform"; + } + + if ($onlyUnsigned) { + stat($unsigned_sis_name); + if( -e _ ) { + print ("Successfully created unsigned package ${unsigned_sis_name}${targetInsert}!\n"); + } else { + print ("\nUnsigned package creation failed!\n"); + } + + if (!$preservePkgOutput) { + unlink $pkgoutput; + } + exit; + } + # Sign SIS with certificate info given as an argument. - system ("signsis $unsigned_sis_name $signed_sis_name $certificate $key $passphrase"); + my $relcert = File::Spec->abs2rel($certificate); + my $relkey = File::Spec->abs2rel($key); + # The 'and' is because system uses 0 to indicate success. + system ("signsis $unsigned_sis_name $signed_sis_name $relcert $relkey $passphrase") and die ("signsis failed"); # Check if creating signed SIS Succeeded stat($signed_sis_name); if( -e _ ) { - my $targetInsert = ""; - if ($targetplatform ne "-") { - $targetInsert = "for $targetplatform "; - } - print ("Successfully created $signed_sis_name ${targetInsert}using certificate: $certtext!\n"); + print ("Successfully created signed package ${signed_sis_name}${targetInsert} using certificate: $certtext!\n"); # Sign with additional certificates & keys for my $row ( @certificates ) { # Get certificate absolute file names, relative paths are relative to certfilepath - my $abscert = File::Spec->rel2abs( $row->[0], $certfilepath); - my $abskey = File::Spec->rel2abs( $row->[1], $certfilepath); + my $relcert = File::Spec->abs2rel(File::Spec->rel2abs( $row->[0], $certfilepath)); + my $relkey = File::Spec->abs2rel(File::Spec->rel2abs( $row->[1], $certfilepath)); - system ("signsis $signed_sis_name $signed_sis_name $abscert $abskey $row->[2]"); + system ("signsis $signed_sis_name $signed_sis_name $relcert $relkey $row->[2]"); print ("\tAdditionally signed the SIS with certificate: $row->[0]!\n"); } diff --git a/bin/elf2e32_qtwrapper b/bin/elf2e32_qtwrapper new file mode 100755 index 0000000..694d54a --- /dev/null +++ b/bin/elf2e32_qtwrapper @@ -0,0 +1,145 @@ +#!/usr/bin/perl -w + +# A script to get around some shortcomings in elf2e32, namely: +# - Returning 0 even when there are errors. +# - Excluding symbols from the dso file even when they are present in the ELF file. +# - Including symbols in the the dso file even when they are not present in the ELF file. +# - Overwriting the old dso file even when there are no changes (increases build time). + +use File::Copy; + +my @args = (); +my @definput; +my @defoutput; +my @dso; +my @tmpdso; +foreach (@ARGV) { + if (/^--definput/o) { + @definput = split('=', $_); + } elsif (/^--defoutput/o) { + @defoutput = split('=', $_); + } elsif (/^--dso/o) { + @dso = split('=', $_); + } elsif (/^--tmpdso/o) { + @tmpdso = split('=', $_); + $tmpdso[0] = "--dso"; + } else { + push(@args, $_); + } +} + +@definput = () if (!@definput || ! -e $definput[1]); + +if (@dso && !@tmpdso || !@dso && @tmpdso) { + print("--dso and --tmpdso must be used together.\n"); + exit 1; +} + +my $buildingLibrary = (@defoutput && @dso) ? 1 : 0; + +my $fixupFile = ""; +my $runCount = 0; +my $returnCode = 0; + +while (1) { + if (++$runCount > 2) { + print("Internal error in $0, link succeeded, but exports may be wrong.\n"); + last; + } + + my $elf2e32Pipe; + my $elf2e32Cmd = "elf2e32 @args" + . " " . join("=", @definput) + . " " . join("=", @defoutput) + . " " . join("=", @tmpdso); + open($elf2e32Pipe, "$elf2e32Cmd 2>&1 |") or die ("Could not run elf2e32"); + + my %fixupSymbols; + my $foundBrokenSymbols = 0; + my $errors = 0; + while (<$elf2e32Pipe>) { + print; + if (/Error:/io) { + $errors = 1; + } elsif (/symbol ([a-z0-9_]+) absent in the DEF file, but present in the ELF file/io) { + $fixupSymbols{$1} = 1; + $foundBrokenSymbols = 1; + } elsif (/[0-9]+ Frozen Export\(s\) missing from the ELF file/io) { + $foundBrokenSymbols = 1; + } + } + close($elf2e32Pipe); + + if ($errors) { + $returnCode = 1; + last; + } + + if ($buildingLibrary) { + my $tmpDefFile; + my $defFile; + open($defFile, "< $defoutput[1]") or die("Could not open $defoutput[1]"); + open($tmpDefFile, "> $defoutput[1].tmp") or die("Could not open $defoutput[1].tmp"); + $fixupFile = "$defoutput[1].tmp"; + while (<$defFile>) { + s/\r//; + s/\n//; + next if (/; NEW:/); + if (/([a-z0-9_]+) @/i) { + if (exists($fixupSymbols{$1})) { + s/ ABSENT//; + } elsif (s/; MISSING://) { + s/$/ ABSENT/; + } + } + print($tmpDefFile "$_\n"); + } + close($defFile); + close($tmpDefFile); + + $definput[1] = "$defoutput[1].tmp"; + + if (!$foundBrokenSymbols || $errors) { + last; + } + + print("Rerunning elf2e32 due to DEF file / ELF file mismatch\n"); + } else { + last; + } +}; + +if ($fixupFile) { + unlink($defoutput[1]); + move($fixupFile, $defoutput[1]); +} + +exit $returnCode if ($returnCode != 0); + +if ($buildingLibrary) { + my $differenceFound = 0; + + if (-e $dso[1]) { + my $dsoFile; + my $tmpdsoFile; + my $dsoBuf; + my $tmpdsoBuf; + open($dsoFile, "< $dso[1]") or die("Could not open $dso[1]"); + open($tmpdsoFile, "< $tmpdso[1]") or die("Could not open $tmpdso[1]"); + binmode($dsoFile); + binmode($tmpdsoFile); + while(read($dsoFile, $dsoBuf, 4096) && read($tmpdsoFile, $tmpdsoBuf, 4096)) { + if ($dsoBuf ne $tmpdsoBuf) { + $differenceFound = 1; + } + } + close($tmpdsoFile); + close($dsoFile); + } else { + $differenceFound = 1; + } + + if ($differenceFound) { + copy($tmpdso[1], $dso[1]); + } +} diff --git a/bin/patch_capabilities b/bin/patch_capabilities new file mode 100755 index 0000000..0d89622 --- /dev/null +++ b/bin/patch_capabilities @@ -0,0 +1,3 @@ +#!/bin/sh +scriptpath=`dirname $0` +perl $scriptpath/patch_capabilities.pl "$@" diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index f82c48f..7d6f5dc 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -46,18 +46,32 @@ # ####################################################################### +use File::Copy; + sub Usage() { print("This script can be used to set capabilities of all binaries\n"); print("specified for deployment in a .pkg file.\n"); print("If no capabilities are given, the binaries will be given the\n"); - print("capabilities supported by self-signed certificates.\n"); - print("\n *** NOTE: If *_template.pkg file is given, 'target-platform' is REQUIRED. ***\n"); - print("\nUsage: patch_capabilities.pl pkg_filename <target-platform> [capability list]\n"); + print("capabilities supported by self-signed certificates.\n\n"); + print(" *** NOTE: If *_template.pkg file is given and one is using symbian-abld or\n"); + print(" symbian-sbsv2 platform, 'target-platform' is REQUIRED. ***\n"); + print("\nUsage: patch_capabilities.pl pkg_filename [target-platform [capability list]]\n"); print("\nE.g. patch_capabilities.pl myapp_template.pkg release-armv5 \"All -TCB\"\n"); exit(); } -my @capabilitiesToSet = ("LocalServices", "NetworkServices", "ReadUserData", "UserEnvironment", "WriteUserData"); +sub trim($) { + my $string = shift; + $string =~ s/^\s+//; + $string =~ s/\s+$//; + return $string; +} + +my $nullDevice = "/dev/null"; +$nullDevice = "NUL" if ($^O =~ /MSWin/); + +my @capabilitiesToAllow = ("LocalServices", "NetworkServices", "ReadUserData", "UserEnvironment", "WriteUserData"); +my @capabilitiesSpecified = (); # If arguments were given to the script, if (@ARGV) @@ -73,11 +87,16 @@ if (@ARGV) if (($pkgFileName =~ m|_template\.pkg$|i) && -r($pkgFileName)) { my $targetplatform; - unless ($targetplatform = shift(@ARGV)) + my $templateFile; + my $templateContents; + open($templateFile, "< $pkgFileName") or die ("Could not open $pkgFileName"); + $templateContents = <$templateFile>; + close($templateFile); + unless (($targetplatform = shift(@ARGV)) || $templateContents !~ /\$\(PLATFORM\)/) { Usage(); } - + $targetplatform = "-" if (!$targetplatform); my @tmpvalues = split('-', $targetplatform); $target = $tmpvalues[0]; $platform = $tmpvalues[1]; @@ -90,13 +109,16 @@ if (@ARGV) # If the specified ".pkg" file exists (and can be read), if (($pkgFileName =~ m|\.pkg$|i) && -r($pkgFileName)) { + print ("\n"); + print ("Patching package file and relevant binaries...\n"); + # If there are more arguments given, parse them as capabilities. if (@ARGV) { - @capabilitiesToSet = (); + @capabilitiesSpecified = (); while (@ARGV) { - push (@capabilitiesToSet, pop(@ARGV)); + push (@capabilitiesSpecified, pop(@ARGV)); } } @@ -163,18 +185,13 @@ if (@ARGV) $manufacturerElseBlock = 0; } - print NEW_PKG $newLine; - - chomp ($line); - # If the line specifies a file, parse the source and destination locations. - if ($line =~ m|\"([^\"]+)\"\s*\-\s*\"([^\"]+)\"|) + if ($line =~ m|^ *\"([^\"]+)\"\s*\-\s*\"([^\"]+)\"|) { my $sourcePath = $1; - my $destinationPath = $2; # If the given file is a binary, check the target and binary type (+ the actual filename) from its path. - if ($sourcePath =~ m:/epoc32/release/([^/]+)/(udeb|urel|\$\(TARGET\))/(\w+(\.dll|\.exe)):i) + if ($sourcePath =~ m:\w+(\.dll|\.exe)$:i) { # Do preprocessing for template pkg, # In case of template pkg target and platform variables are set @@ -184,9 +201,22 @@ if (@ARGV) $sourcePath =~ s/\$\(TARGET\)/$target/gm; } - push (@binaries, $sourcePath); + # Change the source file name (but only if not already patched) + my $patchedSourcePath = $sourcePath; + if ($patchedSourcePath !~ m/_patched_caps/) + { + $newLine =~ s/(^.*)(\.dll|\.exe)(.*)(\.dll|\.exe)/$1_patched_caps$2$3$4/i; + $patchedSourcePath =~ s/(^.*)(\.dll|\.exe)/$1_patched_caps$2/i; + + copy($sourcePath, $patchedSourcePath) or die "$sourcePath cannot be copied for patching."; + } + push (@binaries, $patchedSourcePath); } } + + print NEW_PKG $newLine; + + chomp ($line); } close (PKG); @@ -197,29 +227,51 @@ if (@ARGV) print ("\n"); - my $baseCommandToExecute = "elftran -vid 0x0 -capability \""; - if (@capabilitiesToSet) - { - $baseCommandToExecute .= join(" ", @capabilitiesToSet); - } - $baseCommandToExecute .= "\" "; + my $baseCommandToExecute = "elftran -vid 0x0 -capability \"%s\" "; # Actually set the capabilities of the listed binaries. foreach my $binaryPath(@binaries) { # Create the command line for setting the capabilities. my $commandToExecute = $baseCommandToExecute; + if (@capabilitiesSpecified) + { + $commandToExecute = sprintf($baseCommandToExecute, join(" ", @capabilitiesSpecified)); + } else { + # Test which capabilities are present and then restrict them to the allowed set. + # This avoid raising the capabilities of apps that already have none. + my $dllCaps; + open($dllCaps, "elftran -dump s $binaryPath |") or die ("Could not execute elftran"); + my $capsFound = 0; + my @capabilitiesToSet; + my $capabilitiesToAllow = join(" ", @capabilitiesToAllow); + while (<$dllCaps>) { + if (!$capsFound) { + $capsFound = 1 if (/Capabilities:/); + } else { + $_ = trim($_); + if ($capabilitiesToAllow =~ /$_/) { + push(@capabilitiesToSet, $_); + } + } + } + close($dllCaps); + $commandToExecute = sprintf($baseCommandToExecute, join(" ", @capabilitiesToSet)); + } $commandToExecute .= $binaryPath; # Actually execute the elftran command to set the capabilities. - system ($commandToExecute." > NUL"); - print ("Executed ".$commandToExecute."\n"); + print ("Executing ".$commandToExecute."\n"); + system ($commandToExecute." > $nullDevice"); ## Create another command line to check that the set capabilities are correct. #$commandToExecute = "elftran -dump s ".$binaryPath; } print ("\n"); + print ("NOTE: A patched package may not work as expected due to reduced capabilities.\n"); + print (" Therefore it should not be used for any kind of Symbian signing or distribution!\n"); + print ("\n"); } } else @@ -44,7 +44,6 @@ my %modules = ( # path to module name map "Qt3Support" => "$basedir/src/qt3support", "ActiveQt" => "$basedir/src/activeqt", "QtTest" => "$basedir/src/testlib", - "QtAssistant" => "$basedir/tools/assistant/compat/lib", "QtHelp" => "$basedir/tools/assistant/lib", "QtDesigner" => "$basedir/tools/designer/src/lib", "QtUiTools" => "$basedir/tools/designer/src/uitools", @@ -63,6 +62,7 @@ my %moduleheaders = ( # restrict the module headers to those found in relative p # global variables (modified by options) my $module = 0; my $showonly = 0; +my $quiet = 0; my $remove_stale = 1; my $force_win = 0; my $force_relative = 0; @@ -93,6 +93,7 @@ sub showUsage print " -windows Force platform to Windows (default: " . ($force_win ? "yes" : "no") . ")\n"; print " -showonly Show action but not perform (default: " . ($showonly ? "yes" : "no") . ")\n"; print " -outdir <PATH> Specify output directory for sync (default: $out_basedir)\n"; + print " -quiet Only report problems, not activity (default: " . ($quiet ? "yes" : "no") . ")\n"; print " -separate-module <NAME>:<PROFILEDIR>:<HEADERDIR> Create headers for <NAME> with original headers in <HEADERDIR> relative to <PROFILEDIR> \n"; print " -help This help\n"; exit 0; @@ -145,12 +146,12 @@ sub shouldMasterInclude { return 0 if(basename($iheader) =~ /qconfig/); if(open(F, "<$iheader")) { while(<F>) { - chomp; - return 0 if(/^\#pragma qt_no_master_include$/); - } - close(F); + chomp; + return 0 if(/^\#pragma qt_no_master_include$/); + } + close(F); } else { - return 0; + return 0; } return 1; } @@ -167,17 +168,17 @@ sub classNames { my @ret; my ($iheader) = @_; if(basename($iheader) eq "qglobal.h") { - push @ret, "QtGlobal"; + push @ret, "QtGlobal"; } elsif(basename($iheader) eq "qendian.h") { - push @ret, "QtEndian"; + push @ret, "QtEndian"; } elsif(basename($iheader) eq "qconfig.h") { push @ret, "QtConfig"; } elsif(basename($iheader) eq "qplugin.h") { - push @ret, "QtPlugin"; + push @ret, "QtPlugin"; } elsif(basename($iheader) eq "qalgorithms.h") { - push @ret, "QtAlgorithms"; + push @ret, "QtAlgorithms"; } elsif(basename($iheader) eq "qcontainerfwd.h") { - push @ret, "QtContainerFwd"; + push @ret, "QtContainerFwd"; } elsif(basename($iheader) eq "qdebug.h") { push @ret, "QtDebug"; } elsif(basename($iheader) eq "qevent.h") { @@ -185,7 +186,7 @@ sub classNames { } elsif(basename($iheader) eq "qnamespace.h") { push @ret, "Qt" } elsif(basename($iheader) eq "qssl.h") { - push @ret, "QSsl"; + push @ret, "QSsl"; } elsif(basename($iheader) eq "qtest.h") { push @ret, "QTest" } elsif(basename($iheader) eq "qtconcurrentmap.h") { @@ -203,7 +204,7 @@ sub classNames { while(<F>) { my $line = $_; chomp $line; - chop $line if ($line =~ /\r$/); + chop $line if ($line =~ /\r$/); if($line =~ /^\#/) { if($line =~ /\\$/) { while($line = <F>) { @@ -211,18 +212,18 @@ sub classNames { last unless($line =~ /\\$/); } } - return @ret if($line =~ m/^#pragma qt_sync_stop_processing/); + return @ret if($line =~ m/^#pragma qt_sync_stop_processing/); push(@ret, "$1") if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/); - $line = 0; + $line = 0; } - if($line) { + if($line) { $line =~ s,//.*$,,; #remove c++ comments - $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro - $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro - $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro - $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro + $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro + $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro + $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro + $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro $parsable .= " " . $line; - } + } } close(F); } @@ -258,7 +259,7 @@ sub classNames { $i = $i2 if($end eq ";"); $last_definition = $i + 1; last BLOCK; - } + } } } } @@ -266,42 +267,42 @@ sub classNames { } elsif($character eq ";") { $definition = substr($parsable, $last_definition, $i - $last_definition + 1); $last_definition = $i + 1; - } elsif($character eq "}") { - # a naked } must be a namespace ending - # if it's not a namespace, it's eaten by the loop above - pop @namespaces; - $last_definition = $i + 1; - } + } elsif($character eq "}") { + # a naked } must be a namespace ending + # if it's not a namespace, it's eaten by the loop above + pop @namespaces; + $last_definition = $i + 1; + } - if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) / - && substr($parsable, $i+1, 1) eq "{") { - push @namespaces, $1; + if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) / + && substr($parsable, $i+1, 1) eq "{") { + push @namespaces, $1; - # Eat the opening { so that the condensing loop above doesn't see it - $i++; - $last_definition = $i + 1; - } + # Eat the opening { so that the condensing loop above doesn't see it + $i++; + $last_definition = $i + 1; + } if($definition) { - $definition =~ s=[\n\r]==g; + $definition =~ s=[\n\r]==g; my @symbols; if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) { - push @symbols, $1; + push @symbols, $1; } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) { - push @symbols, $2; + push @symbols, $2; } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) { - push @symbols, $4; + push @symbols, $4; } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) { - push @symbols, "Q" . $1 . "Iterator"; - push @symbols, "QMutable" . $1 . "Iterator"; - } + push @symbols, "Q" . $1 . "Iterator"; + push @symbols, "QMutable" . $1 . "Iterator"; + } - foreach (@symbols) { - my $symbol = $_; - $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces); - push @ret, $symbol - if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q - || $symbol =~ /^Phonon::/); # or in the Phonon namespace + foreach (@symbols) { + my $symbol = $_; + $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces); + push @ret, $symbol + if ($symbol =~ /^Q[^:]*$/ # no-namespace, starting with Q + || $symbol =~ /^Phonon::/); # or in the Phonon namespace } } } @@ -325,7 +326,7 @@ sub syncHeader { unless(-e "$header") { my $header_dir = dirname($header); - mkpath $header_dir, 0777; + mkpath $header_dir, !$quiet; #write it my $iheader_out = fixPaths($iheader, $header_dir); @@ -355,12 +356,13 @@ sub fixPaths { #setup my $ret = $file; + $ret =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; my $file_dir = dirname($file); if($file_dir eq ".") { $file_dir = getcwd(); $file_dir =~ s=\\=/=g; } - $file_dir =~ s,/cygdrive/([a-zA-Z])/,$1:,g; + $file_dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; if($dir eq ".") { $dir = getcwd(); $dir =~ s=\\=/=g; @@ -451,37 +453,37 @@ sub copyFile $filecontents = <I>; close I; if ( open(I, "< " . $ifile) ) { - local $/; - binmode I; - $ifilecontents = <I>; - close I; - $copy = fileCompare($file, $ifile); - $knowdiff = 0, + local $/; + binmode I; + $ifilecontents = <I>; + close I; + $copy = fileCompare($file, $ifile); + $knowdiff = 0, } else { - $copy = -1; - $knowdiff = 1; + $copy = -1; + $knowdiff = 1; } if ( $knowdiff || ($filecontents ne $ifilecontents) ) { - if ( $copy > 0 ) { - my $file_dir = dirname($file); - mkpath $file_dir, 0777 unless(-e "$file_dir"); - open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; - local $/; - binmode O; - print O $ifilecontents; - close O; - return 1; - } elsif ( $copy < 0 ) { - my $ifile_dir = dirname($ifile); - mkpath $ifile_dir, 0777 unless(-e "$ifile_dir"); - open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)"; - local $/; - binmode O; - print O $filecontents; - close O; - return 1; - } + if ( $copy > 0 ) { + my $file_dir = dirname($file); + mkpath $file_dir, !$quiet unless(-e "$file_dir"); + open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)"; + local $/; + binmode O; + print O $ifilecontents; + close O; + return 1; + } elsif ( $copy < 0 ) { + my $ifile_dir = dirname($ifile); + mkpath $ifile_dir, !$quiet unless(-e "$ifile_dir"); + open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)"; + local $/; + binmode O; + print O $filecontents; + close O; + return 1; + } } return 0; } @@ -500,7 +502,7 @@ sub symlinkFile my ($file,$ifile) = @_; if ($isunix) { - print "symlink created for $file "; + print "symlink created for $file " unless $quiet; if ( $force_relative && ($ifile =~ /^$basedir/)) { my $t = getcwd(); my $c = -1; @@ -508,9 +510,9 @@ sub symlinkFile $t =~ s-^$basedir/--; $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 ); $file =~ s-^$basedir/-$p-; - print " ($file)\n"; + print " ($file)\n" unless $quiet; } - print "\n"; + print "\n" unless $quiet; return symlink($file, $ifile); } return copyFile($file, $ifile); @@ -566,87 +568,93 @@ while ( @ARGV ) { #parse my $arg = shift @ARGV; if ("$arg" eq "-h" || "$arg" eq "-help" || "$arg" eq "?") { - $var = "show_help"; - $val = "yes"; + $var = "show_help"; + $val = "yes"; } elsif("$arg" eq "-copy") { - $var = "copy"; - $val = "yes"; + $var = "copy"; + $val = "yes"; } elsif("$arg" eq "-o" || "$arg" eq "-outdir") { - $var = "output"; - $val = shift @ARGV; + $var = "output"; + $val = shift @ARGV; } elsif("$arg" eq "-showonly" || "$arg" eq "-remove-stale" || "$arg" eq "-windows" || - "$arg" eq "-relative" || "$arg" eq "-check-includes") { - $var = substr($arg, 1); - $val = "yes"; + "$arg" eq "-relative" || "$arg" eq "-check-includes") { + $var = substr($arg, 1); + $val = "yes"; } elsif("$arg" =~ /^-no-(.*)$/) { - $var = $1; - $val = "no"; - #these are for commandline compat + $var = $1; + $val = "no"; + #these are for commandline compat } elsif("$arg" eq "-inc") { - $var = "output"; - $val = shift @ARGV; + $var = "output"; + $val = shift @ARGV; } elsif("$arg" eq "-module") { - $var = "module"; - $val = shift @ARGV; + $var = "module"; + $val = shift @ARGV; } elsif("$arg" eq "-separate-module") { - $var = "separate-module"; - $val = shift @ARGV; + $var = "separate-module"; + $val = shift @ARGV; } elsif("$arg" eq "-show") { - $var = "showonly"; - $val = "yes"; + $var = "showonly"; + $val = "yes"; + } elsif("$arg" eq "-quiet") { + $var = "quiet"; + $val = "yes"; } elsif("$arg" eq "-base-dir") { # skip, it's been dealt with at the top of the file shift @ARGV; next; - } elsif("$arg" eq '*') { - # workaround for windows 9x where "%*" expands to "*" - $var = 1; } #do something if(!$var || "$var" eq "show_help") { - print "Unknown option: $arg\n\n" if(!$var); - showUsage(); + print "Unknown option: $arg\n\n" if(!$var); + showUsage(); } elsif ("$var" eq "copy") { - if("$val" eq "yes") { - $copy_headers++; - } elsif($showonly) { - $copy_headers--; - } + if("$val" eq "yes") { + $copy_headers++; + } elsif($showonly) { + $copy_headers--; + } } elsif ("$var" eq "showonly") { - if("$val" eq "yes") { - $showonly++; - } elsif($showonly) { - $showonly--; - } + if("$val" eq "yes") { + $showonly++; + } elsif($showonly) { + $showonly--; + } + } elsif ("$var" eq "quiet") { + if("$val" eq "yes") { + $quiet++; + } elsif($quiet) { + $quiet--; + } } elsif ("$var" eq "check-includes") { - if("$val" eq "yes") { - $check_includes++; - } elsif($check_includes) { - $check_includes--; - } + if("$val" eq "yes") { + $check_includes++; + } elsif($check_includes) { + $check_includes--; + } } elsif ("$var" eq "remove-stale") { - if("$val" eq "yes") { - $remove_stale++; - } elsif($remove_stale) { - $remove_stale--; - } + if("$val" eq "yes") { + $remove_stale++; + } elsif($remove_stale) { + $remove_stale--; + } } elsif ("$var" eq "windows") { - if("$val" eq "yes") { - $force_win++; - } elsif($force_win) { - $force_win--; - } + if("$val" eq "yes") { + $force_win++; + } elsif($force_win) { + $force_win--; + } } elsif ("$var" eq "relative") { - if("$val" eq "yes") { - $force_relative++; - } elsif($force_relative) { - $force_relative--; - } + if("$val" eq "yes") { + $force_relative++; + } elsif($force_relative) { + $force_relative--; + } } elsif ("$var" eq "module") { - print "module :$val:\n"; - die "No such module: $val" unless(defined $modules{$val}); - push @modules_to_sync, $val; + print "module :$val:\n" unless $quiet; + die "No such module: $val" unless(defined $modules{$val}); + push @modules_to_sync, $val; } elsif ("$var" eq "separate-module") { my ($module, $prodir, $headerdir) = split(/:/, $val); $modules{$module} = $prodir; @@ -655,16 +663,16 @@ while ( @ARGV ) { $create_uic_class_map = 0; $create_private_headers = 0; } elsif ("$var" eq "output") { - my $outdir = $val; - if(checkRelative($outdir)) { - $out_basedir = getcwd(); - chomp $out_basedir; - $out_basedir .= "/" . $outdir; - } else { - $out_basedir = $outdir; - } - # \ -> / - $out_basedir =~ s=\\=/=g; + my $outdir = $val; + if(checkRelative($outdir)) { + $out_basedir = getcwd(); + chomp $out_basedir; + $out_basedir .= "/" . $outdir; + } else { + $out_basedir = $outdir; + } + # \ -> / + $out_basedir =~ s=\\=/=g; } } @modules_to_sync = keys(%modules) if($#modules_to_sync == -1); @@ -672,7 +680,8 @@ while ( @ARGV ) { $isunix = checkUnix; #cache checkUnix # create path -mkpath "$out_basedir/include", 0777; +mkpath "$out_basedir/include", !$quiet; +mkpath "$out_basedir/include/Qt", !$quiet; my @ignore_headers = (); my $class_lib_map_contents = ""; @@ -680,7 +689,8 @@ my @ignore_for_master_contents = ( "qt.h", "qpaintdevicedefs.h" ); my @ignore_for_include_check = ( "qatomic.h" ); 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" ); 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" ); -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}" ); +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}" ); +my %colliding_headers = (); foreach (@modules_to_sync) { #iteration info @@ -700,77 +710,77 @@ foreach (@modules_to_sync) { #get dependencies if(-e "$dir/" . basename($dir) . ".pro") { - if(open(F, "<$dir/" . basename($dir) . ".pro")) { - while(<F>) { - my $line = $_; - chomp $line; - if($line =~ /^ *QT *\+?= *([^\r\n]*)/) { - foreach(split(/ /, "$1")) { - $master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core"); - $master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui"); - $master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network"); - $master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg"); - $master_contents .= "#include <QtDeclarative/QtDeclarative>\n" if("$_" eq "declarative"); - $master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script"); - $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools"); - $master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support"); - $master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql"); - $master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml"); - $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns"); - $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl"); - $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg"); - } - } - } - close(F); - } + if(open(F, "<$dir/" . basename($dir) . ".pro")) { + while(<F>) { + my $line = $_; + chomp $line; + if($line =~ /^ *QT *\+?= *([^\r\n]*)/) { + foreach(split(/ /, "$1")) { + $master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core"); + $master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui"); + $master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network"); + $master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg"); + $master_contents .= "#include <QtDeclarative/QtDeclarative>\n" if("$_" eq "declarative"); + $master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script"); + $master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools"); + $master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support"); + $master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql"); + $master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml"); + $master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns"); + $master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl"); + $master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg"); + } + } + } + close(F); + } } #remove the old files if($remove_stale) { - my @subdirs = ("$out_basedir/include/$lib"); - foreach (@subdirs) { - my $subdir = "$_"; - if (opendir DIR, "$subdir") { - while(my $t = readdir(DIR)) { - my $file = "$subdir/$t"; - if(-d "$file") { - push @subdirs, "$file" unless($t eq "." || $t eq ".."); - } else { - my @files = ("$file"); - #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t"); - foreach (@files) { - my $file = $_; - my $remove_file = 0; - if(open(F, "<$file")) { - while(<F>) { - my $line = $_; - chomp $line; - if($line =~ /^\#include \"([^\"]*)\"$/) { - my $include = $1; - $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); - $remove_file = 1 unless(-e "$include"); - } else { - $remove_file = 0; - last; - } - } - close(F); - unlink "$file" if($remove_file); - } - } - } - } - closedir DIR; + my @subdirs = ("$out_basedir/include/$lib"); + foreach (@subdirs) { + my $subdir = "$_"; + if (opendir DIR, "$subdir") { + while(my $t = readdir(DIR)) { + my $file = "$subdir/$t"; + if(-d "$file") { + push @subdirs, "$file" unless($t eq "." || $t eq ".."); + } else { + my @files = ("$file"); + #push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t"); + foreach (@files) { + my $file = $_; + my $remove_file = 0; + if(open(F, "<$file")) { + while(<F>) { + my $line = $_; + chomp $line; + if($line =~ /^\#include \"([^\"]*)\"$/) { + my $include = $1; + $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); + $remove_file = 1 unless(-e "$include"); + } else { + $remove_file = 0; + last; + } + } + close(F); + unlink "$file" if($remove_file); + } + } + } + } + closedir DIR; } - } + } } #create the new ones foreach (split(/;/, $dir)) { - my $current_dir = "$_"; - my $headers_dir = $current_dir; + my $current_dir = "$_"; + my $headers_dir = $current_dir; $headers_dir .= "/$pathtoheaders" if ($pathtoheaders); #calc subdirs my @subdirs = ($headers_dir); @@ -779,7 +789,7 @@ foreach (@modules_to_sync) { opendir DIR, "$subdir" or next; while(my $t = readdir(DIR)) { push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && - !($t eq "..") && !($t eq ".obj") && + !($t eq "..") && !($t eq ".obj") && !($t eq ".moc") && !($t eq ".rcc") && !($t eq ".uic") && !($t eq "build")); } @@ -797,85 +807,105 @@ foreach (@modules_to_sync) { $header = 0 if("$header" eq "$_"); } if($header) { - my $header_copies = 0; - #figure out if it is a public header - my $public_header = $header; - if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { - $public_header = 0; - } else { - foreach (@ignore_for_master_contents) { - $public_header = 0 if("$header" eq "$_"); - } - } + my $header_copies = 0; + #figure out if it is a public header + my $public_header = $header; + if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { + $public_header = 0; + } else { + foreach (@ignore_for_master_contents) { + $public_header = 0 if("$header" eq "$_"); + } + } my $iheader = $subdir . "/" . $header; - my @classes = $public_header ? classNames($iheader) : (); + my @classes = $public_header ? classNames($iheader) : (); if($showonly) { print "$header [$lib]\n"; - foreach(@classes) { - print "SYMBOL: $_\n"; - } + foreach(@classes) { + print "SYMBOL: $_\n"; + } } else { - #find out all the places it goes.. - my @headers; - if ($public_header) { - @headers = ( "$out_basedir/include/$lib/$header" ); - push @headers, "$out_basedir/include/Qt/$header" - if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/); + #find out all the places it goes.. + my @headers; + if ($public_header) { + @headers = ( "$out_basedir/include/$lib/$header" ); + + # write forwarding headers to include/Qt + if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/) { + my $file_name = "$out_basedir/include/Qt/$header"; + my $file_op = '>'; + my $header_content = ''; + if (exists $colliding_headers{$file_name}) { + $file_op = '>>'; + } else { + $colliding_headers{$file_name} = 1; + my $warning_msg = 'Inclusion of header files from include/Qt is deprecated.'; + $header_content = "#ifndef QT_NO_QT_INCLUDE_WARN\n" . + " #if defined(__GNUC__)\n" . + " #pragma warning \"$warning_msg\"\n" . + " #elif defined(_MSC_VER)\n" . + " #pragma message \"WARNING: $warning_msg\"\n" . + " #endif\n". + "#endif\n\n"; + } + $header_content .= '#include "' . "../$lib/$header" . "\"\n"; + open HEADERFILE, $file_op, $file_name or die "unable to open '$file_name' : $!\n"; + print HEADERFILE $header_content; + close HEADERFILE; + } - foreach(@classes) { - my $header_base = basename($header); - my $class = $_; - # Strip namespaces: - $class =~ s/^.*:://; -# if ($class =~ m/::/) { -# class =~ s,::,/,g; -# } - $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n"; - $header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0)); + foreach(@classes) { + my $header_base = basename($header); + my $class = $_; + # Strip namespaces: + $class =~ s/^.*:://; +# if ($class =~ m/::/) { +# class =~ s,::,/,g; +# } + $class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n"; + $header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0)); - # KDE-Compat headers for Phonon - if ($lib eq "phonon") { - $header_copies++ if (syncHeader("$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0)); - } - } - } elsif ($create_private_headers) { - @headers = ( "$out_basedir/include/$lib/private/$header" ); - push @headers, "$out_basedir/include/Qt/private/$header" - if ("$lib" ne "phonon"); - } - foreach(@headers) { #sync them - $header_copies++ if(syncHeader($_, $iheader, $copy_headers)); - } + # KDE-Compat headers for Phonon + if ($lib eq "phonon") { + $header_copies++ if (syncHeader("$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0)); + } + } + } elsif ($create_private_headers) { + @headers = ( "$out_basedir/include/$lib/private/$header" ); + } + foreach(@headers) { #sync them + $header_copies++ if(syncHeader($_, $iheader, $copy_headers)); + } - if($public_header) { - #put it into the master file - $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude($iheader)); + if($public_header) { + #put it into the master file + $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude($iheader)); - #deal with the install directives - if($public_header) { - my $pri_install_iheader = fixPaths($iheader, $current_dir); - foreach(@classes) { - my $class = $_; - # Strip namespaces: - $class =~ s/^.*:://; -# if ($class =~ m/::/) { -# $class =~ s,::,/,g; -# } - my $class_header = fixPaths("$out_basedir/include/$lib/$class", - $current_dir) . " "; - $pri_install_classes .= $class_header - unless($pri_install_classes =~ $class_header); - } - $pri_install_files.= "$pri_install_iheader ";; - } - } - else { - my $pri_install_iheader = fixPaths($iheader, $current_dir); - $pri_install_pfiles.= "$pri_install_iheader ";; - } + #deal with the install directives + if($public_header) { + my $pri_install_iheader = fixPaths($iheader, $current_dir); + foreach(@classes) { + my $class = $_; + # Strip namespaces: + $class =~ s/^.*:://; +# if ($class =~ m/::/) { +# $class =~ s,::,/,g; +# } + my $class_header = fixPaths("$out_basedir/include/$lib/$class", + $current_dir) . " "; + $pri_install_classes .= $class_header + unless($pri_install_classes =~ $class_header); + } + $pri_install_files.= "$pri_install_iheader ";; + } + } + else { + my $pri_install_iheader = fixPaths($iheader, $current_dir); + $pri_install_pfiles.= "$pri_install_iheader ";; + } } - print "header created for $iheader ($header_copies)\n" if($header_copies > 0); + print "header created for $iheader ($header_copies)\n" if($header_copies > 0 && !$quiet); } } } @@ -886,11 +916,12 @@ foreach (@modules_to_sync) { unless($showonly) { my @master_includes; - push @master_includes, "$out_basedir/include/$lib/$lib"; - push @master_includes, "$out_basedir/include/phonon_compat/Phonon/Phonon" if ($lib eq "phonon"); + push @master_includes, "$out_basedir/include/$lib/$lib"; + push @master_includes, "$out_basedir/include/phonon_compat/Phonon/Phonon" if ($lib eq "phonon"); foreach my $master_include (@master_includes) { #generate the "master" include file - $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too + my @tmp = split(/;/,$modules{$lib}); + $pri_install_files .= fixPaths($master_include, "$tmp[0]") . " "; #get the master file installed too if($master_include && -e "$master_include") { open MASTERINCLUDE, "<$master_include"; local $/; @@ -902,8 +933,8 @@ foreach (@modules_to_sync) { } if($master_include && $master_contents) { my $master_dir = dirname($master_include); - mkpath $master_dir, 0777; - print "header (master) created for $lib\n"; + mkpath $master_dir, !$quiet; + print "header (master) created for $lib\n" unless $quiet; open MASTERINCLUDE, ">$master_include"; print MASTERINCLUDE "$master_contents"; close MASTERINCLUDE; @@ -911,10 +942,10 @@ foreach (@modules_to_sync) { } #handle the headers.pri for each module - my $headers_pri_contents = ""; - $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n"; - $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n"; - $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n"; + my $headers_pri_contents = ""; + $headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n"; + $headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n"; + $headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n"; my $headers_pri_file = "$out_basedir/include/$lib/headers.pri"; if(-e "$headers_pri_file") { open HEADERS_PRI_FILE, "<$headers_pri_file"; @@ -927,8 +958,8 @@ foreach (@modules_to_sync) { } if($headers_pri_file && $master_contents) { my $headers_pri_dir = dirname($headers_pri_file); - mkpath $headers_pri_dir, 0777; - print "headers.pri file created for $lib\n"; + mkpath $headers_pri_dir, !$quiet; + print "headers.pri file created for $lib\n" unless $quiet; open HEADERS_PRI_FILE, ">$headers_pri_file"; print HEADERS_PRI_FILE "$headers_pri_contents"; close HEADERS_PRI_FILE; @@ -938,125 +969,125 @@ foreach (@modules_to_sync) { unless($showonly || !$create_uic_class_map) { my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h"; if(-e "$class_lib_map") { - open CLASS_LIB_MAP, "<$class_lib_map"; - local $/; - binmode CLASS_LIB_MAP; - my $old_class_lib_map_contents = <CLASS_LIB_MAP>; - close CLASS_LIB_MAP; - $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms - $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents); + open CLASS_LIB_MAP, "<$class_lib_map"; + local $/; + binmode CLASS_LIB_MAP; + my $old_class_lib_map_contents = <CLASS_LIB_MAP>; + close CLASS_LIB_MAP; + $old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms + $class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents); } if($class_lib_map) { - my $class_lib_map_dir = dirname($class_lib_map); - mkpath $class_lib_map_dir, 0777; - open CLASS_LIB_MAP, ">$class_lib_map"; - print CLASS_LIB_MAP "$class_lib_map_contents"; - close CLASS_LIB_MAP; + my $class_lib_map_dir = dirname($class_lib_map); + mkpath $class_lib_map_dir, !$quiet; + open CLASS_LIB_MAP, ">$class_lib_map"; + print CLASS_LIB_MAP "$class_lib_map_contents"; + close CLASS_LIB_MAP; } } if($check_includes) { for (keys(%modules)) { - #iteration info - my $lib = $_; - my $dir = "$modules{$lib}"; + #iteration info + my $lib = $_; + my $dir = "$modules{$lib}"; { - my $current_dir = "$_"; - #calc subdirs - my @subdirs = ($current_dir); - foreach (@subdirs) { - my $subdir = "$_"; - opendir DIR, "$subdir"; - while(my $t = readdir(DIR)) { + my $current_dir = "$_"; + #calc subdirs + my @subdirs = ($current_dir); + foreach (@subdirs) { + my $subdir = "$_"; + opendir DIR, "$subdir"; + while(my $t = readdir(DIR)) { push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") && !($t eq "..") && !($t eq ".obj") && !($t eq ".moc") && !($t eq ".rcc") && !($t eq ".uic") && !($t eq "build")); - } - closedir DIR; - } + } + closedir DIR; + } - foreach (@subdirs) { - my $subdir = "$_"; + foreach (@subdirs) { + my $subdir = "$_"; my $header_skip_qt_module_test = 0; foreach(@ignore_for_qt_module_check) { foreach (split(/;/, $_)) { $header_skip_qt_module_test = 1 if ("$subdir" =~ /^$_/); } } - my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0); - foreach (@headers) { - my $header = "$_"; + my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0); + foreach (@headers) { + my $header = "$_"; my $header_skip_qt_begin_header_test = 0; my $header_skip_qt_begin_namespace_test = 0; - $header = 0 if("$header" =~ /^ui_.*.h/); - foreach (@ignore_headers) { - $header = 0 if("$header" eq "$_"); - } - if($header) { - my $public_header = $header; - if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { - $public_header = 0; - } else { - foreach (@ignore_for_master_contents) { - $public_header = 0 if("$header" eq "$_"); - } - if($public_header) { - foreach (@ignore_for_include_check) { - $public_header = 0 if("$header" eq "$_"); - } + $header = 0 if("$header" =~ /^ui_.*.h/); + foreach (@ignore_headers) { + $header = 0 if("$header" eq "$_"); + } + if($header) { + my $public_header = $header; + if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) { + $public_header = 0; + } else { + foreach (@ignore_for_master_contents) { + $public_header = 0 if("$header" eq "$_"); + } + if($public_header) { + foreach (@ignore_for_include_check) { + $public_header = 0 if("$header" eq "$_"); + } foreach(@ignore_for_qt_begin_header_check) { $header_skip_qt_begin_header_test = 1 if ("$header" eq "$_"); } foreach(@ignore_for_qt_begin_namespace_check) { $header_skip_qt_begin_namespace_test = 1 if ("$header" eq "$_"); } - } - } + } + } - my $iheader = $subdir . "/" . $header; - if($public_header) { - if(open(F, "<$iheader")) { + my $iheader = $subdir . "/" . $header; + if($public_header) { + if(open(F, "<$iheader")) { my $qt_module_found = 0; - my $qt_begin_header_found = 0; - my $qt_end_header_found = 0; - my $qt_begin_namespace_found = 0; - my $qt_end_namespace_found = 0; - my $line; - while($line = <F>) { - chomp $line; - my $output_line = 1; + my $qt_begin_header_found = 0; + my $qt_end_header_found = 0; + my $qt_begin_namespace_found = 0; + my $qt_end_namespace_found = 0; + my $line; + while($line = <F>) { + chomp $line; + my $output_line = 1; if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) { - last; - } elsif($line =~ /^ *\# *include/) { - my $include = $line; - if($line =~ /<.*>/) { - $include =~ s,.*<(.*)>.*,$1,; - } elsif($line =~ /".*"/) { - $include =~ s,.*"(.*)".*,$1,; - } else { - $include = 0; - } - if($include) { - for (keys(%modules)) { - my $trylib = $_; - if(-e "$out_basedir/include/$trylib/$include") { - print "WARNING: $iheader includes $include when it should include $trylib/$include\n"; - } - } - } - } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) { - $qt_begin_header_found = 1; - } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) { - $qt_end_header_found = 1; - } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) { - $qt_begin_namespace_found = 1; - } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) { - $qt_end_namespace_found = 1; + last; + } elsif($line =~ /^ *\# *include/) { + my $include = $line; + if($line =~ /<.*>/) { + $include =~ s,.*<(.*)>.*,$1,; + } elsif($line =~ /".*"/) { + $include =~ s,.*"(.*)".*,$1,; + } else { + $include = 0; + } + if($include) { + for (keys(%modules)) { + my $trylib = $_; + if(-e "$out_basedir/include/$trylib/$include") { + print "WARNING: $iheader includes $include when it should include $trylib/$include\n"; + } + } + } + } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) { + $qt_begin_header_found = 1; + } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) { + $qt_end_header_found = 1; + } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) { + $qt_begin_namespace_found = 1; + } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) { + $qt_end_namespace_found = 1; } elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) { $qt_module_found = 1; } - } + } if ($header_skip_qt_begin_header_test == 0) { if ($qt_begin_header_found == 0) { print "WARNING: $iheader does not include QT_BEGIN_HEADER\n"; @@ -1082,13 +1113,13 @@ if($check_includes) { print "WARNING: $iheader does not include QT_MODULE\n"; } } - close(F); - } - } - } - } - } - } + close(F); + } + } + } + } + } + } } } |