@@ -151,7 +151,7 @@ if built_in_models_enabled
151151 output : model_file,
152152 copy : true
153153 ),
154- command : [xxd, ' --include ' , ' @INPUT@' , ' @OUTPUT@' ],
154+ command : [xxd, ' -i ' , ' @INPUT@' , ' @OUTPUT@' ],
155155 )
156156 endforeach
157157
@@ -333,14 +333,19 @@ if is_cuda_enabled
333333
334334 message (' ptx_files = @0@' .format(ptx_files))
335335
336- xxd_exe = find_program (' xxd' )
336+ # bin2c is distributed along with cuda tools. Use '--padd 0x00' to add a NULL-terminator byte
337+ # to the end of the generated array.
338+ bin2c_exe = find_program (' bin2c' )
337339 ptx_arrays = []
338340 foreach name, _ptx : ptx_files
339- t = custom_target (' ptx_xxd_ @0@' .format(name),
341+ t = custom_target (' ptx_bin2c_ @0@' .format(name),
340342 build_by_default : true ,
341343 output : [' @PLAINNAME@.c' ],
342344 input : _ptx,
343- command : [xxd_exe, ' --include' ,' @INPUT@' , ' @OUTPUT@' ],
345+ capture : true ,
346+ command : [bin2c_exe, ' --const' , ' --padd' , ' 0x00' ,
347+ ' --name' , ' @BASENAME@_ptx' , ' @INPUT@' ,
348+ ]
344349 )
345350 ptx_arrays += t
346351 endforeach
0 commit comments