mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/wamr: add WAMR to provide WASM support in RIOT
* config.cmake configures wamr build * native thumb and mips * riscv support * switchable commit id defaults to main until PR:WIP is removed
This commit is contained in:
parent
617eb359c0
commit
5198dc48c6
60
pkg/wamr/CMakeLists.txt
Normal file
60
pkg/wamr/CMakeLists.txt
Normal file
@ -0,0 +1,60 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
cmake_minimum_required(VERSION 3.8.2)
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
|
||||
project(NONE)
|
||||
|
||||
enable_language (ASM)
|
||||
|
||||
set (WAMR_BUILD_PLATFORM "riot")
|
||||
|
||||
if (DEFINED WAMR_CONFIG)
|
||||
include (${WAMR_CONFIG})
|
||||
endif ()
|
||||
|
||||
# Build as X86_32 by default, change to "AARCH64[sub]", "ARM[sub]", "THUMB[sub]", "MIPS" or "XTENSA"
|
||||
# if we want to support arm, thumb, mips or xtensa
|
||||
if (NOT DEFINED WAMR_BUILD_TARGET)
|
||||
set (WAMR_BUILD_TARGET "X86_32")
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_INTERP)
|
||||
# Enable Interpreter by default
|
||||
set (WAMR_BUILD_INTERP 1)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_AOT)
|
||||
# Disable AOT by default.
|
||||
set (WAMR_BUILD_AOT 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
|
||||
# Enable libc builtin support by default
|
||||
set (WAMR_BUILD_LIBC_BUILTIN 1)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_LIBC_WASI)
|
||||
# Disable libc wasi support by default
|
||||
set (WAMR_BUILD_LIBC_WASI 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_ROOT_DIR)
|
||||
# this assumption is true if this file is copied to WAMR_ROOT
|
||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
||||
|
||||
# need includes from RIOT
|
||||
string(REGEX MATCHALL "([^\ ]+\ |[^\ ]+$)" RIOT_INCLUDES_LIST "${RIOT_INCLUDES}")
|
||||
|
||||
include_directories(SYSTEM ${RIOT_INCLUDES_LIST})
|
||||
|
||||
|
||||
# target_sources( ${WAMR_RUNTIME_LIB_SOURCE} )
|
||||
# executable linking is done by RIOT build system this just builds libwamr.a
|
||||
|
||||
add_library( wamr ${WAMR_RUNTIME_LIB_SOURCE})
|
81
pkg/wamr/Makefile
Normal file
81
pkg/wamr/Makefile
Normal file
@ -0,0 +1,81 @@
|
||||
PKG_NAME=wamr
|
||||
PKG_URL=https://github.com/bytecodealliance/wasm-micro-runtime.git
|
||||
PKG_BLEADING?=1
|
||||
ifeq ($(PKG_BLEADING),1)
|
||||
PKG_VERSION=main
|
||||
else
|
||||
PKG_VERSION=8fd89bd415db73281c8fbd53de1c2726f35b5ddb
|
||||
endif
|
||||
PKG_LICENSE=Apache-2.0
|
||||
|
||||
PKG_CUSTOM_PREPARED = CHECK_VERSION
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
||||
#less Wall TODO: get things fixed upstream
|
||||
CFLAGS := $(filter-out -pedantic, $(CFLAGS))
|
||||
CFLAGS += -Wno-format
|
||||
CFLAGS += -Wno-strict-prototypes
|
||||
CFLAGS += -Wno-old-style-definition
|
||||
CFLAGS += -Wno-cast-function-type
|
||||
|
||||
#Prepapre includes for cmake
|
||||
RIOT_INCLUDES = $(filter-out -%,$(subst -I,,$(INCLUDES)))
|
||||
|
||||
#translate (CPU_ARCH) to Build Target
|
||||
#WAMR_BUILD_TARGET is "X86_32" "AARCH64[sub]", "ARM[sub]",
|
||||
# "THUMB[sub]", "MIPS" or "XTENSA"
|
||||
#no msp430, no AVR support for now
|
||||
|
||||
ifeq ($(CPU),native)
|
||||
#$(CPU) is defined for every CPU
|
||||
#everyone build on x86_32
|
||||
WAMR_BUILD_TARGET = X86_32
|
||||
else ifeq ($(findstring arm,$(CPU_ARCH)),arm)
|
||||
WAMR_BUILD_TARGET = THUMB
|
||||
else ifeq ($(CPU_ARCH),mips32r2)
|
||||
WAMR_BUILD_TARGET = MIPS
|
||||
else ifeq ($(CPU_ARCH),xtensa)
|
||||
WAMR_BUILD_TARGET = XTENSA
|
||||
else ifeq ($(CPU_ARCH),rv32)
|
||||
WAMR_BUILD_TARGET = RISCV32
|
||||
endif
|
||||
|
||||
ifeq ($(QUIET),0)
|
||||
CMAKEMAKEFLAGS += VERBOSE=1
|
||||
endif
|
||||
|
||||
#WAMR_CONFIG will be included into the cmake
|
||||
ifneq ($(WAMR_CONFIG),)
|
||||
WAMR_CMAKE_FLAGS += "-DWAMR_CONFIG=$(WAMR_CONFIG)"
|
||||
endif
|
||||
|
||||
WAMR_CMAKE_FLAGS += "-DRIOT_INCLUDES=$(RIOT_INCLUDES)"\
|
||||
-DWAMR_BUILD_TARGET=$(WAMR_BUILD_TARGET)\
|
||||
-DWAMR_ROOT_DIR=$(PKG_SOURCE_DIR)/ \
|
||||
-DCMAKE_SYSTEM_NAME=Generic \
|
||||
-DCMAKE_SYSTEM_PROCESSOR="$(MCPU)" \
|
||||
-DCMAKE_C_COMPILER=$(CC) \
|
||||
-DCMAKE_C_COMPILER_WORKS=TRUE \
|
||||
|
||||
all: $(BINDIR)/libwamr.a
|
||||
|
||||
$(BINDIR)/libwamr.a: $(PKG_BUILD_DIR)/libwamr.a
|
||||
cp $< $@
|
||||
|
||||
$(PKG_BUILD_DIR)/libwamr.a: $(PKG_BUILD_DIR)/Makefile
|
||||
+$(MAKE) -C $(PKG_BUILD_DIR) $(CMAKEMAKEFLAGS)
|
||||
|
||||
$(PKG_BUILD_DIR)/Makefile: $(PKG_PREPARED) print_build_target
|
||||
ASMFLAGS="${CFLAGS}" cmake -B$(PKG_BUILD_DIR) $(WAMR_CMAKE_FLAGS)
|
||||
|
||||
print_build_target:
|
||||
@echo PKG_VERSION: $(PKG_VERSION)
|
||||
@echo CPU_ARCH: $(CPU_ARCH)
|
||||
@echo CPU: $(CPU)
|
||||
@echo CFLAGS: $(CFLAGS)
|
||||
@echo WAMR_BUILD_TARGET: $(WAMR_BUILD_TARGET)
|
||||
@echo WAMR_CONFIG: $(WAMR_CONFIG)
|
||||
|
||||
CHECK_VERSION:
|
||||
test -f $(PKG_DOWNLOADED) && (test `cat $(PKG_DOWNLOADED)` = $(PKG_VERSION) || rm $(PKG_DOWNLOADED));true
|
5
pkg/wamr/Makefile.dep
Normal file
5
pkg/wamr/Makefile.dep
Normal file
@ -0,0 +1,5 @@
|
||||
USEMODULE += sema
|
||||
|
||||
#WAMR supports "X86_32/64", "AARCH64", "ARM", "THUMB", "MIPS" and "XTENSA"
|
||||
#no 8/16 Bit TODO: might need to blacklist more
|
||||
FEATURES_BLACKLIST += arch_8bit arch_16bit
|
11
pkg/wamr/Makefile.include
Normal file
11
pkg/wamr/Makefile.include
Normal file
@ -0,0 +1,11 @@
|
||||
IWASM_CORE = $(PKGDIRBASE)/wamr/core
|
||||
IWASM_ROOT = $(IWASM_CORE)/iwasm
|
||||
SHARED_LIB_ROOT = $(IWASM_CORE)/shared
|
||||
|
||||
IWASM_INCLUDES += ${IWASM_ROOT}/include \
|
||||
${SHARED_LIB_ROOT}/platform/include \
|
||||
${SHARED_LIB_ROOT}/platform/riot \
|
||||
|
||||
INCLUDES += $(addprefix -I,${IWASM_INCLUDES})
|
||||
|
||||
ARCHIVES += $(BINDIR)/libwamr.a
|
21
pkg/wamr/config.cmake
Normal file
21
pkg/wamr/config.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
# following line a hints for build options mostly untested
|
||||
# some are not matching RIOTs application targets
|
||||
# they default to off
|
||||
|
||||
# set (WAMR_BUILD_LIBC_WASI 1) #enable libc wasi support
|
||||
# set (WAMR_BUILD_THREAD_MGR 1) #enable thread manager support
|
||||
# set (WAMR_BUILD_APP_FRAMEWORK 1) #enable WAMR app framework support
|
||||
# set (WAMR_BUILD_LIB_PTHREAD 1) #enable pthread support
|
||||
|
||||
# set (WAMR_BUILD_JIT 1) #enable WAMR JIT
|
||||
# set (WAMR_BUILD_FAST_INTERP 1) #enable Fast interpreter
|
||||
# set (WAMR_BUILD_MULTI_MODULE 1) #enable Multiple modules
|
||||
# set (WAMR_BUILD_SPEC_TEST 1) #enable spec test compatible mode is on
|
||||
# set (WAMR_BUILD_BULK_MEMORY 1) #enable Bulk memory feature
|
||||
# set (WAMR_BUILD_SHARED_MEMORY 1) #enable Shared memory
|
||||
# set (WAMR_BUILD_MINI_LOADER 1) #enable WASM mini loader
|
||||
# set (WAMR_DISABLE_HW_BOUND_CHECK 1) #enable Hardware boundary check disabled
|
||||
# set (WAMR_BUILD_MEMORY_PROFILING 1) #enable Memory profiling
|
||||
# set (WAMR_APP_THREAD_STACK_SIZE_MAX ${WAMR_APP_THREAD_STACK_SIZE_MAX}) #set maximum thread stack size
|
||||
# set (WAMR_BUILD_CUSTOM_NAME_SECTION 1) #enable Custom name section
|
||||
# set (WAMR_BUILD_TAIL_CALL 1) #enable Tail call
|
6
pkg/wamr/doc.txt
Normal file
6
pkg/wamr/doc.txt
Normal file
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @defgroup pkg_wamr WebAssembly Micro Runtime
|
||||
* @ingroup pkg
|
||||
* @brief Provides WebAssembly support for RIOT
|
||||
* @see https://github.com/bytecodealliance/wasm-micro-runtime
|
||||
*/
|
Loading…
Reference in New Issue
Block a user