summaryrefslogtreecommitdiffstats
path: root/patches/0006-Make-syncqt-use-sync.profile-files-from-each-module.patch
blob: 95361279f5aafe6369b2379ac850cbe943bf4274 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
From 0b1ac7cf3b009293c3a7acddc854fa375ab40996 Mon Sep 17 00:00:00 2001
From: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Date: Mon, 15 Nov 2010 13:55:17 -0600
Subject: [PATCH] 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.
---
 qtbase/bin/syncqt                       |  163 ++++++++++++++++---------------
 qtbase/configure                        |    3 +-
 qtbase/sync.profile                     |   44 ++++++++
 qtbase/tools/configure/configureapp.cpp |    4 +-
 4 files changed, 130 insertions(+), 84 deletions(-)
 create mode 100644 qtbase/sync.profile

diff --git a/qtbase/bin/syncqt b/qtbase/bin/syncqt
index b867106..e3d941b 100755
--- a/qtbase/bin/syncqt
+++ b/qtbase/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);
                     }
                 }
             }
diff --git a/qtbase/configure b/qtbase/configure
index f2ee5f4..9a04380 100755
--- a/qtbase/configure
+++ b/qtbase/configure
@@ -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
 
diff --git a/qtbase/sync.profile b/qtbase/sync.profile
new file mode 100644
index 0000000..7d2e4b1a7
--- /dev/null
+++ b/qtbase/sync.profile
@@ -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}" );
diff --git a/qtbase/tools/configure/configureapp.cpp b/qtbase/tools/configure/configureapp.cpp
index 46f1a87..2d84ad5 100644
--- a/qtbase/tools/configure/configureapp.cpp
+++ b/qtbase/tools/configure/configureapp.cpp
@@ -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();
             }
         }
-- 
1.7.3.4