Emscripten support.

Doesn't work due to i64 vs i32 type mismatch in glGetIntegerv, which
seems like some general compatibility bullshit, not something related
to CMake.
This commit is contained in:
Bartosz Taudul 2024-03-20 22:25:24 +01:00
parent 8ee866e840
commit 434d73c7bd
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
9 changed files with 23 additions and 61 deletions

View File

@ -25,6 +25,6 @@ if(WIN32)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
endif() endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT EMSCRIPTEN)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif() endif()

View File

@ -33,7 +33,7 @@ if(NO_STATISTICS)
target_compile_definitions(TracyServer PUBLIC TRACY_NO_STATISTICS) target_compile_definitions(TracyServer PUBLIC TRACY_NO_STATISTICS)
endif() endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
target_link_libraries(TracyServer PRIVATE TracyTbb) target_link_libraries(TracyServer PRIVATE TracyTbb)
endif() endif()

View File

@ -33,7 +33,7 @@ endif()
# GLFW # GLFW
if(NOT USE_WAYLAND) if(NOT USE_WAYLAND AND NOT EMSCRIPTEN)
pkg_check_modules(GLFW glfw3) pkg_check_modules(GLFW glfw3)
if (GLFW_FOUND AND NOT DOWNLOAD_GLFW) if (GLFW_FOUND AND NOT DOWNLOAD_GLFW)
add_library(TracyGlfw3 INTERFACE) add_library(TracyGlfw3 INTERFACE)
@ -161,13 +161,9 @@ add_library(TracyImGui STATIC ${IMGUI_SOURCES})
target_include_directories(TracyImGui PUBLIC ${IMGUI_DIR}) target_include_directories(TracyImGui PUBLIC ${IMGUI_DIR})
target_link_libraries(TracyImGui PUBLIC TracyFreetype) target_link_libraries(TracyImGui PUBLIC TracyFreetype)
if (NOT USE_WAYLAND)
target_link_libraries(TracyImGui PUBLIC TracyGlfw3)
endif()
# NFD # NFD
if (NOT NO_FILESELECTOR) if (NOT NO_FILESELECTOR AND NOT EMSCRIPTEN)
set(NFD_DIR "${ROOT_DIR}/nfd") set(NFD_DIR "${ROOT_DIR}/nfd")
if (WIN32) if (WIN32)
@ -215,7 +211,7 @@ endif()
# TBB # TBB
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
# Tracy does not use TBB directly, but the implementation of parallel algorithms # Tracy does not use TBB directly, but the implementation of parallel algorithms
# in some versions of libstdc++ depends on TBB. When it does, you must # in some versions of libstdc++ depends on TBB. When it does, you must
# explicitly link against -ltbb. # explicitly link against -ltbb.

View File

@ -141,4 +141,20 @@ else()
add_executable(${PROJECT_NAME} ${PROFILER_FILES} ${COMMON_FILES} ${SERVER_FILES}) add_executable(${PROJECT_NAME} ${PROFILER_FILES} ${COMMON_FILES} ${SERVER_FILES})
endif() endif()
target_link_libraries(${PROJECT_NAME} PRIVATE TracyServer TracyImGui TracyNfd) target_link_libraries(${PROJECT_NAME} PRIVATE TracyServer TracyImGui)
if(NOT EMSCRIPTEN)
target_link_libraries(${PROJECT_NAME} PRIVATE TracyNfd)
if (NOT USE_WAYLAND)
target_link_libraries(${PROJECT_NAME} PRIVATE TracyGlfw3)
endif()
endif()
if(EMSCRIPTEN)
set_property(TARGET ${PROJECT_NAME} PROPERTY COMPILE_FLAGS "-sUSE_FREETYPE=1 -pthread -DIMGUI_IMPL_OPENGL_ES2")
set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_FLAGS "-sASSERTIONS=0 -sUSE_GLFW=3 -sINITIAL_MEMORY=384mb -sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=4gb -sWASM_BIGINT=1 -sPTHREAD_POOL_SIZE=4 -sEXPORTED_FUNCTIONS=_main,_nativeResize,_nativeOpenFile -sEXPORTED_RUNTIME_METHODS=ccall -sENVIRONMENT=web,worker --preload-file embed.tracy")
file(DOWNLOAD https://share.nereid.pl/i/embed.tracy ${CMAKE_CURRENT_BINARY_DIR}/embed.tracy EXPECTED_MD5 ca0fa4f01e7b8ca5581daa16b16c768d)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/wasm/index.html DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/wasm/httpd.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()

View File

@ -1,20 +0,0 @@
all: release
embed.tracy:
wget https://share.nereid.pl/i/embed.tracy
debug: embed.tracy
@$(MAKE) -f debug.mk all TRACY_NO_ISA_EXTENSIONS=1
release: embed.tracy
@$(MAKE) -f release.mk all TRACY_NO_ISA_EXTENSIONS=1
clean:
@$(MAKE) -f build.mk clean
rm -rf Tracy-release.*
rm -rf Tracy-debug.*
serve:
@python httpd.py
.PHONY: all clean debug release serve

View File

@ -1,16 +0,0 @@
CC=emcc
CXX=em++
CFLAGS += -sUSE_FREETYPE=1 -pthread
CXXFLAGS := $(CFLAGS) -std=c++17
DEFINES += -DIMGUI_ENABLE_FREETYPE -DIMGUI_IMPL_OPENGL_ES2
INCLUDES := -I../../../imgui -I$(HOME)/.emscripten_cache/sysroot/include/capstone
LIBS += -lpthread -ldl $(HOME)/.emscripten_cache/sysroot/lib/libcapstone.a -sUSE_GLFW=3 -sINITIAL_MEMORY=384mb -sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=4gb -sWASM_BIGINT=1 -sPTHREAD_POOL_SIZE=4 -sEXPORTED_FUNCTIONS=_main,_nativeResize,_nativeOpenFile -sEXPORTED_RUNTIME_METHODS=ccall -sENVIRONMENT=web,worker --preload-file embed.tracy
PROJECT := Tracy
IMAGE := $(PROJECT)-$(BUILD).html
NO_TBB := 1
FILTER := ../../../nfd/nfd_win.cpp
include ../../../common/src-from-vcxproj.mk
include ../../../common/unix.mk

View File

@ -1,7 +0,0 @@
CFLAGS := -g3 -gsource-map -Wall
DEFINES := -DDEBUG
BUILD := debug
LIBS := -sDEMANGLE_SUPPORT=1
include ../../../common/unix-debug.mk
include build.mk

View File

@ -161,6 +161,6 @@
addEventListener('resize', resizeHandler); addEventListener('resize', resizeHandler);
resizeHandler(); resizeHandler();
</script> </script>
<script async type="text/javascript" src="Tracy-release.js"></script> <script async type="text/javascript" src="tracy-profiler.js"></script>
</body> </body>
</html> </html>

View File

@ -1,7 +0,0 @@
CFLAGS := -Os
DEFINES := -DNDEBUG
BUILD := release
LIBS := -sASSERTIONS=0
include ../../../common/unix-release.mk
include build.mk