Skip to content
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

CI test: Try fixing Ninja MC in the default case #42

Draft
wants to merge 5 commits into
base: master
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
2 changes: 0 additions & 2 deletions .github/scripts/toolchains/aarch64-apple-darwin-clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_C_COMPILER_TARGET "aarch64-apple-darwin")
set(CMAKE_CXX_COMPILER_TARGET "aarch64-apple-darwin")
set(CMAKE_SYSTEM_NAME "Darwin")
set(CMAKE_SYSTEM_VERSION ${CMAKE_HOST_SYSTEM_VERSION})
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")
7 changes: 7 additions & 0 deletions .github/scripts/toolchains/x86_64-apple-darwin-clang.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_C_COMPILER_TARGET "x86_64-apple-darwin")
set(CMAKE_CXX_COMPILER_TARGET "x86_64-apple-darwin")
set(CMAKE_SYSTEM_NAME "Darwin")
set(CMAKE_SYSTEM_VERSION ${CMAKE_HOST_SYSTEM_VERSION})
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "")
22 changes: 22 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,28 @@ jobs:
working-directory: build
run: ctest --output-on-failure --build-config Debug -j 3

ninja_multi_config_cross_config:
name: Test Ninja Multi-Config Cross-Configs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install CMake
uses: corrosion-rs/install-cmake@v2
with:
cmake: 3.23.5
ninja: 1.10.0
# Install cbindgen before Rust to use recent default Rust version.
- name: Install cbindgen
run: cargo install cbindgen
- name: Install Rust
id: install_rust
uses: dtolnay/rust-toolchain@stable
- name: Configure
run: cmake -S. -Bbuild -G "Ninja Multi-Config" -DCMAKE_CROSS_CONFIGS="Debug;Release" -DCMAKE_DEFAULT_CONFIGS="Debug;Release"
- name: Run Tests
working-directory: build
run: ctest --output-on-failure -j 3 --build-config Debug


test_cxxbridge:
name: Test cxxbridge integration
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@
},
{
"name": "x86_64-apple-darwin-clang",
"inherits": ["x86_64-apple-darwin", "clang"]
"inherits": ["x86_64-apple-darwin", "clang"],
"toolchainFile": "${sourceDir}/.github/scripts/toolchains/${presetName}.cmake"
},
{
"name": "aarch64-apple-darwin-clang",
Expand Down
4 changes: 2 additions & 2 deletions cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function(_corrosion_set_imported_location_deferred target_name base_property out
elseif(output_directory)
set(curr_out_dir "${output_directory}")
else()
set(curr_out_dir "${CMAKE_CURRENT_BINARY_DIR}")
set(curr_out_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
endif()
string(REPLACE "\$<CONFIG>" "${config_type}" curr_out_dir "${curr_out_dir}")
message(DEBUG "Setting ${base_property}_${config_type_upper} for target ${target_name}"
Expand Down Expand Up @@ -235,7 +235,7 @@ function(_corrosion_copy_byproduct_deferred target_name output_dir_prop_names ca
# Fallback to the default directory. We do not append the configuration directory here
# and instead let CMake do this, since otherwise the resolving of dynamic library
# imported paths may fail.
set(curr_out_dir "${CMAKE_CURRENT_BINARY_DIR}")
set(curr_out_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
endif()
set(multiconfig_out_dir_genex "${multiconfig_out_dir_genex}$<$<CONFIG:${config_type}>:${curr_out_dir}>")
endforeach()
Expand Down
13 changes: 13 additions & 0 deletions cmake/FindRust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,19 @@ if (NOT Rust_CARGO_TARGET_CACHED)
if (_Rust_ANDROID_TARGET)
set(Rust_CARGO_TARGET_CACHED "${_Rust_ANDROID_TARGET}" CACHE STRING "Target triple")
endif()
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "OHOS")
if(CMAKE_OHOS_ARCH_ABI STREQUAL arm64-v8a)
set(_RUST_OHOS_TARGET aarch64-unknown-linux-ohos)
elseif(CMAKE_OHOS_ARCH_ABI STREQUAL armeabi-v7a)
set(_RUST_OHOS_TARGET armv7-unknown-linux-ohos)
elseif(CMAKE_OHOS_ARCH_ABI STREQUAL x86_64)
set(_RUST_OHOS_TARGET x86_64-unknown-linux-ohos)
else()
message(WARNING "unrecognized OHOS architecture: ${OHOS_ARCH}")
endif()
if(_RUST_OHOS_TARGET)
set(Rust_CARGO_TARGET_CACHED "${_RUST_OHOS_TARGET}" CACHE STRING "Target triple")
endif()
endif()
# Fallback to the default host target
if(NOT Rust_CARGO_TARGET_CACHED)
Expand Down
6 changes: 6 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ function(corrosion_tests_add_test test_name bin_names)
if(CMAKE_TOOLCHAIN_FILE)
list(APPEND configure_cmake_args TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}")
endif()
if(CMAKE_CROSS_CONFIGS)
list(APPEND configure_cmake_args CMAKE_CROSS_CONFIGS "${CMAKE_CROSS_CONFIGS}")
endif()
if(CMAKE_DEFAULT_CONFIGS)
list(APPEND configure_cmake_args CMAKE_DEFAULT_CONFIGS "${CMAKE_DEFAULT_CONFIGS}")
endif()

add_test(NAME "${test_name}_build"
COMMAND
Expand Down
8 changes: 8 additions & 0 deletions test/ConfigureAndBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ set(oneValueArgs
CARGO_PROFILE
OSX_ARCHITECTURES
TOOLCHAIN_FILE
CMAKE_CROSS_CONFIGS
CMAKE_DEFAULT_CONFIGS
)
set(multiValueArgs "PASS_THROUGH_ARGS")
cmake_parse_arguments(TEST "${options}" "${oneValueArgs}"
Expand Down Expand Up @@ -59,6 +61,12 @@ endif()
if(TEST_TOOLCHAIN_FILE)
list(APPEND configure_args "-DCMAKE_TOOLCHAIN_FILE=${TEST_TOOLCHAIN_FILE}")
endif()
if(TEST_CMAKE_CROSS_CONFIGS)
list(APPEND configure_args "-DCMAKE_CROSS_CONFIGS=${TEST_CMAKE_CROSS_CONFIGS}")
endif()
if(TEST_CMAKE_DEFAULT_CONFIGS)
list(APPEND configure_args "-DCMAKE_DEFAULT_CONFIGS=${TEST_CMAKE_DEFAULT_CONFIGS}")
endif()
if(TEST_CARGO_PROFILE)
list(APPEND configure_args "-DCARGO_PROFILE=${TEST_CARGO_PROFILE}")
endif()
Expand Down
Loading