-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
seperate host &* cart for wasi-sdk cart compile
- Loading branch information
Showing
12 changed files
with
91 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.DS_Store | ||
build | ||
build/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
mkdir -p build | ||
|
||
cd host | ||
emcmake cmake -B build -GNinja | ||
cmake --build build | ||
mv build/host.* ../build | ||
|
||
cd ../cart | ||
cmake -B build -GNinja | ||
cmake --build build | ||
mv build/cart.* ../build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# build for carts | ||
|
||
cmake_minimum_required (VERSION 3.18) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") | ||
|
||
set(CMAKE_SYSTEM_NAME WASI) | ||
set(CMAKE_SYSTEM_VERSION 1) | ||
set(CMAKE_SYSTEM_PROCESSOR wasm32) | ||
set(triple wasm32-wasi) | ||
|
||
# When building from source, WASI_SDK_PREFIX represents the generated directory | ||
if(NOT WASI_SDK_PREFIX) | ||
set(WASI_SDK_PREFIX /opt/wasi-sdk) | ||
endif() | ||
|
||
set(CMAKE_C_COMPILER ${WASI_SDK_PREFIX}/bin/clang${WASI_HOST_EXE_SUFFIX}) | ||
set(CMAKE_CXX_COMPILER ${WASI_SDK_PREFIX}/bin/clang++${WASI_HOST_EXE_SUFFIX}) | ||
set(CMAKE_ASM_COMPILER ${WASI_SDK_PREFIX}/bin/clang${WASI_HOST_EXE_SUFFIX}) | ||
set(CMAKE_AR ${WASI_SDK_PREFIX}/bin/llvm-ar${WASI_HOST_EXE_SUFFIX}) | ||
set(CMAKE_RANLIB ${WASI_SDK_PREFIX}/bin/llvm-ranlib${WASI_HOST_EXE_SUFFIX}) | ||
set(CMAKE_C_COMPILER_TARGET ${triple}) | ||
set(CMAKE_CXX_COMPILER_TARGET ${triple}) | ||
set(CMAKE_ASM_COMPILER_TARGET ${triple}) | ||
|
||
# use only sysroot | ||
set(HAVE_FLAG_SEARCH_PATHS_FIRST 0) | ||
set(CMAKE_C_LINK_FLAGS "") | ||
set(CMAKE_CXX_LINK_FLAGS "") | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||
|
||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
set(CMAKE_EXECUTABLE_SUFFIX ".wasm") | ||
|
||
add_executable(cart cart.c) | ||
target_link_options(cart PRIVATE -Wl,--initial-memory=128057344 -Wl,--import-memory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#define WASM_IMPORT(n) __attribute__((import_module("env"), import_name(n))) | ||
|
||
WASM_IMPORT("logtest") | ||
void logtest(char* message); | ||
|
||
int main(int argc, char* argv[]) { | ||
logtest("I am inside the cart!"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.18) | ||
|
||
project(wasm_shared-host | ||
DESCRIPTION "null0 engine experiment: shared memory" | ||
HOMEPAGE_URL "https://github.com/notnullgames/wasm-shared" | ||
VERSION 0.0.1 | ||
LANGUAGES C | ||
) | ||
|
||
if(NOT EMSCRIPTEN) | ||
message(FATAL_ERROR "You must compile with emscripten.") | ||
endif() | ||
|
||
set(CMAKE_EXECUTABLE_SUFFIX ".mjs") | ||
|
||
add_executable(host host.c) | ||
target_link_options(host PRIVATE -sINITIAL_MEMORY=128MB -sEXPORTED_FUNCTIONS=_logtest -sEXPORTED_RUNTIME_METHODS=wasmMemory) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters