Commit 44752a0f authored by Michael Natterer's avatar Michael Natterer 😴

pdbgen: make it work with a read-only srcdir

Pass srcdir *and* builddir to all pdbgen scripts, and generate all
temp files in $builddir. They get copied for $srcdir only if they have
actually changed, which should never happen on distcheck.
parent 3821eb1a
......@@ -110,6 +110,8 @@ $(srcdir)/enums.pl: stamp-enums
@:
stamp-enums: $(srcdir)/enumgen.pl $(enum_headers) Makefile.am
rootme=`pwd`; \
destdir=`cd $(top_srcdir) && pwd`; export destdir; \
builddir=`cd $(top_builddir) && pwd`; export builddir; \
cd $(srcdir) && $(PERL) enumgen.pl $(enum_headers) \
&& echo timestamp > $$rootme/stamp-enums
......@@ -131,7 +133,8 @@ stamp-groups: Makefile.am
stamp-pdbgen: $(pdbgen_deps) $(pdb_scripts) $(pdb_sources) Makefile.am
rootme=`pwd`; \
destdir=`cd $(top_builddir) && pwd`; export destdir; \
destdir=`cd $(top_srcdir) && pwd`; export destdir; \
builddir=`cd $(top_builddir) && pwd`; export builddir; \
cd $(srcdir) && \
PDBGEN_BACKUP=$(PDBGEN_BACKUP) PDBGEN_GROUPS=$(PDBGEN_GROUPS) \
$(PERL) pdbgen.pl app lib \
......@@ -139,7 +142,8 @@ stamp-pdbgen: $(pdbgen_deps) $(pdb_scripts) $(pdb_sources) Makefile.am
stamp-enum-code: $(srcdir)/enumcode.pl $(enum_deps)
rootme=`pwd`; \
destdir=`cd $(top_builddir) && pwd`; export destdir; \
destdir=`cd $(top_srcdir) && pwd`; export destdir; \
builddir=`cd $(top_builddir) && pwd`; export builddir; \
cd $(srcdir) && \
PDBGEN_BACKUP=$(PDBGEN_BACKUP) \
$(PERL) enumcode.pl \
......
......@@ -16,7 +16,8 @@
package Gimp::CodeGen::app;
$destdir = "$main::destdir/app/pdb";
$destdir = "$main::destdir/app/pdb";
$builddir = "$main::builddir/app/pdb";
*arg_types = \%Gimp::CodeGen::pdb::arg_types;
*arg_parse = \&Gimp::CodeGen::pdb::arg_parse;
......@@ -812,7 +813,7 @@ GPL
$extra = $main::grp{$group}->{extra}->{app}
}
my $cfile = "$destdir/".canonicalize(${group})."-cmds.c$FILE_EXT";
my $cfile = "$builddir/".canonicalize(${group})."-cmds.c$FILE_EXT";
open CFILE, "> $cfile" or die "Can't open $cfile: $!\n";
print CFILE $gpl;
print CFILE qq/#include "config.h"\n\n/;
......@@ -823,7 +824,7 @@ GPL
print CFILE "\nvoid\nregister_${group}_procs (GimpPDB *pdb)\n";
print CFILE "{\n GimpProcedure *procedure;\n$out->{register}}\n";
close CFILE;
&write_file($cfile);
&write_file($cfile, $destdir);
my $decl = "register_${group}_procs";
push @group_decls, $decl;
......@@ -834,7 +835,7 @@ GPL
}
if (! $ENV{PDBGEN_GROUPS}) {
my $internal = "$destdir/internal-procs.h$FILE_EXT";
my $internal = "$builddir/internal-procs.h$FILE_EXT";
open IFILE, "> $internal" or die "Can't open $internal: $!\n";
print IFILE $gpl;
my $guard = "__INTERNAL_PROCS_H__";
......@@ -856,9 +857,9 @@ HEADER
#endif /* $guard */
HEADER
close IFILE;
&write_file($internal);
&write_file($internal, $destdir);
$internal = "$destdir/internal-procs.c$FILE_EXT";
$internal = "$builddir/internal-procs.c$FILE_EXT";
open IFILE, "> $internal" or die "Can't open $internal: $!\n";
print IFILE $gpl;
print IFILE qq@#include "config.h"\n\n@;
......@@ -878,7 +879,7 @@ $group_procs
}
BODY
close IFILE;
&write_file($internal);
&write_file($internal, $destdir);
}
}
......
......@@ -17,8 +17,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
BEGIN {
$srcdir = $ENV{srcdir} || '.';
$destdir = $ENV{destdir} || '.';
$srcdir = $ENV{srcdir} || '.';
$destdir = $ENV{destdir} || '.';
$builddir = $ENV{builddir} || '.';
}
use lib $srcdir;
......@@ -31,7 +32,7 @@ require 'util.pl';
*write_file = \&Gimp::CodeGen::util::write_file;
*FILE_EXT = \$Gimp::CodeGen::util::FILE_EXT;
my $enumfile = "$destdir/libgimp/gimpenums.h$FILE_EXT";
my $enumfile = "$builddir/libgimp/gimpenums.h$FILE_EXT";
open ENUMFILE, "> $enumfile" or die "Can't open $enumfile: $!\n";
print ENUMFILE <<'LGPL';
......@@ -106,9 +107,9 @@ G_END_DECLS
HEADER
close ENUMFILE;
&write_file($enumfile);
&write_file($enumfile, "$destdir/libgimp");
$enumfile = "$destdir/libgimp/gimpenums.c.tail$FILE_EXT";
$enumfile = "$builddir/libgimp/gimpenums.c.tail$FILE_EXT";
open ENUMFILE, "> $enumfile" or die "Can't open $enumfile: $!\n";
print ENUMFILE <<CODE;
......@@ -214,4 +215,4 @@ gimp_enums_get_type_names (gint *n_type_names)
CODE
close ENUMFILE;
&write_file($enumfile);
&write_file($enumfile, "$destdir/libgimp");
......@@ -17,8 +17,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
BEGIN {
$srcdir = $ENV{srcdir} || '.';
$destdir = $ENV{srcdir} || '.';
$srcdir = $ENV{srcdir} || '.';
$destdir = $ENV{destdir} || '.';
$builddir = $ENV{builddir} || '.';
}
use lib $srcdir;
......@@ -252,8 +253,8 @@ $code =~ s/,\n$/\n/s;
foreach ($header, $code, $footer) { s/^://mg }
$outfile = "$destdir/enums.pl$FILE_EXT";
$outfile = "$builddir/tools/pdbgen/enums.pl$FILE_EXT";
open OUTFILE, "> $outfile";
print OUTFILE $header, $code, $footer;
close OUTFILE;
&write_file($outfile);
&write_file($outfile, "$destdir/tools/pdbgen");
......@@ -17,7 +17,8 @@
package Gimp::CodeGen::lib;
# Generates all the libgimp C wrappers (used by plugins)
$destdir = "$main::destdir/libgimp";
$destdir = "$main::destdir/libgimp";
$builddir = "$main::builddir/libgimp";
*arg_types = \%Gimp::CodeGen::pdb::arg_types;
*arg_parse = \&Gimp::CodeGen::pdb::arg_parse;
......@@ -516,8 +517,8 @@ LGPL
}
$hname =~ s/_//g; $hname =~ s/pdb\./_pdb./;
$cname =~ s/_//g; $cname =~ s/pdb\./_pdb./;
my $hfile = "$destdir/$hname$FILE_EXT";
my $cfile = "$destdir/$cname$FILE_EXT";
my $hfile = "$builddir/$hname$FILE_EXT";
my $cfile = "$builddir/$cname$FILE_EXT";
my $extra = {};
if (exists $main::grp{$group}->{extra}->{lib}) {
......@@ -650,7 +651,7 @@ G_END_DECLS
#endif /* $guard */
HEADER
close HFILE;
&write_file($hfile);
&write_file($hfile, $destdir);
open CFILE, "> $cfile" or die "Can't open $cfile: $!\n";
print CFILE $lgpl_top;
......@@ -680,11 +681,11 @@ SECTION_DOCS
print CFILE "\n", $extra->{code} if exists $extra->{code};
print CFILE $out->{code};
close CFILE;
&write_file($cfile);
&write_file($cfile, $destdir);
}
if (! $ENV{PDBGEN_GROUPS}) {
my $gimp_pdb_headers = "$destdir/gimp_pdb_headers.h$FILE_EXT";
my $gimp_pdb_headers = "$builddir/gimp_pdb_headers.h$FILE_EXT";
open PFILE, "> $gimp_pdb_headers" or die "Can't open $gimp_pdb_headers: $!\n";
print PFILE $lgpl_top;
print PFILE " * gimp_pdb_headers.h\n";
......@@ -716,6 +717,6 @@ HEADER
#endif /* $guard */
HEADER
close PFILE;
&write_file($gimp_pdb_headers);
&write_file($gimp_pdb_headers, $destdir);
}
}
......@@ -19,8 +19,9 @@
require 5.004;
BEGIN {
$srcdir = $ENV{srcdir} || '.';
$destdir = $ENV{destdir} || '.';
$srcdir = $ENV{srcdir} || '.';
$destdir = $ENV{destdir} || '.';
$builddir = $ENV{builddir} || '.';
}
use lib $srcdir;
......@@ -41,6 +42,7 @@ BEGIN {
# Stifle "used only once" warnings
$destdir = $destdir;
$builddir = $builddir;
%pdb = ();
# The actual parser (in a string so we can eval it in another namespace)
......
......@@ -16,6 +16,7 @@
package Gimp::CodeGen::util;
use File::Basename 'basename';
use File::Copy 'cp';
use File::Compare 'cmp';
......@@ -24,8 +25,13 @@ $DEBUG_OUTPUT = exists $ENV{PDBGEN_BACKUP} ? $ENV{PDBGEN_BACKUP} : 1;
$FILE_EXT = ".tmp.$$";
sub write_file {
my $file = shift; my $realfile = $file;
my $file = shift;
my $destdir = shift;
my $realfile = basename($file);
$realfile =~ s/$FILE_EXT$//;
$realfile = "$destdir/$realfile";
if (-e $realfile) {
if (cmp($realfile, $file)) {
cp($realfile, "$realfile~") if $DEBUG_OUTPUT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment