|
| 1 | +cmake_minimum_required(VERSION 3.20) |
| 2 | +project(Cpp2Rust-TestSuite) |
| 3 | + |
| 4 | +set(CPP2RUST_PROGRAMS woff2) |
| 5 | +set(CPP2RUST_MODELS unsafe refcount) |
| 6 | +set(CPP2RUST_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/../cpp2rust) |
| 7 | +set(CPP2RUST_BINARY ${CPP2RUST_SRCDIR}/build/cpp2rust/cpp2rust) |
| 8 | + |
| 9 | +# ----------------------------------------------------------------------------- |
| 10 | + |
| 11 | +include(${CPP2RUST_SRCDIR}/cmake/rust-toolchain.cmake) |
| 12 | + |
| 13 | +set(FILTER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/filter_compile_commands.py) |
| 14 | + |
| 15 | +foreach(_prog IN LISTS CPP2RUST_PROGRAMS) |
| 16 | + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${_prog}.cmake) |
| 17 | + |
| 18 | + set(_model_regen_targets "") |
| 19 | + set(_model_build_targets "") |
| 20 | + foreach(_model IN LISTS CPP2RUST_MODELS) |
| 21 | + write_rust_toolchain(${CMAKE_CURRENT_SOURCE_DIR}/${_prog}/out/${_model}) |
| 22 | + |
| 23 | + add_custom_target("build-${_prog}-${_model}" |
| 24 | + COMMAND ${CMAKE_COMMAND} -E env RUSTFLAGS=-Awarnings cargo build --release |
| 25 | + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_prog}/out/${_model}" |
| 26 | + USES_TERMINAL |
| 27 | + ) |
| 28 | + |
| 29 | + list(APPEND _model_regen_targets "regen-${_prog}-${_model}") |
| 30 | + list(APPEND _model_build_targets "build-${_prog}-${_model}") |
| 31 | + endforeach() |
| 32 | + |
| 33 | + add_custom_target("build-${_prog}" |
| 34 | + DEPENDS "build-${_prog}-original" ${_model_build_targets} |
| 35 | + ) |
| 36 | + |
| 37 | + add_custom_target("regen-${_prog}" |
| 38 | + DEPENDS "build-${_prog}-original" ${_model_regen_targets} |
| 39 | + ) |
| 40 | + |
| 41 | + add_custom_target("check-${_prog}" |
| 42 | + COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/${_prog}-test.sh" |
| 43 | + ${CMAKE_BINARY_DIR} |
| 44 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 45 | + ${CPP2RUST_MODELS} |
| 46 | + DEPENDS "build-${_prog}" |
| 47 | + USES_TERMINAL |
| 48 | + ) |
| 49 | + |
| 50 | + add_custom_target("benchmark-${_prog}" |
| 51 | + COMMAND python3 |
| 52 | + "${CPP2RUST_TESTS_DIR}/scripts/${_prog}_bench.py" |
| 53 | + "${CMAKE_BINARY_DIR}" |
| 54 | + --models ${CPP2RUST_MODELS} |
| 55 | + --csv "${CMAKE_BINARY_DIR}/bench_${_prog}.csv" |
| 56 | + --warmup 2 |
| 57 | + --runs 3 |
| 58 | + DEPENDS "build-${_prog}" |
| 59 | + USES_TERMINAL |
| 60 | + ) |
| 61 | +endforeach() |
| 62 | + |
| 63 | +list(TRANSFORM CPP2RUST_PROGRAMS PREPEND "build-" OUTPUT_VARIABLE _build_targets) |
| 64 | +list(TRANSFORM CPP2RUST_PROGRAMS PREPEND "check-" OUTPUT_VARIABLE _check_targets) |
| 65 | +list(TRANSFORM CPP2RUST_PROGRAMS PREPEND "regen-" OUTPUT_VARIABLE _regen_targets) |
| 66 | +list(TRANSFORM CPP2RUST_PROGRAMS PREPEND "benchmark-" OUTPUT_VARIABLE _bench_targets) |
| 67 | + |
| 68 | +add_custom_target("build" DEPENDS ${_check_targets}) |
| 69 | +add_custom_target("check" DEPENDS ${_check_targets}) |
| 70 | +add_custom_target("regen" DEPENDS ${_regen_targets}) |
| 71 | +add_custom_target("benchmark" DEPENDS ${_bench_targets}) |
0 commit comments