meson: add fuzzers alias for all fuzzer targets

Makes it easier to build only fuzzer binaries and avoid building
unnecessary targets from subprojects.
This commit is contained in:
Kacper Michajłow 2024-06-24 16:22:21 +02:00
parent 893ea5e47b
commit 8a5989628c
2 changed files with 32 additions and 28 deletions

View File

@ -349,7 +349,7 @@ jobs:
--werror \ --werror \
-Dc_args="-Wno-error=deprecated -Wno-error=deprecated-declarations" \ -Dc_args="-Wno-error=deprecated -Wno-error=deprecated-declarations" \
-Dfuzzers=true -Dlibmpv=true -Dcplayer=false -Dfuzzers=true -Dlibmpv=true -Dcplayer=false
meson compile -C build meson compile -C build fuzzers
- name: Print meson log - name: Print meson log
if: ${{ failure() && steps.build.outcome == 'failure' }} if: ${{ failure() && steps.build.outcome == 'failure' }}

View File

@ -2,8 +2,10 @@ incdir = include_directories('../')
add_languages('cpp', native: false) add_languages('cpp', native: false)
executable('fuzzer_loadfile_direct', 'fuzzer_loadfile_direct.c', fuzzers = []
link_language: 'cpp', include_directories: incdir, link_with: libmpv)
fuzzers += executable('fuzzer_loadfile_direct', 'fuzzer_loadfile_direct.c',
link_language: 'cpp', include_directories: incdir, link_with: libmpv)
protocols = ['edl', 'file', 'lavf', 'memory'] protocols = ['edl', 'file', 'lavf', 'memory']
demuxers = ['mkv'] demuxers = ['mkv']
@ -28,43 +30,45 @@ if features['libarchive']
endif endif
foreach p : protocols foreach p : protocols
executable('fuzzer_protocol_' + p, fuzzers += executable('fuzzer_protocol_' + p,
'fuzzer_loadfile_direct.c', 'fuzzer_loadfile_direct.c',
link_language: 'cpp', link_language: 'cpp',
c_args: ['-DMPV_PROTO=' + p, '-DMPV_PROTO_' + p.to_upper()], c_args: ['-DMPV_PROTO=' + p, '-DMPV_PROTO_' + p.to_upper()],
include_directories: incdir, include_directories: incdir,
link_with: libmpv) link_with: libmpv)
endforeach endforeach
foreach demuxer : demuxers foreach demuxer : demuxers
cmd = 'file' cmd = 'file'
cmd_ = cmd.underscorify() cmd_ = cmd.underscorify()
demuxer_ = demuxer.underscorify() demuxer_ = demuxer.underscorify()
executable('fuzzer_load' + cmd_ + '_' + demuxer_, fuzzers += executable('fuzzer_load' + cmd_ + '_' + demuxer_,
'fuzzer_load.c', 'fuzzer_load.c',
link_language: 'cpp', link_language: 'cpp',
c_args: ['-DMPV_LOAD="' + cmd + '"', '-DMPV_LOAD' + cmd_.to_upper(), c_args: ['-DMPV_LOAD="' + cmd + '"', '-DMPV_LOAD' + cmd_.to_upper(),
'-DMPV_DEMUXER="' + demuxer + '"', '-DMPV_DEMUXER' + demuxer_.to_upper()], '-DMPV_DEMUXER="' + demuxer + '"', '-DMPV_DEMUXER' + demuxer_.to_upper()],
include_directories: incdir, include_directories: incdir,
link_with: libmpv) link_with: libmpv)
endforeach endforeach
foreach f : ['MPV_FORMAT_STRING', 'MPV_FORMAT_FLAG', 'MPV_FORMAT_INT64', 'MPV_FORMAT_DOUBLE'] foreach f : ['MPV_FORMAT_STRING', 'MPV_FORMAT_FLAG', 'MPV_FORMAT_INT64', 'MPV_FORMAT_DOUBLE']
foreach i : ['0', '1'] foreach i : ['0', '1']
executable('fuzzer_set_property_' + f + '_' + i, fuzzers += executable('fuzzer_set_property_' + f + '_' + i,
'fuzzer_set_property.c', 'fuzzer_set_property.c',
link_language: 'cpp', link_language: 'cpp',
c_args: ['-DMPV_FORMAT=' + f, '-DMPV_RUN=' + i], c_args: ['-DMPV_FORMAT=' + f, '-DMPV_RUN=' + i],
include_directories: incdir, include_directories: incdir,
link_with: libmpv) link_with: libmpv)
endforeach endforeach
endforeach endforeach
foreach cmd : ['file', '-config-file', '-input-conf'] foreach cmd : ['file', '-config-file', '-input-conf']
executable('fuzzer_load' + cmd.underscorify(), fuzzers += executable('fuzzer_load' + cmd.underscorify(),
'fuzzer_load.c', 'fuzzer_load.c',
link_language: 'cpp', link_language: 'cpp',
c_args: ['-DMPV_LOAD="' + cmd + '"', '-DMPV_LOAD' + cmd.underscorify().to_upper()], c_args: ['-DMPV_LOAD="' + cmd + '"', '-DMPV_LOAD' + cmd.underscorify().to_upper()],
include_directories: incdir, include_directories: incdir,
link_with: libmpv) link_with: libmpv)
endforeach endforeach
alias_target('fuzzers', fuzzers)