Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
hannorein committed Oct 31, 2023
1 parent 0401aa5 commit 34d5870
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: REBOUND (emscripten)

on: [push, pull_request]

jobs:
build:

name: Compiling with emscripten
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Download and install emscripten
run: |
git clone https://github.com/emscripten-core/emsdk.git
emsdk/emsdk install latest
emsdk/emsdk activate latest
- name: Compile all C examples (OPENGL=1)
run: |
bash docs/c_examples/compile_emcc.bash 1
- name: Compile all C examples (OPENGL=0)
run: |
bash docs/c_examples/compile_emcc.bash 0
22 changes: 16 additions & 6 deletions docs/c_examples/compile_emcc.bash
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
#!/bin/bash

source emsdk/emsdk_env.sh
READTHEDOCS_OUTPUT="${READTHEDOCS_OUTPUT:-.}"
OPENGL="${1:-1}"

echo "Compiling C examples with emscripten."
echo "Output dir: $READTHEDOCS_OUTPUT"
echo "OPENGL: $OPENGL"
echo ""

for dir in examples/*
for dir in examples/*/
do
echo $dir
echo "Working on $dir ..."
opengl_enabled=$(cat $dir/Makefile | grep -c "export OPENGL=1")
mpi_enabled=$(cat $dir/Makefile | grep -c "export MPI=1")
if [ $opengl_enabled -eq 1 ] && [ $mpi_enabled -eq 0 ]; then
echo "Creating dir... "
echo $READTHEDOCS_OUTPUT/html/emscripten_c_$dir/
if [ $opengl_enabled -eq $OPENGL ] && [ $mpi_enabled -eq 0 ]; then
mkdir -p $READTHEDOCS_OUTPUT/html/emscripten_c_$dir/
emcc -O3 -Isrc/ src/*.c $dir/problem.c -DOPENGL=1 -sSTACK_SIZE=655360 -s USE_GLFW=3 -s FULL_ES3=1 -sASYNCIFY --shell-file docs/c_examples/shell_rebound.html -o $READTHEDOCS_OUTPUT/html/emscripten_c_$dir/index.html
echo "Compiling... "
if [ $OPENGL -eq 1 ]; then
emcc -O3 -Isrc/ src/*.c $dir/problem.c -DOPENGL=1 -sSTACK_SIZE=655360 -s USE_GLFW=3 -s FULL_ES3=1 -sASYNCIFY --shell-file docs/c_examples/shell_rebound.html -o $READTHEDOCS_OUTPUT/html/emscripten_c_$dir/index.html || exit 1
else
emcc -O3 -Isrc/ src/*.c $dir/problem.c -sSTACK_SIZE=655360 -sASYNCIFY -o $READTHEDOCS_OUTPUT/html/emscripten_c_$dir/index.html || exit 1
fi
echo "Done. "
else
echo "Skipping."
fi
Expand Down

0 comments on commit 34d5870

Please sign in to comment.