Implement WAMR-IDE with vscode extension (#943)
Implement WAMR-IDE with vscode extension to enable developing WebAssembly applications with coding, building, running and debugging support. Support both Linux and Windows, and only support putting all the tools in a docker image, e.g. wasi-sdk, wamrc, iwasm and so on. Co-authored-by: Wang Ning <justdoitwn@163.com>
This commit is contained in:
@ -0,0 +1,4 @@
|
||||
# move unnecessary files here to save build time cost and image size
|
||||
*.md
|
||||
*.sh
|
||||
*.bat
|
||||
@ -0,0 +1,63 @@
|
||||
# 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
|
||||
FROM gcc:9.3.0 AS BASE
|
||||
|
||||
## set work directory
|
||||
WORKDIR /root/
|
||||
|
||||
COPY resource /root/
|
||||
|
||||
## set compilation environment for wamrc
|
||||
# - cmake
|
||||
# - wasi-sdk
|
||||
# - wamr-sdk
|
||||
|
||||
## - 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
|
||||
|
||||
## - download wasi-sdk with wget and set up to /opt/wasi-sdk
|
||||
RUN wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz \
|
||||
&& tar -zxvf wasi-sdk-12.0-linux.tar.gz \
|
||||
&& rm -f wasi-sdk-12.0-linux.tar.gz
|
||||
|
||||
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 \
|
||||
# - build wamrc
|
||||
&& 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/app \
|
||||
&& cp -r /root/wasm-micro-runtime/wamr-sdk/app/libc-builtin-sysroot /opt/wamr-sdk/app/ \
|
||||
# - remove the wamr repo to save the size
|
||||
&& rm -fr /root/wasm-micro-runtime
|
||||
|
||||
## STAGE 2
|
||||
FROM ubuntu:20.04
|
||||
RUN mkdir -p /opt/wasi-sdk \
|
||||
&& mkdir -p /opt/cmake \
|
||||
&& mkdir -p /opt/wamr-sdk/app
|
||||
|
||||
# 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 /root/wasi-sdk-12.0/ /opt/wasi-sdk/
|
||||
COPY --from=BASE /root/wamrc /root
|
||||
COPY --from=BASE /root/build_wasm.sh /root
|
||||
|
||||
RUN ln -s /opt/cmake/bin/cmake /usr/bin/cmake \
|
||||
&& ln -s /root/wamrc /usr/bin/wamrc
|
||||
RUN apt-get update && apt-get install make
|
||||
|
||||
WORKDIR /root
|
||||
71
test-tools/wamr-ide/WASM-Toolchain-Provider/Docker/README.md
Normal file
71
test-tools/wamr-ide/WASM-Toolchain-Provider/Docker/README.md
Normal file
@ -0,0 +1,71 @@
|
||||
# WASM Toolchain Provider Introduction
|
||||
|
||||
## Files on HOST
|
||||
|
||||
#### Dockerfile
|
||||
|
||||
- ubuntu : 20.04
|
||||
- set up the necessary toolchains
|
||||
- WASI-SDK (version: 12.0)
|
||||
- WAMR-SDK
|
||||
- repo: bytecode-alliance/wasm-micro-runtime
|
||||
- branch: main
|
||||
- LLVM (latest repo build)
|
||||
- CMake (version: 3.21.1)
|
||||
|
||||
#### build_docker_image.sh
|
||||
|
||||
- the script to build docker image for Linux platform
|
||||
- tag: 1.0
|
||||
|
||||
#### build_docker_image.bat
|
||||
|
||||
- the script to build docker image for windows platform
|
||||
- tag: 1.0
|
||||
|
||||
#### run_container.sh
|
||||
|
||||
- the script to start and run the docker container for Linux platform
|
||||
- mount `host directory` and `container directory`
|
||||
- temporally using `$(pwd)/host_mnt_test` in **host** and `/mnt` in **container**
|
||||
- set docker container name with `--name`
|
||||
- temporally set to _wasm-toolchain-ctr_
|
||||
|
||||
#### run_container.bat
|
||||
|
||||
- the script to start and run the docker container for windows platform
|
||||
|
||||
## Files inside docker
|
||||
|
||||
### `wamrc`
|
||||
|
||||
### `wasi-sdk`
|
||||
|
||||
# Build Docker Image
|
||||
|
||||
- Linux
|
||||
|
||||
```shell
|
||||
chmod +x resource/*
|
||||
./build_docker_image.sh
|
||||
```
|
||||
|
||||
- Windows
|
||||
|
||||
```shell
|
||||
./build_docker_image.bat
|
||||
```
|
||||
|
||||
# Run Docker Container
|
||||
|
||||
- Linux
|
||||
|
||||
```shell
|
||||
./run_container.sh
|
||||
```
|
||||
|
||||
- Windows
|
||||
|
||||
```shell
|
||||
./run_container.bat
|
||||
```
|
||||
@ -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-provider:1.0 .
|
||||
|
||||
@REM delete intermediate docker image
|
||||
sudo docker image prune -f
|
||||
@ -0,0 +1,10 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#!/bin/bash
|
||||
sudo docker pull gcc:9.3.0
|
||||
sudo docker pull ubuntu:20.04
|
||||
sudo docker build -t wasm-toolchain-provider:1.0 .
|
||||
|
||||
# delete intermediate docker image
|
||||
sudo docker image prune -f
|
||||
@ -0,0 +1,24 @@
|
||||
# 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++
|
||||
|
||||
if [ -d /mnt/build ];then
|
||||
rm -fr /mnt/build
|
||||
fi
|
||||
|
||||
mkdir -p /mnt/build
|
||||
cd /mnt/build/
|
||||
echo "========> compile wasm with wasi-sdk"
|
||||
cmake ../.wamr && make
|
||||
|
||||
echo && echo
|
||||
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
|
||||
@ -0,0 +1,16 @@
|
||||
@REM Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
@REM SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
@echo off
|
||||
|
||||
@REM # create mount directory on host
|
||||
|
||||
if not exist host_mnt (
|
||||
md host_mnt
|
||||
)
|
||||
|
||||
docker run -it ^
|
||||
-v %cd%\host_mnt:/mnt ^
|
||||
--name wasm-toolchain-provider-ctr ^
|
||||
wasm-toolchain-provider:1.0 ^
|
||||
/bin/bash
|
||||
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#!/bin/bash
|
||||
set -x
|
||||
|
||||
# create mount directory on host
|
||||
if [ ! -d host_mnt ];then
|
||||
mkdir host_mnt
|
||||
fi
|
||||
|
||||
sudo docker run --name=wasm-toolchain-provider-ctr \
|
||||
-it -v $(pwd)/host_mnt:/mnt \
|
||||
wasm-toolchain-provider:1.0 \
|
||||
/bin/bash
|
||||
Reference in New Issue
Block a user