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
|
#!/usr/bin/perl -w
## Run this first, to generate the x_*.cpp files from the Qt headers
## using kalyptus
my $kalyptusdir = "@srcdir@/../../kalyptus";
use File::Basename;
use File::Copy qw|cp|;
use File::Compare;
use File::Find;
use Cwd;
my $here = getcwd;
my $outdir = $here . "/generate.pl.tmpdir";
my $finaloutdir = $here;
my $defines = "qtdefines";
my $headerlist = "@srcdir@/header_list";
my $kdeheaderlist = "@srcdir@/kde_header_list";
my $definespath = "$here/$defines";
my $headerlistpath = "$here/$headerlist";
my $kdeheaderlistpath = "$here/$kdeheaderlist";
# If srcdir != builddir, then srcdir is probvably an absolute
# path, and it makes no sense to prepend $here.
$definespath = $defines if $defines =~ /^\//;
$headerlistpath = $headerlist if $headerlist =~ /^\//;
$kdeheaderlistpath = $kdeheaderlist if $kdeheaderlist =~ /^\//;
## Note: outdir and finaloutdir should NOT be the same dir!
# Delete all x_*.cpp files under outdir (or create outdir if nonexistent)
if (-d $outdir) { system "rm -f $outdir/x_*.cpp"; } else { mkdir $outdir; }
mkdir $finaloutdir unless (-d $finaloutdir);
# Load the QT_NO_* macros found in "qtdefines". They'll be passed to kalyptus
my $macros="";
if ( -e $definespath ){
print "Found '$defines'. Reading preprocessor symbols from there...\n";
$macros = " --defines=$definespath ";
}
# Need to cd to kalyptus's directory so that perl finds Ast.pm etc.
chdir "$kalyptusdir" or die "Couldn't go to $kalyptusdir (edit script to change dir)\n";
# Find out which header files we need to parse
# We don't want all of them - e.g. not template-based stuff
my %excludes = (
'qaccessible.h' => 1, # Accessibility support is not compiled by defaut
'qassistantclient.h' => 1, # Not part of Qt (introduced in Qt-3.1)
'qmotif.h' => 1, #
'qmotifwidget.h' => 1, # Motif extension (introduced in Qt-3.1)
'qmotifdialog.h' => 1, #
'qxt.h' => 1, # Xt
'qxtwidget.h' => 1, # Xt
'qdns.h' => 1, # internal
'qgl.h' => 1, # OpenGL
'qglcolormap.h' => 1, # OpenGL
'qnp.h' => 1, # NSPlugin
'qttableview.h' => 1, # Not in Qt anymore...
'qtmultilineedit.h' => 1, # Not in Qt anymore...
'qwidgetfactory.h' => 1, # Just an interface
'qsharedmemory.h' => 1, # "not part of the Qt API" they say
'qwindowsstyle.h' => 1, # Qt windowsstyle, plugin
'qmotifstyle.h' => 1,
'qcompactstyle.h' => 1,
'qinterlacestyle.h' => 1,
'qmotifplusstyle.h' => 1,
'qsgistyle.h' => 1,
'qplatinumstyle.h' => 1,
'qcdestyle.h' => 1,
'qwindowsxpstyle.h' => 1 # play on the safe side
);
# Some systems have a QTDIR = TDEDIR = PREFIX
# We need a complete list
my %includes;
open(HEADERS, $headerlistpath) or die "Couldn't open $headerlistpath: $!\n";
map { chomp ; $includes{$_} = 1 unless /^\s*#/ } <HEADERS>;
close HEADERS;
# Find out which header files we need to parse
# We don't want all of them - e.g. not template-based stuff
my %kdeexcludes = (
# These headers don't look suitable for inclusion:
'kallocator.h' => 1,
'kbookmarkimporter_crash.h' => 1,
'kbookmarkimporter_ie.h' => 1,
'kbookmarkimporter_opera.h' => 1,
'kbookmarkimporter_ns.h' => 1,
'kcrash.h' => 1,
'kdebug.h' => 1,
'kdebugclasses.h' => 1,
'kde_terminal_interface.h' => 1,
'kdirnotify_stub.h' => 1,
# These headers currently give problems
'kscreensaver.h' => 1,
'kdirnotify_stub.h' => 1,
'kio/uiserver_stub.h' => 1,
'kio/uiserver.h' => 1,
'kio/tdesasl.h' => 1,
'kio/kpac.h' => 1,
'kio/thumbcreator.h' => 1,
'kio/file.h' => 1,
'kio/chmodjob.h' => 1,
'kparts/genericfactory.h' => 1,
'kparts/pluginselectormodule.h' => 1,
'kopenssl.h' => 1,
'kautomount.h' => 1,
'kimagefilepreview.h' => 1,
'kpropertiesdialog.h' => 1,
'knotifydialog.h' => 1,
'ksockaddr.h' => 1,
'knotifywidgetbase.h' => 1,
);
# Some systems have a QTDIR = TDEDIR = PREFIX
# We need a complete list
my %kdeincludes;
open(HEADERS, $kdeheaderlistpath) or die "Couldn't open $kdeheaderlistpath: $!\n";
map { chomp ; $kdeincludes{$_} = 1 unless /^\s*#/ } <HEADERS>;
close HEADERS;
# Can we compile the OpenGl module ?
if("@KDE_HAVE_GL@" eq "yes")
{
open(DEFS, $definespath);
my @defs = <DEFS>;
close DEFS;
if(!grep(/QT_NO_OPENGL/, @defs))
{
$excludes{'qgl.h'} = undef;
$excludes{'qglcolormap.h'} = undef;
}
else
{
print STDERR "Qt was not compiled with OpenGL support...\n Skipping TQGL Classes.\n";
}
}
# List Qt headers, and exclude the ones listed above
my @headers = ();
$qtinc= '@qt_includes@';
opendir (QT, $qtinc) or die "Couldn't find $qtinc";
foreach $filename (readdir(QT)) {
$entry = $qtinc."/".$filename;
if ( ( -e $entry or -l $entry ) # A real file or a symlink
&& ( ! -d _ ) ) # Not a symlink to a dir though
{
push(@headers, $entry)
if ( !defined $excludes{$filename} # Not excluded
&& $includes{$filename} # Known header
&& $filename =~ /\.h$/ ); # Not a backup file etc. Only headers.
undef $includes{$filename}
}
}
closedir QT;
my @kdeheaders = ();
$kdeprefix = "@KDE_PREFIX@";
$kdeinc= '@kde_includes@';
$kdeinc =~ s/\${prefix}/$kdeprefix/; # Remove ${prefix} in src != build
-d $kdeinc or die "Couldn't process $kdeinc: $!\n";
find(
{ wanted => sub {
(-e || -l and !-d) and do {
$f = substr($_, 1 + length $kdeinc);
push ( @kdeheaders, $_ )
if( !defined $kdeexcludes{$f} # Not excluded
&& $kdeincludes{$f} # Known header
&& /\.h$/); # Not a backup file etc. Only headers.
undef $kdeincludes{$f}
};
},
follow_fast => 1,
follow_skip => 2,
no_chdir => 1
}, $kdeinc
);
# Launch kalyptus
system "perl kalyptus @ARGV --globspace -fsmoke --name=qt $macros --no-cache --allow_k_dcop_accessors --outputdir=$outdir @headers @kdeheaders";
my $exit = $? >> 8;
exit $exit if ($exit);
# Generate diff for smokedata.cpp
unless ( -e "$finaloutdir/smokedata.cpp" ) {
open( TOUCH, ">$finaloutdir/smokedata.cpp");
close TOUCH;
}
system "diff -u $finaloutdir/smokedata.cpp $outdir/smokedata.cpp > $outdir/smokedata.cpp.diff";
# Copy changed or new files to finaloutdir
opendir (OUT, $outdir) or die "Couldn't opendir $outdir";
foreach $filename (readdir(OUT)) {
next if ( -d "$outdir/$filename" ); # only files, not dirs
my $docopy = 1;
if ( -f "$finaloutdir/$filename" ) {
$docopy = compare("$outdir/$filename", "$finaloutdir/$filename"); # 1 if files are differents
}
if ($docopy) {
#print STDERR "Updating $filename...\n";
cp("$outdir/$filename", "$finaloutdir/$filename");
}
}
closedir OUT;
# Check for deleted files and warn
my $deleted = 0;
opendir(FINALOUT, $finaloutdir) or die "Couldn't opendir $finaloutdir";
foreach $filename (readdir(FINALOUT)) {
next if ( -d "$finaloutdir/$filename" ); # only files, not dirs
if ( $filename =~ /.cpp$/ && ! ($filename =~ /_la_closure.cpp/) && ! -f "$outdir/$filename" ) {
print STDERR "Removing obsolete file $filename\n";
unlink "$finaloutdir/$filename";
$deleted = 1;
}
}
closedir FINALOUT;
# Delete outdir
system "rm -rf $outdir";
|