Skip to content

Commit

Permalink
Build: add option to choose to regenerate cmd_descs.[ch] (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
ret2libc authored and XVilka committed Aug 24, 2022
1 parent 1ae0c86 commit d9f0855
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion librz/core/cmd_descs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ cmd_descs_yaml = files(
cmd_descs_src_c = files('cmd_descs.c', 'cmd_descs.h')

r = run_command(py3_exe, '-c', 'import yaml', check: false)
if r.returncode() == 0
cmd_option = get_option('regenerate_cmds')
has_pyyaml = r.returncode() == 0
if (cmd_option.auto() or cmd_option.enabled()) and has_pyyaml
cmd_descs_ch = custom_target(
'cmd_descs.[ch]',
output: ['cmd_descs.c', 'cmd_descs.h'],
input: cmd_descs_yaml,
command: [py3_exe, cmd_descs_generate_py, '--output-dir', '@OUTDIR@', '--src-output-dir', meson.current_source_dir(), '@INPUT@']
)
elif cmd_option.enabled() and not has_pyyaml
error('PyYAML python module was not found, but it is required to regenerate cmd_descs.[ch]')
else
warning('PyYAML python module was not found, using cmd_descs.c/cmd_descs.h from source directory. Install PyYAML (either from your package manager or through pip) if you need to modify cmd_descs files.')
cmd_descs_ch = cmd_descs_src_c
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ option('debugger', type: 'boolean', value: true)

option('enable_tests', type: 'boolean', value: true, description: 'Build unit tests in test/unit')
option('enable_rz_test', type: 'boolean', value: true, description: 'Build rz-test executable for regression testing')
option('regenerate_cmds', type: 'feature', value: 'auto', description: 'Regenerate the cmd_descs.[ch] files (requires PyYAML)')

0 comments on commit d9f0855

Please sign in to comment.