Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .devcontainer/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
clang-format \
clang-tools \
libclang-rt-dev \
libclang-rt-dev-wasm32 \
lld \
llvm \
net-tools \
sudo \
Expand All @@ -42,10 +44,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean -y\
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 50

# Install wasi-sdk
RUN mkdir /opt/wasi-sdk && \
curl -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-$(uname -m | sed s/aarch64/arm64/)-linux.tar.gz | \
tar zxvf - --strip-components=1 -C /opt/wasi-sdk
# Install wasi-sysroot
RUN mkdir /opt/wasi-sysroot && \
curl -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sysroot-$WASI_SDK_VERSION.0.tar.gz | \
tar zxvf - --strip-components=1 -C /opt/wasi-sysroot

FROM ocre-ci AS ocre-dev

Expand Down
14 changes: 9 additions & 5 deletions .devcontainer/zephyr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gperf \
gpg \
jq \
libclang-rt-dev-wasm32 \
libmagic1 \
libsdl2-dev \
lld \
llvm \
make \
net-tools \
Expand All @@ -51,10 +53,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean -y\
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 50

# Install wasi-sdk
RUN mkdir /opt/wasi-sdk && \
curl -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-$(uname -m | sed s/aarch64/arm64/)-linux.tar.gz | \
tar zxvf - --strip-components=1 -C /opt/wasi-sdk
# Install wasi-sysroot
RUN mkdir /opt/wasi-sysroot && \
curl -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sysroot-$WASI_SDK_VERSION.0.tar.gz | \
tar zxvf - --strip-components=1 -C /opt/wasi-sysroot

RUN python -m venv /opt/zephyr-venv && \
. /opt/zephyr-venv/bin/activate && \
Expand All @@ -78,7 +80,9 @@ RUN . /opt/zephyr-venv/bin/activate && \
west sdk install --install-base /opt -t \
x86_64-zephyr-elf \
aarch64-zephyr-elf \
arm-zephyr-eabi
arm-zephyr-eabi \
riscv64-zephyr-elf


FROM base AS ocre-ci

Expand Down
45 changes: 10 additions & 35 deletions .github/workflows/hardware-bu585.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,10 @@ jobs:
strategy:
matrix:
sample:
- name: generic-hello-world
path: generic/hello-world
filename: hello-world.wasm
- name: generic-subscriber
path: generic/messaging/subscriber
filename: subscriber.wasm
- name: generic-publisher
path: generic/messaging/publisher
filename: publisher.wasm
- name: generic-blinky
path: generic/blinky
filename: blinky.wasm

# Examples for future images to add
# - name: generic-filesystem-full
# path: generic/filesystem-full
# filename: filesystem-full.wasm
# - name: b_u585i-modbus-server
# path: board_specific/b_u585i_iot02a/modbus-server
# filename: modbus-server.wasm
- hello-world
- subscriber
- publisher
- blinky

steps:
- name: Cleanup workspace
Expand All @@ -80,26 +64,17 @@ jobs:

- name: Build WASM sample
run: |
SAMPLE_DIR=$GITHUB_WORKSPACE/ocre-runtime/ocre-sdk/${{ matrix.sample.path }}
if [ ! -d "$SAMPLE_DIR" ]; then
echo "Directory not found: $SAMPLE_DIR"
exit 1
fi

mkdir -p "$SAMPLE_DIR/build"
cd "$SAMPLE_DIR/build"
cmake .. -DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PATH/share/cmake/wasi-sdk.cmake
make

env:
WASI_SDK_PATH: /opt/wasi-sdk
mkdir -p "ocre-runtime/ocre-sdk/build"
cd "ocre-runtime/ocre-sdk/build"
cmake ..
make ${{ matrix.sample }}

# Saving files to the runner so avoid uploading .wasm files as artifacts individually, uploaded in separate step
- name: Save .wasm artifact locally
if: always()
run: |
mkdir /var/ocre-ci-files/wasm/${{ matrix.sample.name }}/
cp "ocre-runtime/ocre-sdk/${{ matrix.sample.path }}/build/${{ matrix.sample.filename }}" "/var/ocre-ci-files/wasm/${{ matrix.sample.name }}/${{ matrix.sample.filename }}"
mkdir /var/ocre-ci-files/wasm/${{ matrix.sample }}/
cp "ocre-runtime/ocre-sdk/build/dist/${{ matrix.sample }}.wasm" "/var/ocre-ci-files/wasm/${{ matrix.sample }}/${{ matrix.sample }}.wasm"

