I'm trying to switch a project over to meson
/ninja
but it takes multiple executions of ninja
to successfully complete, and at first glance it appears that the early failures are because of incomplete build steps that are supposed to precede it. The steps that seem out of order are usually while I'm calling a sed
through custom_target
to fix some auto generated output during the compile of a library (lib-b
) that depends on another one (lib-a
). This is essentially what I have for (lib-b
):
lib_b = shared_library('lib-b-' + apiversion, lib_b_sources,
link_args: [ '-Wl,--version-script' ],
vala_header: 'lib-b.h',
vala_args: lib_b_vala_args,
vala_vapi: 'lib-b-@0@.vapi'.format(apiversion),
vala_gir: 'Lib-@0@.gir'.format(apiversion),
dependencies: lib_b_deps,
c_args: lib_b_args,
soversion: soversion,
install: true,
install_dir: [ true, true, true, false ],
)
custom_target('LibB-@0@.gir'.format(apiversion),
command: [ sed,
'-e', 's|Lib[.]|LibB.|g',
'-e', 's|namespace name="Lib"|namespace name="LibB"|g',
'-e', 's|LibB[.]Foo|LibA.Foo|g',
'-e', 's|<package name="lib-b-@0@"/>|<include name="LibA" version="@0@"/><package name="lib-b-@0@"/>|'.format(apiversion),
join_paths(meson.current_build_dir(), 'Lib-@0@.gir'.format(apiversion)),
],
output: 'LibB-@0@.gir'.format(apiversion),
capture: true,
install: true,
install_dir: dir_gir,
)
if g_ir_compiler.found()
custom_target('LibB-@0@.typelib'.format(apiversion),
command: [ g_ir_compiler,
'--shared-library', lib_b.full_path(),
'--includedir', lib_a_girdir,
'--output', '@OUTPUT@',
join_paths(meson.current_build_dir(), 'LibB-@0@.gir'.format(apiversion)),
],
output: 'LibB-@0@.typelib'.format(apiversion),
depends: lib_b,
install: true,
install_dir: dir_typelib,
)
endif
After the first run of ninja
I get errors like this:
FAILED: src/lib/b/LibB-1.0.gir
/usr/bin/python3 /usr/bin/meson --internal exe /home/user/proj/_build/meson-private/meson_exe_sed_3429069bbdfaffa2d113b782ce02a55d5fd96973.dat
/usr/bin/sed: can't read /home/user/proj/_build/src/lib/b/Lib-1.0.gir: No such file or directory
Where Lib-1.0.gir
is supposed to be one of the outputs of the shared_library
command. If I run it again it creates the file, makes it further, and complains with a similar error. I run it again, further this time but errors on other internal projects that depend on the file that isn't being created. I run it one last time and it completes.
It would surprise me if meson
/ninja
was not capable to executing build steps in a sequence where one must precede the other. Have I done something gross/stupid here? I'm basically porting over an autotools
setup that works, but is slooooow.