-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (124 loc) · 4.99 KB
/
Makefile
File metadata and controls
146 lines (124 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright Mia srl
# SPDX-License-Identifier: Apache-2.0
# 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.
DEBUG_MAKEFILE?=
ifeq ($(DEBUG_MAKEFILE),1)
$(warning ***** executing goal(s) "$(MAKECMDGOALS)")
$(warning ***** $(shell date))
else
# If we're not debugging the Makefile, always hide the commands inside the goals
MAKEFLAGS+= -s
endif
# It's necessary to set this because some environments don't link sh -> bash.
# Using env is more portable than setting the path directly
ifeq ($(OS),Windows_NT)
SHELL:= cmd.exe
MKDIR = if not exist "$(subst /,\,$1)" mkdir "$(subst /,\,$1)"
RM = if exist "$(subst /,\,$1)" rmdir /s /q "$(subst /,\,$1)"
READ_FILE = powershell -NoProfile -Command "Get-Content $1 -Raw"
GOBIN_INSTALL = set "GOBIN=$1" && go install $2
else
SHELL:= /usr/bin/env bash
MKDIR = mkdir -p $1
RM = rm -fr $1
READ_FILE = cat $1
GOBIN_INSTALL = GOBIN=$1 go install $2
endif
.EXPORT_ALL_VARIABLES:
.SUFFIXES:
## Set all variables
ifeq ($(origin PROJECT_DIR),undefined)
ifeq ($(OS),Windows_NT)
PROJECT_DIR:= $(abspath $(CURDIR))
else
PROJECT_DIR:= $(abspath $(shell pwd -P))
endif
endif
ifeq ($(origin OUTPUT_DIR),undefined)
OUTPUT_DIR:= $(PROJECT_DIR)/bin
endif
ifeq ($(origin TOOLS_DIR),undefined)
TOOLS_DIR:= $(PROJECT_DIR)/tools
endif
ifeq ($(origin TOOLS_BIN),undefined)
TOOLS_BIN:= $(TOOLS_DIR)/bin
endif
# Set here the name of the package you want to build
CMDNAME:= miactl
BUILD_PATH:= ./cmd/$(CMDNAME)
CONFORMANCE_TEST_PATH:= $(PROJECT_DIR)/tests/e2e
IS_LIBRARY:=
# enable modules
GO111MODULE:= on
GOOS:= $(shell go env GOOS)
GOARCH:= $(shell go env GOARCH)
GOARM:= $(shell go env GOARM)
## Build Variables
ifeq ($(OS),Windows_NT)
GIT_REV:= $(shell git rev-parse --short HEAD 2>NUL)
VERSION:= $(shell git describe --tags --exact-match 2>NUL || git rev-parse --short=12 HEAD 2>NUL)
else
GIT_REV:= $(shell git rev-parse --short HEAD 2>/dev/null)
VERSION:= $(shell git describe --tags --exact-match 2>/dev/null || (echo $(GIT_REV) | cut -c1-12))
endif
# insert here the go module where to add the version metadata
VERSION_MODULE_NAME:= github.com/mia-platform/miactl/internal/cmd
# supported platforms for container creation, these are a subset of the supported
# platforms of the base image.
# Or if you start from scratch the platforms you want to support in your image
# This link contains the rules on how the strings must be formed https://github.com/containerd/containerd/blob/v1.4.3/platforms/platforms.go#L63
SUPPORTED_PLATFORMS:= linux/386 linux/amd64 linux/arm64 linux/arm/v6 linux/arm/v7
# Default platform for which building the docker image (darwin can run linux images for the same arch)
# as SUPPORTED_PLATFORMS it highly depends on which platform are supported by the base image
DEFAULT_DOCKER_PLATFORM:= linux/$(GOARCH)/$(GOARM)
# List of one or more container registries for tagging the resulting docker images
CONTAINER_REGISTRIES:= docker.io/miaplatform ghcr.io/mia-platform
# The description used on the org.opencontainers.description label of the container
DESCRIPTION:= Mia Platform Cli for Console
# The vendor name used on the org.opencontainers.image.vendor label of the container
VENDOR_NAME:= Mia s.r.l.
# The license used on the org.opencontainers.image.license label of the container
LICENSE:= Apache-2.0
# The documentation url used on the org.opencontainers.image.documentation label of the container
DOCUMENTATION_URL:= https://docs.mia-platform.eu
# The source url used on the org.opencontainers.image.source label of the container
SOURCE_URL:= https://github.com/mia-platform/miactl
BUILDX_CONTEXT?= miactl-build-context
# Add additional targets that you want to run when calling make without arguments
.PHONY: all
all: lint test
## Includes
include tools/make/clean.mk
include tools/make/lint.mk
include tools/make/test.mk
include tools/make/generate.mk
include tools/make/build.mk
include tools/make/container.mk
include tools/make/release.mk
# Uncomment the correct test suite to run during CI
.PHONY: ci
ci: test-coverage
# ci: test-integration-coverage
### Put your custom import, define or goals under here ###
generate-deps: $(TOOLS_BIN)/deepcopy-gen
$(TOOLS_BIN)/deepcopy-gen: $(TOOLS_DIR)/DEEPCOPY_GEN_VERSION
$(eval DEEPCOPY_GEN_VERSION:= $(shell $(call READ_FILE,$<)))
$(call MKDIR,$(TOOLS_BIN))
$(info Installing deepcopy-gen $(DEEPCOPY_GEN_VERSION) bin in $(TOOLS_BIN))
$(call GOBIN_INSTALL,$(TOOLS_BIN),k8s.io/code-generator/cmd/deepcopy-gen@$(DEEPCOPY_GEN_VERSION))
BUILD_ALPHA?=false
.PHONY: build-alpha
build-alpha:
ifeq ($(OS),Windows_NT)
set "BUILD_ALPHA=true" && $(MAKE) build
else
BUILD_ALPHA=true $(MAKE) build
endif