From eb6796891148c95a3d57d44fbbc18ac28273a200 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 17 Aug 2021 11:54:13 +0200 Subject: [PATCH] Add cmds target to makefile to build all go commands Signed-off-by: Evan Lezar --- .gitignore | 2 ++ Makefile | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a38c2b0c..3cf3c7a8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ dist *.swo /coverage.out /test/output/ +/nvidia-container-runtime +/nvidia-container-toolkit diff --git a/Makefile b/Makefile index 5017cc78..f04ce31b 100644 --- a/Makefile +++ b/Makefile @@ -37,18 +37,26 @@ BUILDIMAGE ?= $(IMAGE):$(IMAGE_TAG)-devel EXAMPLES := $(patsubst ./examples/%/,%,$(sort $(dir $(wildcard ./examples/*/)))) EXAMPLE_TARGETS := $(patsubst %,example-%, $(EXAMPLES)) -CHECK_TARGETS := assert-fmt vet lint ineffassign misspell -MAKE_TARGETS := binary build all check fmt lint-internal test examples coverage generate $(CHECK_TARGETS) +CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/)))) +CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) -TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS) +$(info CMD_TARGETS=$(CMD_TARGETS)) + +CHECK_TARGETS := assert-fmt vet lint ineffassign misspell +MAKE_TARGETS := binary build all check fmt lint-internal test examples cmds coverage generate $(CHECK_TARGETS) + +TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS) $(CMD_TARGETS) DOCKER_TARGETS := $(patsubst %,docker-%, $(TARGETS)) .PHONY: $(TARGETS) $(DOCKER_TARGETS) GOOS ?= linux -binary: - GOOS=$(GOOS) go build -ldflags "-s -w" -o "$(LIB_NAME)" $(MODULE)/cmd/$(LIB_NAME) +binary: cmd-nvidia-container-toolkit + +cmds: $(CMD_TARGETS) +$(CMD_TARGETS): cmd-%: + GOOS=$(GOOS) go build -ldflags "-s -w" $(MODULE)/cmd/$(*) build: GOOS=$(GOOS) go build ./... @@ -95,7 +103,7 @@ vet: go vet $(MODULE)/... COVERAGE_FILE := coverage.out -test: build +test: build cmds go test -v -coverprofile=$(COVERAGE_FILE) $(MODULE)/... coverage: test