github: Package standalone

This commit is contained in:
Remko Tronçon 2022-05-26 12:07:41 +02:00
parent 77a4df1609
commit 7a1e7de085
4 changed files with 39 additions and 2 deletions

View file

@ -0,0 +1,25 @@
name: Publish Standalone
on:
release:
types: [created]
jobs:
build:
uses: ./.github/workflows/build.yml
publish-standalone:
needs: build
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup
- run: make -C src/standalone install-deps package
- uses: skx/github-action-publish-binaries@44887b225ceca96efd8a912d39c09ad70312af31
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'waforth-*.tgz'

View file

@ -2,3 +2,4 @@
/waforth_core.h
/wasm-micro-runtime
/wasmtime-*
/*.tgz

View file

@ -3,20 +3,24 @@ UNAME_P=$(shell uname -p)
ifeq ($(UNAME_S),Darwin)
WASMTIME_DIR=wasmtime-v0.37.0-x86_64-macos-c-api
WASMTIME_RELEASE_URL=https://github.com/bytecodealliance/wasmtime/releases/download/v0.37.0/wasmtime-v0.37.0-x86_64-macos-c-api.tar.xz
PACKAGE_SUFFIX=x86_64-macos
else
WASMTIME_DIR=wasmtime-v0.37.0-x86_64-linux-c-api
WASMTIME_RELEASE_URL=https://github.com/bytecodealliance/wasmtime/releases/download/v0.37.0/wasmtime-v0.37.0-x86_64-linux-c-api.tar.xz
LIBS=-lpthread -lm -ldl
PACKAGE_SUFFIX=x86_64-linux
endif
CFLAGS=-I$(WASMTIME_DIR)/include
LDFLAGS=
LIBS:=$(WASMTIME_DIR)/lib/libwasmtime.a $(LIBS)
VERSION?=$(shell cat ../../package.json | grep '"version"' | sed -e 's/.*:.*"\(.*\)".*/\1/')
BIN2H=../../scripts/bin2h
WAT2WASM=wat2wasm
WAT2WASM_FLAGS=--debug-names
CFLAGS:=-DVERSION='"$(VERSION)"' $(CFLAGS)
OBJECTS=main.o
all: waforth
@ -37,7 +41,10 @@ install-deps:
-rm -rf wasmtime-*
curl -L -s $(WASMTIME_RELEASE_URL) | tar xJv
.PHONY: package
package: waforth
tar czf waforth-v$(VERSION)-$(PACKAGE_SUFFIX).tgz waforth
.PHONY: clean
clean:
-rm -f waforth_core.wasm waforth_core.h $(OBJECTS) waforth
-rm -f waforth_core.wasm waforth_core.h $(OBJECTS) waforth *.tgz

View file

@ -3,6 +3,10 @@
#include "waforth_core.h"
#include "wasm.h"
#ifndef VERSION
#define VERSION "dev"
#endif
#define CORE_TABLE_EXPORT_INDEX 0
#define CORE_MEMORY_EXPORT_INDEX 1
#define CORE_INTERPRET_EXPORT_INDEX 6
@ -164,7 +168,7 @@ int main(int argc, char *argv_main[]) {
return -1;
}
printf("WAForth\n");
printf("WAForth (" VERSION ")\n");
wasm_val_t as[1] = {WASM_I32_VAL(0)};
wasm_val_vec_t args = WASM_ARRAY_VEC(as);
wasm_val_t vs[] = {WASM_INIT_VAL};