Danijel
Danijel

Reputation: 8606

How to specify a path to Meson custom_target() command?

I did a simple custom target in Meson:


my_build = custom_target('my_build', command: ['../my_script.sh', '-arg1'], build_always_stale: true, output: 'fake')

This works OK..., but when I try to use this as subproject from other Meson projects, I get a message that ../my_script.sh cannot be found.

How do I specify the path to my_script.sh, so that the script is always found, no matter called directly in this subproject, or from a root project?

Upvotes: 1

Views: 1002

Answers (1)

Elvis Oric
Elvis Oric

Reputation: 1364

You need to specify the path to your script and you can do that like this:

scirpt_path = join_paths(meson.current_source_dir(), 'my_script.sh')

and your custom target will look like this:

my_build = custom_target('my_build', command: [script_path, '-arg1'], build_always_stale: true, output: 'fake')

The reason it works for you when you don't have a subproject is because you have a structure that your build directory is in the root of your project, so it is possible to find your script with ../my_script.sh

Upvotes: 1

Related Questions