Skip to content

Commit 12c33cc

Browse files
authored
Merge pull request #21 from cschreib/snitch
Update CMake scripts and CI
2 parents 6cf34c1 + b9c2338 commit 12c33cc

File tree

8 files changed

+42
-23
lines changed

8 files changed

+42
-23
lines changed

.github/workflows/cmake.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- { name: Windows 32, os: windows-latest, compiler: vs2019, arch: "32", cmakepp: "", flags: "-A Win32"}
2424
- { name: Windows 64, os: windows-latest, compiler: vs2019, arch: "64", cmakepp: "", flags: "-A x64"}
2525
- { name: MacOS, os: macos-latest, compiler: clang++, arch: "64", cmakepp: "", flags: ""}
26-
- { name: WebAssembly, os: ubuntu-latest, compiler: em++, arch: "32", cmakepp: "emcmake", flags: "-DCMAKE_CXX_FLAGS='-s DISABLE_EXCEPTION_CATCHING=0' -DCMAKE_CROSSCOMPILING_EMULATOR=node"}
26+
- { name: WebAssembly, os: ubuntu-latest, compiler: em++, arch: "32", cmakepp: "emcmake", flags: "-DCMAKE_CXX_FLAGS='-s DISABLE_EXCEPTION_CATCHING=0' -DCMAKE_CXX_LINK_FLAGS='-s STACK_SIZE=5MB' -DCMAKE_CROSSCOMPILING_EMULATOR=node"}
2727
build-type:
2828
- Release
2929
- Debug
@@ -33,8 +33,9 @@ jobs:
3333

3434
steps:
3535
- name: Checkout code
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737
with:
38+
fetch-depth: 2 # necessary for codecov bash uploader
3839
submodules: 'recursive'
3940

4041
- name: Setup Clang
@@ -44,14 +45,14 @@ jobs:
4445
- name: Setup Emscripten cache
4546
if: matrix.platform.compiler == 'em++'
4647
id: cache-system-libraries
47-
uses: actions/cache@v3.3.1
48+
uses: actions/cache@v4
4849
with:
4950
path: ${{env.EM_CACHE_FOLDER}}
5051
key: ${{env.EM_VERSION}}-${{matrix.platform.name}}-${{matrix.build-type}}
5152

5253
- name: Setup Emscripten
5354
if: matrix.platform.compiler == 'em++'
54-
uses: mymindstorm/setup-emsdk@v12
55+
uses: mymindstorm/setup-emsdk@v14
5556
with:
5657
version: ${{env.EM_VERSION}}
5758
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}

.github/workflows/doc.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616

1717
- name: Get dependencies
1818
run: sudo apt-get install doxygen
@@ -22,13 +22,8 @@ jobs:
2222
shell: bash
2323
run: doxygen dox.conf
2424

