Skip to content

Commit

Permalink
Merge pull request #489 from Interlisp/fgh_em-build-01
Browse files Browse the repository at this point in the history
Add Emscripten build to buildRelease workflow
  • Loading branch information
fghalasz authored Feb 11, 2024
2 parents 586a320 + ce7dead commit ce20acc
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 15 deletions.
104 changes: 89 additions & 15 deletions .github/workflows/buildRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
echo "linux=true" >> $GITHUB_OUTPUT;
echo "macos=true" >> $GITHUB_OUTPUT;
echo "windows=true" >> $GITHUB_OUTPUT;
######################################################################################

Expand All @@ -123,7 +123,7 @@ jobs:
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down Expand Up @@ -157,15 +157,15 @@ jobs:
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}

# Checkout the branch
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Setup release tag
- name: Setup Release Tag
Expand Down Expand Up @@ -272,11 +272,11 @@ jobs:

# Checkout the branch
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down Expand Up @@ -324,7 +324,7 @@ jobs:
export LDEARCH=aarch64-apple-darwin
./makeright init
mkdir -p ../darwin.universal
exe=ldeinit
exe=ldeinit
lipo -create \
-arch arm64 ../darwin.aarch64/${exe} \
-arch x86_64 ../darwin.x86_64/${exe} \
Expand All @@ -346,7 +346,7 @@ jobs:
lipo ${exe} -output ../darwin.x86_64/${exe} -extract x86_64
lipo ${exe} -output ../darwin.aarch64/${exe} -extract arm64
cp -p ${exe} ../darwin.universal/${exe}
done
done
# Create release tar for github.
- name: Make release tar(s)
Expand All @@ -369,7 +369,7 @@ jobs:
# Push Release
- name: Push the release
uses: ncipollo/release-action@v1
with:
with:
allowUpdates: true
artifacts:
/tmp/release_tars/${{ steps.tag.outputs.release_tag }}-darwin.x86_64.tgz,
Expand All @@ -383,7 +383,7 @@ jobs:

# Windows: build for Windows-Cygwin via Docker build and use results to
# create and push release assets to github

windows:

needs: [inputs, sentry]
Expand Down Expand Up @@ -418,21 +418,21 @@ jobs:
# Retrieve SDL2 and install in cygwin
- name: Install SDL2
id: sdl2
env:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download 2.26.5 --repo interlisp/cygwin-sdl --pattern *.tgz --output .\cygwin\sdl2.tar.gz
cygwin\bin\bash -login -c 'cd /; tar xzf sdl2.tar.gz'
# Checkout the branch
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: cygwin\maiko

# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down Expand Up @@ -473,6 +473,80 @@ jobs:



######################################################################################

# Emscripten: build and push Maiko compiled for Emscripten (to run Maiko in browser)

emscripten:

needs: [inputs, sentry]
if: |
needs.inputs.outputs.linux == 'true'
&& (
needs.sentry.outputs.release_not_built == 'true'
|| needs.inputs.outputs.force == 'true'
)
runs-on: ubuntu-latest

steps:

# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}

# Install SDL2
- name: Install SDL2
run: |
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get install -y libsdl2-dev libsdl2-2.0-0
# Install Emscripten SDK
- name: Install Empscripten
working-directory: ../
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
CWD="$(pwd)"
echo "${CWD}" >> ${GITHUB_PATH}
echo "${CWD}/upstream/emscripten" >> ${GITHUB_PATH}
echo "${CWD}/upstream/emscripten/tools" >> ${GITHUB_PATH}
echo "${CWD}/node/$(ls -d node/*64bit | tail -1)/bin" >> ${GITHUB_PATH}
# Checkout the maiko branch
- name: Checkout
uses: actions/checkout@v4

# Setup release tag
- name: Setup Release Tag
id: tag
uses: ./../actions/release-tag-action

# Compile maiko using Emscripten (no load build)
- name: Compile Maiko using Emscripten
working-directory: ./bin
run: |
./makeright wasm_nl
cd ../emscripten.wasm_nl
tar -c -z -f ../${{ steps.tag.outputs.release_tag }}-emscripten.tgz *
# Push Release to github
- name: Push the release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: ${{ steps.tag.outputs.release_tag }}-emscripten.tgz
tag: ${{ steps.tag.outputs.release_tag }}
draft: ${{ needs.inputs.outputs.draft }}
token: ${{ secrets.GITHUB_TOKEN }}


######################################################################################

# Use set-sentry-action to determine set the sentry that says this release has
Expand All @@ -485,12 +559,12 @@ jobs:
outputs:
build_successful: ${{ steps.output.outputs.build_successful }}

needs: [inputs, sentry, linux, macos, windows]
needs: [inputs, sentry, linux, macos, windows, emscripten]

steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ cmake-build-*/**
*.x86_64/**
*.wasm/**
*.wasm-wasm/**
*.wasm_nl/**
*.wasm_nl-wasm_nl/**
*.armv7l-x/**
*.armv7l/**
*.aarch64-x/**
Expand Down
23 changes: 23 additions & 0 deletions bin/makefile-emscripten.wasm_nl-wasm_nl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Options for Emscripten, WASM and SDL

CC = emcc $(CLANG_CFLAGS)

XFILES = $(OBJECTDIR)sdl.o

XFLAGS = -DSDL -sUSE_SDL=2

# OPTFLAGS is normally -O2.
OPTFLAGS = -O2
DFLAGS = $(XFLAGS) -DRELEASE=351 -DMAIKO_ENABLE_NETHUB

MEDLEY?=../../medley
SYSOUT?=$(MEDLEY)/loadups/full.sysout

LD = emcc
LDFLAGS = -sUSE_SDL=2 -sASYNCIFY -sALLOW_MEMORY_GROWTH -sEXIT_RUNTIME=1 -sFORCE_FILESYSTEM -sLZ4

LDELDFLAGS =

OBJECTDIR = ../$(RELEASENAME)/

default : ../$(OSARCHNAME)/ldesdl.js
5 changes: 5 additions & 0 deletions bin/makeright
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ case "$display" in
releasename=${osversion}.${architecture}-${display}
ldename=ldesdl.js
;;
wasm_nl) osversion=emscripten
architecture=wasm_nl
releasename=${osversion}.${architecture}-${display}
ldename=ldesdl.js
;;
*) echo "display-option: $display is not supported."
exit
;;
Expand Down

0 comments on commit ce20acc

Please sign in to comment.