mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-06-18 02:59:21 +00:00
Compare commits
No commits in common. "main" and "WAMR-08-10-2021" have entirely different histories.
main
...
WAMR-08-10
142
.clang-format
142
.clang-format
|
@ -1,4 +1,3 @@
|
|||
# using [clang-formt-12 options](https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html)
|
||||
RawStringFormats:
|
||||
- Language: Cpp
|
||||
Delimiters:
|
||||
|
@ -14,23 +13,35 @@ RawStringFormats:
|
|||
- h
|
||||
- hpp
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: Mozilla
|
||||
BasedOnStyle: google
|
||||
- Language: TextProto
|
||||
Delimiters:
|
||||
- pb
|
||||
- PB
|
||||
- proto
|
||||
- PROTO
|
||||
EnclosingFunctions:
|
||||
- EqualsProto
|
||||
- EquivToProto
|
||||
- PARSE_PARTIAL_TEXT_PROTO
|
||||
- PARSE_TEST_PROTO
|
||||
- PARSE_TEXT_PROTO
|
||||
- ParseTextOrDie
|
||||
- ParseTextProtoOrDie
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
|
||||
Language: Cpp
|
||||
BasedOnStyle: Mozilla
|
||||
# 6.1
|
||||
IndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
# 6.2
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
# 6.3
|
||||
ColumnLimit: 80
|
||||
# 6.9
|
||||
AlignAfterOpenBracket: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AlignConsecutiveMacros: true
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: All
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
# 6.10
|
||||
BinPackParameters: false
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
|
@ -49,13 +60,104 @@ BraceWrapping:
|
|||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: true
|
||||
# 6.27
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
|
||||
# additional
|
||||
AlignEscapedNewlines: Left
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
ColumnLimit: 79
|
||||
ContinuationIndentWidth: 2
|
||||
DerivePointerAlignment: false
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 1
|
||||
- Regex: ".*"
|
||||
Priority: 3
|
||||
IndentPPDirectives: None
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
NamespaceIndentation: None
|
||||
PointerAlignment: Right
|
||||
SpaceAroundPointerQualifiers: After
|
||||
ReflowComments: false
|
||||
SortIncludes: false
|
||||
Standard: Auto
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
|
||||
# AccessModifierOffset: -2
|
||||
# AlignConsecutiveAssignments: false
|
||||
# AlignConsecutiveDeclarations: false
|
||||
# AlignEscapedNewlines: Right
|
||||
# AlignOperands: true
|
||||
# AlignTrailingComments: true
|
||||
# AllowAllConstructorInitializersOnNextLine: true
|
||||
# AllowAllParametersOfDeclarationOnNextLine: false
|
||||
# AllowShortCaseLabelsOnASingleLine: false
|
||||
# AllowShortFunctionsOnASingleLine: Inline
|
||||
# AllowShortLambdasOnASingleLine: All
|
||||
# AllowShortIfStatementsOnASingleLine: Never
|
||||
# AllowShortLoopsOnASingleLine: false
|
||||
# AlwaysBreakAfterDefinitionReturnType: TopLevel
|
||||
# AlwaysBreakAfterReturnType: TopLevel
|
||||
# AlwaysBreakBeforeMultilineStrings: false
|
||||
# AlwaysBreakTemplateDeclarations: Yes
|
||||
# BreakBeforeInheritanceComma: false
|
||||
# BreakInheritanceList: BeforeComma
|
||||
# BreakBeforeTernaryOperators: true
|
||||
# BreakConstructorInitializersBeforeComma: false
|
||||
# BreakConstructorInitializers: BeforeComma
|
||||
# BreakAfterJavaFieldAnnotations: false
|
||||
# BreakStringLiterals: true
|
||||
# CommentPragmas: '^ IWYU pragma:'
|
||||
# CompactNamespaces: false
|
||||
# ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
# ConstructorInitializerIndentWidth: 2
|
||||
# Cpp11BracedListStyle: false
|
||||
# DisableFormat: false
|
||||
# ExperimentalAutoDetectBinPacking: false
|
||||
# FixNamespaceComments: false
|
||||
# ForEachMacros:
|
||||
# - foreach
|
||||
# - Q_FOREACH
|
||||
# - BOOST_FOREACH
|
||||
# IncludeIsMainRegex: '(Test)?$'
|
||||
# IndentCaseLabels: true
|
||||
# IndentWrappedFunctionNames: false
|
||||
# JavaScriptQuotes: Leave
|
||||
# JavaScriptWrapImports: true
|
||||
# KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
# MacroBlockBegin: ''
|
||||
# MacroBlockEnd: ''
|
||||
# MaxEmptyLinesToKeep: 1
|
||||
# ObjCBinPackProtocolList: Auto
|
||||
# ObjCBlockIndentWidth: 2
|
||||
# ObjCSpaceAfterProperty: true
|
||||
# ObjCSpaceBeforeProtocolList: false
|
||||
# PenaltyBreakAssignment: 2
|
||||
# PenaltyBreakBeforeFirstCallParameter: 19
|
||||
# PenaltyBreakComment: 300
|
||||
# PenaltyBreakFirstLessLess: 120
|
||||
# PenaltyBreakString: 1000
|
||||
# PenaltyBreakTemplateDeclaration: 10
|
||||
# PenaltyExcessCharacter: 1000000
|
||||
# PenaltyReturnTypeOnItsOwnLine: 200
|
||||
# SortIncludes: true
|
||||
# SortUsingDeclarations: true
|
||||
# SpaceAfterCStyleCast: false
|
||||
# SpaceAfterLogicalNot: false
|
||||
# SpaceAfterTemplateKeyword: false
|
||||
# SpaceBeforeAssignmentOperators: true
|
||||
# SpaceBeforeCpp11BracedList: false
|
||||
# SpaceBeforeCtorInitializerColon: true
|
||||
# SpaceBeforeInheritanceColon: true
|
||||
# SpaceBeforeParens: ControlStatements
|
||||
# SpaceBeforeRangeBasedForLoopColon: true
|
||||
# SpaceInEmptyParentheses: false
|
||||
# SpacesBeforeTrailingComments: 1
|
||||
# SpacesInAngles: false
|
||||
# SpacesInContainerLiterals: true
|
||||
# SpacesInCStyleCastParentheses: false
|
||||
# SpacesInParentheses: false
|
||||
# SpacesInSquareBrackets: false
|
||||
# TabWidth: 4
|
||||
# UseTab: Never
|
||||
# ...
|
||||
|
||||
|
|
16
.clang-tidy
16
.clang-tidy
|
@ -1,16 +0,0 @@
|
|||
# refer to https://clang.llvm.org/extra/clang-tidy/checks/list.html
|
||||
|
||||
Checks: '-*, readability-identifier-naming, clang-analyzer-core.*,'
|
||||
WarningsAsErrors: '-*'
|
||||
HeaderFilterRegex: ''
|
||||
FormatStyle: file
|
||||
InheritParentConfig: false
|
||||
AnalyzeTemporaryDtors: false
|
||||
User: wamr
|
||||
CheckOptions:
|
||||
- key: readability-identifier-naming.VariableCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.ParameterCase
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.MacroDefinitionCase
|
||||
value: UPPER_CASE
|
|
@ -1,150 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp/.devcontainer/base.Dockerfile
|
||||
# [Choice] Debian / Ubuntu version (use Debian 12/11/9, Ubuntu 18.04/21.04 on local arm64/Apple Silicon): debian-12, debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
|
||||
ARG VARIANT=debian-12
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/cpp:${VARIANT}
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Asian/Shanghai
|
||||
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install -y apt-transport-https apt-utils build-essential \
|
||||
ca-certificates ccache cmake curl g++-multilib git gnupg \
|
||||
libgcc-12-dev lib32gcc-12-dev lsb-release \
|
||||
ninja-build ocaml ocamlbuild \
|
||||
software-properties-common tree tzdata \
|
||||
unzip valgrind vim wget zip --no-install-recommends \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
#
|
||||
# binaryen
|
||||
ARG BINARYEN_VER=114
|
||||
WORKDIR /opt
|
||||
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VER}/binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz \
|
||||
&& tar xf binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz \
|
||||
&& ln -sf /opt/binaryen-version_${BINARYEN_VER} /opt/binaryen \
|
||||
&& rm binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz
|
||||
|
||||
#
|
||||
# CMAKE (https://apt.kitware.com/)
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
# hadolint ignore=DL3008
|
||||
ARG CMAKE_VER=3.27.0
|
||||
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-Linux-x86_64.sh \
|
||||
-q -O /tmp/cmake-install.sh \
|
||||
&& chmod u+x /tmp/cmake-install.sh \
|
||||
&& mkdir /opt/cmake-${CMAKE_VER} \
|
||||
&& /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-${CMAKE_VER} \
|
||||
&& rm /tmp/cmake-install.sh \
|
||||
&& ln -s /opt/cmake-${CMAKE_VER}/bin/* /usr/local/bin
|
||||
|
||||
#
|
||||
# install emsdk
|
||||
WORKDIR /opt
|
||||
RUN git clone https://github.com/emscripten-core/emsdk.git
|
||||
|
||||
ARG EMSDK_VER=3.1.43
|
||||
WORKDIR /opt/emsdk
|
||||
RUN git pull \
|
||||
&& ./emsdk install ${EMSDK_VER} \
|
||||
&& ./emsdk activate ${EMSDK_VER} \
|
||||
&& echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc
|
||||
|
||||
#
|
||||
# install wasi-sdk
|
||||
ARG WASI_SDK_VER=20
|
||||
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER}/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -P /opt \
|
||||
&& tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \
|
||||
&& ln -sf /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk \
|
||||
&& rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz
|
||||
|
||||
#
|
||||
#install wabt
|
||||
ARG WABT_VER=1.0.33
|
||||
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu.tar.gz -P /opt \
|
||||
&& tar xf /opt/wabt-${WABT_VER}-ubuntu.tar.gz -C /opt \
|
||||
&& ln -sf /opt/wabt-${WABT_VER} /opt/wabt \
|
||||
&& rm /opt/wabt-${WABT_VER}-ubuntu.tar.gz
|
||||
|
||||
#
|
||||
# install bazelisk
|
||||
ARG BAZELISK_VER=1.17.0
|
||||
RUN mkdir /opt/bazelisk \
|
||||
&& wget -c --progress=dot:giga https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64 -P /opt/bazelisk \
|
||||
&& chmod a+x /opt/bazelisk/bazelisk-linux-amd64 \
|
||||
&& ln -fs /opt/bazelisk/bazelisk-linux-amd64 /opt/bazelisk/bazel
|
||||
|
||||
#
|
||||
# install clang+llvm
|
||||
ARG LLVM_VER=16
|
||||
RUN apt-get purge -y clang-14 llvm-14 && apt-get autoremove -y
|
||||
WORKDIR /etc/apt/apt.conf.d
|
||||
RUN touch 99verfiy-peer.conf \
|
||||
&& echo "Acquire { https::Verify-Peer false }" > 99verfiy-peer.conf
|
||||
|
||||
WORKDIR /tmp
|
||||
#RUN wget --progress=dot:giga https://apt.llvm.org/llvm.sh \
|
||||
# && chmod a+x ./llvm.sh \
|
||||
# && ./llvm.sh ${LLVM_VER} all
|
||||
|
||||
# Workaround due to https://github.com/llvm/llvm-project/issues/62475
|
||||
# hadolint ignore=DL3008
|
||||
RUN set -ex \
|
||||
&& echo "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-${LLVM_VER} main" > /etc/apt/sources.list.d/apt.llvm.org.list \
|
||||
&& wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y \
|
||||
clang-${LLVM_VER} lldb-${LLVM_VER} lld-${LLVM_VER} clangd-${LLVM_VER} clang-tidy-${LLVM_VER} clang-format-${LLVM_VER} clang-tools-${LLVM_VER} \
|
||||
llvm-${LLVM_VER}-dev lld-${LLVM_VER} lldb-${LLVM_VER} llvm-${LLVM_VER}-tools libomp-${LLVM_VER}-dev libc++-${LLVM_VER}-dev libc++abi-${LLVM_VER}-dev \
|
||||
libclang-common-${LLVM_VER}-dev libclang-${LLVM_VER}-dev libclang-cpp${LLVM_VER}-dev libunwind-${LLVM_VER}-dev \
|
||||
libclang-rt-${LLVM_VER}-dev libpolly-${LLVM_VER}-dev --no-install-recommends \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
#
|
||||
# [Optional]
|
||||
|
||||
#
|
||||
# Install pip
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --reinstall python3-venv python3-pip --no-install-recommends \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
#
|
||||
# Install required python packages
|
||||
# hadolint ignore=DL3013
|
||||
RUN python3 -m pip install --no-cache-dir --break-system-packages --upgrade pip \
|
||||
&& pip3 install --no-cache-dir --break-system-packages black nose pycparser pylint
|
||||
|
||||
#
|
||||
# Install github-cli. It doens't work as a feature of devcontainer.json
|
||||
ARG GH_CLI_VER=2.32.0
|
||||
WORKDIR /tmp
|
||||
RUN wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_amd64.deb \
|
||||
&& dpkg -i gh_${GH_CLI_VER}_linux_amd64.deb
|
||||
|
||||
#
|
||||
# Install NodeJS
|
||||
RUN wget -qO- https://deb.nodesource.com/setup_20.x | bash -
|
||||
# hadolint ignore=DL3008
|
||||
RUN apt-get install -y nodejs --no-install-recommends
|
||||
|
||||
# set path
|
||||
ENV PATH="/opt/bazelisk:/usr/lib/llvm-${LLVM_VER}/bin:${PATH}"
|
||||
ENV CC=/usr/lib/llvm-${LLVM_VER}/bin/clang CXX=/usr/lib/llvm-${LLVM_VER}/bin/clang++
|
||||
RUN printf "%s\n" "PS1='\n[ \u@wamr-dev-docker \W ]\n$ '" >> /root/.bashrc \
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& rm -rf /tmp/*
|
||||
|
||||
# set workdir when container run
|
||||
VOLUME /workspaces
|
||||
WORKDIR /workspaces
|
|
@ -1,50 +0,0 @@
|
|||
// Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
|
||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp
|
||||
{
|
||||
"name": "WAMR-Dev",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-12, debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
|
||||
// Use Debian 12, Debian 11, Debian 9, Ubuntu 18.04 or Ubuntu 21.04 on local arm64/Apple Silicon
|
||||
"args": {
|
||||
"BINARYEN_VER": "114",
|
||||
"BAZELISK_VER": "1.17.0",
|
||||
"CMAKE_VER": "3.27.0",
|
||||
"EMSDK_VER": "3.1.43",
|
||||
"GH_CLI_VER": "2.32.0",
|
||||
"LLVM_VER": "16",
|
||||
"VARIANT": "debian-12",
|
||||
"WASI_SDK_VER": "20",
|
||||
"WABT_VER": "1.0.33"
|
||||
}
|
||||
},
|
||||
"runArgs": [
|
||||
"--cap-add=SYS_PTRACE",
|
||||
"--security-opt",
|
||||
"seccomp=unconfined"
|
||||
],
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"settings": {},
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"dtsvet.vscode-wasm",
|
||||
"llvm-vs-code-extensions.vscode-clangd",
|
||||
"ms-python.python",
|
||||
"ms-python.vscode-pylance",
|
||||
"ms-vscode.cmake-tools"
|
||||
]
|
||||
}
|
||||
},
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "curl https://sh.rustup.rs -sSf | bash -s -- -y",
|
||||
// Comment out this line to run as root instead.
|
||||
"remoteUser": "vscode"
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
# for now, it is used to speed up wasi-nn tests only.
|
||||
# you shall adapt below rules to incoming requirements
|
||||
|
||||
**/build
|
||||
**/tmp.*
|
||||
.*
|
||||
**/*.gguf
|
||||
|
||||
/core/deps/
|
||||
!/core/deps/tensorflow-src
|
||||
/samples
|
||||
/tests
|
5
.github/ISSUE_TEMPLATE/blank_issue.md
vendored
5
.github/ISSUE_TEMPLATE/blank_issue.md
vendored
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
name: Blank Issue
|
||||
about: Create a blank issue.
|
||||
title: ''
|
||||
---
|
28
.github/ISSUE_TEMPLATE/improvement.md
vendored
28
.github/ISSUE_TEMPLATE/improvement.md
vendored
|
@ -1,28 +0,0 @@
|
|||
---
|
||||
name: Improvement
|
||||
about: A feature request or code improvement.
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
Thanks for filing a feature request! Please fill out the TODOs below.
|
||||
|
||||
#### Feature
|
||||
|
||||
TODO: Brief description of the feature/improvement you'd like to see in WAMR
|
||||
|
||||
#### Benefit
|
||||
|
||||
TODO: What is the value of adding this in WAMR? What problems does it solve?
|
||||
|
||||
#### Implementation
|
||||
|
||||
TODO: Do you have an implementation plan, and/or ideas for data structures or
|
||||
algorithms to use?
|
||||
|
||||
#### Alternatives
|
||||
|
||||
TODO: What are the alternative implementation approaches or alternative ways to
|
||||
solve the problem that this feature would solve? How do these alternatives
|
||||
compare to this proposal?
|
36
.github/ISSUE_TEMPLATE/report_bug.md
vendored
36
.github/ISSUE_TEMPLATE/report_bug.md
vendored
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
name: WAMR bug or defect report
|
||||
about: Report a bug or defect in WAMR
|
||||
title: ''
|
||||
---
|
||||
|
||||
Thanks for filing a bug or defect report! Please fill out the TODOs below.
|
||||
|
||||
### Subject of the issue
|
||||
|
||||
Describe the bug or defect here.
|
||||
|
||||
### Test case
|
||||
|
||||
Upload the related wasm file, wast file or the source files if you can.
|
||||
|
||||
### Your environment
|
||||
|
||||
* Host OS
|
||||
* WAMR version, platform, cpu architecture, running mode, etc.
|
||||
|
||||
### Steps to reproduce
|
||||
|
||||
Tell us how to reproduce this bug or defect.
|
||||
|
||||
### Expected behavior
|
||||
|
||||
Tell us what should happen
|
||||
|
||||
### Actual behavior
|
||||
|
||||
Tell us what happens instead
|
||||
|
||||
### Extra Info
|
||||
|
||||
Anything else you'd like to add?
|
47
.github/actions/install-linux-sgx/action.yml
vendored
47
.github/actions/install-linux-sgx/action.yml
vendored
|
@ -1,47 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Always follow https://download.01.org/intel-sgx/latest/linux-latest/docs/
|
||||
|
||||
name: "Install Intel SGX SDK"
|
||||
description: "Installs the Intel SGX SDK and necessary libraries for Ubuntu."
|
||||
author: "Intel Corporation"
|
||||
inputs:
|
||||
os:
|
||||
description: "Operating system to install on (ubuntu-22.04)"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Check Runner OS
|
||||
if: ${{ inputs.os != 'ubuntu-22.04' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::error title=⛔ error hint::Only support ubuntu-22.04 for now"
|
||||
exit 1
|
||||
|
||||
- name: Create installation directory
|
||||
shell: bash
|
||||
run: sudo mkdir -p /opt/intel
|
||||
|
||||
- name: Download and install SGX SDK on ubuntu-22.04
|
||||
if: ${{ inputs.os == 'ubuntu-22.04' }}
|
||||
shell: bash
|
||||
run: |
|
||||
sudo wget -O sgx_linux_x64_sdk.bin https://download.01.org/intel-sgx/sgx-linux/2.25/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.25.100.3.bin
|
||||
sudo chmod +x sgx_linux_x64_sdk.bin
|
||||
echo 'yes' | sudo ./sgx_linux_x64_sdk.bin
|
||||
working-directory: /opt/intel
|
||||
|
||||
- name: Add SGX repository and install libraries
|
||||
shell: bash
|
||||
run: |
|
||||
echo "deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/intel-sgx.list
|
||||
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
|
||||
sudo apt update
|
||||
sudo apt install -y libsgx-launch libsgx-urts
|
||||
|
||||
- name: Source SGX SDK environment
|
||||
shell: bash
|
||||
run: source /opt/intel/sgxsdk/environment
|
125
.github/actions/install-wasi-sdk-wabt/action.yml
vendored
125
.github/actions/install-wasi-sdk-wabt/action.yml
vendored
|
@ -1,125 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Get URLs from:
|
||||
# - https://github.com/WebAssembly/wasi-sdk/releases
|
||||
# - https://github.com/WebAssembly/wabt/releases
|
||||
|
||||
# Install WASI-SDK and WABT at /opt
|
||||
# /opt is the assumed location widely used in the project
|
||||
name: Install WASI-SDK and WABT
|
||||
|
||||
description: A composite action to download and install wasi-sdk and wabt on Ubuntu, macOS.
|
||||
|
||||
inputs:
|
||||
os:
|
||||
description: "Operating system to install on (ubuntu, macos)"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Check Runner OS
|
||||
if: ${{ !startsWith(inputs.os, 'ubuntu') && !startsWith(inputs.os, 'windows') && !startsWith(inputs.os, 'macos') }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::error title=⛔ error hint::Support Ubuntu, Windows, and macOS Only"
|
||||
exit 1
|
||||
|
||||
- name: Set up wasi-sdk and wabt on Ubuntu
|
||||
if: ${{ startsWith(inputs.os, 'ubuntu') }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Downloading wasi-sdk for Ubuntu..."
|
||||
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
|
||||
|
||||
echo "Extracting wasi-sdk..."
|
||||
sudo tar -xf wasi-sdk.tar.gz
|
||||
sudo ln -sf wasi-sdk-25.0-x86_64-linux/ wasi-sdk
|
||||
|
||||
echo "Downloading wabt for Ubuntu..."
|
||||
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-ubuntu-20.04.tar.gz
|
||||
|
||||
echo "Extracting wabt..."
|
||||
sudo tar -xf wabt.tar.gz
|
||||
sudo ln -sf wabt-1.0.37 wabt
|
||||
|
||||
/opt/wasi-sdk/bin/clang --version
|
||||
/opt/wabt/bin/wasm-interp --version
|
||||
|
||||
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on ubuntu"
|
||||
working-directory: /opt
|
||||
|
||||
- name: Set up wasi-sdk and wabt on macOS-13 (intel)
|
||||
if: ${{ inputs.os == 'macos-13' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Downloading wasi-sdk for macOS-13..."
|
||||
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-macos.tar.gz
|
||||
|
||||
echo "Extracting wasi-sdk..."
|
||||
sudo tar -xf wasi-sdk.tar.gz
|
||||
sudo ln -sf wasi-sdk-25.0-x86_64-macos wasi-sdk
|
||||
|
||||
echo "Downloading wabt for macOS-13..."
|
||||
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-macos-12.tar.gz
|
||||
|
||||
echo "Extracting wabt..."
|
||||
sudo tar -xf wabt.tar.gz
|
||||
sudo ln -sf wabt-1.0.36 wabt
|
||||
|
||||
/opt/wasi-sdk/bin/clang --version
|
||||
/opt/wabt/bin/wasm-interp --version
|
||||
|
||||
echo "::notice::wasi-sdk-25 and wabt-1.0.36 installed on macos-13"
|
||||
working-directory: /opt
|
||||
|
||||
- name: Set up wasi-sdk and wabt on macOS-14 (arm64)
|
||||
if: ${{ inputs.os == 'macos-14' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Downloading wasi-sdk for macOS-14..."
|
||||
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-arm64-macos.tar.gz
|
||||
|
||||
echo "Extracting wasi-sdk..."
|
||||
sudo tar -xf wasi-sdk.tar.gz
|
||||
sudo ln -sf wasi-sdk-25.0-arm64-macos wasi-sdk
|
||||
|
||||
echo "Downloading wabt for macOS-14..."
|
||||
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-macos-14.tar.gz
|
||||
|
||||
echo "Extracting wabt..."
|
||||
sudo tar -xf wabt.tar.gz
|
||||
sudo ln -sf wabt-1.0.37 wabt
|
||||
|
||||
/opt/wasi-sdk/bin/clang --version
|
||||
/opt/wabt/bin/wasm-interp --version
|
||||
|
||||
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on macos-14"
|
||||
working-directory: /opt
|
||||
|
||||
- name: Set up wasi-sdk and wabt on Windows
|
||||
if: ${{ startsWith(inputs.os, 'windows') }}
|
||||
shell: bash
|
||||
run: |
|
||||
choco install -y wget
|
||||
|
||||
mkdir -p /opt/wasi-sdk
|
||||
mkdir -p /opt/wabt
|
||||
|
||||
echo "Downloading wasi-sdk for Windows..."
|
||||
wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-windows.tar.gz
|
||||
|
||||
echo "Extracting wasi-sdk..."
|
||||
tar --strip-components=1 -xf wasi-sdk.tar.gz -C /opt/wasi-sdk
|
||||
|
||||
echo "Downloading wabt for Windows..."
|
||||
wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-windows.tar.gz
|
||||
|
||||
echo "Extracting wabt..."
|
||||
tar --strip-components=1 -xf wabt.tar.gz -C /opt/wabt
|
||||
|
||||
/opt/wasi-sdk/bin/clang --version
|
||||
/opt/wabt/bin/wasm-interp --version
|
||||
|
||||
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on Windows"
|
35
.github/dependabot.yml
vendored
35
.github/dependabot.yml
vendored
|
@ -1,35 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/.devcontainer"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "devcontainers"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/build-scripts"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/language-bindings/python/wasm-c-api"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/language-bindings/python/wamr-api"
|
||||
schedule:
|
||||
interval: "weekly"
|
312
.github/scripts/codeql_buildscript.sh
vendored
312
.github/scripts/codeql_buildscript.sh
vendored
|
@ -1,312 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
sudo apt update
|
||||
|
||||
sudo apt install -y build-essential cmake g++-multilib libgcc-12-dev lib32gcc-12-dev ccache ninja-build
|
||||
|
||||
WAMR_DIR=${PWD}
|
||||
|
||||
# TODO: use pre-built llvm binary to build wamrc to
|
||||
# avoid static code analysing for llvm
|
||||
: '
|
||||
# build wamrc
|
||||
cd ${WAMR_DIR}/wamr-compiler
|
||||
./build_llvm.sh
|
||||
rm -fr build && mkdir build && cd build
|
||||
cmake ..
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build wamrc!"
|
||||
exit 1;
|
||||
fi
|
||||
'
|
||||
|
||||
# build iwasm with default features enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -fr build && mkdir build && cd build
|
||||
cmake ..
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with default features enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with default features enabled on x86_32
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -fr build && mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_TARGET=X86_32
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with default features enabled on x86_32!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with classic interpreter enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_INTERP=0
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with classic interpreter enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with extra features enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -fr build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug \
|
||||
-DWAMR_BUILD_LIB_PTHREAD=1 -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=1 -DWAMR_BUILD_SIMD=1 \
|
||||
-DWAMR_BUILD_TAIL_CALL=1 -DWAMR_BUILD_REF_TYPES=1 \
|
||||
-DWAMR_BUILD_CUSTOM_NAME_SECTION=1 -DWAMR_BUILD_MEMORY_PROFILING=1 \
|
||||
-DWAMR_BUILD_PERF_PROFILING=1 -DWAMR_BUILD_DUMP_CALL_STACK=1 \
|
||||
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build wamrc iwasm with extra features enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with global heap pool enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -fr build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug \
|
||||
-DWAMR_BUILD_ALLOC_WITH_USER_DATA=1 \
|
||||
-DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1 \
|
||||
-DWAMR_BUILD_GLOBAL_HEAP_POOL=1 \
|
||||
-DWAMR_BUILD_GLOBAL_HEAP_SIZE=131072
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with global heap pool enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with wasi-threads enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -fr build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LIB_WASI_THREADS=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with wasi-threads enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with GC enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_GC=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with GC enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with exception handling enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_EXCE_HANDLING=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with exception handling enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with memory64 enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MEMORY64=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with memory64 enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with multi-memory enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MULTI_MEMORY=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with multi-memory enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with hardware boundary check disabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_DISABLE_HW_BOUND_CHECK=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with hardware boundary check disabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with quick AOT entry disabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_QUICK_AOT_ENTRY=0
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with quick AOT entry disabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with wakeup of blocking operations disabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_DISABLE_WAKEUP_BLOCKING_OP=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with wakeup of blocking operations disabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with module instance context disabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MODULE_INST_CONTEXT=0 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=0 -DWAMR_BUILD_LIBC_WASI=0
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with module instance context disabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with libc-uvwasi enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -fr build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LIBC_UVWASI=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with libc-uvwasi enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with fast jit lazy mode enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_FAST_JIT_DUMP=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with fast jit lazy mode enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with fast jit eager mode enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_FAST_JIT_DUMP=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with fast jit eager mode enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# TODO: use pre-built llvm binary to build llvm-jit and multi-tier-jit
|
||||
: '
|
||||
# build iwasm with llvm jit lazy mode enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_JIT=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build llvm jit lazy mode enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with llvm jit eager mode enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build llvm jit eager mode enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with multi-tier jit enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
|
||||
-DWAMR_BUILD_FAST_JIT_DUMP=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with multi-tier jit enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
'
|
||||
|
||||
# build iwasm with wasm mini-loader enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MINI_LOADER=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build with wasm mini-loader enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with source debugging enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_DEBUG_AOT=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with source debugging enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with AOT static PGO enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_STATIC_PGO=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with AOT static PGO enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with configurable bounds checks enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_CONFIGURABLE_BOUNDS_CHECKS=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with configurable bounds checks enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with linux perf support enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux/
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LINUX_PERF=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with linux perf support enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with shared heap enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_SHARED_HEAP=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm with shared heap enabled!"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# build iwasm with dynamic aot debug enabled
|
||||
cd ${WAMR_DIR}/product-mini/platforms/linux
|
||||
rm -rf build && mkdir build && cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_DYNAMIC_AOT_DEBUG=1
|
||||
make -j
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "Failed to build iwasm dynamic aot debug enabled!"
|
||||
exit 1;
|
||||
fi
|
124
.github/scripts/codeql_fail_on_error.py
vendored
124
.github/scripts/codeql_fail_on_error.py
vendored
|
@ -1,124 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import requests
|
||||
|
||||
|
||||
def fetch_dismissed_alerts(repo_name, github_token):
|
||||
headers = {
|
||||
"Authorization": f"token {github_token}",
|
||||
"Accept": "application/vnd.github.v3+json",
|
||||
}
|
||||
url = (
|
||||
f"https://api.github.com/repos/{repo_name}/code-scanning/alerts?state=dismissed"
|
||||
)
|
||||
response = requests.get(url, headers=headers)
|
||||
return response.json() # This assumes a successful API call
|
||||
|
||||
|
||||
def parse_location(location):
|
||||
path = location.get("physicalLocation", {}).get("artifactLocation", {}).get("uri")
|
||||
start_line = location.get("physicalLocation", {}).get("region", {}).get("startLine")
|
||||
column_range = (
|
||||
location.get("physicalLocation", {}).get("region", {}).get("startColumn"),
|
||||
location.get("physicalLocation", {}).get("region", {}).get("endColumn"),
|
||||
)
|
||||
return (path, start_line, column_range)
|
||||
|
||||
|
||||
def is_dismissed(rule_id, path, start_line, column_range, dismissed_alerts):
|
||||
for alert in dismissed_alerts:
|
||||
alert_rule_id = alert.get("rule", {}).get("id")
|
||||
alert_path = alert.get("location", {}).get("path")
|
||||
alert_start_line = alert.get("location", {}).get("start_line")
|
||||
alert_column_range = (
|
||||
alert.get("location", {}).get("start_column"),
|
||||
alert.get("location", {}).get("end_column"),
|
||||
)
|
||||
|
||||
if (
|
||||
rule_id == alert_rule_id
|
||||
and path == alert_path
|
||||
and start_line == alert_start_line
|
||||
and column_range == alert_column_range
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
# Return whether SARIF file contains error-level results
|
||||
def codeql_sarif_contain_error(filename, dismissed_alerts):
|
||||
has_error = False
|
||||
|
||||
with open(filename, "r") as f:
|
||||
s = json.load(f)
|
||||
|
||||
for run in s.get("runs", []):
|
||||
rules_metadata = run["tool"]["driver"]["rules"]
|
||||
if not rules_metadata:
|
||||
rules_metadata = run["tool"]["extensions"][0]["rules"]
|
||||
|
||||
for res in run.get("results", []):
|
||||
if "ruleIndex" in res:
|
||||
rule_index = res["ruleIndex"]
|
||||
elif "rule" in res and "index" in res["rule"]:
|
||||
rule_index = res["rule"]["index"]
|
||||
else:
|
||||
continue
|
||||
|
||||
# check whether it's dismissed before
|
||||
rule_id = res["ruleId"]
|
||||
path, start_line, column_range = parse_location(res["locations"][0])
|
||||
# the source code is from dependencies
|
||||
if "_deps" in path:
|
||||
continue
|
||||
if is_dismissed(rule_id, path, start_line, column_range, dismissed_alerts):
|
||||
print(
|
||||
f"====== Finding a dismissed entry: {rule_id} at {path}:{start_line} is dismissed.======"
|
||||
)
|
||||
print(res)
|
||||
continue
|
||||
|
||||
try:
|
||||
rule_level = rules_metadata[rule_index]["defaultConfiguration"]["level"]
|
||||
except IndexError as e:
|
||||
print(e, rule_index, len(rules_metadata))
|
||||
else:
|
||||
if rule_level == "error":
|
||||
# very likely to be an actual error
|
||||
if rules_metadata[rule_index]["properties"].get("precision") in [
|
||||
"high",
|
||||
"very-high",
|
||||
]:
|
||||
# the security severity is above medium(Common Vulnerability Scoring System (CVSS) >= 4.0)
|
||||
if "security-severity" in rules_metadata[rule_index][
|
||||
"properties"
|
||||
] and (
|
||||
float(
|
||||
rules_metadata[rule_index]["properties"][
|
||||
"security-severity"
|
||||
]
|
||||
)
|
||||
> 4.0
|
||||
):
|
||||
print("====== Finding a likely error. ======")
|
||||
print(res)
|
||||
has_error = True
|
||||
|
||||
return has_error
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
|
||||
GITHUB_REPOSITORY = os.getenv("GITHUB_REPOSITORY")
|
||||
dismissed_alerts = fetch_dismissed_alerts(GITHUB_REPOSITORY, GITHUB_TOKEN)
|
||||
|
||||
if codeql_sarif_contain_error(sys.argv[1], dismissed_alerts):
|
||||
sys.exit(1)
|
60
.github/scripts/extract_from_release_notes.py
vendored
60
.github/scripts/extract_from_release_notes.py
vendored
|
@ -1,60 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
"""
|
||||
Extract the latest release notes content from RELEASE_NOTES.md
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
|
||||
def latest_content(release_notes_path):
|
||||
"""
|
||||
can't change the format of the original content
|
||||
"""
|
||||
content = ""
|
||||
start_extract = False
|
||||
with open(release_notes_path, encoding="utf-8") as f:
|
||||
for line in f:
|
||||
if line.startswith("## "):
|
||||
if start_extract:
|
||||
break
|
||||
|
||||
start_extract = True
|
||||
continue
|
||||
|
||||
# hit a separated line
|
||||
if line.startswith("---"):
|
||||
break
|
||||
|
||||
content += line
|
||||
|
||||
content += os.linesep
|
||||
return content
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
GO!GO!!GO!!!
|
||||
"""
|
||||
parser = argparse.ArgumentParser(description="run the sample and examine outputs")
|
||||
parser.add_argument("release_notes_path", type=str)
|
||||
args = parser.parse_args()
|
||||
|
||||
ret = 1
|
||||
try:
|
||||
print(latest_content(args.release_notes_path))
|
||||
ret = 0
|
||||
except AssertionError:
|
||||
traceback.print_exc()
|
||||
return ret
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
126
.github/scripts/fetch_and_compare_version.py
vendored
126
.github/scripts/fetch_and_compare_version.py
vendored
|
@ -1,126 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def fetch_version_from_code():
|
||||
"""
|
||||
search the semantic version definition in core/version.h
|
||||
"""
|
||||
major, minor, patch = "", "", ""
|
||||
with open("core/version.h", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
if "WAMR_VERSION" not in line:
|
||||
continue
|
||||
|
||||
major_match = re.search(r"WAMR_VERSION_MAJOR (\d+)", line)
|
||||
if major_match is not None:
|
||||
major = major_match.groups()[0]
|
||||
continue
|
||||
|
||||
minor_match = re.search(r"WAMR_VERSION_MINOR (\d+)", line)
|
||||
if minor_match is not None:
|
||||
minor = minor_match.groups()[0]
|
||||
continue
|
||||
|
||||
patch_match = re.search(r"WAMR_VERSION_PATCH (\d+)", line)
|
||||
if patch_match is not None:
|
||||
patch = patch_match.groups()[0]
|
||||
|
||||
if len(major) == 0 or len(minor) == 0 or len(patch) == 0:
|
||||
raise Exception(
|
||||
"can't find the semantic version definition likes WAMR_VERSION_*"
|
||||
)
|
||||
return f"WAMR-{major}.{minor}.{patch}"
|
||||
|
||||
|
||||
def fetch_latest_git_tag():
|
||||
"""
|
||||
Get the most recent tag from the HEAD,
|
||||
if it's main branch, it should be the latest release tag.
|
||||
if it's release/x.x.x branch, it should be the latest release tag of the branch.
|
||||
"""
|
||||
list_tag_cmd = "git describe --tags --abbrev=0 HEAD"
|
||||
p = subprocess.run(shlex.split(list_tag_cmd), capture_output=True, check=True)
|
||||
|
||||
all_tags = p.stdout.decode().strip()
|
||||
latest_tag = all_tags.split("\n")[-1]
|
||||
return latest_tag
|
||||
|
||||
|
||||
def match_version_pattern(v):
|
||||
pattern = r"WAMR-\d+\.\d+\.\d+"
|
||||
m = re.match(pattern, v)
|
||||
return m is not None
|
||||
|
||||
|
||||
def split_version_string(v):
|
||||
"""
|
||||
return the semantic version as an integer list
|
||||
"""
|
||||
pattern = r"WAMR-(\d+)\.(\d+)\.(\d+)"
|
||||
m = re.match(pattern, v)
|
||||
return [int(x) for x in m.groups()]
|
||||
|
||||
|
||||
def compare_version_string(v1, v2):
|
||||
"""
|
||||
return value:
|
||||
- 1. if v1 > v2
|
||||
- -1. if v1 < v2
|
||||
- 0. if v1 == v2
|
||||
"""
|
||||
if not match_version_pattern(v1):
|
||||
raise Exception(f"{v1} doesn't match the version pattern")
|
||||
|
||||
if not match_version_pattern(v2):
|
||||
raise Exception(f"{v2} doesn't match the version pattern")
|
||||
|
||||
v1_sem_ver = split_version_string(v1)
|
||||
v2_sem_ver = split_version_string(v2)
|
||||
|
||||
return 0 if v1_sem_ver == v2_sem_ver else (1 if v1_sem_ver > v2_sem_ver else -1)
|
||||
|
||||
|
||||
def is_major_or_minor_changed(v1, v2):
|
||||
"""
|
||||
return true if change either major of v2 or minor of v2
|
||||
return false or else
|
||||
"""
|
||||
if not match_version_pattern(v1):
|
||||
raise Exception(f"{v1} doesn't match the version pattern")
|
||||
|
||||
if not match_version_pattern(v2):
|
||||
raise Exception(f"{v2} doesn't match the version pattern")
|
||||
|
||||
v1_major, v1_minor, _ = split_version_string(v1)
|
||||
v2_major, v2_minor, _ = split_version_string(v2)
|
||||
|
||||
return v2_major != v1_major or v2_minor != v1_minor
|
||||
|
||||
|
||||
def next_version():
|
||||
definition = fetch_version_from_code()
|
||||
tag = fetch_latest_git_tag()
|
||||
|
||||
new_version = ""
|
||||
minor_changed = False
|
||||
if compare_version_string(definition, tag) == 1:
|
||||
new_version = definition.split("-")[-1]
|
||||
|
||||
if is_major_or_minor_changed(tag, definition):
|
||||
minor_changed = True
|
||||
|
||||
return new_version, "major_minor_change" if minor_changed else "patch_change"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"{next_version()[0]},{next_version()[1]}")
|
||||
sys.exit(0)
|
10
.github/scripts/install_qemu_xtensa.sh
vendored
10
.github/scripts/install_qemu_xtensa.sh
vendored
|
@ -1,10 +0,0 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
URL=https://github.com/espressif/qemu/releases/download/esp-develop-9.0.0-20240606/qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz
|
||||
|
||||
DIR=$(mktemp -d)
|
||||
cd ${DIR}
|
||||
curl -fLsS "${URL}" | xzcat | tar -x
|
||||
ln -s ${DIR}/qemu/bin/qemu-system-xtensa /usr/local/bin/qemu-system-xtensa
|
102
.github/scripts/reuse_latest_release_binaries.py
vendored
102
.github/scripts/reuse_latest_release_binaries.py
vendored
|
@ -1,102 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
from urllib.error import HTTPError, URLError
|
||||
import urllib.request
|
||||
|
||||
|
||||
def get_last_commit(target_path, cwd):
|
||||
last_commit_cmd = f"git log -n 1 --pretty=format:%H -- {target_path}"
|
||||
p = subprocess.run(
|
||||
shlex.split(last_commit_cmd), capture_output=True, check=True, cwd=cwd
|
||||
)
|
||||
return p.stdout.decode().strip()
|
||||
|
||||
|
||||
def fetch_git_tags():
|
||||
list_tag_cmd = (
|
||||
'git tag --list WAMR-*.*.* --sort=committerdate --format="%(refname:short)"'
|
||||
)
|
||||
p = subprocess.run(shlex.split(list_tag_cmd), capture_output=True, check=True)
|
||||
|
||||
all_tags = p.stdout.decode().strip()
|
||||
return all_tags.split("\n")
|
||||
|
||||
|
||||
def download_binaries(binary_name_stem, cwd):
|
||||
"""
|
||||
1. find the latest release name
|
||||
2. form assets download url:
|
||||
"""
|
||||
try:
|
||||
all_tags = fetch_git_tags()
|
||||
# *release_process.yml* will create a tag and release at first
|
||||
second_last_tag = all_tags[-2]
|
||||
latest_tag = all_tags[-1]
|
||||
|
||||
latest_url = "https://api.github.com/repos/bytecodealliance/wasm-micro-runtime/releases/latest"
|
||||
print(f"::notice::query the latest release with {latest_url}...")
|
||||
with urllib.request.urlopen(latest_url) as response:
|
||||
body = response.read()
|
||||
|
||||
release_name = json.loads(body)["name"]
|
||||
|
||||
# WAMR-X.Y.Z -> X.Y.Z
|
||||
second_last_sem_ver = second_last_tag[5:]
|
||||
latest_sem_ver = latest_tag[5:]
|
||||
assert latest_sem_ver in binary_name_stem
|
||||
name_stem_in_release = binary_name_stem.replace(
|
||||
latest_sem_ver, second_last_sem_ver
|
||||
)
|
||||
|
||||
# download and rename
|
||||
for file_ext in (".zip", ".tar.gz"):
|
||||
assets_url = f"https://github.com/bytecodealliance/wasm-micro-runtime/releases/download/{release_name}/{name_stem_in_release}{file_ext}"
|
||||
local_path = f"{binary_name_stem}{file_ext}"
|
||||
print(f"::notice::download from {assets_url} and save as {local_path}...")
|
||||
urllib.request.urlretrieve(assets_url, local_path)
|
||||
return True
|
||||
except HTTPError as error:
|
||||
print(error.status, error.reason)
|
||||
except URLError as error:
|
||||
print(error.reason)
|
||||
except TimeoutError:
|
||||
print("Request timeout")
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Reuse binaries of the latest release if no more modification on the_path since last_commit"
|
||||
)
|
||||
parser.add_argument("working_directory", type=str)
|
||||
parser.add_argument("--binary_name_stem", type=str)
|
||||
parser.add_argument("--last_commit", type=str)
|
||||
parser.add_argument("--the_path", type=str)
|
||||
args = parser.parse_args()
|
||||
|
||||
last_commit = get_last_commit(args.the_path, args.working_directory)
|
||||
if last_commit == args.last_commit:
|
||||
return download_binaries(args.binary_name_stem, args.working_directory)
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# use output to indicate results
|
||||
# echo "result=${result}" >> "$GITHUB_OUTPUT"
|
||||
with open(os.environ.get("GITHUB_OUTPUT"), 'a') as output_file:
|
||||
output_file.write("result=hit\n" if main() else "result=not-hit\n")
|
||||
|
||||
# always return 0
|
||||
sys.exit(0)
|
112
.github/workflows/android.yml
vendored
Normal file
112
.github/workflows/android.yml
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: Android
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the master branch
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build iwasm [default]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [classic interp]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_FAST_INTERP=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [multi module]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_MULTI_MODULE=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [lib-pthread]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_LIB_PTHREAD=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [aot only]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [interp only]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [memory profiling]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_MEMORY_PROFILING=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [tail call]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_TAIL_CALL=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [custom name section]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_CUSTOM_NAME_SECTION=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [disable hardware boundary check]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_DISABLE_HW_BOUND_CHECK=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [reference types]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_REF_TYPES=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [128-bit SIMD]
|
||||
run: |
|
||||
cd product-mini/platforms/android
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_SIMD=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
94
.github/workflows/build_docker_images.yml
vendored
94
.github/workflows/build_docker_images.yml
vendored
|
@ -1,94 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: Create and publish Docker images
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
upload_url:
|
||||
description: upload binary assets to the URL of release
|
||||
type: string
|
||||
required: true
|
||||
ver_num:
|
||||
description: a semantic version number.
|
||||
type: string
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build-and-push-images:
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
contents: write # for uploading release artifacts
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build and save Docker image(wasm-debug-server:${{ inputs.ver_num }}) to tar file
|
||||
run: |
|
||||
docker build -t wasm-debug-server:${{ inputs.ver_num }} .
|
||||
docker save -o wasm-debug-server.tar wasm-debug-server:${{ inputs.ver_num }}
|
||||
working-directory: test-tools/wamr-ide/WASM-Debug-Server/Docker
|
||||
|
||||
- name: compress the tar file
|
||||
run: |
|
||||
tar czf wasm-debug-server-${{ inputs.ver_num }}.tar.gz wasm-debug-server.tar
|
||||
zip wasm-debug-server-${{ inputs.ver_num }}.zip wasm-debug-server.tar
|
||||
working-directory: test-tools/wamr-ide/WASM-Debug-Server/Docker
|
||||
|
||||
- name: upload release tar.gz
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: test-tools/wamr-ide/WASM-Debug-Server/Docker/wasm-debug-server-${{ inputs.ver_num }}.tar.gz
|
||||
asset_name: wasm-debug-server-${{ inputs.ver_num }}.tar.gz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: upload release zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: test-tools/wamr-ide/WASM-Debug-Server/Docker/wasm-debug-server-${{ inputs.ver_num }}.zip
|
||||
asset_name: wasm-debug-server-${{ inputs.ver_num }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Build and save Docker image(wasm-toolchain:${{ inputs.ver_num }}) to tar file
|
||||
run: |
|
||||
docker build -t wasm-toolchain:${{ inputs.ver_num }} .
|
||||
docker save -o wasm-toolchain.tar wasm-toolchain:${{ inputs.ver_num }}
|
||||
working-directory: test-tools/wamr-ide/WASM-Toolchain/Docker
|
||||
|
||||
- name: compress the tar file
|
||||
run: |
|
||||
tar czf wasm-toolchain-${{ inputs.ver_num }}.tar.gz wasm-toolchain.tar
|
||||
zip wasm-toolchain-${{ inputs.ver_num }}.zip wasm-toolchain.tar
|
||||
working-directory: test-tools/wamr-ide/WASM-Toolchain/Docker
|
||||
|
||||
- name: upload release tar.gz
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: test-tools/wamr-ide/WASM-Toolchain/Docker/wasm-toolchain-${{ inputs.ver_num }}.tar.gz
|
||||
asset_name: wasm-toolchain-${{ inputs.ver_num }}.tar.gz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: upload release zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: test-tools/wamr-ide/WASM-Toolchain/Docker/wasm-toolchain-${{ inputs.ver_num }}.zip
|
||||
asset_name: wasm-toolchain-${{ inputs.ver_num }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
163
.github/workflows/build_iwasm_release.yml
vendored
163
.github/workflows/build_iwasm_release.yml
vendored
|
@ -1,163 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: build iwasm release
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
arch:
|
||||
description: arch of the release
|
||||
type: string
|
||||
required: false
|
||||
default: x86_64
|
||||
cwd:
|
||||
description: working directory
|
||||
type: string
|
||||
required: true
|
||||
llvm_cache_key:
|
||||
description: the cache key of llvm libraries
|
||||
type: string
|
||||
required: true
|
||||
runner:
|
||||
description: OS of compilation
|
||||
type: string
|
||||
required: true
|
||||
upload_url:
|
||||
description: a semantic version number. it is required when `release` is true.
|
||||
type: string
|
||||
required: false
|
||||
ver_num:
|
||||
description: a semantic version number. it is required when `release` is true.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
env:
|
||||
DEFAULT_BUILD_OPTIONS:
|
||||
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
|
||||
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
|
||||
-DWAMR_BUILD_DEBUG_INTERP=0 \
|
||||
-DWAMR_BUILD_DEBUG_AOT=0 \
|
||||
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
|
||||
-DWAMR_BUILD_LIBC_UVWASI=0 \
|
||||
-DWAMR_BUILD_LIBC_EMCC=0 \
|
||||
-DWAMR_BUILD_LIB_RATS=0 \
|
||||
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
|
||||
-DWAMR_BUILD_MEMORY_PROFILING=0 \
|
||||
-DWAMR_BUILD_MINI_LOADER=0 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=0 \
|
||||
-DWAMR_BUILD_PERF_PROFILING=0 \
|
||||
-DWAMR_BUILD_SPEC_TEST=0 \
|
||||
-DWAMR_BUILD_BULK_MEMORY=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
|
||||
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||
-DWAMR_BUILD_LIBC_WASI=1 \
|
||||
-DWAMR_BUILD_REF_TYPES=1 \
|
||||
-DWAMR_BUILD_SIMD=1 \
|
||||
-DWAMR_BUILD_SHARED_MEMORY=1 \
|
||||
-DWAMR_BUILD_TAIL_CALL=1 \
|
||||
-DWAMR_BUILD_THREAD_MGR=1"
|
||||
GC_EH_BUILD_OPTIONS:
|
||||
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 \
|
||||
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
|
||||
-DWAMR_BUILD_DEBUG_INTERP=0 \
|
||||
-DWAMR_BUILD_DEBUG_AOT=0 \
|
||||
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
|
||||
-DWAMR_BUILD_LIBC_UVWASI=0 \
|
||||
-DWAMR_BUILD_LIBC_EMCC=0 \
|
||||
-DWAMR_BUILD_LIB_RATS=0 \
|
||||
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
|
||||
-DWAMR_BUILD_MEMORY_PROFILING=0 \
|
||||
-DWAMR_BUILD_MINI_LOADER=0 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=0 \
|
||||
-DWAMR_BUILD_PERF_PROFILING=0 \
|
||||
-DWAMR_BUILD_SPEC_TEST=0 \
|
||||
-DWAMR_BUILD_BULK_MEMORY=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD=1 \
|
||||
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
|
||||
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||
-DWAMR_BUILD_LIBC_WASI=1 \
|
||||
-DWAMR_BUILD_REF_TYPES=1 \
|
||||
-DWAMR_BUILD_SIMD=1 \
|
||||
-DWAMR_BUILD_SHARED_MEMORY=1 \
|
||||
-DWAMR_BUILD_TAIL_CALL=1 \
|
||||
-DWAMR_BUILD_THREAD_MGR=1 \
|
||||
-DWAMR_BUILD_EXCE_HANDLING=1 \
|
||||
-DWAMR_BUILD_GC=1"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ inputs.runner }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- build_options: $DEFAULT_BUILD_OPTIONS
|
||||
suffix: ''
|
||||
- build_options: $GC_EH_BUILD_OPTIONS
|
||||
suffix: '-gc-eh'
|
||||
permissions:
|
||||
contents: write # for uploading release artifacts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: get cached LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ inputs.llvm_cache_key }}
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- name: generate iwasm binary release
|
||||
shell: bash
|
||||
run: |
|
||||
cmake -S . -B build ${{ matrix.build_options }}
|
||||
cmake --build build --config Release --parallel 4
|
||||
working-directory: ${{ inputs.cwd }}
|
||||
|
||||
- name: Compress the binary on Windows
|
||||
if: inputs.runner == 'windows-latest'
|
||||
run: |
|
||||
tar -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm.exe
|
||||
Compress-Archive -Path iwasm.exe -DestinationPath iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
|
||||
mv iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
|
||||
working-directory: ${{ inputs.cwd }}/build/Release
|
||||
|
||||
- name: compress the binary on non-Windows
|
||||
if: inputs.runner != 'windows-latest'
|
||||
run: |
|
||||
# Follow the symlink to the actual binary file
|
||||
tar --dereference -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
|
||||
zip iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm
|
||||
working-directory: ${{ inputs.cwd }}/build
|
||||
|
||||
- name: upload release tar.gz
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: ${{ inputs.cwd }}/build/iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
|
||||
asset_name: iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: upload release zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: ${{ inputs.cwd }}/build/iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
|
||||
asset_name: iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
|
||||
asset_content_type: application/zip
|
131
.github/workflows/build_llvm_libraries.yml
vendored
131
.github/workflows/build_llvm_libraries.yml
vendored
|
@ -1,131 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: Reusable workflow-build_llvm_libraries
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
os:
|
||||
required: true
|
||||
type: string
|
||||
arch:
|
||||
required: true
|
||||
type: string
|
||||
container_image:
|
||||
required: false
|
||||
type: string
|
||||
extra_build_llvm_options:
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
cache_key_suffix:
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
outputs:
|
||||
cache_key:
|
||||
description: "A cached key of LLVM libraries"
|
||||
value: ${{ jobs.build_llvm_libraries.outputs.key}}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build_llvm_libraries:
|
||||
runs-on: ${{ inputs.os }}
|
||||
# Using given container image if it is specified.
|
||||
# Otherwise, it will be ignored by the runner.
|
||||
container:
|
||||
image: ${{ inputs.container_image }}
|
||||
outputs:
|
||||
key: ${{ steps.create_lib_cache_key.outputs.key}}
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write # for uploading cached artifact
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install dependencies for non macos-14
|
||||
if: inputs.os != 'macos-14'
|
||||
shell: bash
|
||||
run: /usr/bin/env python3 -m pip install -r requirements.txt
|
||||
working-directory: build-scripts
|
||||
|
||||
- name: install dependencies for macos-14
|
||||
if: inputs.os == 'macos-14'
|
||||
run: /usr/bin/env python3 -m pip install -r requirements.txt --break-system-packages
|
||||
working-directory: build-scripts
|
||||
|
||||
- name: Retrieve the last commit ID
|
||||
id: get_last_commit
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --llvm-ver)" >> $GITHUB_OUTPUT
|
||||
working-directory: build-scripts
|
||||
|
||||
# Bump the prefix number to evict all previous caches and
|
||||
# enforce a clean build, in the unlikely case that some
|
||||
# weird build error occur and llvm/build becomes a potential
|
||||
# suspect.
|
||||
- name: form the cache key of libraries
|
||||
id: create_lib_cache_key
|
||||
shell: bash
|
||||
run: |
|
||||
echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}${{ inputs.cache_key_suffix }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ steps.create_lib_cache_key.outputs.key}}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ccache
|
||||
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
|
||||
restore-keys: |
|
||||
0-ccache-${{ inputs.os }}
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-22.04'
|
||||
|
||||
# Don't install dependencies if the cache is hit or running in docker container
|
||||
- run: sudo apt install -y ccache ninja-build
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'ubuntu') && inputs.container_image == ''
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/Library/Caches/ccache
|
||||
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
|
||||
restore-keys: |
|
||||
0-ccache-${{ inputs.os }}
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
|
||||
|
||||
- run: brew install ccache ninja
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ccache
|
||||
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
|
||||
restore-keys: |
|
||||
0-ccache-${{ inputs.os }}
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'
|
||||
|
||||
# Install tools on Windows
|
||||
- run: choco install -y ccache ninja
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'
|
||||
|
||||
- name: Build LLVM libraries
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --arch ${{ inputs.arch }}
|
||||
working-directory: build-scripts
|
269
.github/workflows/build_wamr_lldb.yml
vendored
269
.github/workflows/build_wamr_lldb.yml
vendored
|
@ -1,269 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: build wamr lldb
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
arch:
|
||||
description: arch of the release
|
||||
type: string
|
||||
required: false
|
||||
default: x86_64
|
||||
runner:
|
||||
description: OS of compilation
|
||||
type: string
|
||||
required: true
|
||||
upload_url:
|
||||
description: upload binary assets to the URL of release
|
||||
type: string
|
||||
required: true
|
||||
ver_num:
|
||||
description: a semantic version number
|
||||
type: string
|
||||
required: true
|
||||
wasi_sdk_url:
|
||||
description: download WASI_SDK from this URL
|
||||
type: string
|
||||
required: false
|
||||
default: "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
try_reuse:
|
||||
permissions:
|
||||
contents: write # for uploading release artifacts
|
||||
uses: ./.github/workflows/reuse_latest_release_binaries.yml
|
||||
with:
|
||||
binary_name_stem: "wamr-lldb-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}"
|
||||
last_commit: "ea63ba4bd010c2285623ad4acc0262a4d63bcfea"
|
||||
the_path: "./build-scripts/lldb_wasm.patch"
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
|
||||
build:
|
||||
needs: try_reuse
|
||||
if: needs.try_reuse.outputs.result != 'hit'
|
||||
runs-on: ${{ inputs.runner }}
|
||||
|
||||
env:
|
||||
PYTHON_VERSION: '3.10'
|
||||
PYTHON_UBUNTU_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz
|
||||
PYTHON_MACOS_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-apple-darwin-install_only.tar.gz
|
||||
permissions:
|
||||
contents: write # for uploading release artifacts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
run: |
|
||||
cd /opt
|
||||
basename=$(basename ${{ inputs.wasi_sdk_url }})
|
||||
sudo wget --progress=dot:giga ${{ inputs.wasi_sdk_url }}
|
||||
sudo tar -xzf ${basename}
|
||||
sudo rm ${basename}
|
||||
sudo mv wasi-sdk-* wasi-sdk
|
||||
|
||||
- name: Cache build
|
||||
id: lldb_build_cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm-project/build/bin
|
||||
./core/deps/llvm-project/build/include
|
||||
./core/deps/llvm-project/build/lib
|
||||
./core/deps/llvm-project/build/libexec
|
||||
./core/deps/llvm-project/build/share
|
||||
./core/deps/llvm-project/lldb/tools/
|
||||
./core/deps/llvm-project/wamr-lldb/
|
||||
key: ${{inputs.arch}}-${{ inputs.runner }}-lldb_build
|
||||
|
||||
- name: setup xcode macos
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
|
||||
uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: latest-stable
|
||||
|
||||
# Remove xCode command line tools, to prevent duplicate symbol compilation failures
|
||||
- name: install utils macos
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
|
||||
run: |
|
||||
brew install swig cmake ninja libedit
|
||||
sudo rm -rf /Library/Developer/CommandLineTools
|
||||
|
||||
- name: install utils ubuntu
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
|
||||
run: sudo apt update && sudo apt-get install -y lld ninja-build
|
||||
|
||||
# `git clone` takes ~7m
|
||||
- name: download llvm
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
wget https://github.com/llvm/llvm-project/archive/1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
|
||||
unzip -q 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
|
||||
mv llvm-project-1f27fe6128769f00197925c3b8f6abb9d0e5cd2e llvm-project
|
||||
working-directory: core/deps/
|
||||
|
||||
- name: apply wamr patch
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
git init
|
||||
git config user.email "action@github.com"
|
||||
git config user.name "github action"
|
||||
git apply ../../../build-scripts/lldb_wasm.patch
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- name: get stand-alone python ubuntu
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
|
||||
run: |
|
||||
wget ${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }} -O python.tar.gz
|
||||
tar -xvf python.tar.gz
|
||||
working-directory: core/deps
|
||||
|
||||
- name: get stand-alone python macos
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
|
||||
run: |
|
||||
wget ${{ env.PYTHON_MACOS_STANDALONE_BUILD }} -O python.tar.gz
|
||||
tar -xvf python.tar.gz
|
||||
working-directory: core/deps
|
||||
|
||||
- name: build lldb ubuntu
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
|
||||
run: |
|
||||
echo "start to build lldb..."
|
||||
mkdir -p wamr-lldb
|
||||
cmake -S ./llvm -B build \
|
||||
-G Ninja \
|
||||
-DCMAKE_INSTALL_PREFIX=../wamr-lldb \
|
||||
-DCMAKE_BUILD_TYPE:STRING="Release" \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;lldb" \
|
||||
-DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \
|
||||
-DLLVM_BUILD_BENCHMARKS:BOOL=OFF \
|
||||
-DLLVM_BUILD_DOCS:BOOL=OFF \
|
||||
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
|
||||
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
|
||||
-DLLVM_BUILD_TESTS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_DOCS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
|
||||
-DLLVM_ENABLE_BINDINGS:BOOL=OFF \
|
||||
-DLLVM_ENABLE_LIBXML2:BOOL=ON \
|
||||
-DLLVM_ENABLE_LLD:BOOL=ON \
|
||||
-DLLDB_ENABLE_PYTHON:BOOL=ON \
|
||||
-DLLDB_EMBED_PYTHON_HOME=ON \
|
||||
-DLLDB_PYTHON_HOME=.. \
|
||||
-DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \
|
||||
-DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}"
|
||||
cmake --build build --target lldb install --parallel $(nproc)
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- name: validate lldb ubuntu
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
|
||||
run: |
|
||||
echo "start to validate lldb..."
|
||||
mkdir -p wamr-debug
|
||||
cmake -S product-mini/platforms/linux -B wamr-debug -DWAMR_BUILD_DEBUG_INTERP=1
|
||||
cmake --build wamr-debug --parallel $(nproc)
|
||||
export LD_LIBRARY_PATH=$(pwd)/core/deps/python/lib:${LD_LIBRARY_PATH}
|
||||
python3 ci/validate_lldb.py --port 1239 --lldb core/deps/wamr-lldb/bin/lldb --wamr wamr-debug/iwasm --verbose
|
||||
working-directory: .
|
||||
|
||||
# Define CMAKE_OSX_SYSROOT to avoid the error:
|
||||
# no such file or directory: 'llvm-project/build/tools/lldb/tools/debugserver/source/mach_excServer.c'
|
||||
# no such file or directory: 'llvm-project/build/tools/lldb/tools/debugserver/source/mach_excUser.c'
|
||||
#
|
||||
# This workaround should be removed when the issue is fixed in llvm-project:
|
||||
# - https://github.com/llvm/llvm-project/pull/138020/
|
||||
- name: build lldb macos
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
|
||||
run: |
|
||||
echo "start to build lldb..."
|
||||
mkdir -p wamr-lldb
|
||||
cmake -S ./llvm -B build \
|
||||
-G Ninja \
|
||||
-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) \
|
||||
-DCMAKE_INSTALL_PREFIX=../wamr-lldb \
|
||||
-DCMAKE_BUILD_TYPE:STRING="Release" \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;lldb" \
|
||||
-DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \
|
||||
-DLLVM_BUILD_BENCHMARKS:BOOL=OFF \
|
||||
-DLLVM_BUILD_DOCS:BOOL=OFF \
|
||||
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
|
||||
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
|
||||
-DLLVM_BUILD_TESTS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_DOCS:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
|
||||
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
|
||||
-DLLVM_ENABLE_BINDINGS:BOOL=OFF \
|
||||
-DLLVM_ENABLE_LIBXML2:BOOL=ON \
|
||||
-DLLDB_BUILD_FRAMEWORK:BOOL=OFF \
|
||||
-DLLDB_ENABLE_PYTHON:BOOL=ON \
|
||||
-DLLDB_EMBED_PYTHON_HOME=ON \
|
||||
-DLLDB_PYTHON_HOME=.. \
|
||||
-DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \
|
||||
-DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}"
|
||||
cmake --build build --target lldb install --parallel $(nproc)
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- name: pack a distribution
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
mkdir -p wamr-lldb/bin
|
||||
mkdir -p wamr-lldb/lib
|
||||
cp build/bin/lldb* wamr-lldb/bin
|
||||
cp lldb/tools/lldb-vscode/package.json wamr-lldb
|
||||
cp -r lldb/tools/lldb-vscode/syntaxes/ wamr-lldb
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- name: pack ubuntu specific libraries
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
|
||||
run: |
|
||||
cp build/lib/liblldb*.so wamr-lldb/lib
|
||||
cp build/lib/liblldb*.so.* wamr-lldb/lib
|
||||
cp -R build/lib/lldb-python wamr-lldb/lib
|
||||
cp -R ../python/lib/python* wamr-lldb/lib
|
||||
cp ../python/lib/libpython${{ env.PYTHON_VERSION }}.so.1.0 wamr-lldb/lib
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- name: pack macos specific libraries
|
||||
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
|
||||
run: |
|
||||
cp build/lib/liblldb*.dylib wamr-lldb/lib
|
||||
cp -R build/lib/lldb-python wamr-lldb/lib
|
||||
cp -R ../python/lib/python* wamr-lldb/lib
|
||||
cp ../python/lib/libpython*.dylib wamr-lldb/lib
|
||||
install_name_tool -change /install/lib/libpython${{ env.PYTHON_VERSION }}.dylib @rpath/libpython${{ env.PYTHON_VERSION }}.dylib wamr-lldb/lib/liblldb.*.dylib
|
||||
# Patch path of python library -> https://github.com/indygreg/python-build-standalone/blob/85923ca3911784e6978b85d56e06e9ae75cb2dc4/docs/quirks.rst?plain=1#L412-L446
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- name: compress the binary
|
||||
run: |
|
||||
tar czf wamr-lldb-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamr-lldb
|
||||
zip -r wamr-lldb-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamr-lldb
|
||||
working-directory: core/deps/llvm-project
|
||||
|
||||
- name: upload release tar.gz
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: core/deps/llvm-project/wamr-lldb-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
|
||||
asset_name: wamr-lldb-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: upload release zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: core/deps/llvm-project/wamr-lldb-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
|
||||
asset_name: wamr-lldb-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
|
||||
asset_content_type: application/zip
|
109
.github/workflows/build_wamr_sdk.yml
vendored
109
.github/workflows/build_wamr_sdk.yml
vendored
|
@ -1,109 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: build wamr-sdk
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
arch:
|
||||
description: arch of the release
|
||||
type: string
|
||||
required: false
|
||||
default: x86_64
|
||||
config_file:
|
||||
description: warm-sdk config file path
|
||||
type: string
|
||||
required: true
|
||||
runner:
|
||||
description: OS of compilation
|
||||
type: string
|
||||
required: true
|
||||
upload_url:
|
||||
description: upload binary assets to the URL of release
|
||||
type: string
|
||||
required: true
|
||||
ver_num:
|
||||
description: a semantic version number
|
||||
type: string
|
||||
required: true
|
||||
wasi_sdk_url:
|
||||
description: download WASI_SDK from this URL
|
||||
type: string
|
||||
required: true
|
||||
wamr_app_framework_url:
|
||||
description: download WAMR app framework to get wamr_sdk
|
||||
type: string
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ inputs.runner }}
|
||||
permissions:
|
||||
contents: write # for uploading release artifacts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: download wamr-app-framework
|
||||
run: |
|
||||
git clone ${{ inputs.wamr_app_framework_url }}
|
||||
cd wamr-app-framework
|
||||
git submodule init
|
||||
git submodule update
|
||||
working-directory: wamr-sdk
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
run: |
|
||||
cd /opt
|
||||
basename=$(basename ${{ inputs.wasi_sdk_url }})
|
||||
sudo wget --progress=dot:giga ${{ inputs.wasi_sdk_url }}
|
||||
sudo tar -xzf ${basename}
|
||||
sudo rm ${basename}
|
||||
sudo mv wasi-sdk-* wasi-sdk
|
||||
|
||||
- name: download dependencies
|
||||
run: |
|
||||
cd ./wamr-app-framework/deps
|
||||
./download.sh
|
||||
working-directory: wamr-sdk
|
||||
|
||||
- name: generate wamr-sdk release
|
||||
run: |
|
||||
cd ./wamr-app-framework/wamr-sdk
|
||||
./build_sdk.sh -n wamr-sdk -x $(pwd)/${{ inputs.config_file }}
|
||||
working-directory: wamr-sdk
|
||||
|
||||
- name: compress the binary
|
||||
run: |
|
||||
cd wamr-app-framework/wamr-sdk/out
|
||||
tar czf wamr-sdk-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamr-sdk
|
||||
zip -r wamr-sdk-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamr-sdk
|
||||
working-directory: wamr-sdk
|
||||
|
||||
- name: upload release tar.gz
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: wamr-sdk/wamr-app-framework/wamr-sdk/out/wamr-sdk-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
|
||||
asset_name: wamr-sdk-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: upload release zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: wamr-sdk/wamr-app-framework/wamr-sdk/out/wamr-sdk-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
|
||||
asset_name: wamr-sdk-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: delete wamr-app-framework
|
||||
run: |
|
||||
rm -rf wamr-app-framework
|
||||
working-directory: wamr-sdk
|
79
.github/workflows/build_wamr_vscode_ext.yml
vendored
79
.github/workflows/build_wamr_vscode_ext.yml
vendored
|
@ -1,79 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: build wamr-ide vscode extension
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
upload_url:
|
||||
description: upload binary assets to the URL of release
|
||||
type: string
|
||||
required: true
|
||||
ver_num:
|
||||
description: a semantic version number.
|
||||
type: string
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
contents: write # for uploading release artifacts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Use Node.js 18.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
|
||||
- name: set vscode extension to correct version
|
||||
run: |
|
||||
npm install -g json
|
||||
json -I -f package.json -e "this.version=\"${{ inputs.ver_num }}\""
|
||||
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||
|
||||
- name: generate wamr ide vscode extension
|
||||
run: |
|
||||
npm install -g @vscode/vsce
|
||||
rm -rf node_modules
|
||||
npm install
|
||||
vsce package
|
||||
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||
|
||||
- name: publish wamr ide vscode extension to the vsce marketplace
|
||||
if: ${{ github.repository == 'bytecodealliance/wasm-micro-runtime' }}
|
||||
run: |
|
||||
vsce publish -p ${{ secrets.TOKEN }}
|
||||
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||
|
||||
- name: compress the vscode extension
|
||||
run: |
|
||||
mv wamride-*.vsix wamr-ide.vsix
|
||||
tar czf wamr-ide-${{ inputs.ver_num }}.tar.gz wamr-ide.vsix
|
||||
zip wamr-ide-${{ inputs.ver_num }}.zip wamr-ide.vsix
|
||||
working-directory: test-tools/wamr-ide/VSCode-Extension
|
||||
|
||||
- name: upload release tar.gz
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: test-tools/wamr-ide/VSCode-Extension/wamr-ide-${{ inputs.ver_num }}.tar.gz
|
||||
asset_name: wamr-ide-${{ inputs.ver_num }}.tar.gz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: upload release zip
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: test-tools/wamr-ide/VSCode-Extension/wamr-ide-${{ inputs.ver_num }}.zip
|
||||
asset_name: wamr-ide-${{ inputs.ver_num }}.zip
|
||||
asset_content_type: application/zip
|
101
.github/workflows/build_wamrc.yml
vendored
101
.github/workflows/build_wamrc.yml
vendored
|
@ -1,101 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: build wamrc
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
arch:
|
||||
description: arch of the release
|
||||
type: string
|
||||
required: false
|
||||
default: x86_64
|
||||
llvm_cache_key:
|
||||
description: the cache key of llvm libraries
|
||||
type: string
|
||||
required: true
|
||||
release:
|
||||
description: it is a part of the release process
|
||||
type: boolean
|
||||
required: true
|
||||
runner:
|
||||
description: OS of compilation
|
||||
type: string
|
||||
required: true
|
||||
upload_url:
|
||||
description: a semantic version number. it is required when `release` is true.
|
||||
type: string
|
||||
required: false
|
||||
ver_num:
|
||||
description: a semantic version number. it is required when `release` is true.
|
||||
type: string
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ inputs.runner }}
|
||||
permissions:
|
||||
contents: write # for uploading release artifacts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: get cached LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ inputs.llvm_cache_key }}
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- name: generate wamrc binary release
|
||||
run: |
|
||||
cmake -S . -B build
|
||||
cmake --build build --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Compress the binary on Windows
|
||||
if: inputs.runner == 'windows-latest' && inputs.release
|
||||
run: |
|
||||
tar -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
|
||||
Compress-Archive -Path wamrc.exe -DestinationPath wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
|
||||
mv wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
|
||||
working-directory: wamr-compiler/build/Release
|
||||
|
||||
- name: compress the binary on non-Windows
|
||||
if: inputs.runner != 'windows-latest' && inputs.release
|
||||
run: |
|
||||
# Follow the symlink to the actual binary file
|
||||
tar --dereference -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
|
||||
zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
|
||||
working-directory: wamr-compiler/build
|
||||
|
||||
- name: upload release tar.gz
|
||||
if: inputs.release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
|
||||
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: upload release zip
|
||||
if: inputs.release
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
|
||||
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
|
||||
asset_content_type: application/zip
|
29
.github/workflows/check_version_h.yml
vendored
29
.github/workflows/check_version_h.yml
vendored
|
@ -1,29 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: confirm version.h stay in sync
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
confirm_version:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: cmake execute to generate version.h
|
||||
run: cmake -B build_version -S .
|
||||
|
||||
- name: confirm version.h
|
||||
run: |
|
||||
if [ -z "$(git status --porcelain | grep version.h)" ]; then
|
||||
echo "version.h is in sync"
|
||||
else
|
||||
echo "version.h is not in sync"
|
||||
exit 1
|
||||
fi
|
121
.github/workflows/codeql.yml
vendored
121
.github/workflows/codeql.yml
vendored
|
@ -1,121 +0,0 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
#pull_request:
|
||||
# types:
|
||||
# - opened
|
||||
# branches: '*'
|
||||
#push:
|
||||
# branches: [ "main" ]
|
||||
# midnight UTC
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
if: github.repository == 'bytecodealliance/wasm-micro-runtime'
|
||||
name: Analyze
|
||||
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
||||
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
||||
# - https://gh.io/supported-runners-and-hardware-resources
|
||||
# - https://gh.io/using-larger-runners
|
||||
# Consider using larger runners for possible analysis time improvements.
|
||||
runs-on: ${{ (matrix.language == 'swift' && 'macos-13') || 'ubuntu-22.04' }}
|
||||
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3.29.0
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
queries: security-and-quality
|
||||
|
||||
# Command-line programs to run using the OS shell.
|
||||
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
|
||||
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
||||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
||||
|
||||
- run: |
|
||||
./.github/scripts/codeql_buildscript.sh
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3.29.0
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
upload: false
|
||||
id: step1
|
||||
|
||||
# Filter out rules with low severity or high false positve rate
|
||||
# Also filter out warnings in third-party code
|
||||
- name: Filter out unwanted errors and warnings
|
||||
uses: advanced-security/filter-sarif@v1
|
||||
with:
|
||||
patterns: |
|
||||
-**:cpp/path-injection
|
||||
-**:cpp/world-writable-file-creation
|
||||
-**:cpp/poorly-documented-function
|
||||
-**:cpp/potentially-dangerous-function
|
||||
-**:cpp/use-of-goto
|
||||
-**:cpp/integer-multiplication-cast-to-long
|
||||
-**:cpp/comparison-with-wider-type
|
||||
-**:cpp/leap-year/*
|
||||
-**:cpp/ambiguously-signed-bit-field
|
||||
-**:cpp/suspicious-pointer-scaling
|
||||
-**:cpp/suspicious-pointer-scaling-void
|
||||
-**:cpp/unsigned-comparison-zero
|
||||
-**/cmake*/Modules/**
|
||||
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
||||
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
||||
|
||||
- name: Upload CodeQL results to code scanning
|
||||
uses: github/codeql-action/upload-sarif@v3.29.0
|
||||
with:
|
||||
sarif_file: ${{ steps.step1.outputs.sarif-output }}
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
- name: Upload CodeQL results as an artifact
|
||||
if: success() || failure()
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: codeql-results
|
||||
path: ${{ steps.step1.outputs.sarif-output }}
|
||||
retention-days: 10
|
||||
|
||||
- name: Fail if an error is found
|
||||
run: |
|
||||
./.github/scripts/codeql_fail_on_error.py \
|
||||
${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
31
.github/workflows/coding_guidelines.yml
vendored
31
.github/workflows/coding_guidelines.yml
vendored
|
@ -1,31 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: Coding Guidelines
|
||||
|
||||
on:
|
||||
# will be triggered on PR events
|
||||
pull_request:
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
compliance_job:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# github.event.pull_request.base.label = ${{github.repository}}/${{github.base_ref}}
|
||||
- name: Run Coding Guidelines Checks
|
||||
run: /usr/bin/env python3 ./ci/coding_guidelines_check.py --commits ${{ github.event.pull_request.base.sha }}..HEAD
|
723
.github/workflows/compilation_on_android_ubuntu.yml
vendored
723
.github/workflows/compilation_on_android_ubuntu.yml
vendored
|
@ -1,723 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: compilation on android, ubuntu-22.04
|
||||
|
||||
on:
|
||||
# will be triggered on PR events
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths:
|
||||
- ".github/workflows/build_llvm_libraries.yml"
|
||||
- ".github/workflows/compilation_on_android_ubuntu.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "tests/unit/**"
|
||||
- "wamr-compiler/**"
|
||||
- "test-tools/wamr-ide/**"
|
||||
# will be triggered on push events
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "dev/**"
|
||||
paths:
|
||||
- ".github/workflows/build_llvm_libraries.yml"
|
||||
- ".github/workflows/compilation_on_android_ubuntu.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "tests/unit/**"
|
||||
- "wamr-compiler/**"
|
||||
- "test-tools/wamr-ide/**"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# For BUILD
|
||||
AOT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_INTERP_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
LLVM_LAZY_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
# For Spec Test
|
||||
DEFAULT_TEST_OPTIONS: "-s spec -b -P"
|
||||
MULTI_MODULES_TEST_OPTIONS: "-s spec -b -M -P"
|
||||
SIMD_TEST_OPTIONS: "-s spec -b -S -P"
|
||||
THREADS_TEST_OPTIONS: "-s spec -b -p -P"
|
||||
X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
|
||||
WASI_TEST_OPTIONS: "-s wasi_certification -w"
|
||||
WAMR_COMPILER_TEST_OPTIONS: "-s wamr_compiler -S -b -P"
|
||||
GC_TEST_OPTIONS: "-s spec -G -b -P"
|
||||
MEMORY64_TEST_OPTIONS: "-s spec -W -b -P"
|
||||
MULTI_MEMORY_TEST_OPTIONS: "-s spec -E -b -P"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check_version_h:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/check_version_h.yml
|
||||
|
||||
build_llvm_libraries_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "ubuntu-22.04"
|
||||
arch: "X86"
|
||||
|
||||
build_wamrc:
|
||||
needs:
|
||||
[build_llvm_libraries_on_ubuntu_2204]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# since jobs.id can't contain the dot character
|
||||
# it is hard to use `format` to assemble the cache key
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
build_iwasm:
|
||||
needs:
|
||||
[build_llvm_libraries_on_ubuntu_2204]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
make_options_run_mode: [
|
||||
# Running mode
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
$MULTI_TIER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
make_options_feature: [
|
||||
# Features
|
||||
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
|
||||
"-DWAMR_BUILD_DEBUG_AOT=1",
|
||||
"-DWAMR_BUILD_DEBUG_INTERP=1",
|
||||
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
|
||||
"-DWAMR_BUILD_LIB_PTHREAD=1",
|
||||
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
|
||||
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
|
||||
"-DWAMR_BUILD_MINI_LOADER=1",
|
||||
"-DWAMR_BUILD_MEMORY_PROFILING=1",
|
||||
"-DWAMR_BUILD_MULTI_MODULE=1",
|
||||
"-DWAMR_BUILD_PERF_PROFILING=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
"-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_LIB_SIMDE=1",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_MEMORY64=1",
|
||||
"-DWAMR_BUILD_MULTI_MEMORY=1",
|
||||
"-DWAMR_BUILD_SHARED=1",
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
platform: [android, linux]
|
||||
exclude:
|
||||
# incompatible feature and platform
|
||||
# incompatible mode and feature
|
||||
# MULTI_MODULE only on INTERP mode and AOT mode
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
# SIMD only on JIT/AOT/fast interpreter mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
# DEBUG_INTERP only on CLASSIC INTERP mode
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
# DEBUG_AOT only on JIT/AOT mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
# TODO: DEBUG_AOT on JIT
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
# MINI_LOADER only on INTERP mode
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
# Memory64 only on CLASSIC INTERP and AOT mode, and only on 64-bit platform
|
||||
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
platform: android
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
# Multi memory only on CLASSIC INTERP mode, and only on 64-bit platform
|
||||
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
platform: android
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
# Fast-JIT and Multi-Tier-JIT mode don't support android
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
# LLVM JIT pre-built binary wasn't compiled by Android NDK
|
||||
# and isn't available for android
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
# android does not support WAMR_BUILD_SHARED in its CMakeLists.txt.
|
||||
- make_options_feature: "-DWAMR_BUILD_SHARED=1"
|
||||
platform: android
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# only download llvm cache when needed
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build iwasm for linux
|
||||
if: matrix.platform == 'linux'
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}
|
||||
|
||||
- name: Build iwasm for android
|
||||
if: matrix.platform == 'android'
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} \
|
||||
-DWAMR_BUILD_TARGET=X86_64
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}
|
||||
|
||||
build_unit_tests:
|
||||
needs:
|
||||
[
|
||||
build_llvm_libraries_on_ubuntu_2204,
|
||||
build_wamrc
|
||||
]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
build_target: [
|
||||
"X86_64",
|
||||
"X86_32",
|
||||
]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Install dependencies for X86_32
|
||||
if: matrix.build_target == 'X86_32'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y g++-multilib
|
||||
|
||||
- name: Build and run unit tests
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_TARGET=${{ matrix.build_target }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
ctest
|
||||
working-directory: tests/unit
|
||||
|
||||
build_samples_wasm_c_api:
|
||||
needs:
|
||||
[
|
||||
build_iwasm,
|
||||
build_llvm_libraries_on_ubuntu_2204,
|
||||
build_wamrc,
|
||||
]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
make_options: [
|
||||
# Running mode
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
$MULTI_TIER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [wasm-c-api]
|
||||
run: |
|
||||
VERBOSE=1
|
||||
cmake -S . -B build ${{ matrix.make_options }}
|
||||
cmake --build build --config Debug --parallel 4
|
||||
ctest --test-dir build --output-on-failure
|
||||
working-directory: samples/wasm-c-api
|
||||
|
||||
- name: Build Sample [printversion]
|
||||
run: |
|
||||
./test.sh
|
||||
working-directory: samples/printversion
|
||||
|
||||
build_samples_others:
|
||||
needs:
|
||||
[
|
||||
build_iwasm,
|
||||
build_llvm_libraries_on_ubuntu_2204,
|
||||
build_wamrc,
|
||||
]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [basic]
|
||||
run: |
|
||||
cd samples/basic
|
||||
./build.sh
|
||||
./run.sh
|
||||
|
||||
- name: Build Sample [file]
|
||||
run: |
|
||||
cd samples/file
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./src/iwasm -f wasm-app/file.wasm -d .
|
||||
|
||||
- name: Build Sample [multi-thread]
|
||||
run: |
|
||||
cd samples/multi-thread
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./iwasm wasm-apps/test.wasm
|
||||
|
||||
- name: Build Sample [multi-module]
|
||||
run: |
|
||||
cd samples/multi-module
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=1
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./multi_module mC.wasm
|
||||
./multi_module mC.aot
|
||||
|
||||
- name: Build Sample [spawn-thread]
|
||||
run: |
|
||||
cd samples/spawn-thread
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./spawn_thread
|
||||
|
||||
- name: Build Sample [ref-types]
|
||||
run: |
|
||||
cd samples/ref-types
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./hello
|
||||
|
||||
- name: Build Sample [wasi-threads]
|
||||
run: |
|
||||
cd samples/wasi-threads
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./iwasm wasm-apps/no_pthread.wasm
|
||||
|
||||
- name: Build Sample [shared-module]
|
||||
run: |
|
||||
cd samples/shared-module
|
||||
./build.sh
|
||||
./run.sh
|
||||
|
||||
- name: Build Sample [terminate]
|
||||
run: |
|
||||
cd samples/terminate
|
||||
./build.sh
|
||||
./run.sh
|
||||
|
||||
- name: Build Sample [debug-tools]
|
||||
run: |
|
||||
cd samples/debug-tools
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./iwasm wasm-apps/trap.wasm | grep "#" > call_stack.txt
|
||||
./iwasm wasm-apps/trap.aot | grep "#" > call_stack_aot.txt
|
||||
bash -x ../symbolicate.sh
|
||||
|
||||
- name: Build Sample [native-stack-overflow]
|
||||
run: |
|
||||
cd samples/native-stack-overflow
|
||||
./build.sh
|
||||
./run.sh test1
|
||||
./run.sh test2
|
||||
|
||||
- name: Build Sample [shared-heap]
|
||||
run: |
|
||||
cd samples/shared-heap
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./shared_heap_test
|
||||
./shared_heap_test --aot
|
||||
|
||||
test:
|
||||
needs:
|
||||
[
|
||||
build_iwasm,
|
||||
build_llvm_libraries_on_ubuntu_2204,
|
||||
build_wamrc,
|
||||
]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
running_mode:
|
||||
[
|
||||
"classic-interp",
|
||||
"fast-interp",
|
||||
"jit",
|
||||
"aot",
|
||||
"fast-jit",
|
||||
"multi-tier-jit",
|
||||
]
|
||||
test_option:
|
||||
[
|
||||
$DEFAULT_TEST_OPTIONS,
|
||||
$MULTI_MODULES_TEST_OPTIONS,
|
||||
$SIMD_TEST_OPTIONS,
|
||||
$THREADS_TEST_OPTIONS,
|
||||
$WASI_TEST_OPTIONS,
|
||||
$GC_TEST_OPTIONS,
|
||||
$MEMORY64_TEST_OPTIONS,
|
||||
$MULTI_MEMORY_TEST_OPTIONS,
|
||||
]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
ubuntu_version: "22.04"
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
running_mode: aot
|
||||
test_option: $WAMR_COMPILER_TEST_OPTIONS
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set-up OCaml
|
||||
uses: ocaml/setup-ocaml@v3
|
||||
if: matrix.test_option == '$GC_TEST_OPTIONS'
|
||||
with:
|
||||
ocaml-compiler: 4.13
|
||||
|
||||
- name: Set-up Ocamlbuild
|
||||
if: matrix.test_option == '$GC_TEST_OPTIONS'
|
||||
run: opam install ocamlbuild dune menhir
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: set env variable(if llvm are used)
|
||||
if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
|
||||
run: echo "USE_LLVM=true" >> $GITHUB_ENV
|
||||
|
||||
- name: set env variable(if x86_32 test needed)
|
||||
if: >
|
||||
((matrix.test_option == '$DEFAULT_TEST_OPTIONS' || matrix.test_option == '$THREADS_TEST_OPTIONS'
|
||||
|| matrix.test_option == '$WASI_TEST_OPTIONS' || matrix.test_option == '$GC_TEST_OPTIONS')
|
||||
&& matrix.test_option != '$MEMORY64_TEST_OPTIONS'
|
||||
&& matrix.running_mode != 'fast-jit' && matrix.running_mode != 'jit' && matrix.running_mode != 'multi-tier-jit')
|
||||
run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
|
||||
|
||||
#only download llvm libraries in jit and aot mode
|
||||
- name: Get LLVM libraries
|
||||
if: env.USE_LLVM == 'true'
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: env.USE_LLVM == 'true' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install jq JSON processor
|
||||
if: matrix.running_mode == 'aot' && matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: sudo apt-get update && sudo apt install -y jq
|
||||
|
||||
- name: Build WASI thread tests
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: bash build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
|
||||
|
||||
- name: build socket api tests
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: bash build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-socket/test/
|
||||
|
||||
- name: run tests
|
||||
timeout-minutes: 30
|
||||
if: matrix.test_option != '$GC_TEST_OPTIONS'
|
||||
run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
working-directory: ./tests/wamr-test-suites
|
||||
|
||||
- name: run gc tests
|
||||
timeout-minutes: 20
|
||||
if: matrix.test_option == '$GC_TEST_OPTIONS'
|
||||
run: |
|
||||
eval $(opam env)
|
||||
./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
working-directory: ./tests/wamr-test-suites
|
||||
|
||||
#only install x32 support libraries when to run x86_32 cases
|
||||
- name: install x32 support libraries
|
||||
if: env.TEST_ON_X86_32 == 'true'
|
||||
run:
|
||||
# Add another apt repository as some packages cannot
|
||||
# be downloaded with the github default repository
|
||||
sudo curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc &&
|
||||
sudo apt-add-repository https://packages.microsoft.com/ubuntu/${{ matrix.ubuntu_version }}/prod &&
|
||||
sudo apt-get update &&
|
||||
sudo apt install -y g++-multilib lib32gcc-9-dev
|
||||
|
||||
- name: run tests x86_32
|
||||
timeout-minutes: 30
|
||||
if: env.TEST_ON_X86_32 == 'true' && matrix.test_option != '$GC_TEST_OPTIONS'
|
||||
run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
working-directory: ./tests/wamr-test-suites
|
||||
|
||||
- name: run gc tests x86_32
|
||||
timeout-minutes: 20
|
||||
if: env.TEST_ON_X86_32 == 'true' && matrix.test_option == '$GC_TEST_OPTIONS'
|
||||
run: |
|
||||
eval $(opam env)
|
||||
./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
working-directory: ./tests/wamr-test-suites
|
423
.github/workflows/compilation_on_macos.yml
vendored
423
.github/workflows/compilation_on_macos.yml
vendored
|
@ -1,423 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: compilation on macos
|
||||
|
||||
on:
|
||||
# will be triggered on PR events
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths:
|
||||
- ".github/workflows/build_llvm_libraries.yml"
|
||||
- ".github/workflows/compilation_on_macos.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# will be triggered on push events
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "dev/**"
|
||||
paths:
|
||||
- ".github/workflows/build_llvm_libraries.yml"
|
||||
- ".github/workflows/compilation_on_macos.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# For BUILD
|
||||
AOT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_INTERP_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
LLVM_LAZY_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build_llvm_libraries_on_intel_macos:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "macos-13"
|
||||
arch: "X86"
|
||||
build_llvm_libraries_on_arm_macos:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "macos-14"
|
||||
arch: "AArch64 ARM"
|
||||
|
||||
build_wamrc:
|
||||
needs: [build_llvm_libraries_on_intel_macos]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-13
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
build_iwasm:
|
||||
needs: [build_llvm_libraries_on_intel_macos]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
make_options_run_mode: [
|
||||
# Running mode
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
make_options_feature: [
|
||||
# Features
|
||||
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
|
||||
# doesn't support
|
||||
#"-DWAMR_BUILD_DEBUG_AOT=1",
|
||||
"-DWAMR_BUILD_DEBUG_INTERP=1",
|
||||
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
|
||||
"-DWAMR_BUILD_LIB_PTHREAD=1",
|
||||
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
|
||||
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
|
||||
"-DWAMR_BUILD_MINI_LOADER=1",
|
||||
"-DWAMR_BUILD_MEMORY_PROFILING=1",
|
||||
"-DWAMR_BUILD_MULTI_MODULE=1",
|
||||
"-DWAMR_BUILD_PERF_PROFILING=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
"-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
]
|
||||
os: [macos-13]
|
||||
platform: [darwin]
|
||||
exclude:
|
||||
# incompatible feature and platform
|
||||
# incompatible mode and feature
|
||||
# MULTI_MODULE only on INTERP mode and AOT mode
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
# SIMD only on JIT/AOT mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
# DEBUG_INTERP only on CLASSIC INTERP mode
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
# DEBUG_AOT only on JIT/AOT mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
# TODO: DEBUG_AOT on JIT
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
# MINI_LOADER only on INTERP mode
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
include:
|
||||
- os: macos-13
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# only download llvm cache when needed
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build iwasm
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}
|
||||
|
||||
build_samples_wasm_c_api:
|
||||
needs:
|
||||
[
|
||||
build_iwasm,
|
||||
build_llvm_libraries_on_intel_macos,
|
||||
build_wamrc,
|
||||
]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
make_options: [
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
$MULTI_TIER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
os: [macos-13]
|
||||
include:
|
||||
- os: macos-13
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [wasm-c-api]
|
||||
run: |
|
||||
VERBOSE=1
|
||||
cmake -S . -B build ${{ matrix.make_options }}
|
||||
cmake --build build --config Debug --parallel 4
|
||||
ctest --test-dir build --output-on-failure
|
||||
working-directory: samples/wasm-c-api
|
||||
|
||||
- name: Build Sample [printversion]
|
||||
run: |
|
||||
./test.sh
|
||||
working-directory: samples/printversion
|
||||
|
||||
build_samples_others:
|
||||
needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13, macos-14]
|
||||
include:
|
||||
- os: macos-13
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
|
||||
- os: macos-14
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_arm_macos.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build Sample [basic]
|
||||
run: |
|
||||
cd samples/basic
|
||||
./build.sh
|
||||
./run.sh
|
||||
|
||||
- name: Build Sample [file]
|
||||
run: |
|
||||
cd samples/file
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./src/iwasm -f wasm-app/file.wasm -d .
|
||||
|
||||
- name: Build Sample [multi-thread]
|
||||
run: |
|
||||
cd samples/multi-thread
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./iwasm wasm-apps/test.wasm
|
||||
|
||||
- name: Build Sample [multi-module]
|
||||
run: |
|
||||
cd samples/multi-module
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./multi_module mC.wasm
|
||||
|
||||
- name: Build Sample [spawn-thread]
|
||||
run: |
|
||||
cd samples/spawn-thread
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./spawn_thread
|
||||
|
||||
- name: Build Sample [ref-types]
|
||||
run: |
|
||||
cd samples/ref-types
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./hello
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
# cmake --build . --config Debug --parallel 4
|
||||
- name: Build Sample [wasi-threads]
|
||||
run: |
|
||||
cd samples/wasi-threads
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --verbose
|
||||
./iwasm wasm-apps/no_pthread.wasm
|
||||
|
||||
../../../wamr-compiler/build/wamrc --size-level=0 --enable-multi-thread -o wasm-apps/no_pthread.aot wasm-apps/no_pthread.wasm
|
||||
./iwasm wasm-apps/no_pthread.aot
|
||||
|
||||
- name: Build Sample [shared-module]
|
||||
run: |
|
||||
cd samples/shared-module
|
||||
./build.sh
|
||||
./run.sh
|
||||
|
||||
- name: Build Sample [terminate]
|
||||
run: |
|
||||
cd samples/terminate
|
||||
./build.sh
|
||||
./run.sh
|
||||
|
||||
- name: Build Sample [debug-tools]
|
||||
run: |
|
||||
cd samples/debug-tools
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./iwasm wasm-apps/trap.wasm | grep "#" > call_stack.txt
|
||||
./iwasm wasm-apps/trap.aot | grep "#" > call_stack_aot.txt
|
||||
bash -x ../symbolicate.sh
|
||||
|
||||
- name: Build Sample [native-stack-overflow]
|
||||
run: |
|
||||
cd samples/native-stack-overflow
|
||||
./build.sh
|
||||
./run.sh test1
|
||||
./run.sh test2
|
||||
|
||||
- name: Build Sample [shared-heap]
|
||||
run: |
|
||||
cd samples/shared-heap
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./shared_heap_test
|
||||
./shared_heap_test --aot
|
146
.github/workflows/compilation_on_nuttx.yml
vendored
146
.github/workflows/compilation_on_nuttx.yml
vendored
|
@ -1,146 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: compilation on nuttx
|
||||
|
||||
on:
|
||||
# will be triggered on PR events
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths:
|
||||
- ".github/workflows/compilation_on_nuttx.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# will be triggered on push events
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "dev/**"
|
||||
paths:
|
||||
- ".github/workflows/compilation_on_nuttx.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
WASI_SDK_PATH: "/opt/wasi-sdk"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build_iwasm_on_nuttx:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/apache/nuttx/apache-nuttx-ci-linux@sha256:d9261eacf6c6ebe656c571757751c803e8f04c3ae9b820320a5ea5dd57b7205a
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
nuttx_board_config: [
|
||||
# x64
|
||||
"boards/sim/sim/sim/configs/nsh",
|
||||
# cortex-m0
|
||||
"boards/arm/rp2040/raspberrypi-pico/configs/nsh",
|
||||
# cortex-m7
|
||||
"boards/arm/stm32h7/nucleo-h743zi/configs/nsh",
|
||||
# riscv32gc
|
||||
"boards/risc-v/qemu-rv/rv-virt/configs/nsh",
|
||||
# riscv64gc
|
||||
"boards/risc-v/qemu-rv/rv-virt/configs/nsh64",
|
||||
# arm64
|
||||
"boards/arm64/qemu/qemu-armv8a/configs/nsh",
|
||||
]
|
||||
|
||||
wamr_config_option:
|
||||
- "CONFIG_INTERPRETERS_WAMR_AOT"
|
||||
- "CONFIG_INTERPRETERS_WAMR_FAST"
|
||||
- "CONFIG_INTERPRETERS_WAMR_CLASSIC"
|
||||
- "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST"
|
||||
- "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_WASI"
|
||||
- "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN"
|
||||
- "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC"
|
||||
- "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI"
|
||||
- "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI"
|
||||
|
||||
steps:
|
||||
- name: Checkout NuttX
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: apache/nuttx
|
||||
ref: releases/12.9
|
||||
path: nuttx
|
||||
|
||||
- name: Checkout NuttX Apps
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: apache/nuttx-apps
|
||||
ref: releases/12.9
|
||||
path: apps
|
||||
|
||||
- name: Checkout WAMR
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.repository }}
|
||||
path: apps/interpreters/wamr/wamr
|
||||
|
||||
- name: Configure WAMR
|
||||
working-directory: nuttx
|
||||
run: |
|
||||
tools/configure.sh ${{ matrix.nuttx_board_config }}
|
||||
kconfig-tweak --enable CONFIG_PSEUDOFS_SOFTLINKS
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_IWASM_TASK
|
||||
kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_PRIORITY 100
|
||||
kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 8192
|
||||
for x in ${{ matrix.wamr_config_option }}; do
|
||||
kconfig-tweak --enable $x
|
||||
done
|
||||
|
||||
- name: Build
|
||||
working-directory: nuttx
|
||||
run: make -j$(nproc) EXTRAFLAGS=-Werror
|
||||
|
||||
- name: Checkout Bloaty
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: google/bloaty
|
||||
submodules: recursive
|
||||
path: bloaty
|
||||
ref: 34f4a66559ad4938c1e629e9b5f54630b2b4d7b0
|
||||
|
||||
- name: Build Bloaty
|
||||
run: |
|
||||
cmake -Bbuild -GNinja bloaty
|
||||
cmake --build build
|
||||
|
||||
- name: Size Report
|
||||
run: |
|
||||
echo "Build target: ${{ matrix.nuttx_board_config }}"
|
||||
echo "WAMR build config: ${{ matrix.wamr_config_option }}"
|
||||
echo "WAMR size:"
|
||||
build/bloaty -d compileunits --source-filter wamr nuttx/nuttx
|
||||
echo "libc-builtin size (if enabled):"
|
||||
build/bloaty -d compileunits --source-filter libc-builtin nuttx/nuttx
|
||||
echo "libc-wasi size (if enabled):"
|
||||
build/bloaty -d compileunits --source-filter libc-wasi nuttx/nuttx
|
317
.github/workflows/compilation_on_sgx.yml
vendored
317
.github/workflows/compilation_on_sgx.yml
vendored
|
@ -1,317 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: compilation on SGX
|
||||
|
||||
on:
|
||||
# will be triggered on PR events
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths:
|
||||
- ".github/workflows/build_llvm_libraries.yml"
|
||||
- ".github/workflows/compilation_on_sgx.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# will be triggered on push events
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "dev/**"
|
||||
paths:
|
||||
- ".github/workflows/build_llvm_libraries.yml"
|
||||
- ".github/workflows/compilation_on_sgx.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# ref types enabled in wamrc by default, so we need to enable it for iwasm in AOT mode
|
||||
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_REF_TYPES=1"
|
||||
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0 -DWAMR_BUILD_SIMD=0"
|
||||
FAST_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
# For Spec Test
|
||||
DEFAULT_TEST_OPTIONS: "-s spec -x -p -b"
|
||||
SIMD_TEST_OPTIONS: "-s spec -x -p -b -S"
|
||||
XIP_TEST_OPTIONS: "-s spec -x -p -b -X"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build_llvm_libraries:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: ubuntu-22.04
|
||||
arch: "X86"
|
||||
|
||||
build_iwasm:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
make_options_run_mode: [
|
||||
# Running modes supported
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
# Running modes unsupported
|
||||
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
make_options_feature: [
|
||||
# Features
|
||||
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
|
||||
# doesn't support
|
||||
# "-DWAMR_BUILD_DEBUG_AOT=1",
|
||||
# "-DWAMR_BUILD_DEBUG_INTERP=1",
|
||||
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
|
||||
"-DWAMR_BUILD_LIB_PTHREAD=1",
|
||||
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
|
||||
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
|
||||
"-DWAMR_BUILD_MINI_LOADER=1",
|
||||
"-DWAMR_BUILD_MEMORY_PROFILING=1",
|
||||
"-DWAMR_BUILD_MULTI_MODULE=1",
|
||||
"-DWAMR_BUILD_PERF_PROFILING=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
# doesn't support
|
||||
"-DWAMR_BUILD_SIMD=0",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_SGX_IPFS=1",
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
platform: [linux-sgx]
|
||||
exclude:
|
||||
# incompatible mode and feature
|
||||
# MINI_LOADER only on INTERP mode
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install SGX SDK and necessary libraries
|
||||
uses: ./.github/actions/install-linux-sgx
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build iwasm
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
cd ../enclave-sample
|
||||
make
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}
|
||||
|
||||
run_samples_file:
|
||||
needs: [build_iwasm, build_llvm_libraries]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
iwasm_make_options_run_mode: [
|
||||
# Running modes supported
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
# Running modes unsupported
|
||||
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
iwasm_make_options_feature: [
|
||||
# Features to be tested: IPFS
|
||||
"-DWAMR_BUILD_SGX_IPFS=1",
|
||||
]
|
||||
platform: [linux-sgx]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: install SGX SDK and necessary libraries
|
||||
uses: ./.github/actions/install-linux-sgx
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build iwasm for testing samples
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.iwasm_make_options_run_mode }} ${{ matrix.iwasm_make_options_feature }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
cd ../enclave-sample
|
||||
make
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}
|
||||
|
||||
- name: Get LLVM libraries
|
||||
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- name: Build wamrc only for testing samples in aot mode
|
||||
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
|
||||
run: |
|
||||
cmake -S . -B build
|
||||
cmake --build build --config Release --parallel 4
|
||||
cp build/wamrc ../product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [file]
|
||||
run: |
|
||||
cmake -S . -B build
|
||||
cmake --build build --config Debug --parallel 4
|
||||
cp build/wasm-app/file.wasm ../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
working-directory: samples/file
|
||||
|
||||
- name: Test Sample [file] in non-aot mode
|
||||
if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
|
||||
run: |
|
||||
source /opt/intel/sgxsdk/environment
|
||||
./iwasm --dir=. ./file.wasm
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
|
||||
- name: Test Sample [file] in aot mode
|
||||
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
|
||||
run: |
|
||||
source /opt/intel/sgxsdk/environment
|
||||
./wamrc -sgx -o ./file.aot ./file.wasm
|
||||
./iwasm --dir=. ./file.aot
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
|
||||
|
||||
spec_test_default:
|
||||
needs: [build_iwasm, build_llvm_libraries]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
#(workaround) disable "fast-interp" because of SIMDE
|
||||
running_mode: ["classic-interp", "aot", "fast-jit"]
|
||||
test_option:
|
||||
[$DEFAULT_TEST_OPTIONS, $SIMD_TEST_OPTIONS, $XIP_TEST_OPTIONS]
|
||||
os: [ubuntu-22.04]
|
||||
exclude:
|
||||
# classic-interp, fast-interp and fast-jit don't support simd
|
||||
- running_mode: "classic-interp"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
- running_mode: "fast-interp"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $SIMD_TEST_OPTIONS
|
||||
# classic-interp, fast-interp and fast jit don't support XIP
|
||||
- running_mode: "classic-interp"
|
||||
test_option: $XIP_TEST_OPTIONS
|
||||
- running_mode: "fast-interp"
|
||||
test_option: $XIP_TEST_OPTIONS
|
||||
- running_mode: "fast-jit"
|
||||
test_option: $XIP_TEST_OPTIONS
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get LLVM libraries
|
||||
if: matrix.running_mode == 'aot'
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install SGX SDK and necessary libraries
|
||||
uses: ./.github/actions/install-linux-sgx
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
#workaround about a https://github.com/actions/runner-images/issues/6680#issuecomment-2640923706
|
||||
- name: Increase swapfile
|
||||
run: |
|
||||
sudo swapoff -a
|
||||
sudo fallocate -l 15G /swapfile
|
||||
sudo chmod 600 /swapfile
|
||||
sudo mkswap /swapfile
|
||||
sudo swapon /swapfile
|
||||
sudo swapon --show
|
||||
|
||||
- name: run spec tests
|
||||
run: |
|
||||
set +e
|
||||
source /opt/intel/sgxsdk/environment
|
||||
attempts=0
|
||||
max_attempts=3
|
||||
|
||||
while [ $attempts -lt $max_attempts ]; do
|
||||
./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
exitcode="$?"
|
||||
|
||||
if [ $exitcode -eq 0 ]; then
|
||||
echo "Spec test passed"
|
||||
exit 0
|
||||
elif [ $exitcode -ne 143 ]; then
|
||||
echo "Spec test failed with error code $exitcode"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$exitcode is a known GitHub-hosted runner issue"
|
||||
echo "::notice::Re-running the spec test due to error code 143"
|
||||
attempts=$((attempts + 1))
|
||||
done
|
||||
|
||||
echo "::notice::Report an error with code 143 in SGX CI after $max_attempts attempts"
|
||||
exit 143
|
||||
working-directory: ./tests/wamr-test-suites
|
183
.github/workflows/compilation_on_windows.yml
vendored
183
.github/workflows/compilation_on_windows.yml
vendored
|
@ -1,183 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: compilation on windows-latest
|
||||
|
||||
on:
|
||||
# will be triggered on PR events
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths:
|
||||
- ".github/workflows/compilation_on_windows.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# will be triggered on push events
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "dev/**"
|
||||
paths:
|
||||
- ".github/workflows/compilation_on_windows.yml"
|
||||
- "build-scripts/**"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "samples/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
# For Spec Test
|
||||
DEFAULT_TEST_OPTIONS: "-s spec -b"
|
||||
MULTI_MODULES_TEST_OPTIONS: "-s spec -b -M"
|
||||
THREADS_TEST_OPTIONS: "-s spec -b -p"
|
||||
WASI_TEST_OPTIONS: "-s wasi_certification -w"
|
||||
WASI_TEST_FILTER: ${{ github.workspace }}/product-mini/platforms/windows/wasi_filtered_tests.json
|
||||
# Used when building the WASI socket and thread tests
|
||||
CC: ${{ github.workspace }}/wasi-sdk/bin/clang
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build_llvm_libraries_on_windows:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "windows-latest"
|
||||
arch: "AArch64 ARM Mips RISCV X86"
|
||||
|
||||
build_iwasm:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
build_options:
|
||||
[
|
||||
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0",
|
||||
"-DWAMR_BUILD_AOT=0",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
"-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_DEBUG_INTERP=1",
|
||||
"-DWAMR_BUILD_LIB_PTHREAD=1",
|
||||
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
|
||||
"-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1",
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: clone uvwasi library
|
||||
if: ${{ !contains(matrix.build_options, '-DWAMR_BUILD_LIBC_UVWASI=0') }}
|
||||
run: |
|
||||
cd core/deps
|
||||
git clone https://github.com/nodejs/uvwasi.git
|
||||
- name: Build iwasm
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.build_options }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
|
||||
build_wamrc:
|
||||
needs: [build_llvm_libraries_on_windows]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# since jobs.id can't contain the dot character
|
||||
# it is hard to use `format` to assemble the cache key
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
cmake -S . -B build
|
||||
cmake --build build --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
test:
|
||||
runs-on: windows-latest
|
||||
needs: [build_iwasm, build_wamrc]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
running_mode: ["classic-interp", "fast-interp"]
|
||||
test_option:
|
||||
[
|
||||
$DEFAULT_TEST_OPTIONS,
|
||||
$MULTI_MODULES_TEST_OPTIONS,
|
||||
$THREADS_TEST_OPTIONS,
|
||||
$WASI_TEST_OPTIONS,
|
||||
]
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: download and install wasi-sdk
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: |
|
||||
curl "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0.m-mingw.tar.gz" -o wasi-sdk.tar.gz -L
|
||||
mkdir wasi-sdk
|
||||
tar -xzf wasi-sdk.tar.gz -C wasi-sdk --strip-components 1
|
||||
|
||||
- name: build socket api tests
|
||||
shell: bash
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: ./build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-socket/test/
|
||||
|
||||
- name: Build WASI thread tests
|
||||
shell: bash
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: ./build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
|
||||
|
||||
- name: install wget
|
||||
shell: bash
|
||||
run: choco install wget
|
||||
|
||||
- name: run tests
|
||||
shell: bash
|
||||
timeout-minutes: 20
|
||||
run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
working-directory: ./tests/wamr-test-suites
|
87
.github/workflows/create_tag.yml
vendored
87
.github/workflows/create_tag.yml
vendored
|
@ -1,87 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: create a tag
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
outputs:
|
||||
minor_version:
|
||||
description: "the new version is a minor version or a major version"
|
||||
value: ${{ jobs.create_tag.outputs.minor_version}}
|
||||
new_ver:
|
||||
description: "the new version"
|
||||
value: ${{ jobs.create_tag.outputs.new_ver}}
|
||||
new_tag:
|
||||
description: "the new tag just created"
|
||||
value: ${{ jobs.create_tag.outputs.new_tag}}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
create_tag:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
minor_version: ${{ steps.preparation.outputs.minor_version }}
|
||||
new_ver: ${{ steps.preparation.outputs.new_ver }}
|
||||
new_tag: ${{ steps.preparation.outputs.new_tag }}
|
||||
permissions:
|
||||
contents: write # create and push tags
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Full git history is needed to get a proper list of commits and tags
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: prepare
|
||||
id: preparation
|
||||
run: |
|
||||
# show latest 3 versions on the branch that create release
|
||||
# Set the initial commit to the head of the branch
|
||||
commit="HEAD"
|
||||
#
|
||||
# Loop to get the three most recent tags
|
||||
for i in {1..3}
|
||||
do
|
||||
# Get the most recent tag reachable from the current commit
|
||||
tag=$(git describe --tags --abbrev=0 $commit)
|
||||
|
||||
# Print the tag
|
||||
echo "$tag"
|
||||
|
||||
# Move to the commit before the found tag to find the next tag in the next iteration
|
||||
commit=$(git rev-list -n 1 $tag^)
|
||||
done
|
||||
# compare latest git tag and semantic version definition
|
||||
result=$(python3 ./.github/scripts/fetch_and_compare_version.py)
|
||||
echo "script result is ${result}"
|
||||
#
|
||||
# return in a form like "WAMR-X.Y.Z,major_minor_change" or ",patch_change"
|
||||
new_ver=$(echo "${result}" | awk -F',' '{print $1}')
|
||||
diff_versioning=$(echo "${result}" | awk -F',' '{print $2}')
|
||||
echo "next version is ${new_ver}, it ${diff_versioning}"
|
||||
#
|
||||
# set output
|
||||
if [[ ${diff_versioning} == 'major_minor_change' ]];then
|
||||
echo "minor_version=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "minor_version=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
#
|
||||
#
|
||||
if [[ -z ${new_ver} ]]; then
|
||||
echo "::error::please indicate the right semantic version in core/version.h"
|
||||
echo "new_ver=''" >> "$GITHUB_OUTPUT"
|
||||
echo "new_tag=''" >> "$GITHUB_OUTPUT"
|
||||
exit 1
|
||||
else
|
||||
echo "new_ver=${new_ver}" >> "$GITHUB_OUTPUT"
|
||||
echo "new_tag=WAMR-${new_ver}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: push tag
|
||||
if: steps.preparation.outputs.new_tag != ''
|
||||
run: |
|
||||
git tag ${{ steps.preparation.outputs.new_tag }}
|
||||
git push origin --force --tags
|
50
.github/workflows/hadolint_dockerfiles.yml
vendored
50
.github/workflows/hadolint_dockerfiles.yml
vendored
|
@ -1,50 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: hadolint dockerfiles
|
||||
|
||||
on:
|
||||
# will be triggered on PR events
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths:
|
||||
- "**/Dockerfile*"
|
||||
- ".github/workflows/hadolint_dockerfiles.yml"
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- "dev/**"
|
||||
paths:
|
||||
- "**/Dockerfile*"
|
||||
- ".github/workflows/hadolint_dockerfiles.yml"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
run-hadolint-on-dockerfiles:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# on default, hadolint will fail on warnings and errors
|
||||
- name: Run hadolint on dockerfiles
|
||||
run: |
|
||||
docker pull hadolint/hadolint:latest-debian
|
||||
find . -name "*Dockerfile*" | while read dockerfile; do
|
||||
echo "run hadolint on $dockerfile:"
|
||||
docker run --rm -i hadolint/hadolint:latest-debian hadolint - <"$dockerfile"
|
||||
echo "successful"
|
||||
done
|
226
.github/workflows/linux.yml
vendored
Normal file
226
.github/workflows/linux.yml
vendored
Normal file
|
@ -0,0 +1,226 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: Linux
|
||||
|
||||
# Controls when the action will run. Triggers the workflow on push or pull request
|
||||
# events but only for the main branch
|
||||
on:
|
||||
# triggers on every branch
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'doc/**'
|
||||
# triggers on every PR
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, ubuntu-20.04]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build iwasm [default]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [classic interp]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_FAST_INTERP=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [multi module]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_MULTI_MODULE=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [lib-pthread]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_LIB_PTHREAD=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [aot only]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [interp only]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [memory profiling]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_MEMORY_PROFILING=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [tail call]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_TAIL_CALL=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [custom name section]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_CUSTOM_NAME_SECTION=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [disable hardware boundary check]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_DISABLE_HW_BOUND_CHECK=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [reference types]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_REF_TYPES=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [128-bit SIMD]
|
||||
run: |
|
||||
cd product-mini/platforms/linux
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_SIMD=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Cache LLVM libraries
|
||||
uses: actions/cache@v2
|
||||
id: cache_llvm
|
||||
env:
|
||||
cache-name: llvm_libraries
|
||||
with:
|
||||
path: ./core/deps/llvm
|
||||
key: ${{ runner.os }}-build-${{env.cache-name}}
|
||||
restore-keys: ${{ runner.os }}-build-${{env.cache-name}}
|
||||
- name: Build llvm and clang from source
|
||||
if: steps.cache_llvm.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cd wamr-compiler
|
||||
./build_llvm.sh
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
cd wamr-compiler
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
cd ..
|
||||
- name: download and install wasi-sdk
|
||||
run: |
|
||||
cd /opt
|
||||
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
|
||||
tar -xzf wasi-sdk-12.0-linux.tar.gz
|
||||
mv wasi-sdk-12.0 wasi-sdk
|
||||
rm wasi-sdk-12.0-linux.tar.gz
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
wget https://github.com/WebAssembly/wabt/releases/download/1.0.23/wabt-1.0.23-ubuntu.tar.gz
|
||||
tar -xzf wabt-1.0.23-ubuntu.tar.gz
|
||||
mv wabt-1.0.23 wabt
|
||||
rm wabt-1.0.23-ubuntu.tar.gz
|
||||
- name: Build Sample [wasm-c-api]
|
||||
run: |
|
||||
cd samples/wasm-c-api
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
./callback
|
||||
./callback_chain
|
||||
./global
|
||||
./hello
|
||||
./hostref
|
||||
./memory
|
||||
./reflect
|
||||
./table
|
||||
./trap
|
||||
cd .. && rm -r build
|
||||
- name: Build Sample [wasm-c-api] [Jit]
|
||||
run: |
|
||||
cd samples/wasm-c-api
|
||||
mkdir build && cd build
|
||||
cmake -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_AOT=1 ..
|
||||
make -j $(nproc)
|
||||
./callback
|
||||
./callback_chain
|
||||
./global
|
||||
./hello
|
||||
./hostref
|
||||
./memory
|
||||
./reflect
|
||||
./table
|
||||
./trap
|
||||
cd .. && rm -r build
|
||||
- name: Build Sample [wasm-c-api] [Aot]
|
||||
run: |
|
||||
cd samples/wasm-c-api
|
||||
mkdir build && cd build
|
||||
cmake -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=1 ..
|
||||
make -j $(nproc)
|
||||
./callback
|
||||
./callback_chain
|
||||
./global
|
||||
./hello
|
||||
./hostref
|
||||
./memory
|
||||
./reflect
|
||||
./table
|
||||
./trap
|
||||
cd .. && rm -r build
|
||||
- name: Build Sample [basic]
|
||||
run: |
|
||||
cd samples/basic
|
||||
./build.sh
|
||||
./run.sh
|
||||
- name: Build Sample [multi-thread]
|
||||
run: |
|
||||
cd samples/multi-thread
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
./iwasm wasm-apps/test.wasm
|
||||
- name: Build Sample [multi-module]
|
||||
run: |
|
||||
cd samples/multi-module
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
./multi_module
|
||||
- name: Build Sample [spawn-thread]
|
||||
run: |
|
||||
cd samples/spawn-thread
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
./spawn_thread
|
||||
- name: Build Sample [ref-types]
|
||||
run: |
|
||||
cd samples/ref-types
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
./hello
|
128
.github/workflows/mac.yml
vendored
Normal file
128
.github/workflows/mac.yml
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: Mac
|
||||
|
||||
# Controls when the action will run. Triggers the workflow on push or pull request
|
||||
# events but only for the main branch
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build iwasm [default]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [classic interp]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_FAST_INTERP=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [multi module]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_MULTI_MODULE=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [lib-pthread]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_LIB_PTHREAD=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [aot only]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [interp only]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=0
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [memory profiling]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_MEMORY_PROFILING=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [tail call]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_TAIL_CALL=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [custom name section]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_CUSTOM_NAME_SECTION=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [disable hardware boundary check]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_DISABLE_HW_BOUND_CHECK=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [ref types]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_REF_TYPES=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: Build iwasm [128-bit SIMD]
|
||||
run: |
|
||||
cd product-mini/platforms/darwin
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_SIMD=1
|
||||
make -j $(nproc)
|
||||
cd .. && rm -rf build
|
||||
- name: download and install wabt
|
||||
run: |
|
||||
cd /opt
|
||||
sudo wget https://github.com/WebAssembly/wabt/releases/download/1.0.19/wabt-1.0.19-macos.tar.gz
|
||||
sudo tar -xzf wabt-1.0.19-macos.tar.gz
|
||||
sudo mv wabt-1.0.19 wabt
|
||||
- name: Build Sample [wasm-c-api]
|
||||
run: |
|
||||
cd samples/wasm-c-api
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make
|
||||
./callback
|
||||
./callback_chain
|
||||
./global
|
||||
./hello
|
||||
./hostref
|
||||
./memory
|
||||
./reflect
|
||||
./table
|
||||
./trap
|
712
.github/workflows/nightly_run.yml
vendored
712
.github/workflows/nightly_run.yml
vendored
|
@ -1,712 +0,0 @@
|
|||
# Copyright (C) 2023 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: nightly_run
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
# running nightly pipeline if you're changing it
|
||||
# stress tests are run only in nightly at the moment, so running them in they are changed
|
||||
paths:
|
||||
- ".github/workflows/nightly_run.yml"
|
||||
- "core/iwasm/libraries/lib-wasi-threads/stress-test/**"
|
||||
|
||||
# midnight UTC
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# For BUILD
|
||||
AOT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_INTERP_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
FAST_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
LLVM_LAZY_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
|
||||
MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
|
||||
# For Spec Test
|
||||
# FIXME: use binary release(adding -b) instead of building from source after upgrading to 22.04
|
||||
DEFAULT_TEST_OPTIONS: "-s spec -P"
|
||||
MULTI_MODULES_TEST_OPTIONS: "-s spec -M -P"
|
||||
SIMD_TEST_OPTIONS: "-s spec -S -P"
|
||||
THREADS_TEST_OPTIONS: "-s spec -p -P"
|
||||
X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
|
||||
WASI_TEST_OPTIONS: "-s wasi_certification -w"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build_llvm_libraries_on_ubuntu:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "ubuntu-22.04"
|
||||
arch: "X86"
|
||||
|
||||
build_wamrc:
|
||||
needs: build_llvm_libraries_on_ubuntu
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# since jobs.id can't contain the dot character
|
||||
# it is hard to use `format` to assemble the cache key
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
build_iwasm:
|
||||
needs: build_llvm_libraries_on_ubuntu
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
make_options_run_mode: [
|
||||
# Running mode
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
$MULTI_TIER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
make_options_feature: [
|
||||
# Features
|
||||
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
|
||||
"-DWAMR_BUILD_DEBUG_AOT=1",
|
||||
"-DWAMR_BUILD_DEBUG_INTERP=1",
|
||||
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
|
||||
"-DWAMR_BUILD_LIB_PTHREAD=1",
|
||||
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
|
||||
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
|
||||
"-DWAMR_BUILD_MINI_LOADER=1",
|
||||
"-DWAMR_BUILD_MEMORY_PROFILING=1",
|
||||
"-DWAMR_BUILD_MULTI_MODULE=1",
|
||||
"-DWAMR_BUILD_PERF_PROFILING=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
"-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_MEMORY64=1",
|
||||
"-DWAMR_BUILD_MULTI_MEMORY=1",
|
||||
"-DWAMR_BUILD_SHARED=1",
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
platform: [android, linux]
|
||||
exclude:
|
||||
# incompatible feature and platform
|
||||
# incompatible mode and feature
|
||||
# MULTI_MODULE only on INTERP mode and AOT mode
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
# SIMD only on JIT/AOT mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
# DEBUG_INTERP only on CLASSIC INTERP mode
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
# DEBUG_AOT only on JIT/AOT mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
# TODO: DEBUG_AOT on JIT
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
# MINI_LOADER only on INTERP mode
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
# Memory64 only on CLASSIC INTERP and AOT mode, and only on 64-bit platform
|
||||
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
platform: android
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
# Multi memory only on CLASSIC INTERP mode, and only on 64-bit platform
|
||||
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
platform: android
|
||||
- make_options_run_mode: $AOT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
# Fast-JIT and Multi-Tier-JIT mode don't support android
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
# LLVM JIT pre-built binary wasn't compiled by Android NDK
|
||||
# and isn't available for android
|
||||
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
|
||||
platform: android
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# only download llvm cache when needed
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Build iwasm for linux
|
||||
if: matrix.platform == 'linux'
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}
|
||||
|
||||
- name: Build iwasm for android
|
||||
if: matrix.platform == 'android'
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} \
|
||||
-DWAMR_BUILD_TARGET=X86_64
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: product-mini/platforms/${{ matrix.platform }}
|
||||
|
||||
build_iwasm_linux_gcc4_8:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ubuntu:14.04
|
||||
strategy:
|
||||
matrix:
|
||||
make_options_run_mode: [
|
||||
# Running mode
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
make_options_feature: [
|
||||
# Features
|
||||
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
|
||||
"-DWAMR_BUILD_DEBUG_AOT=1",
|
||||
"-DWAMR_BUILD_DEBUG_INTERP=1",
|
||||
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
|
||||
"-DWAMR_BUILD_LIB_PTHREAD=1",
|
||||
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
|
||||
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
|
||||
"-DWAMR_BUILD_MINI_LOADER=1",
|
||||
"-DWAMR_BUILD_MEMORY_PROFILING=1",
|
||||
"-DWAMR_BUILD_MULTI_MODULE=1",
|
||||
"-DWAMR_BUILD_PERF_PROFILING=1",
|
||||
"-DWAMR_BUILD_REF_TYPES=1",
|
||||
"-DWAMR_BUILD_SIMD=1",
|
||||
"-DWAMR_BUILD_TAIL_CALL=1",
|
||||
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
|
||||
"-DWAMR_BUILD_MEMORY64=1",
|
||||
"-DWAMR_BUILD_MULTI_MEMORY=1",
|
||||
]
|
||||
exclude:
|
||||
# incompatible feature and platform
|
||||
# incompatible mode and feature
|
||||
# MULTI_MODULE only on INTERP mode and AOT mode
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
|
||||
# SIMD only on JIT/AOT mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_SIMD=1"
|
||||
# DEBUG_INTERP only on CLASSIC INTERP mode
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
|
||||
# DEBUG_AOT only on JIT/AOT mode
|
||||
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
# TODO: DEBUG_AOT on JIT
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
|
||||
# MINI_LOADER only on INTERP mode
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
|
||||
# Memory64 only on CLASSIC INTERP mode
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
|
||||
# Memory64 only on CLASSIC INTERP mode
|
||||
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
|
||||
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt update && apt install -y make g++-4.8 gcc-4.8 wget git
|
||||
|
||||
- name: checkout
|
||||
run: |
|
||||
git clone https://github.com/${{ github.repository }} wamr
|
||||
|
||||
- name: Install cmake
|
||||
run: |
|
||||
wget https://github.com/Kitware/CMake/releases/download/v3.26.1/cmake-3.26.1-linux-x86_64.tar.gz -O cmake.tar.gz
|
||||
tar xzf cmake.tar.gz
|
||||
cp cmake-3.26.1-linux-x86_64/bin/cmake /usr/local/bin
|
||||
cp -r cmake-3.26.1-linux-x86_64/share/cmake-3.26/ /usr/local/share/
|
||||
- name: Build iwasm
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr/product-mini/platforms/linux
|
||||
|
||||
build_samples_wasm_c_api:
|
||||
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
sanitizer: ["", "ubsan", "asan"]
|
||||
make_options: [
|
||||
# Running mode
|
||||
$AOT_BUILD_OPTIONS,
|
||||
$CLASSIC_INTERP_BUILD_OPTIONS,
|
||||
$FAST_INTERP_BUILD_OPTIONS,
|
||||
$FAST_JIT_BUILD_OPTIONS,
|
||||
$LLVM_LAZY_JIT_BUILD_OPTIONS,
|
||||
$LLVM_EAGER_JIT_BUILD_OPTIONS,
|
||||
$MULTI_TIER_JIT_BUILD_OPTIONS,
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
exclude:
|
||||
- make_options: $MULTI_TIER_JIT_BUILD_OPTIONS
|
||||
sanitizer: asan
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Build wamrc
|
||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake -D WAMR_BUILD_SANITIZER="${{matrix.sanitizer}}" ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [wasm-c-api]
|
||||
run: |
|
||||
VERBOSE=1
|
||||
cmake -S . -B build ${{ matrix.make_options }} \
|
||||
-D WAMR_BUILD_SANITIZER="${{matrix.sanitizer}}" \
|
||||
-D WAMR_BUILD_QUICK_AOT_ENTRY=0
|
||||
cmake --build build --config Release --parallel 4
|
||||
ctest --test-dir build --output-on-failure
|
||||
working-directory: samples/wasm-c-api
|
||||
|
||||
build_samples_others:
|
||||
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: Get LLVM libraries
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Build wamrc
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake -D WAMR_BUILD_SANITIZER="${{matrix.sanitizer}}" ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
working-directory: wamr-compiler
|
||||
|
||||
- name: Build Sample [basic]
|
||||
run: |
|
||||
cd samples/basic
|
||||
./build.sh
|
||||
./run.sh
|
||||
- name: Build Sample [file]
|
||||
run: |
|
||||
cd samples/file
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
./src/iwasm -f wasm-app/file.wasm -d .
|
||||
- name: Build Sample [multi-thread]
|
||||
run: |
|
||||
cd samples/multi-thread
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
./iwasm wasm-apps/test.wasm
|
||||
- name: Build Sample [multi-module]
|
||||
run: |
|
||||
cd samples/multi-module
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=1
|
||||
cmake --build . --config Release --parallel 4
|
||||
./multi_module mC.wasm
|
||||
./multi_module mC.aot
|
||||
- name: Build Sample [spawn-thread]
|
||||
run: |
|
||||
cd samples/spawn-thread
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
./spawn_thread
|
||||
- name: Build Sample [ref-types]
|
||||
run: |
|
||||
cd samples/ref-types
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
./hello
|
||||
|
||||
- name: Build Sample [wasi-threads]
|
||||
run: |
|
||||
cd samples/wasi-threads
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
./iwasm wasm-apps/no_pthread.wasm
|
||||
|
||||
- name: Build Sample [shared-module]
|
||||
run: |
|
||||
cd samples/shared-module
|
||||
./build.sh
|
||||
./run.sh
|
||||
|
||||
- name: Build Sample [terminate]
|
||||
run: |
|
||||
cd samples/terminate
|
||||
./build.sh
|
||||
./run.sh
|
||||
|
||||
- name: Build Sample [native-stack-overflow]
|
||||
run: |
|
||||
cd samples/native-stack-overflow
|
||||
./build.sh
|
||||
./run.sh test1
|
||||
./run.sh test2
|
||||
|
||||
- name: Build Sample [native-lib]
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release --parallel 4
|
||||
./iwasm --native-lib=./libtest_add.so --native-lib=./libtest_sqrt.so --native-lib=./libtest_hello.so --native-lib=./libtest_hello2.so wasm-app/test.wasm
|
||||
working-directory: ./samples/native-lib
|
||||
|
||||
# FIXME: un-comment me after fix cmake minimum issue
|
||||
# https://github.com/bytecodealliance/wamr-app-framework/pull/11
|
||||
# - name: checkout wamr-app-framework
|
||||
# run: git clone https://github.com/bytecodealliance/wamr-app-framework.git
|
||||
|
||||
# - name: download wamr-app-framework dependencies
|
||||
# run: LVGL=0 LV_DRIVERS=0 ./download.sh
|
||||
# working-directory: ./wamr-app-framework/deps
|
||||
|
||||
# - name: Build Sample [simple]
|
||||
# run: |
|
||||
# ./build.sh -p host-interp
|
||||
# python3 ./sample_test_run.py $(pwd)/out
|
||||
# exit $?
|
||||
# working-directory: ./wamr-app-framework/samples/simple
|
||||
|
||||
- name: Build Sample [shared-heap]
|
||||
run: |
|
||||
cd samples/shared-heap
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Debug --parallel 4
|
||||
./shared_heap_test
|
||||
./shared_heap_test --aot
|
||||
|
||||
test:
|
||||
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04]
|
||||
sanitizer: ["", "ubsan", "asan", "tsan"]
|
||||
running_mode:
|
||||
[
|
||||
"classic-interp",
|
||||
"fast-interp",
|
||||
"jit",
|
||||
"aot",
|
||||
"fast-jit",
|
||||
"multi-tier-jit",
|
||||
]
|
||||
test_option:
|
||||
[
|
||||
$DEFAULT_TEST_OPTIONS,
|
||||
$MULTI_MODULES_TEST_OPTIONS,
|
||||
$SIMD_TEST_OPTIONS,
|
||||
$THREADS_TEST_OPTIONS,
|
||||
$WASI_TEST_OPTIONS,
|
||||
]
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
|
||||
ubuntu_version: "22.04"
|
||||
|
||||
exclude:
|
||||
# asan works only for aot now
|
||||
- running_mode: "classic-interp"
|
||||
sanitizer: asan
|
||||
- running_mode: "fast-interp"
|
||||
sanitizer: asan
|
||||
- running_mode: "jit"
|
||||
sanitizer: asan
|
||||
- running_mode: "fast-jit"
|
||||
sanitizer: asan
|
||||
- running_mode: "multi-tier-jit"
|
||||
sanitizer: asan
|
||||
- running_mode: "classic-interp"
|
||||
sanitizer: tsan
|
||||
- running_mode: "jit"
|
||||
sanitizer: tsan
|
||||
- running_mode: "fast-jit"
|
||||
sanitizer: tsan
|
||||
- running_mode: "multi-tier-jit"
|
||||
sanitizer: tsan
|
||||
# simd128.h brings ubsan errors
|
||||
# like: negation of XXXcannot be represented in type 'long int';
|
||||
# cast to an unsigned type to negate this value to itself
|
||||
- running_mode: "fast-interp"
|
||||
sanitizer: ubsan
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: install-wasi-sdk-wabt
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
uses: ./.github/actions/install-wasi-sdk-wabt
|
||||
with:
|
||||
os: ${{ matrix.os }}
|
||||
|
||||
- name: set env variable(if llvm are used)
|
||||
if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
|
||||
run: echo "USE_LLVM=true" >> $GITHUB_ENV
|
||||
|
||||
- name: set env variable(if x86_32 test needed)
|
||||
if: >
|
||||
(matrix.test_option == '$DEFAULT_TEST_OPTIONS' || matrix.test_option == '$THREADS_TEST_OPTIONS'
|
||||
|| matrix.test_option == '$WASI_TEST_OPTIONS')
|
||||
&& matrix.running_mode != 'fast-jit' && matrix.running_mode != 'jit' && matrix.running_mode != 'multi-tier-jit'
|
||||
run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
|
||||
|
||||
- name: set additional tsan options
|
||||
run: |
|
||||
echo "TSAN_OPTIONS=suppressions=$PWD/tsan_suppressions.txt" >> $GITHUB_ENV
|
||||
sudo sysctl vm.mmap_rnd_bits=28
|
||||
working-directory: tests/wamr-test-suites
|
||||
|
||||
#only download llvm libraries in jit and aot mode
|
||||
- name: Get LLVM libraries
|
||||
if: env.USE_LLVM == 'true'
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.llvm_cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: env.USE_LLVM == 'true' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: install jq JSON processor
|
||||
if: matrix.running_mode == 'aot' && matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: sudo apt-get update && sudo apt install -y jq
|
||||
|
||||
- name: install for wabt compilation
|
||||
run: sudo apt update && sudo apt install -y ninja-build
|
||||
|
||||
- name: Build WASI thread tests
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: bash build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
|
||||
|
||||
- name: Build WASI thread stress tests
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: bash build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-wasi-threads/stress-test/
|
||||
|
||||
- name: build socket api tests
|
||||
if: matrix.test_option == '$WASI_TEST_OPTIONS'
|
||||
run: bash build.sh
|
||||
working-directory: ./core/iwasm/libraries/lib-socket/test/
|
||||
|
||||
- name: run tests
|
||||
timeout-minutes: 40
|
||||
run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} -T "${{ matrix.sanitizer }}"
|
||||
working-directory: ./tests/wamr-test-suites
|
||||
|
||||
#only install x32 support libraries when to run x86_32 cases
|
||||
- name: install x32 support libraries
|
||||
if: env.TEST_ON_X86_32 == 'true'
|
||||
run:
|
||||
# Add another apt repository as some packages cannot
|
||||
# be downloaded with the github default repository
|
||||
sudo curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc &&
|
||||
sudo apt-add-repository https://packages.microsoft.com/ubuntu/${{ matrix.ubuntu_version }}/prod &&
|
||||
sudo apt-get update &&
|
||||
sudo apt install -y g++-multilib lib32gcc-9-dev
|
||||
|
||||
- name: run tests x86_32
|
||||
timeout-minutes: 40
|
||||
if: env.TEST_ON_X86_32 == 'true'
|
||||
run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
|
||||
working-directory: ./tests/wamr-test-suites
|
241
.github/workflows/release_process.yml
vendored
241
.github/workflows/release_process.yml
vendored
|
@ -1,241 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: the binary release processes
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
require_confirmation:
|
||||
description: "If the process requires a confirmation"
|
||||
type: boolean
|
||||
required: false
|
||||
default: false
|
||||
|
||||
# Cancel any in-flight jobs for the same PR/branch so there's only one active
|
||||
# at a time
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
create_tag:
|
||||
permissions:
|
||||
contents: write # create and push tags
|
||||
uses: ./.github/workflows/create_tag.yml
|
||||
|
||||
create_release:
|
||||
permissions:
|
||||
contents: write # create release
|
||||
needs: [create_tag]
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: prepare the release note
|
||||
run: |
|
||||
extract_result="$(python3 ./.github/scripts/extract_from_release_notes.py RELEASE_NOTES.md)"
|
||||
echo "RELEASE_NOTE<<EOF" >> $GITHUB_ENV
|
||||
echo "${extract_result}" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
|
||||
- name: create a release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ needs.create_tag.outputs.new_tag }}
|
||||
release_name: ${{ needs.create_tag.outputs.new_tag }}
|
||||
prerelease: ${{ inputs.require_confirmation || needs.create_tag.outputs.minor_version }}
|
||||
draft: false
|
||||
body: ${{ env.RELEASE_NOTE }}
|
||||
|
||||
#
|
||||
# LLVM_LIBRARIES
|
||||
build_llvm_libraries_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "ubuntu-22.04"
|
||||
arch: "AArch64 ARM Mips RISCV X86"
|
||||
|
||||
build_llvm_libraries_on_macos:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "macos-13"
|
||||
arch: "AArch64 ARM Mips RISCV X86"
|
||||
|
||||
build_llvm_libraries_on_windows:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "windows-latest"
|
||||
arch: "AArch64 ARM Mips RISCV X86"
|
||||
|
||||
#
|
||||
# WAMRC
|
||||
release_wamrc_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release, build_llvm_libraries_on_ubuntu_2204 ]
|
||||
uses: ./.github/workflows/build_wamrc.yml
|
||||
with:
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
release: true
|
||||
runner: ubuntu-22.04
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
|
||||
release_wamrc_on_ubuntu_macos:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release, build_llvm_libraries_on_macos]
|
||||
uses: ./.github/workflows/build_wamrc.yml
|
||||
with:
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_macos.outputs.cache_key }}
|
||||
release: true
|
||||
runner: macos-13
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
|
||||
release_wamrc_on_windows:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release, build_llvm_libraries_on_windows]
|
||||
uses: ./.github/workflows/build_wamrc.yml
|
||||
with:
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
|
||||
release: true
|
||||
runner: windows-latest
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
|
||||
#
|
||||
# IWASM
|
||||
release_iwasm_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release, build_llvm_libraries_on_ubuntu_2204]
|
||||
uses: ./.github/workflows/build_iwasm_release.yml
|
||||
with:
|
||||
cwd: product-mini/platforms/linux
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||
runner: ubuntu-22.04
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
|
||||
release_iwasm_on_macos:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release, build_llvm_libraries_on_macos]
|
||||
uses: ./.github/workflows/build_iwasm_release.yml
|
||||
with:
|
||||
cwd: product-mini/platforms/darwin
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_macos.outputs.cache_key }}
|
||||
runner: macos-13
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
|
||||
release_iwasm_on_windows:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release, build_llvm_libraries_on_windows]
|
||||
uses: ./.github/workflows/build_iwasm_release.yml
|
||||
with:
|
||||
cwd: product-mini/platforms/windows
|
||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
|
||||
runner: windows-latest
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
|
||||
#
|
||||
# WAMR_SDK
|
||||
release_wamr_sdk_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_wamr_sdk.yml
|
||||
with:
|
||||
config_file: wamr_config_ubuntu_release.cmake
|
||||
runner: ubuntu-22.04
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
|
||||
wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git
|
||||
|
||||
release_wamr_sdk_on_macos:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_wamr_sdk.yml
|
||||
with:
|
||||
config_file: wamr_config_macos_release.cmake
|
||||
runner: macos-13
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-macos.tar.gz
|
||||
wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git
|
||||
|
||||
# Let's disable it for now and reopen it when the actual requirement arises.
|
||||
# Please ensure all dependencies have been updated before reopening.
|
||||
#
|
||||
# # vscode extension cross-platform
|
||||
# release_wamr_ide_vscode_ext:
|
||||
# permissions:
|
||||
# contents: write # upload release artifact
|
||||
# needs: [create_tag, create_release]
|
||||
# uses: ./.github/workflows/build_wamr_vscode_ext.yml
|
||||
# secrets: inherit
|
||||
# with:
|
||||
# upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
# ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
|
||||
# #
|
||||
# # vscode extension docker images package
|
||||
# release_wamr_ide_docker_images_package:
|
||||
# permissions:
|
||||
# contents: write # upload release artifact
|
||||
# needs: [create_tag, create_release]
|
||||
# uses: ./.github/workflows/build_docker_images.yml
|
||||
# with:
|
||||
# upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
# ver_num: ${{ needs.create_tag.outputs.new_ver }}
|
||||
|
||||
#
|
||||
# WAMR_LLDB
|
||||
release_wamr_lldb_on_ubuntu_2204:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_wamr_lldb.yml
|
||||
with:
|
||||
runner: ubuntu-22.04
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
||||
|
||||
release_wamr_lldb_on_macos_universal:
|
||||
permissions:
|
||||
contents: write # upload release artifact
|
||||
needs: [create_tag, create_release]
|
||||
uses: ./.github/workflows/build_wamr_lldb.yml
|
||||
with:
|
||||
runner: macos-13
|
||||
arch: universal
|
||||
upload_url: ${{ needs.create_release.outputs.upload_url }}
|
||||
ver_num: ${{ needs.create_tag.outputs.new_ver}}
|
|
@ -1,74 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
name: reuse binaries of the latest release if no more modification on the_path since last_commit
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
binary_name_stem:
|
||||
type: string
|
||||
required: true
|
||||
last_commit:
|
||||
type: string
|
||||
required: true
|
||||
the_path:
|
||||
type: string
|
||||
required: true
|
||||
upload_url:
|
||||
description: upload binary assets to the URL of release
|
||||
type: string
|
||||
required: true
|
||||
outputs:
|
||||
result:
|
||||
value: ${{ jobs.build.outputs.result }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
reuse:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
result: ${{ steps.try_reuse.outputs.result }}
|
||||
permissions:
|
||||
contents: write # for creating realease and uploading release artifacts
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Full git history is needed to get a proper list of commits and tags
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: try to reuse binaries
|
||||
id: try_reuse
|
||||
run: |
|
||||
echo '::echo::on'
|
||||
python3 ./.github/scripts/reuse_latest_release_binaries.py \
|
||||
--binary_name_stem ${{ inputs.binary_name_stem }} \
|
||||
--last_commit ${{ inputs.last_commit }} \
|
||||
--the_path ${{ inputs.the_path }} .
|
||||
ls -lh .
|
||||
|
||||
- run: echo ${{ steps.try_reuse.outputs.result }}
|
||||
|
||||
- name: upload release tar.gz
|
||||
if: steps.try_reuse.outputs.result == 'hit'
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: ${{ inputs.binary_name_stem }}.tar.gz
|
||||
asset_name: ${{ inputs.binary_name_stem }}.tar.gz
|
||||
asset_content_type: application/x-gzip
|
||||
|
||||
- name: upload release zip
|
||||
if: steps.try_reuse.outputs.result == 'hit'
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ inputs.upload_url }}
|
||||
asset_path: ${{ inputs.binary_name_stem }}.zip
|
||||
asset_name: ${{ inputs.binary_name_stem }}.zip
|
||||
asset_content_type: application/zip
|
335
.github/workflows/spec_test_on_nuttx.yml
vendored
335
.github/workflows/spec_test_on_nuttx.yml
vendored
|
@ -1,335 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: spec test on nuttx
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
paths:
|
||||
- ".github/workflows/spec_test_on_nuttx.yml"
|
||||
- "core/**"
|
||||
- "!core/deps/**"
|
||||
- "product-mini/**"
|
||||
- "!samples/workload/**"
|
||||
- "tests/wamr-test-suites/**"
|
||||
- "wamr-compiler/**"
|
||||
- "wamr-sdk/**"
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
# Note on INTERPRETERS_WAMR_STACK_GUARD_SIZE:
|
||||
# https://github.com/apache/nuttx-apps/pull/2241 is not included in
|
||||
# releases/12.4 branch as of writing this.
|
||||
env:
|
||||
LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
|
||||
WASI_SDK_PATH: "/opt/wasi-sdk"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build_llvm_libraries:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "ubuntu-22.04"
|
||||
arch: "ARM RISCV AArch64"
|
||||
container_image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
|
||||
|
||||
build_llvm_libraries_xtensa:
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
uses: ./.github/workflows/build_llvm_libraries.yml
|
||||
with:
|
||||
os: "ubuntu-22.04"
|
||||
arch: "Xtensa"
|
||||
extra_build_llvm_options: "--platform xtensa"
|
||||
cache_key_suffix: "-xtensa"
|
||||
container_image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
|
||||
|
||||
spec_test_on_qemu:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build_llvm_libraries, build_llvm_libraries_xtensa]
|
||||
container:
|
||||
image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
|
||||
strategy:
|
||||
matrix:
|
||||
target_config: [
|
||||
# {
|
||||
# config: "boards/arm64/qemu/qemu-armv8a/configs/nsh",
|
||||
# target: "aarch64_vfp",
|
||||
# fpu_type: "fp"
|
||||
# },
|
||||
# {
|
||||
# config: "boards/arm/imx6/sabre-6quad/configs/nsh",
|
||||
# target: "thumbv7",
|
||||
# fpu_type: "none"
|
||||
# },
|
||||
{
|
||||
config: "boards/arm/imx6/sabre-6quad/configs/nsh",
|
||||
target: "thumbv7_vfp",
|
||||
fpu_type: "dp"
|
||||
},
|
||||
{
|
||||
config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
|
||||
target: "riscv32",
|
||||
fpu_type: "none"
|
||||
},
|
||||
#{
|
||||
# config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
|
||||
# target: "riscv32_ilp32f",
|
||||
# fpu_type: "fp"
|
||||
#},
|
||||
# {
|
||||
# config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
|
||||
# target: "riscv32_ilp32d",
|
||||
# fpu_type: "dp"
|
||||
# },
|
||||
{
|
||||
config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh64",
|
||||
target: "riscv64",
|
||||
fpu_type: "none"
|
||||
},
|
||||
{
|
||||
config: "boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_debug",
|
||||
target: "xtensa",
|
||||
fpu_type: "none"
|
||||
},
|
||||
]
|
||||
|
||||
wamr_test_option: [
|
||||
{
|
||||
mode: "-t aot",
|
||||
option: "CONFIG_INTERPRETERS_WAMR_AOT"
|
||||
},
|
||||
{
|
||||
mode: "-t aot -X",
|
||||
option: "CONFIG_INTERPRETERS_WAMR_AOT"
|
||||
},
|
||||
# {
|
||||
# mode: "-t classic-interp",
|
||||
# option: "CONFIG_INTERPRETERS_WAMR_CLASSIC"
|
||||
# },
|
||||
# {
|
||||
# mode: "-t fast-interp",
|
||||
# option: "CONFIG_INTERPRETERS_WAMR_FAST"
|
||||
# },
|
||||
]
|
||||
|
||||
wamr_feature_option:
|
||||
# Empty option for default
|
||||
- { option: "", mode: "" }
|
||||
# need to install menhir
|
||||
# - { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" }
|
||||
|
||||
exclude:
|
||||
# XIP is not fully supported yet on RISCV64, some relocations can not be resolved
|
||||
- target_config: { config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh64" }
|
||||
wamr_test_option: { mode: "-t aot -X" }
|
||||
|
||||
# Our xtensa environment doesn't have enough memory
|
||||
- target_config: { target: "xtensa" }
|
||||
wamr_feature_option: { mode: "-G" }
|
||||
|
||||
steps:
|
||||
# Note: we use an unreleased version nuttx for xtensa because
|
||||
# 12.4 doesn't contain necessary esp32s3 changes.
|
||||
- name: Checkout NuttX
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: apache/nuttx
|
||||
ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.9' }}
|
||||
path: nuttx
|
||||
|
||||
- name: Checkout NuttX Apps
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: apache/nuttx-apps
|
||||
ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.9' }}
|
||||
path: apps
|
||||
|
||||
- name: Checkout WAMR
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ github.repository }}
|
||||
path: apps/interpreters/wamr/wamr
|
||||
|
||||
- name: Get LLVM libraries
|
||||
if: contains(matrix.wamr_test_option.mode, 'aot')
|
||||
id: retrieve_llvm_libs
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
./core/deps/llvm/build/bin
|
||||
./core/deps/llvm/build/include
|
||||
./core/deps/llvm/build/lib
|
||||
./core/deps/llvm/build/libexec
|
||||
./core/deps/llvm/build/share
|
||||
key: ${{ matrix.target_config.target == 'xtensa' && needs.build_llvm_libraries_xtensa.outputs.cache_key || needs.build_llvm_libraries.outputs.cache_key }}
|
||||
|
||||
- name: Quit if cache miss
|
||||
if: contains(matrix.wamr_test_option.mode, 'aot') && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
|
||||
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
|
||||
|
||||
- name: Copy LLVM
|
||||
if: contains(matrix.wamr_test_option.mode, 'aot')
|
||||
run: cp -r core/deps/llvm apps/interpreters/wamr/wamr/core/deps/llvm
|
||||
|
||||
- name: Build wamrc
|
||||
if: contains(matrix.wamr_test_option.mode, 'aot')
|
||||
working-directory: apps/interpreters/wamr/wamr/wamr-compiler
|
||||
run: |
|
||||
cmake -B build -DWAMR_BUILD_SHRUNK_MEMORY=0 -S .
|
||||
cmake --build build
|
||||
|
||||
# the nuttx version we use for xtensa requires esptool.py newer than
|
||||
# what we have in our version of the apache-nuttx-ci-linux image.
|
||||
- name: Install the latest esptool.py (xtensa)
|
||||
if: matrix.target_config.target == 'xtensa'
|
||||
run: |
|
||||
pip3 install esptool==4.7.0
|
||||
esptool.py version
|
||||
|
||||
- name: Configure NuttX
|
||||
run: |
|
||||
tools/configure.sh ${{ matrix.target_config.config }}
|
||||
working-directory: nuttx
|
||||
|
||||
# depending on configurations, the iwasm command line generated
|
||||
# by spec-test-script can be longer than the default NSH_LINELEN,
|
||||
# which is 64 or 80.
|
||||
- name: Enable WAMR for NuttX
|
||||
run: |
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_LOG
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_REF_TYPES
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_ENABLE_SPEC_TEST
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_SHARED_MEMORY
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_BULK_MEMORY
|
||||
kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE 1024
|
||||
kconfig-tweak --enable CONFIG_FS_HOSTFS
|
||||
kconfig-tweak --enable CONFIG_ARM_SEMIHOSTING_HOSTFS
|
||||
kconfig-tweak --enable CONFIG_ARM_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
|
||||
kconfig-tweak --enable CONFIG_RISCV_SEMIHOSTING_HOSTFS
|
||||
kconfig-tweak --enable CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
|
||||
kconfig-tweak --enable CONFIG_XTENSA_SEMIHOSTING_HOSTFS
|
||||
kconfig-tweak --enable CONFIG_XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
|
||||
kconfig-tweak --enable CONFIG_LIBC_FLOATINGPOINT
|
||||
kconfig-tweak --set-val CONFIG_NSH_LINELEN 255
|
||||
working-directory: nuttx
|
||||
|
||||
- name: Set WAMR stack size for NuttX
|
||||
if: matrix.target_config.target != 'xtensa'
|
||||
run: |
|
||||
kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 327680
|
||||
working-directory: nuttx
|
||||
|
||||
# because qemu doesn't have a proper emulation of esp32s3 psram,
|
||||
# we are limited to the internal ram, which is about 400KB.
|
||||
- name: Set WAMR stack size for NuttX (xtensa)
|
||||
if: matrix.target_config.target == 'xtensa'
|
||||
run: |
|
||||
kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 25600
|
||||
working-directory: nuttx
|
||||
|
||||
- name: Enable WAMR interpreter/aot runtime for NuttX
|
||||
if: matrix.wamr_test_option.option != ''
|
||||
run: |
|
||||
for x in ${{ matrix.wamr_test_option.option }}; do
|
||||
kconfig-tweak --enable $x
|
||||
done
|
||||
working-directory: nuttx
|
||||
|
||||
- name: Enable WAMR Features for NuttX
|
||||
if: matrix.wamr_feature_option.option != ''
|
||||
run: |
|
||||
for x in ${{ matrix.wamr_feature_option.option }}; do
|
||||
kconfig-tweak --enable $x
|
||||
done
|
||||
working-directory: nuttx
|
||||
|
||||
- name: Disable FPU for NuttX
|
||||
if: matrix.target_config.fpu_type == 'none'
|
||||
run: |
|
||||
kconfig-tweak --disable CONFIG_ARCH_FPU
|
||||
working-directory: nuttx
|
||||
|
||||
- name: Disable DPFPU for NuttX
|
||||
if: matrix.target_config.fpu_type == 'fp'
|
||||
run: |
|
||||
kconfig-tweak --disable CONFIG_ARCH_DPFPU
|
||||
working-directory: nuttx
|
||||
|
||||
# Note: while a real hardware would need
|
||||
# INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=y,
|
||||
# it doesn't work with xtensa qemu which we use on the CI because it
|
||||
# doesn't have a proper emulation of I/D separate mappings.
|
||||
# we work it around by using INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=n.
|
||||
# this configuration won't work on a real hardware.
|
||||
- name: Tweak NuttX config (xtensa)
|
||||
if: matrix.target_config.target == 'xtensa'
|
||||
run: |
|
||||
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_AOT_WORD_ALIGN_READ
|
||||
kconfig-tweak --disable CONFIG_INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR
|
||||
working-directory: nuttx
|
||||
|
||||
- name: Build NuttX
|
||||
run: |
|
||||
make olddefconfig
|
||||
make -j$(nproc)
|
||||
working-directory: nuttx
|
||||
|
||||
# for xtensa, build a 8MB firmware image.
|
||||
# simple boot is assumed. (thus the nuttx.bin offset in the image is 0)
|
||||
# qemu will infer the flash size from the file size.
|
||||
- name: Post build processing (xtensa)
|
||||
if: matrix.target_config.target == 'xtensa'
|
||||
run: |
|
||||
cd nuttx
|
||||
dd if=/dev/zero of=flash.img bs=1024 count=8192
|
||||
dd if=nuttx.bin of=flash.img conv=notrunc
|
||||
mv flash.img nuttx
|
||||
|
||||
- name: Build firmware path
|
||||
id: build_firmware_path
|
||||
run: |
|
||||
echo "firmware=$PWD/nuttx/nuttx" >> $GITHUB_OUTPUT
|
||||
|
||||
# for xtensa, use the espressif fork of qemu, which has esp32s3 support.
|
||||
- name: Install QEMU (xtensa)
|
||||
if: matrix.target_config.target == 'xtensa'
|
||||
run: |
|
||||
apt-get remove -y qemu-system-misc
|
||||
apt-get update && apt-get install -y libsdl2-2.0-0
|
||||
./.github/scripts/install_qemu_xtensa.sh
|
||||
qemu-system-xtensa --version
|
||||
working-directory: apps/interpreters/wamr/wamr
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
|
||||
./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
|
||||
|
||||
- name: pack the log
|
||||
if: always()
|
||||
run: |
|
||||
mkdir log
|
||||
cp $PWD/nuttx/.config log/dot-config
|
||||
cp ${{ steps.build_firmware_path.outputs.firmware }} log
|
||||
tar -C apps/interpreters/wamr/wamr/tests/wamr-test-suites/workspace -cvzf log/report.tgz report
|
||||
|
||||
- name: upload the log
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }}
|
||||
path: log
|
65
.github/workflows/supply_chain.yml
vendored
65
.github/workflows/supply_chain.yml
vendored
|
@ -1,65 +0,0 @@
|
|||
# This workflow uses actions that are not certified by GitHub. They are provided
|
||||
# by a third-party and are governed by separate terms of service, privacy
|
||||
# policy, and support documentation.
|
||||
|
||||
# Check current WASM Micro Runtime results here: https://securityscorecards.dev/viewer/?uri=github.com/bytecodealliance/wasm-micro-runtime
|
||||
|
||||
name: Scorecard supply-chain security
|
||||
on:
|
||||
# For Branch-Protection check. Only the default branch is supported. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
|
||||
branch_protection_rule:
|
||||
# To guarantee Maintained check is occasionally updated. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
||||
# midnight UTC
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
# allow to be triggered manually
|
||||
workflow_dispatch:
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'bytecodealliance/wasm-micro-runtime'
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Needed to publish results and get a badge (see publish_results below).
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
|
||||
# - Publish results to OpenSSF REST API for easy access by consumers
|
||||
# - Allows the repository to include the Scorecard badge.
|
||||
# - See https://github.com/ossf/scorecard-action#publishing-results.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v3.1.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@2847b7f7ab9f48fc49eca90a53fff6007285f399
|
||||
with:
|
||||
sarif_file: results.sarif
|
84
.github/workflows/windows.yml
vendored
Normal file
84
.github/workflows/windows.yml
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
name: Windows
|
||||
|
||||
# Controls when the action will run. Triggers the workflow on push or pull request
|
||||
# events but only for the main branch
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: clone uvwasi library
|
||||
run: |
|
||||
cd core/deps
|
||||
git clone https://github.com/nodejs/uvwasi.git
|
||||
- name: Build iwasm [default]
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release
|
||||
cd .. && rm -force -r build
|
||||
- name: Build iwasm [aot only]
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0
|
||||
cmake --build . --config Release
|
||||
cd .. && rm -force -r build
|
||||
- name: Build iwasm [interp only]
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_AOT=0
|
||||
cmake --build . --config Release
|
||||
cd .. && rm -force -r build
|
||||
- name: Build iwasm [tail call]
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_TAIL_CALL=1
|
||||
cmake --build . --config Release
|
||||
cd .. && rm -force -r build
|
||||
- name: Build iwasm [custom name section]
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_CUSTOM_NAME_SECTION=1
|
||||
cmake --build . --config Release
|
||||
cd .. && rm -force -r build
|
||||
- name: Build iwasm [disable hardware boundary check]
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_DISABLE_HW_BOUND_CHECK=1
|
||||
cmake --build . --config Release
|
||||
cd .. && rm -force -r build
|
||||
- name: Build iwasm [reference types]
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_REF_TYPES=1
|
||||
cmake --build . --config Release
|
||||
cd .. && rm -force -r build
|
||||
- name: Build iwasm [128-bit SIMD]
|
||||
run: |
|
||||
cd product-mini/platforms/windows
|
||||
mkdir build && cd build
|
||||
cmake .. -DWAMR_BUILD_SIMD=1
|
||||
cmake --build . --config Release
|
||||
cd .. && rm -force -r build
|
||||
|
40
.gitignore
vendored
40
.gitignore
vendored
|
@ -1,42 +1,14 @@
|
|||
.cache
|
||||
.clangd
|
||||
|
||||
.vs
|
||||
.vscode
|
||||
.venv
|
||||
/.idea
|
||||
**/cmake-build-*/
|
||||
**/*build*/
|
||||
!/build-scripts
|
||||
*.obj
|
||||
*.a
|
||||
*.so
|
||||
.clangd
|
||||
.DS_Store
|
||||
*.o
|
||||
.aider*
|
||||
|
||||
**/*build/
|
||||
core/deps/**
|
||||
core/shared/mem-alloc/tlsf
|
||||
core/iwasm/libraries/lib-wasi-threads/test/*.wasm
|
||||
core/iwasm/libraries/lib-socket/test/*.wasm
|
||||
core/app-framework/wgl
|
||||
|
||||
wamr-sdk/out/
|
||||
wamr-sdk/runtime/build_runtime_sdk/
|
||||
test-tools/host-tool/bin/
|
||||
product-mini/app-samples/hello-world/test.wasm
|
||||
product-mini/platforms/linux-sgx/enclave-sample/App/
|
||||
product-mini/platforms/linux-sgx/enclave-sample/Enclave/
|
||||
product-mini/platforms/linux-sgx/enclave-sample/iwasm
|
||||
|
||||
build_out
|
||||
tests/wamr-test-suites/workspace
|
||||
|
||||
!/test-tools/wamr-ide/VSCode-Extension/.vscode
|
||||
|
||||
samples/socket-api/wasm-src/inc/pthread.h
|
||||
|
||||
**/__pycache__
|
||||
|
||||
tests/benchmarks/coremark/coremark*
|
||||
|
||||
samples/workload/include/**
|
||||
!samples/workload/include/.gitkeep
|
||||
|
||||
# core/iwasm/libraries/wasi-threads
|
||||
|
|
36
ADOPTERS.md
36
ADOPTERS.md
|
@ -1,36 +0,0 @@
|
|||
# WAMR adopters
|
||||
|
||||
_If you are using WAMR in production/pre-production at your organization, please add your company name to this list.
|
||||
The list is in alphabetical order._
|
||||
|
||||
| Organization | Contact | Status | Description of Use |
|
||||
| -------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
| [Alibaba](https://www.alibaba.com) | [@johnlanni](https://github.com/johnlanni) |  | Higress is a next-generation cloud-native gateway built on the core of open-source Istio + Envoy based on Alibaba's internal Envoy Gateway practice. |
|
||||
| [Amazon](https://www.amazon.com) | [@loganek](https://github.com/loganek) |  | Prime Video is a global streaming service by Amazon that provides on-demand access to a vast library of movies, TV shows, and original programming, as well as live content. |
|
||||
| [Ant Group](https://www.antgroup.com) | [@wei-tang](https://github.com/wei-tang) |  | AntChain is a blockchain technology platform owned by Ant Group, a Chinese tech conglomerate that also runs Alipay, China's largest digital payment system. |
|
||||
| [Bosch](https://www.bosch.com) | emily.ruppel@us.bosch.com |  | Silverline Cloud-Edge platform |
|
||||
| [Disney](https://www.disney.com) | |  | Disney+ Streaming |
|
||||
| [Intel](https://www.intel.com) | [@wenyongh](https://github.com/wenyongh) |  | Edge and the embedded environments |
|
||||
| [Moonbit](https://www.moonbitlang.com) | [@peter-jerry-ye](https://github.com/peter-jerry-ye) |  | MoonBit is an end-to-end programming language toolchain for cloud and edge computing using WebAssembly. |
|
||||
| [Microsoft](https://www.microsoft.com) | [@Mossaka](https://github.com/Mossaka) |  | Hyperlight runs Wasm workloads in VMs without OS and kernel, it is a solution for improving the management and security of Wasm workloads on Azure. |
|
||||
| [Midokura](https://www.midokura.com) | [@yamt](https://github.com/yamt) |  | The next-generation Edge AI sensing platform |
|
||||
| [Siemens](https://www.siemens.com) | [@ttrenner](https://github.com/ttrenner) |  | Industrial, IoT |
|
||||
| [Sony Semiconductor Solutions](https://www.sony-semicon.com) | [@dongsheng28849455](https://github.com/dongsheng28849455) |  | AI digital camera |
|
||||
| [Xiaomi](https://www.mi.com) | [@no1wudi](https://github.com/no1wudi) |  | Xiaomi Vela is Xiaomi's IoT embedded software platform based on the open-source, real-time operating system NuttX. |
|
||||
| [Xiaomi](https://www.mi.com) | [@no1wudi](https://github.com/no1wudi) |  | TEE (trusted execution environment) app engine. |
|
||||
|
||||
# Adopted in open-source projects
|
||||
|
||||
_The list is in alphabetical order._
|
||||
|
||||
| Project | Reference |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
| [Apache Teaclave](https://github.com/apache/incubator-teaclave) | https://github.com/apache/incubator-teaclave/blob/master/docs/executing-wasm.md |
|
||||
| [Envoy](https://github.com/envoyproxy/envoy) | https://github.com/envoyproxy/envoy/blob/main/docs/root/configuration/other_features/wasm.rst |
|
||||
| [faasm](https://github.com/faasm/faasm) | https://github.com/faasm/faasm/blob/main/docs/source/wamr.md |
|
||||
| [fluent-bit](https://github.com/fluent/fluent-bit) | https://github.com/fluent/fluent-bit/tree/master/lib/wasm-micro-runtime-WAMR-1.3.0 |
|
||||
| [harfbuzz](https://github.com/harfbuzz/harfbuzz) | https://github.com/harfbuzz/harfbuzz/blob/main/docs/wasm-shaper.md#enabling-the-wasm-shaper-when-building-harfbuzz |
|
||||
| [inclave-containers](https://github.com/inclavare-containers/inclavare-containers) | https://github.com/inclavare-containers/inclavare-containers |
|
||||
| [private-data-objects](https://github.com/hyperledger-labs/private-data-objects) | https://github.com/hyperledger-labs/private-data-objects/blob/main/common/interpreter/wawaka_wasm/README.md |
|
||||
| [runwasi](https://github.com/containerd/runwasi) | https://github.com/containerd/runwasi/pull/508 (WIP) |
|
||||
| [Wasmnizer-ts](https://github.com/web-devkits/Wasmnizer-ts) | https://github.com/web-devkits/Wasmnizer-ts |
|
|
@ -2,47 +2,33 @@ WebAssembly Micro Runtime Attributions
|
|||
======================================
|
||||
|
||||
WAMR project reused some components from other open source project:
|
||||
- **cJson**: in the repository [wamr-app-framework](https://github.com/bytecodealliance/wamr-app-framework/), used in the host_tool for remotely managing wasm applications
|
||||
- **cJson**: used in the host_tool for remotely managing wasm applications
|
||||
- **contiki-ng**: for the coap protocol implementation
|
||||
- **freebsd libm**: used in core/shared/platform/alios/bh_math.c
|
||||
- **LVGL**: in the repository [wamr-app-framework](https://github.com/bytecodealliance/wamr-app-framework/), for the gui samples and wrapped the wasm graphic layer
|
||||
- **llvm**: for the AOT/JIT compilation
|
||||
- **wasm-c-api**: to implement the C-APIs of wasm. using headers and sameples
|
||||
- **littlevgl**: for the gui samples and wrapped the wasm graphic layer
|
||||
- **llvm**. for the AOT/JIT compilation
|
||||
- **wasm-c-api**. to implement the C-APIs of wasm. using headers and sameples
|
||||
- **wasmtime**: for the wasi libc implementation
|
||||
- **zephyr**: for several platform specific examples
|
||||
- **WebAssembly debugging patch for LLDB**: for extending the ability of LLDB to support wasm debugging
|
||||
- **libuv**: for the WASI Libc with uvwasi implementation
|
||||
- **uvwasi**: for the WASI Libc with uvwasi implementation
|
||||
- **asmjit**: for the Fast JIT x86-64 codegen implementation
|
||||
- **zydis**: for the Fast JIT x86-64 codegen implementation
|
||||
- **NuttX ELF headers**: used in core/iwasm/aot/debug/elf_parser.c
|
||||
- **Dhrystone**: for the test benchmark dhrystone
|
||||
- **zephyr**. for several platform specific examples
|
||||
|
||||
The WAMR fast interpreter is a clean room development. We would acknowledge the inspirations by [WASM3](https://github.com/wasm3/wasm3) open source project for the approach of pre-calculated operand stack location.
|
||||
The WAMR fast interpreter is a clean room development. We would acknowledge the inspirations by [WASM3](https://github.com/wasm3/wasm3) open source project for the approach of pre-calculated oprand stack location.
|
||||
|
||||
| third party components | version number | latest release | vendor pages | CVE details |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| cjson | 1.7.16 | 1.7.16 | https://github.com/DaveGamble/cJSON | https://www.cvedetails.com/vendor/19164/Cjson-Project.html |
|
||||
| cjson | 1.7.10 | 1.7.14 | https://github.com/DaveGamble/cJSON | https://www.cvedetails.com/vendor/19164/Cjson-Project.html |
|
||||
| contiki-ng (er-coap) | unspecified | 3.0 | https://github.com/contiki-os/contiki | https://www.cvedetails.com/vendor/16528/Contiki-os.html |
|
||||
| freebsd libm | unspecified | 13.0 | https://www.freebsd.org/ | https://www.cvedetails.com/vendor/6/Freebsd.html |
|
||||
| LVGL | 6.0.1 | 7.11.0 | https://lvgl.io/ | |
|
||||
| littlevgl | 6.0.1 | 7.11.0 | https://lvgl.io/ | |
|
||||
| llvm | 11.0.1 | 12.0.0 | https://llvm.org | https://www.cvedetails.com/vendor/13260/Llvm.html |
|
||||
| wasm-c-api | ac9b509f4df86e40e56e9b01f3f49afab0100037 | c9d31284651b975f05ac27cee0bab1377560b87e | https://github.com/WebAssembly/wasm-c-api | |
|
||||
| wasmtime | unspecified | v0.26.0 | https://github.com/bytecodealliance/wasmtime | |
|
||||
| zephyr | unspecified | v2.5.0 | https://www.zephyrproject.org/ | https://www.cvedetails.com/vendor/19255/Zephyrproject.html |
|
||||
| WebAssembly debugging patch for LLDB | unspecified | unspecified | https://reviews.llvm.org/D78801 | |
|
||||
| libuv | v1.46.0 | v1.46.0 | https://github.com/libuv/libuv | https://www.cvedetails.com/vendor/15402/Libuv-Project.html |
|
||||
| uvwasi | unspecified | v0.0.12 | https://github.com/nodejs/uvwasi | |
|
||||
| asmjit | unspecified | unspecified | https://github.com/asmjit/asmjit | |
|
||||
| zydis | unspecified | e14a07895136182a5b53e181eec3b1c6e0b434de | https://github.com/zyantific/zydis | |
|
||||
| NuttX ELF headers | 72313301e23f9c2de969fb64b9a0f67bb4c284df | 10.3.0 | https://github.com/apache/nuttx | |
|
||||
| Dhrystone | 2.1 | 2.1 | https://fossies.org/linux/privat/old/ | |
|
||||
|
||||
## Licenses
|
||||
|
||||
### cJson
|
||||
|
||||
[LICENSE](https://github.com/bytecodealliance/wamr-app-framework/blob/main/test-tools/host-tool/external/cJSON/LICENSE)
|
||||
[LICENSE](./test-tools/host-tool/external/cJSON/LICENSE)
|
||||
|
||||
### contiki-ng
|
||||
|
||||
|
@ -52,15 +38,15 @@ The WAMR fast interpreter is a clean room development. We would acknowledge the
|
|||
|
||||
[COPYRIGHT](./core/shared/platform/common/math/COPYRIGHT)
|
||||
|
||||
### LVGL
|
||||
### littlevgl
|
||||
|
||||
[LICENSE](https://github.com/bytecodealliance/wamr-app-framework/blob/main/samples/littlevgl/LICENCE.txt)
|
||||
[LICENCE](./samples/littlevgl/LICENCE.txt)
|
||||
|
||||
[LICENSE](https://github.com/bytecodealliance/wamr-app-framework/blob/main/app-framework/wgl/app/wa-inc/lvgl/LICENCE.txt)
|
||||
[LICENSE](./core/deps/lvgl/LICENCE.txt)
|
||||
|
||||
### llvm
|
||||
|
||||
[LICENSE](./LICENSE)
|
||||
[LICENSE](./core/deps/llvm/llvm/LICENCE.txt)
|
||||
|
||||
### wasm-c-api
|
||||
|
||||
|
@ -76,30 +62,4 @@ The WAMR fast interpreter is a clean room development. We would acknowledge the
|
|||
|
||||
### zephyr
|
||||
|
||||
[LICENSE](https://github.com/bytecodealliance/wamr-app-framework/blob/main/samples/gui/wasm-runtime-wgl/src/platform/zephyr/LICENSE)
|
||||
|
||||
### libuv
|
||||
|
||||
[LICENSE](./core/iwasm/libraries/libc-uvwasi/LICENSE_LIBUV)
|
||||
|
||||
### uvwasi
|
||||
|
||||
[LICENSE](./core/iwasm/libraries/libc-uvwasi/LICENSE_UVWASI)
|
||||
|
||||
### asmjit
|
||||
|
||||
[LICENSE](./core/iwasm/fast-jit/cg/LICENSE_ASMJIT)
|
||||
|
||||
### zydis
|
||||
|
||||
[LICENSE](./core/iwasm/fast-jit/cg/LICENSE_ZYDIS)
|
||||
|
||||
### NuttX ELF headers
|
||||
|
||||
[LICENSE](./core/iwasm/aot/debug/LICENSE_NUTTX)
|
||||
|
||||
[NOTICE](./core/iwasm/aot/debug/NOTICE_NUTTX)
|
||||
|
||||
### Dhrystone
|
||||
|
||||
[LICENSE](./tests/benchmarks/dhrystone/LICENSE)
|
||||
[LICENSE](./samples/gui/wasm-runtime-wgl/src/platform/zephyr/LICENSE)
|
||||
|
|
110
CMakeLists.txt
110
CMakeLists.txt
|
@ -1,24 +1,12 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
cmake_minimum_required (VERSION 3.14)
|
||||
cmake_minimum_required (VERSION 2.8...3.16)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
|
||||
project (iwasm)
|
||||
# set (CMAKE_VERBOSE_MAKEFILE 1)
|
||||
|
||||
if(ESP_PLATFORM)
|
||||
include (${COMPONENT_DIR}/build-scripts/esp-idf/wamr/CMakeLists.txt)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project (iwasm LANGUAGES C)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set (CMAKE_VERBOSE_MAKEFILE OFF)
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_PLATFORM)
|
||||
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
|
||||
endif ()
|
||||
set (WAMR_BUILD_PLATFORM "linux")
|
||||
|
||||
# Reset default linker flags
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||
|
@ -30,18 +18,16 @@ set (CMAKE_C_STANDARD 99)
|
|||
# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
|
||||
# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
|
||||
if (NOT DEFINED WAMR_BUILD_TARGET)
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
|
||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
|
||||
set (WAMR_BUILD_TARGET "AARCH64")
|
||||
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
|
||||
set (WAMR_BUILD_TARGET "RISCV64")
|
||||
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
# Build as X86_64 by default in 64-bit platform
|
||||
set (WAMR_BUILD_TARGET "X86_64")
|
||||
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
else ()
|
||||
# Build as X86_32 by default in 32-bit platform
|
||||
set (WAMR_BUILD_TARGET "X86_32")
|
||||
else ()
|
||||
message(SEND_ERROR "Unsupported build target platform!")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
@ -64,11 +50,6 @@ if (NOT DEFINED WAMR_BUILD_JIT)
|
|||
set (WAMR_BUILD_JIT 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_FAST_JIT)
|
||||
# Disable Fast JIT by default
|
||||
set (WAMR_BUILD_FAST_JIT 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
|
||||
# Enable libc builtin support by default
|
||||
set (WAMR_BUILD_LIBC_BUILTIN 1)
|
||||
|
@ -85,7 +66,7 @@ if (NOT DEFINED WAMR_BUILD_FAST_INTERP)
|
|||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
|
||||
# Disable multiple modules by default
|
||||
# Enable multiple modules
|
||||
set (WAMR_BUILD_MULTI_MODULE 0)
|
||||
endif ()
|
||||
|
||||
|
@ -94,16 +75,6 @@ if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD)
|
|||
set (WAMR_BUILD_LIB_PTHREAD 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS)
|
||||
# Disable wasi threads library by default
|
||||
set (WAMR_BUILD_LIB_WASI_THREADS 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_ENABLE_COPY_CALLSTACK)
|
||||
# Disable copy callstack by default
|
||||
set (WAMR_ENABLE_COPY_CALLSTACK 0)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MINI_LOADER)
|
||||
# Disable wasm mini loader by default
|
||||
set (WAMR_BUILD_MINI_LOADER 0)
|
||||
|
@ -115,23 +86,22 @@ if (NOT DEFINED WAMR_BUILD_SIMD)
|
|||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_REF_TYPES)
|
||||
# Enable reference types by default
|
||||
set (WAMR_BUILD_REF_TYPES 1)
|
||||
# Disable reference types by default
|
||||
set (WAMR_BUILD_REF_TYPES 0)
|
||||
endif ()
|
||||
|
||||
if (COLLECT_CODE_COVERAGE EQUAL 1)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
endif ()
|
||||
|
||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
||||
|
||||
if (NOT WIN32)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security \
|
||||
-ffunction-sections -fdata-sections \
|
||||
-Wno-unused-parameter -Wno-pedantic \
|
||||
-fvisibility=hidden")
|
||||
# Remove the extra spaces for better make log
|
||||
string (REGEX REPLACE " *" " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
|
||||
endif()
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
|
||||
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
|
||||
# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
|
||||
|
||||
if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
|
||||
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
|
||||
|
@ -149,43 +119,21 @@ endif ()
|
|||
|
||||
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
|
||||
|
||||
set (THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
# STATIC LIBRARY
|
||||
add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib)
|
||||
|
||||
add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
set_target_properties (vmlib PROPERTIES OUTPUT_NAME iwasm)
|
||||
target_include_directories(vmlib INTERFACE
|
||||
$<BUILD_INTERFACE:${WAMR_ROOT_DIR}/core/iwasm/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
|
||||
|
||||
target_link_libraries (vmlib PUBLIC ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT})
|
||||
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
|
||||
target_link_libraries(vmlib INTERFACE boringssl_crypto)
|
||||
endif ()
|
||||
# SHARED LIBRARY
|
||||
add_library (iwasm_shared SHARED ${WAMR_RUNTIME_LIB_SOURCE})
|
||||
set_target_properties (iwasm_shared PROPERTIES OUTPUT_NAME iwasm)
|
||||
target_link_libraries (iwasm_shared ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread)
|
||||
|
||||
if (MINGW)
|
||||
target_link_libraries(vmlib INTERFACE -lWs2_32 -lwsock32)
|
||||
target_link_libraries(vmlib PRIVATE ws2_32)
|
||||
endif ()
|
||||
install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(vmlib PRIVATE ntdll)
|
||||
endif()
|
||||
|
||||
set (WAMR_PUBLIC_HEADERS
|
||||
# HEADERS
|
||||
install (FILES
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h
|
||||
${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h
|
||||
)
|
||||
set_target_properties (vmlib PROPERTIES PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}")
|
||||
|
||||
set_version_info (vmlib)
|
||||
|
||||
install (TARGETS vmlib
|
||||
EXPORT iwasmTargets
|
||||
LIBRARY DESTINATION lib
|
||||
PUBLIC_HEADER DESTINATION include
|
||||
)
|
||||
|
||||
install_iwasm_package ()
|
||||
DESTINATION include)
|
||||
|
|
29
CODEOWNERS
29
CODEOWNERS
|
@ -1,29 +0,0 @@
|
|||
# In this project, we use CODEOWNERS to identify people who are likely to know
|
||||
# who should review a pull request.
|
||||
#
|
||||
# People listed in this file are committing to respond in a timely fashion to
|
||||
# PRs in the selected areas. However, that response doesn't have to be a full
|
||||
# code review; it could also take any of these forms:
|
||||
#
|
||||
# - "I intend to review this but I can't yet. Please leave me a message if I
|
||||
# haven't responded by (a specific date in the near future)."
|
||||
#
|
||||
# - "I think (a specific other contributor) should review this." (Note that the
|
||||
# best reviewer for a PR may not necessarily be listed in this file.)
|
||||
#
|
||||
# People must only be added to this file if they've agreed to provide one of
|
||||
# the above responses in a reasonable amount of time for every PR to which
|
||||
# they're assigned.
|
||||
#
|
||||
# We only ask for this commitment from people who are employed full-time to
|
||||
# work on this project. We gratefully welcome reviews from other contributors,
|
||||
# but we don't believe it's fair to ask volunteers to respond quickly.
|
||||
|
||||
# If none of the later patterns match, assign to anyone. This team is the
|
||||
# parent of all the other teams and automatically includes everyone on those
|
||||
# teams.
|
||||
* @loganek @lum1n0us @no1wudi @TianlongLiang @wenyongh @xujuntwt95329 @yamt
|
||||
|
||||
# Some parts of the project require more specialized knowledge. In those areas
|
||||
# we designate smaller groups who are more likely to be aware of who's working
|
||||
# in specific areas.
|
|
@ -19,7 +19,7 @@ Code changes
|
|||
We Use Github Flow, So All Code Changes Happen Through Pull Requests. Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
|
||||
|
||||
- If you've added code that should be tested, add tests. Ensure the test suite passes.
|
||||
- Avoid use macros for different platforms. Use separate folder of source files to host different platform logic.
|
||||
- Avoid use macros for different platforms. Use seperate folder of source files to host diffeent platform logic.
|
||||
- Put macro definitions inside share_lib/include/config.h if you have to use macro.
|
||||
- Make sure your code lints and compliant to our coding style.
|
||||
- Extend the application library is highly welcome.
|
||||
|
@ -27,7 +27,7 @@ We Use Github Flow, So All Code Changes Happen Through Pull Requests. Pull reque
|
|||
Coding Style
|
||||
===============================
|
||||
Please use [K&R](https://en.wikipedia.org/wiki/Indentation_style#K.26R) coding style, such as 4 spaces for indentation rather than tabs etc.
|
||||
We suggest using VS Code like IDE or stable coding format tools, like clang-format, to make your code compliant to the customized format(in .clang-format).
|
||||
We suggest use Eclipse like IDE or stable coding format tools to make your code compliant to K&R format.
|
||||
|
||||
Report bugs
|
||||
===================
|
||||
|
|
190
README.md
190
README.md
|
@ -1,108 +1,146 @@
|
|||
# WebAssembly Micro Runtime
|
||||
|
||||
WebAssembly Micro Runtime
|
||||
=========================
|
||||
[Build WAMR VM core](./doc/build_wamr.md) | [Embed WAMR](./doc/embed_wamr.md) | [Export native function](./doc/export_native_api.md) | [Build WASM applications](./doc/build_wasm_app.md) | [Samples](https://github.com/bytecodealliance/wasm-micro-runtime#samples)
|
||||
|
||||
**A [Bytecode Alliance][BA] project**
|
||||
|
||||
[BA]: https://bytecodealliance.org/
|
||||
|
||||
**[Guide](https://wamr.gitbook.io/)**  **[Website](https://bytecodealliance.github.io/wamr.dev)**  **[Chat](https://bytecodealliance.zulipchat.com/#narrow/stream/290350-wamr)**
|
||||
WebAssembly Micro Runtime (WAMR) is a standalone WebAssembly (WASM) runtime with a small footprint. It includes a few parts as below:
|
||||
- The **"iwasm" VM core**, supporting WebAssembly interpreter, ahead of time compilation (AoT) and Just-in-Time compilation (JIT)
|
||||
|
||||
[Build WAMR](./doc/build_wamr.md) | [Build AOT Compiler](./wamr-compiler/README.md) | [Embed WAMR](./doc/embed_wamr.md) | [Export Native API](./doc/export_native_api.md) | [Build Wasm Apps](./doc/build_wasm_app.md) | [Samples](./samples/README.md)
|
||||
- The **application framework** and the supporting API's for the WASM applications
|
||||
|
||||
WebAssembly Micro Runtime (WAMR) is a lightweight standalone WebAssembly (Wasm) runtime with small footprint, high performance and highly configurable features for applications cross from embedded, IoT, edge to Trusted Execution Environment (TEE), smart contract, cloud native and so on. It includes a few parts as below:
|
||||
- [**VMcore**](./core/iwasm/): A set of runtime libraries for loading and running Wasm modules. It supports rich running modes including interpreter, Ahead-of-Time compilation(AoT) and Just-in-Time compilation (JIT). WAMR supports two JIT tiers - Fast JIT, LLVM JIT, and dynamic tier-up from Fast JIT to LLVM JIT.
|
||||
- [**iwasm**](./product-mini/): The executable binary built with WAMR VMcore which supports WASI and command line interface.
|
||||
- [**wamrc**](./wamr-compiler/): The AOT compiler to compile Wasm file into AOT file
|
||||
- Useful components and tools for building real solutions with WAMR vmcore:
|
||||
- [App-framework](https://github.com/bytecodealliance/wamr-app-framework/blob/main/app-framework/README.md): A framework for supporting APIs for the Wasm applications
|
||||
- [App-manager](https://github.com/bytecodealliance/wamr-app-framework/blob/main/app-mgr/README.md): A framework for dynamical loading the Wasm module remotely
|
||||
- [WAMR-IDE](./test-tools/wamr-ide): An experimental VSCode extension for developping WebAssembly applications with C/C++
|
||||
- The **dynamic management** of the WASM applications
|
||||
|
||||
iwasm VM core
|
||||
=========================
|
||||
|
||||
### Key features
|
||||
- Full compliant to the W3C Wasm MVP
|
||||
- Small runtime binary size (core vmlib on cortex-m4f with tail-call/bulk memory/shared memory support, text size from bloaty)
|
||||
* ~58.9K for fast interpreter
|
||||
* ~56.3K for classic interpreter
|
||||
* ~29.4K for aot runtime
|
||||
* ~21.4K for libc-wasi library
|
||||
* ~3.7K for libc-builtin library
|
||||
- Near to native speed by AOT and JIT
|
||||
- Self-implemented AOT module loader to enable AOT working on Linux, Windows, MacOS, Android, SGX and MCU systems
|
||||
- Choices of Wasm application libc support: the built-in libc subset for the embedded environment or [WASI](https://github.com/WebAssembly/WASI) for the standard libc
|
||||
- [The simple C APIs to embed WAMR into host environment](./doc/embed_wamr.md), see [how to integrate WAMR](./doc/embed_wamr.md) and the [API list](./core/iwasm/include/wasm_export.h)
|
||||
- [The mechanism to export native APIs to Wasm applications](./doc/export_native_api.md), see [how to register native APIs](./doc/export_native_api.md)
|
||||
- [Multiple modules as dependencies](./doc/multi_module.md), ref to [document](./doc/multi_module.md) and [sample](samples/multi-module)
|
||||
- [Multi-thread, pthread APIs and thread management](./doc/pthread_library.md), ref to [document](./doc/pthread_library.md) and [sample](samples/multi-thread)
|
||||
- [wasi-threads](./doc/pthread_impls.md#wasi-threads-new), ref to [document](./doc/pthread_impls.md#wasi-threads-new) and [sample](samples/wasi-threads)
|
||||
- [Linux SGX (Intel Software Guard Extension) support](./doc/linux_sgx.md), ref to [document](./doc/linux_sgx.md)
|
||||
- [Source debugging support](./doc/source_debugging.md), ref to [document](./doc/source_debugging.md)
|
||||
- [XIP (Execution In Place) support](./doc/xip.md), ref to [document](./doc/xip.md)
|
||||
- [Berkeley/Posix Socket support](./doc/socket_api.md), ref to [document](./doc/socket_api.md) and [sample](./samples/socket-api)
|
||||
- [Multi-tier JIT](./product-mini#linux) and [Running mode control](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/)
|
||||
- Language bindings: [Go](./language-bindings/go/README.md), [Python](./language-bindings/python/README.md), [Rust](./language-bindings/rust/README.md)
|
||||
### key features
|
||||
|
||||
### Wasm post-MVP features
|
||||
- 100% compliant to the W3C WASM MVP
|
||||
- Small runtime binary size (85K for interpreter and 50K for AoT) and low memory usage
|
||||
- Near to native speed by AoT
|
||||
- Self-implemented module loader enables AoT working cross Linux, SGX and MCU systems
|
||||
- Choices of WASM application libc support: the built-in libc subset for the embedded environment or [WASI](https://github.com/WebAssembly/WASI) for standard libc
|
||||
- [Embeddable with the supporting C API's](./doc/embed_wamr.md)
|
||||
- [The mechanism for exporting native API's to WASM applications](./doc/export_native_api.md)
|
||||
- [Multiple modules as dependencies](./doc/multi_module.md), ref to [sample](samples/multi-module)
|
||||
- [Thread management and pthread library](./doc/pthread_library.md), ref to [sample](samples/multi-thread)
|
||||
|
||||
### post-MVP features
|
||||
- [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions)
|
||||
- [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops)
|
||||
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations)
|
||||
- [Shared memory](https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md#shared-linear-memory)
|
||||
- [Multi-value](https://github.com/WebAssembly/multi-value)
|
||||
- [wasm-c-api](https://github.com/WebAssembly/wasm-c-api), ref to [document](doc/wasm_c_api.md) and [sample](samples/wasm-c-api)
|
||||
- [Tail-call](https://github.com/WebAssembly/tail-call)
|
||||
- [128-bit SIMD](https://github.com/WebAssembly/simd), ref to [samples/workload](samples/workload)
|
||||
- [Reference Types](https://github.com/WebAssembly/reference-types), ref to [document](doc/ref_types.md) and [sample](samples/ref-types)
|
||||
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations), [Shared memory](https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md#shared-linear-memory), [Memory64](https://github.com/WebAssembly/memory64)
|
||||
- [Tail-call](https://github.com/WebAssembly/tail-call), [Garbage Collection](https://github.com/WebAssembly/gc), [Exception Handling](https://github.com/WebAssembly/exception-handling)
|
||||
|
||||
### Supported architectures and platforms
|
||||
The WAMR VMcore supports the following architectures:
|
||||
|
||||
The iwasm supports the following architectures:
|
||||
|
||||
- X86-64, X86-32
|
||||
- ARM, THUMB (ARMV7 Cortex-M7 and Cortex-A15 are tested)
|
||||
- AArch64 (Cortex-A57 and Cortex-A53 are tested)
|
||||
- MIPS
|
||||
- XTENSA
|
||||
- RISCV64, RISCV32 (RISC-V LP64 and RISC-V LP64D are tested)
|
||||
- XTENSA, MIPS, ARC
|
||||
|
||||
The following platforms are supported, click each link below for how to build iwasm on that platform. Refer to [WAMR porting guide](./doc/port_wamr.md) for how to port WAMR to a new platform.
|
||||
- [Linux](./product-mini/README.md#linux), [Linux SGX (Intel Software Guard Extension)](./doc/linux_sgx.md), [MacOS](./product-mini/README.md#macos), [Android](./product-mini/README.md#android), [Windows](./product-mini/README.md#windows), [Windows (MinGW, MSVC)](./product-mini/README.md#mingw)
|
||||
- [Zephyr](./product-mini/README.md#zephyr), [AliOS-Things](./product-mini/README.md#alios-things), [VxWorks](./product-mini/README.md#vxworks), [NuttX](./product-mini/README.md#nuttx), [RT-Thread](./product-mini/README.md#RT-Thread), [ESP-IDF(FreeRTOS)](./product-mini/README.md#esp-idf)
|
||||
Following platforms are supported. Refer to [WAMR porting guide](./doc/port_wamr.md) for how to port WAMR to a new platform.
|
||||
|
||||
- [Linux](./doc/build_wamr.md#linux), [Linux SGX (Intel Software Guard Extension)](./doc/linux_sgx.md), [MacOS](./doc/build_wamr.md#macos), [Android](./doc/build_wamr.md#android), [Windows](./doc/build_wamr.md#windows)
|
||||
- [Zephyr](./doc/build_wamr.md#zephyr), [AliOS-Things](./doc/build_wamr.md#alios-things), [VxWorks](./doc/build_wamr.md#vxworks), [NuttX](./doc/build_wamr.md#nuttx), [RT-Thread](./doc/build_wamr.md#RT-Thread)
|
||||
|
||||
### Build iwasm VM core (mini product)
|
||||
|
||||
WAMR supports building the iwasm VM core only (no app framework) to the mini product. The WAMR mini product takes the WASM application file name or AoT file name as input and then executes it. For the detailed procedure, please see **[build WAMR VM core](./doc/build_wamr.md)** and **[build and run WASM application](./doc/build_wasm_app.md)**. Also we can click the link of each platform above to see how to build iwasm on it.
|
||||
|
||||
### Build wamrc AoT compiler
|
||||
|
||||
Both wasm binary file and AoT file are supported by iwasm. The wamrc AoT compiler is to compile wasm binary file to AoT file which can also be run by iwasm. Execute following commands to build **wamrc** compiler for Linux:
|
||||
|
||||
```shell
|
||||
cd wamr-compiler
|
||||
./build_llvm.sh (or "./build_llvm_xtensa.sh" to support xtensa target)
|
||||
mkdir build && cd build
|
||||
cmake .. (or "cmake .. -DWAMR_BUILD_TARGET=darwin" for MacOS)
|
||||
make
|
||||
# wamrc is generated under current directory
|
||||
```
|
||||
|
||||
For **Windows**:
|
||||
```shell
|
||||
cd wamr-compiler
|
||||
python build_llvm.py
|
||||
open LLVM.sln in wasm-micro-runtime\core\deps\llvm\win32build with Visual Studio
|
||||
build LLVM.sln Release
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release
|
||||
# wamrc.exe is generated under .\Release directory
|
||||
```
|
||||
|
||||
Application framework
|
||||
===================================
|
||||
|
||||
By using the iwasm VM core, we are flexible to build different application frameworks for the specific domains, although it would take quite some effort.
|
||||
|
||||
The WAMR has offered a comprehensive framework for programming WASM applications for device and IoT usages. The framework supports running multiple applications, that are based on the event driven programming model. Here are the supporting API sets by the [WAMR application framework library](./doc/wamr_api.md) :
|
||||
|
||||
- Timer, Inter-app communication (request/response and pub/sub), Sensor, Connectivity and data transmission, 2D graphic UI
|
||||
|
||||
Browse the folder [core/app-framework](./core/app-framework) for how to extend the application framework.
|
||||
|
||||
# Remote application management
|
||||
|
||||
The WAMR application manager supports [remote application management](./core/app-mgr) from the host environment or the cloud through any physical communications such as TCP, UPD, UART, BLE, etc. Its modular design makes it able to support application management for different managed runtimes.
|
||||
|
||||
The tool [host_tool](./test-tools/host-tool) communicates to the WAMR app manager for installing/uninstalling the WASM applications on companion chip from the host system. And the [IoT App Store Demo](./test-tools/IoT-APP-Store-Demo/) shows the conception of remotely managing the device applications from the cloud.
|
||||
|
||||
|
||||
## Getting started
|
||||
- [Build VM core](./doc/build_wamr.md) and [Build wamrc AOT compiler](./wamr-compiler/README.md)
|
||||
- [Build iwasm (mini product)](./product-mini/README.md): [Linux](./product-mini/README.md#linux), [SGX](./doc/linux_sgx.md), [MacOS](./product-mini/README.md#macos) and [Windows](./product-mini/README.md#windows)
|
||||
- [Embed into C/C++](./doc/embed_wamr.md), [Embed into Python](./language-bindings/python), [Embed into Go](./language-bindings/go), [Embed in Rust](./language-bindings/rust)
|
||||
- [Register native APIs for Wasm applications](./doc/export_native_api.md)
|
||||
- [Build wamrc AOT compiler](./wamr-compiler/README.md)
|
||||
- [Build Wasm applications](./doc/build_wasm_app.md)
|
||||
- [Port WAMR to a new platform](./doc/port_wamr.md)
|
||||
- [VS Code development container](./doc/devcontainer.md)
|
||||
- [Samples](./samples) and [Benchmarks](./tests/benchmarks)
|
||||
- [End-user APIs documentation](https://bytecodealliance.github.io/wamr.dev/apis/)
|
||||
WAMR SDK
|
||||
==========
|
||||
|
||||
Usually there are two tasks for integrating the WAMR into a particular project:
|
||||
|
||||
- Select what WAMR components (vmcore, libc, app-mgr, app-framework components) to be integrated, and get the associated source files added into the project building configuration
|
||||
- Generate the APP SDK for developing the WASM apps on the selected libc and framework components
|
||||
|
||||
The **[WAMR SDK](./wamr-sdk)** tools is helpful to finish the two tasks quickly. It supports menu configuration for selecting WAMR components and builds the WAMR to a SDK package that includes **runtime SDK** and **APP SDK**. The runtime SDK is used for building the native application and the APP SDK should be shipped to WASM application developers.
|
||||
|
||||
|
||||
### Performance and memory
|
||||
- [Blog: The WAMR memory model](https://bytecodealliance.github.io/wamr.dev/blog/the-wamr-memory-model/)
|
||||
- [Blog: Understand WAMR heaps](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-heaps/) and [stacks](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-stacks/)
|
||||
- [Blog: Introduction to WAMR running modes](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/)
|
||||
- [Memory usage tuning](./doc/memory_tune.md): the memory model and how to tune the memory usage
|
||||
- [Memory usage profiling](./doc/build_wamr.md#enable-memory-profiling-experiment): how to profile the memory usage
|
||||
- [Performance tuning](./doc/perf_tune.md): how to tune the performance
|
||||
- [Benchmarks](./tests/benchmarks): checkout these links for how to run the benchmarks: [PolyBench](./tests/benchmarks/polybench), [CoreMark](./tests/benchmarks/coremark), [Sightglass](./tests/benchmarks/sightglass), [JetStream2](./tests/benchmarks/jetstream)
|
||||
- [Performance and footprint data](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Performance): the performance and footprint data
|
||||
Samples
|
||||
=================
|
||||
|
||||
The WAMR [samples](./samples) integrate the iwasm VM core, application manager and selected application framework components.
|
||||
|
||||
- [**basic**](./samples/basic): Demonstrating how to use runtime exposed API's to call WASM functions, how to register native functions and call them, and how to call WASM function from native function.
|
||||
- **[simple](./samples/simple/README.md)**: The runtime is integrated with most of the WAMR APP libraries, and a few WASM applications are provided for testing the WAMR APP API set. It uses **built-in libc** and executes apps in **interpreter** mode by default.
|
||||
- **[littlevgl](./samples/littlevgl/README.md)**: Demonstrating the graphic user interface application usage on WAMR. The whole [LittleVGL](https://github.com/lvgl/) 2D user graphic library and the UI application are built into WASM application. It uses **WASI libc** and executes apps in **AoT mode** by default.
|
||||
- **[gui](./samples/gui/README.md)**: Move the [LittleVGL](https://github.com/lvgl/) library into the runtime and define a WASM application interface by wrapping the littlevgl API. It uses **WASI libc** and executes apps in **interpreter** mode by default.
|
||||
- **[multi-thread](./samples/multi-thread/)**: Demonstrating how to run wasm application which creates multiple threads to execute wasm functions concurrently, and uses mutex/cond by calling pthread related API's.
|
||||
- **[spawn-thread](./samples/spawn-thread)**: Demonstrating how to execute wasm functions of the same wasm application concurrently, in threads created by host embedder or runtime, but not the wasm application itself.
|
||||
- **[multi-module](./samples/multi-module)**: Demonstrating the [multiple modules as dependencies](./doc/multi_module.md) feature which implements the [load-time dynamic linking](https://webassembly.org/docs/dynamic-linking/).
|
||||
- **[ref-types](./samples/ref-types)**: Demonstrating how to call wasm functions with argument of externref type introduced by [reference types proposal](https://github.com/WebAssembly/reference-types).
|
||||
- **[wasm-c-api](./samples/wasm-c-api/README.md)**: Demonstrating how to run some samples from [wasm-c-api proposal](https://github.com/WebAssembly/wasm-c-api) and showing the supported API's.
|
||||
- **[workload](./samples/workload/README.md)**: Demonstrating how to build and run some complex workloads, e.g. tensorflow-lite, XNNPACK, wasm-av1, meshoptimizer and bwa.
|
||||
|
||||
|
||||
Project Technical Steering Committee
|
||||
====================================
|
||||
The [WAMR PTSC Charter](./TSC_Charter.md) governs the operations of the project TSC.
|
||||
The current TSC members:
|
||||
- [dongsheng28849455](https://github.com/dongsheng28849455) - **Dongsheng Yan**, <dongsheng.yan@sony.com>
|
||||
- [loganek](https://github.com/loganek) - **Marcin Kolny**, <mkolny@amazon.co.uk>
|
||||
- [lum1n0us](https://github.com/lum1n0us) - **Liang He**, <liang.he@intel.com>
|
||||
- [no1wudi](https://github.com/no1wudi) **Qi Huang**, <huangqi3@xiaomi.com>
|
||||
- [qinxk-inter](https://github.com/qinxk-inter) - **Xiaokang Qin**, <xiaokang.qxk@antgroup.com>
|
||||
- [ttrenner ](https://github.com/ttrenner) - **Trenner, Thomas**, <trenner.thomas@siemens.com>
|
||||
- [wei-tang](https://github.com/wei-tang) - **Wei Tang**, <tangwei.tang@antgroup.com>
|
||||
- [wenyongh](https://github.com/wenyongh) - **Wenyong Huang**, <wenyong.huang@intel.com>
|
||||
- [woodsmc](https://github.com/woodsmc) - **Woods, Chris**, <chris.woods@siemens.com>
|
||||
- [xujuntwt95329](https://github.com/xujuntwt95329) - **Jun Xu**, <Jun1.Xu@intel.com>
|
||||
- [xwang98](https://github.com/xwang98) - **Xin Wang**, <xin.wang@intel.com> (chair)
|
||||
- [yamt](https://github.com/yamt) - **Takashi Yamamoto**, <yamamoto@midokura.com>
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
@ -111,9 +149,15 @@ exception. See the LICENSE file for details. This license allows you to freely
|
|||
use, modify, distribute and sell your own products based on WAMR.
|
||||
Any contributions you make will be under the same license.
|
||||
|
||||
# More resources
|
||||
- [Who use WAMR?](https://github.com/bytecodealliance/wasm-micro-runtime/wiki)
|
||||
- [WAMR Blogs](https://bytecodealliance.github.io/wamr.dev/blog/)
|
||||
- [Community news and events](https://bytecodealliance.github.io/wamr.dev/events/)
|
||||
- [WAMR TSC meetings](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/TSC-meeting-notes)
|
||||
|
||||
|
||||
# More resources
|
||||
|
||||
Check out the [Wiki documents ](https://github.com/bytecodealliance/wasm-micro-runtime/wiki) for more resources:
|
||||
|
||||
- [Performance and footprint data](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Performance)
|
||||
- [Community news and events](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Events)
|
||||
- [Roadmap](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Roadmap)
|
||||
- [WAMR TSC meetings](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/TSC-meeting)
|
||||
- Technical documents
|
||||
|
||||
|
|
1554
RELEASE_NOTES.md
1554
RELEASE_NOTES.md
File diff suppressed because it is too large
Load Diff
14
SConscript
14
SConscript
|
@ -15,9 +15,19 @@ list = os.listdir(cwd)
|
|||
|
||||
if GetDepend(['PKG_USING_WAMR']):
|
||||
wamr_entry_sconscript = os.path.join(cwd, "product-mini", "platforms", "rt-thread", 'SConscript')
|
||||
wamr_runlib_sconscript = os.path.join(cwd, "build-scripts", 'SConscript')
|
||||
|
||||
if os.path.isfile(wamr_entry_sconscript):
|
||||
objs = objs + SConscript(wamr_entry_sconscript)
|
||||
objs = objs + SConscript(wamr_runlib_sconscript)
|
||||
else:
|
||||
print("[WAMR] entry script wrong:", wamr_entry_sconscript)
|
||||
Return('objs')
|
||||
|
||||
wamr_runlib_sconsript = os.path.join(cwd, "build-scripts", 'SConscript')
|
||||
|
||||
if os.path.isfile(wamr_runlib_sconsript):
|
||||
objs = objs + SConscript(wamr_runlib_sconsript)
|
||||
else:
|
||||
print("[WAMR] runtime lib script wrong:", wamr_runlib_sconsript)
|
||||
|
||||
Return('objs')
|
||||
|
||||
|
|
1
assembly-script/.gitignore
vendored
Normal file
1
assembly-script/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/node_modules
|
124
assembly-script/README.md
Normal file
124
assembly-script/README.md
Normal file
|
@ -0,0 +1,124 @@
|
|||
# AssemblyScript_on_WAMR
|
||||
This project is based on [Wasm Micro Runtime](https://github.com/bytecodealliance/wasm-micro-runtime) (WAMR) and [AssemblyScript](https://github.com/AssemblyScript/assemblyscript). It implements some of the `wamr app framework` in *assemblyscript*, which allows you to write some applications in *assemblyscript* and dynamically installed on *WAMR Runtime*
|
||||
|
||||
## Building
|
||||
To build the samples in this repo, you need `npm` on your system
|
||||
``` bash
|
||||
sudo apt install npm
|
||||
```
|
||||
|
||||
Then install all the dependencies under the repo's root dir
|
||||
``` bash
|
||||
cd $repo_root
|
||||
npm install
|
||||
```
|
||||
|
||||
Use the command to build all samples:
|
||||
``` bash
|
||||
npm run build:all
|
||||
```
|
||||
or you can build every sample individually:
|
||||
``` bash
|
||||
npm run build:timer
|
||||
npm run build:publisher
|
||||
npm run build:subscriber
|
||||
# ...
|
||||
```
|
||||
You will get the compiled wasm file under `build` folder
|
||||
|
||||
Please refer to [package.json](./package.json) for more commands.
|
||||
|
||||
## Run
|
||||
These applications require WAMR's application framework, you need to build WAMR first.
|
||||
|
||||
``` bash
|
||||
cd ${WAMR_ROOT}/samples/simple
|
||||
./build.sh
|
||||
```
|
||||
|
||||
You will get two executable files under `out` folder:
|
||||
|
||||
`simple`: The wamr runtime with application framework
|
||||
|
||||
`host_tool`: The tool used to dynamically install/uninstall applications
|
||||
|
||||
1. Start the runtime:
|
||||
``` bash
|
||||
./simple -s
|
||||
```
|
||||
|
||||
2. Install the compiled wasm file using `host_tool`:
|
||||
``` bash
|
||||
./host_tool -i app_name -f your_compiled_wasm_file.wasm
|
||||
```
|
||||
You can also use the WAMR's AoT compiler `wamrc` to compile the wasm bytecode into native code before you run them. Please refer to this [guide](../README.md#build-wamrc-aot-compiler) to build and install `WAMR AoT compiler`.
|
||||
|
||||
After installing `wamrc`, you can compile the wasm file using command:
|
||||
``` bash
|
||||
wamrc -o file_name.aot file_name.wasm
|
||||
```
|
||||
and you can install the AoT file to the runtime:
|
||||
``` bash
|
||||
./host_tool -i app_name -f your_compiled_aot_file.aot
|
||||
```
|
||||
|
||||
## Development
|
||||
You can develop your own application based on the `wamr_app_lib` APIs.
|
||||
|
||||
### Console APIs
|
||||
``` typescript
|
||||
function log(a: string): void;
|
||||
function log_number(a: number): void;
|
||||
```
|
||||
|
||||
### Timer APIs
|
||||
``` typescript
|
||||
function setTimeout(cb: () => void, timeout: i32): user_timer;
|
||||
function setInterval(cb: () => void, timeout: i32): user_timer;
|
||||
function timer_cancel(timer: user_timer): void;
|
||||
function timer_restart(timer: user_timer, interval: number): void;
|
||||
function now(): i32;
|
||||
|
||||
// export to runtime
|
||||
function on_timer_callback(on_timer_id: i32): void;
|
||||
```
|
||||
|
||||
### Request APIs
|
||||
``` typescript
|
||||
// register handler
|
||||
function register_resource_handler(url: string,
|
||||
request_handle: request_handler_f): void;
|
||||
// request
|
||||
function post(url: string, payload: ArrayBuffer, payload_len: number,
|
||||
tag: string, cb: (resp: wamr_response) => void): void;
|
||||
function get(url: string, tag: string,
|
||||
cb: (resp: wamr_response) => void): void;
|
||||
function put(url: string, payload: ArrayBuffer, payload_len: number, tag: string,
|
||||
cb: (resp: wamr_response) => void): void;
|
||||
function del(url: string, tag: string,
|
||||
cb: (resp: wamr_response) => void): void;
|
||||
|
||||
// response
|
||||
function make_response_for_request(req: wamr_request): wamr_response;
|
||||
function api_response_send(resp: wamr_response): void;
|
||||
|
||||
// event
|
||||
function publish_event(url: string, fmt: number,
|
||||
payload: ArrayBuffer, payload_len: number): void;
|
||||
function subscribe_event(url: string, cb: request_handler_f): void;
|
||||
|
||||
// export to runtime
|
||||
function on_request(buffer_offset: i32, size: i32): void;
|
||||
function on_response(buffer_offset : i32, size: i32): void;
|
||||
```
|
||||
|
||||
You should export the `on_timer_callback`, `on_request` and `on_response` in your application entry file, refer to the samples for example.
|
||||
|
||||
To build your application, you can use `asc`:
|
||||
``` bash
|
||||
asc app.ts -b build/app.wasm -t build/app.wat --sourceMap --validate --optimize
|
||||
```
|
||||
or you can add a command into [package.json](./package.json):
|
||||
``` json
|
||||
"build:app": "asc app.ts -b build/app.wasm -t build/app.wat --sourceMap --validate --optimize",
|
||||
```
|
30
assembly-script/package-lock.json
generated
Normal file
30
assembly-script/package-lock.json
generated
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "assembly_script",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"assemblyscript": {
|
||||
"version": "0.17.4",
|
||||
"resolved": "https://registry.npm.taobao.org/assemblyscript/download/assemblyscript-0.17.4.tgz",
|
||||
"integrity": "sha1-1GEduJpClDNa1H7DxmYaJqRCh3E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"binaryen": "98.0.0-nightly.20201109",
|
||||
"long": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"binaryen": {
|
||||
"version": "98.0.0-nightly.20201109",
|
||||
"resolved": "https://registry.npm.taobao.org/binaryen/download/binaryen-98.0.0-nightly.20201109.tgz",
|
||||
"integrity": "sha1-USv2yhXGe/dAIURzSkg25jmTqgU=",
|
||||
"dev": true
|
||||
},
|
||||
"long": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npm.taobao.org/long/download/long-4.0.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flong%2Fdownload%2Flong-4.0.0.tgz",
|
||||
"integrity": "sha1-mntxz7fTYaGU6lVSQckvdGjVvyg=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
20
assembly-script/package.json
Normal file
20
assembly-script/package.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "assembly_script",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build:request_handler": "asc samples/request_handler.ts -b build/request_handler.wasm -t build/request_handler.wat --sourceMap --optimize --exportRuntime --use abort=",
|
||||
"build:request_sender": "asc samples/request_sender.ts -b build/request_sender.wasm -t build/request_sender.wat --sourceMap --optimize --exportRuntime --use abort=",
|
||||
"build:timer": "asc samples/timer.ts -b build/timer.wasm -t build/timer.wat --sourceMap --optimize --exportRuntime --use abort=",
|
||||
"build:publisher": "asc samples/event_publisher.ts -b build/event_publisher.wasm -t build/event_publisher.wat --sourceMap --optimize --exportRuntime --use abort=",
|
||||
"build:subscriber": "asc samples/event_subscriber.ts -b build/event_subscriber.wasm -t build/event_subscriber.wat --sourceMap --optimize --exportRuntime --use abort=",
|
||||
"build:all": "npm run build:request_handler; npm run build:request_sender; npm run build:timer; npm run build:subscriber; npm run build:publisher"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"assemblyscript": "^0.18.15"
|
||||
}
|
||||
}
|
36
assembly-script/samples/event_publisher.ts
Normal file
36
assembly-script/samples/event_publisher.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
// The entry file of your WebAssembly module.
|
||||
import * as console from "../wamr_app_lib/console"
|
||||
import * as timer from "../wamr_app_lib/timer"
|
||||
import * as request from "../wamr_app_lib/request"
|
||||
|
||||
function publish_overheat_event(): void {
|
||||
var payload = String.UTF8.encode("warning: temperature is over high");
|
||||
request.publish_event("alert/overheat", 0, payload, payload.byteLength);
|
||||
}
|
||||
|
||||
export function on_init() : void {
|
||||
timer.setInterval(publish_overheat_event, 2000);
|
||||
}
|
||||
|
||||
export function on_destroy() : void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Function below are requred by wamr runtime, don't remove or modify them */
|
||||
export function _on_timer_callback(on_timer_id: i32): void {
|
||||
timer.on_timer_callback(on_timer_id);
|
||||
}
|
||||
|
||||
export function _on_request(buffer_offset: i32, size: i32): void {
|
||||
request.on_request(buffer_offset, size);
|
||||
}
|
||||
|
||||
export function _on_response(buffer_offset : i32, size: i32): void {
|
||||
request.on_response(buffer_offset, size);
|
||||
}
|
36
assembly-script/samples/event_subscriber.ts
Normal file
36
assembly-script/samples/event_subscriber.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
// The entry file of your WebAssembly module.
|
||||
import * as console from "../wamr_app_lib/console"
|
||||
import * as timer from "../wamr_app_lib/timer"
|
||||
import * as request from "../wamr_app_lib/request"
|
||||
|
||||
export function on_init() : void {
|
||||
request.subscribe_event("alert/overheat", (req) => {
|
||||
console.log("### user over heat event handler called:");
|
||||
|
||||
console.log("");
|
||||
console.log(" " + String.UTF8.decode(req.payload) + "\n");
|
||||
})
|
||||
}
|
||||
|
||||
export function on_destroy() : void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Function below are requred by wamr runtime, don't remove or modify them */
|
||||
export function _on_timer_callback(on_timer_id: i32): void {
|
||||
timer.on_timer_callback(on_timer_id);
|
||||
}
|
||||
|
||||
export function _on_request(buffer_offset: i32, size: i32): void {
|
||||
request.on_request(buffer_offset, size);
|
||||
}
|
||||
|
||||
export function _on_response(buffer_offset : i32, size: i32): void {
|
||||
request.on_response(buffer_offset, size);
|
||||
}
|
40
assembly-script/samples/request_handler.ts
Normal file
40
assembly-script/samples/request_handler.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
// The entry file of your WebAssembly module.
|
||||
import * as console from "../wamr_app_lib/console"
|
||||
import * as timer from "../wamr_app_lib/timer"
|
||||
import * as request from "../wamr_app_lib/request"
|
||||
|
||||
export function on_init() : void {
|
||||
request.register_resource_handler("/test", (req) => {
|
||||
console.log("### Req: /test " + String.UTF8.decode(req.payload));
|
||||
|
||||
console.log(" request payload:");
|
||||
console.log(" " + String.UTF8.decode(req.payload) + "\n");
|
||||
|
||||
var resp = request.make_response_for_request(req);
|
||||
resp.set_payload(String.UTF8.encode("Ok"), 2);
|
||||
request.api_response_send(resp);
|
||||
});
|
||||
}
|
||||
|
||||
export function on_destroy() : void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Function below are requred by wamr runtime, don't remove or modify them */
|
||||
export function _on_timer_callback(on_timer_id: i32): void {
|
||||
timer.on_timer_callback(on_timer_id);
|
||||
}
|
||||
|
||||
export function _on_request(buffer_offset: i32, size: i32): void {
|
||||
request.on_request(buffer_offset, size);
|
||||
}
|
||||
|
||||
export function _on_response(buffer_offset : i32, size: i32): void {
|
||||
request.on_response(buffer_offset, size);
|
||||
}
|
43
assembly-script/samples/request_sender.ts
Normal file
43
assembly-script/samples/request_sender.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
// The entry file of your WebAssembly module.
|
||||
import * as console from "../wamr_app_lib/console"
|
||||
import * as timer from "../wamr_app_lib/timer"
|
||||
import * as request from "../wamr_app_lib/request"
|
||||
|
||||
export function on_init() : void {
|
||||
var payload = String.UTF8.encode("test message");
|
||||
request.post("/test", payload, payload.byteLength, "", (resp) => {
|
||||
if (resp != null) {
|
||||
console.log("Post Success");
|
||||
|
||||
if (resp.payload != null) {
|
||||
console.log(" response payload:")
|
||||
console.log(" " + String.UTF8.decode(resp.payload!) + "\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
console.log("Post Timeout");
|
||||
});
|
||||
}
|
||||
|
||||
export function on_destroy() : void {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Function below are requred by wamr runtime, don't remove or modify them */
|
||||
export function _on_timer_callback(on_timer_id: i32): void {
|
||||
timer.on_timer_callback(on_timer_id);
|
||||
}
|
||||
|
||||
export function _on_request(buffer_offset: i32, size: i32): void {
|
||||
request.on_request(buffer_offset, size);
|
||||
}
|
||||
|
||||
export function _on_response(buffer_offset : i32, size: i32): void {
|
||||
request.on_response(buffer_offset, size);
|
||||
}
|
36
assembly-script/samples/timer.ts
Normal file
36
assembly-script/samples/timer.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
// The entry file of your WebAssembly module.
|
||||
import * as console from '../wamr_app_lib/console'
|
||||
import * as timer from '../wamr_app_lib/timer'
|
||||
|
||||
/* clousure is not implemented yet, we need to declare global variables
|
||||
so that they can be accessed inside a callback function */
|
||||
var cnt = 0;
|
||||
var my_timer: timer.user_timer;
|
||||
|
||||
export function on_init(): void {
|
||||
/* The callback function will be called every 2 second,
|
||||
and will stop after 10 calls */
|
||||
my_timer = timer.setInterval(() => {
|
||||
cnt ++;
|
||||
console.log((cnt * 2).toString() + " seconds passed");
|
||||
|
||||
if (cnt >= 10) {
|
||||
timer.timer_cancel(my_timer);
|
||||
console.log("Stop Timer");
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
export function on_destroy(): void {
|
||||
|
||||
}
|
||||
|
||||
/* Function below are requred by wamr runtime, don't remove or modify them */
|
||||
export function _on_timer_callback(on_timer_id: i32): void {
|
||||
timer.on_timer_callback(on_timer_id);
|
||||
}
|
6
assembly-script/samples/tsconfig.json
Normal file
6
assembly-script/samples/tsconfig.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"extends": "../node_modules/assemblyscript/std/assembly.json",
|
||||
"include": [
|
||||
"./**/*.ts"
|
||||
]
|
||||
}
|
495
assembly-script/wamr_app_lib/request.ts
Normal file
495
assembly-script/wamr_app_lib/request.ts
Normal file
|
@ -0,0 +1,495 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
import * as console from './console'
|
||||
import * as timer from './timer'
|
||||
|
||||
@external("env", "wasm_response_send")
|
||||
declare function wasm_response_send(buffer: ArrayBuffer, size: i32): void;
|
||||
|
||||
@external("env", "wasm_register_resource")
|
||||
declare function wasm_register_resource(url: ArrayBuffer): void;
|
||||
|
||||
@external("env", "wasm_post_request")
|
||||
declare function wasm_post_request(buffer: ArrayBuffer, size: i32): void;
|
||||
|
||||
@external("env", "wasm_sub_event")
|
||||
declare function wasm_sub_event(url: ArrayBuffer): void;
|
||||
|
||||
var COAP_GET = 1;
|
||||
var COAP_POST = 2;
|
||||
var COAP_PUT = 3;
|
||||
var COAP_DELETE = 4;
|
||||
var COAP_EVENT = COAP_DELETE + 2;
|
||||
|
||||
/* CoAP response codes */
|
||||
export enum CoAP_Status {
|
||||
NO_ERROR = 0,
|
||||
|
||||
CREATED_2_01 = 65, /* CREATED */
|
||||
DELETED_2_02 = 66, /* DELETED */
|
||||
VALID_2_03 = 67, /* NOT_MODIFIED */
|
||||
CHANGED_2_04 = 68, /* CHANGED */
|
||||
CONTENT_2_05 = 69, /* OK */
|
||||
CONTINUE_2_31 = 95, /* CONTINUE */
|
||||
|
||||
BAD_REQUEST_4_00 = 128, /* BAD_REQUEST */
|
||||
UNAUTHORIZED_4_01 = 129, /* UNAUTHORIZED */
|
||||
BAD_OPTION_4_02 = 130, /* BAD_OPTION */
|
||||
FORBIDDEN_4_03 = 131, /* FORBIDDEN */
|
||||
NOT_FOUND_4_04 = 132, /* NOT_FOUND */
|
||||
METHOD_NOT_ALLOWED_4_05 = 133, /* METHOD_NOT_ALLOWED */
|
||||
NOT_ACCEPTABLE_4_06 = 134, /* NOT_ACCEPTABLE */
|
||||
PRECONDITION_FAILED_4_12 = 140, /* BAD_REQUEST */
|
||||
REQUEST_ENTITY_TOO_LARGE_4_13 = 141, /* REQUEST_ENTITY_TOO_LARGE */
|
||||
UNSUPPORTED_MEDIA_TYPE_4_15 = 143, /* UNSUPPORTED_MEDIA_TYPE */
|
||||
|
||||
INTERNAL_SERVER_ERROR_5_00 = 160, /* INTERNAL_SERVER_ERROR */
|
||||
NOT_IMPLEMENTED_5_01 = 161, /* NOT_IMPLEMENTED */
|
||||
BAD_GATEWAY_5_02 = 162, /* BAD_GATEWAY */
|
||||
SERVICE_UNAVAILABLE_5_03 = 163, /* SERVICE_UNAVAILABLE */
|
||||
GATEWAY_TIMEOUT_5_04 = 164, /* GATEWAY_TIMEOUT */
|
||||
PROXYING_NOT_SUPPORTED_5_05 = 165, /* PROXYING_NOT_SUPPORTED */
|
||||
|
||||
/* Erbium errors */
|
||||
MEMORY_ALLOCATION_ERROR = 192, PACKET_SERIALIZATION_ERROR,
|
||||
|
||||
/* Erbium hooks */
|
||||
MANUAL_RESPONSE, PING_RESPONSE
|
||||
};
|
||||
|
||||
var g_mid: i32 = 0;
|
||||
class wamr_request {
|
||||
mid: i32 = 0;
|
||||
url: string = "";
|
||||
action: i32 = 0;
|
||||
fmt: i32 = 0;
|
||||
payload: ArrayBuffer;
|
||||
payload_len: i32 = 0;
|
||||
|
||||
sender: i32 = 0;
|
||||
|
||||
constructor(mid: i32, url: string, action: i32, fmt: i32,
|
||||
payload: ArrayBuffer, payload_len: number) {
|
||||
this.mid = mid;
|
||||
this.url = url;
|
||||
this.action = action;
|
||||
this.fmt = fmt;
|
||||
this.payload = payload;
|
||||
this.payload_len = i32(payload_len);
|
||||
}
|
||||
}
|
||||
|
||||
class wamr_response {
|
||||
mid: i32 = 0;
|
||||
status: i32 = 0;
|
||||
fmt: i32 = 0;
|
||||
payload: ArrayBuffer | null;
|
||||
payload_len: i32 = 0;
|
||||
|
||||
receiver: i32 = 0;
|
||||
|
||||
constructor(mid: i32, status: i32, fmt: i32,
|
||||
payload: ArrayBuffer | null, payload_len: i32) {
|
||||
this.mid = mid;
|
||||
this.status = status;
|
||||
this.fmt = fmt;
|
||||
this.payload = payload;
|
||||
this.payload_len = payload_len;
|
||||
}
|
||||
|
||||
set_status(status: number): void {
|
||||
this.status = i32(status);
|
||||
}
|
||||
|
||||
set_payload(payload: ArrayBuffer, payload_len: number): void {
|
||||
this.payload = payload;
|
||||
this.payload_len = i32(payload_len);
|
||||
}
|
||||
}
|
||||
|
||||
class wamr_resource {
|
||||
url: string;
|
||||
type: number;
|
||||
cb: request_handler_f;
|
||||
|
||||
constructor(url: string, type: number, cb: request_handler_f) {
|
||||
this.url = url;
|
||||
this.type = type;
|
||||
this.cb = cb;
|
||||
}
|
||||
}
|
||||
|
||||
function is_expire(trans: wamr_transaction, index: i32, array: Array<wamr_transaction>): bool {
|
||||
var now = timer.now();
|
||||
|
||||
var elapsed_ms = (now < trans.time) ?
|
||||
(now + (0xFFFFFFFF - trans.time) + 1) : (now - trans.time);
|
||||
|
||||
return elapsed_ms >= TRANSACTION_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
function not_expire(trans: wamr_transaction, index: i32, array: Array<wamr_transaction>): bool {
|
||||
var now = timer.now();
|
||||
|
||||
var elapsed_ms = (now < trans.time) ?
|
||||
(now + (0xFFFFFFFF - trans.time) + 1) : (now - trans.time);
|
||||
|
||||
return elapsed_ms >= TRANSACTION_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
function transaction_timeout_handler(): void {
|
||||
var now = timer.now();
|
||||
|
||||
var expired = transaction_list.filter(is_expire);
|
||||
transaction_list = transaction_list.filter(not_expire);
|
||||
|
||||
expired.forEach(item => {
|
||||
item.cb(null);
|
||||
transaction_remove(item);
|
||||
})
|
||||
|
||||
if (transaction_list.length > 0) {
|
||||
var elpased_ms: number, ms_to_expiry: number;
|
||||
now = timer.now();
|
||||
if (now < transaction_list[0].time) {
|
||||
elpased_ms = now + (0xFFFFFFFF - transaction_list[0].time) + 1;
|
||||
} else {
|
||||
elpased_ms = now - transaction_list[0].time;
|
||||
}
|
||||
ms_to_expiry = TRANSACTION_TIMEOUT_MS - elpased_ms;
|
||||
timer.timer_restart(g_trans_timer, ms_to_expiry);
|
||||
} else {
|
||||
timer.timer_cancel(g_trans_timer);
|
||||
}
|
||||
}
|
||||
|
||||
function transaction_find(mid: number): wamr_transaction | null {
|
||||
for (let i = 0; i < transaction_list.length; i++) {
|
||||
if (transaction_list[i].mid == mid)
|
||||
return transaction_list[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function transaction_add(trans: wamr_transaction): void {
|
||||
transaction_list.push(trans);
|
||||
|
||||
if (transaction_list.length == 1) {
|
||||
g_trans_timer = timer.setTimeout(
|
||||
transaction_timeout_handler,
|
||||
TRANSACTION_TIMEOUT_MS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function transaction_remove(trans: wamr_transaction): void {
|
||||
var index = transaction_list.indexOf(trans);
|
||||
transaction_list.splice(index, 1);
|
||||
}
|
||||
|
||||
var transaction_list = new Array<wamr_transaction>();
|
||||
class wamr_transaction {
|
||||
mid: number;
|
||||
time: number;
|
||||
cb: (resp: wamr_response | null) => void;
|
||||
|
||||
constructor(mid: number, time: number, cb: (resp: wamr_response) => void) {
|
||||
this.mid = mid;
|
||||
this.time = time;
|
||||
this.cb = cb;
|
||||
}
|
||||
}
|
||||
|
||||
var REQUEST_PACKET_FIX_PART_LEN = 18;
|
||||
var RESPONSE_PACKET_FIX_PART_LEN = 16;
|
||||
var TRANSACTION_TIMEOUT_MS = 5000;
|
||||
var g_trans_timer: timer.user_timer;
|
||||
|
||||
var Reg_Event = 0;
|
||||
var Reg_Request = 1;
|
||||
|
||||
function pack_request(req: wamr_request): DataView {
|
||||
var url_len = req.url.length + 1;
|
||||
var len = REQUEST_PACKET_FIX_PART_LEN + url_len + req.payload_len
|
||||
var buf = new ArrayBuffer(len);
|
||||
|
||||
var dataview = new DataView(buf, 0, len);
|
||||
|
||||
dataview.setUint8(0, 1);
|
||||
dataview.setUint8(1, u8(req.action));
|
||||
dataview.setUint16(2, u16(req.fmt));
|
||||
dataview.setUint32(4, req.mid);
|
||||
dataview.setUint32(8, req.sender);
|
||||
dataview.setUint16(12, u16(url_len))
|
||||
dataview.setUint32(14, req.payload_len);
|
||||
|
||||
var i = 0;
|
||||
for (i = 0; i < url_len - 1; i++) {
|
||||
dataview.setUint8(i + 18, u8(req.url.codePointAt(i)));
|
||||
}
|
||||
dataview.setUint8(i + 18, 0);
|
||||
|
||||
var payload_view = new DataView(req.payload);
|
||||
for (i = 0; i < req.payload_len; i++) {
|
||||
dataview.setUint8(i + 18 + url_len, u8(payload_view.getUint8(i)));
|
||||
}
|
||||
|
||||
return dataview;
|
||||
}
|
||||
|
||||
function unpack_request(packet: ArrayBuffer, size: i32): wamr_request {
|
||||
var dataview = new DataView(packet, 0, size);
|
||||
|
||||
if (dataview.getUint8(0) != 1)
|
||||
throw new Error("packet version mismatch");
|
||||
|
||||
if (size < REQUEST_PACKET_FIX_PART_LEN)
|
||||
throw new Error("packet size error");
|
||||
|
||||
var url_len = dataview.getUint16(12);
|
||||
var payload_len = dataview.getUint32(14);
|
||||
|
||||
if (size != (REQUEST_PACKET_FIX_PART_LEN + url_len + payload_len))
|
||||
throw new Error("packet size error");
|
||||
|
||||
var action = dataview.getUint8(1);
|
||||
var fmt = dataview.getUint16(2);
|
||||
var mid = dataview.getUint32(4);
|
||||
var sender = dataview.getUint32(8);
|
||||
|
||||
var url = packet.slice(REQUEST_PACKET_FIX_PART_LEN, REQUEST_PACKET_FIX_PART_LEN + url_len - 1);
|
||||
var payload = packet.slice(REQUEST_PACKET_FIX_PART_LEN + url_len, REQUEST_PACKET_FIX_PART_LEN + url_len + payload_len);
|
||||
|
||||
var req = new wamr_request(mid, String.UTF8.decode(url), action, fmt, payload, payload_len);
|
||||
req.sender = sender;
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
function pack_response(resp: wamr_response): DataView {
|
||||
var len = RESPONSE_PACKET_FIX_PART_LEN + resp.payload_len
|
||||
var buf = new ArrayBuffer(len);
|
||||
|
||||
var dataview = new DataView(buf, 0, len);
|
||||
|
||||
dataview.setUint8(0, 1);
|
||||
dataview.setUint8(1, u8(resp.status));
|
||||
dataview.setUint16(2, u16(resp.fmt));
|
||||
dataview.setUint32(4, resp.mid);
|
||||
dataview.setUint32(8, resp.receiver);
|
||||
dataview.setUint32(12, resp.payload_len)
|
||||
|
||||
if (resp.payload != null) {
|
||||
var payload_view = new DataView(resp.payload!);
|
||||
for (let i = 0; i < resp.payload_len; i++) {
|
||||
dataview.setUint8(i + 16, payload_view.getUint8(i));
|
||||
}
|
||||
}
|
||||
|
||||
return dataview;
|
||||
}
|
||||
|
||||
function unpack_response(packet: ArrayBuffer, size: i32): wamr_response {
|
||||
var dataview = new DataView(packet, 0, size);
|
||||
|
||||
if (dataview.getUint8(0) != 1)
|
||||
throw new Error("packet version mismatch");
|
||||
|
||||
if (size < RESPONSE_PACKET_FIX_PART_LEN)
|
||||
throw new Error("packet size error");
|
||||
|
||||
var payload_len = dataview.getUint32(12);
|
||||
if (size != RESPONSE_PACKET_FIX_PART_LEN + payload_len)
|
||||
throw new Error("packet size error");
|
||||
|
||||
var status = dataview.getUint8(1);
|
||||
var fmt = dataview.getUint16(2);
|
||||
var mid = dataview.getUint32(4);
|
||||
var receiver = dataview.getUint32(8);
|
||||
|
||||
var payload = packet.slice(RESPONSE_PACKET_FIX_PART_LEN);
|
||||
|
||||
var resp = new wamr_response(mid, status, fmt, payload, payload_len);
|
||||
resp.receiver = receiver;
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
function do_request(req: wamr_request, cb: (resp: wamr_response) => void): void {
|
||||
var trans = new wamr_transaction(req.mid, timer.now(), cb);
|
||||
var msg = pack_request(req);
|
||||
|
||||
transaction_add(trans);
|
||||
|
||||
wasm_post_request(msg.buffer, msg.byteLength);
|
||||
}
|
||||
|
||||
function do_response(resp: wamr_response): void {
|
||||
var msg = pack_response(resp);
|
||||
|
||||
wasm_response_send(msg.buffer, msg.byteLength);
|
||||
}
|
||||
|
||||
var resource_list = new Array<wamr_resource>();
|
||||
type request_handler_f = (req: wamr_request) => void;
|
||||
|
||||
function registe_url_handler(url: string, cb: request_handler_f, type: number): void {
|
||||
for (let i = 0; i < resource_list.length; i++) {
|
||||
if (resource_list[i].type == type && resource_list[i].url == url) {
|
||||
resource_list[i].cb = cb;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var res = new wamr_resource(url, type, cb);
|
||||
resource_list.push(res);
|
||||
|
||||
if (type == Reg_Request)
|
||||
wasm_register_resource(String.UTF8.encode(url));
|
||||
else
|
||||
wasm_sub_event(String.UTF8.encode(url));
|
||||
}
|
||||
|
||||
function is_event_type(req: wamr_request): bool {
|
||||
return req.action == COAP_EVENT;
|
||||
}
|
||||
|
||||
function check_url_start(url: string, leading_str: string): bool {
|
||||
return url.split('/')[0] == leading_str.split('/')[0];
|
||||
}
|
||||
|
||||
/* User APIs below */
|
||||
export function post(url: string, payload: ArrayBuffer, payload_len: number, tag: string,
|
||||
cb: (resp: wamr_response) => void): void {
|
||||
var req = new wamr_request(g_mid++, url, COAP_POST, 0, payload, payload_len);
|
||||
|
||||
do_request(req, cb);
|
||||
}
|
||||
|
||||
export function get(url: string, tag: string,
|
||||
cb: (resp: wamr_response) => void): void {
|
||||
var req = new wamr_request(g_mid++, url, COAP_GET, 0, new ArrayBuffer(0), 0);
|
||||
|
||||
do_request(req, cb);
|
||||
}
|
||||
|
||||
export function put(url: string, payload: ArrayBuffer, payload_len: number, tag: string,
|
||||
cb: (resp: wamr_response) => void): void {
|
||||
var req = new wamr_request(g_mid++, url, COAP_PUT, 0, payload, payload_len);
|
||||
|
||||
do_request(req, cb);
|
||||
}
|
||||
|
||||
export function del(url: string, tag: string,
|
||||
cb: (resp: wamr_response) => void): void {
|
||||
var req = new wamr_request(g_mid++, url, COAP_PUT, 0, new ArrayBuffer(0), 0);
|
||||
|
||||
do_request(req, cb);
|
||||
}
|
||||
|
||||
export function make_response_for_request(req: wamr_request): wamr_response {
|
||||
var resp = new wamr_response(req.mid, CoAP_Status.CONTENT_2_05, 0, null, 0);
|
||||
resp.receiver = req.sender;
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
export function api_response_send(resp: wamr_response): void {
|
||||
do_response(resp);
|
||||
}
|
||||
|
||||
export function register_resource_handler(url: string,
|
||||
request_handle: request_handler_f): void {
|
||||
registe_url_handler(url, request_handle, Reg_Request);
|
||||
}
|
||||
|
||||
export function publish_event(url: string, fmt: number,
|
||||
payload: ArrayBuffer, payload_len: number): void {
|
||||
var req = new wamr_request(g_mid++, url, COAP_EVENT, i32(fmt), payload, payload_len);
|
||||
|
||||
var msg = pack_request(req);
|
||||
|
||||
wasm_post_request(msg.buffer, msg.byteLength);
|
||||
}
|
||||
|
||||
export function subscribe_event(url: string, cb: request_handler_f): void {
|
||||
registe_url_handler(url, cb, Reg_Event);
|
||||
}
|
||||
|
||||
|
||||
/* These two APIs are required by wamr runtime,
|
||||
use a wrapper to export them in the entry file
|
||||
|
||||
e.g:
|
||||
|
||||
import * as request from '.wamr_app_lib/request'
|
||||
|
||||
// Your code here ...
|
||||
|
||||
export function _on_request(buffer_offset: i32, size: i32): void {
|
||||
on_request(buffer_offset, size);
|
||||
}
|
||||
|
||||
export function _on_response(buffer_offset: i32, size: i32): void {
|
||||
on_response(buffer_offset, size);
|
||||
}
|
||||
*/
|
||||
export function on_request(buffer_offset: i32, size: i32): void {
|
||||
var buffer = new ArrayBuffer(size);
|
||||
var dataview = new DataView(buffer);
|
||||
|
||||
for (let i = 0; i < size; i++) {
|
||||
dataview.setUint8(i, load<i8>(buffer_offset + i, 0, 1));
|
||||
}
|
||||
|
||||
var req = unpack_request(buffer, size);
|
||||
|
||||
var is_event = is_event_type(req);
|
||||
|
||||
for (let i = 0; i < resource_list.length; i++) {
|
||||
if ((is_event && resource_list[i].type == Reg_Event)
|
||||
|| (!is_event && resource_list[i].type == Reg_Request)) {
|
||||
if (check_url_start(req.url, resource_list[i].url)) {
|
||||
resource_list[i].cb(req);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("on_request: exit. no service handler.");
|
||||
}
|
||||
|
||||
export function on_response(buffer_offset: i32, size: i32): void {
|
||||
var buffer = new ArrayBuffer(size);
|
||||
var dataview = new DataView(buffer);
|
||||
|
||||
for (let i = 0; i < size; i++) {
|
||||
dataview.setUint8(i, load<i8>(buffer_offset + i, 0, 1));
|
||||
}
|
||||
|
||||
var resp = unpack_response(buffer, size);
|
||||
var trans = transaction_find(resp.mid);
|
||||
|
||||
if (trans != null) {
|
||||
if (transaction_list.indexOf(trans) == 0) {
|
||||
if (transaction_list.length >= 2) {
|
||||
var elpased_ms: number, ms_to_expiry: number;
|
||||
var now = timer.now();
|
||||
if (now < transaction_list[1].time) {
|
||||
elpased_ms = now + (0xFFFFFFFF - transaction_list[1].time) + 1;
|
||||
} else {
|
||||
elpased_ms = now - transaction_list[1].time;
|
||||
}
|
||||
ms_to_expiry = TRANSACTION_TIMEOUT_MS - elpased_ms;
|
||||
timer.timer_restart(g_trans_timer, ms_to_expiry);
|
||||
} else {
|
||||
timer.timer_cancel(g_trans_timer);
|
||||
}
|
||||
}
|
||||
|
||||
trans.cb(resp);
|
||||
}
|
||||
}
|
80
assembly-script/wamr_app_lib/timer.ts
Normal file
80
assembly-script/wamr_app_lib/timer.ts
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
@external("env", "wasm_create_timer")
|
||||
declare function wasm_create_timer(a: i32, b: bool, c: bool): i32;
|
||||
|
||||
@external("env", "wasm_timer_cancel")
|
||||
declare function wasm_timer_cancel(a: i32): void;
|
||||
|
||||
@external("env", "wasm_timer_restart")
|
||||
declare function wasm_timer_restart(a: i32, b: i32): void;
|
||||
|
||||
@external("env", "wasm_get_sys_tick_ms")
|
||||
declare function wasm_get_sys_tick_ms(): i32;
|
||||
|
||||
export var timer_list = new Array<user_timer>();
|
||||
|
||||
export class user_timer {
|
||||
timer_id: i32 = 0;
|
||||
timeout: i32;
|
||||
period: bool = false;
|
||||
cb: () => void;
|
||||
|
||||
constructor(cb: () => void, timeout: i32, period: bool) {
|
||||
this.cb = cb;
|
||||
this.timeout = timeout;
|
||||
this.period = period
|
||||
this.timer_id = timer_create(this.timeout, this.period, true);
|
||||
}
|
||||
}
|
||||
|
||||
export function timer_create(a: i32, b: bool, c: bool): i32 {
|
||||
return wasm_create_timer(a, b, c);
|
||||
}
|
||||
|
||||
export function setTimeout(cb: () => void, timeout: i32): user_timer {
|
||||
var timer = new user_timer(cb, timeout, false);
|
||||
timer_list.push(timer);
|
||||
|
||||
return timer;
|
||||
}
|
||||
|
||||
export function setInterval(cb: () => void, timeout: i32): user_timer {
|
||||
var timer = new user_timer(cb, timeout, true);
|
||||
timer_list.push(timer);
|
||||
|
||||
return timer;
|
||||
}
|
||||
|
||||
export function timer_cancel(timer: user_timer): void {
|
||||
wasm_timer_cancel(timer.timer_id);
|
||||
|
||||
var i = 0;
|
||||
for (i = 0; i < timer_list.length; i++) {
|
||||
if (timer_list[i].timer_id == timer.timer_id)
|
||||
break;
|
||||
}
|
||||
|
||||
timer_list.splice(i, 1);
|
||||
}
|
||||
|
||||
export function timer_restart(timer: user_timer, interval: number): void {
|
||||
wasm_timer_restart(timer.timer_id, i32(interval));
|
||||
}
|
||||
|
||||
export function now(): i32 {
|
||||
return wasm_get_sys_tick_ms();
|
||||
}
|
||||
|
||||
// This export function need to be copied to the top application file
|
||||
//
|
||||
export function on_timer_callback(on_timer_id: i32): void {
|
||||
for (let i = 0; i < timer_list.length; i++) {
|
||||
if (timer_list[i].timer_id == on_timer_id) {
|
||||
timer_list[i].cb();
|
||||
}
|
||||
}
|
||||
}
|
6
assembly-script/wamr_app_lib/tsconfig.json
Normal file
6
assembly-script/wamr_app_lib/tsconfig.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"extends": "../node_modules/assemblyscript/std/assembly.json",
|
||||
"include": [
|
||||
"./**/*.ts"
|
||||
]
|
||||
}
|
|
@ -11,14 +11,23 @@ cwd = GetCurrentDir()
|
|||
objs = []
|
||||
|
||||
WAMR_ROOT_DIR = os.path.join(cwd, "..")
|
||||
|
||||
|
||||
SHARED_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'shared')
|
||||
|
||||
IWASM_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'iwasm')
|
||||
|
||||
APP_MGR_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-mgr')
|
||||
|
||||
APP_FRAMEWORK_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-framework')
|
||||
|
||||
DEPS_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'deps')
|
||||
|
||||
if GetDepend(['WAMR_BUILD_INTERP']):
|
||||
script_path = os.path.join(IWASM_DIR, 'interpreter', 'SConscript')
|
||||
objs += SConscript(script_path)
|
||||
|
||||
|
||||
if GetDepend(['WAMR_BUILD_AOT']):
|
||||
script_path = os.path.join(IWASM_DIR, 'aot', 'SConscript')
|
||||
objs += SConscript(script_path)
|
||||
|
@ -26,31 +35,54 @@ if GetDepend(['WAMR_BUILD_AOT']):
|
|||
script_path = os.path.join(IWASM_DIR, 'compilation', 'SConscript')
|
||||
objs += SConscript(script_path)
|
||||
|
||||
|
||||
if GetDepend(['WAMR_BUILD_APP_FRAMEWORK']):
|
||||
objs += SConscript(os.path.join(APP_FRAMEWORK_DIR, 'SConscript'))
|
||||
objs += SConscript(os.path.join(SHARED_DIR, 'coap', 'SConscript'))
|
||||
objs += SConscript(os.path.join(APP_MGR_DIR, 'app-manager', 'SConscript'))
|
||||
objs += SConscript(os.path.join(APP_MGR_DIR, 'app-mgr-shared', 'SConscript'))
|
||||
|
||||
|
||||
|
||||
if GetDepend(['WAMR_BUILD_LIBC_BUILTIN']):
|
||||
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-builtin', 'SConscript'))
|
||||
|
||||
|
||||
|
||||
if GetDepend(['WAMR_BUILD_LIBC_WASI']):
|
||||
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-wasi', 'SConscript'))
|
||||
objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'common', 'posix', 'SConscript'))
|
||||
objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'common', 'libc-util', 'SConscript'))
|
||||
|
||||
|
||||
if GetDepend(['WAMR_BUILD_LIB_PTHREAD']):
|
||||
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'lib-pthread', 'SConscript'))
|
||||
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-pthread', 'SConscript'))
|
||||
# TODO: 这里加一下
|
||||
|
||||
|
||||
|
||||
# if (WAMR_BUILD_THREAD_MGR EQUAL 1)
|
||||
# include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
|
||||
# endif ()
|
||||
|
||||
if GetDepend(['WAMR_BUILD_THREAD_MGR']):
|
||||
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'thread-mgr', 'SConscript'))
|
||||
|
||||
|
||||
|
||||
# if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
|
||||
# include (${IWASM_DIR}/libraries/libc-emcc/libc_emcc.cmake)
|
||||
# endif()
|
||||
|
||||
if GetDepend(['WAMR_BUILD_LIBC_EMCC']):
|
||||
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-emmc', 'SConscript'))
|
||||
|
||||
if GetDepend(['WAMR_BUILD_LIB_WASI_THREADS']):
|
||||
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'lib-wasi-threads', 'SConscript'))
|
||||
|
||||
objs += SConscript(os.path.join(cwd, 'SConscript_config'));
|
||||
|
||||
|
||||
objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'rt-thread', 'SConscript'))
|
||||
objs += SConscript(os.path.join(SHARED_DIR, 'mem-alloc', 'SConscript'))
|
||||
objs += SConscript(os.path.join(IWASM_DIR, 'common', 'SConscript'))
|
||||
objs += SConscript(os.path.join(SHARED_DIR, 'utils', 'SConscript'))
|
||||
|
||||
|
||||
|
||||
Return('objs')
|
||||
|
|
|
@ -11,12 +11,15 @@ from building import *
|
|||
|
||||
Import('rtconfig')
|
||||
|
||||
src = []
|
||||
src = Split('''
|
||||
''')
|
||||
objs = []
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
IWASM_INC_DIR = os.path.join(cwd, '..', 'core', 'iwasm', 'include')
|
||||
|
||||
# include_directories (${IWASM_DIR}/include)
|
||||
|
||||
CPPPATH = [IWASM_INC_DIR]
|
||||
|
||||
if rtconfig.BUILD == 'debug':
|
||||
|
@ -45,11 +48,12 @@ if rtconfig.ARCH == 'arm':
|
|||
print('[WAMR] using armv4')
|
||||
CPPDEFINES += ['BUILD_TARGET_ARM']
|
||||
CPPDEFINES += ['RTT_WAMR_BUILD_TARGET_ARMV4']
|
||||
elif rtconfig.ARCH == 'ia32':
|
||||
CPPDEFINES += ['BUILD_TARGET_X86_32', 'RTT_WAMR_BUILD_TARGET_X86_32']
|
||||
else:
|
||||
print("[WAMR] unknown arch", rtconfig.ARCH)
|
||||
|
||||
|
||||
LIBS = ['m']
|
||||
|
||||
if GetDepend(['WAMR_BUILD_INTERP']):
|
||||
CPPDEFINES += ['WASM_ENABLE_INTERP=1']
|
||||
if GetDepend(['WAMR_BUILD_FAST_INTERP']):
|
||||
|
@ -92,7 +96,6 @@ else:
|
|||
|
||||
if GetDepend(['WAMR_DISABLE_HW_BOUND_CHECK']):
|
||||
CPPDEFINES += ['WASM_DISABLE_HW_BOUND_CHECK=1']
|
||||
CPPDEFINES += ['WASM_DISABLE_STACK_HW_BOUND_CHECK=1']
|
||||
print("[WAMR] Hardware boundary check disabled")
|
||||
|
||||
if GetDepend(['WAMR_BUILD_SIMD']):
|
||||
|
@ -109,30 +112,10 @@ if GetDepend(['WAMR_BUILD_CUSTOM_NAME_SECTION']):
|
|||
|
||||
if GetDepend(['WAMR_BUILD_TAIL_CALL']):
|
||||
CPPDEFINES += ['WASM_ENABLE_TAIL_CALL=1']
|
||||
print('[WAMR] Tail call enabled')
|
||||
print('[WAMR] Tail call enabledd')
|
||||
|
||||
if GetDepend(['WAMR_BUILD_THREAD_MGR']):
|
||||
CPPDEFINES += ['WASM_ENABLE_THREAD_MGR=1']
|
||||
print('[WAMR] Thread manager enabled')
|
||||
|
||||
if GetDepend(['WAMR_BUILD_LIBC_WASI']):
|
||||
CPPDEFINES += ['WASM_ENABLE_LIBC_WASI=1']
|
||||
CPPDEFINES += ['WASM_ENABLE_MODULE_INST_CONTEXT=1']
|
||||
print('[WAMR] Libc wasi enabled')
|
||||
|
||||
if GetDepend(['WAMR_BUILD_LIB_WASI_THREADS']):
|
||||
CPPDEFINES += ['WASM_ENABLE_LIB_WASI_THREADS=1']
|
||||
print('[WAMR] Lib wasi threads enabled')
|
||||
|
||||
if GetDepend(['WAMR_BUILD_REF_TYPES']):
|
||||
CPPDEFINES += ['WASM_ENABLE_REF_TYPES=1']
|
||||
print('[WAMR] enable ref types')
|
||||
|
||||
CPPDEFINES += ['BH_MALLOC=wasm_runtime_malloc']
|
||||
CPPDEFINES += ['BH_FREE=wasm_runtime_free']
|
||||
|
||||
LIBS = ['m']
|
||||
|
||||
group = DefineGroup('wamr', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
|
||||
group = DefineGroup('wamr_config_common', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
|
||||
|
||||
Return('group')
|
||||
|
||||
|
|
|
@ -1,353 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import pathlib
|
||||
import requests
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import sysconfig
|
||||
import sys
|
||||
|
||||
|
||||
def clone_llvm(dst_dir, llvm_repo, llvm_branch):
|
||||
"""
|
||||
any error will raise CallProcessError
|
||||
"""
|
||||
llvm_dir = dst_dir.joinpath("llvm").resolve()
|
||||
|
||||
if not llvm_dir.exists():
|
||||
GIT_CLONE_CMD = f"git clone --depth 1 --branch {llvm_branch} {llvm_repo} llvm"
|
||||
print(GIT_CLONE_CMD)
|
||||
subprocess.check_output(shlex.split(GIT_CLONE_CMD), cwd=dst_dir)
|
||||
|
||||
return llvm_dir
|
||||
|
||||
|
||||
def query_llvm_version(llvm_info):
|
||||
github_token = os.environ['GH_TOKEN']
|
||||
owner_project = llvm_info['repo'].replace("https://github.com/", "").replace(".git", "")
|
||||
url = f"https://api.github.com/repos/{owner_project}/commits/{llvm_info['branch']}"
|
||||
headers = {
|
||||
'Authorization': f"Bearer {github_token}"
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.request("GET", url, headers=headers, data={})
|
||||
response.raise_for_status()
|
||||
except requests.exceptions.HTTPError as error:
|
||||
print (error) # for debugging purpose
|
||||
return None
|
||||
|
||||
response = response.json()
|
||||
return response['sha']
|
||||
|
||||
|
||||
def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_flags=''):
|
||||
LLVM_COMPILE_OPTIONS = [
|
||||
'-DCMAKE_BUILD_TYPE:STRING="Release"',
|
||||
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
|
||||
"-DLLVM_APPEND_VC_REV:BOOL=ON",
|
||||
"-DLLVM_BUILD_EXAMPLES:BOOL=OFF",
|
||||
"-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF",
|
||||
"-DLLVM_ENABLE_BINDINGS:BOOL=OFF",
|
||||
"-DLLVM_ENABLE_IDE:BOOL=OFF",
|
||||
"-DLLVM_ENABLE_LIBEDIT=OFF",
|
||||
"-DLLVM_ENABLE_TERMINFO:BOOL=OFF",
|
||||
"-DLLVM_ENABLE_ZLIB:BOOL=ON",
|
||||
"-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF",
|
||||
"-DLLVM_INCLUDE_DOCS:BOOL=OFF",
|
||||
"-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF",
|
||||
"-DLLVM_INCLUDE_UTILS:BOOL=OFF",
|
||||
"-DLLVM_INCLUDE_TESTS:BOOL=OFF",
|
||||
"-DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON",
|
||||
]
|
||||
|
||||
# ccache is not available on Windows
|
||||
if not "windows" == platform:
|
||||
LLVM_COMPILE_OPTIONS.append("-DLLVM_CCACHE_BUILD:BOOL=ON")
|
||||
# perf support is available on Linux only
|
||||
if "linux" == platform:
|
||||
LLVM_COMPILE_OPTIONS.append("-DLLVM_USE_PERF:BOOL=ON")
|
||||
|
||||
# use clang/clang++/lld. but macos doesn't support lld
|
||||
if not sys.platform.startswith("darwin") and use_clang:
|
||||
if shutil.which("clang") and shutil.which("clang++") and shutil.which("lld"):
|
||||
os.environ["CC"] = "clang"
|
||||
os.environ["CXX"] = "clang++"
|
||||
LLVM_COMPILE_OPTIONS.append('-DLLVM_USE_LINKER:STRING="lld"')
|
||||
print("Use the clang toolchain")
|
||||
else:
|
||||
print("Can not find clang, clang++ and lld, keep using the gcc toolchain")
|
||||
else:
|
||||
print("Use the gcc toolchain")
|
||||
|
||||
LLVM_EXTRA_COMPILE_OPTIONS = {
|
||||
"arc": [
|
||||
'-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD:STRING="ARC"',
|
||||
"-DLLVM_ENABLE_LIBICUUC:BOOL=OFF",
|
||||
"-DLLVM_ENABLE_LIBICUDATA:BOOL=OFF",
|
||||
],
|
||||
"xtensa": [
|
||||
'-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD:STRING="Xtensa"',
|
||||
],
|
||||
"windows": [
|
||||
"-DCMAKE_INSTALL_PREFIX=LLVM-install",
|
||||
],
|
||||
"default": [],
|
||||
}
|
||||
|
||||
experimental_backends = ["ARC", "Xtensa"]
|
||||
normal_backends = [s for s in backends if s not in experimental_backends]
|
||||
|
||||
LLVM_TARGETS_TO_BUILD = [
|
||||
'-DLLVM_TARGETS_TO_BUILD:STRING="' + ";".join(normal_backends) + '"'
|
||||
if normal_backends
|
||||
else '-DLLVM_TARGETS_TO_BUILD:STRING="AArch64;ARM;Mips;RISCV;X86"'
|
||||
]
|
||||
|
||||
# if not on ARC platform, but want to add expeirmental backend ARC as target
|
||||
if platform != "ARC" and "ARC" in backends:
|
||||
LLVM_TARGETS_TO_BUILD.extend(
|
||||
LLVM_EXTRA_COMPILE_OPTIONS["arc"]
|
||||
)
|
||||
|
||||
LLVM_PROJECTS_TO_BUILD = [
|
||||
'-DLLVM_ENABLE_PROJECTS:STRING="' + ";".join(projects) + '"' if projects else ""
|
||||
]
|
||||
|
||||
# lldb project requires libxml2
|
||||
LLVM_LIBXML2_OPTION = [
|
||||
"-DLLVM_ENABLE_LIBXML2:BOOL=" + ("ON" if "lldb" in projects else "OFF")
|
||||
]
|
||||
|
||||
# enabling LLVM_INCLUDE_TOOLS will increase ~300M to the final package
|
||||
LLVM_INCLUDE_TOOLS_OPTION = [
|
||||
"-DLLVM_INCLUDE_TOOLS:BOOL=ON" if projects else "-DLLVM_INCLUDE_TOOLS:BOOL=OFF"
|
||||
]
|
||||
|
||||
if not llvm_dir.exists():
|
||||
raise Exception(f"{llvm_dir} doesn't exist")
|
||||
|
||||
build_dir = llvm_dir.joinpath("build").resolve()
|
||||
build_dir.mkdir(exist_ok=True)
|
||||
|
||||
lib_llvm_core_library = build_dir.joinpath("lib/libLLVMCore.a").resolve()
|
||||
if lib_llvm_core_library.exists():
|
||||
print(
|
||||
f"It has already been fully compiled. If want to a re-build, please remove {build_dir} manually and try again"
|
||||
)
|
||||
return None
|
||||
|
||||
compile_options = " ".join(
|
||||
LLVM_COMPILE_OPTIONS
|
||||
+ LLVM_LIBXML2_OPTION
|
||||
+ LLVM_EXTRA_COMPILE_OPTIONS.get(
|
||||
platform, LLVM_EXTRA_COMPILE_OPTIONS["default"]
|
||||
)
|
||||
+ LLVM_TARGETS_TO_BUILD
|
||||
+ LLVM_PROJECTS_TO_BUILD
|
||||
+ LLVM_INCLUDE_TOOLS_OPTION
|
||||
)
|
||||
|
||||
CONFIG_CMD = f"cmake {compile_options} {extra_flags} ../llvm"
|
||||
if "windows" == platform:
|
||||
if "mingw" in sysconfig.get_platform().lower():
|
||||
CONFIG_CMD += " -G'Unix Makefiles'"
|
||||
else:
|
||||
CONFIG_CMD += " -A x64"
|
||||
else:
|
||||
CONFIG_CMD += " -G'Ninja'"
|
||||
print(f"Config command: {CONFIG_CMD}")
|
||||
subprocess.check_call(shlex.split(CONFIG_CMD), cwd=build_dir)
|
||||
|
||||
BUILD_CMD = "cmake --build . --target package" + (
|
||||
" --config Release" if "windows" == platform else ""
|
||||
)
|
||||
if "windows" == platform:
|
||||
BUILD_CMD += " --parallel " + str(os.cpu_count())
|
||||
print(f"Build command: {BUILD_CMD}")
|
||||
subprocess.check_call(shlex.split(BUILD_CMD), cwd=build_dir)
|
||||
|
||||
return build_dir
|
||||
|
||||
|
||||
def repackage_llvm(llvm_dir):
|
||||
build_dir = llvm_dir.joinpath("./build").resolve()
|
||||
|
||||
packs = [f for f in build_dir.glob("LLVM-*.tar.gz")]
|
||||
if len(packs) > 1:
|
||||
raise Exception("Find more than one LLVM-*.tar.gz")
|
||||
|
||||
if not packs:
|
||||
raise Exception("Didn't find any LLVM-* package")
|
||||
return
|
||||
|
||||
llvm_package = packs[0].name
|
||||
# mv build/LLVM-*.gz .
|
||||
shutil.move(str(build_dir.joinpath(llvm_package).resolve()), str(llvm_dir))
|
||||
# rm -r build
|
||||
shutil.rmtree(str(build_dir))
|
||||
# mkdir build
|
||||
build_dir.mkdir()
|
||||
# tar xf ./LLVM-*.tar.gz --strip-components=1 --directory=build
|
||||
CMD = f"tar xf {llvm_dir.joinpath(llvm_package).resolve()} --strip-components=1 --directory={build_dir}"
|
||||
subprocess.check_call(shlex.split(CMD), cwd=llvm_dir)
|
||||
# rm ./LLVM-1*.gz
|
||||
os.remove(llvm_dir.joinpath(llvm_package).resolve())
|
||||
|
||||
def repackage_llvm_windows(llvm_dir):
|
||||
build_dir = llvm_dir.joinpath("./build").resolve()
|
||||
|
||||
packs_path = [f for f in build_dir.glob("./_CPack_Packages/win64/NSIS/LLVM-*-win64")]
|
||||
if len(packs_path) > 1:
|
||||
raise Exception("Find more than one LLVM-* package")
|
||||
|
||||
if not packs_path:
|
||||
raise Exception("Didn't find any LLVM-* package")
|
||||
return
|
||||
|
||||
llvm_package_path = f"_CPack_Packages/win64/NSIS/{packs_path[0].name}"
|
||||
windows_package_dir = build_dir.joinpath(llvm_package_path).resolve()
|
||||
|
||||
# mv package dir outside of build
|
||||
shutil.move(str(windows_package_dir), str(llvm_dir))
|
||||
# rm -r build
|
||||
shutil.rmtree(str(build_dir))
|
||||
# mkdir build
|
||||
build_dir.mkdir()
|
||||
# move back all the subdiretories under cpack directory(bin/include/lib) to build dir
|
||||
moved_package_dir = llvm_dir.joinpath(packs_path[0].name)
|
||||
for sub_dir in moved_package_dir.iterdir():
|
||||
shutil.move(str(sub_dir), str(build_dir))
|
||||
moved_package_dir.rmdir()
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="build necessary LLVM libraries")
|
||||
parser.add_argument(
|
||||
"--platform",
|
||||
type=str,
|
||||
choices=["android", "arc", "darwin", "linux", "windows", "xtensa"],
|
||||
help="identify current platform",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--arch",
|
||||
nargs="+",
|
||||
type=str,
|
||||
choices=[
|
||||
"AArch64",
|
||||
"ARC",
|
||||
"ARM",
|
||||
"Mips",
|
||||
"RISCV",
|
||||
"WebAssembly",
|
||||
"X86",
|
||||
"Xtensa",
|
||||
],
|
||||
default=[],
|
||||
help="identify LLVM supported backends, separate by space, like '--arch ARM Mips X86'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--project",
|
||||
nargs="+",
|
||||
type=str,
|
||||
default="",
|
||||
choices=["clang", "lldb"],
|
||||
help="identify extra LLVM projects, separate by space, like '--project clang lldb'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--llvm-ver",
|
||||
action="store_true",
|
||||
help="return the version info of generated llvm libraries",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--use-clang",
|
||||
action="store_true",
|
||||
help="use clang instead of gcc",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--extra-cmake-flags",
|
||||
type=str,
|
||||
default="",
|
||||
help="custom extra cmake flags",
|
||||
)
|
||||
options = parser.parse_args()
|
||||
|
||||
# if the "platform" is not identified in the command line option,
|
||||
# detect it
|
||||
if not options.platform:
|
||||
if sys.platform.startswith("win32") or sys.platform.startswith("msys"):
|
||||
platform = "windows"
|
||||
elif sys.platform.startswith("darwin"):
|
||||
platform = "darwin"
|
||||
else:
|
||||
platform = "linux"
|
||||
else:
|
||||
platform = options.platform
|
||||
|
||||
llvm_repo_and_branch = {
|
||||
"arc": {
|
||||
"repo": "https://github.com/llvm/llvm-project.git",
|
||||
"repo_ssh": "git@github.com:llvm/llvm-project.git",
|
||||
"branch": "release/18.x",
|
||||
},
|
||||
"xtensa": {
|
||||
"repo": "https://github.com/espressif/llvm-project.git",
|
||||
"repo_ssh": "git@github.com:espressif/llvm-project.git",
|
||||
"branch": "xtensa_release_18.1.2",
|
||||
},
|
||||
"default": {
|
||||
"repo": "https://github.com/llvm/llvm-project.git",
|
||||
"repo_ssh": "git@github.com:llvm/llvm-project.git",
|
||||
"branch": "release/18.x",
|
||||
},
|
||||
}
|
||||
|
||||
# retrieve the real file
|
||||
current_file = pathlib.Path(__file__)
|
||||
if current_file.is_symlink():
|
||||
current_file = pathlib.Path(os.readlink(current_file))
|
||||
|
||||
current_dir = current_file.parent.resolve()
|
||||
deps_dir = current_dir.joinpath("../core/deps").resolve()
|
||||
|
||||
try:
|
||||
llvm_info = llvm_repo_and_branch.get(platform, llvm_repo_and_branch["default"])
|
||||
|
||||
if options.llvm_ver:
|
||||
commit_hash = query_llvm_version(llvm_info)
|
||||
print(commit_hash)
|
||||
return commit_hash is not None
|
||||
|
||||
repo_addr = llvm_info["repo"]
|
||||
if os.environ.get('USE_GIT_SSH') == "true":
|
||||
repo_addr = llvm_info["repo_ssh"]
|
||||
else:
|
||||
print("To use ssh for git clone, run: export USE_GIT_SSH=true")
|
||||
|
||||
llvm_dir = clone_llvm(deps_dir, repo_addr, llvm_info["branch"])
|
||||
if (
|
||||
build_llvm(
|
||||
llvm_dir, platform, options.arch, options.project, options.use_clang,
|
||||
options.extra_cmake_flags
|
||||
)
|
||||
is not None
|
||||
):
|
||||
# TODO: repackage process may change in the future, this work for LLVM 15.x
|
||||
if "windows" == platform:
|
||||
repackage_llvm_windows(llvm_dir)
|
||||
else:
|
||||
repackage_llvm(llvm_dir)
|
||||
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(0 if main() else 1)
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
string(TOUPPER ${WAMR_BUILD_TARGET} WAMR_BUILD_TARGET)
|
||||
|
||||
|
||||
# Add definitions for the build target
|
||||
if (WAMR_BUILD_TARGET STREQUAL "X86_64")
|
||||
add_definitions(-DBUILD_TARGET_X86_64)
|
||||
|
@ -39,12 +40,8 @@ elseif (WAMR_BUILD_TARGET STREQUAL "RISCV64_LP64")
|
|||
add_definitions(-DBUILD_TARGET_RISCV64_LP64)
|
||||
elseif (WAMR_BUILD_TARGET STREQUAL "RISCV32" OR WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32D")
|
||||
add_definitions(-DBUILD_TARGET_RISCV32_ILP32D)
|
||||
elseif (WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32F")
|
||||
add_definitions(-DBUILD_TARGET_RISCV32_ILP32F)
|
||||
elseif (WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32")
|
||||
add_definitions(-DBUILD_TARGET_RISCV32_ILP32)
|
||||
elseif (WAMR_BUILD_TARGET STREQUAL "ARC")
|
||||
add_definitions(-DBUILD_TARGET_ARC)
|
||||
else ()
|
||||
message (FATAL_ERROR "-- WAMR build target isn't set")
|
||||
endif ()
|
||||
|
@ -59,20 +56,14 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|||
if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
# Add -fPIC flag if build as 64-bit
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -fPIC")
|
||||
endif ()
|
||||
else ()
|
||||
include(CheckCCompilerFlag)
|
||||
Check_C_Compiler_Flag(-m32 M32_OK)
|
||||
if (M32_OK OR WAMR_BUILD_TARGET STREQUAL "X86_32")
|
||||
add_definitions (-m32)
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_TARGET MATCHES "ARM.*")
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm")
|
||||
|
@ -87,231 +78,70 @@ if (NOT WAMR_BUILD_AOT EQUAL 1)
|
|||
endif ()
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_FAST_JIT EQUAL 1)
|
||||
if (NOT WAMR_BUILD_LAZY_JIT EQUAL 0)
|
||||
# Enable Lazy JIT by default
|
||||
set (WAMR_BUILD_LAZY_JIT 1)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_JIT EQUAL 1)
|
||||
if (NOT WAMR_BUILD_LAZY_JIT EQUAL 0)
|
||||
# Enable Lazy JIT by default
|
||||
set (WAMR_BUILD_LAZY_JIT 1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_AOT EQUAL 1)
|
||||
add_definitions("-DWASM_ENABLE_JIT=1")
|
||||
if (NOT DEFINED LLVM_DIR)
|
||||
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
|
||||
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/build")
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/win32build")
|
||||
endif ()
|
||||
if (NOT EXISTS "${LLVM_BUILD_ROOT}")
|
||||
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_BUILD_ROOT}")
|
||||
endif ()
|
||||
set (CMAKE_PREFIX_PATH "${LLVM_BUILD_ROOT};${CMAKE_PREFIX_PATH}")
|
||||
set (LLVM_DIR ${LLVM_BUILD_ROOT}/lib/cmake/llvm)
|
||||
endif ()
|
||||
find_package(LLVM REQUIRED CONFIG)
|
||||
include_directories(${LLVM_INCLUDE_DIRS})
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
||||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
||||
|
||||
# Disable -Wredundant-move when building LLVM JIT
|
||||
include(CheckCXXCompilerFlag)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
check_cxx_compiler_flag("-Wredundant-move" CXX_SUPPORTS_REDUNDANT_MOVE_FLAG)
|
||||
if (CXX_SUPPORTS_REDUNDANT_MOVE_FLAG)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-redundant-move")
|
||||
endif ()
|
||||
# Enable exporting symbols after llvm-17, or LLVM JIT may run failed
|
||||
# with `llvm_orc_registerEHFrameSectionWrapper` symbol not found error
|
||||
if (${LLVM_PACKAGE_VERSION} VERSION_GREATER_EQUAL "17.0.0")
|
||||
set (CMAKE_ENABLE_EXPORTS 1)
|
||||
endif ()
|
||||
else ()
|
||||
set (WAMR_BUILD_JIT 0)
|
||||
message ("-- WAMR JIT disabled due to WAMR AOT is disabled")
|
||||
endif ()
|
||||
else ()
|
||||
unset (LLVM_AVAILABLE_LIBS)
|
||||
endif ()
|
||||
|
||||
# Version
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/version.cmake)
|
||||
|
||||
# Package
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/package.cmake)
|
||||
|
||||
# Sanitizers
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_SANITIZER)
|
||||
set(WAMR_BUILD_SANITIZER $ENV{WAMR_BUILD_SANITIZER})
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_SANITIZER)
|
||||
set(WAMR_BUILD_SANITIZER "")
|
||||
elseif (WAMR_BUILD_SANITIZER STREQUAL "ubsan")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=alignment" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
|
||||
elseif (WAMR_BUILD_SANITIZER STREQUAL "asan")
|
||||
if (NOT WAMR_BUILD_JIT EQUAL 1)
|
||||
set (ASAN_OPTIONS "verbosity=2 debug=true ")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=address -fno-sanitize-recover=all" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
||||
endif()
|
||||
elseif (WAMR_BUILD_SANITIZER STREQUAL "tsan")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
|
||||
elseif (WAMR_BUILD_SANITIZER STREQUAL "posan")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=pointer-overflow -fno-sanitize-recover=all" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=pointer-overflow")
|
||||
elseif (NOT (WAMR_BUILD_SANITIZER STREQUAL "") )
|
||||
message(SEND_ERROR "Unsupported sanitizer: ${WAMR_BUILD_SANITIZER}")
|
||||
endif()
|
||||
|
||||
if (WAMR_BUILD_LINUX_PERF EQUAL 1)
|
||||
if (NOT WAMR_BUILD_JIT AND NOT WAMR_BUILD_AOT)
|
||||
message(WARNING "only support perf in aot and llvm-jit")
|
||||
set(WAMR_BUILD_LINUX_PERF 0)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY)
|
||||
# Enable shrunk memory by default
|
||||
set (WAMR_BUILD_SHRUNK_MEMORY 1)
|
||||
endif ()
|
||||
|
||||
########################################
|
||||
# Default values
|
||||
########################################
|
||||
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
|
||||
set (WAMR_BUILD_BULK_MEMORY 1)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
|
||||
set (WAMR_BUILD_EXCE_HANDLING 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_GC)
|
||||
set (WAMR_BUILD_GC 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MEMORY64)
|
||||
set (WAMR_BUILD_MEMORY64 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MULTI_MEMORY)
|
||||
set (WAMR_BUILD_MULTI_MEMORY 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_SHARED_MEMORY)
|
||||
set(WAMR_BUILD_SHARED_MEMORY 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_STRINGREF)
|
||||
set(WAMR_BUILD_STRINGREF 0)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_TAIL_CALL)
|
||||
set (WAMR_BUILD_TAIL_CALL 0)
|
||||
endif ()
|
||||
|
||||
########################################
|
||||
# Compilation options to marco
|
||||
########################################
|
||||
|
||||
message ("-- Build Configurations:")
|
||||
message (" Build as target ${WAMR_BUILD_TARGET}")
|
||||
message (" Build for platform ${WAMR_BUILD_PLATFORM}")
|
||||
message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
||||
message (" BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
|
||||
################## running mode ##################
|
||||
if (WAMR_BUILD_INTERP EQUAL 1)
|
||||
message (" WAMR Interpreter enabled")
|
||||
else ()
|
||||
message (" WAMR Interpreter disabled")
|
||||
endif ()
|
||||
if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1))
|
||||
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
|
||||
message (" Fast interpreter enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
|
||||
message (" Fast interpreter disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_AOT EQUAL 1)
|
||||
message (" WAMR AOT enabled")
|
||||
else ()
|
||||
message (" WAMR AOT disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_FAST_JIT EQUAL 1)
|
||||
if (WAMR_BUILD_LAZY_JIT EQUAL 1)
|
||||
add_definitions("-DWASM_ENABLE_LAZY_JIT=1")
|
||||
message (" WAMR Fast JIT enabled with Lazy Compilation")
|
||||
else ()
|
||||
message (" WAMR Fast JIT enabled with Eager Compilation")
|
||||
endif ()
|
||||
else ()
|
||||
message (" WAMR Fast JIT disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_JIT EQUAL 1)
|
||||
add_definitions("-DWASM_ENABLE_JIT=1")
|
||||
if (WAMR_BUILD_LAZY_JIT EQUAL 1)
|
||||
add_definitions("-DWASM_ENABLE_LAZY_JIT=1")
|
||||
message (" WAMR LLVM ORC JIT enabled with Lazy Compilation")
|
||||
message (" WAMR JIT enabled")
|
||||
else ()
|
||||
message (" WAMR LLVM ORC JIT enabled with Eager Compilation")
|
||||
message (" WAMR JIT disabled")
|
||||
endif ()
|
||||
else ()
|
||||
message (" WAMR LLVM ORC JIT disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_FAST_JIT EQUAL 1 AND WAMR_BUILD_JIT EQUAL 1
|
||||
AND WAMR_BUILD_LAZY_JIT EQUAL 1)
|
||||
message (" Multi-tier JIT enabled")
|
||||
endif ()
|
||||
################## test modes ##################
|
||||
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
|
||||
message (" spec test compatible mode is on")
|
||||
endif ()
|
||||
if (WAMR_BUILD_WASI_TEST EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_WASI_TEST=1)
|
||||
message (" wasi test compatible mode is on")
|
||||
endif ()
|
||||
################## native ##################
|
||||
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
|
||||
message (" Libc builtin enabled")
|
||||
else ()
|
||||
message (" Libc builtin disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
|
||||
message (" Libc WASI enabled with uvwasi implementation\n"
|
||||
" WANRING:: uvwasi does not currently provide the comprehensive\n"
|
||||
" file system security properties provided by some WASI runtimes.\n"
|
||||
" Full support for secure file system sandboxing may or may not\n"
|
||||
" be implemented in future. In the mean time, DO NOT RELY ON IT\n"
|
||||
" TO RUN UNTRUSTED CODE.")
|
||||
message (" Libc WASI enabled with uvwasi implementation")
|
||||
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
|
||||
message (" Libc WASI enabled")
|
||||
else ()
|
||||
message (" Libc WASI disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
|
||||
message (" Thread manager enabled")
|
||||
if (WAMR_BUILD_FAST_INTERP EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
|
||||
message (" Fast interpreter enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
|
||||
message (" Fast interpreter disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
|
||||
message (" Lib pthread enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
|
||||
message (" Lib pthread semaphore enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
|
||||
message (" Lib wasi-threads enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
|
||||
message (" Libc emcc enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LIB_RATS EQUAL 1)
|
||||
message (" Lib rats enabled")
|
||||
endif()
|
||||
if ((WAMR_BUILD_LIB_SIMDE EQUAL 1))
|
||||
message (" Lib simde enabled")
|
||||
endif()
|
||||
################## WAMR features ##################
|
||||
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
|
||||
message (" Multiple modules enabled")
|
||||
|
@ -319,8 +149,13 @@ else ()
|
|||
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
|
||||
message (" Multiple modules disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
|
||||
message (" spec test compatible mode is on")
|
||||
endif ()
|
||||
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
|
||||
message (" Bulk memory feature enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
|
||||
endif ()
|
||||
|
@ -330,30 +165,14 @@ if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
|
|||
else ()
|
||||
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
|
||||
endif ()
|
||||
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
|
||||
message (" Shared heap enabled")
|
||||
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
|
||||
message (" Thread manager enabled")
|
||||
endif ()
|
||||
|
||||
if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1)
|
||||
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1)
|
||||
message(" Copy callstack enabled")
|
||||
else ()
|
||||
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=0)
|
||||
message(" Copy callstack disabled")
|
||||
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
|
||||
message (" Lib pthread enabled")
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_MEMORY64 EQUAL 1)
|
||||
# if native is 32-bit or cross-compiled to 32-bit
|
||||
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
|
||||
message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target")
|
||||
endif()
|
||||
add_definitions (-DWASM_ENABLE_MEMORY64=1)
|
||||
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
|
||||
set (WAMR_BUILD_DEBUG_INTERP 0)
|
||||
if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
|
||||
message (" Libc emcc enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_MINI_LOADER EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MINI_LOADER=1)
|
||||
|
@ -363,37 +182,17 @@ else ()
|
|||
endif ()
|
||||
if (WAMR_DISABLE_HW_BOUND_CHECK EQUAL 1)
|
||||
add_definitions (-DWASM_DISABLE_HW_BOUND_CHECK=1)
|
||||
add_definitions (-DWASM_DISABLE_STACK_HW_BOUND_CHECK=1)
|
||||
message (" Hardware boundary check disabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_DISABLE_HW_BOUND_CHECK=0)
|
||||
if (WAMR_DISABLE_STACK_HW_BOUND_CHECK EQUAL 1)
|
||||
add_definitions (-DWASM_DISABLE_STACK_HW_BOUND_CHECK=1)
|
||||
message (" Hardware boundary check for native stack disabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_DISABLE_STACK_HW_BOUND_CHECK=0)
|
||||
endif ()
|
||||
endif ()
|
||||
if (WAMR_DISABLE_WAKEUP_BLOCKING_OP EQUAL 1)
|
||||
add_definitions (-DWASM_DISABLE_WAKEUP_BLOCKING_OP=1)
|
||||
message (" Wakeup of blocking operations disabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_DISABLE_WAKEUP_BLOCKING_OP=0)
|
||||
message (" Wakeup of blocking operations enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_SIMD EQUAL 1)
|
||||
if (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
|
||||
set(SIMD_ENABLED 0)
|
||||
message (" SIMD disabled due to not supported on target RISCV64")
|
||||
else()
|
||||
set(SIMD_ENABLED 1)
|
||||
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
|
||||
add_definitions (-DWASM_ENABLE_SIMD=1)
|
||||
message (" SIMD enabled")
|
||||
else ()
|
||||
message (" SIMD disabled due to not supported on target RISCV64")
|
||||
endif ()
|
||||
add_definitions(-DWASM_ENABLE_SIMD=${SIMD_ENABLED})
|
||||
endif ()
|
||||
if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
|
||||
message (" AOT stack frame enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_MEMORY_PROFILING EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MEMORY_PROFILING=1)
|
||||
|
@ -416,295 +215,17 @@ if (WAMR_BUILD_DUMP_CALL_STACK EQUAL 1)
|
|||
endif ()
|
||||
if (WAMR_BUILD_TAIL_CALL EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_TAIL_CALL=1)
|
||||
message (" Tail call enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_REF_TYPES EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_REF_TYPES=1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_GC EQUAL 1)
|
||||
if (WAMR_TEST_GC EQUAL 1)
|
||||
message(" GC testing enabled")
|
||||
endif()
|
||||
endif ()
|
||||
if (WAMR_BUILD_GC EQUAL 1 AND WAMR_BUILD_GC_PERF_PROFILING EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_GC_PERF_PROFILING=1)
|
||||
message (" GC performance profiling enabled")
|
||||
message (" Reference types enabled")
|
||||
else ()
|
||||
message (" GC performance profiling disabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_STRINGREF EQUAL 1)
|
||||
if (NOT DEFINED WAMR_STRINGREF_IMPL_SOURCE)
|
||||
message (" Using WAMR builtin implementation for stringref")
|
||||
else ()
|
||||
message (" Using custom implementation for stringref")
|
||||
endif()
|
||||
endif ()
|
||||
if (WAMR_BUILD_PERF_PROFILING EQUAL 1 OR
|
||||
WAMR_BUILD_DUMP_CALL_STACK EQUAL 1 OR
|
||||
WAMR_BUILD_GC EQUAL 1)
|
||||
# Enable AOT/JIT stack frame when perf-profiling, dump-call-stack
|
||||
# or GC is enabled
|
||||
if (WAMR_BUILD_AOT EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
|
||||
endif ()
|
||||
endif ()
|
||||
if (WAMR_BUILD_EXCE_HANDLING EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_EXCE_HANDLING=1)
|
||||
add_definitions (-DWASM_ENABLE_TAGS=1)
|
||||
message (" Exception Handling enabled")
|
||||
message (" Reference types disabled")
|
||||
endif ()
|
||||
if (DEFINED WAMR_BH_VPRINTF)
|
||||
add_definitions (-DBH_VPRINTF=${WAMR_BH_VPRINTF})
|
||||
endif ()
|
||||
if (DEFINED WAMR_BH_LOG)
|
||||
add_definitions (-DBH_LOG=${WAMR_BH_LOG})
|
||||
endif ()
|
||||
if (WAMR_DISABLE_APP_ENTRY EQUAL 1)
|
||||
message (" WAMR application entry functions excluded")
|
||||
endif ()
|
||||
if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
|
||||
message (" Debug Interpreter enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
|
||||
message (" Debug AOT enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_DYNAMIC_AOT_DEBUG EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_DYNAMIC_AOT_DEBUG=1)
|
||||
message (" Dynamic AOT debug enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LOAD_CUSTOM_SECTION EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_LOAD_CUSTOM_SECTION=1)
|
||||
message (" Load custom section enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_GLOBAL_HEAP_POOL EQUAL 1)
|
||||
add_definitions(-DWASM_ENABLE_GLOBAL_HEAP_POOL=1)
|
||||
message (" Global heap pool enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_GLOBAL_HEAP_SIZE GREATER 0)
|
||||
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
|
||||
message (" Custom global heap size: " ${WAMR_BUILD_GLOBAL_HEAP_SIZE})
|
||||
else ()
|
||||
# Spec test requires more heap pool size
|
||||
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "linux-sgx")
|
||||
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "100 * 1024 * 1024")
|
||||
else ()
|
||||
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "300 * 1024 * 1024")
|
||||
endif ()
|
||||
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
|
||||
else ()
|
||||
# By default, the global heap size is of 10 MB
|
||||
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "10 * 1024 * 1024")
|
||||
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
|
||||
endif ()
|
||||
endif ()
|
||||
if (WAMR_BUILD_STACK_GUARD_SIZE GREATER 0)
|
||||
add_definitions (-DWASM_STACK_GUARD_SIZE=${WAMR_BUILD_STACK_GUARD_SIZE})
|
||||
message (" Custom stack guard size: " ${WAMR_BUILD_STACK_GUARD_SIZE})
|
||||
endif ()
|
||||
if (WAMR_BUILD_SGX_IPFS EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SGX_IPFS=1)
|
||||
message (" SGX IPFS enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_WASI_NN EQUAL 1)
|
||||
message (" WASI-NN enabled")
|
||||
add_definitions (-DWASM_ENABLE_WASI_NN=1)
|
||||
# Variant backends
|
||||
if (NOT WAMR_BUILD_WASI_NN_TFLITE EQUAL 1 AND
|
||||
NOT WAMR_BUILD_WASI_NN_OPENVINO EQUAL 1 AND
|
||||
NOT WAMR_BUILD_WASI_NN_LLAMACPP EQUAL 1)
|
||||
message (FATAL_ERROR " Need to select a backend for WASI-NN")
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_WASI_NN_TFLITE EQUAL 1)
|
||||
message (" WASI-NN: backend tflite enabled")
|
||||
add_definitions (-DWASM_ENABLE_WASI_NN_TFLITE)
|
||||
endif ()
|
||||
if (WAMR_BUILD_WASI_NN_OPENVINO EQUAL 1)
|
||||
message (" WASI-NN: backend openvino enabled")
|
||||
add_definitions (-DWASM_ENABLE_WASI_NN_OPENVINO)
|
||||
endif ()
|
||||
if (WAMR_BUILD_WASI_NN_LLAMACPP EQUAL 1)
|
||||
message (" WASI-NN: backend llamacpp enabled")
|
||||
add_definitions (-DWASM_ENABLE_WASI_NN_LLAMACPP)
|
||||
endif ()
|
||||
# Variant devices
|
||||
if (WAMR_BUILD_WASI_NN_ENABLE_GPU EQUAL 1)
|
||||
message (" WASI-NN: GPU enabled")
|
||||
add_definitions (-DWASM_ENABLE_WASI_NN_GPU=1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_WASI_NN_ENABLE_EXTERNAL_DELEGATE EQUAL 1)
|
||||
message (" WASI-NN: External Delegation enabled")
|
||||
add_definitions (-DWASM_ENABLE_WASI_NN_EXTERNAL_DELEGATE=1)
|
||||
endif ()
|
||||
if (DEFINED WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH)
|
||||
add_definitions (-DWASM_WASI_NN_EXTERNAL_DELEGATE_PATH="${WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH}")
|
||||
endif ()
|
||||
if (WAMR_BUILD_WASI_EPHEMERAL_NN EQUAL 1)
|
||||
message (" WASI-NN: use 'wasi_ephemeral_nn' instead of 'wasi-nn'")
|
||||
add_definitions (-DWASM_ENABLE_WASI_EPHEMERAL_NN=1)
|
||||
endif()
|
||||
endif ()
|
||||
if (WAMR_BUILD_ALLOC_WITH_USER_DATA EQUAL 1)
|
||||
add_definitions(-DWASM_MEM_ALLOC_WITH_USER_DATA=1)
|
||||
endif()
|
||||
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_WASM_CACHE=1)
|
||||
message (" Wasm files cache enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_MODULE_INST_CONTEXT EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_MODULE_INST_CONTEXT=1)
|
||||
message (" Module instance context enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_GC_HEAP_VERIFY EQUAL 1)
|
||||
add_definitions (-DBH_ENABLE_GC_VERIFY=1)
|
||||
message (" GC heap verification enabled")
|
||||
endif ()
|
||||
if ("$ENV{COLLECT_CODE_COVERAGE}" STREQUAL "1" OR COLLECT_CODE_COVERAGE EQUAL 1)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
add_definitions (-DCOLLECT_CODE_COVERAGE)
|
||||
message (" Collect code coverage enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_STATIC_PGO EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_STATIC_PGO=1)
|
||||
message (" AOT static PGO enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_TARGET STREQUAL "X86_64"
|
||||
AND WAMR_BUILD_PLATFORM STREQUAL "linux")
|
||||
if (WAMR_DISABLE_WRITE_GS_BASE EQUAL 1)
|
||||
# disabled by user
|
||||
set (DISABLE_WRITE_GS_BASE 1)
|
||||
elseif (WAMR_DISABLE_WRITE_GS_BASE EQUAL 0)
|
||||
# enabled by user
|
||||
set (DISABLE_WRITE_GS_BASE 0)
|
||||
elseif (CMAKE_CROSSCOMPILING)
|
||||
# disabled in cross compilation environment
|
||||
set (DISABLE_WRITE_GS_BASE 1)
|
||||
else ()
|
||||
# auto-detected by the compiler
|
||||
set (TEST_WRGSBASE_SOURCE "${CMAKE_BINARY_DIR}/test_wrgsbase.c")
|
||||
file (WRITE "${TEST_WRGSBASE_SOURCE}" "
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
int main() {
|
||||
uint64_t value;
|
||||
asm volatile (\"wrgsbase %0\" : : \"r\"(value));
|
||||
printf(\"WRGSBASE instruction is available.\\n\");
|
||||
return 0;
|
||||
}")
|
||||
# Try to compile and run the test program
|
||||
try_run (TEST_WRGSBASE_RESULT
|
||||
TEST_WRGSBASE_COMPILED
|
||||
${CMAKE_BINARY_DIR}/test_wrgsbase
|
||||
SOURCES ${TEST_WRGSBASE_SOURCE}
|
||||
CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
)
|
||||
#message("${TEST_WRGSBASE_COMPILED}, ${TEST_WRGSBASE_RESULT}")
|
||||
if (TEST_WRGSBASE_RESULT EQUAL 0)
|
||||
set (DISABLE_WRITE_GS_BASE 0)
|
||||
else ()
|
||||
set (DISABLE_WRITE_GS_BASE 1)
|
||||
endif ()
|
||||
endif ()
|
||||
if (DISABLE_WRITE_GS_BASE EQUAL 1)
|
||||
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1)
|
||||
message (" Write linear memory base addr to x86 GS register disabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=0)
|
||||
message (" Write linear memory base addr to x86 GS register enabled")
|
||||
endif ()
|
||||
endif ()
|
||||
if (WAMR_CONFIGURABLE_BOUNDS_CHECKS EQUAL 1)
|
||||
add_definitions (-DWASM_CONFIGURABLE_BOUNDS_CHECKS=1)
|
||||
message (" Configurable bounds checks enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_LINUX_PERF EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_LINUX_PERF=1)
|
||||
message (" Linux perf support enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_AOT EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
|
||||
if (NOT DEFINED WAMR_BUILD_QUICK_AOT_ENTRY)
|
||||
# Enable quick aot/jit entries by default
|
||||
set (WAMR_BUILD_QUICK_AOT_ENTRY 1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_QUICK_AOT_ENTRY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=1)
|
||||
message (" Quick AOT/JIT entries enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0)
|
||||
message (" Quick AOT/JIT entries disabled")
|
||||
endif ()
|
||||
else ()
|
||||
# Disable quick aot/jit entries for interp and fast-jit
|
||||
add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0)
|
||||
endif ()
|
||||
if (WAMR_BUILD_AOT EQUAL 1)
|
||||
if (NOT DEFINED WAMR_BUILD_AOT_INTRINSICS)
|
||||
# Enable aot intrinsics by default
|
||||
set (WAMR_BUILD_AOT_INTRINSICS 1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_AOT_INTRINSICS EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_AOT_INTRINSICS=1)
|
||||
message (" AOT intrinsics enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_AOT_INTRINSICS=0)
|
||||
message (" AOT intrinsics disabled")
|
||||
endif ()
|
||||
else ()
|
||||
# Disable aot intrinsics for interp, fast-jit and llvm-jit
|
||||
add_definitions (-DWASM_ENABLE_AOT_INTRINSICS=0)
|
||||
endif ()
|
||||
if (WAMR_BUILD_ALLOC_WITH_USAGE EQUAL 1)
|
||||
add_definitions(-DWASM_MEM_ALLOC_WITH_USAGE=1)
|
||||
endif()
|
||||
if (NOT WAMR_BUILD_SANITIZER STREQUAL "")
|
||||
message (" Sanitizer ${WAMR_BUILD_SANITIZER} enabled")
|
||||
endif ()
|
||||
if (WAMR_BUILD_SHRUNK_MEMORY EQUAL 1)
|
||||
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=1)
|
||||
message (" Shrunk memory enabled")
|
||||
else ()
|
||||
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=0)
|
||||
message (" Shrunk memory disabled")
|
||||
endif()
|
||||
if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1)
|
||||
message (" AOT validator enabled")
|
||||
add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1)
|
||||
endif ()
|
||||
if (WAMR_BUILD_INSTRUCTION_METERING EQUAL 1)
|
||||
message (" Instruction metering enabled")
|
||||
add_definitions (-DWASM_ENABLE_INSTRUCTION_METERING=1)
|
||||
endif ()
|
||||
|
||||
########################################
|
||||
# Show Phase4 Wasm proposals status.
|
||||
########################################
|
||||
|
||||
message (
|
||||
"-- About Wasm Proposals:\n"
|
||||
" Always-on:\n"
|
||||
" \"Multi-value\"\n"
|
||||
" \"Non-trapping float-to-int conversions\"\n"
|
||||
" \"Sign-extension operators\"\n"
|
||||
" \"WebAssembly C and C++ API\"\n"
|
||||
" Configurable. 0 is OFF. 1 is ON:\n"
|
||||
" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
|
||||
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
|
||||
" \"Garbage collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
|
||||
" \"Legacy Exception handling\" via WAMR_BUILD_EXCE_HANDLING: ${WAMR_BUILD_EXCE_HANDLING}\n"
|
||||
" \"Memory64\" via WAMR_BUILD_MEMORY64: ${WAMR_BUILD_MEMORY64}\n"
|
||||
" \"Multiple memories\" via WAMR_BUILD_MULTI_MEMORY: ${WAMR_BUILD_MULTI_MEMORY}\n"
|
||||
" \"Reference Types\" via WAMR_BUILD_REF_TYPES: ${WAMR_BUILD_REF_TYPES}\n"
|
||||
" \"Reference-Typed Strings\" via WAMR_BUILD_STRINGREF: ${WAMR_BUILD_STRINGREF}\n"
|
||||
" \"Tail call\" via WAMR_BUILD_TAIL_CALL: ${WAMR_BUILD_TAIL_CALL}\n"
|
||||
" \"Threads\" via WAMR_BUILD_SHARED_MEMORY: ${WAMR_BUILD_SHARED_MEMORY}\n"
|
||||
" \"Typed Function References\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
|
||||
" Unsupported (>= Phase4):\n"
|
||||
" \"Branch Hinting\"\n"
|
||||
" \"Custom Annotation Syntax in the Text Format\"\n"
|
||||
" \"Exception handling\"\n"
|
||||
" \"Extended Constant Expressions\"\n"
|
||||
" \"Import/Export of Mutable Globals\"\n"
|
||||
" \"JS String Builtins\"\n"
|
||||
" \"Relaxed SIMD\"\n"
|
||||
)
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
# wasm-micro-runtime as ESP-IDF component
|
||||
|
||||
You can build an ESP-IDF project with wasm-micro-runtime as a component:
|
||||
|
||||
- Make sure you have the ESP-IDF properly installed and setup
|
||||
- In particular have the following paths set:
|
||||
- `WAMR_PATH` to point to your wasm-micro-runtime 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.14)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
set (COMPONENTS ${IDF_TARGET} main freertos esptool_py wamr)
|
||||
|
||||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{WAMR_PATH}/build-scripts/esp-idf")
|
||||
|
||||
project(wamr-hello)
|
||||
```
|
||||
- Develop your project in it's `main` component folder.
|
||||
|
||||
You can find an example [here](../../product-mini/platforms/esp-idf).
|
||||
|
||||
- Set target platform: `idf.py set-target esp32c3`
|
||||
- Build: `idf.py build`
|
||||
- Flash: `idf.py flash`
|
||||
- Check the output: `idf.py monitor`
|
|
@ -1,111 +0,0 @@
|
|||
# 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)
|
||||
if (CONFIG_IDF_TARGET_ESP32P4)
|
||||
set (WAMR_BUILD_TARGET "RISCV32_ILP32F")
|
||||
else ()
|
||||
set (WAMR_BUILD_TARGET "RISCV32_ILP32")
|
||||
endif ()
|
||||
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 ()
|
||||
|
||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
||||
|
||||
list (APPEND srcs "${WAMR_RUNTIME_LIB_SOURCE}"
|
||||
"${PLATFORM_SHARED_SOURCE}")
|
||||
|
||||
set (include_dirs "${IWASM_DIR}/include"
|
||||
"${UTILS_SHARED_DIR}"
|
||||
"${PLATFORM_SHARED_DIR}"
|
||||
"${PLATFORM_SHARED_DIR}/../include"
|
||||
"${IWASM_COMMON_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)
|
||||
if (CONFIG_IDF_TARGET_ESP32P4)
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32F=1)
|
||||
else ()
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
|
||||
endif ()
|
||||
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 ()
|
|
@ -1,77 +0,0 @@
|
|||
menu "WASM Micro Runtime"
|
||||
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 y
|
||||
|
||||
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 n
|
||||
|
||||
config WAMR_ENABLE_PERF_PROFILING
|
||||
bool "Performance profiling"
|
||||
default n
|
||||
|
||||
config WAMR_ENABLE_REF_TYPES
|
||||
bool "Reference types"
|
||||
default n
|
||||
|
||||
config WAMR_ENABLE_SHARED_MEMORY
|
||||
bool "Shared memory"
|
||||
default n
|
||||
endmenu
|
|
@ -1,41 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
message(STATUS "involving boringssl...")
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(boringssl
|
||||
PREFIX external/boringssl
|
||||
# follow envoy, which tracks BoringSSL, which tracks Chromium
|
||||
# https://github.com/envoyproxy/envoy/blob/main/bazel/repository_locations.bzl#L112
|
||||
# chromium-105.0.5195.37 (linux/beta)
|
||||
URL https://github.com/google/boringssl/archive/098695591f3a2665fccef83a3732ecfc99acdcdd.tar.gz
|
||||
URL_HASH SHA256=e141448cf6f686b6e9695f6b6459293fd602c8d51efe118a83106752cf7e1280
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP NEW
|
||||
# SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../external/boringssl
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/src/boringssl-build/libssl.a
|
||||
${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/
|
||||
&& ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/src/boringssl-build/libcrypto.a
|
||||
${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/
|
||||
&& ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/src/boringssl/src/include/openssl
|
||||
${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/openssl
|
||||
)
|
||||
|
||||
add_library(boringssl_ssl STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(
|
||||
boringssl_ssl
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/libssl.a
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/
|
||||
)
|
||||
add_dependencies(boringssl_ssl boringssl)
|
||||
|
||||
add_library(boringssl_crypto STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(
|
||||
boringssl_crypto
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/libcrypto.a
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/
|
||||
)
|
||||
add_dependencies(boringssl_crypto boringssl)
|
|
@ -1,6 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/iwasmTargets.cmake")
|
File diff suppressed because it is too large
Load Diff
|
@ -1,30 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
set(_WAMR_BUILD_SCRIPTS_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
function(install_iwasm_package)
|
||||
install (EXPORT iwasmTargets
|
||||
FILE iwasmTargets.cmake
|
||||
NAMESPACE iwasm::
|
||||
DESTINATION lib/cmake/iwasm
|
||||
)
|
||||
|
||||
include (CMakePackageConfigHelpers)
|
||||
configure_package_config_file (${_WAMR_BUILD_SCRIPTS_DIR}/iwasmConfig.cmake.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake"
|
||||
INSTALL_DESTINATION lib/cmake/iwasm
|
||||
)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfigVersion.cmake"
|
||||
VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
install (FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfigVersion.cmake"
|
||||
DESTINATION lib/cmake/iwasm
|
||||
)
|
||||
endfunction()
|
|
@ -1 +0,0 @@
|
|||
requests==2.32.4
|
|
@ -1,6 +1,7 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
|
||||
if (NOT DEFINED WAMR_ROOT_DIR)
|
||||
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../)
|
||||
endif ()
|
||||
|
@ -10,14 +11,15 @@ endif ()
|
|||
if (NOT DEFINED IWASM_DIR)
|
||||
set (IWASM_DIR ${WAMR_ROOT_DIR}/core/iwasm)
|
||||
endif ()
|
||||
if (NOT DEFINED APP_MGR_DIR)
|
||||
set (APP_MGR_DIR ${WAMR_ROOT_DIR}/core/app-mgr)
|
||||
endif ()
|
||||
if (NOT DEFINED APP_FRAMEWORK_DIR)
|
||||
set (APP_FRAMEWORK_DIR ${WAMR_ROOT_DIR}/core/app-framework)
|
||||
endif ()
|
||||
if (NOT DEFINED DEPS_DIR)
|
||||
set (DEPS_DIR ${WAMR_ROOT_DIR}/core/deps)
|
||||
endif ()
|
||||
if (NOT DEFINED SHARED_PLATFORM_CONFIG)
|
||||
# CMake file for platform configuration. The PLATFORM_SHARED_SOURCE variable
|
||||
# should point to a list of platform-specfic source files to compile.
|
||||
set (SHARED_PLATFORM_CONFIG ${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
|
||||
endif ()
|
||||
|
||||
if (DEFINED EXTRA_SDK_INCLUDE_PATH)
|
||||
message(STATUS, "EXTRA_SDK_INCLUDE_PATH = ${EXTRA_SDK_INCLUDE_PATH} ")
|
||||
|
@ -32,59 +34,36 @@ endif ()
|
|||
# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
|
||||
# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
|
||||
if (NOT DEFINED WAMR_BUILD_TARGET)
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
|
||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
|
||||
set (WAMR_BUILD_TARGET "AARCH64")
|
||||
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
|
||||
set (WAMR_BUILD_TARGET "RISCV64")
|
||||
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
# Build as X86_64 by default in 64-bit platform
|
||||
set (WAMR_BUILD_TARGET "X86_64")
|
||||
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
else ()
|
||||
# Build as X86_32 by default in 32-bit platform
|
||||
set (WAMR_BUILD_TARGET "X86_32")
|
||||
else ()
|
||||
message(SEND_ERROR "Unsupported build target platform!")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
################ optional according to settings ################
|
||||
if (WAMR_BUILD_FAST_JIT EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
|
||||
# Enable classic interpreter if Fast JIT or LLVM JIT is enabled
|
||||
set (WAMR_BUILD_INTERP 1)
|
||||
set (WAMR_BUILD_FAST_INTERP 0)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_INTERP EQUAL 1)
|
||||
if (WAMR_BUILD_INTERP EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
|
||||
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_FAST_JIT EQUAL 1)
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
message ("Fast JIT currently not supported on Windows")
|
||||
set (WAMR_BUILD_FAST_JIT 0)
|
||||
else ()
|
||||
include (${IWASM_DIR}/fast-jit/iwasm_fast_jit.cmake)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_JIT EQUAL 1)
|
||||
# Enable AOT if LLVM JIT is enabled
|
||||
set (WAMR_BUILD_AOT 1)
|
||||
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_AOT EQUAL 1)
|
||||
include (${IWASM_DIR}/aot/iwasm_aot.cmake)
|
||||
if (WAMR_BUILD_JIT EQUAL 1)
|
||||
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_STRINGREF EQUAL 1)
|
||||
set (WAMR_BUILD_GC 1)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_GC EQUAL 1)
|
||||
include (${IWASM_DIR}/common/gc/iwasm_gc.cmake)
|
||||
# Enable the dependent feature if GC is enabled
|
||||
set (WAMR_BUILD_REF_TYPES 1)
|
||||
if (WAMR_BUILD_APP_FRAMEWORK EQUAL 1)
|
||||
include (${APP_FRAMEWORK_DIR}/app_framework.cmake)
|
||||
include (${SHARED_DIR}/coap/lib_coap.cmake)
|
||||
include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
|
||||
include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
|
||||
|
@ -93,26 +72,11 @@ endif ()
|
|||
|
||||
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
|
||||
include (${IWASM_DIR}/libraries/libc-uvwasi/libc_uvwasi.cmake)
|
||||
set (WAMR_BUILD_MODULE_INST_CONTEXT 1)
|
||||
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
|
||||
include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
|
||||
set (WAMR_BUILD_MODULE_INST_CONTEXT 1)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
|
||||
# Enable the dependent feature if lib pthread semaphore is enabled
|
||||
set (WAMR_BUILD_LIB_PTHREAD 1)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_WASI_NN EQUAL 1)
|
||||
include (${IWASM_DIR}/libraries/wasi-nn/cmake/wasi_nn.cmake)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
set (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE 0)
|
||||
message ("Lib pthread semaphore currently not supported on Windows")
|
||||
endif ()
|
||||
include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake)
|
||||
# Enable the dependent feature if lib pthread is enabled
|
||||
set (WAMR_BUILD_THREAD_MGR 1)
|
||||
|
@ -120,29 +84,6 @@ if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
|
|||
set (WAMR_BUILD_SHARED_MEMORY 1)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
|
||||
include (${IWASM_DIR}/libraries/lib-wasi-threads/lib_wasi_threads.cmake)
|
||||
# Enable the dependent feature if lib wasi threads is enabled
|
||||
set (WAMR_BUILD_THREAD_MGR 1)
|
||||
set (WAMR_BUILD_BULK_MEMORY 1)
|
||||
set (WAMR_BUILD_SHARED_MEMORY 1)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
|
||||
include (${IWASM_DIR}/libraries/shared-heap/shared_heap.cmake)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
|
||||
set (WAMR_BUILD_THREAD_MGR 1)
|
||||
include (${IWASM_DIR}/libraries/debug-engine/debug_engine.cmake)
|
||||
|
||||
if (WAMR_BUILD_FAST_INTERP EQUAL 1)
|
||||
set (WAMR_BUILD_FAST_INTERP 0)
|
||||
message(STATUS
|
||||
"Debugger doesn't work with fast interpreter, switch to classic interpreter")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
|
||||
include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
|
||||
endif ()
|
||||
|
@ -151,14 +92,6 @@ if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
|
|||
include (${IWASM_DIR}/libraries/libc-emcc/libc_emcc.cmake)
|
||||
endif()
|
||||
|
||||
if (WAMR_BUILD_LIB_RATS EQUAL 1)
|
||||
include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake)
|
||||
endif ()
|
||||
|
||||
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
|
||||
include (${WAMR_ROOT_DIR}/build-scripts/involve_boringssl.cmake)
|
||||
endif ()
|
||||
|
||||
####################### Common sources #######################
|
||||
if (NOT MSVC)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
|
||||
|
@ -168,18 +101,6 @@ endif ()
|
|||
# include the build config template file
|
||||
include (${CMAKE_CURRENT_LIST_DIR}/config_common.cmake)
|
||||
|
||||
if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM})
|
||||
set(WAMR_BUILD_SIMDE 0)
|
||||
else()
|
||||
include (${IWASM_DIR}/libraries/simde/simde.cmake)
|
||||
set (WAMR_BUILD_SIMDE 1)
|
||||
endif()
|
||||
else()
|
||||
set(WAMR_BUILD_SIMDE 0)
|
||||
endif ()
|
||||
|
||||
include_directories (${IWASM_DIR}/include)
|
||||
|
||||
file (GLOB header
|
||||
|
@ -187,20 +108,9 @@ file (GLOB header
|
|||
)
|
||||
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
|
||||
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
enable_language (ASM_MASM)
|
||||
else()
|
||||
enable_language (ASM)
|
||||
endif()
|
||||
|
||||
# it will expose the runtime APIs.
|
||||
# you'll use the following command to check the exported APIs
|
||||
# dumpbin.exe /EXPORTS xxx
|
||||
if (MSVC)
|
||||
add_compile_definitions(COMPILING_WASM_RUNTIME_API=1)
|
||||
endif ()
|
||||
|
||||
include (${SHARED_PLATFORM_CONFIG})
|
||||
include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
|
||||
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
|
||||
include (${IWASM_DIR}/common/iwasm_common.cmake)
|
||||
include (${SHARED_DIR}/utils/shared_utils.cmake)
|
||||
|
@ -212,20 +122,16 @@ set (source_all
|
|||
${UTILS_SHARED_SOURCE}
|
||||
${LIBC_BUILTIN_SOURCE}
|
||||
${LIBC_WASI_SOURCE}
|
||||
${WASI_NN_SOURCES}
|
||||
${IWASM_COMMON_SOURCE}
|
||||
${IWASM_INTERP_SOURCE}
|
||||
${IWASM_AOT_SOURCE}
|
||||
${IWASM_COMPL_SOURCE}
|
||||
${IWASM_FAST_JIT_SOURCE}
|
||||
${IWASM_GC_SOURCE}
|
||||
${LIB_WASI_THREADS_SOURCE}
|
||||
${WASM_APP_LIB_SOURCE_ALL}
|
||||
${NATIVE_INTERFACE_SOURCE}
|
||||
${APP_MGR_SOURCE}
|
||||
${LIB_PTHREAD_SOURCE}
|
||||
${THREAD_MGR_SOURCE}
|
||||
${LIBC_EMCC_SOURCE}
|
||||
${LIB_RATS_SOURCE}
|
||||
${DEBUG_ENGINE_SOURCE}
|
||||
${LIB_SHARED_HEAP_SOURCE}
|
||||
)
|
||||
|
||||
set (WAMR_RUNTIME_LIB_SOURCE ${source_all})
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
if(NOT WAMR_ROOT_DIR)
|
||||
# if from wamr-compiler
|
||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||
endif()
|
||||
|
||||
set(WAMR_VERSION_MAJOR 2)
|
||||
set(WAMR_VERSION_MINOR 3)
|
||||
set(WAMR_VERSION_PATCH 1)
|
||||
|
||||
message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}")
|
||||
|
||||
# Configure the version header file
|
||||
configure_file(
|
||||
${WAMR_ROOT_DIR}/core/version.h.in
|
||||
${WAMR_ROOT_DIR}/core/version.h
|
||||
)
|
||||
|
||||
# Set the library version and SOVERSION
|
||||
function(set_version_info target)
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}
|
||||
SOVERSION ${WAMR_VERSION_MAJOR}
|
||||
)
|
||||
endfunction()
|
18
ci/Dockerfile
Normal file
18
ci/Dockerfile
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt update \
|
||||
&& apt install -y apt-transport-https ca-certificates gnupg \
|
||||
software-properties-common wget lsb-release curl build-essential
|
||||
|
||||
#
|
||||
# CMAKE (https://apt.kitware.com/)
|
||||
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null \
|
||||
&& apt purge --auto-remove cmake \
|
||||
&& apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' \
|
||||
&& apt update \
|
||||
&& apt-get install -y kitware-archive-keyring \
|
||||
&& rm /etc/apt/trusted.gpg.d/kitware.gpg \
|
||||
&& apt-get install -y cmake
|
|
@ -1,34 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
readonly CURRENT_PATH=$(dirname "$(realpath "$0")")
|
||||
readonly ROOT=$(realpath "${CURRENT_PATH}/..")
|
||||
readonly VARIANT=$(lsb_release -c | awk '{print $2}')
|
||||
|
||||
docker build \
|
||||
--memory=4G --cpu-quota=50000 \
|
||||
-t wamr_dev_${VARIANT}:0.1 -f "${ROOT}"/.devcontainer/Dockerfile "${ROOT}"/.devcontainer \
|
||||
docker build -t wamr_dev:0.1 -f Dockerfile . \
|
||||
&& docker run --rm -it \
|
||||
--cap-add=SYS_PTRACE \
|
||||
--cpus=".5" \
|
||||
--memory=4G \
|
||||
--mount type=bind,src="${ROOT}",dst=/workspaces \
|
||||
--name wamr_build_env \
|
||||
--security-opt=seccomp=unconfined \
|
||||
wamr_dev_${VARIANT}:0.1 \
|
||||
--name wamr_building \
|
||||
--mount type=bind,src=$(realpath .)/..,dst=/source \
|
||||
--workdir /source \
|
||||
wamr_dev:0.1 \
|
||||
/bin/bash -c "\
|
||||
pwd \
|
||||
&& pushd product-mini/platforms/linux \
|
||||
&& rm -rf build \
|
||||
&& mkdir build \
|
||||
pushd product-mini/platforms/linux \
|
||||
&& mkdir -p build \
|
||||
&& pushd build \
|
||||
&& rm -rf * \
|
||||
&& cmake .. \
|
||||
&& make \
|
||||
&& popd \
|
||||
&& popd \
|
||||
&& echo 'Copying the binary ...' \
|
||||
&& rm -rf build_out \
|
||||
&& mkdir build_out \
|
||||
&& cp product-mini/platforms/linux/build/iwasm build_out/iwasm"
|
||||
&& echo 'Copying binary for image build' \
|
||||
&& mkdir -p build_out \
|
||||
&& rm build_out/* \
|
||||
&& cp -f product-mini/platforms/linux/build/iwasm build_out/iwasm"
|
||||
|
|
|
@ -1,330 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
import argparse
|
||||
import re
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
CLANG_FORMAT_CMD = "clang-format-14"
|
||||
GIT_CLANG_FORMAT_CMD = "git-clang-format-14"
|
||||
|
||||
# glob style patterns
|
||||
EXCLUDE_PATHS = [
|
||||
"**/.git/*",
|
||||
"**/.github/*",
|
||||
"**/.vscode/*",
|
||||
"**/build/*",
|
||||
"**/build-scripts/*",
|
||||
"**/ci/*",
|
||||
"**/core/deps/*",
|
||||
"**/doc/*",
|
||||
"**/samples/wasm-c-api/src/*.*",
|
||||
"**/samples/workload/*",
|
||||
"**/test-tools/wasi-sdk/*",
|
||||
"**/tests/wamr-test-suites/workspace/*",
|
||||
]
|
||||
|
||||
C_SUFFIXES = [".c", ".cc", ".cpp", ".h"]
|
||||
INVALID_DIR_NAME_SEGMENT = r"([a-zA-Z0-9]+\_[a-zA-Z0-9]+)"
|
||||
INVALID_FILE_NAME_SEGMENT = r"([a-zA-Z0-9]+\-[a-zA-Z0-9]+)"
|
||||
|
||||
|
||||
def locate_command(command: str) -> bool:
|
||||
if not shutil.which(command):
|
||||
print(f"Command '{command}'' not found")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def is_excluded(path: str) -> bool:
|
||||
path = Path(path).resolve()
|
||||
for exclude_path in EXCLUDE_PATHS:
|
||||
if path.match(exclude_path):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def pre_flight_check(root: Path) -> bool:
|
||||
def check_aspell(root):
|
||||
return True
|
||||
|
||||
def check_clang_format(root: Path) -> bool:
|
||||
if not locate_command(CLANG_FORMAT_CMD):
|
||||
return False
|
||||
|
||||
# Quick syntax check for .clang-format
|
||||
try:
|
||||
subprocess.check_output(
|
||||
shlex.split(f"{CLANG_FORMAT_CMD} --dump-config"), cwd=root
|
||||
)
|
||||
except subprocess.CalledProcessError:
|
||||
print(f"Might have a typo in .clang-format")
|
||||
return False
|
||||
return True
|
||||
|
||||
def check_git_clang_format() -> bool:
|
||||
return locate_command(GIT_CLANG_FORMAT_CMD)
|
||||
|
||||
return check_aspell(root) and check_clang_format(root) and check_git_clang_format()
|
||||
|
||||
|
||||
def run_clang_format(file_path: Path, root: Path) -> bool:
|
||||
try:
|
||||
subprocess.check_call(
|
||||
shlex.split(
|
||||
f"{CLANG_FORMAT_CMD} --style=file --Werror --dry-run {file_path}"
|
||||
),
|
||||
cwd=root,
|
||||
)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
print(f"{file_path} failed the check of {CLANG_FORMAT_CMD}")
|
||||
return False
|
||||
|
||||
|
||||
def run_clang_format_diff(root: Path, commits: str) -> bool:
|
||||
"""
|
||||
Use `clang-format-14` or `git-clang-format-14` to check code format of
|
||||
the PR, with a commit range specified. It is required to format the
|
||||
code before committing the PR, or it might fail to pass the CI check:
|
||||
|
||||
1. Install clang-format-14.0.0
|
||||
|
||||
You can download the package from
|
||||
https://github.com/llvm/llvm-project/releases
|
||||
and install it.
|
||||
|
||||
For Debian/Ubuntu, we can probably use
|
||||
`sudo apt-get install clang-format-14`.
|
||||
|
||||
Homebrew has it as a part of llvm@14.
|
||||
```shell
|
||||
brew install llvm@14
|
||||
/usr/local/opt/llvm@14/bin/clang-format
|
||||
```
|
||||
|
||||
2. Format the C/C++ source file
|
||||
``` shell
|
||||
cd path/to/wamr/root
|
||||
clang-format-14 --style file -i path/to/file
|
||||
```
|
||||
|
||||
The code wrapped by `/* clang-format off */` and `/* clang-format on */`
|
||||
will not be formatted, you shall use them when the formatted code is not
|
||||
readable or friendly:
|
||||
|
||||
``` cc
|
||||
/* clang-format off */
|
||||
code snippets
|
||||
/* clang-format on */
|
||||
```
|
||||
|
||||
"""
|
||||
try:
|
||||
before, after = commits.split("..")
|
||||
after = after if after else "HEAD"
|
||||
COMMAND = (
|
||||
f"{GIT_CLANG_FORMAT_CMD} -v --binary "
|
||||
f"{shutil.which(CLANG_FORMAT_CMD)} --style file "
|
||||
f"--extensions c,cpp,h --diff {before} {after}"
|
||||
)
|
||||
|
||||
p = subprocess.Popen(
|
||||
shlex.split(COMMAND),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=None,
|
||||
stdin=None,
|
||||
universal_newlines=True,
|
||||
)
|
||||
|
||||
stdout, _ = p.communicate()
|
||||
if not stdout.startswith("diff --git"):
|
||||
return True
|
||||
|
||||
diff_content = stdout.split("\n")
|
||||
found = False
|
||||
for summary in [x for x in diff_content if x.startswith("diff --git")]:
|
||||
# b/path/to/file -> path/to/file
|
||||
with_invalid_format = re.split(r"\s+", summary)[-1][2:]
|
||||
if not is_excluded(with_invalid_format):
|
||||
print(f"--- {with_invalid_format} failed on code style checking.")
|
||||
found = True
|
||||
else:
|
||||
return not found
|
||||
except subprocess.subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
|
||||
def run_aspell(file_path: Path, root: Path) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def check_dir_name(path: Path, root: Path) -> bool:
|
||||
m = re.search(INVALID_DIR_NAME_SEGMENT, str(path.relative_to(root).parent))
|
||||
if m:
|
||||
print(f"--- found a character '_' in {m.groups()} in {path}")
|
||||
|
||||
return not m
|
||||
|
||||
|
||||
def check_file_name(path: Path) -> bool:
|
||||
"""
|
||||
file names should not contain any character '-'
|
||||
|
||||
but some names are well known and use '-' as the separator, e.g.:
|
||||
- docker-compose
|
||||
- package-lock
|
||||
- vite-env.d
|
||||
"""
|
||||
if path.stem in [
|
||||
"docker-compose",
|
||||
"package-lock",
|
||||
"vite-env.d",
|
||||
"osv-scanner",
|
||||
]:
|
||||
return True
|
||||
|
||||
m = re.search(INVALID_FILE_NAME_SEGMENT, path.stem)
|
||||
if m:
|
||||
print(f"--- found a character '-' in {m.groups()} in {path}")
|
||||
|
||||
return not m
|
||||
|
||||
|
||||
def parse_commits_range(root: Path, commits: str) -> list:
|
||||
GIT_LOG_CMD = f"git log --pretty='%H' {commits}"
|
||||
try:
|
||||
ret = subprocess.check_output(
|
||||
shlex.split(GIT_LOG_CMD), cwd=root, universal_newlines=True
|
||||
)
|
||||
return [x for x in ret.split("\n") if x]
|
||||
except subprocess.CalledProcessError:
|
||||
print(f"can not parse any commit from the range {commits}")
|
||||
return []
|
||||
|
||||
|
||||
def analysis_new_item_name(root: Path, commit: str) -> bool:
|
||||
"""
|
||||
For any file name in the repo, it is required to use '_' to replace '-'.
|
||||
|
||||
For any directory name in the repo, it is required to use '-' to replace '_'.
|
||||
"""
|
||||
GIT_SHOW_CMD = f"git show --oneline --name-status --diff-filter A {commit}"
|
||||
try:
|
||||
invalid_items = True
|
||||
output = subprocess.check_output(
|
||||
shlex.split(GIT_SHOW_CMD), cwd=root, universal_newlines=True
|
||||
)
|
||||
if not output:
|
||||
return True
|
||||
|
||||
NEW_FILE_PATTERN = "^A\s+(\S+)"
|
||||
for line_no, line in enumerate(output.split("\n")):
|
||||
# bypass the first line, usually it is the commit description
|
||||
if line_no == 0:
|
||||
continue
|
||||
|
||||
if not line:
|
||||
continue
|
||||
|
||||
match = re.match(NEW_FILE_PATTERN, line)
|
||||
if not match:
|
||||
continue
|
||||
|
||||
new_item = match.group(1)
|
||||
new_item = Path(new_item).resolve()
|
||||
|
||||
if new_item.is_file():
|
||||
if not check_file_name(new_item):
|
||||
invalid_items = False
|
||||
continue
|
||||
|
||||
new_item = new_item.parent
|
||||
|
||||
if not check_dir_name(new_item, root):
|
||||
invalid_items = False
|
||||
continue
|
||||
else:
|
||||
return invalid_items
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
|
||||
def process_entire_pr(root: Path, commits: str) -> bool:
|
||||
if not commits:
|
||||
print("Please provide a commits range")
|
||||
return False
|
||||
|
||||
commit_list = parse_commits_range(root, commits)
|
||||
if not commit_list:
|
||||
print(f"Quit since there is no commit to check with")
|
||||
return True
|
||||
|
||||
print(f"there are {len(commit_list)} commits in the PR")
|
||||
|
||||
found = False
|
||||
if not analysis_new_item_name(root, commits):
|
||||
print(f"{analysis_new_item_name.__doc__}")
|
||||
found = True
|
||||
|
||||
if not run_clang_format_diff(root, commits):
|
||||
print(f"{run_clang_format_diff.__doc__}")
|
||||
found = True
|
||||
|
||||
return not found
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Check if change meets all coding guideline requirements"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--commits", default=None, help="Commit range in the form: a..b"
|
||||
)
|
||||
options = parser.parse_args()
|
||||
|
||||
wamr_root = Path(__file__).parent.joinpath("..").resolve()
|
||||
|
||||
if not pre_flight_check(wamr_root):
|
||||
return False
|
||||
|
||||
return process_entire_pr(wamr_root, options.commits)
|
||||
|
||||
|
||||
# run with python3 -m unitest ci/coding_guidelines_check.py
|
||||
class TestCheck(unittest.TestCase):
|
||||
def test_check_dir_name_failed(self):
|
||||
root = Path("/root/Workspace/")
|
||||
new_file_path = root.joinpath("core/shared/platform/esp_idf/espid_memmap.c")
|
||||
self.assertFalse(check_dir_name(new_file_path, root))
|
||||
|
||||
def test_check_dir_name_pass(self):
|
||||
root = Path("/root/Workspace/")
|
||||
new_file_path = root.joinpath("core/shared/platform/esp-idf/espid_memmap.c")
|
||||
self.assertTrue(check_dir_name(new_file_path, root))
|
||||
|
||||
def test_check_file_name_failed(self):
|
||||
new_file_path = Path(
|
||||
"/root/Workspace/core/shared/platform/esp-idf/espid-memmap.c"
|
||||
)
|
||||
self.assertFalse(check_file_name(new_file_path))
|
||||
|
||||
def test_check_file_name_pass(self):
|
||||
new_file_path = Path(
|
||||
"/root/Workspace/core/shared/platform/esp-idf/espid_memmap.c"
|
||||
)
|
||||
self.assertTrue(check_file_name(new_file_path))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(0 if main() else 1)
|
|
@ -1,32 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2023 Amazon.com Inc. or its affiliates. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# This is a sample of pre-commit hook that can be used to make your code fit the WAMR CI code style requirements.
|
||||
# You need to have clang-format-12 installed to use this hook.
|
||||
# To add this pre-commit hook, copy it to <path_to_wamr>/.git/hooks/pre-commit
|
||||
# (you don't need any extensions here)
|
||||
|
||||
# Function to check if a file has a C or C++ extension
|
||||
|
||||
is_c_or_cpp_file() {
|
||||
file="$1"
|
||||
if [[ "$filename" =~ \.(h|c|cpp)$ ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Loop through staged files and apply command "abc" to C and C++ files
|
||||
for staged_file in $(git diff --cached --name-only); do
|
||||
if is_c_or_cpp_file "$staged_file"; then
|
||||
clang-format-12 -Werror --style file --dry-run "$staged_file" 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Issues are found in $staged_file. Applying the fix"
|
||||
clang-format-12 --style file -i "$staged_file"
|
||||
fi
|
||||
git add "$staged_file" # Add the modified file back to staging
|
||||
fi
|
||||
done
|
15
ci/setup.sh
15
ci/setup.sh
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2023 Amazon.com Inc. or its affiliates. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# This script executes some commands to make your onboarding with WAMR easier.
|
||||
# For example, setting pre-commit hook that will make your code complaint with the
|
||||
# code style requirements checked in WAMR CI
|
||||
|
||||
echo "Copy the pre-commit hook to your hooks folder"
|
||||
cp pre_commit_hook_sample ../.git/hooks/pre-commit
|
||||
|
||||
# Feel free to propose your commands to this script to make developing WAMR easier
|
||||
|
||||
echo "Setup is done"
|
|
@ -1,128 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2023 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
#
|
||||
|
||||
import argparse
|
||||
import time
|
||||
from pathlib import Path
|
||||
import subprocess, shlex
|
||||
|
||||
SCRIPT_DIR = Path(__file__).parent.resolve()
|
||||
REPO_ROOT_DIR = SCRIPT_DIR.parent
|
||||
SAMPLE_CODE_FILE = REPO_ROOT_DIR / 'product-mini/app-samples/hello-world/main.c'
|
||||
WASM_OUT_FILE = SCRIPT_DIR / 'out.wasm'
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Validate the customized lldb with sample code"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-l", "--lldb", dest='lldb', default='lldb', help="path to lldb executable"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-w", "--wamr", dest='wamr', default='iwasm', help="path to iwasm executable"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", "--port", dest='port', default='1234', help="debug server listen port"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v", "--verbose", dest='verbose', action='store_true', default=False, help="display lldb stdout"
|
||||
)
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
lldb_command_epilogue = '-o q'
|
||||
|
||||
test_cases = {
|
||||
'run_to_exit': '-o c',
|
||||
'func_breakpoint': '-o "b main" -o c -o c',
|
||||
'line_breakpoint': '-o "b main.c:12" -o c -o c',
|
||||
'break_on_unknown_func': '-o "b not_a_func" -o c',
|
||||
'watch_point': '-o "b main" -o c -o "watchpoint set variable buf" -o c -o "fr v buf" -o c',
|
||||
}
|
||||
|
||||
# Step1: Build wasm module with debug information
|
||||
build_cmd = f'/opt/wasi-sdk/bin/clang -g -O0 -o {WASM_OUT_FILE} {SAMPLE_CODE_FILE}'
|
||||
try:
|
||||
print(f'building wasm module ...', end='', flush=True)
|
||||
subprocess.check_call(shlex.split(build_cmd))
|
||||
print(f'\t OK')
|
||||
except subprocess.CalledProcessError:
|
||||
print("Failed to build wasm module with debug information")
|
||||
exit(1)
|
||||
|
||||
def print_process_output(p):
|
||||
try:
|
||||
outs, errs = p.communicate(timeout=2)
|
||||
print("stdout:")
|
||||
print(outs)
|
||||
print("stderr:")
|
||||
print(errs)
|
||||
except subprocess.TimeoutExpired:
|
||||
print("Failed to get process output")
|
||||
|
||||
# Step2: Launch WAMR in debug mode and validate lldb commands
|
||||
|
||||
iteration = 0
|
||||
for case, cmd in test_cases.items():
|
||||
lldb_command_prologue = f'{options.lldb} -o "process connect -p wasm connect://127.0.0.1:{int(options.port) + iteration}"'
|
||||
wamr_cmd = f'{options.wamr} -g=127.0.0.1:{int(options.port) + iteration} {WASM_OUT_FILE}'
|
||||
iteration += 1
|
||||
|
||||
has_error = False
|
||||
print(f'validating case [{case}] ...', end='', flush=True)
|
||||
lldb_cmd = f'{lldb_command_prologue} {cmd} {lldb_command_epilogue}'
|
||||
|
||||
wamr_process = subprocess.Popen(shlex.split(
|
||||
wamr_cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
|
||||
time.sleep(0.1)
|
||||
if (wamr_process.poll() != None):
|
||||
print("\nWAMR doesn't wait for lldb connection")
|
||||
print_process_output(wamr_process)
|
||||
exit(1)
|
||||
|
||||
lldb_process = subprocess.Popen(shlex.split(
|
||||
lldb_cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
|
||||
if (options.verbose):
|
||||
while (lldb_process.poll() is None):
|
||||
print(lldb_process.stdout.read(), end='', flush=True)
|
||||
|
||||
try:
|
||||
if (lldb_process.wait(5) != 0):
|
||||
print(f"\nFailed to validate case [{case}]")
|
||||
print_process_output(lldb_process)
|
||||
has_error = True
|
||||
|
||||
if wamr_process.wait(2) != 0:
|
||||
print("\nWAMR process doesn't exit normally")
|
||||
print_process_output(wamr_process)
|
||||
has_error = True
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
print(f"\nFailed to validate case [{case}]")
|
||||
print("wamr output:")
|
||||
print_process_output(wamr_process)
|
||||
print("lldb output:")
|
||||
print_process_output(lldb_process)
|
||||
has_error = True
|
||||
finally:
|
||||
if (lldb_process.poll() == None):
|
||||
print(f'\nterminating lldb process [{lldb_process.pid}]')
|
||||
lldb_process.kill()
|
||||
if (wamr_process.poll() == None):
|
||||
print(f'terminating wamr process [{wamr_process.pid}]')
|
||||
wamr_process.kill()
|
||||
|
||||
if (has_error):
|
||||
exit(1)
|
||||
|
||||
print(f'\t OK')
|
||||
|
||||
# wait 100ms to ensure the socket is closed
|
||||
time.sleep(0.1)
|
||||
|
||||
print('Validate lldb success')
|
||||
exit(0)
|
125
core/app-framework/README.md
Normal file
125
core/app-framework/README.md
Normal file
|
@ -0,0 +1,125 @@
|
|||
Application framework
|
||||
=======
|
||||
|
||||
## Directory structure
|
||||
|
||||
|
||||
|
||||
This folder "app-native-shared" is for the source files shared by both WASM APP and native runtime
|
||||
|
||||
- The c files in this directory are compiled into both the WASM APP and runtime.
|
||||
- The header files for distributing to SDK are placed in the "bi-inc" folder.
|
||||
|
||||
|
||||
|
||||
This folder "template" contains a pre-defined directory structure for a framework component. The developers can copy the template folder to create new components to the application framework.
|
||||
|
||||
|
||||
|
||||
Every other subfolder is framework component. Each component contains two library parts: **app and native**.
|
||||
|
||||
- The "base" component provide timer API and inter-app communication support. It must be enabled if other components are selected.
|
||||
- Under the "app" folder of a component, the subfolder "wa_inc" holds all header files that should be included by the WASM applications
|
||||
|
||||
|
||||
|
||||
## Application framework basic model
|
||||
|
||||
The app framework is built on top of two fundamental operations:
|
||||
|
||||
- [Native calls into WASM function](../../doc/embed_wamr.md)
|
||||
|
||||
- [WASM app calls into native API](../../doc/export_native_api.md)
|
||||
|
||||
Asynchronized programming model is supported for WASM applications
|
||||
|
||||
- Every WASM app has its own sandbox and thread
|
||||
|
||||
- Queue and messaging
|
||||
|
||||
<img src="../../doc/pics/app_framework.PNG" style="zoom:67%;" />
|
||||
|
||||
|
||||
|
||||
## Customized building of app framework
|
||||
|
||||
A component can be compilation configurable to the runtime. The wamr SDK tool "build_sdk.sh" supports menu config to select app components for building a customized runtime.
|
||||
|
||||
A number of CMAKE variables are defined to control build of framework and components. You can create a cmake file for defining these variables and include it in the CMakeList.txt for your software, or pass it in "-x" argument when run the [build_sdk.sh](../../wamr-sdk/build_sdk.sh) for building the runtime SDK.
|
||||
|
||||
```cmake
|
||||
set (WAMR_BUILD_APP_FRAMEWORK 1)
|
||||
set (WAMR_BUILD_APP_LIST WAMR_APP_BUILD_BASE)
|
||||
```
|
||||
|
||||
Variables:
|
||||
|
||||
- **WAMR_BUILD_APP_FRAMEWORK**: enable the application framework
|
||||
- **WAMR_BUILD_APP_LIST**: the selected components to be built into the final runtime
|
||||
|
||||
|
||||
|
||||
The configuration file can be generated through the wamr-sdk menu config:
|
||||
|
||||
```bash
|
||||
cd wamr-sdk
|
||||
./build_sdk -n [profile] -i
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Create new components
|
||||
|
||||
Generally you should follow following steps to create a new component:
|
||||
|
||||
- Copy the “template” for creating a new folder
|
||||
|
||||
- Implement the app part
|
||||
|
||||
- If your component exports native function to WASM, ensure your created a header file under app for declaring the function prototype.
|
||||
- If you component provides header files for the WASM applications to include, ensure it is placed under subfolder "wa_inc".
|
||||
|
||||
- Implement the native part
|
||||
|
||||
- If your native function is exported to WASM, you need to create an inl file for the registration. It can be any file name, assuming the file name is "my_component.inl" here:
|
||||
|
||||
```c
|
||||
//use right signature for your functions
|
||||
EXPORT_WASM_API_WITH_SIG(wasm_my_component_api_1, "(i*~)i"),
|
||||
EXPORT_WASM_API_WITH_SIG(wasm_my_component_api_2, "(i)i"),
|
||||
```
|
||||
|
||||
- Ensure "wasm_lib.cmake" is provided as it will be included by the WAMR SDK building script
|
||||
|
||||
- Add a definition in "wasm_lib.cmake" for your component, e.g.
|
||||
|
||||
```cmake
|
||||
add_definitions (-DAPP_FRAMEWORK_MY_COMPONENT)
|
||||
```
|
||||
|
||||
- Modify the file [app_ext_lib_export.c](./app_ext_lib_export.c) to register native APIs exported for the new introduced component. Skip it if not exporting native functions.
|
||||
|
||||
```
|
||||
#include "lib_export.h"
|
||||
|
||||
...
|
||||
#ifdef APP_FRAMEWORK_MY_COMPONENT // this definition is created in wasm_lib.cmake
|
||||
#include "my_component_native_api.h"
|
||||
#endif
|
||||
|
||||
static NativeSymbol extended_native_symbol_defs[] = {
|
||||
...
|
||||
#ifdef APP_FRAMEWORK_MY_COMPONENT
|
||||
#include "my_component.inl"
|
||||
#endif
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Sensor component working flow
|
||||
|
||||
|
||||
|
||||

|
||||
|
11
core/app-framework/app-native-shared/README.md
Normal file
11
core/app-framework/app-native-shared/README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
Notes:
|
||||
=======
|
||||
This folder is for the source files shared by both WASM APP and native runtime
|
||||
|
||||
- The c files in this directory are compiled into both the WASM APP and runtime.
|
||||
- The header files for distributing to SDK are placed in the "bi-inc" folder.
|
||||
|
||||
|
||||
|
||||
|
||||
|
834
core/app-framework/app-native-shared/attr_container.c
Normal file
834
core/app-framework/app-native-shared/attr_container.c
Normal file
|
@ -0,0 +1,834 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bi-inc/attr_container.h"
|
||||
|
||||
typedef union jvalue {
|
||||
bool z;
|
||||
int8_t b;
|
||||
uint16_t c;
|
||||
int16_t s;
|
||||
int32_t i;
|
||||
int64_t j;
|
||||
float f;
|
||||
double d;
|
||||
} jvalue;
|
||||
|
||||
|
||||
|
||||
static inline int16_t get_int16(const char *buf)
|
||||
{
|
||||
int16_t ret;
|
||||
bh_memcpy_s(&ret, sizeof(int16_t), buf, sizeof(int16_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint16_t get_uint16(const char *buf)
|
||||
{
|
||||
return get_int16(buf);
|
||||
}
|
||||
|
||||
static inline int32_t get_int32(const char *buf)
|
||||
{
|
||||
int32_t ret;
|
||||
bh_memcpy_s(&ret, sizeof(int32_t), buf, sizeof(int32_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint32_t get_uint32(const char *buf)
|
||||
{
|
||||
return get_int32(buf);
|
||||
}
|
||||
|
||||
static inline int64_t get_int64(const char *buf)
|
||||
{
|
||||
int64_t ret;
|
||||
bh_memcpy_s(&ret, sizeof(int64_t), buf, sizeof(int64_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline uint64_t get_uint64(const char *buf)
|
||||
{
|
||||
return get_int64(buf);
|
||||
}
|
||||
|
||||
static inline void set_int16(char *buf, int16_t v)
|
||||
{
|
||||
bh_memcpy_s(buf, sizeof(int16_t), &v, sizeof(int16_t));
|
||||
}
|
||||
|
||||
static inline void set_uint16(char *buf, uint16_t v)
|
||||
{
|
||||
bh_memcpy_s(buf, sizeof(uint16_t), &v, sizeof(uint16_t));
|
||||
}
|
||||
|
||||
static inline void set_int32(char *buf, int32_t v)
|
||||
{
|
||||
bh_memcpy_s(buf, sizeof(int32_t), &v, sizeof(int32_t));
|
||||
}
|
||||
|
||||
static inline void set_uint32(char *buf, uint32_t v)
|
||||
{
|
||||
bh_memcpy_s(buf, sizeof(uint32_t), &v, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
static inline void set_int64(char *buf, int64_t v)
|
||||
{
|
||||
bh_memcpy_s(buf, sizeof(int64_t), &v, sizeof(int64_t));
|
||||
}
|
||||
|
||||
static inline void set_uint64(char *buf, uint64_t v)
|
||||
{
|
||||
bh_memcpy_s(buf, sizeof(uint64_t), &v, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
char*
|
||||
attr_container_get_attr_begin(const attr_container_t *attr_cont,
|
||||
uint32_t *p_total_length, uint16_t *p_attr_num)
|
||||
{
|
||||
char *p = (char*) attr_cont->buf;
|
||||
uint16_t str_len, attr_num;
|
||||
uint32_t total_length;
|
||||
|
||||
/* skip total length */
|
||||
total_length = get_uint32(p);
|
||||
p += sizeof(uint32_t);
|
||||
if (!total_length)
|
||||
return NULL;
|
||||
|
||||
/* tag length */
|
||||
str_len = get_uint16(p);
|
||||
p += sizeof(uint16_t);
|
||||
if (!str_len)
|
||||
return NULL;
|
||||
|
||||
/* tag content */
|
||||
p += str_len;
|
||||
if ((uint32_t)(p - attr_cont->buf) >= total_length)
|
||||
return NULL;
|
||||
|
||||
/* attribute num */
|
||||
attr_num = get_uint16(p);
|
||||
p += sizeof(uint16_t);
|
||||
if ((uint32_t)(p - attr_cont->buf) >= total_length)
|
||||
return NULL;
|
||||
|
||||
if (p_total_length)
|
||||
*p_total_length = total_length;
|
||||
|
||||
if (p_attr_num)
|
||||
*p_attr_num = attr_num;
|
||||
|
||||
/* first attribute */
|
||||
return p;
|
||||
}
|
||||
|
||||
static char*
|
||||
attr_container_get_attr_next(const char *curr_attr)
|
||||
{
|
||||
char *p = (char*) curr_attr;
|
||||
uint8_t type;
|
||||
|
||||
/* key length and key */
|
||||
p += sizeof(uint16_t) + get_uint16(p);
|
||||
type = *p++;
|
||||
|
||||
/* Short type to Boolean type */
|
||||
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN) {
|
||||
p += 1 << (type & 3);
|
||||
return p;
|
||||
}
|
||||
/* String type */
|
||||
else if (type == ATTR_TYPE_STRING) {
|
||||
p += sizeof(uint16_t) + get_uint16(p);
|
||||
return p;
|
||||
}
|
||||
/* ByteArray type */
|
||||
else if (type == ATTR_TYPE_BYTEARRAY) {
|
||||
p += sizeof(uint32_t) + get_uint32(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char*
|
||||
attr_container_find_attr(const attr_container_t *attr_cont, const char *key)
|
||||
{
|
||||
uint32_t total_length;
|
||||
uint16_t str_len, attr_num, i;
|
||||
const char *p = attr_cont->buf;
|
||||
|
||||
if (!key)
|
||||
return NULL;
|
||||
|
||||
if (!(p = attr_container_get_attr_begin(attr_cont, &total_length, &attr_num)))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < attr_num; i++) {
|
||||
/* key length */
|
||||
if (!(str_len = get_uint16(p)))
|
||||
return NULL;
|
||||
|
||||
if (str_len == strlen(key) + 1
|
||||
&& memcmp(p + sizeof(uint16_t), key, str_len) == 0) {
|
||||
if ((uint32_t)(p + sizeof(uint16_t) + str_len
|
||||
- attr_cont->buf) >= total_length)
|
||||
return NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
if (!(p = attr_container_get_attr_next(p)))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char*
|
||||
attr_container_get_attr_end(const attr_container_t *attr_cont)
|
||||
{
|
||||
uint32_t total_length;
|
||||
uint16_t attr_num, i;
|
||||
char *p;
|
||||
|
||||
if (!(p = attr_container_get_attr_begin(attr_cont, &total_length, &attr_num)))
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < attr_num; i++)
|
||||
if (!(p = attr_container_get_attr_next(p)))
|
||||
return NULL;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static char*
|
||||
attr_container_get_msg_end(attr_container_t *attr_cont)
|
||||
{
|
||||
char *p = attr_cont->buf;
|
||||
return p + get_uint32(p);
|
||||
}
|
||||
|
||||
uint16_t attr_container_get_attr_num(const attr_container_t *attr_cont)
|
||||
{
|
||||
uint16_t str_len;
|
||||
/* skip total length */
|
||||
const char *p = attr_cont->buf + sizeof(uint32_t);
|
||||
|
||||
str_len = get_uint16(p);
|
||||
/* skip tag length and tag */
|
||||
p += sizeof(uint16_t) + str_len;
|
||||
|
||||
/* attribute num */
|
||||
return get_uint16(p);
|
||||
}
|
||||
|
||||
static void attr_container_inc_attr_num(attr_container_t *attr_cont)
|
||||
{
|
||||
uint16_t str_len, attr_num;
|
||||
/* skip total length */
|
||||
char *p = attr_cont->buf + sizeof(uint32_t);
|
||||
|
||||
str_len = get_uint16(p);
|
||||
/* skip tag length and tag */
|
||||
p += sizeof(uint16_t) + str_len;
|
||||
|
||||
/* attribute num */
|
||||
attr_num = get_uint16(p) + 1;
|
||||
set_uint16(p, attr_num);
|
||||
}
|
||||
|
||||
attr_container_t *
|
||||
attr_container_create(const char *tag)
|
||||
{
|
||||
attr_container_t *attr_cont;
|
||||
int length, tag_length;
|
||||
char *p;
|
||||
|
||||
tag_length = tag ? strlen(tag) + 1 : 1;
|
||||
length = offsetof(attr_container_t, buf) +
|
||||
/* total length + tag length + tag + reserved 100 bytes */
|
||||
sizeof(uint32_t) + sizeof(uint16_t) + tag_length + 100;
|
||||
|
||||
if (!(attr_cont = attr_container_malloc(length))) {
|
||||
attr_container_printf(
|
||||
"Create attr_container failed: allocate memory failed.\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(attr_cont, 0, length);
|
||||
p = attr_cont->buf;
|
||||
|
||||
/* total length */
|
||||
set_uint32(p, length - offsetof(attr_container_t, buf));
|
||||
p += 4;
|
||||
|
||||
/* tag length, tag */
|
||||
set_uint16(p, tag_length);
|
||||
p += 2;
|
||||
if (tag)
|
||||
bh_memcpy_s(p, tag_length, tag, tag_length);
|
||||
|
||||
return attr_cont;
|
||||
}
|
||||
|
||||
void attr_container_destroy(const attr_container_t *attr_cont)
|
||||
{
|
||||
if (attr_cont)
|
||||
attr_container_free((char*) attr_cont);
|
||||
}
|
||||
|
||||
static bool check_set_attr(attr_container_t **p_attr_cont, const char *key)
|
||||
{
|
||||
uint32_t flags;
|
||||
|
||||
if (!p_attr_cont || !*p_attr_cont || !key || strlen(key) == 0) {
|
||||
attr_container_printf(
|
||||
"Set attribute failed: invalid input arguments.\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
flags = get_uint32((char*) *p_attr_cont);
|
||||
if (flags & ATTR_CONT_READONLY_SHIFT) {
|
||||
attr_container_printf(
|
||||
"Set attribute failed: attribute container is readonly.\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool attr_container_set_attr(attr_container_t **p_attr_cont, const char *key,
|
||||
int type, const void *value, int value_length)
|
||||
{
|
||||
attr_container_t *attr_cont, *attr_cont1;
|
||||
uint16_t str_len;
|
||||
uint32_t total_length, attr_len;
|
||||
char *p, *p1, *attr_end, *msg_end, *attr_buf;
|
||||
|
||||
if (!check_set_attr(p_attr_cont, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
attr_cont = *p_attr_cont;
|
||||
p = attr_cont->buf;
|
||||
total_length = get_uint32(p);
|
||||
|
||||
if (!(attr_end = attr_container_get_attr_end(attr_cont))) {
|
||||
attr_container_printf("Set attr failed: get attr end failed.\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
msg_end = attr_container_get_msg_end(attr_cont);
|
||||
|
||||
/* key len + key + '\0' + type */
|
||||
attr_len = sizeof(uint16_t) + strlen(key) + 1 + 1;
|
||||
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN)
|
||||
attr_len += 1 << (type & 3);
|
||||
else if (type == ATTR_TYPE_STRING)
|
||||
attr_len += sizeof(uint16_t) + value_length;
|
||||
else if (type == ATTR_TYPE_BYTEARRAY)
|
||||
attr_len += sizeof(uint32_t) + value_length;
|
||||
|
||||
if (!(p = attr_buf = attr_container_malloc(attr_len))) {
|
||||
attr_container_printf("Set attr failed: allocate memory failed.\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Set the attr buf */
|
||||
str_len = (uint16_t)(strlen(key) + 1);
|
||||
set_uint16(p, str_len);
|
||||
p += sizeof(uint16_t);
|
||||
bh_memcpy_s(p, str_len, key, str_len);
|
||||
p += str_len;
|
||||
|
||||
*p++ = type;
|
||||
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN)
|
||||
bh_memcpy_s(p, 1 << (type & 3), value, 1 << (type & 3));
|
||||
else if (type == ATTR_TYPE_STRING) {
|
||||
set_uint16(p, value_length);
|
||||
p += sizeof(uint16_t);
|
||||
bh_memcpy_s(p, value_length, value, value_length);
|
||||
} else if (type == ATTR_TYPE_BYTEARRAY) {
|
||||
set_uint32(p, value_length);
|
||||
p += sizeof(uint32_t);
|
||||
bh_memcpy_s(p, value_length, value, value_length);
|
||||
}
|
||||
|
||||
if ((p = (char*) attr_container_find_attr(attr_cont, key))) {
|
||||
/* key found */
|
||||
p1 = attr_container_get_attr_next(p);
|
||||
|
||||
if (p1 - p == attr_len) {
|
||||
bh_memcpy_s(p, attr_len, attr_buf, attr_len);
|
||||
attr_container_free(attr_buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((uint32_t)(p1 - p + msg_end - attr_end) >= attr_len) {
|
||||
memmove(p, p1, attr_end - p1);
|
||||
bh_memcpy_s(p + (attr_end - p1), attr_len, attr_buf, attr_len);
|
||||
attr_container_free(attr_buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
total_length += attr_len + 100;
|
||||
if (!(attr_cont1 = attr_container_malloc(
|
||||
offsetof(attr_container_t, buf) + total_length))) {
|
||||
attr_container_printf(
|
||||
"Set attr failed: allocate memory failed.\r\n");
|
||||
attr_container_free(attr_buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
bh_memcpy_s(attr_cont1, p - (char* )attr_cont, attr_cont,
|
||||
p - (char* )attr_cont);
|
||||
bh_memcpy_s((char* )attr_cont1 + (unsigned )(p - (char* )attr_cont),
|
||||
attr_end - p1, p1, attr_end - p1);
|
||||
bh_memcpy_s(
|
||||
(char* )attr_cont1 + (unsigned )(p - (char* )attr_cont)
|
||||
+ (unsigned )(attr_end - p1), attr_len, attr_buf,
|
||||
attr_len);
|
||||
p = attr_cont1->buf;
|
||||
set_uint32(p, total_length);
|
||||
*p_attr_cont = attr_cont1;
|
||||
/* Free original buffer */
|
||||
attr_container_free(attr_cont);
|
||||
attr_container_free(attr_buf);
|
||||
return true;
|
||||
} else {
|
||||
/* key not found */
|
||||
if ((uint32_t)(msg_end - attr_end) >= attr_len) {
|
||||
bh_memcpy_s(attr_end, msg_end - attr_end, attr_buf, attr_len);
|
||||
attr_container_inc_attr_num(attr_cont);
|
||||
attr_container_free(attr_buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
total_length += attr_len + 100;
|
||||
if (!(attr_cont1 = attr_container_malloc(
|
||||
offsetof(attr_container_t, buf) + total_length))) {
|
||||
attr_container_printf(
|
||||
"Set attr failed: allocate memory failed.\r\n");
|
||||
attr_container_free(attr_buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
bh_memcpy_s(attr_cont1, attr_end - (char* )attr_cont, attr_cont,
|
||||
attr_end - (char* )attr_cont);
|
||||
bh_memcpy_s(
|
||||
(char* )attr_cont1 + (unsigned )(attr_end - (char* )attr_cont),
|
||||
attr_len, attr_buf, attr_len);
|
||||
attr_container_inc_attr_num(attr_cont1);
|
||||
p = attr_cont1->buf;
|
||||
set_uint32(p, total_length);
|
||||
*p_attr_cont = attr_cont1;
|
||||
/* Free original buffer */
|
||||
attr_container_free(attr_cont);
|
||||
attr_container_free(attr_buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool attr_container_set_short(attr_container_t **p_attr_cont, const char *key,
|
||||
short value)
|
||||
{
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_SHORT, &value, 2);
|
||||
}
|
||||
|
||||
bool attr_container_set_int(attr_container_t **p_attr_cont, const char *key,
|
||||
int value)
|
||||
{
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_INT, &value, 4);
|
||||
}
|
||||
|
||||
bool attr_container_set_int64(attr_container_t **p_attr_cont, const char *key,
|
||||
int64_t value)
|
||||
{
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_INT64, &value, 8);
|
||||
}
|
||||
|
||||
bool attr_container_set_byte(attr_container_t **p_attr_cont, const char *key,
|
||||
int8_t value)
|
||||
{
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_BYTE, &value, 1);
|
||||
}
|
||||
|
||||
bool attr_container_set_uint16(attr_container_t **p_attr_cont, const char *key,
|
||||
uint16_t value)
|
||||
{
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_UINT16, &value,
|
||||
2);
|
||||
}
|
||||
|
||||
bool attr_container_set_float(attr_container_t **p_attr_cont, const char *key,
|
||||
float value)
|
||||
{
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_FLOAT, &value, 4);
|
||||
}
|
||||
|
||||
bool attr_container_set_double(attr_container_t **p_attr_cont, const char *key,
|
||||
double value)
|
||||
{
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_DOUBLE, &value,
|
||||
8);
|
||||
}
|
||||
|
||||
bool attr_container_set_bool(attr_container_t **p_attr_cont, const char *key,
|
||||
bool value)
|
||||
{
|
||||
int8_t value1 = value ? 1 : 0;
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_BOOLEAN, &value1,
|
||||
1);
|
||||
}
|
||||
|
||||
bool attr_container_set_string(attr_container_t **p_attr_cont, const char *key,
|
||||
const char *value)
|
||||
{
|
||||
if (!value) {
|
||||
attr_container_printf("Set attr failed: invald input arguments.\r\n");
|
||||
return false;
|
||||
}
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_STRING, value,
|
||||
strlen(value) + 1);;
|
||||
}
|
||||
|
||||
bool attr_container_set_bytearray(attr_container_t **p_attr_cont,
|
||||
const char *key, const int8_t *value, unsigned length)
|
||||
{
|
||||
if (!value) {
|
||||
attr_container_printf("Set attr failed: invald input arguments.\r\n");
|
||||
return false;
|
||||
}
|
||||
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_BYTEARRAY, value,
|
||||
length);;
|
||||
}
|
||||
|
||||
static const char*
|
||||
attr_container_get_attr(const attr_container_t *attr_cont, const char *key)
|
||||
{
|
||||
const char *attr_addr;
|
||||
|
||||
if (!attr_cont || !key) {
|
||||
attr_container_printf(
|
||||
"Get attribute failed: invalid input arguments.\r\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(attr_addr = attr_container_find_attr(attr_cont, key))) {
|
||||
attr_container_printf("Get attribute failed: lookup key failed.\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* key len + key + '\0' */
|
||||
return attr_addr + 2 + strlen(key) + 1;
|
||||
}
|
||||
|
||||
#define TEMPLATE_ATTR_BUF_TO_VALUE(attr, key, var_name) do {\
|
||||
jvalue val; \
|
||||
const char *addr = attr_container_get_attr(attr, key); \
|
||||
uint8_t type; \
|
||||
if (!addr) \
|
||||
return 0; \
|
||||
val.j = 0; \
|
||||
type = *(uint8_t*)addr++; \
|
||||
switch (type) { \
|
||||
case ATTR_TYPE_SHORT: \
|
||||
case ATTR_TYPE_INT: \
|
||||
case ATTR_TYPE_INT64: \
|
||||
case ATTR_TYPE_BYTE: \
|
||||
case ATTR_TYPE_UINT16: \
|
||||
case ATTR_TYPE_FLOAT: \
|
||||
case ATTR_TYPE_DOUBLE: \
|
||||
case ATTR_TYPE_BOOLEAN: \
|
||||
bh_memcpy_s(&val, sizeof(val.var_name), addr, 1 << (type & 3)); \
|
||||
break; \
|
||||
case ATTR_TYPE_STRING: \
|
||||
{ \
|
||||
unsigned len= get_uint16(addr); \
|
||||
addr += 2; \
|
||||
if (len > sizeof(val.var_name)) \
|
||||
len = sizeof(val.var_name); \
|
||||
bh_memcpy_s(&val.var_name, sizeof(val.var_name), addr, len); \
|
||||
break; \
|
||||
} \
|
||||
case ATTR_TYPE_BYTEARRAY: \
|
||||
{ \
|
||||
unsigned len= get_uint32(addr); \
|
||||
addr += 4; \
|
||||
if (len > sizeof(val.var_name)) \
|
||||
len = sizeof(val.var_name); \
|
||||
bh_memcpy_s(&val.var_name, sizeof(val.var_name), addr, len); \
|
||||
break; \
|
||||
} \
|
||||
default: \
|
||||
bh_assert(0); \
|
||||
break; \
|
||||
} \
|
||||
return val.var_name; \
|
||||
} while (0)
|
||||
|
||||
short attr_container_get_as_short(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, s);
|
||||
}
|
||||
|
||||
int attr_container_get_as_int(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, i);
|
||||
}
|
||||
|
||||
int64_t attr_container_get_as_int64(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, j);
|
||||
}
|
||||
|
||||
int8_t attr_container_get_as_byte(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, b);
|
||||
}
|
||||
|
||||
uint16_t attr_container_get_as_uint16(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, s);
|
||||
}
|
||||
|
||||
float attr_container_get_as_float(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, f);
|
||||
}
|
||||
|
||||
double attr_container_get_as_double(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, d);
|
||||
}
|
||||
|
||||
bool attr_container_get_as_bool(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, z);
|
||||
}
|
||||
|
||||
const int8_t*
|
||||
attr_container_get_as_bytearray(const attr_container_t *attr_cont,
|
||||
const char *key, unsigned *array_length)
|
||||
{
|
||||
const char *addr = attr_container_get_attr(attr_cont, key);
|
||||
uint8_t type;
|
||||
uint32_t length;
|
||||
|
||||
if (!addr)
|
||||
return NULL;
|
||||
|
||||
if (!array_length) {
|
||||
attr_container_printf("Get attribute failed: invalid input arguments.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
type = *(uint8_t*) addr++;
|
||||
switch (type) {
|
||||
case ATTR_TYPE_SHORT:
|
||||
case ATTR_TYPE_INT:
|
||||
case ATTR_TYPE_INT64:
|
||||
case ATTR_TYPE_BYTE:
|
||||
case ATTR_TYPE_UINT16:
|
||||
case ATTR_TYPE_FLOAT:
|
||||
case ATTR_TYPE_DOUBLE:
|
||||
case ATTR_TYPE_BOOLEAN:
|
||||
length = 1 << (type & 3);
|
||||
break;
|
||||
case ATTR_TYPE_STRING:
|
||||
length = get_uint16(addr);
|
||||
addr += 2;
|
||||
break;
|
||||
case ATTR_TYPE_BYTEARRAY:
|
||||
length = get_uint32(addr);
|
||||
addr += 4;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*array_length = length;
|
||||
return (const int8_t*) addr;
|
||||
}
|
||||
|
||||
char*
|
||||
attr_container_get_as_string(const attr_container_t *attr_cont, const char *key)
|
||||
{
|
||||
unsigned array_length;
|
||||
return (char*) attr_container_get_as_bytearray(attr_cont, key,
|
||||
&array_length);
|
||||
}
|
||||
|
||||
const char*
|
||||
attr_container_get_tag(const attr_container_t *attr_cont)
|
||||
{
|
||||
return attr_cont ?
|
||||
attr_cont->buf + sizeof(uint32_t) + sizeof(uint16_t) : NULL;
|
||||
}
|
||||
|
||||
bool attr_container_contain_key(const attr_container_t *attr_cont,
|
||||
const char *key)
|
||||
{
|
||||
if (!attr_cont || !key || !strlen(key)) {
|
||||
attr_container_printf(
|
||||
"Check contain key failed: invalid input arguments.\r\n");
|
||||
return false;
|
||||
}
|
||||
return attr_container_find_attr(attr_cont, key) ? true : false;
|
||||
}
|
||||
|
||||
unsigned int attr_container_get_serialize_length(
|
||||
const attr_container_t *attr_cont)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (!attr_cont) {
|
||||
attr_container_printf(
|
||||
"Get container serialize length failed: invalid input arguments.\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
p = attr_cont->buf;
|
||||
return sizeof(uint16_t) + get_uint32(p);
|
||||
}
|
||||
|
||||
bool attr_container_serialize(char *buf, const attr_container_t *attr_cont)
|
||||
{
|
||||
const char *p;
|
||||
uint16_t flags;
|
||||
uint32_t length;
|
||||
|
||||
if (!buf || !attr_cont) {
|
||||
attr_container_printf(
|
||||
"Container serialize failed: invalid input arguments.\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
p = attr_cont->buf;
|
||||
length = sizeof(uint16_t) + get_uint32(p);
|
||||
bh_memcpy_s(buf, length, attr_cont, length);
|
||||
/* Set readonly */
|
||||
flags = get_uint16((const char*) attr_cont);
|
||||
set_uint16(buf, flags | (1 << ATTR_CONT_READONLY_SHIFT));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool attr_container_is_constant(const attr_container_t* attr_cont)
|
||||
{
|
||||
uint16_t flags;
|
||||
|
||||
if (!attr_cont) {
|
||||
attr_container_printf(
|
||||
"Container check const: invalid input arguments.\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
flags = get_uint16((const char*) attr_cont);
|
||||
return (flags & (1 << ATTR_CONT_READONLY_SHIFT)) ? true : false;
|
||||
}
|
||||
|
||||
void attr_container_dump(const attr_container_t *attr_cont)
|
||||
{
|
||||
uint32_t total_length;
|
||||
uint16_t attr_num, i, type;
|
||||
const char *p, *tag, *key;
|
||||
jvalue value;
|
||||
|
||||
if (!attr_cont)
|
||||
return;
|
||||
|
||||
tag = attr_container_get_tag(attr_cont);
|
||||
if (!tag)
|
||||
return;
|
||||
|
||||
attr_container_printf("Attribute container dump:\n");
|
||||
attr_container_printf("Tag: %s\n", tag);
|
||||
|
||||
p = attr_container_get_attr_begin(attr_cont, &total_length, &attr_num);
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
attr_container_printf("Attribute list:\n");
|
||||
for (i = 0; i < attr_num; i++) {
|
||||
key = p + 2;
|
||||
/* Skip key len and key */
|
||||
p += 2 + get_uint16(p);
|
||||
type = *p++;
|
||||
attr_container_printf(" key: %s", key);
|
||||
|
||||
switch (type) {
|
||||
case ATTR_TYPE_SHORT:
|
||||
bh_memcpy_s(&value.s, sizeof(int16_t), p, sizeof(int16_t));
|
||||
attr_container_printf(", type: short, value: 0x%x\n",
|
||||
value.s & 0xFFFF);
|
||||
p += 2;
|
||||
break;
|
||||
case ATTR_TYPE_INT:
|
||||
bh_memcpy_s(&value.i, sizeof(int32_t), p, sizeof(int32_t));
|
||||
attr_container_printf(", type: int, value: 0x%x\n", value.i);
|
||||
p += 4;
|
||||
break;
|
||||
case ATTR_TYPE_INT64:
|
||||
bh_memcpy_s(&value.j, sizeof(uint64_t), p, sizeof(uint64_t));
|
||||
attr_container_printf(", type: int64, value: 0x%llx\n", (long long unsigned int)(value.j));
|
||||
p += 8;
|
||||
break;
|
||||
case ATTR_TYPE_BYTE:
|
||||
bh_memcpy_s(&value.b, 1, p, 1);
|
||||
attr_container_printf(", type: byte, value: 0x%x\n",
|
||||
value.b & 0xFF);
|
||||
p++;
|
||||
break;
|
||||
case ATTR_TYPE_UINT16:
|
||||
bh_memcpy_s(&value.c, sizeof(uint16_t), p, sizeof(uint16_t));
|
||||
attr_container_printf(", type: uint16, value: 0x%x\n", value.c);
|
||||
p += 2;
|
||||
break;
|
||||
case ATTR_TYPE_FLOAT:
|
||||
bh_memcpy_s(&value.f, sizeof(float), p, sizeof(float));
|
||||
attr_container_printf(", type: float, value: %f\n", value.f);
|
||||
p += 4;
|
||||
break;
|
||||
case ATTR_TYPE_DOUBLE:
|
||||
bh_memcpy_s(&value.d, sizeof(double), p, sizeof(double));
|
||||
attr_container_printf(", type: double, value: %f\n", value.d);
|
||||
p += 8;
|
||||
break;
|
||||
case ATTR_TYPE_BOOLEAN:
|
||||
bh_memcpy_s(&value.z, 1, p, 1);
|
||||
attr_container_printf(", type: bool, value: 0x%x\n", value.z);
|
||||
p++;
|
||||
break;
|
||||
case ATTR_TYPE_STRING:
|
||||
attr_container_printf(", type: string, value: %s\n",
|
||||
p + sizeof(uint16_t));
|
||||
p += sizeof(uint16_t) + get_uint16(p);
|
||||
break;
|
||||
case ATTR_TYPE_BYTEARRAY:
|
||||
attr_container_printf(", type: byte array, length: %d\n",
|
||||
get_uint32(p));
|
||||
p += sizeof(uint32_t) + get_uint32(p);
|
||||
break;
|
||||
default:
|
||||
bh_assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
attr_container_printf("\n");
|
||||
}
|
||||
|
425
core/app-framework/app-native-shared/bi-inc/attr_container.h
Normal file
425
core/app-framework/app-native-shared/bi-inc/attr_container.h
Normal file
|
@ -0,0 +1,425 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _ATTR_CONTAINER_H_
|
||||
#define _ATTR_CONTAINER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "bh_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Attribute type */
|
||||
enum {
|
||||
ATTR_TYPE_BEGIN = 1,
|
||||
ATTR_TYPE_SHORT = ATTR_TYPE_BEGIN,
|
||||
ATTR_TYPE_INT,
|
||||
ATTR_TYPE_INT64,
|
||||
ATTR_TYPE_BYTE,
|
||||
ATTR_TYPE_UINT16,
|
||||
ATTR_TYPE_FLOAT,
|
||||
ATTR_TYPE_DOUBLE,
|
||||
ATTR_TYPE_BOOLEAN,
|
||||
ATTR_TYPE_STRING,
|
||||
ATTR_TYPE_BYTEARRAY,
|
||||
ATTR_TYPE_END = ATTR_TYPE_BYTEARRAY
|
||||
};
|
||||
|
||||
#define ATTR_CONT_READONLY_SHIFT 2
|
||||
|
||||
typedef struct attr_container {
|
||||
/* container flag:
|
||||
* bit0, bit1 denote the implemenation algorithm, 00: buffer, 01: link list
|
||||
* bit2 denotes the readonly flag: 1 is readonly and attr cannot be set
|
||||
*/
|
||||
char flags[2];
|
||||
/**
|
||||
* Buffer format
|
||||
* for buffer implementation:
|
||||
* buf length (4 bytes)
|
||||
* tag length (2 bytes)
|
||||
* tag
|
||||
* attr num (2bytes)
|
||||
* attr[0..n-1]:
|
||||
* attr key length (2 bytes)
|
||||
* attr type (1byte)
|
||||
* attr value (length depends on attr type)
|
||||
*/
|
||||
char buf[1];
|
||||
} attr_container_t;
|
||||
|
||||
/**
|
||||
* Create attribute container
|
||||
*
|
||||
* @param tag tag of current attribute container
|
||||
*
|
||||
* @return the created attribute container, NULL if failed
|
||||
*/
|
||||
attr_container_t *
|
||||
attr_container_create(const char *tag);
|
||||
|
||||
/**
|
||||
* Destroy attribute container
|
||||
*
|
||||
* @param attr_cont the attribute container to destroy
|
||||
*/
|
||||
void
|
||||
attr_container_destroy(const attr_container_t *attr_cont);
|
||||
|
||||
/**
|
||||
* Set short attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_short(attr_container_t **p_attr_cont, const char *key,
|
||||
short value);
|
||||
|
||||
/**
|
||||
* Set int attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_int(attr_container_t **p_attr_cont, const char *key,
|
||||
int value);
|
||||
|
||||
/**
|
||||
* Set int64 attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_int64(attr_container_t **p_attr_cont, const char *key,
|
||||
int64_t value);
|
||||
|
||||
/**
|
||||
* Set byte attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_byte(attr_container_t **p_attr_cont, const char *key,
|
||||
int8_t value);
|
||||
|
||||
/**
|
||||
* Set uint16 attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_uint16(attr_container_t **p_attr_cont, const char *key,
|
||||
uint16_t value);
|
||||
|
||||
/**
|
||||
* Set float attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_float(attr_container_t **p_attr_cont, const char *key,
|
||||
float value);
|
||||
|
||||
/**
|
||||
* Set double attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_double(attr_container_t **p_attr_cont, const char *key,
|
||||
double value);
|
||||
|
||||
/**
|
||||
* Set bool attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_bool(attr_container_t **p_attr_cont, const char *key,
|
||||
bool value);
|
||||
|
||||
/**
|
||||
* Set string attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the attribute value
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_string(attr_container_t **p_attr_cont, const char *key,
|
||||
const char *value);
|
||||
|
||||
/**
|
||||
* Set bytearray attribute in attribute container
|
||||
*
|
||||
* @param p_attr_cont pointer to attribute container to set attribute, and
|
||||
* return the new attribute container if it is re-created
|
||||
* @param key the attribute key
|
||||
* @param value the bytearray buffer
|
||||
* @param length the bytearray length
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_set_bytearray(attr_container_t **p_attr_cont, const char *key,
|
||||
const int8_t *value, unsigned length);
|
||||
|
||||
/**
|
||||
* Get tag of current attribute container
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
*
|
||||
* @return tag of current attribute container
|
||||
*/
|
||||
const char*
|
||||
attr_container_get_tag(const attr_container_t *attr_cont);
|
||||
|
||||
/**
|
||||
* Get attribute number of current attribute container
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
*
|
||||
* @return attribute number of current attribute container
|
||||
*/
|
||||
uint16_t
|
||||
attr_container_get_attr_num(const attr_container_t *attr_cont);
|
||||
|
||||
/**
|
||||
* Whether the attribute container contains an attribute key.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return true if key is contained in message, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_contain_key(const attr_container_t *attr_cont, const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as short value,
|
||||
* return 0 if attribute isn't found in message.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the short value of the attribute, 0 if key isn't found
|
||||
*/
|
||||
short
|
||||
attr_container_get_as_short(const attr_container_t *attr_cont, const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as int value,
|
||||
* return 0 if attribute isn't found in message.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the int value of the attribute, 0 if key isn't found
|
||||
*/
|
||||
int
|
||||
attr_container_get_as_int(const attr_container_t *attr_cont, const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as int64 value,
|
||||
* return 0 if attribute isn't found in attribute container.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the long value of the attribute, 0 if key isn't found
|
||||
*/
|
||||
int64_t
|
||||
attr_container_get_as_int64(const attr_container_t *attr_cont, const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as byte value,
|
||||
* return 0 if attribute isn't found in attribute container.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the byte value of the attribute, 0 if key isn't found
|
||||
*/
|
||||
int8_t
|
||||
attr_container_get_as_byte(const attr_container_t *attr_cont, const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as uint16 value,
|
||||
* return 0 if attribute isn't found in attribute container.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the char value of the attribute, 0 if key isn't found
|
||||
*/
|
||||
uint16_t
|
||||
attr_container_get_as_uint16(const attr_container_t *attr_cont,
|
||||
const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as float value,
|
||||
* return 0 if attribute isn't found in attribute container.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the float value of the attribute, 0 if key isn't found
|
||||
*/
|
||||
float
|
||||
attr_container_get_as_float(const attr_container_t *attr_cont, const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as double value,
|
||||
* return 0 if attribute isn't found in attribute container.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the double value of the attribute, 0 if key isn't found
|
||||
*/
|
||||
double
|
||||
attr_container_get_as_double(const attr_container_t *attr_cont,
|
||||
const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as bool value,
|
||||
* return false if attribute isn't found in attribute container.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the bool value of the attribute, 0 if key isn't found
|
||||
*/
|
||||
bool
|
||||
attr_container_get_as_bool(const attr_container_t *attr_cont, const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as string value,
|
||||
* return NULL if attribute isn't found in attribute container.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the string value of the attribute, NULL if key isn't found
|
||||
*/
|
||||
char*
|
||||
attr_container_get_as_string(const attr_container_t *attr_cont,
|
||||
const char *key);
|
||||
|
||||
/**
|
||||
* Get attribute from attribute container and return it as bytearray value,
|
||||
* return 0 if attribute isn't found in attribute container.
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
* @param key the attribute key
|
||||
*
|
||||
* @return the bytearray value of the attribute, NULL if key isn't found
|
||||
*/
|
||||
const int8_t*
|
||||
attr_container_get_as_bytearray(const attr_container_t *attr_cont,
|
||||
const char *key, unsigned *array_length);
|
||||
|
||||
/**
|
||||
* Get the buffer size of attribute container
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
*
|
||||
* @return the buffer size of attribute container
|
||||
*/
|
||||
unsigned
|
||||
attr_container_get_serialize_length(const attr_container_t *attr_cont);
|
||||
|
||||
/**
|
||||
* Serialize attribute container to a buffer
|
||||
*
|
||||
* @param buf the buffer to receive the serialized data
|
||||
* @param attr_cont the attribute container to be serialized
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_serialize(char *buf, const attr_container_t *attr_cont);
|
||||
|
||||
/**
|
||||
* Whether the attribute container is const, or set attribute isn't supported
|
||||
*
|
||||
* @param attr_cont the attribute container
|
||||
*
|
||||
* @return true if const, false otherwise
|
||||
*/
|
||||
bool
|
||||
attr_container_is_constant(const attr_container_t* attr_cont);
|
||||
|
||||
void
|
||||
attr_container_dump(const attr_container_t *attr_cont);
|
||||
|
||||
#ifndef attr_container_malloc
|
||||
#define attr_container_malloc WA_MALLOC
|
||||
#endif
|
||||
|
||||
#ifndef attr_container_free
|
||||
#define attr_container_free WA_FREE
|
||||
#endif
|
||||
|
||||
#ifndef attr_container_printf
|
||||
#define attr_container_printf printf
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* end of _ATTR_CONTAINER_H_ */
|
||||
|
156
core/app-framework/app-native-shared/bi-inc/shared_utils.h
Normal file
156
core/app-framework/app-native-shared/bi-inc/shared_utils.h
Normal file
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _SHARED_UTILS_H_
|
||||
#define _SHARED_UTILS_H_
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FMT_ATTR_CONTAINER 99
|
||||
#define FMT_APP_RAW_BINARY 98
|
||||
|
||||
/* the request structure */
|
||||
typedef struct request {
|
||||
// message id
|
||||
uint32 mid;
|
||||
|
||||
// url of the request
|
||||
char *url;
|
||||
|
||||
// action of the request, can be PUT/GET/POST/DELETE
|
||||
int action;
|
||||
|
||||
// payload format, currently only support attr_container_t type
|
||||
int fmt;
|
||||
|
||||
// payload of the request, currently only support attr_container_t type
|
||||
void *payload;
|
||||
|
||||
//length in bytes of the payload
|
||||
int payload_len;
|
||||
|
||||
//sender of the request
|
||||
unsigned long sender;
|
||||
} request_t;
|
||||
|
||||
/* the response structure */
|
||||
typedef struct response {
|
||||
// message id
|
||||
uint32 mid;
|
||||
|
||||
// status of the response
|
||||
int status;
|
||||
|
||||
// payload format
|
||||
int fmt;
|
||||
|
||||
// payload of the response,
|
||||
void *payload;
|
||||
|
||||
//length in bytes of the payload
|
||||
int payload_len;
|
||||
|
||||
//receiver of the response
|
||||
unsigned long reciever;
|
||||
} response_t;
|
||||
|
||||
int
|
||||
check_url_start(const char* url, int url_len, const char * leading_str);
|
||||
|
||||
bool
|
||||
match_url(char * pattern, char * matched);
|
||||
|
||||
char *
|
||||
find_key_value(char * buffer, int buffer_len, char * key, char * value,
|
||||
int value_len, char delimiter);
|
||||
|
||||
request_t *
|
||||
clone_request(request_t *request);
|
||||
|
||||
void
|
||||
request_cleaner(request_t *request);
|
||||
|
||||
response_t *
|
||||
clone_response(response_t * response);
|
||||
|
||||
void
|
||||
response_cleaner(response_t * response);
|
||||
|
||||
/**
|
||||
* @brief Set fields of response.
|
||||
*
|
||||
* @param response pointer of the response to be set
|
||||
* @param status status of response
|
||||
* @param fmt format of the response payload
|
||||
* @param payload payload of the response
|
||||
* @param payload_len length in bytes of the response payload
|
||||
*
|
||||
* @return pointer to the response
|
||||
*
|
||||
* @warning the response pointer MUST NOT be NULL
|
||||
*/
|
||||
response_t *
|
||||
set_response(response_t * response, int status, int fmt,
|
||||
const char *payload, int payload_len);
|
||||
|
||||
/**
|
||||
* @brief Make a response for a request.
|
||||
*
|
||||
* @param request pointer of the request
|
||||
* @param response pointer of the response to be made
|
||||
*
|
||||
* @return pointer to the response
|
||||
*
|
||||
* @warning the request and response pointers MUST NOT be NULL
|
||||
*/
|
||||
response_t *
|
||||
make_response_for_request(request_t * request, response_t * response);
|
||||
|
||||
/**
|
||||
* @brief Initialize a request.
|
||||
*
|
||||
* @param request pointer of the request to be initialized
|
||||
* @param url url of the request
|
||||
* @param action action of the request
|
||||
* @param fmt format of the request payload
|
||||
* @param payload payload of the request
|
||||
* @param payload_len length in bytes of the request payload
|
||||
*
|
||||
* @return pointer to the request
|
||||
*
|
||||
* @warning the request pointer MUST NOT be NULL
|
||||
*/
|
||||
request_t *
|
||||
init_request(request_t * request, char *url, int action, int fmt,
|
||||
void *payload, int payload_len);
|
||||
|
||||
char *
|
||||
pack_request(request_t *request, int * size);
|
||||
|
||||
request_t *
|
||||
unpack_request(char * packet, int size, request_t * request);
|
||||
|
||||
char *
|
||||
pack_response(response_t *response, int * size);
|
||||
|
||||
response_t *
|
||||
unpack_response(char * packet, int size, response_t * response);
|
||||
|
||||
void
|
||||
free_req_resp_packet(char * packet);
|
||||
|
||||
char *
|
||||
wa_strdup(const char *str);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of _SHARED_UTILS_H_ */
|
103
core/app-framework/app-native-shared/bi-inc/wgl_shared_utils.h
Normal file
103
core/app-framework/app-native-shared/bi-inc/wgl_shared_utils.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_SHARED_UTILS_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_SHARED_UTILS_H
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
/* Object native function IDs */
|
||||
enum {
|
||||
OBJ_FUNC_ID_DEL,
|
||||
OBJ_FUNC_ID_DEL_ASYNC,
|
||||
OBJ_FUNC_ID_CLEAN,
|
||||
OBJ_FUNC_ID_SET_EVT_CB,
|
||||
OBJ_FUNC_ID_ALIGN,
|
||||
|
||||
/* Number of functions */
|
||||
_OBJ_FUNC_ID_NUM,
|
||||
};
|
||||
|
||||
/* Button native function IDs */
|
||||
enum {
|
||||
BTN_FUNC_ID_CREATE,
|
||||
BTN_FUNC_ID_SET_TOGGLE,
|
||||
BTN_FUNC_ID_SET_STATE,
|
||||
BTN_FUNC_ID_TOGGLE,
|
||||
BTN_FUNC_ID_SET_INK_IN_TIME,
|
||||
BTN_FUNC_ID_SET_INK_WAIT_TIME,
|
||||
BTN_FUNC_ID_SET_INK_OUT_TIME,
|
||||
BTN_FUNC_ID_GET_STATE,
|
||||
BTN_FUNC_ID_GET_TOGGLE,
|
||||
BTN_FUNC_ID_GET_INK_IN_TIME,
|
||||
BTN_FUNC_ID_GET_INK_WAIT_TIME,
|
||||
BTN_FUNC_ID_GET_INK_OUT_TIME,
|
||||
/* Number of functions */
|
||||
_BTN_FUNC_ID_NUM,
|
||||
};
|
||||
|
||||
/* Check box native function IDs */
|
||||
enum {
|
||||
CB_FUNC_ID_CREATE,
|
||||
CB_FUNC_ID_SET_TEXT,
|
||||
CB_FUNC_ID_SET_STATIC_TEXT,
|
||||
CB_FUNC_ID_GET_TEXT,
|
||||
CB_FUNC_ID_GET_TEXT_LENGTH,
|
||||
|
||||
/* Number of functions */
|
||||
_CB_FUNC_ID_NUM,
|
||||
};
|
||||
|
||||
/* List native function IDs */
|
||||
enum {
|
||||
LIST_FUNC_ID_CREATE,
|
||||
LIST_FUNC_ID_ADD_BTN,
|
||||
|
||||
/* Number of functions */
|
||||
_LIST_FUNC_ID_NUM,
|
||||
};
|
||||
|
||||
/* Label native function IDs */
|
||||
enum {
|
||||
LABEL_FUNC_ID_CREATE,
|
||||
LABEL_FUNC_ID_SET_TEXT,
|
||||
LABEL_FUNC_ID_SET_ARRAY_TEXT,
|
||||
LABEL_FUNC_ID_SET_STATIC_TEXT,
|
||||
LABEL_FUNC_ID_SET_LONG_MODE,
|
||||
LABEL_FUNC_ID_SET_ALIGN,
|
||||
LABEL_FUNC_ID_SET_RECOLOR,
|
||||
LABEL_FUNC_ID_SET_BODY_DRAW,
|
||||
LABEL_FUNC_ID_SET_ANIM_SPEED,
|
||||
LABEL_FUNC_ID_SET_TEXT_SEL_START,
|
||||
LABEL_FUNC_ID_SET_TEXT_SEL_END,
|
||||
LABEL_FUNC_ID_GET_TEXT,
|
||||
LABEL_FUNC_ID_GET_TEXT_LENGTH,
|
||||
LABEL_FUNC_ID_GET_LONG_MODE,
|
||||
LABEL_FUNC_ID_GET_ALIGN,
|
||||
LABEL_FUNC_ID_GET_RECOLOR,
|
||||
LABEL_FUNC_ID_GET_BODY_DRAW,
|
||||
LABEL_FUNC_ID_GET_ANIM_SPEED,
|
||||
LABEL_FUNC_ID_GET_LETTER_POS,
|
||||
LABEL_FUNC_ID_GET_TEXT_SEL_START,
|
||||
LABEL_FUNC_ID_GET_TEXT_SEL_END,
|
||||
LABEL_FUNC_ID_INS_TEXT,
|
||||
LABEL_FUNC_ID_CUT_TEXT,
|
||||
/* Number of functions */
|
||||
_LABEL_FUNC_ID_NUM,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_SHARED_UTILS_H */
|
15
core/app-framework/app-native-shared/native_interface.cmake
Normal file
15
core/app-framework/app-native-shared/native_interface.cmake
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
set (NATIVE_INTERFACE_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
include_directories(${NATIVE_INTERFACE_DIR})
|
||||
|
||||
|
||||
file (GLOB_RECURSE source_all ${NATIVE_INTERFACE_DIR}/*.c)
|
||||
|
||||
set (NATIVE_INTERFACE_SOURCE ${source_all})
|
||||
|
||||
set (WASM_APP_BI_INC_DIR "${NATIVE_INTERFACE_DIR}/bi-inc")
|
||||
LIST (APPEND RUNTIME_LIB_HEADER_LIST "${NATIVE_INTERFACE_DIR}/native_interface.h")
|
||||
|
15
core/app-framework/app-native-shared/native_interface.h
Normal file
15
core/app-framework/app-native-shared/native_interface.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _NATIVE_INTERFACE_H_
|
||||
#define _NATIVE_INTERFACE_H_
|
||||
|
||||
/* Note: the bh_plaform.h is the only head file separately
|
||||
implemented by both [app] and [native] worlds */
|
||||
#include "bh_platform.h"
|
||||
|
||||
|
||||
#endif /* end of _NATIVE_INTERFACE_H */
|
||||
|
413
core/app-framework/app-native-shared/restful_utils.c
Normal file
413
core/app-framework/app-native-shared/restful_utils.c
Normal file
|
@ -0,0 +1,413 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bi-inc/shared_utils.h"
|
||||
|
||||
/* Serialization of request and response message
|
||||
*
|
||||
* Choices:
|
||||
* We considered a few options:
|
||||
* 1. coap
|
||||
* 2. flatbuffer
|
||||
* 3. cbor
|
||||
* 4. attr-containers of our own
|
||||
* 5. customized serialization for request/response
|
||||
*
|
||||
* Now we choose the #5 mainly because we need to quickly get the URL for dispatching
|
||||
* and sometimes we want to change the URL in the original packet. the request format:
|
||||
* fixed part: version: (1 byte), code (1 byte), fmt(2 byte), mid (4 bytes), sender_id(4 bytes), url_len(2 bytes), payload_len(4bytes)
|
||||
* dynamic part: url (bytes in url_len), payload
|
||||
*
|
||||
* response format:
|
||||
* fixed part: (1 byte), code (1 byte), fmt(2 byte), mid (4 bytes), sender_id(4 bytes), payload_len(4bytes)
|
||||
* dynamic part: payload
|
||||
*/
|
||||
#define REQUES_PACKET_VER 1
|
||||
#define REQUEST_PACKET_FIX_PART_LEN 18
|
||||
#define REQUEST_PACKET_URL_OFFSET REQUEST_PACKET_FIX_PART_LEN
|
||||
#define REQUEST_PACKET_URL_LEN *((uint16*)( (char*) buffer + 12))) //!!! to ensure little endian
|
||||
#define REQUEST_PACKET_PAYLOAD_LEN *((uint32*)( (char*) buffer + 14))) //!!! to ensure little endian
|
||||
#define REQUEST_PACKET_URL(buffer) ((char*) buffer + REQUEST_PACKET_URL_OFFSET)
|
||||
#define REQUEST_PACKET_PAYLOAD(buffer) ((char*) buffer + REQUEST_PACKET_URL_OFFSET + REQUEST_PACKET_URL_LEN(buffer))
|
||||
|
||||
#define RESPONSE_PACKET_FIX_PART_LEN 16
|
||||
|
||||
char * pack_request(request_t *request, int * size)
|
||||
{
|
||||
int url_len = strlen(request->url) + 1;
|
||||
int len = REQUEST_PACKET_FIX_PART_LEN + url_len + request->payload_len;
|
||||
char * packet = (char*) WA_MALLOC(len);
|
||||
if (packet == NULL)
|
||||
return NULL;
|
||||
|
||||
// TODO: ensure little endian for words and dwords
|
||||
*packet = REQUES_PACKET_VER;
|
||||
*((uint8*) (packet + 1)) = request->action;
|
||||
*((uint16*) (packet + 2)) = htons(request->fmt);
|
||||
*((uint32*) (packet + 4)) = htonl(request->mid);
|
||||
*((uint32*) (packet + 8)) = htonl(request->sender);
|
||||
*((uint16*) (packet + 12)) = htons(url_len);
|
||||
*((uint32*) (packet + 14)) = htonl(request->payload_len);
|
||||
strcpy(packet + REQUEST_PACKET_URL_OFFSET, request->url);
|
||||
memcpy(packet + REQUEST_PACKET_URL_OFFSET + url_len, request->payload,
|
||||
request->payload_len);
|
||||
|
||||
*size = len;
|
||||
return packet;
|
||||
}
|
||||
|
||||
void free_req_resp_packet(char * packet)
|
||||
{
|
||||
WA_FREE(packet);
|
||||
}
|
||||
|
||||
request_t * unpack_request(char * packet, int size, request_t * request)
|
||||
{
|
||||
if (*packet != REQUES_PACKET_VER) {
|
||||
return NULL;
|
||||
}
|
||||
if (size < REQUEST_PACKET_FIX_PART_LEN) {
|
||||
return NULL;
|
||||
}
|
||||
uint16 url_len = ntohs(*((uint16*) (packet + 12)));
|
||||
uint32 payload_len = ntohl(*((uint32*) (packet + 14)));
|
||||
|
||||
if (size != ( REQUEST_PACKET_FIX_PART_LEN + url_len + payload_len)) {
|
||||
return NULL;
|
||||
}
|
||||
if (*(packet + REQUEST_PACKET_FIX_PART_LEN + url_len - 1) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
request->action = *((uint8*) (packet + 1));
|
||||
request->fmt = ntohs(*((uint16*) (packet + 2)));
|
||||
request->mid = ntohl(*((uint32*) (packet + 4)));
|
||||
request->sender = ntohl(*((uint32*) (packet + 8)));
|
||||
request->payload_len = payload_len;
|
||||
request->url = REQUEST_PACKET_URL(packet);
|
||||
if (payload_len > 0)
|
||||
request->payload = packet + REQUEST_PACKET_URL_OFFSET + url_len;
|
||||
else
|
||||
request->payload = NULL;
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
char * pack_response(response_t *response, int * size)
|
||||
{
|
||||
int len = RESPONSE_PACKET_FIX_PART_LEN + response->payload_len;
|
||||
char * packet = (char*) WA_MALLOC(len);
|
||||
if (packet == NULL)
|
||||
return NULL;
|
||||
|
||||
// TODO: ensure little endian for words and dwords
|
||||
*packet = REQUES_PACKET_VER;
|
||||
*((uint8*) (packet + 1)) = response->status;
|
||||
*((uint16*) (packet + 2)) = htons(response->fmt);
|
||||
*((uint32*) (packet + 4)) = htonl(response->mid);
|
||||
*((uint32*) (packet + 8)) = htonl(response->reciever);
|
||||
*((uint32*) (packet + 12)) = htonl(response->payload_len);
|
||||
memcpy(packet + RESPONSE_PACKET_FIX_PART_LEN, response->payload,
|
||||
response->payload_len);
|
||||
|
||||
*size = len;
|
||||
return packet;
|
||||
}
|
||||
|
||||
response_t * unpack_response(char * packet, int size, response_t * response)
|
||||
{
|
||||
if (*packet != REQUES_PACKET_VER)
|
||||
return NULL;
|
||||
if (size < RESPONSE_PACKET_FIX_PART_LEN)
|
||||
return NULL;
|
||||
uint32 payload_len = ntohl(*((uint32*) (packet + 12)));
|
||||
if (size != ( RESPONSE_PACKET_FIX_PART_LEN + payload_len))
|
||||
return NULL;
|
||||
|
||||
response->status = *((uint8*) (packet + 1));
|
||||
response->fmt = ntohs(*((uint16*) (packet + 2)));
|
||||
response->mid = ntohl(*((uint32*) (packet + 4)));
|
||||
response->reciever = ntohl(*((uint32*) (packet + 8)));
|
||||
response->payload_len = payload_len;
|
||||
if (payload_len > 0)
|
||||
response->payload = packet + RESPONSE_PACKET_FIX_PART_LEN;
|
||||
else
|
||||
response->payload = NULL;
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
request_t *clone_request(request_t *request)
|
||||
{
|
||||
/* deep clone */
|
||||
request_t *req = (request_t *) WA_MALLOC(sizeof(request_t));
|
||||
if (req == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
req->action = request->action;
|
||||
req->fmt = request->fmt;
|
||||
req->url = wa_strdup(request->url);
|
||||
req->sender = request->sender;
|
||||
req->mid = request->mid;
|
||||
|
||||
if (req->url == NULL)
|
||||
goto fail;
|
||||
|
||||
req->payload_len = request->payload_len;
|
||||
|
||||
if (request->payload_len) {
|
||||
req->payload = (char *) WA_MALLOC(request->payload_len);
|
||||
if (!req->payload)
|
||||
goto fail;
|
||||
memcpy(req->payload, request->payload, request->payload_len);
|
||||
} else {
|
||||
// when payload_len is 0, the payload may be used for carrying some handle or integer
|
||||
req->payload = request->payload;
|
||||
}
|
||||
|
||||
return req;
|
||||
|
||||
fail:
|
||||
request_cleaner(req);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void request_cleaner(request_t *request)
|
||||
{
|
||||
if (request->url != NULL)
|
||||
WA_FREE(request->url);
|
||||
if (request->payload != NULL && request->payload_len > 0)
|
||||
WA_FREE(request->payload);
|
||||
|
||||
WA_FREE(request);
|
||||
}
|
||||
|
||||
void response_cleaner(response_t * response)
|
||||
{
|
||||
if (response->payload != NULL && response->payload_len > 0)
|
||||
WA_FREE(response->payload);
|
||||
|
||||
WA_FREE(response);
|
||||
}
|
||||
|
||||
response_t * clone_response(response_t * response)
|
||||
{
|
||||
response_t *clone = (response_t *) WA_MALLOC(sizeof(response_t));
|
||||
if (clone == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(clone, 0, sizeof(*clone));
|
||||
clone->fmt = response->fmt;
|
||||
clone->mid = response->mid;
|
||||
clone->status = response->status;
|
||||
clone->reciever = response->reciever;
|
||||
clone->payload_len = response->payload_len;
|
||||
if (clone->payload_len) {
|
||||
clone->payload = (char *) WA_MALLOC(response->payload_len);
|
||||
if (!clone->payload)
|
||||
goto fail;
|
||||
memcpy(clone->payload, response->payload, response->payload_len);
|
||||
} else {
|
||||
// when payload_len is 0, the payload may be used for carrying some handle or integer
|
||||
clone->payload = response->payload;
|
||||
}
|
||||
return clone;
|
||||
|
||||
fail:
|
||||
response_cleaner(clone);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
response_t * set_response(response_t * response, int status, int fmt,
|
||||
const char *payload, int payload_len)
|
||||
{
|
||||
response->payload = (void *)payload;
|
||||
response->payload_len = payload_len;
|
||||
response->status = status;
|
||||
response->fmt = fmt;
|
||||
return response;
|
||||
}
|
||||
|
||||
response_t * make_response_for_request(request_t * request,
|
||||
response_t * response)
|
||||
{
|
||||
response->mid = request->mid;
|
||||
response->reciever = request->sender;
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
request_t * init_request(request_t * request, char *url, int action, int fmt,
|
||||
void *payload, int payload_len)
|
||||
{
|
||||
static unsigned int mid = 0;
|
||||
request->url = url;
|
||||
request->action = action;
|
||||
request->fmt = fmt;
|
||||
request->payload = payload;
|
||||
request->payload_len = payload_len;
|
||||
request->mid = ++mid;
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
/*
|
||||
check if the "url" is starting with "leading_str"
|
||||
return: 0 - not match; >0 - the offset of matched url, include any "/" at the end
|
||||
notes:
|
||||
1. it ensures the leading_str "/abc" can pass "/abc/cde" and "/abc/, but fail "/ab" and "/abcd".
|
||||
leading_str "/abc/" can pass "/abc"
|
||||
2. it omit the '/' at the first char
|
||||
3. it ensure the leading_str "/abc" can pass "/abc?cde
|
||||
*/
|
||||
|
||||
int check_url_start(const char* url, int url_len, const char * leading_str)
|
||||
{
|
||||
int offset = 0;
|
||||
if (*leading_str == '/')
|
||||
leading_str++;
|
||||
if (url_len > 0 && *url == '/') {
|
||||
url_len--;
|
||||
url++;
|
||||
offset++;
|
||||
}
|
||||
|
||||
int len = strlen(leading_str);
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
// ensure leading_str not end with "/"
|
||||
if (leading_str[len - 1] == '/') {
|
||||
len--;
|
||||
if (len == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// equal length
|
||||
if (url_len == len) {
|
||||
if (memcmp(url, leading_str, url_len) == 0) {
|
||||
return (offset + len);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (url_len < len)
|
||||
return 0;
|
||||
|
||||
else if (memcmp(url, leading_str, len) != 0)
|
||||
return 0;
|
||||
|
||||
else if (url[len] != '/' && url[len] != '?')
|
||||
return 0;
|
||||
else
|
||||
return (offset + len + 1);
|
||||
}
|
||||
|
||||
// * @pattern:
|
||||
// * sample 1: /abcd, match /abcd only
|
||||
// * sample 2: /abcd/ match match "/abcd" and "/abcd/*"
|
||||
// * sample 3: /abcd*, match any url started with "/abcd"
|
||||
// * sample 4: /abcd/*, exclude "/abcd"
|
||||
|
||||
bool match_url(char * pattern, char * matched)
|
||||
{
|
||||
if (*pattern == '/')
|
||||
pattern++;
|
||||
if (*matched == '/')
|
||||
matched++;
|
||||
|
||||
int matched_len = strlen(matched);
|
||||
if (matched_len == 0)
|
||||
return false;
|
||||
|
||||
if (matched[matched_len - 1] == '/') {
|
||||
matched_len--;
|
||||
if (matched_len == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
int len = strlen(pattern);
|
||||
if (len == 0)
|
||||
return false;
|
||||
|
||||
if (pattern[len - 1] == '/') {
|
||||
len--;
|
||||
if (strncmp(pattern, matched, len) != 0)
|
||||
return false;
|
||||
|
||||
if (len == matched_len)
|
||||
return true;
|
||||
|
||||
if (matched_len > len && matched[len] == '/')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
} else if (pattern[len - 1] == '*') {
|
||||
if (pattern[len - 2] == '/') {
|
||||
if (strncmp(pattern, matched, len - 1) == 0)
|
||||
return true;
|
||||
|
||||
else
|
||||
return false;
|
||||
} else {
|
||||
return (strncmp(pattern, matched, len - 1) == 0);
|
||||
}
|
||||
} else {
|
||||
return (strcmp(pattern, matched) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* get the value of the key from following format buffer:
|
||||
* key1=value1;key2=value2;key3=value3
|
||||
*/
|
||||
char * find_key_value(char * buffer, int buffer_len, char * key, char * value,
|
||||
int value_len, char delimiter)
|
||||
{
|
||||
char * p = buffer;
|
||||
int remaining = buffer_len;
|
||||
int key_len = strlen(key);
|
||||
|
||||
while (*p != 0 && remaining > 0) {
|
||||
while (*p == ' ' || *p == delimiter) {
|
||||
p++;
|
||||
remaining--;
|
||||
}
|
||||
|
||||
if (remaining <= key_len)
|
||||
return NULL;
|
||||
|
||||
// find the key
|
||||
if (0 == strncmp(p, key, key_len) && p[key_len] == '=') {
|
||||
p += (key_len + 1);
|
||||
remaining -= (key_len + 1);
|
||||
char * v = value;
|
||||
memset(value, 0, value_len);
|
||||
value_len--; // ensure last char is 0
|
||||
while (*p != delimiter && remaining > 0 && value_len > 0) {
|
||||
*v++ = *p++;
|
||||
remaining--;
|
||||
value_len--;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// goto next key
|
||||
while (*p != delimiter && remaining > 0) {
|
||||
p++;
|
||||
remaining--;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
39
core/app-framework/app_ext_lib_export.c
Normal file
39
core/app-framework/app_ext_lib_export.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "lib_export.h"
|
||||
|
||||
#ifdef APP_FRAMEWORK_SENSOR
|
||||
#include "sensor_native_api.h"
|
||||
#endif
|
||||
|
||||
#ifdef APP_FRAMEWORK_CONNECTION
|
||||
#include "connection_native_api.h"
|
||||
#endif
|
||||
|
||||
#ifdef APP_FRAMEWORK_WGL
|
||||
#include "gui_native_api.h"
|
||||
#endif
|
||||
|
||||
/* More header file here */
|
||||
|
||||
static NativeSymbol extended_native_symbol_defs[] = {
|
||||
#ifdef APP_FRAMEWORK_SENSOR
|
||||
#include "runtime_sensor.inl"
|
||||
#endif
|
||||
|
||||
#ifdef APP_FRAMEWORK_CONNECTION
|
||||
#include "connection.inl"
|
||||
#endif
|
||||
|
||||
#ifdef APP_FRAMEWORK_WGL
|
||||
#include "wamr_gui.inl"
|
||||
#endif
|
||||
|
||||
/* More inl file here */
|
||||
};
|
||||
|
||||
int
|
||||
get_ext_lib_export_apis(NativeSymbol **p_ext_lib_apis)
|
||||
{
|
||||
*p_ext_lib_apis = extended_native_symbol_defs;
|
||||
return sizeof(extended_native_symbol_defs) / sizeof(NativeSymbol);
|
||||
}
|
||||
|
89
core/app-framework/app_framework.cmake
Normal file
89
core/app-framework/app_framework.cmake
Normal file
|
@ -0,0 +1,89 @@
|
|||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
|
||||
add_definitions (-DWASM_ENABLE_APP_FRAMEWORK=1)
|
||||
|
||||
set (APP_FRAMEWORK_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
|
||||
LIST (APPEND WASM_APP_LIB_SOURCE_ALL ${CMAKE_CURRENT_LIST_DIR}/app_ext_lib_export.c)
|
||||
endif()
|
||||
|
||||
# app-native-shared and base are required
|
||||
include (${APP_FRAMEWORK_ROOT_DIR}/app-native-shared/native_interface.cmake)
|
||||
LIST (APPEND WASM_APP_SOURCE_ALL ${NATIVE_INTERFACE_SOURCE})
|
||||
|
||||
MACRO(SUBDIRLIST result curdir)
|
||||
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
|
||||
SET(dirlist "")
|
||||
FOREACH(child ${children})
|
||||
IF(IS_DIRECTORY ${curdir}/${child})
|
||||
LIST(APPEND dirlist ${child})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
SET(${result} ${dirlist})
|
||||
ENDMACRO()
|
||||
|
||||
function (add_module_native arg)
|
||||
message ("Add native module ${ARGV0}")
|
||||
include (${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/wasm_lib.cmake)
|
||||
|
||||
file (GLOB header
|
||||
${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/*.h
|
||||
${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/*.inl
|
||||
)
|
||||
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
|
||||
set (RUNTIME_LIB_HEADER_LIST ${RUNTIME_LIB_HEADER_LIST} PARENT_SCOPE)
|
||||
|
||||
LIST (APPEND WASM_APP_LIB_SOURCE_ALL ${WASM_APP_LIB_CURRENT_SOURCE})
|
||||
set (WASM_APP_LIB_SOURCE_ALL ${WASM_APP_LIB_SOURCE_ALL} PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
function (add_module_app arg)
|
||||
message ("Add app module ${ARGV0}")
|
||||
include (${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/app/wasm_app.cmake)
|
||||
|
||||
LIST (APPEND WASM_APP_WA_INC_DIR_LIST "${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/app/wa-inc")
|
||||
set (WASM_APP_WA_INC_DIR_LIST ${WASM_APP_WA_INC_DIR_LIST} PARENT_SCOPE)
|
||||
|
||||
LIST (APPEND WASM_APP_NAME ${ARGV0})
|
||||
set (WASM_APP_NAME ${WASM_APP_NAME} PARENT_SCOPE)
|
||||
|
||||
LIST (APPEND WASM_APP_SOURCE_ALL ${WASM_APP_CURRENT_SOURCE})
|
||||
set (WASM_APP_SOURCE_ALL ${WASM_APP_SOURCE_ALL} PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
if ("${WAMR_BUILD_APP_LIST}" STREQUAL "WAMR_APP_BUILD_ALL")
|
||||
# add all modules under this folder
|
||||
SUBDIRLIST(SUBDIRS ${APP_FRAMEWORK_ROOT_DIR})
|
||||
|
||||
FOREACH(subdir ${SUBDIRS})
|
||||
if ("${subdir}" STREQUAL "app-native-shared")
|
||||
continue()
|
||||
endif ()
|
||||
if ("${subdir}" STREQUAL "template")
|
||||
continue()
|
||||
endif ()
|
||||
|
||||
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
|
||||
add_module_native (${subdir})
|
||||
else ()
|
||||
add_module_app (${subdir})
|
||||
endif ()
|
||||
ENDFOREACH()
|
||||
|
||||
else ()
|
||||
# add each module in the list
|
||||
FOREACH (dir IN LISTS WAMR_BUILD_APP_LIST)
|
||||
string(REPLACE "WAMR_APP_BUILD_" "" dir ${dir})
|
||||
string(TOLOWER ${dir} dir)
|
||||
|
||||
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
|
||||
add_module_native (${dir})
|
||||
else ()
|
||||
add_module_app (${dir})
|
||||
endif ()
|
||||
ENDFOREACH (dir)
|
||||
|
||||
endif()
|
81
core/app-framework/base/app/bh_platform.c
Normal file
81
core/app-framework/base/app/bh_platform.c
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "bh_platform.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static bool is_little_endian()
|
||||
{
|
||||
long i = 0x01020304;
|
||||
unsigned char* c = (unsigned char*) &i;
|
||||
return (*c == 0x04) ? true : false;
|
||||
}
|
||||
|
||||
static void swap32(uint8* pData)
|
||||
{
|
||||
uint8 value = *pData;
|
||||
*pData = *(pData + 3);
|
||||
*(pData + 3) = value;
|
||||
|
||||
value = *(pData + 1);
|
||||
*(pData + 1) = *(pData + 2);
|
||||
*(pData + 2) = value;
|
||||
}
|
||||
|
||||
static void swap16(uint8* pData)
|
||||
{
|
||||
uint8 value = *pData;
|
||||
*(pData) = *(pData + 1);
|
||||
*(pData + 1) = value;
|
||||
}
|
||||
|
||||
uint32 htonl(uint32 value)
|
||||
{
|
||||
uint32 ret;
|
||||
if (is_little_endian()) {
|
||||
ret = value;
|
||||
swap32((uint8*) &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
uint32 ntohl(uint32 value)
|
||||
{
|
||||
return htonl(value);
|
||||
}
|
||||
|
||||
uint16 htons(uint16 value)
|
||||
{
|
||||
uint16 ret;
|
||||
if (is_little_endian()) {
|
||||
ret = value;
|
||||
swap16((uint8 *)&ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16 ntohs(uint16 value)
|
||||
{
|
||||
return htons(value);
|
||||
}
|
||||
|
||||
char *wa_strdup(const char *s)
|
||||
{
|
||||
char *s1 = NULL;
|
||||
if (s && (s1 = WA_MALLOC(strlen(s) + 1)))
|
||||
memcpy(s1, s, strlen(s) + 1);
|
||||
return s1;
|
||||
}
|
62
core/app-framework/base/app/bh_platform.h
Executable file
62
core/app-framework/base/app/bh_platform.h
Executable file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_
|
||||
#define DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef char int8;
|
||||
typedef unsigned short uint16;
|
||||
typedef short int16;
|
||||
typedef unsigned int uint32;
|
||||
typedef int int32;
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL ((void*) 0)
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
// all wasm-app<->native shared source files should use WA_MALLOC/WA_FREE.
|
||||
// they will be mapped to different implementations in each side
|
||||
#ifndef WA_MALLOC
|
||||
#define WA_MALLOC malloc
|
||||
#endif
|
||||
|
||||
#ifndef WA_FREE
|
||||
#define WA_FREE free
|
||||
#endif
|
||||
|
||||
|
||||
uint32 htonl(uint32 value);
|
||||
uint32 ntohl(uint32 value);
|
||||
uint16 htons(uint16 value);
|
||||
uint16 ntohs(uint16 value);
|
||||
|
||||
|
||||
// We are not worried for the WASM world since the sandbox will catch it.
|
||||
#define bh_memcpy_s(dst, dst_len, src, src_len) memcpy(dst, src, src_len)
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define bh_assert(v) (void)0
|
||||
#else
|
||||
#define bh_assert(v) do { \
|
||||
if (!(v)) { \
|
||||
int _count; \
|
||||
printf("ASSERTION FAILED: %s, at %s, line %d",\
|
||||
#v, __FILE__, __LINE__); \
|
||||
_count = printf("\n"); \
|
||||
printf("%d\n", _count / (_count - 1)); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif /* DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_ */
|
32
core/app-framework/base/app/req_resp_api.h
Normal file
32
core/app-framework/base/app/req_resp_api.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _REQ_RESP_API_H_
|
||||
#define _REQ_RESP_API_H_
|
||||
|
||||
#include "bh_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
bool
|
||||
wasm_response_send(const char *buf, int size);
|
||||
|
||||
void
|
||||
wasm_register_resource(const char *url);
|
||||
|
||||
void
|
||||
wasm_post_request(const char *buf, int size);
|
||||
|
||||
void
|
||||
wasm_sub_event(const char *url);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* end of _REQ_RESP_API_H_ */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user