@@ -31,21 +31,25 @@ def build_options_append(cmakeopt, cliarg):
3131 build_options_append ('GRAMMARINATOR_DECODE' , 'ON' if args .decode else 'OFF' )
3232 build_options_append ('GRAMMARINATOR_FUZZNULL' , 'ON' if args .fuzznull else 'OFF' )
3333 build_options_append ('GRAMMARINATOR_GRLF' , 'ON' if args .grlf else 'OFF' )
34+ build_options_append ('GRAMMARINATOR_GRAFL' , 'ON' if args .grafl else 'OFF' )
3435
35- if args .generate or args .fuzznull or args .grlf :
36+ if args .generate or args .fuzznull or args .grlf or args . grafl :
3637 build_options_append ('GRAMMARINATOR_GENERATOR' , args .generator )
3738 build_options_append ('GRAMMARINATOR_MODEL' , args .model )
3839 build_options_append ('GRAMMARINATOR_LISTENER' , args .listener )
3940 build_options_append ('GRAMMARINATOR_TRANSFORMER' , args .transformer )
4041
41- if args .generate or args .decode or args .fuzznull or args .grlf :
42+ if args .generate or args .decode or args .fuzznull or args .grlf or args . grafl :
4243 build_options_append ('GRAMMARINATOR_SERIALIZER' , args .serializer )
4344 build_options_append ('GRAMMARINATOR_TREECODEC' , args .treecodec )
4445 build_options_append ('GRAMMARINATOR_INCLUDE' , args .include )
4546 build_options_append ('GRAMMARINATOR_INCLUDEDIRS' , ';' .join (os .path .abspath (includedir ) for includedir in args .includedir ))
4647 build_options_append ('GRAMMARINATOR_SUFFIX' , args .suffix )
4748 build_options_append ('GRAMMARINATOR_LOG_LEVEL' , args .log_level )
4849
50+ if args .grafl :
51+ build_options_append ('GRAMMARINATOR_AFL_INCLUDEDIR' , os .path .abspath (args .afl_includedir ))
52+
4953 return build_options
5054
5155
@@ -109,6 +113,10 @@ def main():
109113 help = 'build a dummy fuzznull binary to test libFuzzer integration without a real fuzz target (default: %(default)s)' )
110114 sgrp .add_argument ('--grlf' , default = False , action = 'store_true' ,
111115 help = 'build a static libgrlf library for libFuzzer integration (default: %(default)s)' )
116+ sgrp .add_argument ('--grafl' , default = False , action = 'store_true' ,
117+ help = 'build a shared libgrafl library for AFL++ integration (default: %(default)s)' )
118+ sgrp .add_argument ('--afl-includedir' , metavar = 'DIR' ,
119+ help = 'AFL include directory (mandatory if --grafl is specified)' )
112120 sgrp .add_argument ('--generator' , metavar = 'NAME' ,
113121 help = 'name of the generator class' )
114122 sgrp .add_argument ('--model' , metavar = 'NAME' ,
@@ -134,12 +142,16 @@ def main():
134142 'json' : 'JsonTreeCodec'
135143 }[args .tree_format ] if args .tree_format else None
136144
137- if args .generate or args .fuzznull or args .grlf :
145+ if args .generate or args .fuzznull or args .grlf or args . grafl :
138146 if not args .includedir or (not args .generator and not args .include ):
139147 parser .error ('To build specialized artefacts, either the `--generator` or the `--include`, and the `--includedir` arguments must be defined.' )
140148 if not args .generator and not args .suffix :
141149 sys .stderr .write (f'{ parser .prog } : Neither `--generator` nor `--suffix` is defined; the created binary will get a default name.\n ' )
142150
151+ if args .grafl :
152+ if not args .afl_includedir :
153+ parser .error ('To build AFL integration, the `--afl-includedir` argument must be defined.' )
154+
143155 try :
144156 configure_cmake (args )
145157 cmake_build (args )
0 commit comments