diff --git a/libgimp/meson.build b/libgimp/meson.build index 746576555b..a1f12f9dd7 100644 --- a/libgimp/meson.build +++ b/libgimp/meson.build @@ -3,7 +3,7 @@ # Moreover it is generated in 2 steps, first with common mkenums # arguments, then concatenating with a "tail" file. gimpenums_notail = custom_target('gimpenums.c.notail', - input : [ 'gimpenums.h', ], + input : [ 'gimpenums.h', stamp_enumcode], output: [ 'gimpenums.c.notail', ], command: [ gimp_mkenums, @@ -14,6 +14,7 @@ gimpenums_notail = custom_target('gimpenums.c.notail', + '#include "libgimpbase/gimpbase.h"\n' + '#include "libgimpbase/gimpbase-private.h"\n' + '#include "libgimpconfig/gimpconfigenums.h"\n' + + '#include "pdb/stamp-enumcode.h"\n' + '#include "gimpenums.h"\n', '--fprod', '/* enumerations from "@basename@" */', @@ -40,7 +41,7 @@ gimpenums_notail = custom_target('gimpenums.c.notail', '@endif@', '--dtail', libgimp_mkenums_dtails, - '@INPUT@', + '@INPUT0@', ], capture: true, ) diff --git a/pdb/enumgen.pl b/pdb/enumgen.pl index b525769795..4a6944420c 100755 --- a/pdb/enumgen.pl +++ b/pdb/enumgen.pl @@ -20,6 +20,7 @@ BEGIN { $srcdir = $ENV{srcdir} || '.'; $destdir = $ENV{destdir} || '.'; $builddir = $ENV{builddir} || '.'; + $topsrcdir = $ENV{topsrcdir} || '.'; } use lib $srcdir; @@ -244,7 +245,7 @@ while (<>) { } $mapping =~ s/,\n\s*$//s; - $ARGV =~ s@(?:(?:..|app)/)*@@; + $ARGV =~ s@($topsrcdir/)?(?:(?:..|app)/)*@@; $code .= < diff --git a/pdb/meson-enumcode.sh b/pdb/meson-enumcode.sh new file mode 100644 index 0000000000..1cee6ed546 --- /dev/null +++ b/pdb/meson-enumcode.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +PERL="$1" +top_srcdir="$2" +top_builddir="$3" + +# Environment for the pdbgen.pl file. +destdir=`cd "$top_srcdir" && pwd` +export destdir +builddir=`cd "$top_builddir" && pwd` +export BUILD builddir + +cd "$top_srcdir"/ +$PERL -I "$top_builddir/pdb" -I "$top_srcdir/pdb" pdb/enumcode.pl +RET=$? +if [ $RET -eq 0 ]; then + echo "/* Generated on `date`. */" > $top_builddir/pdb/stamp-enumcode.h +fi +exit $RET diff --git a/pdb/meson-enumgen.sh b/pdb/meson-enumgen.sh new file mode 100644 index 0000000000..200a55f29a --- /dev/null +++ b/pdb/meson-enumgen.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +PERL="$1" +top_srcdir="$2" +top_builddir="$3" + +# Environment for the pdbgen.pl file. +destdir=`cd "$top_srcdir" && pwd` +export destdir +builddir=`cd "$top_builddir" && pwd` +export BUILD builddir + +cd "$top_srcdir"/pdb +shift 3 +$PERL enumgen.pl "${@}" +RET=$? +if [ $RET -eq 0 ]; then + echo "/* Generated on `date`. */" > $top_builddir/pdb/stamp-enumgen.h +fi +exit $RET diff --git a/pdb/meson.build b/pdb/meson.build index 974589d9f8..ad71945392 100644 --- a/pdb/meson.build +++ b/pdb/meson.build @@ -80,15 +80,11 @@ perlbindir = meson.current_build_dir() perl_env = [ 'PDBGEN_BACKUP=' + (pdbgen_backup ? '1' : '0'), 'PDBGEN_GROUPS=' + (pdbgen_groups ? '1' : '0'), - 'rootme=' + perlbindir, - 'srcdir=' + perlsrcdir, - 'destdir=' + meson.project_build_root(), - 'builddir=' + meson.project_build_root(), -] -perl_opts = [ - perl, - '-I', perlbindir, - '-I', perlsrcdir, + 'rootme=' + perlbindir, + 'srcdir=' + perlsrcdir, + 'destdir=' + meson.project_build_root(), + 'builddir=' + meson.project_build_root(), + 'topsrcdir=' + meson.project_source_root(), ] groups_pl_content = '# This file is autogenerated\n' @@ -99,7 +95,6 @@ endforeach groups_pl_content += ');\n' - # All perl files groups_pl = custom_target('groups.pl', @@ -109,93 +104,61 @@ groups_pl = custom_target('groups.pl', capture: true, ) -pdbgen_run = find_program('meson-pdbgen.sh') +enumgen_run = find_program('meson-enumgen.sh') +pdbgen_run = find_program('meson-pdbgen.sh') +enumcode_run = find_program('meson-enumcode.sh') -if meson.version().version_compare('>=0.57.0') - enums_pl = custom_target('enums.pl', - input : [ 'enumgen.pl', 'enums-external.pl', enum_headers, ], - output: [ 'enums.pl', ], - env: perl_env, - command: [ - perl, '@INPUT0@', - enum_headers, - ], - ) +enums_pl = custom_target('enums.pl', + input : [ 'meson-enumgen.sh', 'enumgen.pl', 'enums-external.pl', enum_headers, ], + output: [ 'stamp-enumgen.h', ], + env: perl_env, + command: [ + enumgen_run, perl, meson.project_source_root(), meson.project_build_root(), + enum_headers, + ], + build_by_default: true, +) - pdbgen = custom_target('stamp-pdbgen.h', - input : [ - files( - 'meson-pdbgen.sh', - 'pdbgen.pl', +pdbgen = custom_target('stamp-pdbgen.h', + input : [ + files( + 'meson-pdbgen.sh', + 'pdbgen.pl', - 'app.pl', - 'lib.pl', - 'pdb.pl', - 'stddefs.pdb', - 'util.pl', - ), - enums_pl, - groups_pl, - pdb_sources, - ], - output: [ 'stamp-pdbgen.h', ], - env: perl_env, - command: [ - pdbgen_run, perl, meson.project_source_root(), meson.project_build_root() - ], - ) + 'app.pl', + 'lib.pl', + 'pdb.pl', + 'stddefs.pdb', + 'util.pl', + ), + enums_pl, + groups_pl, + pdb_sources, + ], + output: [ 'stamp-pdbgen.h', ], + env: perl_env, + command: [ + pdbgen_run, perl, meson.project_source_root(), meson.project_build_root() + ], + build_by_default: true, +) - stamp_enumcode = custom_target('stamp-enum-code', - input : [ 'enumcode.pl', ], - output: [ 'stamp-enum-code', ], - env: perl_env, - command: [ - perl_opts, '@INPUT0@', - ], - ) -else - # TODO: remove this workaround when we bump meson requirement to >= 0.57.0 - # See MR !506. - # In the meantime, make sure the 2 if/else blocks are well synced. - env = find_program('env') +stamp_enumcode = custom_target('gimpenums.h', + input : [ + files( + 'meson-enumcode.sh', + 'enumcode.pl', + 'enumgen.pl', - enums_pl = custom_target('enums.pl', - input : [ 'enumgen.pl', 'enums-external.pl', enum_headers, ], - output: [ 'enums.pl', ], - command: [ - env, perl_env, perl_opts, '@INPUT0@', - enum_headers, - ], - ) - - pdbgen = custom_target('stamp-pdbgen.h', - input : [ - files( - 'meson-pdbgen.sh', - 'pdbgen.pl', - - 'app.pl', - 'lib.pl', - 'pdb.pl', - 'stddefs.pdb', - 'util.pl', - ), - enums_pl, - groups_pl, - pdb_sources, - ], - output: [ 'stamp-pdbgen.h', ], - command: [ - env, perl_env, pdbgen_run, perl, meson.project_source_root(), meson.project_build_root() - ], - ) - - - stamp_enumcode = custom_target('stamp-enum-code', - input : [ 'enumcode.pl', ], - output: [ 'stamp-enum-code', ], - command: [ - env, perl_env, perl_opts, '@INPUT0@', - ], - ) -endif + 'util.pl', + ), + enums_pl, + enum_headers, + ], + output: [ 'stamp-enumcode.h', ], + env: perl_env, + command: [ + enumcode_run, perl, meson.project_source_root(), meson.project_build_root() + ], + build_by_default: true, +)