Build: add option to choose to regenerate cmd_descs.[ch] (#2934)

This commit is contained in:
Riccardo Schirone 2022-08-19 16:15:56 +02:00 committed by GitHub
parent c542bfcb4a
commit d1feb6cea3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -39,3 +39,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)')