Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the CMake_WASM example work again #470

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples_for_PC/CMake_WASM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)
project (lv_wasm)

add_definitions(-DLGFX_SDL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -s USE_SDL=2")
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -g -s USE_SDL=2")

include_directories(../../../LovyanGFX/src/)

Expand Down
9 changes: 4 additions & 5 deletions examples_for_PC/CMake_WASM/LGFX_WASM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
void setup(void);
void loop(void);

void loopThread(void *arg)
void loopThread(void)
{
lgfx::Panel_sdl::loop();
loop();
lgfx::Panel_sdl::sdl_event_handler();
}

int monitor_hor_res, monitor_ver_res;

int main(int argc, char **argv)
{
setup();
emscripten_set_main_loop_arg(loopThread, NULL, -1, true);
lgfx::Panel_sdl::setup();
emscripten_set_main_loop(loopThread, -1, true);
}
15 changes: 15 additions & 0 deletions examples_for_PC/CMake_WASM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,19 @@
2. `cd build`
3. `emcmake cmake ..`
4. `emmake make`
5. `http-server`
5. open `index.html` in your browser.

## Notes
this is a debug build: `set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -g -s USE_SDL=2")`
It uses the SDL2 library bundled with the Emscripten SDK so I think the `Install SDL``
is not necessary

### Debugging
I followed the [Debugging WebAssembly with modern tools](https://developer.chrome.com/blog/wasm-debugging-2020/) tutorial and was able to debug at the C source level just fine


Steps:
1. Install Chrome Canary
2. Install the C/C++ DevTools Support (DWARF) as outline
3. serve `index.html` via `http-server` - opening file//wherever/index.html breaks debugging