artifact-wasm-files:
name: Artifact built .wasm Files
Expand Down
9 changes: 6 additions & 3 deletions cmake/state_information.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/var/lib/ocre/images)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/var/lib/ocre/containers)

if(OCRE_SDK_PRELOADED_IMAGES)
string(REPLACE ".wasm" "" OCRE_SDK_PRELOADED_IMAGES_STR "${OCRE_SDK_PRELOADED_IMAGES}")

include(ExternalProject)
ExternalProject_Add(
OcreSampleContainers
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../ocre-sdk"
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/OcreSampleContainers"
BUILD_COMMAND cmake --build . -- ${OCRE_SDK_PRELOADED_IMAGES_STR}
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/OcreSampleContainers/build"
BUILD_ALWAYS TRUE
INSTALL_COMMAND ""
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../ocre-sdk"
CMAKE_ARGS "-DWAMR_ROOT_DIR=${CMAKE_CURRENT_LIST_DIR}/../wasm-micro-runtime" "-DCMAKE_VERBOSE_MAKEFILE=ON"
CMAKE_ARGS "-DWAMR_ROOT:STRING=${CMAKE_CURRENT_LIST_DIR}/../wasm-micro-runtime"
)
endif()

Expand All @@ -31,7 +34,7 @@ foreach(image IN ITEMS ${OCRE_SDK_PRELOADED_IMAGES})
message(STATUS "Adding sdk sample '${image}' to preloaded images")
add_custom_target(${image}
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/OcreSampleContainers/build/${image}
${CMAKE_CURRENT_BINARY_DIR}/OcreSampleContainers/build/dist/${image}
${CMAKE_CURRENT_BINARY_DIR}/var/lib/ocre/images/${image}
DEPENDS OcreSampleContainers
)
Expand Down
2 changes: 1 addition & 1 deletion docs/Devcontainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SPDX-License-Identifier: Apache-2.0 -->

Devcontainers are tools that allows you to create and manage isolated development environments in containers. It provides a consistent and reproducible development environment across different machines and operating systems.

It is the fastest and easiest way to develop Ocre in Linux, macOS, and Windows. As it already comes preinstalled with all the necessary tools for building Ocre and the samples, including wasi-sdk.
It is the fastest and easiest way to develop Ocre in Linux, macOS, and Windows. As it already comes preinstalled with all the necessary tools for building Ocre and the samples, including wasi-sysroot.

