1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 gb_UnoApiHeadersTarget_select_variant
= $(if
$(filter udkapi
,$(1)),comprehensive
,$(2))
12 include $(GBUILDDIR
)/platform
/unxgcc.mk
14 # don't sort; later can override previous settings!
15 gb_EMSCRIPTEN_PRE_JS_FILES
= \
16 $(SRCDIR
)/static
/emscripten
/environment.js \
17 $(call gb_CustomTarget_get_workdir
,static
/emscripten_fs_image
)/soffice.data.js.link \
19 gb_RUN_CONFIGURE
:= $(SRCDIR
)/solenv
/bin
/run-configure
20 # avoid -s SAFE_HEAP=1 - c.f. gh#8584 this breaks source maps
21 gb_EMSCRIPTEN_CPPFLAGS
:= -pthread
-s USE_PTHREADS
=1 -D_LARGEFILE64_SOURCE
-D_LARGEFILE_SOURCE
22 gb_EMSCRIPTEN_LDFLAGS
:= $(gb_EMSCRIPTEN_CPPFLAGS
)
24 # Initial memory size and worker thread pool
25 gb_EMSCRIPTEN_LDFLAGS
+= -s TOTAL_MEMORY
=1GB
-s PTHREAD_POOL_SIZE
=4
27 # To keep the link time (and memory) down, prevent all rewriting options from wasm-emscripten-finalize
28 # See emscripten.py, finalize_wasm, modify_wasm = True
29 # So we need WASM_BIGINT=1 and ASSERTIONS=1 (2 implies STACK_OVERFLOW_CHECK)
30 gb_EMSCRIPTEN_LDFLAGS
+= --bind
-s FORCE_FILESYSTEM
=1 -s WASM_BIGINT
=1 -s ERROR_ON_UNDEFINED_SYMBOLS
=1 -s FETCH
=1 -s ASSERTIONS
=1 -s EXIT_RUNTIME
=0 -s EXPORTED_RUNTIME_METHODS
=["UTF16ToString","stringToUTF16","UTF8ToString","allocateUTF8","printErr","ccall","cwrap"]
31 gb_EMSCRIPTEN_QTDEFS
:= -DQT_NO_LINKED_LIST
-DQT_NO_JAVA_STYLE_ITERATORS
-DQT_NO_EXCEPTIONS
-DQT_NO_DEBUG
-DQT_WIDGETS_LIB
-DQT_GUI_LIB
-DQT_CORE_LIB
33 gb_Executable_EXT
:= .html
34 ifeq ($(ENABLE_WASM_EXCEPTIONS
),TRUE
)
35 # Note that to really use WASM exceptions everywhere, you most probably want to also use
36 # CC=emcc -pthread -s USE_PTHREADS=1 -fwasm-exceptions -s SUPPORT_LONGJMP=wasm
37 # and CXX=em++ -pthread -s USE_PTHREADS=1 -fwasm-exceptions -s SUPPORT_LONGJMP=wasm
38 # in your autogen.input. Otherwise these flags won't propagate to all external libraries, I fear.
39 gb_EMSCRIPTEN_EXCEPT
= -fwasm-exceptions
-s SUPPORT_LONGJMP
=wasm
40 gb_EMSCRIPTEN_CPPFLAGS
+= -s SUPPORT_LONGJMP
=wasm
42 gb_EMSCRIPTEN_EXCEPT
= -s DISABLE_EXCEPTION_CATCHING
=0
45 gb_CXXFLAGS
+= $(gb_EMSCRIPTEN_CPPFLAGS
)
47 ifeq ($(ENABLE_WASM_EXCEPTIONS
),TRUE
)
48 # Here we don't use += because gb_LinkTarget_EXCEPTIONFLAGS from com_GCC_defs.mk contains -fexceptions and
49 # gb_EMSCRIPTEN_EXCEPT already has -fwasm-exceptions
50 gb_LinkTarget_EXCEPTIONFLAGS
= $(gb_EMSCRIPTEN_EXCEPT
)
52 gb_LinkTarget_EXCEPTIONFLAGS
+= $(gb_EMSCRIPTEN_EXCEPT
)
55 gb_LinkTarget_CFLAGS
+= $(gb_EMSCRIPTEN_CPPFLAGS
)
56 gb_LinkTarget_CXXFLAGS
+= $(gb_EMSCRIPTEN_CPPFLAGS
) $(gb_EMSCRIPTEN_EXCEPT
)
57 ifeq ($(ENABLE_QT5
),TRUE
)
58 gb_LinkTarget_CFLAGS
+= $(gb_EMSCRIPTEN_QTDEFS
)
59 gb_LinkTarget_CXXFLAGS
+= $(gb_EMSCRIPTEN_QTDEFS
)
61 gb_LinkTarget_LDFLAGS
+= $(gb_EMSCRIPTEN_LDFLAGS
) $(gb_EMSCRIPTEN_CPPFLAGS
) $(gb_EMSCRIPTEN_EXCEPT
)
63 # Linker and compiler optimize + debug flags are handled in LinkTarget.mk
65 gb_LINKERSTRIPDEBUGFLAGS
:=
66 # This maps to g3, no source maps, but DWARF with current emscripten!
67 # https://developer.chrome.com/blog/wasm-debugging-2020/
68 gb_DEBUGINFO_FLAGS
= -g
70 ifeq ($(HAVE_EXTERNAL_DWARF
),TRUE
)
71 gb_DEBUGINFO_FLAGS
+= -gseparate-dwarf
74 gb_COMPILEROPTFLAGS
:= -O3
76 # We need at least code elimination, otherwise linking OOMs even with 64GB.
77 # So we "fake" -Og support to mean -O1 for Emscripten and always enable it for debug in configure.
78 gb_COMPILERDEBUGOPTFLAGS
:= -O1
79 gb_COMPILERNOOPTFLAGS
:= -O1
-fstrict-aliasing
-fstrict-overflow
81 # cleanup addition JS and wasm files for binaries
82 define gb_Executable_Executable_platform
83 $(call gb_LinkTarget_add_auxtargets
,$(2),\
84 $(patsubst %.lib
,%.linkdeps
,$(3)) \
85 $(patsubst %.lib
,%.wasm
,$(3)) \
86 $(patsubst %.lib
,%.js
,$(3)) \
87 $(patsubst %.lib
,%.worker.js
,$(3)) \
90 $(foreach pre_js
,$(gb_EMSCRIPTEN_PRE_JS_FILES
),$(call gb_Executable_add_prejs
,$(1),$(pre_js
)))
94 define gb_CppunitTest_CppunitTest_platform
95 $(call gb_LinkTarget_add_auxtargets
,$(2),\
96 $(patsubst %.lib
,%.linkdeps
,$(3)) \
97 $(patsubst %.lib
,%.wasm
,$(3)) \
98 $(patsubst %.lib
,%.js
,$(3)) \
99 $(patsubst %.lib
,%.worker.js
,$(3)) \
102 $(foreach pre_js
,$(gb_EMSCRIPTEN_PRE_JS_FILES
),$(call gb_CppunitTest_add_prejs
,$(1),$(pre_js
)))
106 gb_SUPPRESS_TESTS
:= $(true
)
108 define gb_Library_get_rpath
111 define gb_Executable_get_rpath
114 # vim: set noet sw=4 ts=4