blob: 199d28ce43b6cbc598cc0c91ce96b8aec70bc642 [file] [log] [blame]
Matteo Scandolo4747d292019-08-05 11:50:18 -07001# Copyright 2019-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15VERSION ?= $(shell cat ./VERSION)
16
17## Docker related
18DOCKER_TAG ?= ${VERSION}
19DOCKER_REPOSITORY ?= voltha/
20DOCKER_REGISTRY ?= ""
21DOCKER_BUILD_ARGS ?=
22
23## Docker labels. Only set ref and commit date if committed
24DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
25DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
26DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
27DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
28
29# Public targets
30
31all: help
32
33protos: api/openolt.pb.go # @HELP Build proto files
34
35build: protos # @HELP Build the binary
36 GO111MODULE=on go build -i -v -o ./cmd/bbsim ./internal/bbsim
37
38test: protos # @HELP Execute unit tests
39 GO111MODULE=on go test ./internal/bbsim
40
41docker-build:
42 docker build -t ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG} -f build/package/Dockerfile .
43
44docker-push:
45 docker push ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}bbsim:${DOCKER_TAG}
46
47help: # @HELP Print the command options
48 @echo
49 @echo "\033[0;31m BroadBand Simulator (BBSim) \033[0m"
50 @echo
51 @echo Emulates the control plane of an openolt compatible device
52 @echo Useful for development and scale testing
53 @echo
54 @grep -E '^.*: .* *# *@HELP' $(MAKEFILE_LIST) \
55 | sort \
56 | awk ' \
57 BEGIN {FS = ": .* *# *@HELP"}; \
58 {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}; \
59 '
60
61
62# Internals
63
64api/openolt.pb.go: api/openolt.proto
65 @protoc -I . \
66 -I${GOPATH}/src \
67 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
68 --go_out=plugins=grpc:./ \
69 $<
70