Skip to content

Commit 001740f

Browse files
authored
Add model package, visitors, and validation rules (#1)
1 parent 918b51f commit 001740f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+8281
-39
lines changed

.github/workflows/build.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-*
8+
tags:
9+
- v*
10+
pull_request:
11+
branches:
12+
- main
13+
- release-*
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v1
20+
21+
- uses: actions/setup-go@v3
22+
with:
23+
go-version: '1.19'
24+
25+
- uses: acifani/setup-tinygo@v1
26+
with:
27+
tinygo-version: 0.25.0
28+
29+
- uses: actions/setup-go@v3
30+
with:
31+
go-version: '1.19'
32+
33+
- name: Install wasm-opt
34+
run: |
35+
wget https://github.com/WebAssembly/binaryen/releases/download/version_110/binaryen-version_110-x86_64-linux.tar.gz
36+
tar -xvzf binaryen-version_110-x86_64-linux.tar.gz
37+
rm -rf binaryen-version_110-x86_64-linux.tar.gz
38+
cp binaryen-version_110/bin/wasm-opt /usr/local/bin
39+
rm -Rf binaryen-version_110
40+
41+
- name: Install tinyjson
42+
run: go install github.com/CosmWasm/tinyjson/...@latest
43+
44+
- name: Install Apex CLI
45+
run: wget -q https://apexlang.io/install.sh -O - | /bin/bash
46+
47+
- name: Apex code generation
48+
run: apex generate
49+
50+
- name: Build WebAssembly parser
51+
run: |
52+
tinygo build -o apex-parser.wasm -scheduler=none -target=wasi -wasm-abi=generic -no-debug cmd/apex-api/main.go
53+
wasm-opt -O apex-parser.wasm -o apex-parser.wasm
54+
55+
- name: Is Release?
56+
if: startswith(github.ref, 'refs/tags/v')
57+
run: echo "DEPLOY_PACKAGE=true" >> $GITHUB_ENV
58+
59+
- name: Upload WebAssebly parser
60+
if: env.DEPLOY_PACKAGE == 'true'
61+
uses: actions/upload-artifact@v2
62+
with:
63+
name: Apex Parser Wasm Module
64+
path: apex-parser.wasm

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.wasm
2+
test.*
3+
/apex-host

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.PHONY: all wasm-cli wasm-api codegen
2+
3+
all: codegen wasm-cli wasm-api wasm-host
4+
5+
wasm-cli:
6+
tinygo build -o apex-cli.wasm -scheduler=none -target=wasi -wasm-abi=generic -no-debug cmd/apex-cli/main.go
7+
wasm-opt -O apex-cli.wasm -o apex-cli.wasm
8+
9+
wasm-api:
10+
tinygo build -o apex-api.wasm -scheduler=none -target=wasi -wasm-abi=generic -no-debug cmd/apex-api/main.go
11+
wasm-opt -O apex-api.wasm -o apex-api.wasm
12+
cp apex-api.wasm cmd/host/apex-api.wasm
13+
14+
wasm-host:
15+
go build -o apex-host cmd/host/main.go
16+
17+
codegen:
18+
apex generate

apex.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
spec: model.apexlang
2+
config:
3+
package: model
4+
module: github.com/apexlang/apex-wasm
5+
generates:
6+
model/model.go:
7+
module: '@apexlang/codegen/go'
8+
visitorClass: InterfacesVisitor
9+
config:
10+
writeTypeInfo: false
11+
runAfter:
12+
- command: tinyjson -all model/model.go

0 commit comments

Comments
 (0)