Skip to content

Commit 9ed78cd

Browse files
build(cmake): Lower minimum Clang version for Velox compatibility: (#72)
Co-authored-by: kirkrodrigues <[email protected]>
1 parent 49d5713 commit 9ed78cd

File tree

11 files changed

+64
-203
lines changed

11 files changed

+64
-203
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,12 @@ jobs:
4343
run: "npm install -g @go-task/cli"
4444

4545
- if: "'macos-14' == matrix.os"
46-
name: "Install macOS 14 deps: coreutils (for md5sum) and Apple Clang 16 (for C++20)"
46+
name: "Install coreutils (for md5sum)"
4747
run: |-
4848
brew install coreutils
49-
brew install llvm@16
5049
5150
- name: "Run unit tests and examples"
52-
env: >-
53-
${{
54-
'macos-14' == matrix.os
55-
&& fromJson('{
56-
"CC": "/opt/homebrew/opt/llvm@16/bin/clang",
57-
"CXX": "/opt/homebrew/opt/llvm@16/bin/clang++"
58-
}')
59-
|| fromJson('{}')
60-
}}
51+
6152
# Currently unit tests rely on cassert and fail to compile in release mode.
6253
run: |-
6354
task test:run-debug

CMakeLists.txt

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,14 @@ project(ystdlib VERSION "0.1.0" LANGUAGES CXX)
55
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
66
include(CMakePackageConfigHelpers)
77
include(GNUInstallDirs)
8+
include(Toolchains/utils)
89
include(ystdlib-helpers)
910

11+
validate_compiler_versions()
12+
1013
option(BUILD_SHARED_LIBS "Build using shared libraries." OFF)
1114
option(ystdlib_BUILD_TESTING "Build the testing tree for ystdlib." ON)
1215

13-
# Require compiler versions that support the C++20 features necessary for compiling ystdlib
14-
if("AppleClang" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
15-
set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "16")
16-
elseif("Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
17-
set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "16")
18-
elseif("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
19-
set(ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION "11")
20-
else()
21-
message(
22-
FATAL_ERROR
23-
"Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}. Please use AppleClang, Clang, or GNU."
24-
)
25-
endif()
26-
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION}")
27-
message(
28-
FATAL_ERROR
29-
"${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at \
30-
least ${ystdlib_CMAKE_CXX_COMPILER_MIN_VERSION}."
31-
)
32-
endif()
33-
3416
set(CMAKE_EXPORT_COMPILE_COMMANDS
3517
ON
3618
CACHE BOOL

cmake/Toolchains/utils.cmake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This file contains utility functions for validating toolchain versions to ensure compatibility
2+
# with the C++20 features required by the project.
3+
4+
# Checks if the compiler ID and version meet the minimum requirements to support C++20 features
5+
# required by the project.
6+
function(validate_compiler_versions)
7+
if("AppleClang" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
8+
set(CXX_COMPILER_MIN_VERSION "15")
9+
elseif("Clang" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
10+
set(CXX_COMPILER_MIN_VERSION "15")
11+
elseif("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
12+
set(CXX_COMPILER_MIN_VERSION "11")
13+
else()
14+
message(
15+
FATAL_ERROR
16+
"Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}. Please use AppleClang, Clang, or GNU."
17+
)
18+
endif()
19+
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "${CXX_COMPILER_MIN_VERSION}")
20+
message(
21+
FATAL_ERROR
22+
"${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION} is too low. Must be at"
23+
" least ${CXX_COMPILER_MIN_VERSION}."
24+
)
25+
endif()
26+
endfunction()

cmake/ystdlib-helpers.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function(add_cpp_library)
114114
)
115115
endfunction()
116116

117-
# Adds a C++ 20 test executable named `unit-test-NAME` that will be built with `SOURCES` and linked
117+
# Adds a C++20 test executable named `unit-test-NAME` that will be built with `SOURCES` and linked
118118
# with `LINK_LIBRARIES`, in addition to Catch2.
119119
#
120120
# @param {string} NAME

src/ystdlib/containers/Array.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Array {
3737
// NOLINTNEXTLINE(*-avoid-c-arrays)
3838
: m_data{std::make_unique<T[]>(list.size())},
3939
m_size{list.size()} {
40-
std::ranges::copy(list, m_data.get());
40+
std::copy(list.begin(), list.end(), m_data.get());
4141
}
4242

4343
// Disable copy constructor and assignment operator

src/ystdlib/containers/test/test_Array.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <algorithm>
22
#include <concepts>
33
#include <cstddef>
4-
#include <ranges>
54
#include <stdexcept>
65
#include <string>
76
#include <string_view>
@@ -66,9 +65,12 @@ void test_list_initialization_in_function_call(
6665
ystdlib::containers::Array<PolymorphicConstructors> const& arr,
6766
std::vector<size_t> const& data
6867
) {
69-
REQUIRE(std::ranges::equal(
70-
arr | std::views::transform([](auto const& obj) { return obj.get_value(); }),
71-
data
68+
REQUIRE(std::equal(
69+
arr.begin(),
70+
arr.end(),
71+
data.begin(),
72+
data.end(),
73+
[](auto const& obj, size_t v) { return obj.get_value() == v; }
7274
));
7375
}
7476
} // namespace
@@ -88,7 +90,7 @@ TEST_CASE("test_array_reference", "[containers][Array]") {
8890
arr.at(idx) = idx;
8991
}
9092
auto const& arr_const_ref = arr;
91-
REQUIRE(std::ranges::equal(arr, arr_const_ref));
93+
REQUIRE(std::equal(arr.begin(), arr.end(), arr_const_ref.begin(), arr_const_ref.end()));
9294
}
9395

9496
TEST_CASE("test_array_ranged_copy", "[containers][Array]") {
@@ -97,8 +99,8 @@ TEST_CASE("test_array_ranged_copy", "[containers][Array]") {
9799
vec.push_back(idx);
98100
}
99101
Array<size_t> arr(cBufferSize);
100-
std::ranges::copy(vec, arr.begin());
101-
REQUIRE(std::ranges::equal(vec, arr));
102+
std::copy(vec.begin(), vec.end(), arr.begin());
103+
REQUIRE(std::equal(vec.cbegin(), vec.cend(), arr.begin(), arr.end()));
102104
}
103105

104106
TEST_CASE("test_array_movable", "[containers][Array]") {
@@ -109,7 +111,12 @@ TEST_CASE("test_array_movable", "[containers][Array]") {
109111
reference_array.at(idx) = idx;
110112
}
111113
auto const arr_moved{std::move(arr)};
112-
REQUIRE(std::ranges::equal(reference_array, arr_moved));
114+
REQUIRE(std::equal(
115+
reference_array.begin(),
116+
reference_array.end(),
117+
arr_moved.begin(),
118+
arr_moved.end()
119+
));
113120
}
114121

115122
TEST_CASE("test_array_illegal_access", "[containers][Array]") {
@@ -143,8 +150,8 @@ TEMPLATE_TEST_CASE(
143150
) {
144151
REQUIRE(std::is_fundamental_v<TestType>);
145152
Array<TestType> arr(cBufferSize);
146-
std::ranges::for_each(arr, [](auto const& p) -> void {
147-
REQUIRE((static_cast<TestType>(0) == p));
153+
std::for_each(arr.begin(), arr.end(), [](auto const& p) {
154+
REQUIRE(static_cast<TestType>(0) == p);
148155
});
149156
}
150157

@@ -158,7 +165,7 @@ TEST_CASE("test_array_list_initialization", "[containers][Array]") {
158165
vec{"yscope", "clp", "ystdlib", "ystdlib::containers::Array", "default_initializable"};
159166
Array<std::string> const
160167
arr{"yscope", "clp", "ystdlib", "ystdlib::containers::Array", "default_initializable"};
161-
REQUIRE(std::ranges::equal(vec, arr));
168+
REQUIRE(std::equal(vec.cbegin(), vec.cend(), arr.begin(), arr.end()));
162169

163170
// Test polymorphic list initialization
164171
REQUIRE(std::is_copy_constructible_v<PolymorphicConstructors>);
@@ -174,10 +181,12 @@ TEST_CASE("test_array_list_initialization", "[containers][Array]") {
174181
cTestNum0,
175182
std::string{cTestStr},
176183
ExplicitConstructor{cTestNum1}};
177-
REQUIRE(std::ranges::equal(
178-
list_init_arr
179-
| std::views::transform([](auto const& obj) { return obj.get_value(); }),
180-
data
184+
REQUIRE(std::equal(
185+
list_init_arr.begin(),
186+
list_init_arr.end(),
187+
data.cbegin(),
188+
data.cend(),
189+
[](auto const& obj, auto const& v) { return obj.get_value() == v; }
181190
));
182191
}
183192

src/ystdlib/error_handling/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ add_cpp_library(
1616
NAMESPACE ystdlib
1717
PUBLIC_HEADERS
1818
ErrorCode.hpp
19-
TraceableException.hpp
2019
Result.hpp
2120
utils.hpp
2221
PUBLIC_LINK_LIBRARIES
@@ -30,7 +29,6 @@ if(ystdlib_ENABLE_TESTS)
3029
SOURCES
3130
test/test_ErrorCode.cpp
3231
test/test_Result.cpp
33-
test/test_TraceableException.cpp
3432
test/types.cpp
3533
UNIFIED_TEST_TARGET "${UNIFIED_UNIT_TEST_TARGET}"
3634
)

src/ystdlib/error_handling/TraceableException.hpp

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/ystdlib/error_handling/test/test_ErrorCode.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ TEST_CASE("test_error_code", "[error_handling][ErrorCode]") {
4949

5050
TEST_CASE("test_error_code_failure_condition", "[error_handling][ErrorCode]") {
5151
std::error_code const failure_error_code{BinaryErrorCode{BinaryErrorCodeEnum::Failure}};
52-
std::ranges::for_each(cFailureConditions, [&](auto const& failure_condition) {
53-
REQUIRE((failure_error_code == failure_condition));
54-
});
55-
std::ranges::for_each(cNoneFailureConditions, [&](auto const& none_failure_condition) {
56-
REQUIRE((failure_error_code != none_failure_condition));
57-
});
52+
for (auto const& failure_condition : cFailureConditions) {
53+
REQUIRE(failure_error_code == failure_condition);
54+
}
55+
for (auto const& none_failure_condition : cNoneFailureConditions) {
56+
REQUIRE(failure_error_code != none_failure_condition);
57+
}
5858
}
5959
} // namespace ystdlib::error_handling::test

src/ystdlib/error_handling/test/test_TraceableException.cpp

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)