Stephen Kyle | 67f059e | 2018-09-27 10:00:33 +0100 | [diff] [blame] | 1 | set(ENV{QEMU_LD_PREFIX} "${BROTLI_WRAPPER_LD_PREFIX}") |
| 2 | |
Evan Nemerson | 93ef13f | 2016-06-20 13:07:35 -0700 | [diff] [blame] | 3 | execute_process( |
| 4 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
Eugene Kliuchnikov | 03739d2 | 2017-05-29 17:55:14 +0200 | [diff] [blame] | 5 | COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --quality=${QUALITY} ${INPUT} --output=${OUTPUT}.br |
Evan Nemerson | 03657e8 | 2016-07-28 13:31:09 -0700 | [diff] [blame] | 6 | RESULT_VARIABLE result |
| 7 | ERROR_VARIABLE result_stderr) |
Evan Nemerson | 93ef13f | 2016-06-20 13:07:35 -0700 | [diff] [blame] | 8 | if(result) |
Evan Nemerson | 03657e8 | 2016-07-28 13:31:09 -0700 | [diff] [blame] | 9 | message(FATAL_ERROR "Compression failed: ${result_stderr}") |
Evan Nemerson | 93ef13f | 2016-06-20 13:07:35 -0700 | [diff] [blame] | 10 | endif() |
| 11 | |
| 12 | execute_process( |
| 13 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
Eugene Kliuchnikov | 03739d2 | 2017-05-29 17:55:14 +0200 | [diff] [blame] | 14 | COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress ${OUTPUT}.br --output=${OUTPUT}.unbr |
Evan Nemerson | 93ef13f | 2016-06-20 13:07:35 -0700 | [diff] [blame] | 15 | RESULT_VARIABLE result) |
| 16 | if(result) |
| 17 | message(FATAL_ERROR "Decompression failed") |
| 18 | endif() |
| 19 | |
| 20 | function(test_file_equality f1 f2) |
| 21 | if(NOT CMAKE_VERSION VERSION_LESS 2.8.7) |
| 22 | file(SHA512 "${f1}" f1_cs) |
| 23 | file(SHA512 "${f2}" f2_cs) |
| 24 | if(NOT "${f1_cs}" STREQUAL "${f2_cs}") |
| 25 | message(FATAL_ERROR "Files do not match") |
| 26 | endif() |
| 27 | else() |
| 28 | file(READ "${f1}" f1_contents) |
| 29 | file(READ "${f2}" f2_contents) |
| 30 | if(NOT "${f1_contents}" STREQUAL "${f2_contents}") |
| 31 | message(FATAL_ERROR "Files do not match") |
| 32 | endif() |
| 33 | endif() |
| 34 | endfunction() |
| 35 | |
Eugene Kliuchnikov | 03739d2 | 2017-05-29 17:55:14 +0200 | [diff] [blame] | 36 | test_file_equality("${INPUT}" "${OUTPUT}.unbr") |