Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 541aafc | 2024-02-28 09:54:53 -0500 | [diff] [blame] | 3 | # Copyright 2016-2024 Open Networking Foundation Contributors |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 16 | # ----------------------------------------------------------------------- |
Joey Armstrong | 541aafc | 2024-02-28 09:54:53 -0500 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ----------------------------------------------------------------------- |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 20 | |
| 21 | .PHONY: help |
| 22 | .DEFAULT_GOAL := help |
| 23 | |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 24 | ##--------------------## |
| 25 | ##---] INCLUDES [---## |
| 26 | ##--------------------## |
Joey Armstrong | 99a72d0 | 2023-06-09 10:26:42 -0400 | [diff] [blame] | 27 | include config.mk |
| 28 | include makefiles/include.mk |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 29 | |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 30 | # Variables |
| 31 | VERSION ?= $(shell cat ./VERSION) |
| 32 | |
| 33 | ## Docker related |
| 34 | DOCKER_REGISTRY ?= |
| 35 | DOCKER_REPOSITORY ?= |
| 36 | DOCKER_BUILD_ARGS ?= |
| 37 | DOCKER_TAG ?= ${VERSION} |
| 38 | ONOS_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}voltha-onos:${DOCKER_TAG} |
| 39 | |
| 40 | ## Docker labels. Only set ref and commit date if committed |
| 41 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 42 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
Matt Jeanneret | 805f76e | 2019-05-16 16:18:26 -0400 | [diff] [blame] | 43 | DOCKER_LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
| 44 | |
| 45 | ifeq ($(shell git ls-files --others --modified --exclude-standard 2>/dev/null | wc -l | sed -e 's/ //g'),0) |
| 46 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 47 | else |
| 48 | DOCKER_LABEL_VCS_REF = $(shell git rev-parse HEAD)+dirty |
| 49 | endif |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 50 | |
| 51 | .PHONY: docker-build |
| 52 | |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 53 | # For each makefile target, add ## <description> on the target line and it will be listed by 'make help' |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 54 | help :: ## Print help for each Makefile target |
Joey Armstrong | 541aafc | 2024-02-28 09:54:53 -0500 | [diff] [blame] | 55 | @echo "Usage: $(MAKE) [options] [target] ..." |
| 56 | |
| 57 | @printf ' %-33.33s %s' 'test' \ |
| 58 | 'Run repository based test suites (test=)' |
| 59 | @printf ' %-33.33s %s' 'test-bats' \ |
| 60 | 'Invoke bats harness shell test suites (wip)' |
| 61 | @printf ' %-33.33s %s' 'test-release' \ |
| 62 | 'Verify released VERSION does ont contain dev/SNAPSHOT apps' |
| 63 | |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 64 | @echo |
Joey Armstrong | 695ba5c | 2023-01-20 11:17:49 -0500 | [diff] [blame] | 65 | @grep --no-filename '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \ |
| 66 | | sort \ |
| 67 | | awk 'BEGIN {FS=":.* ## "}; {printf " %-25s : %s\n", $$1, $$2};' |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 68 | |
| 69 | ## Docker targets |
| 70 | |
Joey Armstrong | 7c3a1e0 | 2023-07-01 16:21:24 -0400 | [diff] [blame] | 71 | ## ----------------------------------------------------------------------- |
| 72 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 73 | build: docker-build ## alias for "docker-build" |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 74 | |
Joey Armstrong | 7c3a1e0 | 2023-07-01 16:21:24 -0400 | [diff] [blame] | 75 | ## ----------------------------------------------------------------------- |
| 76 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 77 | local-onosapps: ## if LOCAL_ONOSAPPS=true runs the get-local-oars.sh |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 78 | mkdir -p local_imports/oar |
| 79 | ifdef LOCAL_ONOSAPPS |
Joey Armstrong | 4048c1f | 2022-12-17 22:24:42 -0500 | [diff] [blame] | 80 | $(RM) -r local_imports/oar |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 81 | ./get-local-oars.sh |
| 82 | endif |
| 83 | |
Joey Armstrong | 7c3a1e0 | 2023-07-01 16:21:24 -0400 | [diff] [blame] | 84 | ## ----------------------------------------------------------------------- |
| 85 | ## Intent: build docker image |
| 86 | ## use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize |
| 87 | ## ----------------------------------------------------------------------- |
| 88 | docker-build: local-onosapps ## build docker image |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 89 | docker build $(DOCKER_BUILD_ARGS) \ |
| 90 | -t ${ONOS_IMAGENAME} \ |
| 91 | --build-arg LOCAL_ONOSAPPS=$(LOCAL_ONOSAPPS) \ |
| 92 | --build-arg org_label_schema_version="${VERSION}" \ |
| 93 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 94 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 95 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 96 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 97 | -f Dockerfile.voltha-onos . |
| 98 | |
Joey Armstrong | 7c3a1e0 | 2023-07-01 16:21:24 -0400 | [diff] [blame] | 99 | ## ----------------------------------------------------------------------- |
| 100 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 541aafc | 2024-02-28 09:54:53 -0500 | [diff] [blame] | 101 | test := $(null) |
| 102 | |
| 103 | ifdef TEST-BATS |
| 104 | test += test-bats |
| 105 | endif |
| 106 | |
| 107 | ifdef RELEASE |
| 108 | test += test-release |
| 109 | endif |
| 110 | |
| 111 | test :: $(test) ## verify that if the version is released we're not pointing to SNAPSHOT apps |
| 112 | |
| 113 | ## ----------------------------------------------------------------------- |
| 114 | ## Intent: Shell script testing with the bats test harness. |
| 115 | ## Usage: make test TEST-BATS=1 |
| 116 | ## ----------------------------------------------------------------------- |
| 117 | test-bats: |
| 118 | $(HIDE)$(MAKE) -C test/bats $@ |
| 119 | |
| 120 | ## ----------------------------------------------------------------------- |
| 121 | ## Intent: Release based testing. |
| 122 | ## ----------------------------------------------------------------------- |
| 123 | ## Usage: |
| 124 | ## make test-release |
| 125 | ## make test RELEASE=1 |
| 126 | ## ----------------------------------------------------------------------- |
| 127 | ## Legacy: VERSION validation has been defined as a default repository |
| 128 | ## based test. The target should be isolated and should only |
| 129 | ## be required durring a release cycle. |
| 130 | ## ----------------------------------------------------------------------- |
| 131 | test-release : |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 132 | bash tests/version-check.sh |
| 133 | |
Joey Armstrong | 541aafc | 2024-02-28 09:54:53 -0500 | [diff] [blame] | 134 | ## ----------------------------------------------------------------------- |
| 135 | ## ----------------------------------------------------------------------- |
Matteo Scandolo | c209e80 | 2021-06-07 16:59:30 +0200 | [diff] [blame] | 136 | docker-push: ## push to docker registy: use DOCKER_REGISTRY, DOCKER_REPOSITORY and DOCKER_TAG to customize |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 137 | docker push ${ONOS_IMAGENAME} |
| 138 | |
Joey Armstrong | 541aafc | 2024-02-28 09:54:53 -0500 | [diff] [blame] | 139 | ## ----------------------------------------------------------------------- |
| 140 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 99a72d0 | 2023-06-09 10:26:42 -0400 | [diff] [blame] | 141 | clean :: ## clean the build environment |
Joey Armstrong | 4048c1f | 2022-12-17 22:24:42 -0500 | [diff] [blame] | 142 | $(RM) -r local_imports |
Matt Jeanneret | c7b437c | 2019-05-13 12:33:08 -0400 | [diff] [blame] | 143 | |
Joey Armstrong | 541aafc | 2024-02-28 09:54:53 -0500 | [diff] [blame] | 144 | ## ----------------------------------------------------------------------- |
| 145 | ## ----------------------------------------------------------------------- |
Joey Armstrong | a9deb69 | 2023-06-30 18:13:01 -0400 | [diff] [blame] | 146 | sterile :: clean |
| 147 | |
Joey Armstrong | 04c6c45 | 2024-02-28 15:47:34 -0500 | [diff] [blame] | 148 | # [EOF] |