[VOL-2767]
Modify makefile to support local_lib-go, make docker-build to make build for ofagent-go
Change-Id: I09ec6d2eab57e6161c14b37cf1bf04bdb51e0a76
diff --git a/Makefile b/Makefile
index 0a0d677..5a83a0f 100644
--- a/Makefile
+++ b/Makefile
@@ -58,13 +58,14 @@
GOLANGCI_LINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") -v gocache:/.cache -v gocache-${VOLTHA_TOOLS_VERSION}:/go/pkg voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-golangci-lint golangci-lint
HADOLINT = docker run --rm --user $$(id -u):$$(id -g) -v ${CURDIR}:/app $(shell test -t 0 && echo "-it") voltha/voltha-ci-tools:${VOLTHA_TOOLS_VERSION}-hadolint hadolint
-.PHONY: docker-build local-protos local-voltha
+.PHONY: local-protos local-voltha
# This should to be the first and default target in this Makefile
help:
@echo "Usage: make [<target>]"
@echo "where available targets are:"
@echo
+ @echo "build : Build ofagent-go docker image"
@echo "docker-build : Build ofagent-go docker image"
@echo "help : Print this help"
@echo "docker-push : Push the docker images to an external repository"
@@ -82,6 +83,14 @@
cp -r ${GOPATH}/src/github.com/opencord/voltha-protos/go/* vendor/github.com/opencord/voltha-protos/go
endif
+## Local Development Helpers
+local-lib-go:
+ifdef LOCAL_LIB_GO
+ mkdir -p vendor/github.com/opencord/voltha-lib-go/v3/pkg
+ cp -r ${LOCAL_LIB_GO}/pkg/* vendor/github.com/opencord/voltha-lib-go/v3/pkg/
+endif
+
+
local-voltha:
ifdef LOCAL_VOLTHA
mkdir -p vendor/github.com/opencord/voltha-go/
@@ -89,10 +98,12 @@
rm -rf vendor/github.com/opencord/voltha-go/vendor
endif
+## Docker targets
+build: docker-build
## Docker targets
-docker-build: local-protos local-voltha
+docker-build: local-protos local-voltha local-lib-go
docker build $(DOCKER_BUILD_ARGS) -t ${ADAPTER_IMAGENAME}:${DOCKER_TAG} -t ${ADAPTER_IMAGENAME}:latest -f docker/Dockerfile.ofagent-go .
docker-push:
@@ -121,7 +132,7 @@
lint: lint-mod lint-dockerfile
-test:
+test: local-lib-go
@mkdir -p ./tests/results
@${GO} test -mod=vendor -v -coverprofile ./tests/results/go-test-coverage.out -covermode count ./... 2>&1 | tee ./tests/results/go-test-results.out ;\
RETURN=$$? ;\
diff --git a/README.md b/README.md
index e6aa9c9..5f68b77 100644
--- a/README.md
+++ b/README.md
@@ -18,4 +18,22 @@
- Normal Logging
- `./build/ofagent-go -ofaddress=localhost openflowPort=6653 -volthaAddress=localhost -volthaPort=50057`
- Debug Logging
- - `./build/ofagent-go -debug -ofaddress=localhost openflowPort=6653 -volthaAddress=localhost -volthaPort=50057`
\ No newline at end of file
+ - `./build/ofagent-go -debug -ofaddress=localhost openflowPort=6653 -volthaAddress=localhost -volthaPort=50057`
+
+## Building with a Local Copy of `voltha-protos` or `voltha-lib-go`
+If you want to build/test using a local copy or `voltha-protos` or `voltha-lib-go`
+this can be accomplished by using the environment variables `LOCAL_PROTOS` and
+`LOCAL_LIB_GO`. These environment variables should be set to the filesystem
+path where the local source is located, e.g.
+
+```bash
+LOCAL\_PROTOS=$HOME/src/voltha-protos
+LOCAL\_LIB\_GO=$HOME/src/voltha-lib-go
+```
+
+When these environment variables are set the vendored versions of these packages
+will be removed from the `vendor` directory and replaced by coping the files from
+the specified locations to the `vendor` directory. *NOTE:* _this means that
+the files in the `vendor` directory are no longer what is in the `git` repository
+and it will take manual `git` intervention to put the original files back._
+
diff --git a/VERSION b/VERSION
index 25b6557..0664a8f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.1.6-dev
+1.1.6