libgimp, pdb: (meson) fix building of libgimp/gimpenums.h inside the source tree.

This was not working properly and needed some external build script as well as
the stamp/bogus header trick like for other similar in-source generated code.

In the same time, I get rid of old meson code which was meant for when using
meson < 0.57.0 (since our requirement is now meson >= 0.59.0).
This commit is contained in:
Jehan 2023-08-30 15:52:47 +02:00
parent a40357a165
commit 1d16c1584f
5 changed files with 102 additions and 98 deletions

View File

@ -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,
)

View File

@ -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 .= <<ENTRY;
: $enumname =>

19
pdb/meson-enumcode.sh Normal file
View File

@ -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

20
pdb/meson-enumgen.sh Normal file
View File

@ -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

View File

@ -84,11 +84,7 @@ perl_env = [
'srcdir=' + perlsrcdir,
'destdir=' + meson.project_build_root(),
'builddir=' + meson.project_build_root(),
]
perl_opts = [
perl,
'-I', perlbindir,
'-I', perlsrcdir,
'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,20 +104,22 @@ groups_pl = custom_target('groups.pl',
capture: true,
)
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', ],
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: [
perl, '@INPUT0@',
enumgen_run, perl, meson.project_source_root(), meson.project_build_root(),
enum_headers,
],
)
build_by_default: true,
)
pdbgen = custom_target('stamp-pdbgen.h',
pdbgen = custom_target('stamp-pdbgen.h',
input : [
files(
'meson-pdbgen.sh',
@ -143,59 +140,25 @@ if meson.version().version_compare('>=0.57.0')
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')
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',
stamp_enumcode = custom_target('gimpenums.h',
input : [
files(
'meson-pdbgen.sh',
'pdbgen.pl',
'meson-enumcode.sh',
'enumcode.pl',
'enumgen.pl',
'app.pl',
'lib.pl',
'pdb.pl',
'stddefs.pdb',
'util.pl',
),
enums_pl,
groups_pl,
pdb_sources,
enum_headers,
],
output: [ 'stamp-pdbgen.h', ],
output: [ 'stamp-enumcode.h', ],
env: perl_env,
command: [
env, perl_env, pdbgen_run, perl, meson.project_source_root(), meson.project_build_root()
enumcode_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
build_by_default: true,
)