Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit d29254b

Browse files
committed
[emscripten] gyp: Add Emscripten target to build system.
1 parent 5f4031c commit d29254b

File tree

11 files changed

+180
-6
lines changed

11 files changed

+180
-6
lines changed

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Tools that Make calls
2222
XCODEBUILD ?= xcodebuild
2323
WINE ?= wine
24+
EMMAKE ?= emmake
2425

2526
# Some magic to control which versions of iOS we try to build. N.b. you may
2627
# also need to modify the buildbot configuration
@@ -166,3 +167,16 @@ all-win-%:
166167

167168
$(addsuffix -win,all config compile): %: %-x86
168169

170+
################################################################
171+
# Emscripten rules
172+
################################################################
173+
174+
config-emscripten:
175+
$(EMMAKE) ./config.sh --platform emscripten
176+
177+
compile-emscripten:
178+
$(EMMAKE) $(MAKE) -C build-emscripten/livecode
179+
180+
all-emscripten:
181+
$(MAKE) config-emscripten
182+
$(MAKE) compile-emscripten

config.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ The currently-supported PLATFORMs are:
5757
linux-x86_64
5858
android-armv6
5959
win-x86
60+
emscripten
6061
6162
EOF
6263
exit $1
@@ -176,6 +177,7 @@ case ${PLATFORM} in
176177
mac) ;;
177178
ios) ;;
178179
win-x86) ;;
180+
emscripten) ;;
179181
*)
180182
echo "ERROR: Unrecognised platform: '${PLATFORM}'" >&2
181183
exit 1;;
@@ -198,6 +200,7 @@ if test -z "$OS"; then
198200
mac*) OS="mac" ;;
199201
ios*) OS="ios" ;;
200202
win*) OS="win" ;;
203+
emscripten*) OS="emscripten" ;;
201204
esac
202205
fi
203206

@@ -206,7 +209,7 @@ if test -z "$FORMATS"; then
206209
case ${OS} in
207210
# Always use Linux-style makefiles for Android as the Android toolchain
208211
# is more Linux-y than Darwin-y
209-
linux|android) FORMATS="make-linux" ;;
212+
linux|android|emscripten) FORMATS="make-linux" ;;
210213
mac|ios) FORMATS="xcode" ;;
211214
win) FORMATS="msvs" ;;
212215
esac
@@ -244,6 +247,7 @@ if test -z "$TARGET_ARCH"; then
244247
*-x86) TARGET_ARCH="x86" ;;
245248
*-x86_64) TARGET_ARCH="x86_64" ;;
246249
*-armv6) TARGET_ARCH="armv6" ;;
250+
emscripten) TARGET_ARCH="js" ;;
247251

248252
mac*|ios*)
249253
case ${XCODE_TARGET_SDK} in
@@ -358,7 +362,7 @@ if [ "${BUILD_EDITION}" == "commercial" ] ; then
358362
fi
359363

360364
case ${OS} in
361-
linux)
365+
linux|emscripten)
362366
invoke_gyp $basic_args "-DOS=${OS}" "-Dtarget_arch=${TARGET_ARCH}" "$@"
363367
;;
364368
android)

config/arch.gypi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@
5757
'host_os': 'linux',
5858
},
5959
],
60+
[
61+
'OS == "emscripten"',
62+
{
63+
'target_arch': 'js',
64+
},
65+
],
6066
],
6167
},
6268

