3 ## Run this first, to generate the x_*.cpp files from the Qt headers
6 my $kalyptusdir = "@CMAKE_CURRENT_SOURCE_DIR@/../../kalyptus";
15 my $outdir = $here . "/generate.pl.tmpdir";
16 my $finaloutdir = $here;
17 my $defines = "qtdefines";
18 my $headerlist = "@CMAKE_CURRENT_SOURCE_DIR@/header_list";
19 my $definespath = "$here/../$defines";
20 my $headerlistpath = "$headerlist";
21 my $qtscript_headerlist = "";
22 my $qtscript_headerlistpath = "";
24 $qtscript_headerlist = "@CMAKE_CURRENT_SOURCE_DIR@/qtscript_header_list";
25 $qtscript_headerlistpath = "$here/$qtscript_headerlist";
27 ## If srcdir != builddir, use headerlist from src
28 $headerlistpath = $headerlist if ($headerlist =~ /^\//);
29 $qtscript_headerlistpath = $qtscript_headerlist if ($qtscript_headerlist =~ /^\//);
31 ## Note: outdir and finaloutdir should NOT be the same dir!
33 # Delete all x_*.cpp files under outdir (or create outdir if nonexistent)
34 if (-d
$outdir) { system "rm -f $outdir/x_*.cpp"; } else { mkdir $outdir; }
36 mkdir $finaloutdir unless (-d
$finaloutdir);
38 # Load the QT_NO_* macros found in "qtdefines". They'll be passed to kalyptus
40 if ( -e
$definespath ){
41 print "Found '$defines'. Reading preprocessor symbols from there...\n";
42 $macros = " --defines=$definespath ";
45 mkdir $kalyptusdir, 0777;
46 # Need to cd to kalyptus's directory so that perl finds Ast.pm etc.
47 chdir "$kalyptusdir" or die "Couldn't go to $kalyptusdir (edit script to change dir)\n";
49 # Find out which header files we need to parse
50 # We don't want all of them - e.g. not template-based stuff
52 # 'qaccessible.h' => 1, # Accessibility support is not compiled by defaut
53 # 'qassistantclient.h' => 1, # Not part of Qt (introduced in Qt-3.1)
55 # 'qmotifwidget.h' => 1, # Motif extension (introduced in Qt-3.1)
56 # 'qmotifdialog.h' => 1, #
58 # 'qxtwidget.h' => 1, # Xt
59 # 'qdns.h' => 1, # internal
60 # 'qgl.h' => 1, # OpenGL
61 # 'qglcolormap.h' => 1, # OpenGL
62 # 'qnp.h' => 1, # NSPlugin
63 # 'qttableview.h' => 1, # Not in Qt anymore...
64 # 'qtmultilineedit.h' => 1, # Not in Qt anymore...
65 # 'qwidgetfactory.h' => 1, # Just an interface
66 # 'qsharedmemory.h' => 1, # "not part of the Qt API" they say
67 # 'qwindowsstyle.h' => 1, # Qt windowsstyle, plugin
68 # 'qmotifstyle.h' => 1,
69 # 'qcompactstyle.h' => 1,
70 # 'qinterlacestyle.h' => 1,
71 # 'qmotifplusstyle.h' => 1,
73 # 'qplatinumstyle.h' => 1,
75 # 'qworkspace.h' => 1,
76 # 'qwindowsxpstyle.h' => 1 # play on the safe side
79 # Some systems have a QTDIR = KDEDIR = PREFIX
80 # We need a complete list
83 open(HEADERS
, $headerlistpath) or die "Couldn't open $headerlistpath: $!\n";
84 map { chomp ; $includes{$_} = 1 } <HEADERS
>;
87 open(HEADERS
, $qtscript_headerlistpath) or die "Couldn't open $qtscript_headerlistpath: $!\n";
88 map { chomp ; $includes{$_} = 1 } <HEADERS
>;
91 # Can we compile the OpenGl module ?
92 if("@QT_OPENGL_FOUND@" eq "YES")
94 open(DEFS
, $definespath);
97 if(!grep(/QT_NO_OPENGL/, @defs))
99 $excludes{'qgl.h'} = undef;
100 $excludes{'qglcolormap.h'} = undef;
104 print STDERR
"Qt was not compiled with OpenGL support...\n Skipping QGL Classes.\n";
108 # List Qt headers, and exclude the ones listed above
111 my @qtinc= (@qt_incs@
);
115 (-e
|| -l
and !-d
) and do {
117 if( !defined $excludes{$f} # Not excluded
118 && $includes{$f} # Known header
119 && /\.h$/) # Not a backup file etc. Only headers.
121 my $header = $File::Find
::name
;
123 my @header_lines = <FILE
>;
124 if (@header_lines == 1) {
125 $line = $header_lines[0];
126 if ($line =~ /^#include "(.*)"/) {
127 push ( @headers, $File::Find
::dir
. substr($1, 2) );
129 push ( @headers, $header );
132 push ( @headers, $header );
145 chdir "../smoke/qtscript";
146 system "perl -I@kdebindings_SOURCE_DIR@/kalyptus @kdebindings_SOURCE_DIR@/kalyptus/kalyptus @ARGV --qt4 --globspace -fsmoke --name=qtscript --classlist='@CMAKE_CURRENT_SOURCE_DIR@/classlist' --init-modules=qt $macros --no-cache --outputdir=$outdir @headers";
148 exit $exit if ($exit);
149 chdir "$kalyptusdir";
151 # Generate diff for smokedata.cpp
152 unless ( -e
"$finaloutdir/smokedata.cpp" ) {
153 open( TOUCH
, ">$finaloutdir/smokedata.cpp");
156 system "diff -u $finaloutdir/smokedata.cpp $outdir/smokedata.cpp > $outdir/smokedata.cpp.diff";
158 # Copy changed or new files to finaloutdir
159 opendir (OUT
, $outdir) or die "Couldn't opendir $outdir";
160 foreach $filename (readdir(OUT
)) {
161 next if ( -d
"$outdir/$filename" ); # only files, not dirs
163 if ( -f
"$finaloutdir/$filename" ) {
164 $docopy = compare
("$outdir/$filename", "$finaloutdir/$filename"); # 1 if files are differents
167 #print STDERR "Updating $filename...\n";
168 cp
("$outdir/$filename", "$finaloutdir/$filename");
173 # Check for deleted files and warn
175 opendir(FINALOUT
, $finaloutdir) or die "Couldn't opendir $finaloutdir";
176 foreach $filename (readdir(FINALOUT
)) {
177 next if ( -d
"$finaloutdir/$filename" ); # only files, not dirs
178 if ( $filename =~ /.cpp$/ && ! ($filename =~ /_la_closure.cpp/) && ! -f
"$outdir/$filename" ) {
179 print STDERR
"Removing obsolete file $filename\n";
180 unlink "$finaloutdir/$filename";
187 system "rm -rf $outdir";