diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-06-20 10:34:13 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-20 12:38:32 +0200 |
commit | 6d9c545d2b83305c3c30a0e917e6c3a474dfe66a (patch) | |
tree | 54a003c6db32c85f80c5fbb46dbf9322855966e6 /bin | |
parent | 86f953a6d40666a3355e76b3ab2c8a2cf5452ec6 (diff) | |
parent | b652bffea7a0a1bf209c21d9b73f509226f031bd (diff) |
Merge "Merge branch 'buildsystem'" into refs/staging/master
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/qtmodule-configtests | 12 | ||||
-rwxr-xr-x | bin/syncqt | 299 |
2 files changed, 69 insertions, 242 deletions
diff --git a/bin/qtmodule-configtests b/bin/qtmodule-configtests index 965a3e556b..c6ebe2fafd 100755 --- a/bin/qtmodule-configtests +++ b/bin/qtmodule-configtests @@ -57,7 +57,6 @@ use File::Path 'mkpath'; use File::Spec::Functions qw/ :ALL /; use File::Temp qw/ :POSIX /; use Cwd; -use Cwd 'abs_path'; use Config; # Which file to look for the %configtests variable in @@ -77,9 +76,8 @@ my $generator = $ARGV[3]; our %configtests; -my $absOutDir = abs_path($out_basedir); -my $qmakeCachePath = catfile($absOutDir, '.qmake.cache'); -my $configLogPath = catfile($absOutDir, 'config.log'); +my $qmakeCachePath = catfile($out_basedir, '.qmake.cache'); +my $configLogPath = catfile($out_basedir, 'config.log'); my $QMAKE = catfile($qtbasedir, "bin", ($^O =~ /win32/i) ? 'qmake.exe' : 'qmake'); if (!-x $QMAKE) { @@ -241,13 +239,13 @@ sub executeTest { my @QMAKEARGS = ('CONFIG-=debug_and_release', 'CONFIG-=app_bundle'); - my $testOutDir = catdir($absOutDir, 'config.tests', $testName); + my $testOutDir = catdir($out_basedir, 'config.tests', $testName); # Since we might be cross compiling, look for barename (Linux) and .exe (Win32/Symbian) my $testOutFile1 = catfile($testOutDir, "$testName.exe"); my $testOutFile2 = catfile($testOutDir, $testName); - if (abs_path($basedir) eq abs_path($out_basedir)) { + if ($basedir eq $out_basedir) { chdir $testOutDir or die "\nUnable to change to config test directory ($testOutDir): $!\n"; } else { # shadow build if (! -e $testOutDir) { @@ -315,7 +313,7 @@ loadConfigTests(); # Only do this step for modules that have config tests # (qtbase doesn't). We try to preserve existing contents (and furthermore # only write to .qmake.cache if the tests change) -if (abs_path($out_basedir) ne abs_path($qtbasedir)) { +if ($out_basedir ne $qtbasedir) { # Read any existing content my $existingContents = fileContents($qmakeCachePath); my %oldTestResults; diff --git a/bin/syncqt b/bin/syncqt index 3581e31d84..5f8bbe248a 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -47,6 +47,7 @@ # use packages ------------------------------------------------------- use File::Basename; use File::Path; +use File::Spec; use Cwd; use Cwd 'abs_path'; use Config; @@ -82,16 +83,11 @@ our $quoted_basedir; # Make sure we use Windows line endings for chomp and friends on Windows. $INPUT_RECORD_SEPARATOR = "\r\n" if ($^O eq "msys"); -# try to figure out where QtBase is located -# normally the script location should be enough, if not fall back to -# QTDIR environment variable. If that doesn't work, later ask the -# user to use the -qtdir option explicitly. -my $qtbasedir = $ENV{"QTDIR"}; -$qtbasedir = dirname(dirname($0)) if (!$qtbasedir); +my $qtbasedir = dirname(dirname($0)); normalizePath(\$qtbasedir) if (defined $qtbasedir); # will be defined based on the modules sync.profile -our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %mastercontent, %modulepris, %explicitheaders, %deprecatedheaders); +our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %modulepris, %explicitheaders, %deprecatedheaders); # global variables (modified by options) my $isunix = 0; @@ -106,10 +102,7 @@ my $copy_headers = 0; my $create_uic_class_map = 0; my $create_private_headers = 1; my $module_fwd = ""; -my $cache_module_fwd = 0; my $developer_build = 0; -my $no_module_version_header = 0; -my $makefile_generator = ""; my @modules_to_sync ; $force_relative = 1 if ( -d "/System/Library/Frameworks" ); @@ -144,13 +137,8 @@ sub showUsage print " -private Force copy private headers (default: " . ($create_private_headers ? "yes" : "no") . ")\n"; print " -module-fwd <PATH> Create fwd includes for module pri files in the given\n"; print " path (default: none)\n"; - print " -cache-module-fwd Create a .qmake.cache file to cache the location of the\n"; - print " fwd includes\n"; print " -developer-build Point libraries and binaries to a common directory for\n"; print " easy development\n"; - print " -no-module-version-header\n"; - print " Don't create module version header file\n"; - print " -generator <PATH> Specify the makefile generator setting (e.g. 'UNIX')\n"; print " -help This help\n"; exit 0; } @@ -189,30 +177,6 @@ sub checkRelative { } ###################################################################### -# Syntax: shouldMasterInclude(iheader) -# Params: iheader, string, filename to verify inclusion -# -# Purpose: Determines if header should be in the master include file. -# Returns: 0 if file contains "#pragma qt_no_master_include" or not -# able to open, else 1. -###################################################################### -sub shouldMasterInclude { - my ($iheader) = @_; - return 0 if(basename($iheader) =~ /_/); - return 0 if(basename($iheader) =~ /qconfig/); - if(open(F, "<$iheader")) { - while(<F>) { - chomp; - return 0 if(/^\#pragma qt_no_master_include$/); - } - close(F); - } else { - return 0; - } - return 1; -} - -###################################################################### # Syntax: classNames(iheader) # Params: iheader, string, filename to parse for classname "symlinks" # @@ -391,50 +355,20 @@ sub syncHeader { # Purpose: file is made relative (if possible) of dir. # Returns: String with the above applied conversion. ###################################################################### + +sub cleanupPath { + my ($file) = @_; + normalizePath(\$file); + while ($file =~ s,/[^/]+/\.\./,/,) {} + return $file; +} + sub fixPaths { my ($file, $dir) = @_; - normalizePath(\$file); - normalizePath(\$dir); - #setup - my $ret = $file; - $ret =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; - my $file_dir = dirname($file); - if($file_dir eq ".") { - $file_dir = getcwd(); - normalizePath(\$file_dir); - } - $file_dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; - if($dir eq ".") { - $dir = getcwd(); - normalizePath(\$dir); - } - $dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g; - return basename($file) if($file_dir eq $dir); - - #guts - while ($file_dir =~ s,/[^/]+/\.\./,/,) {} - while ($dir =~ s,/[^/]+/\.\./,/,) {} - my $match_dir = 0; - for(my $i = 1; $i < length($file_dir); $i++) { - my $slash = index($file_dir, "/", $i); - last if($slash == -1); - my $tmp = substr($file_dir, 0, $slash); - last unless($dir =~ m,^\Q$tmp\E/,); - $match_dir = $tmp; - $i = $slash; - } - if($match_dir) { - my $after = substr($dir, length($match_dir)); - my $count = ($after =~ tr,/,,); - my $dots = ""; - for(my $i = 0; $i < $count; $i++) { - $dots .= "../"; - } - $ret =~ s,^\Q$match_dir\E,$dots,; - } - $ret =~ s,/+,/,g; - return $ret; + my $out = File::Spec->abs2rel(cleanupPath($file), cleanupPath($dir)); + $out =~ s,\\,/,g; + return $out; } ###################################################################### @@ -625,6 +559,18 @@ sub loadSyncProfile { return $result; } +sub basePrettify { + my ($arg) = @_; + $$arg =~ s,^\Q$basedir\E,<srcbase>,; + $$arg =~ s,^\Q$out_basedir\E,<outbase>,; +} + +sub cleanPath { + my ($arg) = @_; + while ($arg =~ s,[^/]+/\.\.(/|$),,) {} + return $arg; +} + sub locateSyncProfile { my ($directory) = @_; @@ -672,15 +618,9 @@ while ( @ARGV ) { } elsif($arg eq "-module-fwd") { $var = "module_fwd"; $val = shift @ARGV; - } elsif($arg eq "-cache-module-fwd") { - $var = "cache_module_fwd"; - $val = "yes"; } elsif($arg eq "-developer-build") { $var = "developer_build"; $val = "yes"; - } elsif($arg eq "-no-module-version-header") { - $var = "no_module_version_header"; - $val = "yes"; } elsif($arg =~ /^-no-(.*)$/) { $var = $1; $val = "no"; @@ -712,9 +652,6 @@ while ( @ARGV ) { } elsif($arg eq "-qtdir") { $var = "qtdir"; $val = shift @ARGV; - } elsif($arg eq "-generator") { - $var = "makefile_generator"; - $val = shift @ARGV; } elsif($arg =~/^-/) { print "Unknown option: $arg\n\n" if(!$var); showUsage(); @@ -794,14 +731,8 @@ while ( @ARGV ) { } } elsif ($var eq "module_fwd") { $module_fwd = $val; - } elsif ($var eq "cache_module_fwd") { - $cache_module_fwd = 1; } elsif ($var eq "developer_build") { $developer_build = 1; - } elsif ($var eq "makefile_generator") { - $makefile_generator = $val; - } elsif ($var eq "no_module_version_header") { - $no_module_version_header = 1; } elsif ($var eq "output") { my $outdir = $val; if(checkRelative($outdir)) { @@ -830,8 +761,7 @@ our @ignore_for_include_check = (); our @ignore_for_qt_begin_header_check = (); our @ignore_for_qt_begin_namespace_check = (); our @ignore_for_qt_module_check = (); -my %colliding_headers = (); -my %inject_headers = ( "$basedir/src/corelib/global" => ( "qconfig.h" ) ); # all from build dir +our %inject_headers = (); # load the module's sync.profile here, before we can loadSyncProfile(\$basedir, \$out_basedir); @@ -842,15 +772,24 @@ my %allmoduleheadersprivate = map { $_ => 1 } @allmoduleheadersprivate; $isunix = checkUnix; #cache checkUnix +my $qt_version = fileContents($qtbasedir."/mkspecs/qconfig.pri"); +if (length($qt_version)) { + $qt_version =~ s,.*^QT_VERSION\h*=\h*(\S+).*,$1,sm; +} else { + $qt_version = fileContents($basedir."/src/corelib/global/qglobal.h"); + $qt_version =~ s,.*^#\h*define\h+QT_VERSION_STR\h+"([^"]+)".*,$1,sm; +} foreach my $lib (@modules_to_sync) { #iteration info my $dir = $modules{$lib}; - my $module_version = ""; - my $module_major_version = 0; - my $module_minor_version = 0; - my $module_patch_version = 0; - if (-e "$modulepris{$lib}") { + my $project = $dir; + $project =~ s,/([^/]+)$,/$1/$1.pro,; + my $module_version = fileContents($project); + $module_version = $qt_version unless ($module_version =~ s,.*^VERSION\h*=\h*(\S+).*,$1,sm); + + # Backwards compatibility for modules with checked in .pri files. + if (defined $modulepris{$lib} and -e "$modulepris{$lib}") { my $content = fileContents($modulepris{$lib}); my @version_rows = grep(/QT\..*\.VERSION/, split('\n', $content)); if(@version_rows) { @@ -859,16 +798,8 @@ foreach my $lib (@modules_to_sync) { chomp $module_version; $module_version =~ s/^\s*QT\..*\.VERSION\s*=\s*([^#]+).*$/$1/; $module_version =~ s/\s+$//; - my @versions = split(/\./, $module_version); - $module_major_version = int($versions[0]); - chomp $module_major_version; - $module_minor_version = int($versions[1]); - chomp $module_minor_version; - $module_patch_version = int($versions[2]); - chomp $module_patch_version; } } - print "$lib: WARNING: Module\'s pri missing QT.<module>.VERSION variable! Private headers not versioned!\n" if (!$module_version); my $pathtoheaders = ""; $pathtoheaders = $moduleheaders{$lib} if ($moduleheaders{$lib}); @@ -882,29 +813,20 @@ foreach my $lib (@modules_to_sync) { my $pri_install_pfiles = ""; my $pri_install_qpafiles = ""; - my $libcapitals = $lib; - $libcapitals =~ y/a-z/A-Z/; - my $master_contents = "#ifndef QT_".$libcapitals."_MODULE_H\n#define QT_".$libcapitals."_MODULE_H\n"; - - #get dependencies - if(-e "$dir/" . basename($dir) . ".pro") { - if(open(F, "<$dir/" . basename($dir) . ".pro")) { - while(my $line = <F>) { - chomp $line; - if($line =~ /^ *QT *\+?= *([^\r\n]*)/) { - foreach(split(/ /, $1)) { - $_ =~ s/-private$//; - my $content = $mastercontent{$_}; - $master_contents .= $content if ($content); - } - } - } - close(F); - } - } + push @{$inject_headers{$dir}}, lc($lib)."version.h"; + $classnames{lc($lib)."version.h"} = $lib."Version"; #remove the old files if($remove_stale) { + my %injections = (); + for my $p (keys %inject_headers) { + next unless ($p =~ /^\Q$dir\E(\/|$)/); + my $sp = $p; + $sp =~ s,^\Q$basedir\E/,$out_basedir/,; + for my $n (@{$inject_headers{$p}}) { + $injections{$sp."/".$n} = 1; + } + } my @subdirs = ("$out_basedir/include/$lib"); foreach my $subdir (@subdirs) { if (opendir DIR, $subdir) { @@ -923,7 +845,7 @@ foreach my $lib (@modules_to_sync) { if($line =~ /^\#include \"([^\"]*)\"$/) { my $include = $1; $include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/"); - $remove_file = 1 unless(-e $include); + $remove_file = 1 unless(-e $include or defined $injections{cleanPath($include)}); } else { $remove_file = 0; last; @@ -941,32 +863,6 @@ foreach my $lib (@modules_to_sync) { } } - # create the version header files for each module - unless ($no_module_version_header) { - my $modulepri = $modulepris{$lib}; - if (-e $modulepri) { - my $modulepriname = basename($modulepri); - # FIXME: this creates a file in the source location for shadow-builds - my $moduleversionheader = "$modules{$lib}/" . lc($lib) . "version.h"; - my $modulehexstring = sprintf("0x%02X%02X%02X", $module_major_version, $module_minor_version, $module_patch_version); - open MODULE_VERSION_HEADER_FILE, ">$moduleversionheader" or die "Can't open $moduleversionheader for writing"; - print MODULE_VERSION_HEADER_FILE "/* This file was generated by syncqt with the info from sync.profile. */\n"; - print MODULE_VERSION_HEADER_FILE "#ifndef QT_". uc($lib) . "_VERSION_H\n"; - print MODULE_VERSION_HEADER_FILE "#define QT_". uc($lib) . "_VERSION_H\n"; - print MODULE_VERSION_HEADER_FILE "\n"; - print MODULE_VERSION_HEADER_FILE "#define " .uc($lib) . "_VERSION_STR \"" . $module_version . "\"\n"; - print MODULE_VERSION_HEADER_FILE "\n"; - print MODULE_VERSION_HEADER_FILE "#define " .uc($lib) . "_VERSION $modulehexstring\n", ; - print MODULE_VERSION_HEADER_FILE "\n"; - print MODULE_VERSION_HEADER_FILE "#endif // QT_". uc($lib) . "_VERSION_H\n"; - close MODULE_VERSION_HEADER_FILE; - $moduleversionheader = "<srcbase>" . substr($moduleversionheader, length($basedir)) if ($verbose_level < 2); - print "$lib: created version header $moduleversionheader\n" if($verbose_level); - } elsif ($modulepri) { - print "$lib: WARNING: Module\'s pri file '$modulepri' not found.\n$lib: Skipped creating module version header.\n"; - } - } - #create the new ones foreach my $current_dir (split(/;/, $dir)) { my @headers_paths = split(/;/, $pathtoheaders); @@ -997,7 +893,7 @@ foreach my $lib (@modules_to_sync) { foreach my $subdir (@subdirs) { my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0); if (defined $inject_headers{$subdir}) { - foreach my $if ($inject_headers{$subdir}) { + foreach my $if (@{$inject_headers{$subdir}}) { @headers = grep(!/^\Q$if\E$/, @headers); #in case we configure'd previously push @headers, "*".$if; } @@ -1066,17 +962,9 @@ foreach my $lib (@modules_to_sync) { } } elsif ($create_private_headers && !$qpa_header) { - if ($module_version) { - @headers = ( "$out_basedir/include/$lib/$module_version/$lib/private/$header" ); - } else { - @headers = ( "$out_basedir/include/$lib/private/$header" ); - } + @headers = ( "$out_basedir/include/$lib/$module_version/$lib/private/$header" ); } elsif ($create_private_headers) { - if ($module_version) { - @headers = ( "$out_basedir/include/$lib/$module_version/$lib/qpa/$header" ); - } else { - @headers = ( "$out_basedir/include/$lib/qpa/$header" ); - } + @headers = ( "$out_basedir/include/$lib/$module_version/$lib/qpa/$header" ); } foreach(@headers) { #sync them @@ -1084,9 +972,6 @@ foreach my $lib (@modules_to_sync) { } 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); @@ -1120,7 +1005,7 @@ foreach my $lib (@modules_to_sync) { if ($verbose_level && $header_copies) { my $new_header_dirname = dirname($iheader); - $new_header_dirname = "<srcbase>" . substr($new_header_dirname, length($basedir)) if ($new_header_dirname && $verbose_level < 2); + basePrettify(\$new_header_dirname) if ($new_header_dirname && $verbose_level < 2); my $header_base = basename($iheader); if ($verbose_level < 3) { my $line_prefix = ","; @@ -1133,7 +1018,7 @@ foreach my $lib (@modules_to_sync) { } print "$line_prefix $header_base ($header_copies)"; } else { # $verbose_level >= 3 - $iheader = "<srcbase>" . substr($iheader, length($basedir)) if ($verbose_level == 3); + basePrettify(\$iheader) if ($verbose_level == 3); print "$lib: created $header_copies fwd-include headers for $iheader\n"; } } @@ -1144,9 +1029,6 @@ foreach my $lib (@modules_to_sync) { } } - # close the master include: - $master_contents .= "#endif\n"; - unless($showonly) { # create deprecated headers my $first = 1; @@ -1157,11 +1039,7 @@ foreach my $lib (@modules_to_sync) { my $header_path = "$out_basedir/include/$lib/"; unless ($public_header) { - if ($module_version) { - $header_path .= "$module_version/$lib/private/"; - } else { - $header_path .= "private/"; - } + $header_path .= "$module_version/$lib/private/"; } $header_path .= "$header"; @@ -1213,30 +1091,9 @@ foreach my $lib (@modules_to_sync) { print " }\n" unless ($first); } - 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"); - foreach my $master_include (@master_includes) { - #generate the "master" include file - 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 $/; - binmode MASTERINCLUDE; - my $oldmaster = <MASTERINCLUDE>; - close MASTERINCLUDE; - $oldmaster =~ s/\r//g; # remove \r's , so comparison is ok on all platforms - $master_include = 0 if($oldmaster eq $master_contents); - } - if($master_include && $master_contents) { - my $master_dir = dirname($master_include); - make_path($master_dir, $lib, $verbose_level); - open MASTERINCLUDE, ">$master_include"; - print MASTERINCLUDE $master_contents; - close MASTERINCLUDE; - print "$lib: created header (master) file\n" if($verbose_level); - } + # KDE-Compat master header for Phonon + if ($lib eq "phonon") { + syncHeader($lib, "$out_basedir/include/phonon_compat/Phonon/Phonon", "$out_basedir/include/phonon/phonon", 0); } #handle the headers.pri for each module @@ -1255,7 +1112,7 @@ foreach my $lib (@modules_to_sync) { $old_headers_pri_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms $headers_pri_file = 0 if($old_headers_pri_contents eq $headers_pri_contents); } - if($headers_pri_file && $master_contents) { + if($headers_pri_file) { my $headers_pri_dir = dirname($headers_pri_file); make_path($headers_pri_dir, $lib, $verbose_level); open HEADERS_PRI_FILE, ">$headers_pri_file"; @@ -1267,7 +1124,7 @@ foreach my $lib (@modules_to_sync) { # create forwarding module pri in qtbase/mkspecs/modules if ($module_fwd) { my $modulepri = $modulepris{$lib}; - if (-e $modulepri) { + if (defined $modulepri and -e $modulepri) { my $modulepriname = basename($modulepri); make_path($module_fwd, $lib, $verbose_level); my $moduleprifwd = "$module_fwd/$modulepriname"; @@ -1283,17 +1140,6 @@ foreach my $lib (@modules_to_sync) { print MODULE_PRI_FILE "include($modulepri)\n"; close MODULE_PRI_FILE; utime(time, (stat($modulepri))[9], $moduleprifwd); - if ($cache_module_fwd) { - my $cacheStatement = "QMAKE_EXTRA_MODULE_FORWARDS = \"$module_fwd\""; - my $cacheFile = "$out_basedir/.qmake.cache"; - my $existingQmakeCache = fileContents($cacheFile); - # Skip if it's already there. - if ($existingQmakeCache !~ $cacheStatement) { - open QMAKE_CACHE_FILE, ">>$cacheFile" or die("Could not open $cacheFile for writing"); - print QMAKE_CACHE_FILE "$cacheStatement\n"; - close(QMAKE_CACHE_FILE); - } - } } elsif ($modulepri) { print "$lib: WARNING: Module\'s pri file '$modulepri' not found.\n$lib: Skipped creating forwarding pri.\n"; } @@ -1441,21 +1287,4 @@ if($check_includes) { } } -# Do configure tests now (pass some things along) -# fatal tests have a non zero return -# If the generator is not set (e.g. someone invoking syncqt as part of configure etc, then don't run tests either) -unless ($showonly || $makefile_generator eq '') { - my $configtests = dirname($0)."/qtmodule-configtests"; - if (! -f $configtests) { - $configtests = $qtbasedir."/bin/qtmodule-configtests"; - } - if (! -f $configtests) { - warn "Unable to locate qtmodule-configtests script - config tests disabled.\n"; - } else { - if (system($EXECUTABLE_NAME, $configtests, $basedir, $out_basedir, $qtbasedir, $makefile_generator)) { - die "$configtests exited with status $?"; - } - } -} - exit 0; |