From f5327b29f7927bda3b1029a435ee10d9c2c0db0f Mon Sep 17 00:00:00 2001 From: requilence Date: Tue, 4 Feb 2020 20:31:51 +0200 Subject: [PATCH] update readme and makefile --- Makefile | 15 +++++++------- README.md | 60 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index 1f31ccf5a..68e5f3310 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY : protos_deps setup: - GOPRIVATE=github.com/anytypeio/go-anytype-library go mod download - go get github.com/ahmetb/govvv + GOPRIVATE=github.com/anytypeio go mod download + GO111MODULE=off go get github.com/ahmetb/govvv npm install fmt: @@ -31,8 +31,7 @@ test-deps: build-lib: $(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-middleware/lib)) - export GO111MODULE=on - go build -v -o dist/lib.a -tags nogrpcserver -ldflags "$(FLAGS)" -buildmode=c-archive -v ./lib/clib + GO111MODULE=on go build -v -o dist/lib.a -tags nogrpcserver -ldflags "$(FLAGS)" -buildmode=c-archive -v ./lib/clib build-js: cp dist/lib.a jsaddon/lib.a @@ -114,10 +113,10 @@ build-debug: protos-debug run-debug: build-debug ./dist/debug -build-dev-js: - go mod download - make build-lib build-js - npm run build:ts +build-dev-js: setup build-lib build-js protos-ts cp -r jsaddon/build ../js-anytype/ cp build/ts/commands.js ../js-anytype/src/proto/commands.js +install-dev-js: + cp -r jsaddon/build ../js-anytype/ + cp build/ts/commands.js ../js-anytype/src/proto/commands.js diff --git a/README.md b/README.md index f7661d720..e0ab5bd49 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,19 @@ #### How to build -1. Install Golang 1.12.* [from here](http://golang.org/dl/) +1. Install Golang 1.13.* [from here](http://golang.org/dl/) 2. `make setup` to install deps -3. `make build-lib` to build C(`.so`) library into `dist` folder +3. `make build-lib` to build C-archived(`lib.a + lib.h`) library into `dist` folder 4. `make build-js` to build NodeJS Addon into `jsaddon/build` -5. `npm install & npm build:ts` to compile proto files for TS/JS to `build/ts` +5. `npm install & npm build:ts` to compile proto files for TS/JS into `build/ts` +6. `make install-dev-js` to copy the compiled NodeJS addon and protobuf binding into `../js-anytype` -#### Rebuild proto files -This repo uses custom protoc plugin located at [anytypeio/protobuf/protoc-gen-gogo/gomobile](https://github.com/anytypeio/protobuf/tree/master/protoc-gen-gogo/gomobile). -So make sure you have installed it: +#### Rebuild protobuf generated files +This repo uses custom protoc located at [anytypeio/protobuf](https://github.com/anytypeio/protobuf/tree/master/protoc-gen-gogo). It adds `gomobile` plugin and some env-controlled options to control the generated code style. + +This protobuf generator will replace your `protoc` binary, BTW it doesn't have any breaking changes for other protobuf and grpc code + +You can install it with a simple command: ``` make setup-protoc ``` @@ -21,26 +25,6 @@ Then you can easily regenerate proto files: make protos ``` - -#### Run local gRPC server to debug -⚠️ Make sure to update/install protobuf compiler from [this repo](https://github.com/anytypeio/protobuf) using `make setup-protoc` - -Commands: -`make run-debug` - builds proto files for grpc server, builds the binary and runs it -`make build-debug` - builds proto files for grpc server and builds the binary into `dist/debug` - -If you want to change the default port(9999): -`ANYTYPE_GRPC_ADDR=127.0.0.1:8888 make run-debug` - - -Useful tools for debug: -**GUI** -https://github.com/uw-labs/bloomrpc -`HowTo: Set the import path to the middleware root, then select commands.proto file` - -**CLI** -https://github.com/njpatel/grpcc - #### Run tests GO test: ``` @@ -52,3 +36,27 @@ NodeJS addon test: cd jsaddon npm run test ``` + +#### Run local gRPC server to debug +⚠️ Make sure to update/install protobuf compiler from [this repo](https://github.com/anytypeio/protobuf) using `make setup-protoc` + +Commands: +- `make run-debug` - builds proto files for grpc server, builds the binary and runs it +- `make build-debug` - builds proto files for grpc server and builds the binary into `dist/debug` + +If you want to change the default port(9999): + +`ANYTYPE_GRPC_ADDR=127.0.0.1:8888 make run-debug` + +---- +Useful tools for debug: + +**GUI** + +https://github.com/uw-labs/bloomrpc + +`HowTo: Set the import path to the middleware root, then select commands.proto file` + +**CLI** + +https://github.com/njpatel/grpcc