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";
22 my $phononheaderlist = "@CMAKE_CURRENT_SOURCE_DIR@/phonon_header_list";
23 my $phononheaderlistpath = "$here/$phononheaderlist";
25 ## If srcdir != builddir, use headerlist from src
26 $headerlistpath = $headerlist if ($headerlist =~ /^\//);
27 $phononheaderlistpath = $phononheaderlist if $phononheaderlist =~ /^\//;
29 ## Note: outdir and finaloutdir should NOT be the same dir!
31 # Delete all x_*.cpp files under outdir (or create outdir if nonexistent)
32 if (-d
$outdir) { system "rm -f $outdir/x_*.cpp"; } else { mkdir $outdir; }
34 mkdir $finaloutdir unless (-d
$finaloutdir);
36 # Load the QT_NO_* macros found in "qtdefines". They'll be passed to kalyptus
38 if ( -e
$definespath ){
39 print "Found '$defines'. Reading preprocessor symbols from there...\n";
40 $macros = " --defines=$definespath ";
43 mkdir $kalyptusdir, 0777;
44 # Need to cd to kalyptus's directory so that perl finds Ast.pm etc.
45 chdir "$kalyptusdir" or die "Couldn't go to $kalyptusdir (edit script to change dir)\n";
49 # Some systems have a QTDIR = KDEDIR = PREFIX
50 # We need a complete list
53 open(HEADERS
, $headerlistpath) or die "Couldn't open $headerlistpath: $!\n";
54 map { chomp ; $includes{$_} = 1 } <HEADERS
>;
58 # Some systems have a QTDIR = KDEDIR = PREFIX
59 # We need a complete list
63 open(HEADERS
, $phononheaderlistpath) or die "Couldn't open $phononheaderlistpath: $!\n";
64 map { chomp ; $kdeincludes{$_} = 1 unless /^\s*#/ } <HEADERS
>;
67 # List Qt headers, and exclude the ones listed above
74 (-e
|| -l
and !-d
) and do {
76 if( $includes{$f} # Known header
77 && /\.h$/) # Not a backup file etc. Only headers.
79 my $header = $File::Find
::name
;
80 if ( $header !~ /src/ ) {
82 my @header_lines = <FILE
>;
83 if (@header_lines == 1) {
84 $line = $header_lines[0];
85 if ($line =~ /^#include "(.*)"/) {
86 push ( @headers, $File::Find
::dir
. substr($1, 2) );
88 push ( @headers, $header );
91 push ( @headers, $header );
105 $kdeprefix = "@KDE_PREFIX@";
106 $kdeinc= ('@kde_includes@', '@PHONON_INCLUDE_DIR@' );
107 $kdeinc =~ s/\${prefix}/$kdeprefix/; # Remove ${prefix} in src != build
108 -d
$kdeinc or die "Couldn't process $kdeinc: $!\n";
112 (-e
|| -l
and !-d
) and do {
113 $f = substr($_, 1 + length $kdeinc);
114 push ( @kdeheaders, $_ )
115 if( $kdeincludes{$f} # Known header
116 && /\.h$/); # Not a backup file etc. Only headers.
117 undef $kdeincludes{$f}
127 chdir "../smoke/phonon";
128 system "perl -I@kdebindings_SOURCE_DIR@/kalyptus @kdebindings_SOURCE_DIR@/kalyptus/kalyptus @ARGV --qt4 --globspace -fsmoke --name=phonon --init-modules=qt --classlist=@CMAKE_CURRENT_SOURCE_DIR@/classlist $macros --no-cache --outputdir=$outdir @headers @kdeheaders";
130 exit $exit if ($exit);
131 chdir "$kalyptusdir";
133 # Generate diff for smokedata.cpp
134 unless ( -e
"$finaloutdir/smokedata.cpp" ) {
135 open( TOUCH
, ">$finaloutdir/smokedata.cpp");
138 system "diff -u $finaloutdir/smokedata.cpp $outdir/smokedata.cpp > $outdir/smokedata.cpp.diff";
140 # Copy changed or new files to finaloutdir
141 opendir (OUT
, $outdir) or die "Couldn't opendir $outdir";
142 foreach $filename (readdir(OUT
)) {
143 next if ( -d
"$outdir/$filename" ); # only files, not dirs
145 if ( -f
"$finaloutdir/$filename" ) {
146 $docopy = compare
("$outdir/$filename", "$finaloutdir/$filename"); # 1 if files are differents
149 #print STDERR "Updating $filename...\n";
150 cp
("$outdir/$filename", "$finaloutdir/$filename");
155 # Check for deleted files and warn
157 opendir(FINALOUT
, $finaloutdir) or die "Couldn't opendir $finaloutdir";
158 foreach $filename (readdir(FINALOUT
)) {
159 next if ( -d
"$finaloutdir/$filename" ); # only files, not dirs
160 if ( $filename =~ /.cpp$/ && ! ($filename =~ /_la_closure.cpp/) && ! -f
"$outdir/$filename" ) {
161 print STDERR
"Removing obsolete file $filename\n";
162 unlink "$finaloutdir/$filename";
169 system "rm -rf $outdir";