|
@@ -2,16 +2,20 @@
|
|
|
|
|
|
|
|
BINARY := ./imgproxy
|
|
BINARY := ./imgproxy
|
|
|
|
|
|
|
|
|
|
+MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
|
GOCMD := go
|
|
GOCMD := go
|
|
|
GOBUILD := $(GOCMD) build
|
|
GOBUILD := $(GOCMD) build
|
|
|
GOCLEAN := $(GOCMD) clean
|
|
GOCLEAN := $(GOCMD) clean
|
|
|
GOTEST := $(GOCMD) test
|
|
GOTEST := $(GOCMD) test
|
|
|
GOFMT := gofmt
|
|
GOFMT := gofmt
|
|
|
GOLINT := golangci-lint
|
|
GOLINT := golangci-lint
|
|
|
|
|
+CLANG_FORMAT := clang-format
|
|
|
GOTESTSUM := gotestsum
|
|
GOTESTSUM := gotestsum
|
|
|
SRCDIR := ./cli
|
|
SRCDIR := ./cli
|
|
|
RCFILE := ./.imgproxyrc
|
|
RCFILE := ./.imgproxyrc
|
|
|
BREW_PREFIX :=
|
|
BREW_PREFIX :=
|
|
|
|
|
+DEVROOT_TMP_DIR ?= $(MAKEFILE_DIR).tmp/_dev-root
|
|
|
|
|
+BASE_IMAGE ?= ghcr.io/imgproxy/imgproxy-base:v4-dev
|
|
|
|
|
|
|
|
# Common environment setup for CGO builds
|
|
# Common environment setup for CGO builds
|
|
|
ifneq ($(shell which brew),)
|
|
ifneq ($(shell which brew),)
|
|
@@ -43,6 +47,23 @@ ifeq (build-and-run,$(firstword $(MAKECMDGOALS)))
|
|
|
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
|
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
|
|
endif
|
|
endif
|
|
|
|
|
|
|
|
|
|
+# Wrapper action to run commands in Docker
|
|
|
|
|
+.PHONY: _run-in-docker
|
|
|
|
|
+_run-in-docker:
|
|
|
|
|
+ifdef IMGPROXY_IN_BASE_CONTAINER
|
|
|
|
|
+ @$(MAKE) $(DOCKERCMD)
|
|
|
|
|
+else
|
|
|
|
|
+ @mkdir -p ${DEVROOT_TMP_DIR}/.cache ${DEVROOT_TMP_DIR}/go/pkg/mod
|
|
|
|
|
+ @docker run --init --rm -it \
|
|
|
|
|
+ -v "$(MAKEFILE_DIR):/workspaces/imgproxy" \
|
|
|
|
|
+ -v "${DEVROOT_TMP_DIR}/.cache:/root/.cache" \
|
|
|
|
|
+ -v "${DEVROOT_TMP_DIR}/go/pkg/mod:/root/go/pkg/mod" \
|
|
|
|
|
+ -w /workspaces/imgproxy \
|
|
|
|
|
+ -e IMGPROXY_IN_BASE_CONTAINER=1 \
|
|
|
|
|
+ $(BASE_IMAGE) \
|
|
|
|
|
+ bash -c "make $(DOCKERCMD)"
|
|
|
|
|
+endif
|
|
|
|
|
+
|
|
|
# Default target
|
|
# Default target
|
|
|
.PHONY: all
|
|
.PHONY: all
|
|
|
all: build
|
|
all: build
|
|
@@ -84,8 +105,10 @@ build-and-run: build run
|
|
|
#
|
|
#
|
|
|
# Usage:
|
|
# Usage:
|
|
|
# make test -- -run FooTest
|
|
# make test -- -run FooTest
|
|
|
-.PHONY: test
|
|
|
|
|
-test:
|
|
|
|
|
|
|
+.PHONY: test _test
|
|
|
|
|
+test: DOCKERCMD := _test
|
|
|
|
|
+test: _run-in-docker
|
|
|
|
|
+_test:
|
|
|
ifneq ($(shell which $(GOTESTSUM)),)
|
|
ifneq ($(shell which $(GOTESTSUM)),)
|
|
|
@$(GOTESTSUM) ./...
|
|
@$(GOTESTSUM) ./...
|
|
|
else
|
|
else
|
|
@@ -98,10 +121,23 @@ fmt:
|
|
|
@$(GOFMT) -s -w .
|
|
@$(GOFMT) -s -w .
|
|
|
|
|
|
|
|
# Lint code (requires golangci-lint installed)
|
|
# Lint code (requires golangci-lint installed)
|
|
|
-.PHONY: lint
|
|
|
|
|
-lint:
|
|
|
|
|
|
|
+.PHONY: lint-go _lint-go
|
|
|
|
|
+lint-go: DOCKERCMD := _lint-go
|
|
|
|
|
+lint-go: _run-in-docker
|
|
|
|
|
+_lint-go:
|
|
|
@$(GOLINT) run
|
|
@$(GOLINT) run
|
|
|
|
|
|
|
|
|
|
+# Lint C code (requires clang-format installed)
|
|
|
|
|
+.PHONE: lint-clang _lint-clang
|
|
|
|
|
+ling-clang: DOCKERCMD := _lint-clang
|
|
|
|
|
+ling-clang: _run-in-docker
|
|
|
|
|
+_lint-clang:
|
|
|
|
|
+ @find . -not -path "./.tmp/*" -not -path "./.git/*" \( -iname "*.h" -o -iname "*.c" -o -iname "*.cpp" \) | xargs $(CLANG_FORMAT) --dry-run --Werror
|
|
|
|
|
+
|
|
|
|
|
+# Run all linters
|
|
|
|
|
+.PHONY: lint
|
|
|
|
|
+lint: lint-go ling-clang
|
|
|
|
|
+
|
|
|
# Upgrade direct Go dependencies
|
|
# Upgrade direct Go dependencies
|
|
|
.PHONY: upgrade
|
|
.PHONY: upgrade
|
|
|
upgrade:
|
|
upgrade:
|
|
@@ -109,6 +145,18 @@ upgrade:
|
|
|
@$(GOCMD) get $$($(GOCMD) list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all)
|
|
@$(GOCMD) get $$($(GOCMD) list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all)
|
|
|
@$(GOCMD) mod tidy
|
|
@$(GOCMD) mod tidy
|
|
|
|
|
|
|
|
|
|
+# Run lychee
|
|
|
|
|
+.PHONY: lychee _lychee
|
|
|
|
|
+lychee: DOCKERCMD := _lychee
|
|
|
|
|
+lychee: _run-in-docker
|
|
|
|
|
+_lychee:
|
|
|
|
|
+ lychee docs README.md CHANGELOG.md --exclude localhost --exclude twitter.com --exclude x.com --exclude-path docs/index.html
|
|
|
|
|
+
|
|
|
|
|
+.PHONY: devcontainer
|
|
|
|
|
+devcontainer:
|
|
|
|
|
+ devcontainer exec --workspace-folder $(MAKEFILE_DIR) --config .devcontainer/oss/devcontainer.json bash
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
# Make any unknown target do nothing to avoid "up to date" messages
|
|
# Make any unknown target do nothing to avoid "up to date" messages
|
|
|
.PHONY: FORCE
|
|
.PHONY: FORCE
|
|
|
%: FORCE
|
|
%: FORCE
|