25-
- name: Compress
26-
working-directory: ${{github.workspace}}/doc
27-
shell: bash
28-
run: zip docs.zip html/*
29-
3025
- name: Upload as an Artifact
31-
uses: actions/upload-artifact@v2
26+
uses: actions/upload-artifact@v4
3227
with:
33-
name: docs.zip
34-
path: ${{github.workspace}}/doc/docs.zip
28+
name: docs
29+
path: ${{github.workspace}}/doc/html

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
cmake_minimum_required(VERSION 3.8)
1+
cmake_minimum_required(VERSION 3.8..3.31)
22

33
# Setup main project
4-
project(oup LANGUAGES CXX VERSION 1.0)
4+
project(oup LANGUAGES CXX VERSION 0.7.3)
55

66
# Create library (header-only)
77
add_library(oup INTERFACE)

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Corentin Schreiber
3+
Copyright (c) 2025 Corentin Schreiber
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ int main() {
5959
auto owner_ptr = oup::make_observable_sealed<std::string>("hello");
6060

6161
// A sealed pointer cannot be copied but it can be moved
62-
// auto tmp_copied = owner_ptr; // error!
63-
// auto tmp_moved = std::move(owner_ptr); // OK
62+
// oup::observable_sealed_ptr<std::string> owner_copied = owner_ptr; // error!
63+
// oup::observable_sealed_ptr<std::string> owner_moved = std::move(owner_ptr); // OK
6464

6565
// Make the observer pointer point to the object
6666
obs_ptr = owner_ptr;
@@ -73,8 +73,8 @@ int main() {
7373
std::cout << *obs_ptr << std::endl;
7474

7575
// An observer pointer can be copied and moved
76-
// auto tmp_copied = obs_ptr; // OK
77-
// auto tmp_moved = std::move(obs_ptr); // OK
76+
// oup::observer_ptr<std::string> obs_copied = obs_ptr; // OK
77+
// oup::observer_ptr<std::string> obs_moved = std::move(obs_ptr); // OK
7878
}
7979

8080
// The sealed pointer has gone out of scope, the object is deleted,

tests/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ function(add_platform_definitions TARGET)
33
if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
44
target_compile_definitions(${TARGET} PRIVATE OUP_PLATFORM_WASM)
55
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_EMSCRIPTEN)
6+
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_LLVM)
67
elseif (APPLE)
78
target_compile_definitions(${TARGET} PRIVATE OUP_PLATFORM_OSX)
89
elseif (UNIX)
@@ -22,6 +23,7 @@ function(add_platform_definitions TARGET)
2223
target_compile_options(${TARGET} PRIVATE -Wall)
2324
target_compile_options(${TARGET} PRIVATE -Wextra)
2425
target_compile_options(${TARGET} PRIVATE -Werror)
26+
target_compile_definitions(${TARGET} PRIVATE OUP_COMPILER_LLVM)
2527
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
2628
target_compile_options(${TARGET} PRIVATE /W4)
2729
target_compile_options(${TARGET} PRIVATE /WX)
@@ -30,10 +32,9 @@ function(add_platform_definitions TARGET)
3032
endfunction()
3133

3234
include(FetchContent)
33-
3435
FetchContent_Declare(snitch
3536
GIT_REPOSITORY https://github.com/cschreib/snitch.git
36-
GIT_TAG v1.1.0)
37+
GIT_TAG v1.3.2)
3738
FetchContent_MakeAvailable(snitch)
3839

3940
set(RUNTIME_TEST_FILES

tests/runtime_tests_owner_construction.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,17 @@ TEMPLATE_LIST_TEST_CASE(
101101
if constexpr (eoft_allocates<TestType>) {
102102
fail_next_allocation{}, TestType{raw_ptr};
103103
} else {
104+
#if !defined(OUP_COMPILER_LLVM) || !defined(NDEBUG)
104105
REQUIRE_THROWS_AS((fail_next_allocation{}, TestType{raw_ptr}), std::bad_alloc);
106+
#else
107+
// LLVM in Release mode is able to inline the allocation, bypassing our
108+
// custom allocator that fails...
109+
try {
110+
fail_next_allocation{}, TestType{raw_ptr};
111+
} catch (const std::bad_alloc&) {
112+
// If it does throw, good. Else, ignore it.
113+
}
114+
#endif
105115
}
106116
}
107117

@@ -120,8 +130,18 @@ TEMPLATE_LIST_TEST_CASE(
120130
if constexpr (eoft_allocates<TestType>) {
121131
fail_next_allocation{}, TestType{raw_ptr, deleter};
122132
} else {
133+
#if !defined(OUP_COMPILER_LLVM) || !defined(NDEBUG)
123134
REQUIRE_THROWS_AS(
124135
(fail_next_allocation{}, TestType{raw_ptr, deleter}), std::bad_alloc);
136+
#else
137+
// LLVM in Release mode is able to inline the allocation, bypassing our
138+
// custom allocator that fails...
139+
try {
140+
fail_next_allocation{}, TestType{raw_ptr, deleter};
141+
} catch (const std::bad_alloc&) {
142+
// If it does throw, good. Else, ignore it.
143+
}
144+
#endif
125145
}
126146
}
127147

tests/testing.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#include "snitch/snitch.hpp"
1+
#include "snitch/snitch_macros_check.hpp"
2+
#include "snitch/snitch_macros_exceptions.hpp"
3+
#include "snitch/snitch_macros_test_case.hpp"
24
#include "tests_common.hpp"
35

46
// clang-format off

0 commit comments

Comments
 (0)