improve build scripts

This commit is contained in:
vms 2020-08-09 11:27:34 +03:00
parent 9dd65dedad
commit 55e1ec7de6
3 changed files with 48 additions and 1 deletions

View File

@ -4,9 +4,11 @@ RUN apt-get update \
&& apt-get install -y ca-certificates \
curl \
git \
make
make \
cargo
RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-10/wasi-sdk-10.0-linux.tar.gz | tar xz --strip-components=1 -C /
RUN cargo install fcli
VOLUME /code
WORKDIR /code

View File

@ -7,6 +7,7 @@ default: all
wasm:
cd src && $(MAKE) -f Makefile_wasm && mv redis.wasm ../
~/.cargo/bin/fce embed -i redis.wasm -o redis.wasm -w redis.wit
install:
cd src && $(MAKE) $@

44
redis.wit Normal file
View File

@ -0,0 +1,44 @@
;; Fluence Redis fork Wasm Interface Types
;; allocate
(@interface type (func (param i32) (result i32))) ;; 0
;; deallocate
(@interface type (func (param i32 i32))) ;; 1
;; invoke
(@interface type (func (param string) (result string))) ;; 2
;; get_result_ptr/get_result_size
(@interface type (func (result i32))) ;; 3
;; set_result_ptr/set_result_size
(@interface type (func (param i32))) ;; 4
(@interface export "allocate" (func 0)) ;; 0
(@interface export "deallocate" (func 1)) ;; 1
(@interface export "invoke" (func 2)) ;; 2
(@interface export "get_result_size" (func 3)) ;; 3
(@interface export "get_result_ptr" (func 3)) ;; 4
(@interface export "set_result_size" (func 4)) ;; 5
(@interface export "set_result_ptr" (func 4)) ;; 6
;; adapter for export invoke function
(@interface func (type 2)
arg.get 0
string.size
call-core 0 ;; call allocate
arg.get 0
string.lower_memory
call-core 2 ;; call invoke
call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr
string.lift_memory
call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr
call-core 1 ;; call deallocate
)
;; Implementations
(@interface implement (func 2) (func 2))