GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

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