VOL-2169 Add LOCAL_LIB_GO and update README
Change-Id: Id749550a336716216f8fe84819f217ec1fed1794
diff --git a/Makefile b/Makefile
index 203e642..8305705 100644
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,6 @@
--build-arg org_opencord_vcs_dirty="${DOCKER_LABEL_VCS_DIRTY}"
DOCKER_BUILD_ARGS_LOCAL ?= ${DOCKER_BUILD_ARGS} \
- --build-arg LOCAL_PYVOLTHA=${LOCAL_PYVOLTHA} \
--build-arg LOCAL_PROTOS=${LOCAL_PROTOS}
# Default is GO111MODULE=auto, which will refuse to use go mod if running
@@ -58,7 +57,7 @@
# inside a GOPATH).
export GO111MODULE=on
-.PHONY: rw_core ro_core afrouter afrouterd local-protos local-pyvoltha
+.PHONY: rw_core ro_core afrouter afrouterd local-protos local-lib-go
# This should to be the first and default target in this Makefile
help:
@@ -77,15 +76,27 @@
@echo "lint-sanity : Verify that 'go vet' doesn't report any issues"
@echo "lint-mod : Verify the integrity of the 'mod' files"
@echo "lint : Shorthand for lint-style & lint-sanity"
- @echo "sca : Runs various SCA through golangci-lint tool"
- @echo "test : Generate reports for all go tests"
+ @echo "local-lib-go : Copies a local version of the VOTLHA dependencies into the vendor directory"
+ @echo "local-protos : Copies a local verison of the VOLTHA protos into the vendor directory"
+ @echo "sca : Runs various SCA through golangci-lint tool"
+ @echo "test : Generate reports for all go tests"
@echo
## Local Development Helpers
local-protos:
ifdef LOCAL_PROTOS
- mkdir -p vendor/github.com/opencord/voltha-protos
- cp -r ${GOPATH}/src/github.com/opencord/voltha-protos/voltha.pb vendor/github.com/opencord/voltha-protos/
+ rm -rf vendor/github.com/opencord/voltha-protos/go
+ mkdir -p vendor/github.com/opencord/voltha-protos/go
+ cp -r ${LOCAL_PROTOS}/go/* vendor/github.com/opencord/voltha-protos/go
+ rm -rf vendor/github.com/opencord/voltha-protos/go/vendor
+endif
+
+## Local Development Helpers
+local-lib-go:
+ifdef LOCAL_LIB_GO
+ rm -rf vendor/github.com/opencord/voltha-lib-go
+ mkdir -p vendor/github.com/opencord/voltha-lib-go/v2/pkg
+ cp -r ${LOCAL_LIB_GO}/pkg/* vendor/github.com/opencord/voltha-lib-go/v2/pkg/
endif
## Docker targets
@@ -94,10 +105,10 @@
docker-build: afrouter afrouterd
-afrouter: local-protos
+afrouter: local-protos local-lib-go
docker build $(DOCKER_BUILD_ARGS) -t ${AFROUTER_IMAGENAME}:${DOCKER_TAG} -t ${AFROUTER_IMAGENAME}:latest -f docker/Dockerfile.afrouter .
-afrouterd: local-protos
+afrouterd: local-protos local-lib-go
docker build $(DOCKER_BUILD_ARGS) -t ${AFROUTERD_IMAGENAME}:${DOCKER_TAG} -t ${AFROUTERD_IMAGENAME}:latest -f docker/Dockerfile.afrouterd .
docker-push:
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0081315
--- /dev/null
+++ b/README.md
@@ -0,0 +1,29 @@
+# How to Build the Voltha api-server
+
+## Working with Go Dependencies
+This project uses Go Modules https://github.com/golang/go/wiki/Modules to manage
+dependencies. As a local best pratice this project also vendors the dependencies.
+If you need to update dependencies please follow the Go Modules best practices
+and also perform the following steps before committing a patch:
+```bash
+go mod tidy
+go mod verify
+go mod vendor
+```
+
+## 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._