commit emscripten not wokring

main
Brett 2023-12-16 03:19:27 -05:00
parent 4d14ac2794
commit a101d47458
6 changed files with 100 additions and 11 deletions

View File

@ -12,12 +12,21 @@ option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
option(BUILD_GRAPHICS_TESTS "Build the BLT Graphics test set" OFF)
set(CMAKE_CXX_STANDARD 17)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
if (EMSCRIPTEN)
message("Using emscriptem linker and compile flags!")
#add_definitions("-std=c++17")
set(CMAKE_VERBOSE_MAKEFILE on)
else ()
message("Not using emscripten! (linking GLFW)")
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(libraries/glfw-3.3.8)
endif ()
add_subdirectory(libraries/BLT)
add_subdirectory(libraries/glfw-3.3.8)
list(APPEND IMGUI_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/libraries/imgui/imgui.cpp")
list(APPEND IMGUI_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/libraries/imgui/imgui_demo.cpp")
@ -35,11 +44,27 @@ file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
add_library(BLT_WITH_GRAPHICS ${PROJECT_BUILD_FILES} ${IMGUI_SOURCE_FILES})
target_link_libraries(BLT_WITH_GRAPHICS PUBLIC glfw)
if (EMSCRIPTEN)
#set_target_properties(FinalProject PROPERTIES LINK_FLAGS "-s DEMANGLE_SUPPORT=1 --preload-file ${CMAKE_SOURCE_DIR}/assets --bind")
#set_target_properties(FinalProject PROPERTIES LINK_FLAGS "-s DEMANGLE_SUPPORT=1 --preload-file 'assets' --bind")
#set_target_properties(FinalProject PROPERTIES LINK_FLAGS "-sMAX_WEBGL_VERSION=2 -sASSERTIONS=1 -pthread -sPTHREAD_POOL_SIZE=8 -s INITIAL_MEMORY=134217728 -sUSE_GLFW=3 --preload-file 'assets'")
set_target_properties(BLT_WITH_GRAPHICS PROPERTIES LINK_FLAGS "-sMAX_WEBGL_VERSION=2 -sASSERTIONS=1 -pthread -sPTHREAD_POOL_SIZE=8 -s INITIAL_MEMORY=134217728 -sUSE_GLFW=3")
# these flags will be set by cmake automatically based on build type
#set_target_properties(FinalProject PROPERTIES COMPILE_FLAGS "-O3")
set_target_properties(BLT_WITH_GRAPHICS PROPERTIES COMPILE_FLAGS "-pthread")
target_compile_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing)
target_link_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Wpedantic -Wno-comment -Wno-strict-aliasing)
else ()
target_link_libraries(BLT_WITH_GRAPHICS PUBLIC glfw)
target_compile_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing)
target_link_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing)
endif ()
target_link_libraries(BLT_WITH_GRAPHICS PUBLIC BLT)
target_compile_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing)
target_link_options(BLT_WITH_GRAPHICS PRIVATE -Wall -Werror -Wpedantic -Wno-comment -Wno-strict-aliasing)
if (${ENABLE_ADDRSAN} MATCHES ON)
target_compile_options(BLT_WITH_GRAPHICS PRIVATE -fsanitize=address)
@ -56,7 +81,7 @@ if (${ENABLE_TSAN} MATCHES ON)
target_link_options(BLT_WITH_GRAPHICS PRIVATE -fsanitize=thread)
endif ()
if(${BUILD_GRAPHICS_TESTS})
if (${BUILD_GRAPHICS_TESTS})
message("Building graphics test")
project(BLT_GRAPHICS_TESTS VERSION ${BLT_GRAPHICS_TEST_VERSION})
@ -88,6 +113,6 @@ if(${BUILD_GRAPHICS_TESTS})
target_link_options(BLT_GRAPHICS_TESTS PRIVATE -fsanitize=thread)
endif ()
message("Built graphics tests")
endif()
endif ()
project(BLT)

12
build_emscript.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/bash
#mkdir cmake-build-emrelease
rm -fr cmake-build-emrelease
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_GRAPHICS_TESTS:BOOL=ON -S ./ -B ./cmake-build-emrelease
cd cmake-build-emrelease
emmake make -j 32
cp BLT_GRAPHICS_TESTS.js /var/www/html/emscript/
cp BLT_GRAPHICS_TESTS.data /var/www/html/emscript/
cp BLT_GRAPHICS_TESTS.wasm /var/www/html/emscript/
cp BLT_GRAPHICS_TESTS.worker.js /var/www/html/emscript/