config/crosscompile.gypi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
'cross_compile': 1,
2727
},
2828
],
29+
[
30+
# Emscripten builds are always cross-compiled
31+
'OS == "emscripten"',
32+
{
33+
'cross_compile': 1,
34+
}
35+
],
2936
[
3037
# Linux may or may not be cross-compiled
3138
'OS == "linux"',

config/emscripten.gypi

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
'variables':
3+
{
4+
'mobile': 1,
5+
'output_dir': '../emscripten-js-bin',
6+
},
7+
8+
'target_defaults':
9+
{
10+
'variables':
11+
{
12+
'app_bundle_suffix': '',
13+
'ext_bundle_suffix': '.so',
14+
'lib_suffix': '.so',
15+
'ext_suffix': '.so',
16+
'exe_suffix': '.js',
17+
'debug_info_suffix': '.dbg',
18+
19+
'c++_std': 'gnu++03',
20+
},
21+
22+
'defines':
23+
[
24+
'__GNU__',
25+
],
26+
27+
'cflags_cc':
28+
[
29+
'-fno-exceptions',
30+
'-fno-rtti',
31+
],
32+
33+
'cflags_c':
34+
[
35+
'-std=gnu99',
36+
'-Wstrict-prototypes',
37+
],
38+
39+
'cflags':
40+
[
41+
'-Wall',
42+
'-Wextra',
43+
],
44+
45+
'ar_flags':
46+
[
47+
# llvm-ar doesn't understand "T" (i.e. "thin archive")
48+
'crs',
49+
],
50+
51+
'target_conditions':
52+
[
53+
[
54+
'_toolset == "target"',
55+
{
56+
'cflags':
57+
[
58+
'-O2',
59+
'-s ASSERTIONS=1',
60+
'-s DEMANGLE_SUPPORT=1',
61+
'-s EMTERPRETIFY=1',
62+
'-s EMTERPRETIFY_ASYNC=1',
63+
'-s WARN_ON_UNDEFINED_SYMBOLS=1',
64+
'-s ALLOW_MEMORY_GROWTH=1',
65+
],
66+
},
67+
],
68+
],
69+
70+
'configurations':
71+
{
72+
'Debug':
73+
{
74+
'cflags':
75+
[
76+
'-g3',
77+
],
78+
79+
'defines':
80+
[
81+
'_DEBUG',
82+
],
83+
},
84+
85+
'Release':
86+
{
87+
'cflags':
88+
[
89+
'-O3',
90+
'-g3',
91+
],
92+
93+
'defines':
94+
[
95+
'_RELEASE',
96+
'NDEBUG',
97+
],
98+
},
99+
100+
'Fast':
101+
{
102+
'cflags':
103+
[
104+
'-O0',
105+
'-g0',
106+
],
107+
108+
'defines':
109+
[
110+
'_RELEASE',
111+
'NDEBUG',
112+
],
113+
},
114+
},
115+
},
116+
}

config/paths.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'conditions':
55
[
66
[
7-
'OS == "linux" or OS == "android"',
7+
'OS == "linux" or OS == "android" or OS == "emscripten"',
88
{
99
'src_top_dir_abs': '$(abs_srcdir)',
1010
},

config/target_os.gypi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,14 @@
5151
],
5252
},
5353
],
54+
[
55+
'OS == "emscripten"',
56+
{
57+
'includes':
58+
[
59+
'emscripten.gypi',
60+
],
61+
},
62+
],
5463
],
5564
}

engine/engine-sources.gypi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,15 @@
887887
],
888888
},
889889
],
890+
[
891+
'OS != "emscripten"',
892+
{
893+
'sources/':
894+
[
895+
['exclude', '(^|/)em-.*\\.cpp$'],
896+
],
897+
},
898+
],
890899
[
891900
'OS == "win"',
892901
{
@@ -990,6 +999,15 @@
990999
],
9911000
},
9921001
],
1002+
[
1003+
'OS == "emscripten"',
1004+
{
1005+
'sources!':
1006+
[
1007+
'src/mcssl.cpp',
1008+
],
1009+
},
1010+
],
9931011
[
9941012
'mobile != 0',
9951013
{

engine/kernel-mode-template.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[
1212
[
1313
# Only the Linux and Android builds support proper cross-compilation
14-
'OS == "linux" or OS == "android"',
14+
'OS == "linux" or OS == "android" or OS == "emscripten"',
1515
{
1616
'dependencies':
1717
[

util/perfect/perfect.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'conditions':
1414
[
1515
[
16-
'OS == "linux" or OS == "android"',
16+
'OS == "linux" or OS == "android" or OS == "emscripten"',
1717
{
1818
'toolsets': ['host'],
1919
},

0 commit comments

Comments
 (0)