diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-05-14 01:11:56 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-05-14 01:11:56 -0400 |
commit | be7828684b888a8c9743e6dd7c54c924c076c8e2 (patch) | |
tree | f990b8b7e0991ac6f1b1c4020af1ddc6f53eca01 | |
parent | 04df88912dc043b2443e855cddc0f8b5377ace4b (diff) |
Add makefile and use protobufjs
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 29 | ||||
-rw-r--r-- | main.go | 4 | ||||
-rw-r--r-- | main.ts | 3 |
4 files changed, 34 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore index 165a7f9ae..9a5e8f727 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ dist/ deno assets.go msg.pb.go +msg.pb.js +msg.pb.d.ts diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..5cd8b9c15 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +deno: assets.go msg.pb.go main.go + go build -o deno + +assets.go: dist/main.js + go-bindata -pkg main -o assets.go dist/ + +msg.pb.go: msg.proto + protoc --go_out=. msg.proto + +msg.pb.js: msg.proto node_modules + ./node_modules/.bin/pbjs -t static-module -w commonjs -o msg.pb.js msg.proto + +msg.pb.d.ts: msg.pb.js node_modules + ./node_modules/.bin/pbts -o msg.pb.d.ts msg.pb.js + +dist/main.js: main.ts msg.pb.js msg.pb.d.ts node_modules + ./node_modules/.bin/parcel build --out-dir=dist/ --no-minify main.ts + +node_modules: + yarn + +clean: + -rm -f deno assets.go msg.pb.go msg.pb.js msg.pb.d.ts + -rm -rf dist/ + +distclean: clean + -rm -rf node_modules/ + +.PHONY: clean distclean @@ -1,9 +1,5 @@ package main -//go:generate protoc --go_out=. msg.proto -//go:generate ./node_modules/.bin/parcel build --out-dir=dist/ --no-minify main.ts -//go:generate go-bindata -pkg $GOPACKAGE -o assets.go dist/ - import ( "github.com/golang/protobuf/proto" "github.com/ry/v8worker2" @@ -1,7 +1,10 @@ import * as ts from "typescript"; +import { main as pb } from "./msg.pb" V8Worker2.recv((ab: ArrayBuffer) { + let msg = pb.Msg.decode(new Uint8Array(ab)); V8Worker2.print("Got array buffer", ab.byteLength); + V8Worker2.print("msg.argv", msg.argv); }); V8Worker2.print("Hello"); |