Problems with generator() and/or custom_target()

570 views
Skip to first unread message

Tom Schutter

unread,
Feb 11, 2018, 7:44:20 PM2/11/18
to The Meson Build System
I am trying to figure out how to use generator() and/or custom_target().

I have an IDL compiler that reads a .idl file and generates a .h file.  Each .idl file is also paired with a .user-created .c file.  That .c file (and others) include the generated .h file.

I created a generator like this:
  idl2c = generator(
    idl2c_exe
,
    output
: ['@BASENAME@.h'],
    arguments
: ['-O@BUILD_DIR@', '@INPUT@']
 
)

The idea would be to have lines like this in my build.meson files:
  idl2c.process('foo.idl', 'bar.idl', 'baz.idl', <and more>)

But that does not do anything, I believe that is because nothing depends upon the output from idl2c.process().  I have tried creating a custom_target that uses idl2c.process() but have gotten nowhere.

In addition, the doc says that each output will be created in a target-private directory @BUILD_DIR@.  But I need this output to be in a non-target-private directory so that all of the .c files can locate the generated .h file.

There are hundreds of .idl files, so I do not want to create a custom_target for each one.

Where do I go from here?

Jussi Pakkanen

unread,
Feb 12, 2018, 4:27:32 AM2/12/18
to Tom Schutter, The Meson Build System
On Mon, Feb 12, 2018 at 2:44 AM, Tom Schutter <tschu...@gmail.com> wrote:

> The idea would be to have lines like this in my build.meson files:
> idl2c.process('foo.idl', 'bar.idl', 'baz.idl', <and more>)

You need to put the output of that command to the target where you
want to use the files. So something like:

gen_srcs = idl2c.process(...)
executable('mytarget', 'main.c', gen_srcs)

mikkelfj

unread,
Feb 12, 2018, 9:02:34 AM2/12/18
to The Meson Build System
You try to see how it is done in the flatcc meson sample. FlatCC is essentially an IDL compiler.

There is a test app and a branch of flatcc with meson build support.
It does not use the latest meson version.


Notably the rules file may be of interest.

Dependency generation was added to flatcc to better handle nested dependencies, and it works really well.
Reply all
Reply to author
Forward
0 new messages