Skip to content

Commit 16d3b29

Browse files
JoyHakrenatoGarcia
authored andcommitted
Add MinGW support
1 parent d1d95ed commit 16d3b29

5 files changed

Lines changed: 83 additions & 9 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,58 @@ jobs:
105105
- name: run
106106
run: ctest -V -C Release
107107

108+
mingw:
109+
name: MinGW ${{ matrix.sys }} C++${{ matrix.cpp }}
110+
runs-on: windows-latest
111+
strategy:
112+
fail-fast: false
113+
matrix:
114+
cpp: [11, 14, 17, 20, 23]
115+
sys:
116+
- mingw64
117+
- mingw32
118+
- ucrt64
119+
- clang64
120+
include:
121+
- range_v3: ON
122+
- range_v3: OFF
123+
cpp: 11
124+
- range_v3: OFF
125+
sys: mingw32
126+
defaults:
127+
run:
128+
shell: msys2 {0}
129+
steps:
130+
- uses: actions/checkout@v4
131+
- uses: msys2/setup-msys2@v2
132+
with:
133+
msystem: ${{ matrix.sys }}
134+
update: true
135+
pacboy: >-
136+
gcc:p
137+
cmake:p
138+
ninja:p
139+
boost:p
140+
fmt:p
141+
${{ matrix.sys != 'mingw32' && 'range-v3:p' || '' }}
142+
- name: setup catch2
143+
run: |
144+
mkdir -p cmake/catch2
145+
curl -L -o cmake/catch2/catch.hpp https://github.com/catchorg/Catch2/releases/download/v2.13.10/catch.hpp
146+
cat > cmake/FindCatch2.cmake << 'EOF'
147+
add_library(Catch2::Catch2 INTERFACE IMPORTED)
148+
set_target_properties(Catch2::Catch2 PROPERTIES
149+
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}"
150+
)
151+
set(Catch2_FOUND TRUE)
152+
EOF
153+
- name: build
154+
run: |
155+
cmake . -G Ninja -DCMAKE_MODULE_PATH=$(pwd)/cmake -DENABLE_RANGE_V3=${{ matrix.range_v3 }} -DENABLE_FMT=ON -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=${{ matrix.cpp }} -DCMAKE_CXX_FLAGS='-Wall -Wextra -Wconversion -Wshadow -pedantic -Werror -Wno-c2y-extensions' -DCMAKE_BUILD_TYPE=Release
156+
cmake --build .
157+
- name: run
158+
run: ctest -V
159+
108160
macos:
109161
name: Xcode C++${{ matrix.cpp }}
110162
runs-on: macos-14

AUTHORS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
Renato Florentino Garcia <fgarcia.renato@gmail.com>
1+
Renato Garcia <fgarcia.renato@gmail.com>
2+
Dwayne Robinson <fdwr@hotmail.com>
3+
JoyHak <access-restricted@onionmail.org>

icecream.hpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@
7171
#pragma warning(disable: 4127 4355 4514 4623 4626 4820 4866 4868 5027 5045 4582 4583)
7272
#endif
7373

74-
#if (!defined(__APPLE__) && (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 15000))
74+
#if !( \
75+
defined(__APPLE__) /* macOS */ \
76+
|| (defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 15000) /* libc++ < 15.0 */ \
77+
|| (defined(__MSVCRT_VERSION__) && !defined( _UCRT)) /* msvcrt */ \
78+
)
7579
#define ICECREAM_UCHAR_HEADER
7680
#include <uchar.h>
7781
#endif
@@ -4081,6 +4085,25 @@ namespace detail {
40814085

40824086
// -------------------------------------------------- Range classes
40834087

4088+
// Check if a value of type From fits in type To. Uses SFINAE to avoid tautological
4089+
// comparison warnings when From type have the same size or is shorter than To type.
4090+
template<typename To, typename From>
4091+
auto fits_in(From v) -> typename std::enable_if<
4092+
(sizeof(From) > sizeof(To)), bool
4093+
>::type
4094+
{
4095+
return v >= std::numeric_limits<To>::lowest()
4096+
&& v <= std::numeric_limits<To>::max();
4097+
}
4098+
4099+
template<typename To, typename From>
4100+
auto fits_in(From) -> typename std::enable_if<
4101+
(sizeof(From) <= sizeof(To)), bool
4102+
>::type
4103+
{
4104+
return true;
4105+
}
4106+
40844107
// Direct representation of a slicing string.
40854108
struct Slice
40864109
{
@@ -4141,10 +4164,7 @@ namespace detail {
41414164
)
41424165

41434166
// or if there is an overflow to convert from long to ptrdiff
4144-
|| (
4145-
lnum > std::numeric_limits<ptrdiff_t>::max()
4146-
|| lnum < std::numeric_limits<ptrdiff_t>::lowest()
4147-
)
4167+
|| !fits_in<ptrdiff_t>(lnum)
41484168
) {
41494169
return {};
41504170
}

tests/test_c++11.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ TEST_CASE("pointer_like")
786786

787787
float* v0 = nullptr;
788788
IC(v0);
789-
#if !defined(__APPLE__) && defined(_LIBCPP_VERSION)
789+
#if !defined(__APPLE__) && defined(_LIBCPP_VERSION) && !defined(__MINGW64__)
790790
REQUIRE(str == "ic| v0: (nil)\n");
791791
#else
792792
REQUIRE_THAT(str, Catch::Matches("ic\\| v0: (0x)*0+\n"));
@@ -800,7 +800,7 @@ TEST_CASE("pointer_like")
800800

801801
auto v0 = std::unique_ptr<double> {};
802802
IC(v0);
803-
#if !defined(__APPLE__) && defined(_LIBCPP_VERSION)
803+
#if !defined(__APPLE__) && defined(_LIBCPP_VERSION) && !defined(__MINGW64__)
804804
REQUIRE(str == "ic| v0: (nil)\n");
805805
#else
806806
REQUIRE_THAT(str, Catch::Matches("ic\\| v0: (0x)*0+\n"));

tests/test_clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TEST_CASE("dump_string")
3636
{&i0},
3737
};
3838

39-
#if !defined(__APPLE__) && defined(_LIBCPP_VERSION)
39+
#if !defined(__APPLE__) && defined(_LIBCPP_VERSION) && !defined(__MINGW64__)
4040
auto const result = "ic\\| v0: \\{integers: \\[(0x)*[0-9a-fA-F]+, \\(nil\\)\\]\\}\n";
4141
#else
4242
auto const result = "ic\\| v0: \\{integers: \\[(0x)*[0-9a-fA-F]+, (0x)*0\\]\\}\n";

0 commit comments

Comments
 (0)