dockerfile: move to repo root
This commit is contained in:
6
Makefile
6
Makefile
@ -1,8 +1,8 @@
|
|||||||
docker:
|
docker:
|
||||||
docker build -t wasm-base wasm-base
|
docker build -t wasm-base -f wasm-base.dockerfile .
|
||||||
|
|
||||||
run:
|
run:
|
||||||
docker run --rm -it wasm-base:latest /bin/bash
|
docker run --rm -it wasm-base:latest /usr/bin/fish
|
||||||
|
|
||||||
run-external:
|
run-external:
|
||||||
docker run --rm -it -v "./wasm-base/examples:/home/ubuntu/examples" wasm-base:latest /bin/bash
|
docker run --rm -it -v "./wasm-base/examples:/home/ubuntu/examples" wasm-base:latest /usr/bin/fish
|
||||||
|
|||||||
@ -3,13 +3,15 @@ FROM ubuntu:noble AS wamr-builder
|
|||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& DEBIAN_FRONTEND=noninteractive TZ=Europe/Berline apt-get install -y --no-install-recommends \
|
&& DEBIAN_FRONTEND=noninteractive TZ=Europe/Berline apt-get install -y --no-install-recommends \
|
||||||
build-essential \
|
build-essential \
|
||||||
busybox \
|
gcc-multilib \
|
||||||
git \
|
|
||||||
cmake \
|
|
||||||
ca-certificates \
|
|
||||||
g++-multilib \
|
g++-multilib \
|
||||||
libgcc-11-dev \
|
libgcc-11-dev \
|
||||||
lib32gcc-11-dev \
|
lib32gcc-11-dev \
|
||||||
|
libc6-dev-i386 \
|
||||||
|
busybox \
|
||||||
|
git \
|
||||||
|
ca-certificates \
|
||||||
|
cmake \
|
||||||
ccache \
|
ccache \
|
||||||
python3-minimal \
|
python3-minimal \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
@ -24,10 +26,12 @@ RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime \
|
|||||||
&& git checkout WAMR-2.4.4
|
&& git checkout WAMR-2.4.4
|
||||||
WORKDIR /wasm-micro-runtime
|
WORKDIR /wasm-micro-runtime
|
||||||
|
|
||||||
# Build WAMR iwasm (standalone interpreter)
|
# Build WAMR iwasm (vmcore standalone interpreter)
|
||||||
RUN cd product-mini/platforms/linux \
|
RUN cd product-mini/platforms/linux \
|
||||||
&& mkdir build_iwasm && cd build_iwasm \
|
&& mkdir build_iwasm && cd build_iwasm \
|
||||||
&& cmake \
|
&& cmake \
|
||||||
|
-DWAMR_BUILD_PLATFORM=linux \
|
||||||
|
-DWAMR_BUILD_TARGET=X86_64 \
|
||||||
-DWAMR_BUILD_AOT=0 \
|
-DWAMR_BUILD_AOT=0 \
|
||||||
-DWAMR_BUILD_WAMR_COMPILER=0 \
|
-DWAMR_BUILD_WAMR_COMPILER=0 \
|
||||||
-DWAMR_BUILD_INTERP=1 \
|
-DWAMR_BUILD_INTERP=1 \
|
||||||
@ -39,25 +43,13 @@ RUN cd product-mini/platforms/linux \
|
|||||||
.. \
|
.. \
|
||||||
&& make -j$(nproc)
|
&& make -j$(nproc)
|
||||||
|
|
||||||
# Build WAMR libiwasm (interpreter runtime)
|
|
||||||
RUN mkdir build_libiwasm && cd build_libiwasm \
|
|
||||||
&& cmake \
|
|
||||||
-DWAMR_BUILD_AOT=1 \
|
|
||||||
-DWAMR_BUILD_WAMR_COMPILER=0 \
|
|
||||||
-DWAMR_BUILD_INTERP=1 \
|
|
||||||
-DWAMR_BUILD_FAST_INTERP=0 \
|
|
||||||
-DWAMR_BUILD_JIT=0 \
|
|
||||||
-DWAMR_BUILD_FAST_JIT=0 \
|
|
||||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
|
||||||
-DWAMR_BUILD_LIBC_WASI=1 \
|
|
||||||
.. \
|
|
||||||
&& make -j$(nproc)
|
|
||||||
|
|
||||||
# Build WAMR wamrc (standalone compiler)
|
# Build WAMR wamrc (standalone compiler)
|
||||||
RUN cd wamr-compiler \
|
RUN cd wamr-compiler \
|
||||||
&& ./build_llvm.sh \
|
&& ./build_llvm.sh \
|
||||||
&& mkdir build_wamrc && cd build_wamrc \
|
&& mkdir build_wamrc && cd build_wamrc \
|
||||||
&& cmake \
|
&& cmake \
|
||||||
|
-DWAMR_BUILD_PLATFORM=linux \
|
||||||
|
-DWAMR_BUILD_TARGET=X86_64 \
|
||||||
-DWAMR_BUILD_AOT=0 \
|
-DWAMR_BUILD_AOT=0 \
|
||||||
-DWAMR_BUILD_WAMR_COMPILER=1 \
|
-DWAMR_BUILD_WAMR_COMPILER=1 \
|
||||||
-DWAMR_BUILD_INTERP=0 \
|
-DWAMR_BUILD_INTERP=0 \
|
||||||
@ -69,11 +61,30 @@ RUN cd wamr-compiler \
|
|||||||
.. \
|
.. \
|
||||||
&& make -j$(nproc)
|
&& make -j$(nproc)
|
||||||
|
|
||||||
# Build WAMR libvmlib (compiler runtime)
|
# Build WAMR libvmlib (compiler runtime - to compile wasm modules embedded in a native application)
|
||||||
RUN cd wamr-compiler \
|
RUN cd wamr-compiler \
|
||||||
&& ./build_llvm.sh \
|
&& ./build_llvm.sh \
|
||||||
|
# && ./build_llvm.sh --extra-cmake-flags "-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_EXE_LINKER_FLAGS=-m32 -lstdc++" \
|
||||||
&& mkdir build_libvmlib && cd build_libvmlib \
|
&& mkdir build_libvmlib && cd build_libvmlib \
|
||||||
&& cmake \
|
&& cmake \
|
||||||
|
-DWAMR_BUILD_PLATFORM=linux \
|
||||||
|
-DWAMR_BUILD_TARGET=X86_64 \
|
||||||
|
-DWAMR_BUILD_AOT=1 \
|
||||||
|
-DWAMR_BUILD_WAMR_COMPILER=0 \
|
||||||
|
-DWAMR_BUILD_INTERP=0 \
|
||||||
|
-DWAMR_BUILD_FAST_INTERP=0 \
|
||||||
|
-DWAMR_BUILD_JIT=0 \
|
||||||
|
-DWAMR_BUILD_FAST_JIT=0 \
|
||||||
|
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||||
|
-DWAMR_BUILD_LIBC_WASI=0 \
|
||||||
|
.. \
|
||||||
|
&& make -j$(nproc)
|
||||||
|
|
||||||
|
# Build WAMR libiwasm (vmcore interpreter runtime - to run wasm modules embedded in a native application)
|
||||||
|
RUN mkdir build_libiwasm && cd build_libiwasm \
|
||||||
|
&& cmake \
|
||||||
|
-DWAMR_BUILD_PLATFORM=linux \
|
||||||
|
-DWAMR_BUILD_TARGET=X86_64 \
|
||||||
-DWAMR_BUILD_AOT=1 \
|
-DWAMR_BUILD_AOT=1 \
|
||||||
-DWAMR_BUILD_WAMR_COMPILER=0 \
|
-DWAMR_BUILD_WAMR_COMPILER=0 \
|
||||||
-DWAMR_BUILD_INTERP=1 \
|
-DWAMR_BUILD_INTERP=1 \
|
||||||
@ -81,7 +92,7 @@ RUN cd wamr-compiler \
|
|||||||
-DWAMR_BUILD_JIT=0 \
|
-DWAMR_BUILD_JIT=0 \
|
||||||
-DWAMR_BUILD_FAST_JIT=0 \
|
-DWAMR_BUILD_FAST_JIT=0 \
|
||||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||||
-DWAMR_BUILD_LIBC_WASI=1 \
|
-DWAMR_BUILD_LIBC_WASI=0 \
|
||||||
.. \
|
.. \
|
||||||
&& make -j$(nproc)
|
&& make -j$(nproc)
|
||||||
|
|
||||||
@ -91,13 +102,16 @@ FROM ghcr.io/webassembly/wasi-sdk:wasi-sdk-29
|
|||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& DEBIAN_FRONTEND=noninteractive TZ=Europe/Berline apt-get install -y --no-install-recommends \
|
&& DEBIAN_FRONTEND=noninteractive TZ=Europe/Berline apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
gcc-multilib \
|
||||||
|
busybox \
|
||||||
git \
|
git \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
wget \
|
wget \
|
||||||
neovim \
|
neovim \
|
||||||
ranger \
|
ranger \
|
||||||
wabt \
|
wabt \
|
||||||
busybox \
|
fish \
|
||||||
&& apt-get clean
|
&& apt-get clean
|
||||||
|
|
||||||
COPY --from=wamr-builder /wasm-micro-runtime /opt/wamr
|
COPY --from=wamr-builder /wasm-micro-runtime /opt/wamr
|
||||||
@ -1,94 +0,0 @@
|
|||||||
# Paths
|
|
||||||
WAMR_ROOT := /opt/wamr
|
|
||||||
WAMRC := /opt/wamr-wamrc/wamrc
|
|
||||||
IWASM := /opt/wamr-iwasm/iwasm
|
|
||||||
WAMRC_LIB := /opt/wamr-libvmlib
|
|
||||||
IWASM_LIB := /opt/wamr-libiwasm
|
|
||||||
|
|
||||||
WASI_ROOT := /opt/wasi-sdk
|
|
||||||
WASI_CC := $(WASI_ROOT)/bin/clang
|
|
||||||
WASI_CFLAGS := --target=wasm32-wasi \
|
|
||||||
--sysroot=$(WASI_ROOT)/share/wasi-sysroot \
|
|
||||||
-O0 -g -Wall
|
|
||||||
|
|
||||||
# Embedding
|
|
||||||
EMBED_CC := gcc
|
|
||||||
EMBED_INCL := -I$(WAMR_ROOT)/core/iwasm/include \
|
|
||||||
-I$(WAMR_ROOT)/core/iwasm/common \
|
|
||||||
-I$(WAMR_ROOT)/core/shared/platform/linux \
|
|
||||||
-I$(WAMR_ROOT)/core/shared/utils \
|
|
||||||
-I$(WAMR_ROOT)/core/shared/utils/uncommon
|
|
||||||
EMBED_SOURCES := $(WAMR_ROOT)/core/shared/utils/uncommon/bh_read_file.c
|
|
||||||
EMBED_CFLAGS := -O0 -g -Wall $(EMBED_INCL) $(EMBED_SOURCES)
|
|
||||||
AOT_LDFLAGS := -Wl,-rpath,$(WAMRC_LIB)
|
|
||||||
AOT_LDLIBS := -L$(WAMRC_LIB) -lvmlib -lm
|
|
||||||
INTER_LDFLAGS := -Wl,-rpath,$(IWASM_LIB)
|
|
||||||
INTER_LDLIBS := -L$(IWASM_LIB) -liwasm -lm
|
|
||||||
XXD := busybox xxd
|
|
||||||
|
|
||||||
# Files
|
|
||||||
SRCS := $(wildcard *.c)
|
|
||||||
WASMS := $(SRCS:.c=.wasm)
|
|
||||||
CWASMS := $(SRCS:.c=_wasm.c)
|
|
||||||
AOTS := $(SRCS:.c=.aot)
|
|
||||||
OBJS := $(SRCS:.c=.o)
|
|
||||||
DEPS := $(SRCS:.c=.d)
|
|
||||||
HOSTS := $(SRCS:.c=.host)
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all build-wasms build-aots build-cwasms build-hosts clean
|
|
||||||
|
|
||||||
all: build-wasms build-aots build-cwasms build-hosts
|
|
||||||
|
|
||||||
# Compile to wasm bytecode using wasi-sdk
|
|
||||||
build-wasms: $(WASMS)
|
|
||||||
|
|
||||||
%.wasm: %.c
|
|
||||||
$(WASI_CC) $(WASI_CFLAGS) $< -o $@
|
|
||||||
|
|
||||||
# Compile ahead-of-time module using wamrc
|
|
||||||
build-aots: $(AOTS)
|
|
||||||
|
|
||||||
%.aot: %.wasm
|
|
||||||
$(WAMRC) -o $@ $<
|
|
||||||
# $(WAMRC) --enable-wasi -o $@ $<
|
|
||||||
|
|
||||||
# Convert the .aot files to C-style arrays (to embed them into the resulting host binary)
|
|
||||||
build-cwasms: $(CWASMS)
|
|
||||||
|
|
||||||
%_wasm.c: %.aot
|
|
||||||
$(XXD) -i $< > $@
|
|
||||||
|
|
||||||
# Compile the host that will load and run the compiled wasm module
|
|
||||||
# The compiled wasm module is embedded as C-style array
|
|
||||||
build-hosts: $(HOSTS)
|
|
||||||
|
|
||||||
# The C-style array is called %_aot, e.g. test_aot
|
|
||||||
# We have to modify the host to refer to that with the correct name
|
|
||||||
%.host: %_wasm.c
|
|
||||||
cp embed/host.c embed/$*_host.c
|
|
||||||
sed -i \
|
|
||||||
-e "s/__WASM_ARRAY_FILE__/$*_wasm.c/g" \
|
|
||||||
-e "s/__WASM_ARRAY__/$*_aot/g" \
|
|
||||||
-e "s/__WASM_ARRAY_LEN__/$*_aot_len/g" \
|
|
||||||
embed/$*_host.c
|
|
||||||
$(EMBED_CC) $(EMBED_CFLAGS) embed/$*_host.c -o $@ $(INTER_LDFLAGS) $(INTER_LDLIBS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.wasm
|
|
||||||
rm -f *.aot
|
|
||||||
rm -f *_wasm.c
|
|
||||||
rm -f *.d
|
|
||||||
rm -f *.o
|
|
||||||
rm -f embed/*_host.c
|
|
||||||
rm -f *.host
|
|
||||||
|
|
||||||
# Compile to C-embedded
|
|
||||||
# embed: $(OBJS)
|
|
||||||
# $(EMBED_CC) $(OBJS) -o embed $(AOT_LDFLAGS) $(AOT_LDLIBS)
|
|
||||||
|
|
||||||
# %.o: %.c
|
|
||||||
# $(EMBED_CC) $(EMBED_CFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
# embed_host:
|
|
||||||
# $(EMBED_CC) $(EMBED_CFLAGS) embed/host.c -o host $(INTER_LDFLAGS) $(INTER_LDLIBS)
|
|
||||||
Reference in New Issue
Block a user