diff --git a/.gitignore b/.gitignore index 920b1724..f6baad91 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ cmake-build-release/ .idea/ node_modules/ *.dSYM -.vs/ \ No newline at end of file +.vs/ +build* diff --git a/CMakeLists.txt b/CMakeLists.txt index 10a49b89..c69999f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ add_subdirectory("examples/cpp-project-example") add_subdirectory("examples/raylib-multi-context") add_subdirectory("examples/raylib-sidebar-scrolling-container") # add_subdirectory("examples/cairo-pdf-rendering") Some issue with github actions populating cairo, disable for now -if(NOT MSVC) +if(${CMAKE_C_COMPILER} MATCHES "clang") add_subdirectory("examples/clay-official-website") endif() add_subdirectory("examples/introducing-clay-video-demo") diff --git a/examples/clay-official-website/CMakeLists.txt b/examples/clay-official-website/CMakeLists.txt index 9702d219..211bf2e3 100644 --- a/examples/clay-official-website/CMakeLists.txt +++ b/examples/clay-official-website/CMakeLists.txt @@ -1,11 +1,61 @@ cmake_minimum_required(VERSION 3.27) project(clay_official_website C) +if(NOT ${CMAKE_C_COMPILER} MATCHES "clang") + message(FATAL_ERROR "clang is required for webassembly build") +endif() + set(CMAKE_C_STANDARD 99) add_executable(clay_official_website main.c) -target_compile_options(clay_official_website PUBLIC -Wall -Werror -Wno-unknown-pragmas -Wno-error=missing-braces) +# expand @URL@ macro from index.html.in to index.html +set(URL "http://localhost:8080/") +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/index.html.in" INDEX_HTML) +string(REPLACE @URL@ ${URL} INDEX_HTML "${INDEX_HTML}") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/index.html" "${INDEX_HTML}") + +set_target_properties(clay_official_website PROPERTIES OUTPUT_NAME "index") +set(CMAKE_EXECUTABLE_SUFFIX ".wasm") +target_compile_options(clay_official_website PUBLIC + --target=wasm32 + -Wall + -Werror + -Wno-unknown-pragmas + -emit-llvm + -Os + -DCLAY_WASM + -mbulk-memory) target_include_directories(clay_official_website PUBLIC .) +target_link_options(clay_official_website + PUBLIC + --target=wasm32 + -nostdlib + -Wl,--strip-all + -Wl,--export-dynamic + -Wl,--no-entry + -Wl,--export=__heap_base + -Wl,--export=ACTIVE_RENDERER_INDEX + -Wl,--initial-memory=16908288) +add_custom_command( + TARGET clay_official_website POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory + ${CMAKE_CURRENT_BINARY_DIR}/web) +add_custom_command( + TARGET clay_official_website POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/fonts + ${CMAKE_CURRENT_BINARY_DIR}/web/fonts) +add_custom_command( + TARGET clay_official_website POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/images + ${CMAKE_CURRENT_BINARY_DIR}/web/images) +add_custom_command( + TARGET clay_official_website POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/index.html + ${CMAKE_CURRENT_BINARY_DIR}/index.wasm + ${CMAKE_CURRENT_BINARY_DIR}/web) -set(CMAKE_C_FLAGS_RELEASE "-O3") \ No newline at end of file +set(CMAKE_C_FLAGS_RELEASE "-O3") diff --git a/examples/clay-official-website/build/clay/fonts/Calistoga-Regular.ttf b/examples/clay-official-website/build/clay/fonts/Calistoga-Regular.ttf deleted file mode 100644 index 3fc1c1ed..00000000 Binary files a/examples/clay-official-website/build/clay/fonts/Calistoga-Regular.ttf and /dev/null differ diff --git a/examples/clay-official-website/build/clay/fonts/Quicksand-Semibold.ttf b/examples/clay-official-website/build/clay/fonts/Quicksand-Semibold.ttf deleted file mode 100644 index 27106d00..00000000 Binary files a/examples/clay-official-website/build/clay/fonts/Quicksand-Semibold.ttf and /dev/null differ diff --git a/examples/clay-official-website/build/clay/images/check_1.png b/examples/clay-official-website/build/clay/images/check_1.png deleted file mode 100644 index 280fd234..00000000 Binary files a/examples/clay-official-website/build/clay/images/check_1.png and /dev/null differ diff --git a/examples/clay-official-website/build/clay/images/check_2.png b/examples/clay-official-website/build/clay/images/check_2.png deleted file mode 100644 index 7972581f..00000000 Binary files a/examples/clay-official-website/build/clay/images/check_2.png and /dev/null differ diff --git a/examples/clay-official-website/build/clay/images/check_3.png b/examples/clay-official-website/build/clay/images/check_3.png deleted file mode 100644 index fb60187d..00000000 Binary files a/examples/clay-official-website/build/clay/images/check_3.png and /dev/null differ diff --git a/examples/clay-official-website/build/clay/images/check_4.png b/examples/clay-official-website/build/clay/images/check_4.png deleted file mode 100644 index a938f812..00000000 Binary files a/examples/clay-official-website/build/clay/images/check_4.png and /dev/null differ diff --git a/examples/clay-official-website/build/clay/images/check_5.png b/examples/clay-official-website/build/clay/images/check_5.png deleted file mode 100644 index ea6cfca3..00000000 Binary files a/examples/clay-official-website/build/clay/images/check_5.png and /dev/null differ diff --git a/examples/clay-official-website/build/clay/images/debugger.png b/examples/clay-official-website/build/clay/images/debugger.png deleted file mode 100644 index 79c01331..00000000 Binary files a/examples/clay-official-website/build/clay/images/debugger.png and /dev/null differ diff --git a/examples/clay-official-website/build/clay/images/declarative.png b/examples/clay-official-website/build/clay/images/declarative.png deleted file mode 100644 index 5cd4abbe..00000000 Binary files a/examples/clay-official-website/build/clay/images/declarative.png and /dev/null differ diff --git a/examples/clay-official-website/build/clay/images/renderer.png b/examples/clay-official-website/build/clay/images/renderer.png deleted file mode 100644 index 92537c3e..00000000 Binary files a/examples/clay-official-website/build/clay/images/renderer.png and /dev/null differ diff --git a/examples/clay-official-website/build/clay/index.wasm b/examples/clay-official-website/build/clay/index.wasm deleted file mode 100755 index 9847ded4..00000000 Binary files a/examples/clay-official-website/build/clay/index.wasm and /dev/null differ diff --git a/examples/clay-official-website/index.html b/examples/clay-official-website/index.html deleted file mode 100644 index 497f52ab..00000000 --- a/examples/clay-official-website/index.html +++ /dev/null @@ -1,789 +0,0 @@ - - -
- - - - - -