From 4ffb41d8f085257dc46bd233fdd63f0d56886ee7 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Mon, 20 Nov 2023 18:36:03 +0100 Subject: [PATCH] Use different C++ build directories for debug/release and roundtrips --- docs/code-examples/roundtrips.py | 17 ++++++++++++++--- pixi.toml | 20 ++++++++++---------- tests/cpp/log_benchmark/main.cpp | 2 +- tests/roundtrips.py | 15 +++++++++++++-- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/docs/code-examples/roundtrips.py b/docs/code-examples/roundtrips.py index 79a663619ae69..a1ece2cb4290f 100755 --- a/docs/code-examples/roundtrips.py +++ b/docs/code-examples/roundtrips.py @@ -56,6 +56,8 @@ # fmt: on +cpp_build_dir = "build/roundtrips" + def run( args: list[str], *, env: dict[str, str] | None = None, timeout: int | None = None, cwd: str | None = None @@ -119,7 +121,16 @@ def main() -> None: build_type = "Debug" if args.release: build_type = "Release" - configure_args = ["cmake", f"-DCMAKE_BUILD_TYPE={build_type}", "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON", ".."] + configure_args = [ + "cmake", + "-G", + "Ninja", + "-B", + cpp_build_dir, + f"-DCMAKE_BUILD_TYPE={build_type}", + "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON", + "..", + ] run( configure_args, env=build_env, @@ -299,15 +310,15 @@ def cmake_build(target: str, release: bool) -> None: build_process_args = [ "cmake", "--build", + cpp_build_dir, ".", - "--config", config, "--target", target, "--parallel", str(multiprocessing.cpu_count()), ] - run(build_process_args, cwd="build") + run(build_process_args, cwd=cpp_build_dir) def run_comparison(rrd0_path: str, rrd1_path: str, full_dump: bool) -> None: diff --git a/pixi.toml b/pixi.toml index 2a17c2904a15c..48254d7956a85 100644 --- a/pixi.toml +++ b/pixi.toml @@ -48,31 +48,31 @@ py-test = { cmd = "python -m pytest -vv rerun_py/tests/unit", depends_on = [ ] } # All the cpp-* tasks can be configured with environment variables, e.g.: RERUN_WERROR=ON CXX=clang++ -cpp-prepare-release = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=Release" -cpp-prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=Debug" -cpp-build-all = { cmd = "cmake --build build --config Debug --target all", depends_on = [ +cpp-prepare-release = "cmake -G 'Ninja' -B build/release -S . -DCMAKE_BUILD_TYPE=Release" +cpp-prepare = "cmake -G 'Ninja' -B build/debug -S . -DCMAKE_BUILD_TYPE=Debug" +cpp-build-all = { cmd = "cmake --build build/debug --config Debug --target all", depends_on = [ "cpp-prepare", ] } cpp-clean = "rm -rf build CMakeCache.txt CMakeFiles" -cpp-build-tests = { cmd = "cmake --build build --config Debug --target rerun_sdk_tests", depends_on = [ +cpp-build-tests = { cmd = "cmake --build build/debug --config Debug --target rerun_sdk_tests", depends_on = [ "cpp-prepare", ] } -cpp-build-roundtrips = { cmd = "cmake --build build --config Debug --target roundtrips", depends_on = [ +cpp-build-roundtrips = { cmd = "cmake --build build/debug --config Debug --target roundtrips", depends_on = [ "cpp-prepare", ] } -cpp-build-examples = { cmd = "cmake --build build --config Debug --target examples", depends_on = [ +cpp-build-examples = { cmd = "cmake --build build/debug --config Debug --target examples", depends_on = [ "cpp-prepare", ] } -cpp-build-doc-examples = { cmd = "cmake --build build --config Debug --target doc_examples", depends_on = [ +cpp-build-doc-examples = { cmd = "cmake --build build/debug --config Debug --target doc_examples", depends_on = [ "cpp-prepare", ] } -cpp-build-log-benchmark = { cmd = "cmake --build build --config Release --target log_benchmark", depends_on = [ +cpp-build-log-benchmark = { cmd = "cmake --build build/release --config Release --target log_benchmark", depends_on = [ "cpp-prepare-release", ] } -cpp-test = { cmd = "export RERUN_STRICT=1 && ./build/rerun_cpp/tests/rerun_sdk_tests", depends_on = [ +cpp-test = { cmd = "export RERUN_STRICT=1 && ./build/debug/rerun_cpp/tests/rerun_sdk_tests", depends_on = [ "cpp-build-tests", ] } -cpp-log-benchmark = { cmd = "export RERUN_STRICT=1 && ./build/tests/cpp/log_benchmark/log_benchmark", depends_on = [ +cpp-log-benchmark = { cmd = "export RERUN_STRICT=1 && ./build/release/tests/cpp/log_benchmark/log_benchmark", depends_on = [ "cpp-build-log-benchmark", ] } cpp-build-and-test-all = { depends_on = ["cpp-build-all", "cpp-test"] } diff --git a/tests/cpp/log_benchmark/main.cpp b/tests/cpp/log_benchmark/main.cpp index 2852f03abbd10..08a1e17fa5f10 100644 --- a/tests/cpp/log_benchmark/main.cpp +++ b/tests/cpp/log_benchmark/main.cpp @@ -25,7 +25,7 @@ // For better whole-executable timing capture you can also first build the executable and then run: // ``` // pixi run cpp-build-log-benchmark -// ./build/tests/cpp/log_benchmark/log_benchmark +// ./build/release/tests/cpp/log_benchmark/log_benchmark // ``` // diff --git a/tests/roundtrips.py b/tests/roundtrips.py index d53d39bb8f742..33dcd38fdfce1 100755 --- a/tests/roundtrips.py +++ b/tests/roundtrips.py @@ -28,6 +28,8 @@ "time_series_scalar": ["cpp", "py", "rust"], # Don't need it, API example roundtrips cover it all } +cpp_build_dir = "build/roundtrips" + def run( args: list[str], *, env: dict[str, str] | None = None, timeout: int | None = None, cwd: str | None = None @@ -84,7 +86,16 @@ def main() -> None: build_type = "Debug" if args.release: build_type = "Release" - configure_args = ["cmake", f"-DCMAKE_BUILD_TYPE={build_type}", "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON", ".."] + configure_args = [ + "cmake", + "-G", + "Ninja", + "-B", + cpp_build_dir, + f"-DCMAKE_BUILD_TYPE={build_type}", + "-DCMAKE_COMPILE_WARNING_AS_ERROR=ON", + "..", + ] run( configure_args, env=build_env, @@ -248,7 +259,7 @@ def cmake_build(target: str, release: bool) -> None: "--parallel", str(multiprocessing.cpu_count()), ] - run(build_process_args, cwd="build") + run(build_process_args, cwd=cpp_build_dir) def run_comparison(rrd0_path: str, rrd1_path: str, full_dump: bool) -> None: