From 07bed9a211115c56bfa63983b0502f691f19f789 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Mon, 15 Nov 2010 13:55:17 -0600 Subject: Make syncqt use sync.profile files from each module The sync.profile replaces the hardcoded paths inside syncqt, and enables it to work for other modules than just qtbase. --- bin/syncqt | 163 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 84 insertions(+), 79 deletions(-) (limited to 'bin/syncqt') diff --git a/bin/syncqt b/bin/syncqt index b8671063c4..e3d941b109 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -12,40 +12,22 @@ use File::Basename; use File::Path; use Cwd; +use Cwd 'abs_path'; use Config; use strict; -for (my $i = 0; $i < $#ARGV; $i++) { - if ($ARGV[$i] eq "-base-dir" && $i < $#ARGV - 1) { - $ENV{"QTDIR"} = $ARGV[$i + 1]; - last; - } -} +# set output basedir to be where ever syncqt is run from +our $out_basedir = getcwd(); +$out_basedir =~ s=\\=/=g; +our $basedir; +our $quoted_basedir; -die "syncqt: QTDIR not defined" if ! $ENV{"QTDIR"}; # sanity check -# global variables -my $isunix = 0; -my $basedir = $ENV{"QTDIR"}; -$basedir =~ s=\\=/=g; -my %modules = ( # path to module name map - "QtGui" => "$basedir/src/gui", - "QtOpenGL" => "$basedir/src/opengl", - "QtOpenVG" => "$basedir/src/openvg", - "QtCore" => "$basedir/src/corelib", - "QtXml" => "$basedir/src/xml", - "QtSql" => "$basedir/src/sql", - "QtNetwork" => "$basedir/src/network", - "QtSvg" => "$basedir/src/svg", - "QtTest" => "$basedir/src/testlib", - "QtDBus" => "$basedir/src/dbus", -); -my %moduleheaders = ( # restrict the module headers to those found in relative path -); - -#$modules{"QtCore"} .= ";$basedir/mkspecs/" . $ENV{"MKSPEC"} if defined $ENV{"MKSPEC"}; +# will be defined based on the modules sync.profile +our (%modules, %moduleheaders, %classnames, %mastercontent); # global variables (modified by options) +my $isunix = 0; my $module = 0; my $showonly = 0; my $quiet = 0; @@ -58,9 +40,7 @@ my $create_uic_class_map = 1; my $create_private_headers = 1; my @modules_to_sync ; $force_relative = 1 if ( -d "/System/Library/Frameworks" ); -my $out_basedir = $basedir; -$out_basedir =~ s=\\=/=g; -my $quoted_basedir = "\Q$basedir"; + # functions ---------------------------------------------------------- @@ -74,6 +54,8 @@ my $quoted_basedir = "\Q$basedir"; sub showUsage { print "$0 usage:\n"; + print " Specifies which module to sync header files for (required for shadow builds!)\n\n"; + print " -copy Copy headers instead of include-fwd(default: " . ($copy_headers ? "yes" : "no") . ")\n"; print " -remove-stale Removes stale headers (default: " . ($remove_stale ? "yes" : "no") . ")\n"; print " -relative Force relative symlinks (default: " . ($force_relative ? "yes" : "no") . ")\n"; @@ -155,37 +137,9 @@ sub shouldMasterInclude { sub classNames { my @ret; my ($iheader) = @_; - if(basename($iheader) eq "qglobal.h") { - push @ret, "QtGlobal"; - } elsif(basename($iheader) eq "qendian.h") { - push @ret, "QtEndian"; - } elsif(basename($iheader) eq "qconfig.h") { - push @ret, "QtConfig"; - } elsif(basename($iheader) eq "qplugin.h") { - push @ret, "QtPlugin"; - } elsif(basename($iheader) eq "qalgorithms.h") { - push @ret, "QtAlgorithms"; - } elsif(basename($iheader) eq "qcontainerfwd.h") { - push @ret, "QtContainerFwd"; - } elsif(basename($iheader) eq "qdebug.h") { - push @ret, "QtDebug"; - } elsif(basename($iheader) eq "qevent.h") { - push @ret, "QtEvents"; - } elsif(basename($iheader) eq "qnamespace.h") { - push @ret, "Qt" - } elsif(basename($iheader) eq "qssl.h") { - push @ret, "QSsl"; - } elsif(basename($iheader) eq "qtest.h") { - push @ret, "QTest" - } elsif(basename($iheader) eq "qtconcurrentmap.h") { - push @ret, "QtConcurrentMap" - } elsif(basename($iheader) eq "qtconcurrentfilter.h") { - push @ret, "QtConcurrentFilter" - } elsif(basename($iheader) eq "qtconcurrentrun.h") { - push @ret, "QtConcurrentRun" - } elsif(basename($iheader) eq "qaudio.h") { - push @ret, "QAudio" - } + + my $classname = $classnames{basename($iheader)}; + push @ret, $classname if ($classname); my $parsable = ""; if(open(F, "<$iheader")) { @@ -548,6 +502,52 @@ sub findFiles { return @files; } +###################################################################### +# Syntax: loadSyncProfile() +# +# Purpose: Locates the sync.profile. +# Returns: Hashmap of module name -> directory. +###################################################################### +sub loadSyncProfile { + my ($srcbase, $outbase) = @_; + print("srcbase = $$srcbase \n"); + print("outbase = $$outbase \n"); + + my $syncprofile = "$$srcbase/sync.profile"; + my $result; + unless ($result = do "$syncprofile") { + die "syncqt couldn't parse $syncprofile: $@" if $@; + die "syncqt couldn't execute $syncprofile: $!" unless defined $result; + } + return $result; +} + +sub locateSyncProfile +{ + my ($directory) = @_; + my $syncprofile; + $directory = abs_path($directory); + while(!defined $syncprofile) { + local(*D); + if (opendir(D, $directory)) { + foreach my $file (sort readdir(D)) { + next if ($file =~ /^\.\.?$/); + $syncprofile = "$directory/$file" if ($file =~ /^sync\.profile$/); + last if (defined $syncprofile); + } + closedir(D); + } + last if (defined $syncprofile || $directory eq "/" || $directory =~ /^?:[\/\\]$/); + $directory = dirname($directory); + } + return $syncprofile; +} + +# check if this is an in-source build, and if so use that as the basedir too +$basedir = locateSyncProfile($out_basedir); +$basedir = dirname($basedir) if ($basedir); +$quoted_basedir = "\Q$basedir"; + # -------------------------------------------------------------------- # "main" function # -------------------------------------------------------------------- @@ -597,6 +597,15 @@ while ( @ARGV ) { # skip, it's been dealt with at the top of the file shift @ARGV; next; + } elsif($arg =~/^-/) { + print "Unknown option: $arg\n\n" if(!$var); + showUsage(); + } else { + $basedir = locateSyncProfile($arg); + die "Could not find a sync.profile for '$arg'\n" if (!$basedir); + $basedir = dirname($basedir); + $basedir =~ s=\\=/=g; + $var = "ignore"; } #do something @@ -668,6 +677,13 @@ while ( @ARGV ) { $out_basedir =~ s=\\=/=g; } } + +# if we have no $basedir we cannot be sure which sources you want, so die +die "Could not find any sync.profile for your module!\nPass to syncqt to sync your header files.\nsyncqt failed" if (!$basedir); + +# load the module's sync.profile here, before we can +loadSyncProfile(\$basedir, \$out_basedir); + @modules_to_sync = keys(%modules) if($#modules_to_sync == -1); $isunix = checkUnix; #cache checkUnix @@ -678,11 +694,11 @@ mkpath "$out_basedir/include/Qt", !$quiet; my @ignore_headers = (); my $class_lib_map_contents = ""; -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", "qatomic_arm.h", "qatomic_armv7.h" ); -my @ignore_for_qt_module_check = ( "$modules{QtCore}/arch", "$modules{QtCore}/global", "$modules{QtSql}/drivers", "$modules{QtTest}", "$modules{QtDBus}" ); +our @ignore_for_master_contents = (); +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 @@ -708,19 +724,8 @@ foreach my $lib (@modules_to_sync) { chomp $line; if($line =~ /^ *QT *\+?= *([^\r\n]*)/) { foreach(split(/ /, $1)) { - $master_contents .= "#include \n" if($_ eq "core"); - $master_contents .= "#include \n" if($_ eq "gui"); - $master_contents .= "#include \n" if($_ eq "network"); - $master_contents .= "#include \n" if($_ eq "svg"); - $master_contents .= "#include \n" if($_ eq "declarative"); - $master_contents .= "#include \n" if($_ eq "script"); - $master_contents .= "#include \n" if($_ eq "scripttools"); - $master_contents .= "#include \n" if($_ eq "qt3support"); - $master_contents .= "#include \n" if($_ eq "sql"); - $master_contents .= "#include \n" if($_ eq "xml"); - $master_contents .= "#include \n" if($_ eq "xmlpatterns"); - $master_contents .= "#include \n" if($_ eq "opengl"); - $master_contents .= "#include \n" if($_ eq "openvg"); + my $content = $mastercontent{$_}; + $master_contents .= $content if ($content); } } } -- cgit v1.2.3