bool3max
bool3max

Reputation: 2865

Meson custom_target never executes despite sources and dependencies out of date

I've got this section in my project's root's meson.build:

if get_option('gen_py_bindings')

  message('told to build py bindings')

  custom_target('py_bindings', 
command: ['env', '_MESON_MODULE_NAME=' + meson.project_name(), ',_MESON_MODULE_VERSION=' + meson.project_version(), './py3_bindings/setup.py', 'build'], 
depends: [mainlib], 
depend_files: files(['py3_bindings/module.c', 'py3_bindings/setup.py']), 
input: ['py3_bindings/setup.py'], 
install: false, output: 'sharedextension.so')

endif

It's a custom target that runs a setup.py script to build python bindings for my project's library.


The problem is that it is always seemingly up-to-date. I've used the depends keyword argument to specify that it depends on another build target in the project, and the depend_files keyword argument to specify that it depends on the C source file that the script uses to build the extension, as well the actual script that is being ran as the command. I've also used the input keyword argument even though I don't understand the difference between it and depend_files.


I can only get the custom target to regenerate if I make a change to meson.build (the message() call is displayed successfully).

No other change will do. I've tried updating all files listed in the custom target but it always results in: ninja: no work to do.. Even if other out-of-date targets get rebuilt/relinked/etc...

I'm using ninja 1.9.0 and meson 0.52.1 on linux.


I am also well aware of the build_always_stale keyword argument but I don't want to use it unless necessary. (update: setting it to true still doesn't result in the target rebuilding, looks like there's something more at play here but I can't figure it out).

Upvotes: 1

Views: 2446

Answers (1)

bool3max
bool3max

Reputation: 2865

By default, custom targets don't get built when running plain ninja and thus the build_by_default keyword argument needs to be passed and set to true, e.g.

custom_target('target', build_by_default: true)

Upvotes: 2

Related Questions