From f63d230ae4644817f504b7c881b2b0e71c07631f Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sat, 14 Mar 2026 13:07:09 +0100 Subject: [PATCH 01/12] feat: use wasi-sysroot instead of WASI-SDK Currently, since WASI-SDK only provides binaries for a few platforms, excluding RISCV32, and we want to provide support for those, it will be better if we use "upstream" clang to build the WASM modules. So, instead of wasi-sdk, we just need the sysroot. Signed-off-by: Marco Casaroli --- CMakeLists.txt | 2 +- scripts/Platform/WASI.cmake | 1 + scripts/wasm32-wasi-pthread.cmake | 46 +++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 scripts/Platform/WASI.cmake create mode 100644 scripts/wasm32-wasi-pthread.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1082b56..240e008 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.20.0) # Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-pthread.cmake) +set(CMAKE_TOOLCHAIN_FILE scripts/wasm32-wasi-pthread.cmake) set(CMAKE_VERBOSE_MAKEFILE TRUE) diff --git a/scripts/Platform/WASI.cmake b/scripts/Platform/WASI.cmake new file mode 100644 index 0000000..b49713f --- /dev/null +++ b/scripts/Platform/WASI.cmake @@ -0,0 +1 @@ +set(WASI 1) diff --git a/scripts/wasm32-wasi-pthread.cmake b/scripts/wasm32-wasi-pthread.cmake new file mode 100644 index 0000000..9a45745 --- /dev/null +++ b/scripts/wasm32-wasi-pthread.cmake @@ -0,0 +1,46 @@ +# Cmake toolchain description file for the Makefile + +if(NOT WASI_SYSROOT) + set(WASI_SYSROOT "/opt/wasi-sysroot") +endif() + +set(CMAKE_SYSTEM_NAME WASI) +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_PROCESSOR wasm32) +set(triple wasm32-wasi-threads) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread --sysroot=${WASI_SYSROOT}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread --sysroot=${WASI_SYSROOT}") +# wasi-threads requires --import-memory. +# wasi requires --export-memory. +# (--export-memory is implicit unless --import-memory is given) +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--import-memory") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-memory") + +if(WIN32) + set(WASI_HOST_EXE_SUFFIX ".exe") +else() + set(WASI_HOST_EXE_SUFFIX "") +endif() + +# When building from source, WASI_SDK_PREFIX represents the generated directory +if(NOT WASI_SDK_PREFIX) + set(WASI_SDK_PREFIX ${CMAKE_CURRENT_LIST_DIR}/../../) +endif() + +set(CMAKE_C_COMPILER clang) +set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_ASM_COMPILER clang) +set(CMAKE_AR llvm-ar) +set(CMAKE_RANLIB llvm-ranlib) +set(CMAKE_C_COMPILER_TARGET ${triple}) +set(CMAKE_CXX_COMPILER_TARGET ${triple}) +set(CMAKE_ASM_COMPILER_TARGET ${triple}) + +# Don't look in the sysroot for executables to run during the build +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# Only look in the sysroot (not in the host paths) for the rest +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) From 79e0b52053cf42e603dcf9b83ed7da7080e5c054 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sat, 21 Mar 2026 16:12:32 +0100 Subject: [PATCH 02/12] refactor: separate sysroot Signed-off-by: Marco Casaroli --- CMakeLists.txt | 212 +++++++++++++----- generic/big-sample/CMakeLists.txt | 22 +- generic/blinky-board-generic/CMakeLists.txt | 27 +-- generic/blinky/CMakeLists.txt | 29 +-- generic/echo-server/CMakeLists.txt | 25 +-- generic/filesystem-full/CMakeLists.txt | 30 +-- generic/filesystem/CMakeLists.txt | 29 +-- generic/hello-world/CMakeLists.txt | 22 +- generic/hello-world/main.c | 6 +- generic/log_mirror_forwarder/CMakeLists.txt | 42 ++-- .../publisher_inside/CMakeLists.txt | 29 +-- .../publisher_outside/CMakeLists.txt | 29 +-- .../subscriber_temp/CMakeLists.txt | 29 +-- generic/messaging/publisher/CMakeLists.txt | 29 +-- generic/messaging/subscriber/CMakeLists.txt | 29 +-- generic/modbus-client/CMakeLists.txt | 40 +--- generic/sensor-rng/CMakeLists.txt | 29 +-- .../shared-filesystem-reader/CMakeLists.txt | 29 +-- .../shared-filesystem-writer/CMakeLists.txt | 29 +-- generic/webserver-complex/CMakeLists.txt | 45 ++-- generic/webserver/CMakeLists.txt | 45 ++-- scripts/wasm32-wasi-pthread.cmake | 23 +- testing/CMakeLists.txt | 11 + 23 files changed, 331 insertions(+), 509 deletions(-) create mode 100644 testing/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 240e008..80639e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,95 +1,199 @@ cmake_minimum_required (VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE scripts/wasm32-wasi-pthread.cmake) +project(ocre-sdk) set(CMAKE_VERBOSE_MAKEFILE TRUE) -project(OcreSdkSamples) +make_directory(${CMAKE_CURRENT_LIST_DIR}/sysroot) -# Set the linker flags -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined -Wl,--max-memory=1048576") +include(ExternalProject) +ExternalProject_Add(wasi-sysroot + URL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-32/wasi-sysroot-32.0.tar.gz + URL_HASH SHA256=f2537f6e5804f7f24e32dd140e9371e9670a9fd2646b6a813ddb896b29954b12 + DOWNLOAD_EXTRACT_TIMESTAMP FALSE + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND cp -r ../wasi-sysroot/. ${CMAKE_CURRENT_LIST_DIR}/sysroot +) -# Set compilation flags -add_compile_options( - -O0 -Wno-unknown-attributes - -O3 - -Wall - -Wextra - -Wno-unused-parameter +ExternalProject_Add(ocre-sdk + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/ocre-sdk + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DWAMR_ROOT:STRING=${WAMR_ROOT}" + DEPENDS wasi-sysroot ) -if(NOT WAMR_ROOT_DIR) - set(WAMR_ROOT_DIR "wasm-micro-runtime") -endif() +add_custom_target(sysroot + DEPENDS + wasi-sysroot + ocre-sdk +) -include(${WAMR_ROOT_DIR}/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake) +# Containers -add_subdirectory(ocre-sdk) +make_directory(${CMAKE_CURRENT_BINARY_DIR}/dist) -# Create the executable targets -add_executable("hello-world.wasm" generic/hello-world/main.c) +# Generic Samples -add_executable("blinky.wasm" generic/blinky/main.c) +ExternalProject_Add(big-sample + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/big-sample + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp big-sample.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) + +ExternalProject_Add(blinky + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/blinky + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp blinky.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -# Include + link the Ocre API and WAMR socket library -target_include_directories("blinky.wasm" PRIVATE - ocre_api +ExternalProject_Add(blinky-board-generic + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/blinky-board-generic + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp blinky-board-generic.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk ) -target_link_libraries("blinky.wasm" ocre_api) +ExternalProject_Add(echo-server + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/echo-server + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp echo-server.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -add_executable("publisher.wasm" generic/messaging/publisher/main.c) +ExternalProject_Add(filesystem + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/filesystem + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp filesystem.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -target_include_directories("publisher.wasm" PRIVATE - ocre_api +ExternalProject_Add(filesystem-full + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/filesystem-full + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp filesystem-full.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk ) -target_link_libraries("publisher.wasm" ocre_api) +ExternalProject_Add(hello-world + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/hello-world + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp hello-world.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -add_executable("subscriber.wasm" generic/messaging/subscriber/main.c) +ExternalProject_Add(log_mirror_forwarder + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/log_mirror_forwarder + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp syslog_webserver.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -target_include_directories("subscriber.wasm" PRIVATE - ocre_api +ExternalProject_Add(publisher + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/publisher + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp publisher.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk ) -target_link_libraries("subscriber.wasm" ocre_api) +ExternalProject_Add(subscriber + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/subscriber + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp subscriber.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -add_executable("filesystem.wasm" generic/filesystem/main.c) +ExternalProject_Add(publisher_inside + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/publisher_inside + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp publisher_inside.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -target_include_directories("filesystem.wasm" PRIVATE - ocre_api +ExternalProject_Add(publisher_outside + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/publisher_outside + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp publisher_outside.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk ) -target_link_libraries("filesystem.wasm" ocre_api) +ExternalProject_Add(subscriber_temp + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/subscriber_temp + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp subscriber_temp.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -add_executable("filesystem-full.wasm" generic/filesystem-full/main.c) +ExternalProject_Add(modbus-client + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/modbus-client + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp modbus-client.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -target_include_directories("filesystem-full.wasm" PRIVATE - ocre_api +ExternalProject_Add(shared-filesystem-reader + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/shared-filesystem/shared-filesystem-reader + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp shared-filesystem-reader.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk ) -target_link_libraries("filesystem-full.wasm" ocre_api) +ExternalProject_Add(shared-filesystem-writer + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/shared-filesystem/shared-filesystem-writer + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp shared-filesystem-writer.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -add_executable("webserver.wasm" generic/webserver/main.c generic/webserver/mongoose.c) +ExternalProject_Add(webserver + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/webserver + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp webserver.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -target_include_directories("webserver.wasm" PRIVATE - ${WAMR_ROOT_DIR}/core/iwasm/libraries/lib-socket - ocre_api +ExternalProject_Add(webserver-complex + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/webserver-complex + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp webserver-complex.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk ) -target_link_libraries("webserver.wasm" socket_wasi_ext ocre_api) +# Testing -add_executable("webserver-complex.wasm" generic/webserver-complex/main.c generic/webserver-complex/mongoose.c) +ExternalProject_Add(print_args + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/print_args + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp print_args.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -target_include_directories("webserver-complex.wasm" PRIVATE - ${WAMR_ROOT_DIR}/core/iwasm/libraries/lib-socket - ocre_api +ExternalProject_Add(pthread + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/pthread + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp pthread.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk ) -target_link_libraries("webserver-complex.wasm" socket_wasi_ext ocre_api) +ExternalProject_Add(return0 + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/return0 + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp return0.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) -add_executable("return0.wasm" testing/return0.c) -add_executable("return1.wasm" testing/return1.c) -add_executable("sleep_5_return_0.wasm" testing/sleep_5_return_0.c) -add_executable("pthread.wasm" testing/pthread.c) +ExternalProject_Add(return1 + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/return1 + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp return1.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) + +ExternalProject_Add(sleep5_return0 + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/sleep5_return0 + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + INSTALL_COMMAND cp sleep5_return0.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist + DEPENDS ocre-sdk +) diff --git a/generic/big-sample/CMakeLists.txt b/generic/big-sample/CMakeLists.txt index cc147dc..10e0e9b 100644 --- a/generic/big-sample/CMakeLists.txt +++ b/generic/big-sample/CMakeLists.txt @@ -1,23 +1,7 @@ cmake_minimum_required(VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -# Set the project name (needs to come after the toolchain file) -set(APPNAME big-sample) -project(${APPNAME}) +project(big-sample) -# Set the linker flags -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") - -# Set compilation flags -add_compile_options( - -O0 -Wno-unknown-attributes - -O3 - -Wall - -Wextra - -Wno-unused-parameter -) - -# Create the executable target -add_executable(${APPNAME}.wasm main.c) +add_executable(big-sample.wasm main.c) diff --git a/generic/blinky-board-generic/CMakeLists.txt b/generic/blinky-board-generic/CMakeLists.txt index 6e366d8..564a462 100644 --- a/generic/blinky-board-generic/CMakeLists.txt +++ b/generic/blinky-board-generic/CMakeLists.txt @@ -1,25 +1,12 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -set(APPNAME blinky-board-generic) -project(${APPNAME} LANGUAGES C) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +project(blinky-board-generic) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_executable(blinky-board-generic.wasm main.c) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(blinky-board-generic.wasm + PUBLIC + ocre_api +) diff --git a/generic/blinky/CMakeLists.txt b/generic/blinky/CMakeLists.txt index dcadc1d..7ca7ede 100644 --- a/generic/blinky/CMakeLists.txt +++ b/generic/blinky/CMakeLists.txt @@ -1,25 +1,12 @@ -cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -set(APPNAME blinky) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +project(blinky) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_executable(blinky.wasm main.c) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(blinky.wasm + PUBLIC + ocre_api +) diff --git a/generic/echo-server/CMakeLists.txt b/generic/echo-server/CMakeLists.txt index b289159..dd23f53 100644 --- a/generic/echo-server/CMakeLists.txt +++ b/generic/echo-server/CMakeLists.txt @@ -1,23 +1,12 @@ cmake_minimum_required(VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) -set(CMAKE_BUILD_TYPE Release) -set(APPNAME echo-server) -project(${APPNAME}) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -# Include the WAMR socket library CMake file (adjust path as needed) -include(../../wasm-micro-runtime/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake) +project(echo-server) -add_compile_options( - -O0 -Wno-unknown-attributes -) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-undefined -z stack-size=4096") -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary -) -add_executable(${APPNAME}.wasm src/main.c) -target_include_directories(${APPNAME}.wasm PRIVATE - ../../wasm-micro-runtime/core/iwasm/libraries/lib-socket +add_executable(echo-server.wasm src/main.c) + +target_link_libraries(echo-server.wasm + PUBLIC + socket_wasi_ext ) -target_link_libraries(${APPNAME}.wasm socket_wasi_ext) diff --git a/generic/filesystem-full/CMakeLists.txt b/generic/filesystem-full/CMakeLists.txt index aa5af08..8ea255d 100644 --- a/generic/filesystem-full/CMakeLists.txt +++ b/generic/filesystem-full/CMakeLists.txt @@ -1,30 +1,22 @@ cmake_minimum_required (VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -set(CMAKE_BUILD_TYPE Release) +project(filesystem-full) -set(APPNAME filesystem-full) -project(${APPNAME}) +set(CMAKE_BUILD_TYPE Release) -# When compiling with no stdlib -# add_compile_options( -# --target=wasm32-wasm-unknown -# -nostdlib -# ) +add_executable(filesystem-full.wasm main.c) -add_compile_options( - -Os +target_compile_options(filesystem-full.wasm + PRIVATE + -Os -Wno-unknown-attributes ) -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined - -z stack-size=1024 # Probably larger than needed - optimize - -Wl,--initial-memory=65536 # Minimum size of linear memory\ +target_link_options(filesystem-full.wasm + PRIVATE + -z stack-size=1024 # Probably larger than needed + -Wl,--initial-memory=65536 # Minimum size of linear memory -Wl,--max-memory=65536 # Maximum size of linear memory ) - -add_executable(${APPNAME}.wasm main.c) diff --git a/generic/filesystem/CMakeLists.txt b/generic/filesystem/CMakeLists.txt index 4c86f61..ae79888 100644 --- a/generic/filesystem/CMakeLists.txt +++ b/generic/filesystem/CMakeLists.txt @@ -1,30 +1,7 @@ cmake_minimum_required (VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -set(CMAKE_BUILD_TYPE Release) +project(filesystem) -set(APPNAME filesystem) -project(${APPNAME}) - -# When compiling with no stdlib -# add_compile_options( -# --target=wasm32-wasm-unknown -# -nostdlib -# ) - -add_compile_options( - -Os - -Wno-unknown-attributes -) - -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined - -z stack-size=1024 # Probably larger than needed - optimize - -Wl,--initial-memory=65536 # Minimum size of linear memory\ - -Wl,--max-memory=65536 # Maximum size of linear memory -) - -add_executable(${APPNAME}.wasm main.c) +add_executable(filesystem.wasm main.c) diff --git a/generic/hello-world/CMakeLists.txt b/generic/hello-world/CMakeLists.txt index d6736ab..a055a6c 100644 --- a/generic/hello-world/CMakeLists.txt +++ b/generic/hello-world/CMakeLists.txt @@ -1,23 +1,7 @@ cmake_minimum_required(VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -# Set the project name (needs to come after the toolchain file) -set(APPNAME hello-world) -project(${APPNAME}) +project(hello-world) -# Set the linker flags -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") - -# Set compilation flags -add_compile_options( - -O0 -Wno-unknown-attributes - -O3 - -Wall - -Wextra - -Wno-unused-parameter -) - -# Create the executable target -add_executable(${APPNAME}.wasm main.c) \ No newline at end of file +add_executable(hello-world.wasm main.c) diff --git a/generic/hello-world/main.c b/generic/hello-world/main.c index 01adcdb..41bcdb7 100644 --- a/generic/hello-world/main.c +++ b/generic/hello-world/main.c @@ -5,17 +5,17 @@ * SPDX-License-Identifier: Apache-2.0 */ - + #include // Application entry point int main() -{ +{ printf("\n\ _ _________ ___ ______________ ______ ____ __ \n\ | | /| / / __/ _ )/ _ | / __/ __/ __/ |/ / _ )/ /\\ \\/ / \n\ | |/ |/ / _// _ / __ |_\\ \\_\\ \\/ _// /|_/ / _ / /__\\ / \n\ |__/|__/___/____/_/ |_/___/___/___/_/ /_/____/____//_/ \n\ - powered by Ocre "); + powered by Ocre \n"); return 0; } diff --git a/generic/log_mirror_forwarder/CMakeLists.txt b/generic/log_mirror_forwarder/CMakeLists.txt index 9aba13d..9deec8e 100644 --- a/generic/log_mirror_forwarder/CMakeLists.txt +++ b/generic/log_mirror_forwarder/CMakeLists.txt @@ -1,41 +1,27 @@ -cmake_minimum_required (VERSION 3.20.0) +cmake_minimum_required(VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-pthread.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -set(CMAKE_BUILD_TYPE Release) +project(syslog_webserver) -set(APPNAME syslog_webserver) -project(${APPNAME}) +set(CMAKE_BUILD_TYPE Release) -# Include the WAMR socket library CMake file (adjust path as needed) -include(../../wasm-micro-runtime/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake) +add_executable(syslog_webserver.wasm + main.c + mongoose.c +) -add_compile_options( -# --target=wasm32-wasm-unknown # Target WebAssembly +target_compile_options(syslog_webserver.wasm + PRIVATE -Os -Wno-unknown-attributes -D_WASI_EMULATED_PTHREAD ) - -# Set compilation flags -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined +target_link_options(syslog_webserver.wasm + PRIVATE -z stack-size=8192 ) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) - -add_executable(${APPNAME}.wasm main.c mongoose.c) - -# Include + link the Ocre API and WAMR socket library -target_include_directories(${APPNAME}.wasm PRIVATE - ../../wasm-micro-runtime/core/iwasm/libraries/lib-socket +target_link_libraries(syslog_webserver.wasm + socket_wasi_ext ocre_api ) -target_link_libraries(${APPNAME}.wasm socket_wasi_ext ocre_api) diff --git a/generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt b/generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt index e6365cf..f0130f0 100644 --- a/generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt +++ b/generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt @@ -1,25 +1,12 @@ -cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -set(APPNAME publisher_inside) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../../scripts/wasm32-wasi-pthread.cmake) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +project(publisher_inside) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_executable(publisher_inside.wasm main.c) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(publisher_inside.wasm + PUBLIC + ocre_api +) diff --git a/generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt b/generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt index a55e8d5..8a93d4e 100644 --- a/generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt +++ b/generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt @@ -1,25 +1,12 @@ -cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -set(APPNAME publisher_outside) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../../scripts/wasm32-wasi-pthread.cmake) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +project(publisher_outside) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_executable(publisher_outside.wasm main.c) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(publisher_outside.wasm + PUBLIC + ocre_api +) diff --git a/generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt b/generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt index 24421d7..02c9e4c 100644 --- a/generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt +++ b/generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt @@ -1,25 +1,12 @@ -cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -set(APPNAME subscriber_temp) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../../scripts/wasm32-wasi-pthread.cmake) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +project(subscriber_temp) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_executable(subscriber_temp.wasm main.c) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(subscriber_temp.wasm + PUBLIC + ocre_api +) diff --git a/generic/messaging/publisher/CMakeLists.txt b/generic/messaging/publisher/CMakeLists.txt index 70fcbbf..bbe4ff5 100644 --- a/generic/messaging/publisher/CMakeLists.txt +++ b/generic/messaging/publisher/CMakeLists.txt @@ -1,25 +1,12 @@ -cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -set(APPNAME publisher) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/wasm32-wasi-pthread.cmake) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +project(publisher) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_executable(publisher.wasm main.c) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(publisher.wasm + PUBLIC + ocre_api +) diff --git a/generic/messaging/subscriber/CMakeLists.txt b/generic/messaging/subscriber/CMakeLists.txt index 7845d99..db1cedd 100644 --- a/generic/messaging/subscriber/CMakeLists.txt +++ b/generic/messaging/subscriber/CMakeLists.txt @@ -1,25 +1,12 @@ -cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -set(APPNAME subscriber) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/wasm32-wasi-pthread.cmake) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +project(subscriber) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_executable(subscriber.wasm main.c) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(subscriber.wasm + PUBLIC + ocre_api +) diff --git a/generic/modbus-client/CMakeLists.txt b/generic/modbus-client/CMakeLists.txt index b30938b..1577787 100644 --- a/generic/modbus-client/CMakeLists.txt +++ b/generic/modbus-client/CMakeLists.txt @@ -1,42 +1,26 @@ -cmake_minimum_required (VERSION 3.20.0) +cmake_minimum_required(VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -set(CMAKE_BUILD_TYPE Release) +project(modbus-client) -set(APPNAME modbus-client) -project(${APPNAME}) +set(CMAKE_BUILD_TYPE Release) -# Include the WAMR socket library CMake file (adjust path as needed) -include(../../wasm-micro-runtime/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake) +add_executable(modbus-client.wasm main.c mongoose.c) -add_compile_options( -# --target=wasm32-wasm-unknown # Target WebAssembly +target_compile_options(modbus-client.wasm + PRIVATE -Os -Wno-unknown-attributes ) -# Set compilation flags -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined +target_link_options(modbus-client.wasm + PRIVATE -z stack-size=16384 - -Wl,--initial-memory=65536 # Minimum size of linear memory\ + -Wl,--initial-memory=65536 # Minimum size of linear memory -Wl,--max-memory=65536 # Maximum size of linear memory ) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) - -add_executable(${APPNAME}.wasm main.c mongoose.c) - -# Include + link the Ocre API and WAMR socket library -target_include_directories(${APPNAME}.wasm PRIVATE - ../../wasm-micro-runtime/core/iwasm/libraries/lib-socket +target_link_libraries(modbus-client.wasm + socket_wasi_ext ocre_api ) -target_link_libraries(${APPNAME}.wasm socket_wasi_ext ocre_api) diff --git a/generic/sensor-rng/CMakeLists.txt b/generic/sensor-rng/CMakeLists.txt index edce8d3..b89dd20 100644 --- a/generic/sensor-rng/CMakeLists.txt +++ b/generic/sensor-rng/CMakeLists.txt @@ -1,25 +1,12 @@ -cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -set(APPNAME sensor-rng) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +project(sensor-rng) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_executable(sensor-rng.wasm main.c) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(sensor-rng.wasm + PUBLIC + ocre_api +) diff --git a/generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt b/generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt index 945a3d3..8e61bb3 100644 --- a/generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt +++ b/generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt @@ -1,30 +1,7 @@ cmake_minimum_required (VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/wasm32-wasi-pthread.cmake) -set(CMAKE_BUILD_TYPE Release) +project(shared-filesystem-reader) -set(APPNAME shared-filesystem-reader) -project(${APPNAME}) - -# When compiling with no stdlib -# add_compile_options( -# --target=wasm32-wasm-unknown -# -nostdlib -# ) - -add_compile_options( - -Os - -Wno-unknown-attributes -) - -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined - -z stack-size=1024 # Probably larger than needed - optimize - -Wl,--initial-memory=65536 # Minimum size of linear memory\ - -Wl,--max-memory=65536 # Maximum size of linear memory -) - -add_executable(${APPNAME}.wasm main.c) \ No newline at end of file +add_executable(shared-filesystem-reader.wasm main.c) diff --git a/generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt b/generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt index b4a5161..a272ce5 100644 --- a/generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt +++ b/generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt @@ -1,30 +1,7 @@ cmake_minimum_required (VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/wasm32-wasi-pthread.cmake) -set(CMAKE_BUILD_TYPE Release) +project(shared-filesystem-writer) -set(APPNAME shared-filesystem-writer) -project(${APPNAME}) - -# When compiling with no stdlib -# add_compile_options( -# --target=wasm32-wasm-unknown -# -nostdlib -# ) - -add_compile_options( - -Os - -Wno-unknown-attributes -) - -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined - -z stack-size=1024 # Probably larger than needed - optimize - -Wl,--initial-memory=65536 # Minimum size of linear memory\ - -Wl,--max-memory=65536 # Maximum size of linear memory -) - -add_executable(${APPNAME}.wasm main.c) +add_executable(shared-filesystem-writer.wasm main.c) diff --git a/generic/webserver-complex/CMakeLists.txt b/generic/webserver-complex/CMakeLists.txt index c0b8b07..07a90a8 100644 --- a/generic/webserver-complex/CMakeLists.txt +++ b/generic/webserver-complex/CMakeLists.txt @@ -1,42 +1,29 @@ -cmake_minimum_required (VERSION 3.20.0) +cmake_minimum_required(VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -set(CMAKE_BUILD_TYPE Release) +project(webserver-complex) -set(APPNAME webserver-complex) -project(${APPNAME}) +set(CMAKE_BUILD_TYPE Release) -# Include the WAMR socket library CMake file (adjust path as needed) -include(../../wasm-micro-runtime/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake) +add_executable(webserver-complex.wasm + main.c + mongoose.c +) -add_compile_options( -# --target=wasm32-wasm-unknown # Target WebAssembly +target_compile_options(webserver-complex.wasm + PRIVATE -Os -Wno-unknown-attributes + -D_WASI_EMULATED_PTHREAD ) - -# Set compilation flags -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined +target_link_options(webserver-complex.wasm + PRIVATE -z stack-size=8192 - -Wl,--initial-memory=65536 # Minimum size of linear memory\ + -Wl,--initial-memory=65536 # Minimum size of linear memory -Wl,--max-memory=65536 # Maximum size of linear memory ) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) - -add_executable(${APPNAME}.wasm main.c mongoose.c) - -# Include + link the Ocre API and WAMR socket library -target_include_directories(${APPNAME}.wasm PRIVATE - ../../wasm-micro-runtime/core/iwasm/libraries/lib-socket +target_link_libraries(webserver-complex.wasm + socket_wasi_ext ocre_api ) -target_link_libraries(${APPNAME}.wasm socket_wasi_ext ocre_api) diff --git a/generic/webserver/CMakeLists.txt b/generic/webserver/CMakeLists.txt index 820c60f..a5f9227 100644 --- a/generic/webserver/CMakeLists.txt +++ b/generic/webserver/CMakeLists.txt @@ -1,42 +1,29 @@ -cmake_minimum_required (VERSION 3.20.0) +cmake_minimum_required(VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) -set(CMAKE_BUILD_TYPE Release) +project(webserver) -set(APPNAME webserver) -project(${APPNAME}) +set(CMAKE_BUILD_TYPE Release) -# Include the WAMR socket library CMake file (adjust path as needed) -include(../../wasm-micro-runtime/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake) +add_executable(webserver.wasm + main.c + mongoose.c +) -add_compile_options( -# --target=wasm32-wasm-unknown # Target WebAssembly +target_compile_options(webserver.wasm + PRIVATE -Os -Wno-unknown-attributes + -D_WASI_EMULATED_PTHREAD ) - -# Set compilation flags -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined +target_link_options(webserver.wasm + PRIVATE -z stack-size=8192 - -Wl,--initial-memory=65536 # Minimum size of linear memory\ + -Wl,--initial-memory=65536 # Minimum size of linear memory -Wl,--max-memory=65536 # Maximum size of linear memory ) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) - -add_executable(${APPNAME}.wasm main.c mongoose.c) - -# Include + link the Ocre API and WAMR socket library -target_include_directories(${APPNAME}.wasm PRIVATE - ../../wasm-micro-runtime/core/iwasm/libraries/lib-socket +target_link_libraries(webserver.wasm + socket_wasi_ext ocre_api ) -target_link_libraries(${APPNAME}.wasm socket_wasi_ext ocre_api) diff --git a/scripts/wasm32-wasi-pthread.cmake b/scripts/wasm32-wasi-pthread.cmake index 9a45745..0e8143a 100644 --- a/scripts/wasm32-wasi-pthread.cmake +++ b/scripts/wasm32-wasi-pthread.cmake @@ -1,31 +1,18 @@ # Cmake toolchain description file for the Makefile if(NOT WASI_SYSROOT) - set(WASI_SYSROOT "/opt/wasi-sysroot") + set(WASI_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/../sysroot") endif() set(CMAKE_SYSTEM_NAME WASI) set(CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_PROCESSOR wasm32) -set(triple wasm32-wasi-threads) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread --sysroot=${WASI_SYSROOT}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread --sysroot=${WASI_SYSROOT}") -# wasi-threads requires --import-memory. -# wasi requires --export-memory. -# (--export-memory is implicit unless --import-memory is given) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--import-memory") -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-memory") -if(WIN32) - set(WASI_HOST_EXE_SUFFIX ".exe") -else() - set(WASI_HOST_EXE_SUFFIX "") -endif() +set(triple wasm32-wasi-threads) -# When building from source, WASI_SDK_PREFIX represents the generated directory -if(NOT WASI_SDK_PREFIX) - set(WASI_SDK_PREFIX ${CMAKE_CURRENT_LIST_DIR}/../../) -endif() +set(CMAKE_C_FLAGS "-pthread --sysroot=${WASI_SYSROOT}") +set(CMAKE_CXX_FLAGS "-pthread --sysroot=${WASI_SYSROOT}") +set(CMAKE_EXE_LINKER_FLAGS "-Wl,--import-memory -Wl,--export-memory -Wl,--strip-all -Wl,--allow-undefined -Wl,--max-memory=4194304") set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt new file mode 100644 index 0000000..ae37173 --- /dev/null +++ b/testing/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.20.0) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../scripts/wasm32-wasi-pthread.cmake) + +project(testing) + +add_executable(print_args.wasm print_args.c) +add_executable(pthread.wasm pthread.c) +add_executable(return0.wasm return0.c) +add_executable(return1.wasm return1.c) +add_executable(sleep_5_return_0.wasm sleep_5_return_0.c) From 6095fe016ef7d917e12c02666554107a802e446d Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sat, 21 Mar 2026 16:12:45 +0100 Subject: [PATCH 03/12] chore(gitignore): add sysroot Signed-off-by: Marco Casaroli --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 1150372..7de337d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Build directories **/build/ +sysroot/ + # VSCode .vscode/* *.code-workspace From 8a0873a73ceea852924de1dfe885023eaa2137c0 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sat, 21 Mar 2026 16:12:54 +0100 Subject: [PATCH 04/12] docs: update README Signed-off-by: Marco Casaroli --- README.md | 109 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 7e87d21..fbe1a09 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,40 @@ The Ocre SDK provides a modular C-based API for building portable embedded applications that compile to WebAssembly. It includes both headers and source files, enabling flexible integration across platforms. This repository also contains a wide range of generic and board-specific examples that demonstrate real-world use cases. -All examples are designed to be built using [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) and executed inside the [Ocre Runtime](https://github.com/project-ocre/ocre-runtime), a lightweight WASI-compatible runtime tailored for embedded-style workloads. +All examples are designed to be executed inside the [Ocre Runtime](https://github.com/project-ocre/ocre-runtime), a lightweight WASI-compatible runtime tailored for embedded-style workloads. ## Repository Structure + ``` ├── ocre-api # Core SDK: headers + sources ├── generic # Platform-independent examples - │ ├── blinky, echo-server, filesystem, etc. - │ └── build folders per sample - ├── board_specific # Hardware-targeted examples - │ ├── arduino_portenta_h7 + │ ├── blinky, echo-server, filesystem, etc. + │ └── build folders per sample + ├── board_specific # Hardware-targeted examples + │ ├── arduino_portenta_h7 │ └── b_u585i_iot02a ├── testing # Testing and potentially faulty images. - │ └── return0, return1, pthread, etc. + │ └── return0, return1, pthread, etc. ├── wasm-micro-runtime # External module ``` -Each sample includes: -- CMakeLists.txt for build configuration -- A build/ directory (created during compilation) -- Optional subfolders like src/, fs/, or IMU/ depending on the sample - ## Getting Started +### System requirements + +To build the samples, you need LLVM, LLD, Clang 12+, wasm32 runtime libraries. You also need cmake, make and **\***. Install all on an Ubuntu 22 with: + +```sh +sudo apt install \ + cmake \ + clang \ + libclang-rt-dev-wasm32 \ + lld \ + llvm +``` + +Alternatively, you can use the Ocre devcontainer. Check Ocre documentation for more information. + ### Clone the Repository To get started with the full example suite: @@ -39,40 +50,65 @@ Or add the SDK as a submodule to your own project: git submodule add https://github.com/project-ocre/ocre-sdk.git ``` -Make sure the ocre-api folder is accessible to your build system. +## Set up Sysroot -## Building with wasi-sdk -All examples are designed to compile to .wasm using [wasi-sdk](https://github.com/WebAssembly/wasi-sdk). +The default sysroot can be set up automatically. From the root of this repository: -> **Note:** By default, we expect the WASI SDK toolchain file to be located at: -> -> `/opt/wasi-sdk/share/cmake/wasi-sdk.cmake` -> -> This is typically set in each sample's `CMakeLists.txt`. You can modify this path as needed for your environment. +```sh +mkdir build +cd build +cmake .. +make sysroot +``` -### Build Instructions -Each sample can be built independently. Here's a generic flow +The `sysroot` Make target will download the wasi-sysroot, then compile `lib_socket_ext` and `ocre_api`, and populate them into the `sysroot` directory on the root of this repository. -```bash -cd generic/blinky -mkdir -p build && cd build -cmake .. -cmake --build . +It is also possible to specify a different WAMR root, used for building `lib_socket_ext`, through the `WAMR_ROOT` CMake variable, if you do not want to use the included git submodule: + +```sh +cmake .. -DWAMR_ROOT=~/ocre/wasm-micro-runtime ``` -This will generate a .wasm binary in the build/ directory. -Repeat the same process for any other sample—whether under generic/ or board_specific/ +## Build Samples -## Running with Ocre Runtime -All compiled .wasm samples are compatible with the [Ocre Runtime](https://github.com/project-ocre/ocre-runtime), which provides a lightweight execution environment for WASI modules. +### From the ocre-sdk build directory -Example: -```bash -app build/hello-world.wasm +Alternatively, the `all` Make target will build most of the generic samples and testing containers: + +```sh +make +``` + +You can also build a specific sample, for example: + +```sh +make hello-world ``` +The built files are stord in the `dist` directory inside the current build directory: + +```sh +ls dist +``` + +### From each sample's directory + +Assumming, you already have the sysroot installed into the `sysroot` directory, it is possible to build each sample from their own directory, for example: + +```sh +cd generic/hello-world +mkdir build +cd build +cmake .. +make +``` + +The built file is stored in the current build directory. + ## Example Categories + ### Generic Samples + - blinky - hello-world - echo-server @@ -81,15 +117,20 @@ app build/hello-world.wasm - messaging: publisher, subscriber, multipublisher-subscriber - modbus-client - sensor-rng + ### Board-Specific Samples + - arduino_portenta_h7: blinky-h7 - b_u585i_iot02a: sensor, sensor-IMU, modbus-server, blinky-xmas, blinky-u585, blinky-button -These demonstrate hardware-specific integrations while still leveraging the common ocre-api. + These demonstrate hardware-specific integrations while still leveraging the common ocre-api. + ## SDK Highlights + - Header and source-based SDK (ocre-api) - Modular CMake-based build system - Runtime execution via Ocre Runtime - Extensible for new boards and applications ## Contributing + Want to add a new board or example? Fork the repo, create your sample under generic/ or board_specific/, and submit a pull request. Contributions are welcome From cbdd120203e645383f75fd38db98c5d3d6ede7fc Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sat, 21 Mar 2026 17:32:04 +0100 Subject: [PATCH 05/12] build: refactor testing containers Signed-off-by: Marco Casaroli --- testing/CMakeLists.txt | 11 ----------- testing/print_args/CMakeLists.txt | 7 +++++++ testing/{print_args.c => print_args/main.c} | 0 testing/pthread/CMakeLists.txt | 7 +++++++ testing/{pthread.c => pthread/main.c} | 0 testing/return0/CMakeLists.txt | 7 +++++++ testing/{return0.c => return0/main.c} | 0 testing/return1/CMakeLists.txt | 7 +++++++ testing/{return1.c => return1/main.c} | 0 testing/sleep5_return0/CMakeLists.txt | 7 +++++++ testing/{sleep_5_return_0.c => sleep5_return0/main.c} | 0 11 files changed, 35 insertions(+), 11 deletions(-) delete mode 100644 testing/CMakeLists.txt create mode 100644 testing/print_args/CMakeLists.txt rename testing/{print_args.c => print_args/main.c} (100%) create mode 100644 testing/pthread/CMakeLists.txt rename testing/{pthread.c => pthread/main.c} (100%) create mode 100644 testing/return0/CMakeLists.txt rename testing/{return0.c => return0/main.c} (100%) create mode 100644 testing/return1/CMakeLists.txt rename testing/{return1.c => return1/main.c} (100%) create mode 100644 testing/sleep5_return0/CMakeLists.txt rename testing/{sleep_5_return_0.c => sleep5_return0/main.c} (100%) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt deleted file mode 100644 index ae37173..0000000 --- a/testing/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.20.0) - -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../scripts/wasm32-wasi-pthread.cmake) - -project(testing) - -add_executable(print_args.wasm print_args.c) -add_executable(pthread.wasm pthread.c) -add_executable(return0.wasm return0.c) -add_executable(return1.wasm return1.c) -add_executable(sleep_5_return_0.wasm sleep_5_return_0.c) diff --git a/testing/print_args/CMakeLists.txt b/testing/print_args/CMakeLists.txt new file mode 100644 index 0000000..8cf59d7 --- /dev/null +++ b/testing/print_args/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20.0) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) + +project(print_args) + +add_executable(print_args.wasm main.c) diff --git a/testing/print_args.c b/testing/print_args/main.c similarity index 100% rename from testing/print_args.c rename to testing/print_args/main.c diff --git a/testing/pthread/CMakeLists.txt b/testing/pthread/CMakeLists.txt new file mode 100644 index 0000000..b1772ea --- /dev/null +++ b/testing/pthread/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20.0) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) + +project(pthread) + +add_executable(pthread.wasm main.c) diff --git a/testing/pthread.c b/testing/pthread/main.c similarity index 100% rename from testing/pthread.c rename to testing/pthread/main.c diff --git a/testing/return0/CMakeLists.txt b/testing/return0/CMakeLists.txt new file mode 100644 index 0000000..935faff --- /dev/null +++ b/testing/return0/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20.0) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) + +project(return0) + +add_executable(return0.wasm main.c) diff --git a/testing/return0.c b/testing/return0/main.c similarity index 100% rename from testing/return0.c rename to testing/return0/main.c diff --git a/testing/return1/CMakeLists.txt b/testing/return1/CMakeLists.txt new file mode 100644 index 0000000..7bd3d58 --- /dev/null +++ b/testing/return1/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20.0) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) + +project(return1) + +add_executable(return1.wasm main.c) diff --git a/testing/return1.c b/testing/return1/main.c similarity index 100% rename from testing/return1.c rename to testing/return1/main.c diff --git a/testing/sleep5_return0/CMakeLists.txt b/testing/sleep5_return0/CMakeLists.txt new file mode 100644 index 0000000..3ad1c6c --- /dev/null +++ b/testing/sleep5_return0/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20.0) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) + +project(sleep5_return0) + +add_executable(sleep5_return0.wasm main.c) diff --git a/testing/sleep_5_return_0.c b/testing/sleep5_return0/main.c similarity index 100% rename from testing/sleep_5_return_0.c rename to testing/sleep5_return0/main.c From 66948a6f467986ee1ec3b6b6f13ab85882a96520 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sat, 21 Mar 2026 18:56:09 +0100 Subject: [PATCH 06/12] build: ocre-sdk Signed-off-by: Marco Casaroli --- ocre-sdk/CMakeLists.txt | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ocre-sdk/CMakeLists.txt b/ocre-sdk/CMakeLists.txt index dfbb8e8..788fa35 100644 --- a/ocre-sdk/CMakeLists.txt +++ b/ocre-sdk/CMakeLists.txt @@ -1,9 +1,22 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) -project(ocre_api LANGUAGES C) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../scripts/wasm32-wasi-pthread.cmake) + +project(ocre-sdk) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +if (NOT WAMR_ROOT) + set(WAMR_ROOT "${CMAKE_CURRENT_LIST_DIR}/../wasm-micro-runtime") +endif() + +# WAMR Sockets lib +add_library(socket_wasi_ext STATIC ${WAMR_ROOT}/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c) +target_include_directories(socket_wasi_ext PUBLIC ${WAMR_ROOT}/core/iwasm/libraries/lib-socket/inc) +install(TARGETS socket_wasi_ext DESTINATION ${WASI_SYSROOT}/lib/${triple}) +install(FILES ${WAMR_ROOT}/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h DESTINATION ${WASI_SYSROOT}/include/${triple}/) + +# Ocre API add_library(ocre_api STATIC ocre_api.c) -target_include_directories(ocre_api PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_compile_options(ocre_api PRIVATE -O3 -Wall -Wextra -Wno-unused-parameter -Wno-unknown-attributes) -install(TARGETS ocre_api ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) -install(FILES ocre_api.h DESTINATION include) \ No newline at end of file +install(TARGETS ocre_api DESTINATION ${WASI_SYSROOT}/lib/${triple}) +install(FILES ocre_api.h DESTINATION ${WASI_SYSROOT}/include/${triple}) From 4984bdea669f347254112a865d5eee498bde47af Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sun, 22 Mar 2026 12:03:29 +0100 Subject: [PATCH 07/12] build: print WAMR_ROOT location Signed-off-by: Marco Casaroli --- ocre-sdk/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ocre-sdk/CMakeLists.txt b/ocre-sdk/CMakeLists.txt index 788fa35..9ecad22 100644 --- a/ocre-sdk/CMakeLists.txt +++ b/ocre-sdk/CMakeLists.txt @@ -10,6 +10,8 @@ if (NOT WAMR_ROOT) set(WAMR_ROOT "${CMAKE_CURRENT_LIST_DIR}/../wasm-micro-runtime") endif() +message(STATUS "Using WAMR ROOT: ${WAMR_ROOT}") + # WAMR Sockets lib add_library(socket_wasi_ext STATIC ${WAMR_ROOT}/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c) target_include_directories(socket_wasi_ext PUBLIC ${WAMR_ROOT}/core/iwasm/libraries/lib-socket/inc) From e8b4c76820c0b1b72d5f49ba7e8ff0f66c823bc7 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sun, 22 Mar 2026 12:03:07 +0100 Subject: [PATCH 08/12] ci: add build Signed-off-by: Marco Casaroli --- .github/workflows/build.yml | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..766f31c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +# @copyright Copyright (c) contributors to Project Ocre, +# which has been established as Project Ocre a Series of LF Projects, LLC +# +# SPDX-License-Identifier: Apache-2.0 + +name: Build Samples + +on: + pull_request: + push: + branches: + - main + workflow_dispatch: + inputs: + devcontainer-tag: + description: "Devcontainer tag" + required: false + default: "latest" + type: string + +concurrency: + group: ${{ github.repository }}-${{ github.workflow }}@build-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build Samples + runs-on: "ubuntu-22.04" + container: + image: ghcr.io/project-ocre/ocre-runtime/devcontainer-linux:${{ inputs.devcontainer-tag || 'latest'}} + options: --user 1001:127 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Configure + run: | + mkdir build && cd build + cmake .. + make From a65e2988a45838827cb45da3092ec512df6f75f0 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Mon, 23 Mar 2026 15:51:08 +0100 Subject: [PATCH 09/12] build: use wasi-sdk Signed-off-by: Marco Casaroli --- CMakeLists.txt | 50 ------------------- .../blinky-h7/CMakeLists.txt | 8 +-- .../blinky-button/CMakeLists.txt | 2 +- .../b_u585i_iot02a/blinky-u585/CMakeLists.txt | 2 +- .../b_u585i_iot02a/blinky-xmas/CMakeLists.txt | 2 +- .../modbus-server/CMakeLists.txt | 2 +- .../b_u585i_iot02a/sensor-IMU/CMakeLists.txt | 2 +- .../b_u585i_iot02a/sensor/CMakeLists.txt | 2 +- generic/big-sample/CMakeLists.txt | 2 +- generic/blinky-board-generic/CMakeLists.txt | 4 +- generic/blinky/CMakeLists.txt | 4 +- generic/echo-server/CMakeLists.txt | 4 +- generic/filesystem-full/CMakeLists.txt | 2 +- generic/filesystem/CMakeLists.txt | 2 +- generic/hello-world/CMakeLists.txt | 2 +- generic/log_mirror_forwarder/CMakeLists.txt | 4 +- .../publisher_inside/CMakeLists.txt | 4 +- .../publisher_outside/CMakeLists.txt | 4 +- .../subscriber_temp/CMakeLists.txt | 4 +- generic/messaging/publisher/CMakeLists.txt | 4 +- generic/messaging/subscriber/CMakeLists.txt | 4 +- generic/modbus-client/CMakeLists.txt | 4 +- generic/sensor-rng/CMakeLists.txt | 4 +- .../shared-filesystem-reader/CMakeLists.txt | 4 +- .../shared-filesystem-writer/CMakeLists.txt | 4 +- generic/webserver-complex/CMakeLists.txt | 4 +- generic/webserver/CMakeLists.txt | 4 +- ocre-sdk/CMakeLists.txt | 7 +-- ocre.cmake | 3 ++ scripts/Platform/WASI.cmake | 1 - scripts/wasm32-wasi-pthread.cmake | 33 ------------ testing/print_args/CMakeLists.txt | 2 +- testing/pthread/CMakeLists.txt | 2 +- testing/return0/CMakeLists.txt | 2 +- testing/return1/CMakeLists.txt | 2 +- testing/sleep5_return0/CMakeLists.txt | 2 +- 36 files changed, 68 insertions(+), 124 deletions(-) create mode 100644 ocre.cmake delete mode 100644 scripts/Platform/WASI.cmake delete mode 100644 scripts/wasm32-wasi-pthread.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 80639e1..ef16ec6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,161 +4,116 @@ project(ocre-sdk) set(CMAKE_VERBOSE_MAKEFILE TRUE) -make_directory(${CMAKE_CURRENT_LIST_DIR}/sysroot) - include(ExternalProject) -ExternalProject_Add(wasi-sysroot - URL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-32/wasi-sysroot-32.0.tar.gz - URL_HASH SHA256=f2537f6e5804f7f24e32dd140e9371e9670a9fd2646b6a813ddb896b29954b12 - DOWNLOAD_EXTRACT_TIMESTAMP FALSE - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND cp -r ../wasi-sysroot/. ${CMAKE_CURRENT_LIST_DIR}/sysroot -) - -ExternalProject_Add(ocre-sdk - SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/ocre-sdk - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" - CMAKE_ARGS "-DWAMR_ROOT:STRING=${WAMR_ROOT}" - DEPENDS wasi-sysroot -) - -add_custom_target(sysroot - DEPENDS - wasi-sysroot - ocre-sdk -) - -# Containers make_directory(${CMAKE_CURRENT_BINARY_DIR}/dist) -# Generic Samples - ExternalProject_Add(big-sample SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/big-sample CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp big-sample.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(blinky SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/blinky CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp blinky.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(blinky-board-generic SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/blinky-board-generic CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp blinky-board-generic.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(echo-server SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/echo-server CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp echo-server.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(filesystem SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/filesystem CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp filesystem.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(filesystem-full SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/filesystem-full CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp filesystem-full.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(hello-world SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/hello-world CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp hello-world.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(log_mirror_forwarder SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/log_mirror_forwarder CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp syslog_webserver.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(publisher SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/publisher CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp publisher.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(subscriber SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/subscriber CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp subscriber.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(publisher_inside SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/publisher_inside CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp publisher_inside.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(publisher_outside SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/publisher_outside CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp publisher_outside.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(subscriber_temp SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/subscriber_temp CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp subscriber_temp.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(modbus-client SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/modbus-client CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp modbus-client.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(shared-filesystem-reader SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/shared-filesystem/shared-filesystem-reader CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp shared-filesystem-reader.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(shared-filesystem-writer SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/shared-filesystem/shared-filesystem-writer CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp shared-filesystem-writer.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(webserver SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/webserver CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp webserver.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(webserver-complex SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/webserver-complex CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp webserver-complex.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) # Testing @@ -167,33 +122,28 @@ ExternalProject_Add(print_args SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/print_args CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp print_args.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(pthread SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/pthread CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp pthread.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(return0 SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/return0 CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp return0.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(return1 SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/return1 CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp return1.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) ExternalProject_Add(sleep5_return0 SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/sleep5_return0 CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" INSTALL_COMMAND cp sleep5_return0.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist - DEPENDS ocre-sdk ) diff --git a/board_specific/arduino_portenta_h7/blinky-h7/CMakeLists.txt b/board_specific/arduino_portenta_h7/blinky-h7/CMakeLists.txt index f2480f6..63425dd 100644 --- a/board_specific/arduino_portenta_h7/blinky-h7/CMakeLists.txt +++ b/board_specific/arduino_portenta_h7/blinky-h7/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 3.20.0) -# Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) +# Set the WASI SDK toolchain file +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) -# Set the project name (needs to come after the toolchain file) +# Set the project name (needs to come after the toolchain file) set(APPNAME blinky-h7) project(${APPNAME}) -# Set the linker flags +# Set the linker flags set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") # Set compilation flags diff --git a/board_specific/b_u585i_iot02a/blinky-button/CMakeLists.txt b/board_specific/b_u585i_iot02a/blinky-button/CMakeLists.txt index b46a007..65c40ad 100644 --- a/board_specific/b_u585i_iot02a/blinky-button/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/blinky-button/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) set(APPNAME blinky-button) project(${APPNAME} LANGUAGES C) diff --git a/board_specific/b_u585i_iot02a/blinky-u585/CMakeLists.txt b/board_specific/b_u585i_iot02a/blinky-u585/CMakeLists.txt index 7b33654..9d33684 100644 --- a/board_specific/b_u585i_iot02a/blinky-u585/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/blinky-u585/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) set(APPNAME blinky-u585) project(${APPNAME} LANGUAGES C) diff --git a/board_specific/b_u585i_iot02a/blinky-xmas/CMakeLists.txt b/board_specific/b_u585i_iot02a/blinky-xmas/CMakeLists.txt index 8e5c6e3..3fd45af 100644 --- a/board_specific/b_u585i_iot02a/blinky-xmas/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/blinky-xmas/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) set(APPNAME blinky-xmas) project(${APPNAME} LANGUAGES C) diff --git a/board_specific/b_u585i_iot02a/modbus-server/CMakeLists.txt b/board_specific/b_u585i_iot02a/modbus-server/CMakeLists.txt index 57d7abd..8e99a8d 100644 --- a/board_specific/b_u585i_iot02a/modbus-server/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/modbus-server/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.20.0) # Set the WASI SDK toolchain file -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk-p1.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) set(CMAKE_BUILD_TYPE Release) diff --git a/board_specific/b_u585i_iot02a/sensor-IMU/CMakeLists.txt b/board_specific/b_u585i_iot02a/sensor-IMU/CMakeLists.txt index 625f9ca..261d74f 100644 --- a/board_specific/b_u585i_iot02a/sensor-IMU/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/sensor-IMU/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) set(APPNAME sensor-imu) project(${APPNAME} LANGUAGES C) diff --git a/board_specific/b_u585i_iot02a/sensor/CMakeLists.txt b/board_specific/b_u585i_iot02a/sensor/CMakeLists.txt index 994fcea..9fba652 100644 --- a/board_specific/b_u585i_iot02a/sensor/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/sensor/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) set(APPNAME sensor) project(${APPNAME} LANGUAGES C) diff --git a/generic/big-sample/CMakeLists.txt b/generic/big-sample/CMakeLists.txt index 10e0e9b..86de480 100644 --- a/generic/big-sample/CMakeLists.txt +++ b/generic/big-sample/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(big-sample) diff --git a/generic/blinky-board-generic/CMakeLists.txt b/generic/blinky-board-generic/CMakeLists.txt index 564a462..b892865 100644 --- a/generic/blinky-board-generic/CMakeLists.txt +++ b/generic/blinky-board-generic/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) + +add_subdirectory(../../ocre-sdk ocre-sdk) project(blinky-board-generic) diff --git a/generic/blinky/CMakeLists.txt b/generic/blinky/CMakeLists.txt index 7ca7ede..b2ec9b3 100644 --- a/generic/blinky/CMakeLists.txt +++ b/generic/blinky/CMakeLists.txt @@ -1,11 +1,13 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(blinky) add_executable(blinky.wasm main.c) +add_subdirectory(../../ocre-sdk ocre-sdk) + target_link_libraries(blinky.wasm PUBLIC ocre_api diff --git a/generic/echo-server/CMakeLists.txt b/generic/echo-server/CMakeLists.txt index dd23f53..d13f9a5 100644 --- a/generic/echo-server/CMakeLists.txt +++ b/generic/echo-server/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) + +add_subdirectory(../../ocre-sdk ocre-sdk) project(echo-server) diff --git a/generic/filesystem-full/CMakeLists.txt b/generic/filesystem-full/CMakeLists.txt index 8ea255d..05c3aa9 100644 --- a/generic/filesystem-full/CMakeLists.txt +++ b/generic/filesystem-full/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(filesystem-full) diff --git a/generic/filesystem/CMakeLists.txt b/generic/filesystem/CMakeLists.txt index ae79888..9a87c2e 100644 --- a/generic/filesystem/CMakeLists.txt +++ b/generic/filesystem/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(filesystem) diff --git a/generic/hello-world/CMakeLists.txt b/generic/hello-world/CMakeLists.txt index a055a6c..96456b3 100644 --- a/generic/hello-world/CMakeLists.txt +++ b/generic/hello-world/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(hello-world) diff --git a/generic/log_mirror_forwarder/CMakeLists.txt b/generic/log_mirror_forwarder/CMakeLists.txt index 9deec8e..2a70f00 100644 --- a/generic/log_mirror_forwarder/CMakeLists.txt +++ b/generic/log_mirror_forwarder/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) + +add_subdirectory(../../ocre-sdk ocre-sdk) project(syslog_webserver) diff --git a/generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt b/generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt index f0130f0..055899a 100644 --- a/generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt +++ b/generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../../ocre.cmake) + +add_subdirectory(../../../../ocre-sdk ocre-sdk) project(publisher_inside) diff --git a/generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt b/generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt index 8a93d4e..c23c20f 100644 --- a/generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt +++ b/generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../../ocre.cmake) + +add_subdirectory(../../../../ocre-sdk ocre-sdk) project(publisher_outside) diff --git a/generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt b/generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt index 02c9e4c..6fdfacb 100644 --- a/generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt +++ b/generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../../ocre.cmake) + +add_subdirectory(../../../../ocre-sdk ocre-sdk) project(subscriber_temp) diff --git a/generic/messaging/publisher/CMakeLists.txt b/generic/messaging/publisher/CMakeLists.txt index bbe4ff5..fb6bb0d 100644 --- a/generic/messaging/publisher/CMakeLists.txt +++ b/generic/messaging/publisher/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) + +add_subdirectory(../../../ocre-sdk ocre-sdk) project(publisher) diff --git a/generic/messaging/subscriber/CMakeLists.txt b/generic/messaging/subscriber/CMakeLists.txt index db1cedd..4a66910 100644 --- a/generic/messaging/subscriber/CMakeLists.txt +++ b/generic/messaging/subscriber/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) + +add_subdirectory(../../../ocre-sdk ocre-sdk) project(subscriber) diff --git a/generic/modbus-client/CMakeLists.txt b/generic/modbus-client/CMakeLists.txt index 1577787..ecef426 100644 --- a/generic/modbus-client/CMakeLists.txt +++ b/generic/modbus-client/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) + +add_subdirectory(../../ocre-sdk ocre-sdk) project(modbus-client) diff --git a/generic/sensor-rng/CMakeLists.txt b/generic/sensor-rng/CMakeLists.txt index b89dd20..6ef1d9a 100644 --- a/generic/sensor-rng/CMakeLists.txt +++ b/generic/sensor-rng/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) + +add_subdirectory(../../ocre-sdk ocre-sdk) project(sensor-rng) diff --git a/generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt b/generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt index 8e61bb3..3fc0125 100644 --- a/generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt +++ b/generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) + +add_subdirectory(../../../ocre-sdk ocre-sdk) project(shared-filesystem-reader) diff --git a/generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt b/generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt index a272ce5..f8e7911 100644 --- a/generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt +++ b/generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) + +add_subdirectory(../../../ocre-sdk ocre-sdk) project(shared-filesystem-writer) diff --git a/generic/webserver-complex/CMakeLists.txt b/generic/webserver-complex/CMakeLists.txt index 07a90a8..349d5af 100644 --- a/generic/webserver-complex/CMakeLists.txt +++ b/generic/webserver-complex/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) + +add_subdirectory(../../ocre-sdk ocre-sdk) project(webserver-complex) diff --git a/generic/webserver/CMakeLists.txt b/generic/webserver/CMakeLists.txt index a5f9227..cf33dba 100644 --- a/generic/webserver/CMakeLists.txt +++ b/generic/webserver/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) + +add_subdirectory(../../ocre-sdk ocre-sdk) project(webserver) diff --git a/ocre-sdk/CMakeLists.txt b/ocre-sdk/CMakeLists.txt index 9ecad22..4a6c2d5 100644 --- a/ocre-sdk/CMakeLists.txt +++ b/ocre-sdk/CMakeLists.txt @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../scripts/wasm32-wasi-pthread.cmake) - project(ocre-sdk) set(CMAKE_VERBOSE_MAKEFILE TRUE) @@ -15,10 +13,7 @@ message(STATUS "Using WAMR ROOT: ${WAMR_ROOT}") # WAMR Sockets lib add_library(socket_wasi_ext STATIC ${WAMR_ROOT}/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c) target_include_directories(socket_wasi_ext PUBLIC ${WAMR_ROOT}/core/iwasm/libraries/lib-socket/inc) -install(TARGETS socket_wasi_ext DESTINATION ${WASI_SYSROOT}/lib/${triple}) -install(FILES ${WAMR_ROOT}/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h DESTINATION ${WASI_SYSROOT}/include/${triple}/) # Ocre API add_library(ocre_api STATIC ocre_api.c) -install(TARGETS ocre_api DESTINATION ${WASI_SYSROOT}/lib/${triple}) -install(FILES ocre_api.h DESTINATION ${WASI_SYSROOT}/include/${triple}) +target_include_directories(ocre_api PUBLIC ${CMAKE_CURRENT_LIST_DIR}) diff --git a/ocre.cmake b/ocre.cmake new file mode 100644 index 0000000..8efb980 --- /dev/null +++ b/ocre.cmake @@ -0,0 +1,3 @@ +set(CMAKE_TOOLCHAIN_FILE /opt/wasi-sdk/share/cmake/wasi-sdk.cmake) + +set(CMAKE_EXE_LINKER_FLAGS "-Wl,--import-memory -Wl,--export-memory -Wl,--strip-all -Wl,--allow-undefined -Wl,--max-memory=4194304") diff --git a/scripts/Platform/WASI.cmake b/scripts/Platform/WASI.cmake deleted file mode 100644 index b49713f..0000000 --- a/scripts/Platform/WASI.cmake +++ /dev/null @@ -1 +0,0 @@ -set(WASI 1) diff --git a/scripts/wasm32-wasi-pthread.cmake b/scripts/wasm32-wasi-pthread.cmake deleted file mode 100644 index 0e8143a..0000000 --- a/scripts/wasm32-wasi-pthread.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# Cmake toolchain description file for the Makefile - -if(NOT WASI_SYSROOT) - set(WASI_SYSROOT "${CMAKE_CURRENT_LIST_DIR}/../sysroot") -endif() - -set(CMAKE_SYSTEM_NAME WASI) -set(CMAKE_SYSTEM_VERSION 1) -set(CMAKE_SYSTEM_PROCESSOR wasm32) - -set(triple wasm32-wasi-threads) - -set(CMAKE_C_FLAGS "-pthread --sysroot=${WASI_SYSROOT}") -set(CMAKE_CXX_FLAGS "-pthread --sysroot=${WASI_SYSROOT}") -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--import-memory -Wl,--export-memory -Wl,--strip-all -Wl,--allow-undefined -Wl,--max-memory=4194304") - -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_ASM_COMPILER clang) -set(CMAKE_AR llvm-ar) -set(CMAKE_RANLIB llvm-ranlib) -set(CMAKE_C_COMPILER_TARGET ${triple}) -set(CMAKE_CXX_COMPILER_TARGET ${triple}) -set(CMAKE_ASM_COMPILER_TARGET ${triple}) - -# Don't look in the sysroot for executables to run during the build -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -# Only look in the sysroot (not in the host paths) for the rest -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) diff --git a/testing/print_args/CMakeLists.txt b/testing/print_args/CMakeLists.txt index 8cf59d7..f70afc4 100644 --- a/testing/print_args/CMakeLists.txt +++ b/testing/print_args/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(print_args) diff --git a/testing/pthread/CMakeLists.txt b/testing/pthread/CMakeLists.txt index b1772ea..d8253d9 100644 --- a/testing/pthread/CMakeLists.txt +++ b/testing/pthread/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(pthread) diff --git a/testing/return0/CMakeLists.txt b/testing/return0/CMakeLists.txt index 935faff..938a2d1 100644 --- a/testing/return0/CMakeLists.txt +++ b/testing/return0/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(return0) diff --git a/testing/return1/CMakeLists.txt b/testing/return1/CMakeLists.txt index 7bd3d58..1a0cf29 100644 --- a/testing/return1/CMakeLists.txt +++ b/testing/return1/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(return1) diff --git a/testing/sleep5_return0/CMakeLists.txt b/testing/sleep5_return0/CMakeLists.txt index 3ad1c6c..ec0286d 100644 --- a/testing/sleep5_return0/CMakeLists.txt +++ b/testing/sleep5_return0/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/../../scripts/wasm32-wasi-pthread.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) project(sleep5_return0) From f6477f3860d58f4dfb0f6aaffec93b7afced8496 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Mon, 23 Mar 2026 15:51:41 +0100 Subject: [PATCH 10/12] Revert "docs: update README" This reverts commit 33f38064b4bacc861b51858091d5f46ff8d073f2. Signed-off-by: Marco Casaroli --- README.md | 109 +++++++++++++++++------------------------------------- 1 file changed, 34 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index fbe1a09..7e87d21 100644 --- a/README.md +++ b/README.md @@ -2,39 +2,28 @@ The Ocre SDK provides a modular C-based API for building portable embedded applications that compile to WebAssembly. It includes both headers and source files, enabling flexible integration across platforms. This repository also contains a wide range of generic and board-specific examples that demonstrate real-world use cases. -All examples are designed to be executed inside the [Ocre Runtime](https://github.com/project-ocre/ocre-runtime), a lightweight WASI-compatible runtime tailored for embedded-style workloads. +All examples are designed to be built using [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) and executed inside the [Ocre Runtime](https://github.com/project-ocre/ocre-runtime), a lightweight WASI-compatible runtime tailored for embedded-style workloads. ## Repository Structure - ``` ├── ocre-api # Core SDK: headers + sources ├── generic # Platform-independent examples - │ ├── blinky, echo-server, filesystem, etc. - │ └── build folders per sample - ├── board_specific # Hardware-targeted examples - │ ├── arduino_portenta_h7 + │ ├── blinky, echo-server, filesystem, etc. + │ └── build folders per sample + ├── board_specific # Hardware-targeted examples + │ ├── arduino_portenta_h7 │ └── b_u585i_iot02a ├── testing # Testing and potentially faulty images. - │ └── return0, return1, pthread, etc. + │ └── return0, return1, pthread, etc. ├── wasm-micro-runtime # External module ``` -## Getting Started - -### System requirements +Each sample includes: +- CMakeLists.txt for build configuration +- A build/ directory (created during compilation) +- Optional subfolders like src/, fs/, or IMU/ depending on the sample -To build the samples, you need LLVM, LLD, Clang 12+, wasm32 runtime libraries. You also need cmake, make and **\***. Install all on an Ubuntu 22 with: - -```sh -sudo apt install \ - cmake \ - clang \ - libclang-rt-dev-wasm32 \ - lld \ - llvm -``` - -Alternatively, you can use the Ocre devcontainer. Check Ocre documentation for more information. +## Getting Started ### Clone the Repository @@ -50,65 +39,40 @@ Or add the SDK as a submodule to your own project: git submodule add https://github.com/project-ocre/ocre-sdk.git ``` -## Set up Sysroot +Make sure the ocre-api folder is accessible to your build system. -The default sysroot can be set up automatically. From the root of this repository: +## Building with wasi-sdk +All examples are designed to compile to .wasm using [wasi-sdk](https://github.com/WebAssembly/wasi-sdk). -```sh -mkdir build -cd build -cmake .. -make sysroot -``` +> **Note:** By default, we expect the WASI SDK toolchain file to be located at: +> +> `/opt/wasi-sdk/share/cmake/wasi-sdk.cmake` +> +> This is typically set in each sample's `CMakeLists.txt`. You can modify this path as needed for your environment. -The `sysroot` Make target will download the wasi-sysroot, then compile `lib_socket_ext` and `ocre_api`, and populate them into the `sysroot` directory on the root of this repository. - -It is also possible to specify a different WAMR root, used for building `lib_socket_ext`, through the `WAMR_ROOT` CMake variable, if you do not want to use the included git submodule: - -```sh -cmake .. -DWAMR_ROOT=~/ocre/wasm-micro-runtime -``` - -## Build Samples - -### From the ocre-sdk build directory - -Alternatively, the `all` Make target will build most of the generic samples and testing containers: - -```sh -make -``` +### Build Instructions +Each sample can be built independently. Here's a generic flow -You can also build a specific sample, for example: - -```sh -make hello-world -``` - -The built files are stord in the `dist` directory inside the current build directory: - -```sh -ls dist +```bash +cd generic/blinky +mkdir -p build && cd build +cmake .. +cmake --build . ``` +This will generate a .wasm binary in the build/ directory. -### From each sample's directory +Repeat the same process for any other sample—whether under generic/ or board_specific/ -Assumming, you already have the sysroot installed into the `sysroot` directory, it is possible to build each sample from their own directory, for example: +## Running with Ocre Runtime +All compiled .wasm samples are compatible with the [Ocre Runtime](https://github.com/project-ocre/ocre-runtime), which provides a lightweight execution environment for WASI modules. -```sh -cd generic/hello-world -mkdir build -cd build -cmake .. -make +Example: +```bash +app build/hello-world.wasm ``` -The built file is stored in the current build directory. - ## Example Categories - ### Generic Samples - - blinky - hello-world - echo-server @@ -117,20 +81,15 @@ The built file is stored in the current build directory. - messaging: publisher, subscriber, multipublisher-subscriber - modbus-client - sensor-rng - ### Board-Specific Samples - - arduino_portenta_h7: blinky-h7 - b_u585i_iot02a: sensor, sensor-IMU, modbus-server, blinky-xmas, blinky-u585, blinky-button - These demonstrate hardware-specific integrations while still leveraging the common ocre-api. - +These demonstrate hardware-specific integrations while still leveraging the common ocre-api. ## SDK Highlights - - Header and source-based SDK (ocre-api) - Modular CMake-based build system - Runtime execution via Ocre Runtime - Extensible for new boards and applications ## Contributing - Want to add a new board or example? Fork the repo, create your sample under generic/ or board_specific/, and submit a pull request. Contributions are welcome From 74ef58c795967bdc71566901cdcff4723a62fbb8 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Mon, 23 Mar 2026 15:59:35 +0100 Subject: [PATCH 11/12] build(board_specific): fix build Signed-off-by: Marco Casaroli --- .../blinky-h7/CMakeLists.txt | 27 +++++--------- .../b_u585i_iot02a/blinky-u585/CMakeLists.txt | 31 +++++----------- .../b_u585i_iot02a/blinky-xmas/CMakeLists.txt | 31 +++++----------- .../modbus-server/CMakeLists.txt | 37 ++++--------------- .../b_u585i_iot02a/sensor-IMU/CMakeLists.txt | 31 +++++----------- .../b_u585i_iot02a/sensor/CMakeLists.txt | 31 +++++----------- 6 files changed, 56 insertions(+), 132 deletions(-) diff --git a/board_specific/arduino_portenta_h7/blinky-h7/CMakeLists.txt b/board_specific/arduino_portenta_h7/blinky-h7/CMakeLists.txt index 63425dd..56f40aa 100644 --- a/board_specific/arduino_portenta_h7/blinky-h7/CMakeLists.txt +++ b/board_specific/arduino_portenta_h7/blinky-h7/CMakeLists.txt @@ -1,23 +1,14 @@ -cmake_minimum_required(VERSION 3.20.0) +cmake_minimum_required (VERSION 3.20.0) -# Set the WASI SDK toolchain file -include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) -# Set the project name (needs to come after the toolchain file) -set(APPNAME blinky-h7) -project(${APPNAME}) +project(blinky-h7) -# Set the linker flags -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") +add_executable(blinky-h7.wasm main.c) -# Set compilation flags -add_compile_options( - -O0 -Wno-unknown-attributes - -O3 - -Wall - -Wextra - -Wno-unused-parameter -) +add_subdirectory(../../../ocre-sdk ocre-sdk) -# Create the executable target -add_executable(${APPNAME}.wasm main.c) +target_link_libraries(blinky-h7.wasm + PUBLIC + ocre_api +) diff --git a/board_specific/b_u585i_iot02a/blinky-u585/CMakeLists.txt b/board_specific/b_u585i_iot02a/blinky-u585/CMakeLists.txt index 9d33684..0321382 100644 --- a/board_specific/b_u585i_iot02a/blinky-u585/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/blinky-u585/CMakeLists.txt @@ -1,25 +1,14 @@ -cmake_minimum_required(VERSION 3.20.0) -include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) -set(APPNAME blinky-u585) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) + +project(blinky-u585) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +add_executable(blinky-u585.wasm main.c) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_subdirectory(../../../ocre-sdk ocre-sdk) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(blinky-u585.wasm + PUBLIC + ocre_api +) diff --git a/board_specific/b_u585i_iot02a/blinky-xmas/CMakeLists.txt b/board_specific/b_u585i_iot02a/blinky-xmas/CMakeLists.txt index 3fd45af..e72b456 100644 --- a/board_specific/b_u585i_iot02a/blinky-xmas/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/blinky-xmas/CMakeLists.txt @@ -1,25 +1,14 @@ -cmake_minimum_required(VERSION 3.20.0) -include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) -set(APPNAME blinky-xmas) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) + +project(blinky-xmas) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +add_executable(blinky-xmas.wasm main.c) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_subdirectory(../../../ocre-sdk ocre-sdk) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(blinky-xmas.wasm + PUBLIC + ocre_api +) diff --git a/board_specific/b_u585i_iot02a/modbus-server/CMakeLists.txt b/board_specific/b_u585i_iot02a/modbus-server/CMakeLists.txt index 8e99a8d..267d1dd 100644 --- a/board_specific/b_u585i_iot02a/modbus-server/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/modbus-server/CMakeLists.txt @@ -1,38 +1,15 @@ cmake_minimum_required (VERSION 3.20.0) -# Set the WASI SDK toolchain file -include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) -set(CMAKE_BUILD_TYPE Release) +project(modbus-server) -set(APPNAME modbus-server) -project(${APPNAME}) +add_executable(modbus-server.wasm main.c mongoose.c) -# Include the WAMR socket library CMake file (adjust path as needed) -include(../../../wasm-micro-runtime/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake) +add_subdirectory(../../../ocre-sdk ocre-sdk) -add_compile_options( -# --target=wasm32-wasm-unknown # Target WebAssembly - -Os -Wno-unknown-attributes -) - -# Set compilation flags -add_link_options( - -Wl,--strip-all # Strip all symbol/debug information from the binary - -Wl,--allow-undefined # Let the ocre api functions be undefined - -z stack-size=16384 - -Wl,--initial-memory=65536 # Minimum size of linear memory\ - -Wl,--max-memory=65536 # Maximum size of linear memory -) - -# Add the ocre-sdk as a subdirectory and build it -add_subdirectory(../../../ocre-sdk ocre-sdk-build) - -add_executable(${APPNAME}.wasm main.c mongoose.c) - -# Include + link the Ocre API and WAMR socket library -target_include_directories(${APPNAME}.wasm PRIVATE - ../../../wasm-micro-runtime/core/iwasm/libraries/lib-socket +target_link_libraries(modbus-server.wasm + PUBLIC ocre_api + socket_wasi_ext ) -target_link_libraries(${APPNAME}.wasm socket_wasi_ext ocre_api) diff --git a/board_specific/b_u585i_iot02a/sensor-IMU/CMakeLists.txt b/board_specific/b_u585i_iot02a/sensor-IMU/CMakeLists.txt index 261d74f..2b8179b 100644 --- a/board_specific/b_u585i_iot02a/sensor-IMU/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/sensor-IMU/CMakeLists.txt @@ -1,25 +1,14 @@ -cmake_minimum_required(VERSION 3.20.0) -include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) -set(APPNAME sensor-imu) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) + +project(sensor-imu) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +add_executable(sensor-imu.wasm main.c) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_subdirectory(../../../ocre-sdk ocre-sdk) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(sensor-imu.wasm + PUBLIC + ocre_api +) diff --git a/board_specific/b_u585i_iot02a/sensor/CMakeLists.txt b/board_specific/b_u585i_iot02a/sensor/CMakeLists.txt index 9fba652..36c9521 100644 --- a/board_specific/b_u585i_iot02a/sensor/CMakeLists.txt +++ b/board_specific/b_u585i_iot02a/sensor/CMakeLists.txt @@ -1,25 +1,14 @@ -cmake_minimum_required(VERSION 3.20.0) -include(${CMAKE_CURRENT_LIST_DIR}/../../ocre.cmake) -set(APPNAME sensor) -project(${APPNAME} LANGUAGES C) +cmake_minimum_required (VERSION 3.20.0) -set(CMAKE_EXE_LINKER_FLAGS "-Wl,--strip-all -Wl,--allow-undefined") -add_compile_options( - -O3 - -Wall - -Wextra - -Wno-unused-parameter - -Wno-unknown-attributes -) +include(${CMAKE_CURRENT_LIST_DIR}/../../../ocre.cmake) + +project(sensor) -# Add the ocre-sdk as a subdirectory and build it -set(OCRE_SDK_PATH "../../../ocre-sdk") -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${OCRE_SDK_PATH}/CMakeLists.txt") - message(FATAL_ERROR "ocre-sdk not found at ${OCRE_SDK_PATH}. Please ensure the ocre-sdk directory exists and contains CMakeLists.txt") -endif() +add_executable(sensor.wasm main.c) -add_subdirectory(${OCRE_SDK_PATH} ocre-sdk-build) +add_subdirectory(../../../ocre-sdk ocre-sdk) -add_executable(${APPNAME}.wasm main.c) -target_include_directories(${APPNAME}.wasm PRIVATE ocre_api) -target_link_libraries(${APPNAME}.wasm PRIVATE ocre_api) +target_link_libraries(sensor.wasm + PUBLIC + ocre_api +) From 15c9963ec3585692dc309352ad4914f70ad496c9 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Mon, 23 Mar 2026 17:55:16 +0100 Subject: [PATCH 12/12] build: pass WAMR_ROOT to samples Signed-off-by: Marco Casaroli --- CMakeLists.txt | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef16ec6..06a70fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,109 +10,109 @@ make_directory(${CMAKE_CURRENT_BINARY_DIR}/dist) ExternalProject_Add(big-sample SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/big-sample - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp big-sample.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(blinky SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/blinky - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp blinky.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(blinky-board-generic SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/blinky-board-generic - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp blinky-board-generic.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(echo-server SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/echo-server - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp echo-server.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(filesystem SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/filesystem - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp filesystem.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(filesystem-full SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/filesystem-full - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp filesystem-full.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(hello-world SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/hello-world - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp hello-world.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(log_mirror_forwarder SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/log_mirror_forwarder - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp syslog_webserver.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(publisher SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/publisher - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp publisher.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(subscriber SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/subscriber - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp subscriber.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(publisher_inside SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/publisher_inside - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp publisher_inside.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(publisher_outside SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/publisher_outside - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp publisher_outside.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(subscriber_temp SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/messaging/multipublisher-subscriber/subscriber_temp - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp subscriber_temp.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(modbus-client SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/modbus-client - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp modbus-client.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(shared-filesystem-reader SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/shared-filesystem/shared-filesystem-reader - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp shared-filesystem-reader.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(shared-filesystem-writer SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/shared-filesystem/shared-filesystem-writer - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp shared-filesystem-writer.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(webserver SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/webserver - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp webserver.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(webserver-complex SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/generic/webserver-complex - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp webserver-complex.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) @@ -120,30 +120,30 @@ ExternalProject_Add(webserver-complex ExternalProject_Add(print_args SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/print_args - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp print_args.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(pthread SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/pthread - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp pthread.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(return0 SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/return0 - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp return0.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(return1 SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/return1 - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp return1.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist ) ExternalProject_Add(sleep5_return0 SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/testing/sleep5_return0 - CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + CMAKE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DWAMR_ROOT:STRING=${WAMR_ROOT}" INSTALL_COMMAND cp sleep5_return0.wasm ${CMAKE_CURRENT_BINARY_DIR}/dist )