python = import('python') python3 = python.find_installation('python3') openssl = find_program('openssl', required: true) private_pem = custom_target('privateKey.pem', output: 'privateKey.pem', command: [ openssl, 'genrsa', '-out', '@OUTPUT@', '4096' ] ) public_pem = custom_target('publicKey.pem', input: private_pem, output: 'publicKey.pem', command: [ openssl, 'rsa', '-in', '@INPUT@', '-pubout', '-out', '@OUTPUT@' ] ) publicKey_h = custom_target('publicKey_h', input: files('ssl-keygen.py'), output: 'publicKey.h', command: [python3, '@INPUT@', '--private', private_pem, '--public', public_pem, '--output=@OUTPUT@', '--array-name=publicKey_pem'] ) pluginloader_moc = mod_qt5.preprocess( moc_headers: ['pluginloader.h'], dependencies: dep_qt5 ) dep_pluginloader = declare_dependency( include_directories: include_directories('.'), link_with: static_library('plugin', ['pluginloader.cpp', pluginloader_moc, publicKey_h], include_directories: include_directories('.'), dependencies: [dep_qt5, dependency('openssl', required: true)]) ) # generate a test file that would be signed signedfile_dat = custom_target('signedfile.dat', input: 'write-random.py', output: 'signedfile.dat', command: [ python3, '@INPUT@', '--output=@OUTPUT@' ] ) # sign test file signedfile_sig = custom_target('signedfile.dat.sig', input: signedfile_dat, output: 'signedfile.dat.sig', command: [ openssl, 'dgst', '-sha256', '-sign', private_pem, '-out', '@OUTPUT@', '@INPUT@' ] ) signedfile_idep = declare_dependency(sources: [ signedfile_dat, signedfile_sig ]) pluginloader_sigmatch = executable('pluginloader-sigmatch', sources: [ 'test/pluginloader-sigmatch.cpp' ], dependencies: [ dep_qt5, dep_gtest, dep_pluginloader, signedfile_idep ] ) test('pluginloader: signature matching', pluginloader_sigmatch, env: environment({ 'SIGNEDFILE' : 'signedfile.dat' }), workdir: meson.current_build_dir() )