From 6571aaf1c45885407038e03b0e9ed5952a06baeb Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Date: Thu, 30 Jan 2014 19:34:49 +0100
Subject: [PATCH] merge %explicitheaders into %classnames
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

no need to have two mechanisms for the same thing.

the values of %classnames can be comma-separated lists now, so one
header can have multiple classes assigned. conversely, if an extracted
class name reverse-maps to a different file name, it is omitted.

Change-Id: Ia0a35d64764b6376f33b77bbfe59e1df70a3cf1a
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
---
 bin/syncqt.pl | 35 +++++++++++++++++------------------
 sync.profile  |  8 +-------
 2 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/bin/syncqt.pl b/bin/syncqt.pl
index 8b7ea3b4591..2a1523bbbd9 100755
--- a/bin/syncqt.pl
+++ b/bin/syncqt.pl
@@ -84,9 +84,12 @@ our $quoted_basedir;
 $INPUT_RECORD_SEPARATOR = "\r\n" if ($^O eq "msys");
 
 # will be defined based on the modules sync.profile
-our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %explicitheaders, %deprecatedheaders);
+our (%modules, %moduleheaders, @allmoduleheadersprivate, %classnames, %deprecatedheaders);
 our @qpa_headers = ();
 
+# will be derived from sync.profile
+our %reverse_classnames = ();
+
 # global variables (modified by options)
 my $isunix = 0;
 my $module = 0;
@@ -206,8 +209,9 @@ sub classNames {
     my @ret;
     my ($iheader) = @_;
 
-    my $classname = $classnames{basename($iheader)};
-    push @ret, $classname if ($classname);
+    my $ihdrbase = basename($iheader);
+    my $classname = $classnames{$ihdrbase};
+    push @ret, split(/,/, $classname) if ($classname);
 
     my $parsable = "";
     if(open(F, "<$iheader")) {
@@ -306,6 +310,8 @@ sub classNames {
             foreach my $symbol (@symbols) {
                 $symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces);
 
+                my $revhdr = $reverse_classnames{$symbol};
+                next if (defined($revhdr) and $revhdr ne $ihdrbase);
                 if ($symbol =~ /^Q[^:]*$/) {           # no-namespace, starting with Q
                     push @ret, $symbol;
                 } elsif (defined($publicclassregexp)) {
@@ -580,6 +586,13 @@ sub loadSyncProfile {
         die "syncqt couldn't parse $syncprofile: $@" if $@;
         die "syncqt couldn't execute $syncprofile: $!" unless defined $result;
     }
+
+    for my $fn (keys %classnames) {
+        for my $cn (split(/,/, $classnames{$fn})) {
+            $reverse_classnames{$cn} = $fn;
+        }
+    }
+
     return $result;
 }
 
@@ -936,17 +949,8 @@ foreach my $lib (@modules_to_sync) {
     #                                  class =~ s,::,/,g;
     #                               }
 
-                                    if (defined $explicitheaders{$lib}{$class}) {
-                                        $header_copies++ if(syncHeader($lib, "$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$explicitheaders{$lib}{$class}", 0, $ts));
-                                    } else {
-                                        $header_copies++ if(syncHeader($lib, "$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0, $ts));
-                                    }
-                                }
-
-                                if ($explicitheaders{$lib}{basename($header)}) {
-                                    $header_copies++ if(syncHeader($lib, "$out_basedir/include/$lib/$explicitheaders{$lib}{basename($header)}", "$out_basedir/include/$lib/$header", 0, $ts));
+                                    $header_copies++ if (syncHeader($lib, "$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0, $ts));
                                 }
-
                             } elsif ($create_private_headers && !$qpa_header) {
                                 @headers = ( "$out_basedir/include/$lib/$module_version/$lib/private/$header" );
                             } elsif ($create_private_headers) {
@@ -975,11 +979,6 @@ foreach my $lib (@modules_to_sync) {
                                         $pri_install_classes .= $class_header
                                                                     unless($pri_install_classes =~ $class_header);
                                     }
-                                    if ($explicitheaders{$lib}{basename($iheader)}) {
-                                        my $compat_header = fixPaths("$out_basedir/include/$lib/$explicitheaders{$lib}{basename($iheader)}",
-                                                                     $dir) . " ";
-                                        $pri_install_files .= $compat_header unless($pri_install_files =~ $compat_header);
-                                    }
                                     $pri_install_files.= "$pri_install_iheader ";;
                                 }
                             }
diff --git a/sync.profile b/sync.profile
index 7bd10b48652..9c759297ce1 100644
--- a/sync.profile
+++ b/sync.profile
@@ -31,6 +31,7 @@
     "qevent.h" => "QtEvents",
     "qnamespace.h" => "Qt",
     "qnumeric.h" => "QtNumeric",
+    "qvariant.h" => "QVariantHash,QVariantList,QVariantMap",
     "qsql.h" => "QSql",
     "qssl.h" => "QSsl",
     "qtest.h" => "QTest",
@@ -44,13 +45,6 @@
         "QGenericPluginFactory" => "QtGui/QGenericPluginFactory"
     }
 );
-%explicitheaders = (
-    "QtCore" => {
-        "QVariantHash" => "qvariant.h",
-        "QVariantList" => "qvariant.h",
-        "QVariantMap" => "qvariant.h",
-    }
-);
 
 @qpa_headers = ( qr/^qplatform/, qr/^qwindowsystem/ );
 my @angle_headers = ('egl.h', 'eglext.h', 'eglplatform.h', 'gl2.h', 'gl2ext.h', 'gl2platform.h', 'ShaderLang.h', 'khrplatform.h');
-- 
GitLab