summaryrefslogtreecommitdiff
path: root/bin/syncqt.pl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/syncqt.pl')
-rwxr-xr-xbin/syncqt.pl120
1 files changed, 91 insertions, 29 deletions
diff --git a/bin/syncqt.pl b/bin/syncqt.pl
index ce07af4895..cc91a11de0 100755
--- a/bin/syncqt.pl
+++ b/bin/syncqt.pl
@@ -172,6 +172,30 @@ 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"
#
@@ -383,6 +407,32 @@ sub fileContents {
}
######################################################################
+# Syntax: writeFile(filename, contents)
+# Params: filename, string, filename of file to write
+# contents, string, new contents for the file
+#
+# Purpose: Write file with given contents. If new contents match old
+# ones, do no change the file's timestamp.
+# Returns: 1 if the file's contents changed.
+######################################################################
+sub writeFile {
+ my ($filename, $contents, $lib, $what) = @_;
+ my $oldcontents = fileContents($filename);
+ $oldcontents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
+ if ($oldcontents ne $contents) {
+ open(O, "> " . $filename) || die "Could not open $filename for writing: $!\n";
+ print O $contents;
+ close O;
+ if ($lib && $verbose_level) {
+ my $action = ($oldcontents eq "") ? "created" : "updated";
+ print "$lib: $action $what\n";
+ }
+ return 1;
+ }
+ return 0;
+}
+
+######################################################################
# Syntax: fileCompare(file1, file2)
# Params: file1, string, filename of first file
# file2, string, filename of second file
@@ -787,7 +837,9 @@ foreach my $lib (@modules_to_sync) {
die "No such module: $lib" unless(defined $modules{$lib});
#iteration info
- my @dirs = split(/;/, $modules{$lib});
+ my $module = $modules{$lib};
+ my $is_qt = !($module =~ s/^!//);
+ my @dirs = split(/;/, $module);
my $dir = $dirs[0];
my $pathtoheaders = "";
@@ -802,6 +854,12 @@ foreach my $lib (@modules_to_sync) {
my $pri_install_pfiles = "";
my $pri_install_qpafiles = "";
+ my $libcapitals = uc($lib);
+ my $master_contents =
+ "#ifndef QT_".$libcapitals."_MODULE_H\n" .
+ "#define QT_".$libcapitals."_MODULE_H\n" .
+ "#include <$lib/${lib}Depends>\n";
+
#remove the old files
if($remove_stale) {
my %injections = ();
@@ -867,15 +925,8 @@ foreach my $lib (@modules_to_sync) {
#calc files and "copy" them
foreach my $subdir (@subdirs) {
my @headers = findFiles($subdir, "^[-a-z0-9_]*\\.h\$" , 0);
- if (defined $inject_headers{$subdir}) {
- foreach my $if (@{$inject_headers{$subdir}}) {
- @headers = grep(!/^\Q$if\E$/, @headers); #in case we configure'd previously
- push @headers, "*".$if;
- }
- }
my $header_dirname = "";
foreach my $header (@headers) {
- my $shadow = ($header =~ s/^\*//);
$header = 0 if($header =~ /^ui_.*.h/);
foreach (@ignore_headers) {
$header = 0 if($header eq $_);
@@ -897,8 +948,7 @@ foreach my $lib (@modules_to_sync) {
}
my $iheader = $subdir . "/" . $header;
- $iheader =~ s/^\Q$basedir\E/$out_basedir/ if ($shadow);
- my @classes = $public_header && !$minimal ? classNames($iheader) : ();
+ my @classes = $public_header && (!$minimal && $is_qt) ? classNames($iheader) : ();
if($showonly) {
print "$header [$lib]\n";
foreach(@classes) {
@@ -938,10 +988,13 @@ foreach my $lib (@modules_to_sync) {
}
foreach(@headers) { #sync them
- $header_copies++ if(syncHeader($lib, $_, $iheader, $copy_headers && !$shadow, $ts));
+ $header_copies++ if (syncHeader($lib, $_, $iheader, $copy_headers, $ts));
}
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, $dir);
@@ -1000,7 +1053,12 @@ foreach my $lib (@modules_to_sync) {
}
}
- unless ($showonly || $minimal) {
+ # close the master include:
+ $master_contents .=
+ "#include \"".lc($lib)."version.h\"\n" .
+ "#endif\n";
+
+ unless ($showonly || $minimal || !$is_qt) {
# create deprecated headers
my $first = 1;
while (my ($header, $include) = each %{$deprecatedheaders{$lib}}) {
@@ -1068,7 +1126,26 @@ foreach my $lib (@modules_to_sync) {
syncHeader($lib, $VHeader, $vheader, 0);
$pri_install_files .= fixPaths($vheader, $dir) . " ";
$pri_install_classes .= fixPaths($VHeader, $dir) . " ";
+ my @versions = split(/\./, $module_version);
+ my $modulehexstring = sprintf("0x%02X%02X%02X", $versions[0], $versions[1], $versions[2]);
+ my $vhdrcont =
+ "/* This file was generated by syncqt. */\n".
+ "#ifndef QT_".uc($lib)."_VERSION_H\n".
+ "#define QT_".uc($lib)."_VERSION_H\n".
+ "\n".
+ "#define ".uc($lib)."_VERSION_STR \"".$module_version."\"\n".
+ "\n".
+ "#define ".uc($lib)."_VERSION ".$modulehexstring."\n".
+ "\n".
+ "#endif // QT_".uc($lib)."_VERSION_H\n";
+ writeFile($vheader, $vhdrcont, $lib, "version header");
+
+ my $master_include = "$out_basedir/include/$lib/$lib";
+ $pri_install_files .= fixPaths($master_include, $dir) . " ";
+ writeFile($master_include, $master_contents, $lib, "master header");
+ }
+ unless ($showonly || $minimal) {
#handle the headers.pri for each module
my $headers_pri_contents = "";
$headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n";
@@ -1076,23 +1153,7 @@ foreach my $lib (@modules_to_sync) {
$headers_pri_contents .= "SYNCQT.PRIVATE_HEADER_FILES = $pri_install_pfiles\n";
$headers_pri_contents .= "SYNCQT.QPA_HEADER_FILES = $pri_install_qpafiles\n";
my $headers_pri_file = "$out_basedir/include/$lib/headers.pri";
- if(-e $headers_pri_file) {
- open HEADERS_PRI_FILE, "<$headers_pri_file";
- local $/;
- binmode HEADERS_PRI_FILE;
- my $old_headers_pri_contents = <HEADERS_PRI_FILE>;
- close HEADERS_PRI_FILE;
- $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) {
- my $headers_pri_dir = dirname($headers_pri_file);
- make_path($headers_pri_dir, $lib, $verbose_level);
- open HEADERS_PRI_FILE, ">$headers_pri_file";
- print HEADERS_PRI_FILE $headers_pri_contents;
- close HEADERS_PRI_FILE;
- print "$lib: created headers.pri file\n" if($verbose_level);
- }
+ writeFile($headers_pri_file, $headers_pri_contents, $lib, "headers.pri file");
}
}
unless($showonly || !$create_uic_class_map) {
@@ -1117,6 +1178,7 @@ unless($showonly || !$create_uic_class_map) {
if($check_includes) {
foreach my $lib (@modules_to_sync) {
+ next if ($modules{$lib} =~ /^!/);
#calc subdirs
my @subdirs = listSubdirs(map { s/^\^//; $_ } split(/;/, $modules{$lib}));