Upgrade WAMR-IDE (#1313)
Upgrade WAMR-IDE: test-tools/wamr-ide folder - add `wamr-sdk` to include libc-builtin-sysroot header files - add `prettier` check and apply script in `package.json` - update `wasm-toolchain` dockerfile and resource - enhance `build | run | debug` process to clean up the container - enhance the change workspace - enhance `wasm` type project check before building, running and debugging - format the project_compilation.json - update documents
This commit is contained in:
4
test-tools/wamr-ide/WASM-Toolchain/Docker/.dockerignore
Normal file
4
test-tools/wamr-ide/WASM-Toolchain/Docker/.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
# remove unnecessary files here to save build time cost and image size
|
||||
*.md
|
||||
*.sh
|
||||
*.bat
|
||||
70
test-tools/wamr-ide/WASM-Toolchain/Docker/Dockerfile
Normal file
70
test-tools/wamr-ide/WASM-Toolchain/Docker/Dockerfile
Normal file
@ -0,0 +1,70 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
## Build docker image that consists of gcc, cmake, wasi-sdk & zephyr sdk
|
||||
FROM gcc:9.3.0 AS BASE
|
||||
|
||||
## set work directory
|
||||
WORKDIR /root/
|
||||
|
||||
COPY resource /root/
|
||||
|
||||
## - download cmake with wget and set up
|
||||
RUN wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.tar.gz \
|
||||
&& tar -zxvf cmake-3.21.1-linux-x86_64.tar.gz \
|
||||
&& rm -f cmake-3.21.1-linux-x86_64.tar.gz \
|
||||
&& mv cmake-3.21.1-linux-x86_64 /opt/cmake \
|
||||
&& ln -s /opt/cmake/bin/cmake /bin/cmake \
|
||||
&& apt-get install make
|
||||
|
||||
## set compilation environment for wamrc
|
||||
# - wamr repo
|
||||
# - cmake
|
||||
# - wasi-sdk
|
||||
# - wamr-sdk
|
||||
|
||||
## - download wasi-sdk with wget and set up to /opt/wasi-sdk
|
||||
RUN wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-14/wasi-sdk-14.0-linux.tar.gz \
|
||||
&& tar -zxvf wasi-sdk-14.0-linux.tar.gz \
|
||||
&& mv wasi-sdk-14.0 /opt/wasi-sdk/ \
|
||||
&& rm -f wasi-sdk-14.0-linux.tar.gz
|
||||
|
||||
## - clone wamr repo
|
||||
RUN git clone -b main --depth=1 https://github.com/bytecodealliance/wasm-micro-runtime.git \
|
||||
&& cd /root/wasm-micro-runtime/wamr-compiler \
|
||||
&& ./build_llvm.sh \
|
||||
&& cd /root/wasm-micro-runtime/wamr-compiler \
|
||||
&& mkdir build \
|
||||
&& cd build \
|
||||
&& cmake .. \
|
||||
&& make \
|
||||
# - copy the wamrc to /root
|
||||
&& cp /root/wasm-micro-runtime/wamr-compiler/build/wamrc /root/wamrc \
|
||||
&& mkdir -p /opt/wamr-sdk \
|
||||
&& cp -r /root/wasm-micro-runtime/wamr-sdk/app /opt/wamr-sdk/ \
|
||||
&& mv /root/wamr_toolchain.cmake /opt/wamr-sdk/app \
|
||||
# - remove the wamr repo to save the size
|
||||
&& rm -fr /root/wasm-micro-runtime
|
||||
|
||||
# ## STAGE 2
|
||||
FROM ubuntu:20.04
|
||||
ENV HOME_DIR=/home/wasm-toolchain
|
||||
|
||||
RUN mkdir -p /opt/wasi-sdk \
|
||||
&& mkdir -p /opt/cmake \
|
||||
&& mkdir -p /opt/wamr-sdk/app \
|
||||
&& mkdir -p /home/wasm-toolchain
|
||||
|
||||
# COPY files from BASE image
|
||||
COPY --from=BASE /opt/cmake/ /opt/cmake/
|
||||
COPY --from=BASE /opt/wamr-sdk/app/ /opt/wamr-sdk/app/
|
||||
COPY --from=BASE /opt/wasi-sdk /opt/wasi-sdk/
|
||||
COPY --from=BASE /root/wamrc ${HOME_DIR}
|
||||
COPY --from=BASE /root/build_wasm.sh ${HOME_DIR}
|
||||
|
||||
RUN ln -s /opt/cmake/bin/cmake /usr/bin/cmake \
|
||||
&& ln -s ${HOME_DIR}/wamrc /usr/bin/wamrc
|
||||
|
||||
RUN apt-get update && apt-get install make
|
||||
|
||||
WORKDIR ${HOME_DIR}
|
||||
19
test-tools/wamr-ide/WASM-Toolchain/Docker/README.md
Normal file
19
test-tools/wamr-ide/WASM-Toolchain/Docker/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
### Build Docker Image
|
||||
|
||||
- Linux
|
||||
|
||||
```shell
|
||||
chmod +x resource/*
|
||||
./build_docker_image.sh
|
||||
```
|
||||
|
||||
- Windows
|
||||
|
||||
```shell
|
||||
./build_docker_image.bat
|
||||
```
|
||||
|
||||
### Resource Details
|
||||
|
||||
- `Dockerflie` is the source file to build `wasm-debug-server` docker image.
|
||||
- `resource/build_wasm.sh` is the script to compile the wasm app with `wasi-sdk`.
|
||||
@ -0,0 +1,12 @@
|
||||
@REM Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
@REM SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
@echo off
|
||||
|
||||
@REM pull gcc and ubuntu image firstly no matter whether exist or not.
|
||||
docker pull gcc:9.3.0
|
||||
docker pull ubuntu:20.04
|
||||
docker build -t wasm-toolchain:1.0 .
|
||||
|
||||
@REM delete intermediate docker image
|
||||
docker image prune -f
|
||||
10
test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.sh
Executable file
10
test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.sh
Executable file
@ -0,0 +1,10 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#!/bin/bash
|
||||
docker pull gcc:9.3.0
|
||||
docker pull ubuntu:20.04
|
||||
docker build -t wasm-toolchain:1.0 .
|
||||
|
||||
# delete intermediate docker image
|
||||
docker image prune -f
|
||||
25
test-tools/wamr-ide/WASM-Toolchain/Docker/resource/build_wasm.sh
Executable file
25
test-tools/wamr-ide/WASM-Toolchain/Docker/resource/build_wasm.sh
Executable file
@ -0,0 +1,25 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#!/bin/bash
|
||||
export CC=/opt/wasi-sdk/bin/clang
|
||||
export CXX=/opt/wasi-sdk/bin/clang++
|
||||
|
||||
cd /mnt
|
||||
if [ -d build ];then
|
||||
rm -fr build
|
||||
fi
|
||||
|
||||
mkdir -p build && cd build
|
||||
echo "========> compile wasm with wasi-sdk"
|
||||
cmake -DWASI_SDK_DIR=/opt/wasi-sdk -DCMAKE_TOOLCHAIN_FILE=/opt/wamr-sdk/app/wamr_toolchain.cmake ../.wamr && make
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "========> compile wasm to AoT with wamrc"
|
||||
# target name will be provided:
|
||||
# - user input the target name in IDE
|
||||
# - generated wasm binary name will be set as user's input target name
|
||||
# - aot binary name should be the same as wasm binary name
|
||||
# - target name will be provided through 1st parameter
|
||||
wamrc -o $1.aot $1.wasm
|
||||
fi
|
||||
33
test-tools/wamr-ide/WASM-Toolchain/Docker/resource/wamr_toolchain.cmake
Executable file
33
test-tools/wamr-ide/WASM-Toolchain/Docker/resource/wamr_toolchain.cmake
Executable file
@ -0,0 +1,33 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
SET (CMAKE_SYSTEM_NAME Linux)
|
||||
SET (CMAKE_SYSTEM_PROCESSOR wasm32)
|
||||
SET (CMAKE_SYSROOT ${CMAKE_CURRENT_LIST_DIR}/libc-builtin-sysroot)
|
||||
|
||||
IF (NOT (DEFINED WASI_SDK_DIR OR DEFINED CACHE{WASI_SDK_DIR}))
|
||||
SET (WASI_SDK_DIR "/opt/wasi-sdk")
|
||||
ELSE ()
|
||||
MESSAGE (STATUS "WASI_SDK_DIR=${WASI_SDK_DIR}")
|
||||
LIST (APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES "WASI_SDK_DIR")
|
||||
ENDIF ()
|
||||
|
||||
|
||||
SET (CMAKE_C_FLAGS "-nostdlib" CACHE INTERNAL "")
|
||||
SET (CMAKE_C_COMPILER_TARGET "wasm32")
|
||||
SET (CMAKE_C_COMPILER "${WASI_SDK_DIR}/bin/clang")
|
||||
|
||||
SET (CMAKE_CXX_FLAGS "-nostdlib" CACHE INTERNAL "")
|
||||
SET (CMAKE_CXX_COMPILER_TARGET "wasm32")
|
||||
SET (CMAKE_CXX_COMPILER "${WASI_SDK_DIR}/bin/clang++")
|
||||
|
||||
SET (CMAKE_EXE_LINKER_FLAGS
|
||||
"-Wl,--no-entry,--fatal-warnings" CACHE INTERNAL "")
|
||||
|
||||
SET (CMAKE_LINKER "${WASI_SDK_DIR}/bin/wasm-ld" CACHE INTERNAL "")
|
||||
SET (CMAKE_AR "${WASI_SDK_DIR}/bin/llvm-ar" CACHE INTERNAL "")
|
||||
SET (CMAKE_NM "${WASI_SDK_DIR}/bin/llvm-nm" CACHE INTERNAL "")
|
||||
SET (CMAKE_OBJDUMP "${WASI_SDK_DIR}/bin/llvm-dwarfdump" CACHE INTERNAL "")
|
||||
SET (CMAKE_RANLIB "${WASI_SDK_DIR}/bin/llvm-ranlib" CACHE INTERNAL "")
|
||||
SET (CMAKE_EXE_LINKER_FLAGS
|
||||
"${CMAKE_EXE_LINKER_FLAGS},--allow-undefined-file=${CMAKE_SYSROOT}/share/defined-symbols.txt" CACHE INTERNAL "")
|
||||
Reference in New Issue
Block a user