Skip to content

Commit

Permalink
Enable emscripten in CI (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabrahams authored Aug 13, 2024
1 parent dfa962b commit 1548fa4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
name:
- Linux GCC
- Linux Clang
- Linux Emscripten
- MacOS Clang
- MacOS GCC
- Windows MSVC
Expand All @@ -35,6 +36,8 @@ jobs:
include:
- compiler: clang++

- cmake-launcher: ''

- name: 'Linux GCC'
compiler: g++
os: ubuntu-latest
Expand All @@ -53,6 +56,14 @@ jobs:
compiler: cl
os: windows-latest

- name: 'Linux Emscripten'
compiler: ''
os: ubuntu-latest
cmake-launcher: emcmake

env:
compiler: ${{ matrix.compiler && format('-DCMAKE_CXX_COMPILER={0}', matrix.compiler) || '' }}

steps:
- name: Install cppcheck
run: ${{ runner.os == 'Windows' && 'choco install cppcheck -y' || runner.os == 'macOS' && 'brew install cppcheck' || runner.os == 'Linux' && 'sudo apt-get install cppcheck' }}
Expand All @@ -72,6 +83,10 @@ jobs:
exit 1
fi
- name: Set up Emscripten
uses: mymindstorm/setup-emsdk@v14
if: ${{ contains(matrix.name, 'Emscripten') }}

- name: Set up MSVC (Windows)
uses: compnerd/gha-setup-vsdevenv@main

Expand All @@ -85,7 +100,7 @@ jobs:

- name: Configure
run: |
cmake -Wno-dev -S . -B ./build -GNinja -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DCMAKE_CXX_STANDARD=17
${{ matrix.cmake-launcher }} cmake -Wno-dev -S . -B ./build -GNinja ${{env.compiler}} -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DCMAKE_CXX_STANDARD=17
- name: Build
run: |
Expand Down
6 changes: 6 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ if(PROJECT_IS_TOP_LEVEL OR TEST_INSTALLED_VERSION)
endif()
endif()


if(EMSCRIPTEN)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
endif()

# ---- Dependencies ----

include(GoogleTest)
Expand Down
8 changes: 4 additions & 4 deletions test/precondition_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "adobe/contract_checks.hpp"
#ifndef _WIN32
#include <gtest/gtest.h>
#if !defined(GTEST_OS_WINDOWS) && !defined(__EMSCRIPTEN__)
#include <csignal>
#endif
#include <gtest/gtest.h>

ADOBE_DEFAULT_CONTRACT_VIOLATION_HANDLER()

#ifdef _WIN32
#if defined(GTEST_OS_WINDOWS) || defined(__EMSCRIPTEN__)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define EXPECT_ABORT(code, expected_output_regex) \
EXPECT_DEATH(code, expected_output_regex ".*\n*##ABORTED##");
EXPECT_DEATH_IF_SUPPORTED(code, expected_output_regex ".*\n*##ABORTED##");
#else
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define EXPECT_ABORT(code, expected_output_regex) \
Expand Down

0 comments on commit 1548fa4

Please sign in to comment.