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

build clay-official-website with clang only #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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