-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup: better ESP32 support, make build options configurable (#7)
- Loading branch information
Showing
10 changed files
with
582 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# extism-wamr as ESP-IDF component | ||
|
||
You can build an ESP-IDF project with extism-wamr as a component: | ||
|
||
- Make sure you have the ESP-IDF properly installed and setup | ||
- In particular have the following paths set: | ||
- `EXTISM_WAMR_PATH` to point to your wamr-sdk repository | ||
- `IDF_PATH` to point to your ESP-IDF | ||
- `source $IDF_PATH/export.sh` | ||
- Create a new project, e.g.: `idf.py create-project wamr-hello` | ||
- In the newly created project folder edit the `CMakeList.txt`: | ||
|
||
``` | ||
cmake_minimum_required(VERSION 3.5) | ||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
set (COMPONENTS ${IDF_TARGET} main freertos esptool_py extism-wamr) | ||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{EXTISM_WAMR_PATH}/build-scripts/esp-idf") | ||
project(wamr-hello) | ||
``` | ||
- Develop your project in it's `main` component folder. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Copyright (C) 2021 Intel Corporation and others. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# Set WAMR's build options | ||
|
||
if (NOT CMAKE_BUILD_EARLY_EXPANSION) | ||
|
||
if (CONFIG_IDF_TARGET_ARCH_RISCV) | ||
set (WAMR_BUILD_TARGET "RISCV32") | ||
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA) | ||
set (WAMR_BUILD_TARGET "XTENSA") | ||
else () | ||
message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported") | ||
endif () | ||
|
||
set (WAMR_BUILD_PLATFORM "esp-idf") | ||
|
||
if (CONFIG_WAMR_BUILD_DEBUG) | ||
set (CMAKE_BUILD_TYPE Debug) | ||
else () | ||
set (CMAKE_BUILD_TYPE Release) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_INTERP) | ||
set (WAMR_BUILD_INTERP 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_INTERP_FAST) | ||
set (WAMR_BUILD_FAST_INTERP 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_AOT) | ||
set (WAMR_BUILD_AOT 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_LIBC_BUILTIN) | ||
set (WAMR_BUILD_LIBC_BUILTIN 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_INTERP_LOADER_MINI) | ||
set (WAMR_BUILD_MINI_LOADER 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_MULTI_MODULE) | ||
set (WAMR_BUILD_MULTI_MODULE 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_SHARED_MEMORY) | ||
set (WAMR_BUILD_SHARED_MEMORY 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_MEMORY_PROFILING) | ||
set (WAMR_BUILD_MEMORY_PROFILING 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_PERF_PROFILING) | ||
set (WAMR_BUILD_PERF_PROFILING 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_REF_TYPES) | ||
set (WAMR_BUILD_REF_TYPES 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_LIBC_WASI) | ||
set (WAMR_BUILD_LIBC_WASI 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_LIB_PTHREAD) | ||
set (WAMR_BUILD_LIB_PTHREAD 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_TAIL_CALL) | ||
set (WAMR_BUILD_TAIL_CALL 1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_GC) | ||
set (WAMR_BUILD_GC 1) | ||
endif () | ||
|
||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../wasm-micro-runtime) | ||
set (SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../src) | ||
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) | ||
|
||
list (APPEND srcs "${WAMR_RUNTIME_LIB_SOURCE}" | ||
"${PLATFORM_SHARED_SOURCE}" | ||
"${SRC_DIR}/symbols.c" | ||
"${SRC_DIR}/kernel.c" | ||
"${SRC_DIR}/extism.c" | ||
|
||
) | ||
|
||
set (include_dirs "${IWASM_DIR}/include" | ||
"${UTILS_SHARED_DIR}" | ||
"${PLATFORM_SHARED_DIR}" | ||
"${PLATFORM_SHARED_DIR}/../include" | ||
"${IWASM_COMMON_DIR}" | ||
"${SRC_DIR}" | ||
) | ||
endif () | ||
|
||
|
||
|
||
idf_component_register(SRCS ${srcs} | ||
INCLUDE_DIRS ${include_dirs} | ||
REQUIRES pthread lwip esp_timer | ||
KCONFIG ${CMAKE_CURRENT_LIST_DIR}/Kconfig) | ||
|
||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") | ||
|
||
if (CONFIG_IDF_TARGET_ARCH_RISCV) | ||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1) | ||
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA) | ||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_XTENSA=1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_AOT) | ||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DWASM_ENABLE_AOT=1) | ||
endif () | ||
|
||
if (CONFIG_WAMR_ENABLE_INTERP) | ||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DWASM_ENABLE_INTERP=1) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
menu "Extism WAMR" | ||
choice WAMR_BUILD_TYPE | ||
prompt "Build type" | ||
default WAMR_BUILD_RELEASE | ||
|
||
config WAMR_BUILD_RELEASE | ||
bool "Release" | ||
|
||
config WAMR_BUILD_DEBUG | ||
bool "Debug" | ||
endchoice | ||
|
||
config WAMR_ENABLE_AOT | ||
bool "AOT" | ||
default n | ||
|
||
menuconfig WAMR_ENABLE_INTERP | ||
bool "Interpreter" | ||
default y | ||
|
||
if WAMR_ENABLE_INTERP | ||
|
||
choice WAMR_INTERP_MODE | ||
prompt "Interpreter mode" | ||
default WAMR_INTERP_FAST | ||
|
||
config WAMR_INTERP_CLASSIC | ||
bool "Classic" | ||
|
||
config WAMR_INTERP_FAST | ||
bool "Fast" | ||
endchoice | ||
|
||
choice WAMR_INTERP_LOADER_MODE | ||
prompt "Loader mode" | ||
default WAMR_INTERP_LOADER_NORMAL | ||
|
||
config WAMR_INTERP_LOADER_NORMAL | ||
bool "Normal" | ||
|
||
config WAMR_INTERP_LOADER_MINI | ||
bool "Mini" | ||
endchoice | ||
endif | ||
|
||
config WAMR_ENABLE_LIB_PTHREAD | ||
bool "Lib pthread" | ||
default y | ||
|
||
config WAMR_ENABLE_LIBC_BUILTIN | ||
bool "Libc builtin" | ||
default y | ||
|
||
config WAMR_ENABLE_LIBC_WASI | ||
bool "Libc WASI" | ||
default y | ||
|
||
config WAMR_ENABLE_MEMORY_PROFILING | ||
bool "Memory profiling" | ||
default n | ||
|
||
config WAMR_ENABLE_MULTI_MODULE | ||
bool "Multi module" | ||
default y | ||
|
||
config WAMR_ENABLE_PERF_PROFILING | ||
bool "Performance profiling" | ||
default n | ||
|
||
config WAMR_ENABLE_REF_TYPES | ||
bool "Reference types" | ||
default y | ||
|
||
config WAMR_ENABLE_SHARED_MEMORY | ||
bool "Shared memory" | ||
default n | ||
|
||
config WAMR_ENABLE_GC | ||
bool "GC" | ||
default n | ||
|
||
config WAMR_ENABLE_TAIL_CALL | ||
bool "Tail calls" | ||
default n | ||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: "2.0.0" | ||
description: Extism WAMR SDK | ||
repository: https://github.com/extism/wamr-sdk | ||
documentation: https://github.com/extism/wamr-sdk | ||
issues: https://github.com/extism/wamr-sdk/issues | ||
dependencies: | ||
idf: ">=4.4" | ||
targets: | ||
- esp32 | ||
- esp32s3 | ||
- esp32c3 | ||
- esp32c6 | ||
# examples: | ||
# - path: product-mini/platforms/esp-idf |
Oops, something went wrong.