Skip to content

ci: set the CARGO_BUILD_TARGET to reuse same cache #1191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/github-cxx-qt-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ jobs:
cargo_dir: ~/.cargo
rustc_wrapper: sccache
build_type: Release
cargo_target: x86_64-unknown-linux-gnu
- name: Ubuntu 24.04 (gcc) Qt6
os: ubuntu-24.04
qt_version: 6
Expand All @@ -308,6 +309,7 @@ jobs:
libgl1-mesa-dev
libvulkan-dev
libxkbcommon-dev
cargo_target: x86_64-unknown-linux-gnu

- name: macOS 13 (clang) Qt5
os: macos-13
Expand All @@ -331,6 +333,7 @@ jobs:
cxx: clang++
rustc_wrapper: sccache
build_type: Release
cargo_target: x86_64-apple-darwin
- name: macOS 14 (clang) Qt6
os: macos-14
qt_version: 6
Expand All @@ -353,6 +356,7 @@ jobs:
cxx: clang++
rustc_wrapper: sccache
build_type: Release
cargo_target: aarch64-apple-darwin

- name: Windows 2022 (MSVC) Qt5
os: windows-2022
Expand All @@ -372,6 +376,7 @@ jobs:
cxx: cl
rustc_wrapper: sccache
build_type: Release
cargo_target: x86_64-pc-windows-msvc
- name: Windows 2022 (MSVC2019) Qt6
os: windows-2022
qt_version: 6
Expand All @@ -390,6 +395,7 @@ jobs:
cxx: cl
rustc_wrapper: sccache
build_type: Release
cargo_target: x86_64-pc-windows-msvc
# Use a Debug build to ensure we can build and run tests in Debug mode with MSVC
- name: Windows 2022 (MSVC2022) Qt6 Debug
os: windows-2022
Expand All @@ -409,6 +415,7 @@ jobs:
cxx: cl
rustc_wrapper: sccache
build_type: Debug
cargo_target: x86_64-pc-windows-msvc

runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
Expand All @@ -422,6 +429,8 @@ jobs:
SCCACHE_CACHE_SIZE: 600M
SCCACHE_LOG: debug
SCCACHE_ERROR_LOG: ${{ matrix.sccache_log_path }}
# Ensure that we share the same target sub folder
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder how much sharing there can be between the builds, or if they are ultimately different anyway and need separate folders/caches. (cmake vs cargo)

CARGO_BUILD_TARGET: ${{ matrix.cargo_target }}

steps:
- name: "Clone Git repository"
Expand Down
15 changes: 4 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND BUILD_TESTING)
list(APPEND CARGO_ENV ${RUNTIME_ENV})
endif()

# Same logic as in Corrosion.cmake
if(CMAKE_VS_PLATFORM_NAME)
set(BUILD_DIR "${CMAKE_VS_PLATFORM_NAME}/$<CONFIG>")
elseif(CMAKE_CONFIGURATION_TYPES)
set(BUILD_DIR "$<CONFIG>")
else()
set(BUILD_DIR .)
endif()

# Set the target dir to the same that Corrosion uses to reuse build artifacts
# from the main build.
set(CARGO_TARGET_DIR "${CMAKE_BINARY_DIR}/${BUILD_DIR}/cargo/build")
set(CARGO_TARGET_DIR "${CMAKE_BINARY_DIR}/cargo/build")

if(BUILD_TESTING)
# Add CMake tests for `cargo test/clippy/fmt/doc`.
Expand All @@ -157,8 +148,10 @@ if(BUILD_TESTING)
set_tests_properties(cargo_tests cargo_clippy PROPERTIES
ENVIRONMENT_MODIFICATION "${CARGO_ENV}"
)
# Cargo doc cannot have a target set otherwise it fails
# https://github.com/rust-lang/cargo/issues/10368
set_tests_properties(cargo_doc PROPERTIES
ENVIRONMENT_MODIFICATION "${CARGO_ENV};RUSTDOCFLAGS=set:--deny=warnings"
ENVIRONMENT_MODIFICATION "${CARGO_ENV};RUSTDOCFLAGS=set:--deny=warnings;CARGO_BUILD_TARGET=unset:;"
)

# Ensure test inputs and outputs are formatted
Expand Down
Loading