More information can be found at [the official Devcontainers documentation](https://containers.dev/).

Expand Down
36 changes: 10 additions & 26 deletions docs/NativeBuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,26 @@ Our reference system is a Ubuntu 24.04 LTS, however these instructions can be ea
### Build Tools

Ocre requires CMake and a C compiler such as GCC. For full testing support, we also use clang.
If we are checking out the Ocre repository, we also need Git to clone Ocre Runtime, and Wget to unpack the WASI-SDK. Install all with:
If we are checking out the Ocre repository, we also need Git to clone Ocre Runtime, and Wget to unpack wasi-sysroot. Install all with:

```sh
sudo apt update -y
sudo apt install -y apt install build-essential git cmake clang wget
sudo apt install -y apt install build-essential git cmake clang wget libclang-rt-dev-wasm32 lld
```

### WASI-SDK
### WASI Sysroot

For building WASM/WASI containers (including the test containers), we need the WASI-SDK.
Download a WASI-P1 compatible WASI-SDK from [the WASI SDK releases page](https://github.com/WebAssembly/wasi-sdk/releases) for your platform. The current recommended version is `wasi-sdk-29`.
For building WASM/WASI containers (including the test containers), we need the WASI Sysroot.
Download wasi-sysroot from [the WASI SDK releases page](https://github.com/WebAssembly/wasi-sdk/releases) for your platform. The current recommended version is `wasi-sysroot-29`.

This is usually installed under `/opt/wasi-sdk` for default easy usage without the need to set environment variables.
This is usually installed under `/opt/wasi-sysroot` for default easy usage without the need to set environment variables.

Download, unpack and install WASI SDK. Note that these are Linux binary packages. Make sure you replace `amd_64` with `arm64` in case your host is ARM64 based:
Download, unpack and install wasi-sysroot:

```sh
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-29/wasi-sdk-29.0-amd_64-linux.tar.gz
tar -xzf wasi-sdk-29.0-amd_64-linux.tar.gz
sudo mv wasi-sdk-29.0-amd_64-linux /opt/wasi-sdk
```

You can check that WASI SDK is properly installed by checking the WASI clang version:

```sh
/opt/wasi-sdk/bin/clang --version
```

The output should be similar to:

```
clang version 21.1.4-wasi-sdk (https://github.com/llvm/llvm-project 222fc11f2b8f25f6a0f4976272ef1bb7bf49521d)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: /opt/wasi-sdk/bin
Configuration file: /opt/wasi-sdk/bin/clang.cfg
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-29/wasi-sysroot-29.0.tar.gz
tar -xzf wasi-sysroot-29.0.tar.gz
sudo mv wasi-sysroot-29.0 /opt/wasi-sysroot
```

## Linux
Expand Down
2 changes: 1 addition & 1 deletion ocre-sdk
Submodule ocre-sdk updated 36 files
+2 −0 .gitignore
+158 −54 CMakeLists.txt
+75 −34 README.md
+3 −19 generic/big-sample/CMakeLists.txt
+7 −20 generic/blinky-board-generic/CMakeLists.txt
+8 −21 generic/blinky/CMakeLists.txt
+7 −18 generic/echo-server/CMakeLists.txt
+11 −19 generic/filesystem-full/CMakeLists.txt
+3 −26 generic/filesystem/CMakeLists.txt
+3 −19 generic/hello-world/CMakeLists.txt
+3 −3 generic/hello-world/main.c
+14 −28 generic/log_mirror_forwarder/CMakeLists.txt
+8 −21 generic/messaging/multipublisher-subscriber/publisher_inside/CMakeLists.txt
+8 −21 generic/messaging/multipublisher-subscriber/publisher_outside/CMakeLists.txt
+8 −21 generic/messaging/multipublisher-subscriber/subscriber_temp/CMakeLists.txt
+8 −21 generic/messaging/publisher/CMakeLists.txt
+8 −21 generic/messaging/subscriber/CMakeLists.txt
+12 −28 generic/modbus-client/CMakeLists.txt
+8 −21 generic/sensor-rng/CMakeLists.txt
+3 −26 generic/shared-filesystem/shared-filesystem-reader/CMakeLists.txt
+3 −26 generic/shared-filesystem/shared-filesystem-writer/CMakeLists.txt
+16 −29 generic/webserver-complex/CMakeLists.txt
+16 −29 generic/webserver/CMakeLists.txt
+19 −6 ocre-sdk/CMakeLists.txt
+1 −0 scripts/Platform/WASI.cmake
+33 −0 scripts/wasm32-wasi-pthread.cmake
+7 −0 testing/print_args/CMakeLists.txt
+0 −0 testing/print_args/main.c
+7 −0 testing/pthread/CMakeLists.txt
+0 −0 testing/pthread/main.c
+7 −0 testing/return0/CMakeLists.txt
+0 −0 testing/return0/main.c
+7 −0 testing/return1/CMakeLists.txt
+0 −0 testing/return1/main.c
+7 −0 testing/sleep5_return0/CMakeLists.txt
+0 −0 testing/sleep5_return0/main.c
2 changes: 1 addition & 1 deletion tests/system/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(CMAKE_C_COMPILER /usr/bin/clang)
list(APPEND OCRE_SDK_PRELOADED_IMAGES
"return0.wasm"
"return1.wasm"
"sleep_5_return_0.wasm"
"sleep5_return0.wasm"
)

if (SANITIZER)
Expand Down
2 changes: 1 addition & 1 deletion tests/system/zephyr/container/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ list(APPEND EXTRA_DTC_OVERLAY_FILE fstab.overlay)
list(APPEND OCRE_SDK_PRELOADED_IMAGES
"return0.wasm"
"return1.wasm"
"sleep_5_return_0.wasm"
"sleep5_return0.wasm"
"hello-world.wasm"
"blinky.wasm"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/system/zephyr/context/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ list(APPEND EXTRA_DTC_OVERLAY_FILE fstab.overlay)
list(APPEND OCRE_SDK_PRELOADED_IMAGES
"return0.wasm"
"return1.wasm"
"sleep_5_return_0.wasm"
"sleep5_return0.wasm"
"hello-world.wasm"
"filesystem.wasm"
"blinky.wasm"
Expand Down
Loading