diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b149137 --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +# Copyright 2019 The Things Industries B.V. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHELL = bash +GO = go +PROTOC = protoc + +PROTO_PATH ?= ../.. +VERSIONS ?= v1alpha1 +GOPATH ?= $(shell $(GO) env GOPATH) + +.PHONY: all +all: $(VERSIONS) + +.PHONY: deps +deps: + $(GO) get github.com/gogo/protobuf/protoc-gen-gogofaster + $(GO) get google.golang.org/grpc + +.PHONY: clean +clean: + rm -rf $(VERSIONS) + +v%: + $(PROTOC) -I=$(GOPATH)/src -I=$(GOPATH)/src/github.com/gogo/protobuf/protobuf --gogofaster_out=plugins=grpc,\ +Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\ +Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\ +Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,\ +Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\ +Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\ +Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types:../../ \ + --proto_path=$(PROTO_PATH) \ + $(PROTO_PATH)/packetbroker/api/$@/*.proto + +# vim: ft=make diff --git a/README.md b/README.md new file mode 100644 index 0000000..575333b --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# Packet Broker API for Go + +`go-api` is the Packet Broker API for Go. + +## Installing + +Use `go get` to retrieve the Go API. + +```bash +$ go get go.packetbroker.org/api +``` + +## Regenerating + +The generated protos are checked in to this repository. You only need to regenerate the protos to incorporate changes coming from upstream. + +To generate protos, [install the Protocol Compiler](https://github.com/protocolbuffers/protobuf#protocol-compiler-installation). + +Before generating protos, get the dependencies: + +```bash +$ make deps +``` + +Clean existing generated protos: + +```bash +$ make clean +``` + +To generate protos, clone the [Packet Broker API repository](https://github.com/packetbroker/api). + +If you clone the API repository in `../../packetbroker/api` relative to the path of this repository: + +```bash +$ make +``` + +If you clone the API repository somewhere else, pass the import path where the `packetbroker/api` folder resides like this: + +```bash +$ PROTO_PATH= make +``` + +## License + +The Go API is distributed under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). See `LICENSE` for more information.