Makefile 2.3 KB
Newer Older
J
jeff 已提交
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
# 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 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
J
Jeff 已提交
31
all: test ks-apiserver ks-apigateway ks-iam controller-manager
J
jeff 已提交
32 33

# Build ks-apiserver binary
H
hongming 已提交
34
ks-apiserver: test
J
jeff 已提交
35 36
	hack/gobuild.sh cmd/ks-apiserver

H
hongming 已提交
37 38 39 40 41 42 43 44
# 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

J
Jeff 已提交
45 46 47 48
# Build controller-manager binary
controller-manager: test
	hack/gobuild.sh cmd/controller-manager

J
jeff 已提交
49 50 51 52 53 54 55 56
# Run go fmt against code 
fmt:
	go fmt ./pkg/... ./cmd/...

# Run go vet against code
vet:
	go vet ./pkg/... ./cmd/...

J
jeff 已提交
57 58 59 60 61 62 63 64 65 66
# Generate manifests e.g. CRD, RBAC etc.
manifests:
	go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all

deploy: manifests
	kubectl apply -f config/crds
	kustomize build config/default | kubectl apply -f -

# Generate DeepCopy to implement runtime.Object
deepcopy:
H
hongming 已提交
67
	./vendor/k8s.io/code-generator/generate-groups.sh all kubesphere.io/kubesphere/pkg/client kubesphere.io/kubesphere/pkg/apis "servicemesh:v1alpha2 tenant:v1alpha1"
J
jeff 已提交
68

J
jeff 已提交
69 70 71 72 73 74 75 76
# 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
H
hongming 已提交
77
docker-build: all
J
jeff 已提交
78 79 80 81
	docker build . -t ${IMG}

# Run tests
test: generate fmt vet
H
hongming 已提交
82
	go test ./pkg/... ./cmd/... -coverprofile cover.out
J
jeff 已提交
83 84 85 86 87

.PHONY: clean
clean:
	-make -C ./pkg/version clean
	@echo "ok"