Skip to content

Commit 7a77bf8

Browse files
authored
Merge pull request #576 from ChinYikMing/ci-emcc-build
Allow emcc build and validate in CI
2 parents 375e96d + 774bd94 commit 7a77bf8

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

.github/workflows/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,35 @@ jobs:
5858
uses: rlalik/setup-cpp-compiler@master
5959
with:
6060
compiler: ${{ matrix.compiler }}
61+
- name: Setup emsdk
62+
uses: mymindstorm/setup-emsdk@v14
63+
with:
64+
version: 3.1.51
65+
actions-cache-folder: 'emsdk-cache'
6166
- name: fetch artifact first to reduce HTTP requests
6267
env:
6368
CC: ${{ steps.install_cc.outputs.cc }}
6469
run: |
6570
make artifact
6671
make ENABLE_SYSTEM=1 artifact
6772
make ENABLE_ARCH_TEST=1 artifact
73+
# Hack Cloudflare 403 Forbidden on GitHub Runner for Doom artifact download
74+
wget --header="User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0" \
75+
--header="Referer: https://www.doomworld.com/" \
76+
--header="Accept-Language: en-US,en;q=0.9" \
77+
-O build/shareware_doom_iwad.zip \
78+
"https://www.doomworld.com/3ddownloads/ports/shareware_doom_iwad.zip"
79+
unzip -d build/ build/shareware_doom_iwad.zip
80+
if: ${{ always() }}
81+
- name: default build using emcc
82+
run: |
83+
make CC=emcc -j$(nproc)
84+
if: ${{ always() }}
85+
- name: default build for system emulation using emcc
86+
run: |
87+
make distclean
88+
make CC=emcc ENABLE_SYSTEM=1 -j$(nproc)
89+
make distclean ENABLE_SYSTEM=1
6890
if: ${{ always() }}
6991
- name: default build with -g
7092
env:

mk/system.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ $(BUILD_DTB): $(DEV_SRC)/minimal.dts
1212
$(VECHO) " DTC\t$@\n"
1313
$(Q)$(CC) -nostdinc -E -P -x assembler-with-cpp -undef $(CFLAGS_dt) $^ | $(DTC) - > $@
1414

15+
# Assume the system has either GCC or Clang
16+
NATIVE_CC := $(shell which gcc || which clang)
17+
1518
BIN_TO_C := $(OUT)/bin2c
1619
$(BIN_TO_C): tools/bin2c.c
20+
# emcc generates wasm but not executable, so fallback to use GCC or Clang
21+
ifeq ("$(CC_IS_EMCC)", "1")
22+
$(Q)$(NATIVE_CC) -Wall -o $@ $^
23+
else
1724
$(Q)$(CC) -Wall -o $@ $^
25+
endif
1826

1927
BUILD_DTB2C := src/minimal_dtb.h
2028
$(BUILD_DTB2C): $(BIN_TO_C) $(BUILD_DTB)

mk/toolchain.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ else ifneq ($(shell $(CC) --version | grep "Free Software Foundation"),)
5252
CC_IS_GCC := 1
5353
endif
5454

55+
ifeq ("$(CC_IS_CLANG)$(CC_IS_GCC)$(CC_IS_EMCC)", "")
56+
$(error "Only supported GCC/Clang/Emcc")
57+
endif
58+
5559
CFLAGS_NO_CET :=
5660
processor := $(shell uname -m)
5761
ifeq ($(processor),$(filter $(processor),i386 x86_64))

0 commit comments

Comments
 (0)