From 60be7672b5c1126da85c77000854a1e42ee21449 Mon Sep 17 00:00:00 2001 From: Richard Pospesel Date: Sat, 17 Feb 2024 13:32:25 +0000 Subject: [PATCH] build: move dependency handling of build and test targets into cmake targets --- Makefile | 90 ++++------------- README.md | 9 +- source/CMakeLists.txt | 9 ++ source/bindings/c/CMakeLists.txt | 10 +- source/bindings/cpp/CMakeLists.txt | 15 ++- source/bindings/java/CMakeLists.txt | 15 ++- source/bindings/python/CMakeLists.txt | 7 ++ source/examples/cpp/CMakeLists.txt | 17 ++-- source/gosling/CMakeLists.txt | 98 +++++++++++-------- source/gosling/crates/cgosling/CMakeLists.txt | 12 ++- source/gosling/crates/gosling/CMakeLists.txt | 12 ++- source/gosling/crates/honk-rpc/CMakeLists.txt | 6 +- .../crates/tor-interface/CMakeLists.txt | 10 +- source/pages/CMakeLists.txt | 12 +-- source/pages/images/CMakeLists.txt | 13 ++- source/test/functional/CMakeLists.txt | 8 +- source/test/unit/CMakeLists.txt | 6 +- 17 files changed, 183 insertions(+), 166 deletions(-) diff --git a/Makefile b/Makefile index 3db1ccef..fdb12ef5 100644 --- a/Makefile +++ b/Makefile @@ -36,76 +36,59 @@ config-min-size-rel: # build debug target debug: config-debug - @$(MAKE) -C out/debug + @$(MAKE) build_target -C out/debug # build release target release: config-release - @$(MAKE) -C out/release + @$(MAKE) build_target -C out/release # build release target rel-with-deb-info: config-rel-with-deb-info - @$(MAKE) -C out/rel-with-deb-info + @$(MAKE) build_target -C out/rel-with-deb-info # build release target min-size-rel: config-min-size-rel - @$(MAKE) -C out/min-size-rel + @$(MAKE) build_target -C out/min-size-rel # # Online Test Targets (invokes real tor) # -define test - @$(MAKE) honk_rpc_cargo_test -C out/$(1) - @$(MAKE) tor_interface_cargo_test -C out/$(1) - @$(MAKE) gosling_cargo_test -C out/$(1) - @$(MAKE) cgosling_cargo_test -C out/$(1) - @$(MAKE) gosling_functional_test -C out/$(1) - @$(MAKE) gosling_unit_test -C out/$(1) -endef - # build and run debug target tests test-debug: config-debug - @$(call test,"debug") + @$(MAKE) test_target -C out/debug # build and run release target tests test-release: config-release - @$(call test,"release") + @$(MAKE) test_target -C out/release # build and run rel-with-deb-info target tests test-rel-with-deb-info: config-rel-with-deb-info - @$(call test,"rel-with-deb-info") + @$(MAKE) test_target -C out/rel-with-deb-info # build and run min-size-rel target tests test-min-size-rel: config-min-size-rel - @$(call test,"min-size-rel") + @$(MAKE) test_target -C out/min-size-rel # # Offline Test targets (mock tor) # -define test-offline - @$(MAKE) honk_rpc_cargo_test -C out/$(1) - @$(MAKE) tor_interface_cargo_test_offline -C out/$(1) - @$(MAKE) gosling_cargo_test_offline -C out/$(1) - @$(MAKE) cgosling_cargo_test_offline -C out/$(1) - @$(MAKE) gosling_unit_test -C out/$(1) -endef - # debug tests which do not require access to the tor network test-offline-debug: config-debug - @$(call test-offline,"debug") + @$(MAKE) test_offline_target -C out/debug # release tests which do not require access to the tor network test-offline-release: config-release - @$(call test-offline,"release") + @$(MAKE) test_offline_target -C out/release # release tests which do not require access to the tor network test-offline-rel-with-deb-info: config-rel-with-deb-info - @$(call test-offline,"rel-with-deb-info") + @$(MAKE) test_offline_target -C out/rel-with-deb-info # release tests which do not require access to the tor network test-offline-min-size-rel: config-min-size-rel - @$(call test-offline,"min-size-rel") + @$(MAKE) test_offline_target -C out/min-size-rel # # Rust Code Coverage Targets @@ -151,69 +134,36 @@ lint: config-debug --include=out/debug/bindings/cpp/include/cgosling.hpp\ --project=out/debug/compile_commands.sans-catch2.json -define install_pages - @$(MAKE) install_pages -C out/$(1) - @$(MAKE) install_crate_docs -C out/$(1) - @$(MAKE) install_gosling_code_coverage -C out/$(1) - @$(MAKE) install_doxygen_output -C out/$(1) -endef - # # Website Install Targets # -# debug build the website, code coverage, c/c++ apis, and rust docs -install-pages-debug: config-debug - @$(call install_pages,"debug") +website-debug: config-debug + @$(MAKE) website_target -C out/debug -# release build the website, code coverage, c/c++ apis, and rust docs -install-pages-rel-with-deb-info: config-rel-with-deb-info - @$(call install_pages,"rel-with-deb-info") +website-rel-with-deb-info: config-rel-with-deb-info + @$(MAKE) website_target -C out/rel-with-deb-info # # Library Install Targets # # debug build everything and deploy to dist -install-debug: config-debug +install-debug: debug @$(MAKE) install -C out/debug # release build everything and deploy to dist -install-release: config-release +install-release: release @$(MAKE) install -C out/release # rel-with-deb-info build everything and deploy to dist -install-rel-with-deb-info: config-rel-with-deb-info +install-rel-with-deb-info: rel-with-deb-info @$(MAKE) install -C out/rel-with-deb-info # min-size-rel build everything and deploy to dist -install-min-size-rel: config-min-size-rel +install-min-size-rel: min-size-rel @$(MAKE) install -C out/min-size-rel -# -# Example Programs Install Targets -# - -define install_examples - @$(MAKE) install_hello_world_cpp -C out/$(1) -endef - -# debug build examples and deploy to dist -install-examples-debug: config-debug - @$(call install_examples,"debug") - -# release build everything and deploy to dist -install-examples-release: config-release - @$(call install_examples,"release") - -# rel-with-deb-info build everything and deploy to dist -install-examples-rel-with-deb-info: config-rel-with-deb-info - @$(call install_examples,"rel-with-deb-info") - -# min-size-rel build everything and deploy to dist -install-examples-min-size-rel: config-min-size-rel - @$(call install_examples,"min-size-rel") - # # Fuzzing targets # diff --git a/README.md b/README.md index a930029b..387c56ea 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ The **fuzz-** make targets have the following additional dependencies: - [cargo-fuzz](https://github.com/rust-fuzz/cargo-fuzz) - [libfuzzer](https://www.llvm.org/docs/LibFuzzer.html) -The **pages-** make target has the following additional dependencies: +The **website-** make target has the following additional dependencies: - [doxygen](https://www.doxygen.nl/) - [graphviz](https://www.graphviz.org/) @@ -95,16 +95,11 @@ The following make targets are supported: - **release** - **rel-with-deb-info** - **min-size-rel** -- **Install Targets:** build and deploy `cgosling` headers and static+shared libraries to `dist/*` +- **Install Targets:** build and deploy `cgosling` headers, static+shared libraries, bindings, and examples to `dist/*` - **install-debug** - **install-release** - **install-rel-with-deb-info** - **install-min-size-rel** -- **Install Examples Targets::** build and deploy the example projects to `dist/*` - - **install-examples-debug** - - **install-examples-release** - - **install-examples-rel-with-deb-info** - - **install-examples-min-size-rel** - **Test Targets:** build and run all tests using real tor daemon - **test-debug** - **test-release** diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 42b6e3aa..17d2cb17 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -56,6 +56,15 @@ endif() set(CARGO_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}/gosling) +# main build target needed for install +add_custom_target(build_target) +# runs all tests (requires internet access) +add_custom_target(test_target) +# runs the offline tests using mock tor provider +add_custom_target(test_offline_target) +# builds the documentation website +add_custom_target(website_target) + add_subdirectory(gosling) add_subdirectory(extern) add_subdirectory(test) diff --git a/source/bindings/c/CMakeLists.txt b/source/bindings/c/CMakeLists.txt index 82865fff..56a55ea8 100644 --- a/source/bindings/c/CMakeLists.txt +++ b/source/bindings/c/CMakeLists.txt @@ -41,7 +41,7 @@ foreach(src dest IN ZIP_LISTS gosling_c_bindings_sources gosling_c_bindings_outp COMMAND cp ${src} ${dest}) endforeach() -add_custom_target(gosling_c_bindings_target ALL +add_custom_target(gosling_c_bindings_target DEPENDS ${gosling_c_bindings_outputs}) add_dependencies(gosling_c_bindings_target cgosling_target) @@ -70,6 +70,10 @@ if(WINDOWS) target_link_libraries(gosling_c_static_bindings INTERFACE ntdll) endif() +add_custom_target(gosling_c_static_bindings_target) +add_dependencies(gosling_c_static_bindings_target gosling_c_static_bindings) +add_dependencies(build_target gosling_c_static_bindings_target) + # # Shared Library # @@ -87,6 +91,10 @@ if ((DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX)) ) endif() +add_custom_target(gosling_c_shared_bindings_target) +add_dependencies(gosling_c_shared_bindings_target gosling_c_shared_bindings) +add_dependencies(build_target gosling_c_shared_bindings_target) + # # Install # diff --git a/source/bindings/cpp/CMakeLists.txt b/source/bindings/cpp/CMakeLists.txt index 42b80434..714a1b32 100644 --- a/source/bindings/cpp/CMakeLists.txt +++ b/source/bindings/cpp/CMakeLists.txt @@ -20,7 +20,7 @@ add_custom_command( COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo run ${CARGO_FLAGS} --bin build_cpp_bindings ${CARGO_TARGET_DIR}/cgosling.json cgosling.hpp.handlebars ${GOSLING_INCLUDE_DIR}/cgosling.hpp WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) -add_custom_target(gosling_cpp_bindings_target ALL +add_custom_target(gosling_cpp_bindings_target DEPENDS ${gosling_cpp_bindings_outputs} gosling_c_bindings_target) # @@ -33,6 +33,10 @@ add_dependencies(gosling_cpp_static_bindings gosling_cpp_bindings_target) target_include_directories(gosling_cpp_static_bindings INTERFACE ${GOSLING_INCLUDE_DIR}) target_link_libraries(gosling_cpp_static_bindings INTERFACE gosling_c_static_bindings) +add_custom_target(gosling_cpp_static_bindings_target) +add_dependencies(gosling_cpp_static_bindings_target gosling_cpp_static_bindings) +add_dependencies(build_target gosling_cpp_static_bindings_target) + # # Shared Library # @@ -43,6 +47,10 @@ add_dependencies(gosling_cpp_shared_bindings gosling_cpp_bindings_target) target_include_directories(gosling_cpp_shared_bindings INTERFACE ${GOSLING_INCLUDE_DIR}) target_link_libraries(gosling_cpp_shared_bindings INTERFACE gosling_c_shared_bindings) +add_custom_target(gosling_cpp_shared_bindings_target) +add_dependencies(gosling_cpp_shared_bindings_target gosling_cpp_shared_bindings) +add_dependencies(build_target gosling_cpp_shared_bindings_target) + # # Install C++ Header # @@ -79,7 +87,7 @@ else() add_dependencies(gosling_cpp_doxygen_target gosling_cpp_bindings_target) # - # Install C/C++ Doxygen documentation + # Deploy C/C++ Doxygen documentation # add_custom_command( DEPENDS gosling_cpp_doxygen_target @@ -87,7 +95,8 @@ else() COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/website/cgosling COMMAND cp -r ${CMAKE_CURRENT_BINARY_DIR}/html/* ${CMAKE_INSTALL_PREFIX}/website/cgosling/. ) - add_custom_target(install_doxygen_output + add_custom_target(deploy_doxygen_website_target DEPENDS ${CMAKE_INSTALL_PREFIX}/website/cgosling ) + add_dependencies(website_target deploy_doxygen_website_target) endif() diff --git a/source/bindings/java/CMakeLists.txt b/source/bindings/java/CMakeLists.txt index a2ddf36d..cf622a7a 100644 --- a/source/bindings/java/CMakeLists.txt +++ b/source/bindings/java/CMakeLists.txt @@ -50,7 +50,16 @@ else() target_link_libraries(goslingjni PRIVATE gosling_cpp_static_bindings) target_compile_features(goslingjni PRIVATE cxx_std_17) - add_custom_target(gosling_java_bindings_target ALL - DEPENDS goslingjni - ) + add_custom_target(gosling_java_bindings_target) + add_dependencies(gosling_java_bindings_target goslingjni) + add_dependencies(build_target gosling_java_bindings_target) + + # + # Install + # + + install(TARGETS goslingjni) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Gosling.jar + DESTINATION bindings/java) + endif() diff --git a/source/bindings/python/CMakeLists.txt b/source/bindings/python/CMakeLists.txt index e1394d26..27d866c5 100644 --- a/source/bindings/python/CMakeLists.txt +++ b/source/bindings/python/CMakeLists.txt @@ -18,3 +18,10 @@ add_custom_command( ) add_custom_target(gosling_python_bindings_target ALL DEPENDS ${gosling_python_bindings_outputs}) + +# +# Install +# + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cgosling.py + DESTINATION bindings/python) diff --git a/source/examples/cpp/CMakeLists.txt b/source/examples/cpp/CMakeLists.txt index fac8ddaf..3ac87415 100644 --- a/source/examples/cpp/CMakeLists.txt +++ b/source/examples/cpp/CMakeLists.txt @@ -39,9 +39,14 @@ else() target_compile_features(hello_world_cpp PRIVATE cxx_std_17) - add_custom_target(install_hello_world_cpp - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/hello_world_cpp${CMAKE_EXECUTABLE_SUFFIX} - COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/examples - COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/hello_world_cpp${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_INSTALL_PREFIX}/examples/ - ) -endif() \ No newline at end of file + add_custom_target(hello_world_cpp_target) + add_dependencies(hello_world_cpp_target hello_world_cpp) + add_dependencies(build_target hello_world_cpp_target) + + # + # Install hello world example binary + # + + install(TARGETS hello_world_cpp + DESTINATION examples/hello_world_cpp) +endif() diff --git a/source/gosling/CMakeLists.txt b/source/gosling/CMakeLists.txt index 4bcf3164..6efb63ce 100644 --- a/source/gosling/CMakeLists.txt +++ b/source/gosling/CMakeLists.txt @@ -1,72 +1,88 @@ add_subdirectory(crates) -# -# code coverage -# -add_custom_command( - OUTPUT ${CARGO_TARGET_DIR}/tarpaulin/tarpaulin-report.html - COMMAND CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo tarpaulin --out html --output-dir ${CARGO_TARGET_DIR}/tarpaulin --timeout 600 - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +find_program(CARGO_TARPAULIN_EXECUTABLE NAMES cargo-tarpaulin) -add_custom_target(gosling_cargo_tarpaulin - DEPENDS ${CARGO_TARGET_DIR}/tarpaulin/tarpaulin-report.html - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + message(WARNING "Debug symbols not available; will not generate Rust test coverage") +elseif (NOT CARGO_TARPAULIN_EXECUTABLE) + message(WARNING "Could not find cargo-tarpaulin; will not generate Rust test coverage") +else() -# -# Install Rust test code-coverage report -# -add_custom_command( - OUTPUT ${CMAKE_INSTALL_PREFIX}/website/coverage.html - DEPENDS ${CARGO_TARGET_DIR}/tarpaulin/tarpaulin-report.html - COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/website - COMMAND cp ${CARGO_TARGET_DIR}/tarpaulin/tarpaulin-report.html ${CMAKE_INSTALL_PREFIX}/website/coverage.html -) + # + # Code coverage + # + add_custom_command( + OUTPUT ${CARGO_TARGET_DIR}/tarpaulin/coverage.html + COMMAND CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo tarpaulin --out html --output-dir ${CARGO_TARGET_DIR}/tarpaulin --timeout 600 + COMMAND mv ${CARGO_TARGET_DIR}/tarpaulin/tarpaulin-report.html ${CARGO_TARGET_DIR}/tarpaulin/coverage.html + COMMAND ${CMAKE_COMMAND} -E echo "Test Coverage Report: ${CARGO_TARGET_DIR}/tarpaulin/coverage.html" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + add_custom_target(gosling_cargo_tarpaulin + DEPENDS ${CARGO_TARGET_DIR}/tarpaulin/coverage.html + ) -add_custom_target(install_gosling_code_coverage - DEPENDS ${CMAKE_INSTALL_PREFIX}/website/coverage.html gosling_cargo_tarpaulin -) - -# -# offline code coverage -# -add_custom_command( - OUTPUT ${CARGO_TARGET_DIR}/tarpaulin-offline/tarpaulin-report.html - COMMAND CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo tarpaulin --out html --output-dir ${CARGO_TARGET_DIR}/tarpaulin-offline --features tor-interface/offline-test gosling/offline-test - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + # + # Code coverage (offline) + # + add_custom_command( + OUTPUT ${CARGO_TARGET_DIR}/tarpaulin/coverage-offline.html + COMMAND CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo tarpaulin --out html --output-dir ${CARGO_TARGET_DIR}/tarpaulin --features tor-interface/offline-test gosling/offline-test cgosling/offline-test + COMMAND mv ${CARGO_TARGET_DIR}/tarpaulin/tarpaulin-report.html ${CARGO_TARGET_DIR}/tarpaulin/coverage-offline.html + COMMAND ${CMAKE_COMMAND} -E echo "Test Coverage Report: ${CARGO_TARGET_DIR}/tarpaulin/coverage-offline.html" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + add_custom_target(gosling_cargo_tarpaulin_offline + DEPENDS ${CARGO_TARGET_DIR}/tarpaulin/coverage-offline.html + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) -add_custom_target(gosling_cargo_tarpaulin_offline - DEPENDS ${CARGO_TARGET_DIR}/tarpaulin-offline/tarpaulin-report.html - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) + # + # Deploy Rust test code-coverage reports to website + # + add_custom_command( + OUTPUT ${CMAKE_INSTALL_PREFIX}/website/coverage.html ${CMAKE_INSTALL_PREFIX}/website/coverage-offline.html + DEPENDS ${CARGO_TARGET_DIR}/tarpaulin/coverage.html ${CARGO_TARGET_DIR}/tarpaulin/coverage-offline.html + COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/website + COMMAND cp ${CARGO_TARGET_DIR}/tarpaulin/coverage.html ${CMAKE_INSTALL_PREFIX}/website/coverage.html + COMMAND cp ${CARGO_TARGET_DIR}/tarpaulin/coverage-offline.html ${CMAKE_INSTALL_PREFIX}/website/coverage-offline.html + ) + add_custom_target(deploy_gosling_test_coverage_website_target + DEPENDS ${CMAKE_INSTALL_PREFIX}/website/coverage.html ${CMAKE_INSTALL_PREFIX}/website/coverage-offline.html + ) + add_dependencies(website_target deploy_gosling_test_coverage_website_target) +endif() # -# crate linting +# Run crate linting # add_custom_target(gosling_cargo_clippy COMMAND CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo clippy WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # -# crate documentation +# Build crate documentation # add_custom_command( OUTPUT ${CARGO_TARGET_DIR}/doc COMMAND CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} cargo doc --no-deps --workspace --exclude cgosling + COMMAND ${CMAKE_COMMAND} -E echo "Rust Crate Documentation: ${CARGO_TARGET_DIR}/doc/gosling/index.html" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/crates) -add_custom_target(gosling_cargo_doc +add_custom_target(gosling_cargo_doc_target DEPENDS ${CARGO_TARGET_DIR}/doc) # -# Install Rust crate documenation +# Deploy Rust crate documenation to website # add_custom_command( - DEPENDS gosling_cargo_doc + DEPENDS gosling_cargo_doc_target OUTPUT ${CMAKE_INSTALL_PREFIX}/website/crates COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/website/crates COMMAND cp -r ${CARGO_TARGET_DIR}/doc/* ${CMAKE_INSTALL_PREFIX}/website/crates/. ) -add_custom_target(install_crate_docs +add_custom_target(deploy_crate_docs_website_target DEPENDS ${CMAKE_INSTALL_PREFIX}/website/crates ) +add_dependencies(website_target deploy_crate_docs_website_target) + diff --git a/source/gosling/crates/cgosling/CMakeLists.txt b/source/gosling/crates/cgosling/CMakeLists.txt index e1f8066e..fe746547 100644 --- a/source/gosling/crates/cgosling/CMakeLists.txt +++ b/source/gosling/crates/cgosling/CMakeLists.txt @@ -45,20 +45,22 @@ add_custom_target(cgosling_target add_dependencies(cgosling_target gosling_target) # -# test target +# cargo test target # -add_custom_target(cgosling_cargo_test +add_custom_target(cgosling_cargo_test_target COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo test ${CARGO_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +add_dependencies(test_target cgosling_cargo_test_target) # -# test target (offline) +# cargo test (offline) target # -add_custom_target(cgosling_cargo_test_offline +add_custom_target(cgosling_cargo_test_offline_target COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo test ${CARGO_FLAGS} --features offline-test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +add_dependencies(test_offline_target cgosling_cargo_test_offline_target) # # fuzz targets @@ -66,4 +68,4 @@ add_custom_target(cgosling_cargo_test_offline add_custom_target(gosling_cargo_fuzz_cgosling COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo fuzz run fuzz_cgosling ${CARGO_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) \ No newline at end of file +) diff --git a/source/gosling/crates/gosling/CMakeLists.txt b/source/gosling/crates/gosling/CMakeLists.txt index 44d33cc1..3fbdc8b2 100644 --- a/source/gosling/crates/gosling/CMakeLists.txt +++ b/source/gosling/crates/gosling/CMakeLists.txt @@ -25,17 +25,19 @@ add_custom_target(gosling_target DEPENDS ${gosling_outputs}) add_dependencies(gosling_target honk_rpc_target tor_interface_target) -# cargo test -add_custom_target(gosling_cargo_test +# cargo test target +add_custom_target(gosling_cargo_test_target COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo test ${CARGO_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +add_dependencies(test_target gosling_cargo_test_target) -# cargo test (offline) -add_custom_target(gosling_cargo_test_offline +# cargo test (offline) target +add_custom_target(gosling_cargo_test_offline_target COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo test ${CARGO_FLAGS} --features offline-test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +add_dependencies(test_offline_target gosling_cargo_test_offline_target) # # fuzz targets @@ -58,4 +60,4 @@ add_custom_target(gosling_cargo_fuzz_endpoint_server add_custom_target(gosling_cargo_fuzz_endpoint_client COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo fuzz run fuzz_endpoint_client ${CARGO_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) \ No newline at end of file +) diff --git a/source/gosling/crates/honk-rpc/CMakeLists.txt b/source/gosling/crates/honk-rpc/CMakeLists.txt index 9bfe2cfa..1c0e0ed5 100644 --- a/source/gosling/crates/honk-rpc/CMakeLists.txt +++ b/source/gosling/crates/honk-rpc/CMakeLists.txt @@ -20,12 +20,14 @@ add_custom_target(honk_rpc_target DEPENDS ${honk_rpc_outputs}) # -# test target +# cargo test target # -add_custom_target(honk_rpc_cargo_test +add_custom_target(honk_rpc_cargo_test_target COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo test ${CARGO_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +add_dependencies(test_target honk_rpc_cargo_test_target) +add_dependencies(test_offline_target honk_rpc_cargo_test_target) # # fuzz target diff --git a/source/gosling/crates/tor-interface/CMakeLists.txt b/source/gosling/crates/tor-interface/CMakeLists.txt index 88b39c67..e9b30ba8 100644 --- a/source/gosling/crates/tor-interface/CMakeLists.txt +++ b/source/gosling/crates/tor-interface/CMakeLists.txt @@ -25,17 +25,19 @@ add_custom_command( add_custom_target(tor_interface_target DEPENDS ${tor_interface_outputs}) -# cargo test -add_custom_target(tor_interface_cargo_test +# cargo test target +add_custom_target(tor_interface_cargo_test_target COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo test ${CARGO_FLAGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +add_dependencies(test_target tor_interface_cargo_test_target) -# cargo test (offline) -add_custom_target(tor_interface_cargo_test_offline +# cargo test (offline) target +add_custom_target(tor_interface_cargo_test_offline_target COMMAND env CARGO_TARGET_DIR=${CARGO_TARGET_DIR} RUSTFLAGS=${RUSTFLAGS} RUST_BACKTRACE=full cargo test ${CARGO_FLAGS} --features offline-test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) +add_dependencies(test_offline_target tor_interface_cargo_test_offline_target) # # fuzz target diff --git a/source/pages/CMakeLists.txt b/source/pages/CMakeLists.txt index 3f35df49..baeb7c9f 100644 --- a/source/pages/CMakeLists.txt +++ b/source/pages/CMakeLists.txt @@ -22,7 +22,7 @@ else() # list of build output filenames set(build_outputs) # list of final installed files - set(install_outputs) + set(deploy_outputs) # our source markdown files set(page_sources @@ -82,7 +82,7 @@ else() ) # - # Install website pages + # Deploy website pages # add_custom_command( @@ -95,10 +95,10 @@ else() DEPENDS ${CMAKE_INSTALL_PREFIX}/website ${CMAKE_CURRENT_BINARY_DIR}/${file} COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/${file} ${CMAKE_INSTALL_PREFIX}/website/${file} ) - list(APPEND install_outputs ${CMAKE_INSTALL_PREFIX}/website/${file}) + list(APPEND deploy_outputs ${CMAKE_INSTALL_PREFIX}/website/${file}) endforeach() - - add_custom_target(install_pages - DEPENDS ${install_outputs} install_gosling_pages_images + add_custom_target(deploy_pages_website_target + DEPENDS ${deploy_outputs} deploy_gosling_pages_images_website_target ) + add_dependencies(website_target deploy_pages_website_target) endif() diff --git a/source/pages/images/CMakeLists.txt b/source/pages/images/CMakeLists.txt index 3ee1238c..4fe6307c 100644 --- a/source/pages/images/CMakeLists.txt +++ b/source/pages/images/CMakeLists.txt @@ -1,7 +1,7 @@ # list of build output filenames set(build_outputs) # list of final installed files -set(install_outputs) +set(deploy_outputs) # files which we will just copy directly set(copy_sources @@ -14,7 +14,7 @@ foreach(file ${copy_sources}) DEPENDS ${file} COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/${file} ${file}) list(APPEND build_outputs ${file}) - list(APPEND install_outputs ${CMAKE_CURRENT_BINARY_DIR}/${file}) + list(APPEND deploy_outputs ${CMAKE_CURRENT_BINARY_DIR}/${file}) endforeach() # files which we need to generate via plantuml @@ -32,7 +32,7 @@ foreach(file_uml ${plantuml_sources}) COMMAND plantuml -tsvg ${CMAKE_CURRENT_SOURCE_DIR}/${file_uml} -output ${CMAKE_CURRENT_BINARY_DIR} COMMAND tidy -xml -indent --hide-comments 1 --write-back 1 ${file_svg}) list(APPEND build_outputs ${file_svg}) - list(APPEND install_outputs ${CMAKE_CURRENT_BINARY_DIR}/${file_svg}) + list(APPEND deploy_outputs ${CMAKE_CURRENT_BINARY_DIR}/${file_svg}) endforeach() add_custom_target(gosling_pages_images_target @@ -53,9 +53,8 @@ foreach(file ${build_outputs}) DEPENDS ${CMAKE_INSTALL_PREFIX}/website/images ${CMAKE_CURRENT_BINARY_DIR}/${file} COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/${file} ${CMAKE_INSTALL_PREFIX}/website/images/${file} ) - list(APPEND install_outputs ${CMAKE_INSTALL_PREFIX}/website/images/${file}) + list(APPEND deploy_outputs ${CMAKE_INSTALL_PREFIX}/website/images/${file}) endforeach() - -add_custom_target(install_gosling_pages_images - DEPENDS ${install_outputs} gosling_pages_images_target +add_custom_target(deploy_gosling_pages_images_website_target + DEPENDS ${deploy_outputs} gosling_pages_images_target ) diff --git a/source/test/functional/CMakeLists.txt b/source/test/functional/CMakeLists.txt index 061961d3..3af92b14 100644 --- a/source/test/functional/CMakeLists.txt +++ b/source/test/functional/CMakeLists.txt @@ -19,13 +19,13 @@ else() target_compile_features(gosling_functional PRIVATE cxx_std_17) - add_custom_target(gosling_functional_test + add_custom_target(gosling_functional_test_target COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR} COMMAND gosling_functional WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - add_dependencies(gosling_functional_test gosling_functional) - -endif() \ No newline at end of file + add_dependencies(gosling_functional_test_target gosling_functional) + add_dependencies(test_target gosling_functional_test_target) +endif() diff --git a/source/test/unit/CMakeLists.txt b/source/test/unit/CMakeLists.txt index cc33ab3f..c7b93f50 100644 --- a/source/test/unit/CMakeLists.txt +++ b/source/test/unit/CMakeLists.txt @@ -6,11 +6,13 @@ target_precompile_headers(gosling_unit PRIVATE precomp.hpp) target_link_libraries(gosling_unit PRIVATE gosling_cpp_shared_bindings) target_link_libraries(gosling_unit PRIVATE Catch2::Catch2WithMain) -add_custom_target(gosling_unit_test +add_custom_target(gosling_unit_test_target COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR} COMMAND gosling_unit WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) -add_dependencies(gosling_unit_test gosling_unit) +add_dependencies(gosling_unit_test_target gosling_unit) +add_dependencies(test_target gosling_unit_test_target) +add_dependencies(test_offline_target gosling_unit_test_target)