Skip to content

Commit

Permalink
Fix Emscripten builds
Browse files Browse the repository at this point in the history
Also, add a CI job for Emscripten
  • Loading branch information
eliaskosunen committed Oct 30, 2024
1 parent 88e23f2 commit 815b1fb
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/arch.yml'
- 'cmake/**'
Expand All @@ -16,6 +17,7 @@ on:
branches:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/arch.yml'
- 'cmake/**'
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/linux.yml'
- 'benchmark/**'
Expand All @@ -18,6 +19,7 @@ on:
branches:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/linux.yml'
- 'benchmark/**'
Expand Down Expand Up @@ -710,3 +712,55 @@ jobs:
- name: Test
working-directory: ${{ runner.workspace }}/build
run: ctest --output-on-failure

emscripten:
runs-on: ubuntu-22.04

env:
CMAKE_CXX_STANDARD: 17
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache

steps:
- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest

- name: Install ccache
run: |
${APT_INSTALL} ccache
- name: Checkout
uses: actions/checkout@v4

- name: Load ccache
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ github.workflow }}-emscripten-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-emscripten-${{ github.ref }}
ccache-${{ github.workflow }}-emscripten-${{ github.base_ref }}
ccache-${{ github.workflow }}-emscripten
- name: Setup ccache
run: |
ccache --version
ccache --zero-stats
ccache --show-stats
ccache --show-config
- name: Setup EMSDK
uses: mymindstorm/setup-emsdk@v14
with:
version: latest
actions-cache-folder: 'emsdk-cache'

- name: Run CMake
run: |
mkdir ${{ runner.workspace }}/build
cd ${{ runner.workspace }}/build
emcmake cmake -DSCN_CI=ON -DSCN_BENCHMARKS=OFF $GITHUB_WORKSPACE
- name: Build
working-directory: ${{ runner.workspace }}/build
run: |
emmake cmake --build . --parallel
2 changes: 2 additions & 0 deletions .github/workflows/lite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches-ignore:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/lite.yml'
- 'benchmark/**'
Expand All @@ -18,6 +19,7 @@ on:
branches-ignore:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/lite.yml'
- 'benchmark/**'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/macos.yml'
- 'benchmark/**'
Expand All @@ -18,6 +19,7 @@ on:
branches:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/macos.yml'
- 'benchmark/**'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/windows.yml'
- 'benchmark/**'
Expand All @@ -18,6 +19,7 @@ on:
branches:
- master
- v*/dev
- ci/*
paths:
- '.github/workflows/windows.yml'
- 'benchmark/**'
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
_Released 2024-xx-xx_

* Fix formatting options of user-defined types sometimes being ignored
* Fix build failures on Emscripten
* Update documentation to have a version-dropdown

## 3.0.1
Expand Down
5 changes: 3 additions & 2 deletions src/scn/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ SCN_GCC_POP
#if SCN_DISABLE_LOCALE
#define SCN_XLOCALE SCN_XLOCALE_DISABLED
#elif (!defined(__ANDROID_API__) || __ANDROID_API__ >= 28) && \
SCN_HAS_INCLUDE(<xlocale.h>)
!defined(__EMSCRIPTEN__) && SCN_HAS_INCLUDE(<xlocale.h>)
#include <xlocale.h>
#define SCN_XLOCALE SCN_XLOCALE_POSIX

#elif defined(_MSC_VER)
#define SCN_XLOCALE SCN_XLOCALE_MSVC

#elif defined(__GLIBC__) && !defined(__ANDROID_API__)
#elif defined(__GLIBC__) && !defined(__ANDROID_API__) && \
!defined(__EMSCRIPTEN__)
// glibc

#include <features.h>
Expand Down

0 comments on commit 815b1fb

Please sign in to comment.