84 lines
2.3 KiB
Makefile
84 lines
2.3 KiB
Makefile
# Copyright 2018 The KubeSphere Authors. All rights reserved.
|
|
# Use of this source code is governed by a Apache license
|
|
# that can be found in the LICENSE file.
|
|
|
|
# The binary to build
|
|
BIN ?= ks-apiserver
|
|
|
|
IMG ?= kubespheredev/ks-apiserver
|
|
OUTPUT_DIR=bin
|
|
|
|
define get_diff_files
|
|
$(eval DIFF_FILES=$(shell git diff --name-only --diff-filter=ad | grep -E "^(test|cmd|pkg)/.+\.go"))
|
|
endef
|
|
define get_build_flags
|
|
$(eval SHORT_VERSION=$(shell git describe --tags --always --dirty="-dev"))
|
|
$(eval SHA1_VERSION=$(shell git show --quiet --pretty=format:%H))
|
|
$(eval DATE=$(shell date +'%Y-%m-%dT%H:%M:%S'))
|
|
$(eval BUILD_FLAG= -X $(TRAG.Version).ShortVersion="$(SHORT_VERSION)" \
|
|
-X $(TRAG.Version).GitSha1Version="$(SHA1_VERSION)" \
|
|
-X $(TRAG.Version).BuildDate="$(DATE)")
|
|
endef
|
|
|
|
define ALL_HELP_INFO
|
|
# Build code.
|
|
#
|
|
# Args:
|
|
# WHAT: Directory names to build. If any of these directories has a 'main'
|
|
# package, the build will produce executable files under $(OUT_DIR).
|
|
# If not specified, "everything" will be built.
|
|
# GOFLAGS: Extra flags to pass to 'go' when building.
|
|
# GOLDFLAGS: Extra linking flags passed to 'go' when building.
|
|
# GOGCFLAGS: Additional go compile flags passed to 'go' when building.
|
|
#
|
|
# Example:
|
|
# make
|
|
# make all
|
|
# make all WHAT=cmd/ks-apiserver
|
|
# Note: Use the -N -l options to disable compiler optimizations an inlining.
|
|
# Using these build options allows you to subsequently use source
|
|
# debugging tools like delve.
|
|
endef
|
|
.PHONY: all
|
|
all: test ks-apiserver ks-apigateway ks-iam
|
|
|
|
# Build ks-apiserver binary
|
|
ks-apiserver: test
|
|
hack/gobuild.sh cmd/ks-apiserver
|
|
|
|
# Build ks-apigateway binary
|
|
ks-apigateway: test
|
|
hack/gobuild.sh cmd/ks-apigateway
|
|
|
|
# Build ks-iam binary
|
|
ks-iam: test
|
|
hack/gobuild.sh cmd/ks-iam
|
|
|
|
# Run go fmt against code
|
|
fmt:
|
|
go fmt ./pkg/... ./cmd/...
|
|
|
|
# Run go vet against code
|
|
vet:
|
|
go vet ./pkg/... ./cmd/...
|
|
|
|
# Generate code
|
|
generate:
|
|
ifndef GOPATH
|
|
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH)
|
|
endif
|
|
go generate ./pkg/... ./cmd/...
|
|
|
|
# Build the docker image
|
|
docker-build: all
|
|
docker build . -t ${IMG}
|
|
|
|
# Run tests
|
|
test: generate fmt vet
|
|
go test ./pkg/... ./cmd/... -coverprofile cover.out
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
-make -C ./pkg/version clean
|
|
@echo "ok"
|