0

We ‘d like to introduce Meson to build our existing C++ application. Our structure is as follows:

  • Wie have 8 main modules (mod_X)
  • Every module has 20-40 subdirs, each with 5 – 100 cpp files; separated in libs and executables.
  • mod_INFRA/apps/myparser has a target that creates a code generator executable
    • Which depends only on mod_INFRA/libs/A
  • The code generator must be applied to certain files (*.rules) in numerous subdirs in all modules and subdirs, including mod_INFRA itself.
  • The generated source code must be compiled and considered with the target in subdir_X

What I’d like to achieve:

  • In root/meson.builddefine a common and re-usable custom_target or generator that I can invoke/apply in every module and subdir as needed.

Problem:

  • In root/meson.build, we define common variables such as compiler flags etc., and we do subdir(‘mod_INFRA’) for each module. In mod_INFRA/meson.build I do subdir(‘apps/xyz’), subdir(‘libs/abc’), etc. for each subdir. That’s all fine
  • However I struggle to define the custom_target or generator in root/meson.build. The required executable is not yet available before subdir('mod_INFRA'). And after subdir(..) it is too late, as I need the generator already to build files in other subdirs in mod_INFRA.

A possible solution could be a “proxy” that lazily resolves the executable by target name. E.g. if I could do (pseudo code): generator(getTargetOutput(‘myparser’), …). But I could not find out if that is available.

Any other thoughts on how to resolve it, without completely restructuring the directory structure?

- meson.build
- mod_INFRA
  - meson.build
  - apps
    - meson.build
    - myparser
      - meson.build
  - libs
    - subdir_INFRA_A   (required to build myparser)
      - meson.build
    - subdir_INFRA_B
      - meson.build
    - subdir_INFRA_C    (requires parser to generate code)
      - meson.build
- mod_A
  - meson.build
  - subdir_A_A      (requires parser to generate code)
    - meson.build
  - subdir_A_B      (requires parser to generate code)
    - meson.build
- mod_B
...
Juergen
  • 699
  • 7
  • 20

1 Answers1

0

Somebody suggested: From the top level can you do a subdir straight into "mod_INFRA/libs/subdir_INFRA_A" and "apps/myparser" directories to build them, before returning to the top level and then subdir down a single level repeatedly thereafter? That did the trick,

Juergen
  • 699
  • 7
  • 20