@ -1 +1 @@
Subproject commit bda044de1eda8a556c5174461227ae12c8c891d3
Subproject commit bc8134e3a2c69877ff008d84e81df3e06729d679

View File

@ -217,18 +217,31 @@ namespace blt::gfx
bool isCursorInWindow()
{
#ifdef __EMSCRIPTEN__
// TODO:
return true;
#else
return glfwGetWindowAttrib(window_state.window, GLFW_HOVERED);
#endif
}
void setRawInput(bool state)
{
#ifdef __EMSCRIPTEN__
// TODO?
#else
if (glfwRawMouseMotionSupported())
glfwSetInputMode(window_state.window, GLFW_RAW_MOUSE_MOTION, state ? GLFW_TRUE : GLFW_FALSE);
#endif
}
bool isRawInput()
{
#ifdef __EMSCRIPTEN__
return false;
#else
return glfwGetInputMode(window_state.window, GLFW_RAW_MOUSE_MOTION);
#endif
}
void setClipboard(const std::string& str)

39
test.txt Normal file
View File

@ -0,0 +1,39 @@
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease
/usr/bin/cmake -S/home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template -B/home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/CMakeFiles /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease'
make -f libraries/BLT/CMakeFiles/BLT.dir/build.make libraries/BLT/CMakeFiles/BLT.dir/depend
make[2]: Entering directory '/home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease'
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT/CMakeFiles/BLT.dir/DependInfo.cmake "--color="
make[2]: Leaving directory '/home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease'
make -f libraries/BLT/CMakeFiles/BLT.dir/build.make libraries/BLT/CMakeFiles/BLT.dir/build
make[2]: Entering directory '/home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease'
[ 12%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/filesystem.cpp.o
[ 12%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o
[ 12%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/format.cpp.o
[ 16%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o
[ 20%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o
[ 24%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/profiling/profiler.cpp.o
[ 48%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/nbt/nbt.cpp.o
[ 48%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/profiling/profiler_v2.cpp.o
[ 48%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/system.cpp.o
[ 48%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/nbt/nbt_block.cpp.o
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/filesystem.cpp.o -MF CMakeFiles/BLT.dir/src/blt/std/filesystem.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/std/filesystem.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/std/filesystem.cpp
[ 48%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o -MF CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/std/assert.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/std/assert.cpp
[ 48%] Building CXX object libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/logging.cpp.o
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/format.cpp.o -MF CMakeFiles/BLT.dir/src/blt/std/format.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/std/format.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/std/format.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o -MF CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/std/loader.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/std/loader.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/string.cpp.o -MF CMakeFiles/BLT.dir/src/blt/std/string.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/std/string.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/std/string.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/profiling/profiler.cpp.o -MF CMakeFiles/BLT.dir/src/blt/profiling/profiler.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/profiling/profiler.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/profiling/profiler.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/nbt/nbt.cpp.o -MF CMakeFiles/BLT.dir/src/blt/nbt/nbt.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/nbt/nbt.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/nbt/nbt.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/system.cpp.o -MF CMakeFiles/BLT.dir/src/blt/std/system.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/std/system.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/std/system.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/std/logging.cpp.o -MF CMakeFiles/BLT.dir/src/blt/std/logging.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/std/logging.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/std/logging.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/profiling/profiler_v2.cpp.o -MF CMakeFiles/BLT.dir/src/blt/profiling/profiler_v2.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/profiling/profiler_v2.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/profiling/profiler_v2.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/nbt/nbt_block.cpp.o -MF CMakeFiles/BLT.dir/src/blt/nbt/nbt_block.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/nbt/nbt_block.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/nbt/nbt_block.cpp
cd /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease/libraries/BLT && /home/brett/Documents/github/emsdk/upstream/emscripten/em++ @CMakeFiles/BLT.dir/includes_CXX.rsp -DNDEBUG -O2 -std=gnu++17 -Wall -Wextra -Wpedantic -MD -MT libraries/BLT/CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o -MF CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o.d -o CMakeFiles/BLT.dir/src/blt/parse/argparse.cpp.o -c /home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/libraries/BLT/src/blt/parse/argparse.cpp
make[2]: Leaving directory '/home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease'
make[1]: Leaving directory '/home/brett/Documents/code/c++/Libraries/BLT-With-Graphics-Template/cmake-build-emrelease'

View File

@ -10,7 +10,7 @@ void init()
void update(std::int32_t width, std::int32_t height)
{
ImGui::ShowDemoWindow();
}
int main()