Skip to content

Commit f674cc4

Browse files
authored
Emscripten build examples (#7787)
1 parent 5d28538 commit f674cc4

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: build-web-examples
2+
3+
4+
# make the action not run on the local repo if the branch is also in a pull request to OF/OF
5+
#on:
6+
# workflow_dispatch:
7+
# inputs:
8+
# release:
9+
# description: 'release'
10+
# required: true
11+
# default: 'nightly'
12+
on:
13+
push:
14+
if: github.event_name == 'push' && github.event.pull_request == null
15+
paths-ignore:
16+
- '**/*.md'
17+
- 'examples/**'
18+
pull_request:
19+
if: github.event_name == 'pull_request' && github.repository == 'openframeworks/openFrameworks'
20+
paths-ignore:
21+
- '**/*.md'
22+
- 'examples/**'
23+
jobs:
24+
build-web-examples:
25+
runs-on: ubuntu-20.04
26+
strategy:
27+
matrix:
28+
cfg:
29+
- target: emscripten
30+
env:
31+
TARGET: ${{matrix.cfg.target}}
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Docker Step
35+
run: docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.21 bash
36+
- name: Download libs
37+
run: ./scripts/$TARGET/download_libs.sh
38+
- name: Install dependencies
39+
run: ./scripts/ci/$TARGET/install_web_examples.sh
40+
- name: Build
41+
run: docker exec -e GA_EXAMPLES_USER=${{ secrets.SSH_USER }} -e GA_EXAMPLES_SERVER=${{ secrets.SSH_SERVER }} -e GA_EXAMPLES_KEY=${{ secrets.SSH_KEY }} -e GH_HEAD_REF=${{ github.head_ref }} -e GH_BRANCH=${{ github.ref_name }} -e GH_ACTIONS=true -i emscripten sh -c "scripts/ci/$TARGET/examples_to_build.sh"
42+
env:
43+
GA_EXAMPLES_USER: ${{ secrets.SSH_USER }}
44+
GA_EXAMPLES_SERVER: ${{ secrets.SSH_SERVER }}
45+
GA_EXAMPLES_KEY: ${{ secrets.SSH_KEY }}
46+
GH_HEAD_REF: ${{ github.head_ref }}
47+
GH_BRANCH: ${{ github.ref_name }}
48+
GH_ACTIONS: "true"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
# List of folder paths to iterate through make sure there is no trailing slash
4+
folders=(
5+
"examples/3d/pointCloudExample"
6+
# "examples/3d/3DPrimitivesExample"
7+
# "examples/3d/ofxAssimpBoneControlExample"
8+
# "examples/3d/ofxAssimpAdvancedExample"
9+
# "examples/3d/ofxAssimpAdvancedExample"
10+
# Add more paths as needed
11+
)
12+
13+
echo "RUNNING IN CI ${GH_BRANCH} ${GH_ACTIONS}"
14+
echo "TRYING USER/SERVER ${GA_EXAMPLES_USER}@${GA_EXAMPLES_SERVER}"
15+
16+
cur_root=$(pwd);
17+
cd $cur_root;
18+
mkdir -p out
19+
out_folder="$cur_root/out"
20+
21+
# Iterate through the folder paths
22+
for folder in "${folders[@]}"; do
23+
# Check if the folder exists
24+
if [ -d "$folder" ]; then
25+
26+
# Change to the directory
27+
cd $folder
28+
cp ../../../scripts/templates/emscripten/Makefile .
29+
cp ../../../scripts/templates/emscripten/config.make .
30+
emmake make -j2 Release
31+
32+
errorcode=$?
33+
if [[ $errorcode -ne 0 ]]; then
34+
echo "Couldn't build emscripten example: $folder"
35+
else
36+
folder_name=$(basename "$folder")
37+
cp -r "bin/em/$folder_name" "$out_folder/"
38+
fi
39+
40+
cd $cur_root
41+
else
42+
echo "Folder does not exist: $folder"
43+
fi
44+
done
45+
46+
cd $cur_root;
47+
DO_UPLOAD="false"
48+
49+
#if [[ "$GH_ACTIONS" = true && "${GH_BRANCH}" == "master" && -z "${GH_HEAD_REF}" ]]; then
50+
if [[ "$GH_ACTIONS" = "true" ]]; then
51+
echo "upload 1/2 - make key file"
52+
# Temporary file to store the private key
53+
key_file=$(mktemp)
54+
echo -e "$GA_EXAMPLES_KEY" > "$key_file"
55+
chmod 600 "$key_file"
56+
DO_UPLOAD="true";
57+
fi
58+
59+
if [ "$DO_UPLOAD" = "true" ]; then
60+
echo "upload 2/2 - time for rsync"
61+
remote_path="/home/ofadmin/openFrameworks.cc/examples/"
62+
rsync -avz -e "ssh -i $key_file" "$out_folder/" "$GA_EXAMPLES_USER@$GA_EXAMPLES_SERVER:$remote_path"
63+
rm -f "$key_file"
64+
fi
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
docker exec -i emscripten apt update
4+
docker exec -i emscripten apt install -y rsync
5+
docker exec -i emscripten sh -c "echo \$PATH"
6+

0 commit comments

Comments
 (0)