mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
Add a way to list imports and files used by specific binaries
This commit adds a new Make target that makes use of go list to show directly imported packages and used files in a given binary. This target should be added in all future targets that build binaries, if listing imported packages and used files is important. Existing targets were modified to include build-metadata. Also, since build-metadata depends on EXTENSIONS variable, a dummy tag is used to overwrite the defaults of this variable in case of minimal-type targets. Signed-off-by: Alex Stan <alexandrustan96@yahoo.ro>
This commit is contained in:
parent
4ae1a908a0
commit
9194fea6d4
1 changed files with 15 additions and 6 deletions
21
Makefile
21
Makefile
|
@ -34,28 +34,37 @@ ifdef EXTENSIONS
|
|||
$(eval extended-name=-$(subst $(comma),$(hyphen),$(EXTENSIONS)))
|
||||
endif
|
||||
|
||||
.PHONY: build-metadata
|
||||
build-metadata:
|
||||
echo "Imports: \n"
|
||||
go list -tags $(EXTENSIONS) -f '{{ join .Imports "\n" }}' ./... | sort -u
|
||||
echo "\n Files: \n"
|
||||
go list -tags $(EXTENSIONS) -f '{{ join .GoFiles "\n" }}' ./... | sort -u
|
||||
|
||||
.PHONY: binary
|
||||
binary: modcheck swagger create-name
|
||||
binary: modcheck swagger create-name build-metadata
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH) -buildmode=pie -tags $(EXTENSIONS),containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=$(extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot
|
||||
|
||||
.PHONY: binary-debug
|
||||
binary-debug: modcheck swagger create-name
|
||||
binary-debug: modcheck swagger create-name build-metadata
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-debug -buildmode=pie -tags $(EXTENSIONS),containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=$(extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot
|
||||
|
||||
.PHONY: binary-minimal
|
||||
binary-minimal: modcheck swagger
|
||||
binary-minimal: EXTENSIONS=minimal # tag doesn't exist, but we need it to overwrite default value and indicate that we have no extension in build-metadata
|
||||
binary-minimal: modcheck swagger build-metadata
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-minimal -buildmode=pie -tags containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=minimal -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot
|
||||
|
||||
.PHONY: cli
|
||||
cli: modcheck create-name
|
||||
cli: modcheck create-name build-metadata
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zli-$(OS)-$(ARCH) -buildmode=pie -tags $(EXTENSIONS),ui_base,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=$(extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zli
|
||||
|
||||
.PHONY: bench
|
||||
bench: modcheck create-name
|
||||
bench: modcheck create-name build-metadata
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zb-$(OS)-$(ARCH) -buildmode=pie -tags $(EXTENSIONS),containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=$(extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zb
|
||||
|
||||
.PHONY: exporter-minimal
|
||||
exporter-minimal: modcheck
|
||||
exporter-minimal: EXTENSIONS=minimal # tag doesn't exist, but we need it to overwrite default value and indicate that we have no extension in build-metadata
|
||||
exporter-minimal: modcheck build-metadata
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zxp-$(OS)-$(ARCH) -buildmode=pie -tags containers_image_openpgp -v -trimpath ./cmd/zxp
|
||||
|
||||
.PHONY: test
|
||||
|
|
Loading…
Reference in a new issue