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.
This commit is contained in:
parent
703842d450
commit
07bed9a211
163
bin/syncqt
163
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 " <module directory> 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 <module directory> 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 <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");
|
||||
my $content = $mastercontent{$_};
|
||||
$master_contents .= $content if ($content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
configure
vendored
3
configure
vendored
@ -2550,8 +2550,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then
|
||||
if [ -x "$relpath/bin/syncqt" ]; then
|
||||
mkdir -p "$outpath/bin"
|
||||
echo "#!/bin/sh" >"$outpath/bin/syncqt"
|
||||
echo "QTDIR=\"$relpath\"; export QTDIR" >>"$outpath/bin/syncqt"
|
||||
echo "perl \"$relpath/bin/syncqt\" -outdir \"$outpath\" \"\$@\"" >>"$outpath/bin/syncqt"
|
||||
echo "perl \"$relpath/bin/syncqt\" -outdir \"$outpath\" \"$relpath\" \"\$@\"" >>"$outpath/bin/syncqt"
|
||||
chmod 755 "$outpath/bin/syncqt"
|
||||
fi
|
||||
|
||||
|
44
sync.profile
Normal file
44
sync.profile
Normal file
@ -0,0 +1,44 @@
|
||||
%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",
|
||||
);
|
||||
%moduleheaders = ( # restrict the module headers to those found in relative path
|
||||
);
|
||||
%classnames = (
|
||||
"qglobal.h" => "QtGlobal",
|
||||
"qendian.h" => "QtEndian",
|
||||
"qconfig.h" => "QtConfig",
|
||||
"qplugin.h" => "QtPlugin",
|
||||
"qalgorithms.h" => "QtAlgorithms",
|
||||
"qcontainerfwd.h" => "QtContainerFwd",
|
||||
"qdebug.h" => "QtDebug",
|
||||
"qevent.h" => "QtEvents",
|
||||
"qnamespace.h" => "Qt",
|
||||
"qssl.h" => "QSsl",
|
||||
"qtest.h" => "QTest",
|
||||
"qtconcurrentmap.h" => "QtConcurrentMap",
|
||||
"qtconcurrentfilter.h" => "QtConcurrentFilter",
|
||||
"qtconcurrentrun.h" => "QtConcurrentRun",
|
||||
);
|
||||
%mastercontent = (
|
||||
"core" => "#include <QtCore/QtCore>\n",
|
||||
"gui" => "#include <QtGui/QtGui>\n",
|
||||
"network" => "#include <QtNetwork/QtNetwork>\n",
|
||||
"svg" => "#include <QtSvg/QtSvg>\n",
|
||||
"opengl" => "#include <QtOpenGL/QtOpenGL>\n",
|
||||
"openvg" => "#include <QtOpenVG/QtOpenVG>\n",
|
||||
"xml" => "#include <QtXml/QtXml>\n",
|
||||
);
|
||||
@ignore_for_master_contents = ( "qt.h", "qpaintdevicedefs.h" );
|
||||
@ignore_for_include_check = ( "qatomic.h" );
|
||||
@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" );
|
||||
@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" );
|
||||
@ignore_for_qt_module_check = ( "$modules{QtCore}/arch", "$modules{QtCore}/global", "$modules{QtTest}", "$modules{QtDBus}" );
|
@ -188,9 +188,7 @@ Configure::Configure(int& argc, char** argv)
|
||||
if (syncqt_bat.open(QFile::WriteOnly)) {
|
||||
QTextStream stream(&syncqt_bat);
|
||||
stream << "@echo off" << endl
|
||||
<< "set QTDIR=" << QDir::toNativeSeparators(sourcePath) << endl
|
||||
<< "call " << fixSeparators(sourcePath) << fixSeparators("/bin/syncqt.bat -outdir \"") << fixSeparators(buildPath) << "\"" << endl
|
||||
<< "set QTDIR=" << QDir::toNativeSeparators(buildPath) << endl;
|
||||
<< "call " << fixSeparators(sourcePath) << fixSeparators("/bin/syncqt.bat -outdir \"") << fixSeparators(buildPath) << "\" \"" << fixSeparators(sourcePath) << "\"" << endl
|
||||
syncqt_bat.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user