Skip to content

Commit 7b13168

Browse files
committed
makefile: utilities and review layout
Signed-off-by: CrazyMax <[email protected]>
1 parent 1b9bd75 commit 7b13168

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ help: ## show make targets
99

1010
.PHONY: clean-src
1111
clean-src:
12-
[ ! -d src ] || $(CHOWN) -R $(shell id -u):$(shell id -g) src
13-
$(RM) -r src
12+
@[ ! -d src ] || $(CHOWN) -R $(shell id -u):$(shell id -g) src
13+
@$(RM) -r src
1414

1515
.PHONY: src
1616
src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/buildx src/github.com/docker/compose src/github.com/docker/scan-cli-plugin ## clone source
@@ -50,22 +50,27 @@ src/github.com/docker/scan-cli-plugin:
5050

5151
.PHONY: checkout-cli
5252
checkout-cli: src/github.com/docker/cli
53+
$(call title,Checkout $(DOCKER_CLI_REPO)#$(DOCKER_CLI_REF))
5354
./scripts/checkout.sh src/github.com/docker/cli "$(DOCKER_CLI_REF)"
5455

5556
.PHONY: checkout-docker
5657
checkout-docker: src/github.com/docker/docker
58+
$(call title,Checkout $(DOCKER_ENGINE_REPO)#$(DOCKER_ENGINE_REF))
5759
./scripts/checkout.sh src/github.com/docker/docker "$(DOCKER_ENGINE_REF)"
5860

5961
.PHONY: checkout-buildx
6062
checkout-buildx: src/github.com/docker/buildx
63+
$(call title,Checkout $(DOCKER_BUILDX_REPO)#$(DOCKER_BUILDX_REF))
6164
./scripts/checkout.sh src/github.com/docker/buildx "$(DOCKER_BUILDX_REF)"
6265

6366
.PHONY: checkout-compose
6467
checkout-compose: src/github.com/docker/compose
68+
$(call title,Checkout $(DOCKER_COMPOSE_REPO)#$(DOCKER_COMPOSE_REF))
6569
./scripts/checkout.sh src/github.com/docker/compose "$(DOCKER_COMPOSE_REF)"
6670

6771
.PHONY: checkout-scan-cli-plugin
6872
checkout-scan-cli-plugin: src/github.com/docker/scan-cli-plugin
73+
$(call title,Checkout $(DOCKER_SCAN_REPO)#$(DOCKER_SCAN_REF))
6974
./scripts/checkout.sh src/github.com/docker/scan-cli-plugin "$(DOCKER_SCAN_REF)"
7075

7176
.PHONY: checkout

common.mk

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,17 @@ export DOCKER_ENGINE_REF
6363
export DOCKER_SCAN_REF
6464
export DOCKER_COMPOSE_REF
6565
export DOCKER_BUILDX_REF
66+
67+
# utilities
68+
BOLD := $(shell tput -T linux bold)
69+
PURPLE := $(shell tput -T linux setaf 5)
70+
GREEN := $(shell tput -T linux setaf 2)
71+
CYAN := $(shell tput -T linux setaf 6)
72+
RED := $(shell tput -T linux setaf 1)
73+
RESET := $(shell tput -T linux sgr0)
74+
TITLE := $(BOLD)$(PURPLE)
75+
SUCCESS := $(BOLD)$(GREEN)
76+
77+
define title
78+
@printf '$(TITLE)$(1)$(RESET)\n'
79+
endef

scripts/checkout.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616

1717
checkout() (
18-
set -ex
18+
set -e
1919
SRC="$1"
2020
REF="$2"
2121
REF_FETCH="$REF"
@@ -27,11 +27,13 @@ checkout() (
2727
else
2828
REF="FETCH_HEAD"
2929
fi
30-
git -C "$SRC" fetch --update-head-ok --depth 1 origin "$REF_FETCH"
31-
git -C "$SRC" checkout -q "$REF"
30+
(
31+
set -x
32+
git -C "$SRC" fetch --update-head-ok --depth 1 origin "$REF_FETCH"
33+
git -C "$SRC" checkout -q "$REF"
34+
)
3235
)
3336

34-
3537
# Only execute checkout function above if this file is executed, not sourced from another script
3638
prog=checkout.sh # needs to be in sync with this file's name
3739
if [ "$(basename -- $0)" = "$prog" ]; then

static/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@ export CONTAINERD_VERSION
1717
export RUNC_VERSION
1818

1919
.PHONY: help
20-
help:
21-
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(BOLD)$(CYAN)%-25s$(RESET)%s\n", $$1, $$2}'
20+
help: ## show make targets
21+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
2222

2323
.PHONY: clean
2424
clean: ## remove build artifacts
25+
$(call title,Removing build artifacts)
2526
@[ ! -d build ] || $(CHOWN) -R $(shell id -u):$(shell id -g) build
2627
@$(RM) -r build
2728

2829
.PHONY: build
2930
build: ## build static package
31+
$(call title,Building static package for $(TARGETPLATFORM))
3032
./build-static "$(CURDIR)" "$(TARGETPLATFORM)"
3133

3234
.PHONY: hash_files
3335
hash_files: ## hash files
34-
@echo "Hashing directory $(DIR_TO_HASH)"
36+
$(call title,Hashing directory $(DIR_TO_HASH))
3537
$(HASH_CMD) "$(DIR_TO_HASH)"

0 commit comments

Comments
 (0)