Hi!
I am Dlang user and I want to bind my code with huge amount of C libraries.
In D world we have excellent tool named "dpp" (or "D++") for this purpose: it processes its own formatted files (.dpp) and C headers into D files what can be used as D header or D source. (Actually D compilers isn't do distinguish between headers and sources and resulting file can be used by both ways).
It is important thing: in a whole project I want to use many dpp files, thus I need a way to process all of them by same Meson code.
So, I just use generator:
=============
project('d++ preprocessor')
dub = find_program('dub', native: true)
dpp_preprocessor = generator(
dub,
arguments : [
'run', 'dpp', '--',
'--preprocess-only',
'--source-output-path=@BUILD_DIR@',
'@EXTRA_ARGS@',
'@INPUT@',
],
output: '@BASENAME@.d',
)
Generator calling:
=============
freertos_binding = dpp_preprocessor.process(
files(
'freertos_dpp_bindings/freertos.dpp',
),
)
=============
Now freertos_binding variable contains D module what can be used to bind D code to C code.
But I don't know how to use this file properly.
For now, I use custom_target glue code what copies this file to place known in advance:
cp = find_program('cp')
freertos_d_unused = custom_target(
'Temporary FreeRTOS bindings generator',
input: freertos_binding,
output: 'freertos.d',
command : [cp, '@INPUT@', '@OUTPUT@'],
build_by_default: true,
)
And then manually copy this file into sources tree (and also commit it into git repo) to use path to it as include_dir at all another dependencies/libraries/executables.
It works, but it is not convient to use, and I feel it is totally wrong way. Also, I can't use many bindings because of this - each binding adds too many lines of glue code.
Related issue what I reported previously:
But maybe there is some other way what available for now in Meson?
(In fact, I have no understanding why Meson prohibits working with header files by the same way as with source files. Perhaps, except that often for header files you need to be able to extract the directory in which they are located, from all other points of view, as for me, headers is just another separate type of sources.)