Skip to content

Commit

Permalink
build clay-official-website with clang only
Browse files Browse the repository at this point in the history
  • Loading branch information
pvmm committed Jan 16, 2025
1 parent cd82ce6 commit 92ad790
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 812 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ cmake-build-release/
.idea/
node_modules/
*.dSYM
.vs/
.vs/
build*
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
54 changes: 52 additions & 2 deletions examples/clay-official-website/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
set(CMAKE_C_FLAGS_RELEASE "-O3")
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 92ad790

Please sign in to comment.