Skip to content

Commit

Permalink
Add makefile and use protobufjs
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed May 14, 2018
1 parent 04df889 commit be78286
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ dist/
deno
assets.go
msg.pb.go
msg.pb.js
msg.pb.d.ts
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
@@ -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");

0 comments on commit be78286

Please sign in to comment.