Skip to content

Commit 0901095

Browse files
authored
adding emscripten build test (#710)
* adding emscripten build test * minor fixes * better guarding * lint
1 parent 4e33f2e commit 0901095

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

.github/workflows/emscripten.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: emscripten
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
10+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
11+
- uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14
12+
- name: Verify
13+
run: emcc -v
14+
- name: Checkout
15+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v3.6.0
16+
- name: Configure
17+
run: emcmake cmake -B build
18+
- name: Build # We build but do not test
19+
run: cmake --build build

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/tests/config.h.in"
108108
#################################
109109

110110
add_subdirectory(src)
111-
if(ENABLE_ROARING_TESTS)
111+
if(ENABLE_ROARING_TESTS AND NOT EMSCRIPTEN)
112112
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # we only include the benchmarks on 64-bit systems.
113113
add_subdirectory(benchmarks)
114114
endif()
115115
add_subdirectory(tests)
116116
endif()
117117
find_program(BASH bash)
118118

119-
if(ENABLE_ROARING_TESTS AND BASH)
119+
if(ENABLE_ROARING_TESTS AND BASH AND NOT EMSCRIPTEN)
120120
message(STATUS "Amalgamation tests enabled")
121121
set(CROARING_SINGLEHEADER_FILES
122122
${CMAKE_CURRENT_BINARY_DIR}/amalgamation_demo.c

cpp/roaring64map.hh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <algorithm>
1313
#include <cinttypes> // PRIu64 macro
14+
#include <climits> // for UINT64_MAX
1415
#include <cstdarg> // for va_list handling in bitmapOf()
1516
#include <cstdio> // for std::printf() in the printf() method
1617
#include <cstring> // for std::memcpy()
@@ -781,6 +782,9 @@ class Roaring64Map {
781782
* Returns true if the bitmap is full (cardinality is max uint64_t + 1).
782783
*/
783784
bool isFull() const {
785+
// This function is somewhat absurd. A full 64-bit bitmap would surely
786+
// exceed our memory limits.
787+
#if SIZE_MAX >= UINT64_MAX
784788
// only bother to check if map is fully saturated
785789
//
786790
// we put std::numeric_limits<>::max/min in parentheses
@@ -793,6 +797,11 @@ class Roaring64Map {
793797
return roaring_map_entry.second.isFull();
794798
})
795799
: false;
800+
#else
801+
// if SIZE_MAX < UINT64_MAX, then we cannot represent a full bitmap
802+
// in a 64-bit integer, so we return false.
803+
return false;
804+
#endif
796805
}
797806

798807
/**

src/containers/run.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void run_container_offset(const run_container_t *c, container_t **loc,
157157
lo = run_container_create_given_capacity(lo_cap);
158158
memcpy(lo->runs, c->runs, lo_cap * sizeof(rle16_t));
159159
lo->n_runs = lo_cap;
160-
for (int i = 0; i < lo_cap; ++i) {
160+
for (unsigned int i = 0; i < lo_cap; ++i) {
161161
lo->runs[i].value += offset;
162162
}
163163
*loc = (container_t *)lo;
@@ -167,7 +167,7 @@ void run_container_offset(const run_container_t *c, container_t **loc,
167167
hi = run_container_create_given_capacity(hi_cap);
168168
memcpy(hi->runs, c->runs + pivot, hi_cap * sizeof(rle16_t));
169169
hi->n_runs = hi_cap;
170-
for (int i = 0; i < hi_cap; ++i) {
170+
for (unsigned int i = 0; i < hi_cap; ++i) {
171171
hi->runs[i].value += offset;
172172
}
173173
*hic = (container_t *)hi;

tools/cmake/FindCTargets.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include(${PROJECT_SOURCE_DIR}/tools/cmake/Import.cmake)
22
set(BUILD_STATIC_LIB ON)
3-
if (ENABLE_ROARING_TESTS)
3+
if (ENABLE_ROARING_TESTS AND NOT EMSCRIPTEN)
44
if(ROARING_USE_CPM)
55
CPMAddPackage(
66
NAME cmocka

0 commit comments

Comments
 (0)