Skip to content

Commit 99ca093

Browse files
authored
Merge pull request #33 from gilzoide/bugfix/unity-6-web
Fix Unity 6 Web builds by disabling C++ exceptions
2 parents 432d872 + 1e7d77e commit 99ca093

File tree

5 files changed

+34
-24
lines changed

5 files changed

+34
-24
lines changed

Plugins/Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ build/android/x86/libflex-ui.so: CXX = $(wildcard $(ANDROID_NDK_ROOT)/toolchains
8080
build/android/x86/libflex-ui.so: check-ndk-root
8181

8282
# WebGL
83+
build/webgl/libflex-ui.a: CXXFLAGS += -fno-exceptions
8384
build/webgl/libflex-ui.a: CXX = $(EMCXX)
8485
build/webgl/libflex-ui.a: AR = $(EMAR)
8586

@@ -125,5 +126,5 @@ docker-all-windows:
125126
docker build -f src~/Dockerfile.build.windows -t gilzoide-flex-ui-build-windows:latest src~
126127
docker run --rm -v "$(CURDIR)":/src -w /src gilzoide-flex-ui-build-windows:latest make all-windows-mingw
127128
docker-all-webgl:
128-
docker build -f src~/Dockerfile.build.webgl -t gilzoide-flex-ui-build-webgl:latest src~
129-
docker run --rm -v "$(CURDIR)":/src -w /src gilzoide-flex-ui-build-webgl:latest make all-webgl
129+
docker build -f src~/Dockerfile.build.webgl --platform=linux/amd64 -t gilzoide-flex-ui-build-webgl:latest src~
130+
docker run --rm -v "$(CURDIR)":/src -w /src --platform=linux/amd64 gilzoide-flex-ui-build-webgl:latest make all-webgl

Plugins/build/webgl/libflex-ui.a

-4.72 KB
Binary file not shown.

Plugins/flex-ui-amalgamated.cpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -9468,7 +9468,14 @@ void Event::publish(
94689468
///////////////////////////////////////////////////////////
94699469
#define EXPORT __attribute__((visibility("default")))
94709470

9471+
#ifdef __cpp_exceptions
94719472
#include <stdexcept>
9473+
#define TRY(body) try body
9474+
#define CATCH(exception, body) catch(exception) body
9475+
#else
9476+
#define TRY(body) body
9477+
#define CATCH(exception, body)
9478+
#endif
94729479

94739480
extern "C" {
94749481

@@ -9510,13 +9517,13 @@ EXPORT void FlexUi_NodeCalculateLayout(_YGNodeRef node, float availableWidth, fl
95109517
}
95119518

95129519
EXPORT const char *FlexUi_NodeInsertChild(_YGNodeRef node, _YGNodeRef child, int index) {
9513-
try {
9520+
TRY({
95149521
_YGNodeInsertChild(node, child, index);
95159522
return NULL;
9516-
}
9517-
catch (std::logic_error err) {
9523+
})
9524+
CATCH(std::logic_error err, {
95189525
return strdup(err.what());
9519-
}
9526+
})
95209527
}
95219528

95229529
EXPORT void FlexUi_NodeRemoveChild(_YGNodeRef node, _YGNodeRef child) {
@@ -9532,13 +9539,13 @@ EXPORT int FlexUi_NodeGetChildCount(_YGNodeConstRef node) {
95329539
}
95339540

95349541
EXPORT const char *FlexUi_NodeSetConfig(_YGNodeRef node, _YGConfigRef config) {
9535-
try {
9542+
TRY({
95369543
_YGNodeSetConfig(node, config);
95379544
return NULL;
9538-
}
9539-
catch (std::logic_error err) {
9545+
})
9546+
CATCH(std::logic_error err, {
95409547
return strdup(err.what());
9541-
}
9548+
})
95429549
}
95439550

95449551
EXPORT void FlexUi_NodeSetContext(_YGNodeRef node, void* context) {

Plugins/src~/Dockerfile.build.webgl

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
# syntax=docker/dockerfile:1
2-
FROM debian:12-slim
3-
4-
RUN apt-get -qq update \
5-
&& apt-get -qq install -y --no-install-recommends \
6-
emscripten \
7-
make
2+
FROM emscripten/emsdk:3.1.8

Plugins/src~/flex-ui.cpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@
3636
///////////////////////////////////////////////////////////
3737
#define EXPORT __attribute__((visibility("default")))
3838

39+
#ifdef __cpp_exceptions
3940
#include <stdexcept>
41+
#define TRY(body) try body
42+
#define CATCH(exception, body) catch(exception) body
43+
#else
44+
#define TRY(body) body
45+
#define CATCH(exception, body)
46+
#endif
4047

4148
extern "C" {
4249

@@ -78,13 +85,13 @@ EXPORT void FlexUi_NodeCalculateLayout(YGNodeRef node, float availableWidth, flo
7885
}
7986

8087
EXPORT const char *FlexUi_NodeInsertChild(YGNodeRef node, YGNodeRef child, int index) {
81-
try {
88+
TRY({
8289
YGNodeInsertChild(node, child, index);
8390
return NULL;
84-
}
85-
catch (std::logic_error err) {
91+
})
92+
CATCH(std::logic_error err, {
8693
return strdup(err.what());
87-
}
94+
})
8895
}
8996

9097
EXPORT void FlexUi_NodeRemoveChild(YGNodeRef node, YGNodeRef child) {
@@ -100,13 +107,13 @@ EXPORT int FlexUi_NodeGetChildCount(YGNodeConstRef node) {
100107
}
101108

102109
EXPORT const char *FlexUi_NodeSetConfig(YGNodeRef node, YGConfigRef config) {
103-
try {
110+
TRY({
104111
YGNodeSetConfig(node, config);
105112
return NULL;
106-
}
107-
catch (std::logic_error err) {
113+
})
114+
CATCH(std::logic_error err, {
108115
return strdup(err.what());
109-
}
116+
})
110117
}
111118

112119
EXPORT void FlexUi_NodeSetContext(YGNodeRef node, void* context) {

0 commit comments

Comments
 (0)