2020-12-30 15:26:25 +00:00
|
|
|
# Keep the Makefile POSIX-compliant. We currently allow hyphens in
|
|
|
|
# target names, but that may change in the future.
|
2020-07-09 17:54:53 +01:00
|
|
|
#
|
2020-12-30 15:26:25 +00:00
|
|
|
# See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html.
|
|
|
|
.POSIX:
|
|
|
|
|
2023-02-21 14:07:12 +00:00
|
|
|
# This comment is used to simplify checking local copies of the
|
|
|
|
# Makefile. Bump this number every time a significant change is made to
|
|
|
|
# this Makefile.
|
|
|
|
#
|
|
|
|
# AdGuard-Project-Version: 2
|
|
|
|
|
|
|
|
# Don't name these macros "GO" etc., because GNU Make apparently makes
|
|
|
|
# them exported environment variables with the literal value of
|
|
|
|
# "${GO:-go}" and so on, which is not what we need. Use a dot in the
|
|
|
|
# name to make sure that users don't have an environment variable with
|
|
|
|
# the same name.
|
|
|
|
#
|
|
|
|
# See https://unix.stackexchange.com/q/646255/105635.
|
|
|
|
GO.MACRO = $${GO:-go}
|
|
|
|
VERBOSE.MACRO = $${VERBOSE:-0}
|
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
CHANNEL = development
|
|
|
|
CLIENT_DIR = client
|
2021-04-22 18:06:34 +01:00
|
|
|
COMMIT = $$( git rev-parse --short HEAD )
|
2020-12-30 15:26:25 +00:00
|
|
|
DIST_DIR = dist
|
2021-03-12 12:05:16 +00:00
|
|
|
GOPROXY = https://goproxy.cn|https://proxy.golang.org|direct
|
2022-03-28 15:05:19 +01:00
|
|
|
GOSUMDB = sum.golang.google.cn
|
2020-12-30 17:36:57 +00:00
|
|
|
GPG_KEY = devteam@adguard.com
|
2020-12-30 15:26:25 +00:00
|
|
|
GPG_KEY_PASSPHRASE = not-a-real-password
|
|
|
|
NPM = npm
|
|
|
|
NPM_FLAGS = --prefix $(CLIENT_DIR)
|
2021-04-08 11:55:12 +01:00
|
|
|
NPM_INSTALL_FLAGS = $(NPM_FLAGS) --quiet --no-progress --ignore-engines\
|
|
|
|
--ignore-optional --ignore-platform --ignore-scripts
|
2021-04-02 11:44:55 +01:00
|
|
|
RACE = 0
|
2020-12-30 15:26:25 +00:00
|
|
|
SIGN = 1
|
|
|
|
VERSION = v0.0.0
|
|
|
|
YARN = yarn
|
|
|
|
|
2022-10-04 14:02:55 +01:00
|
|
|
NEXTAPI = 0
|
2022-04-26 18:50:09 +01:00
|
|
|
|
2021-05-21 12:55:42 +01:00
|
|
|
# Macros for the build-release target. If FRONTEND_PREBUILT is 0, the
|
|
|
|
# default, the macro $(BUILD_RELEASE_DEPS_$(FRONTEND_PREBUILT)) expands
|
|
|
|
# into BUILD_RELEASE_DEPS_0, and so both frontend and backend
|
|
|
|
# dependencies are fetched and the frontend is built. Otherwise, if
|
|
|
|
# FRONTEND_PREBUILT is 1, only backend dependencies are fetched and the
|
2022-08-15 16:46:19 +01:00
|
|
|
# frontend isn't rebuilt.
|
2021-05-21 12:55:42 +01:00
|
|
|
#
|
|
|
|
# TODO(a.garipov): We could probably do that from .../build-release.sh,
|
|
|
|
# but that would mean either calling make from inside make or
|
|
|
|
# duplicating commands in two places, both of which don't seem to me
|
|
|
|
# like nice solutions.
|
|
|
|
FRONTEND_PREBUILT = 0
|
|
|
|
BUILD_RELEASE_DEPS_0 = deps js-build
|
|
|
|
BUILD_RELEASE_DEPS_1 = go-deps
|
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
ENV = env\
|
|
|
|
COMMIT='$(COMMIT)'\
|
|
|
|
CHANNEL='$(CHANNEL)'\
|
2020-12-30 17:36:57 +00:00
|
|
|
GPG_KEY='$(GPG_KEY)'\
|
2020-12-30 15:26:25 +00:00
|
|
|
GPG_KEY_PASSPHRASE='$(GPG_KEY_PASSPHRASE)'\
|
|
|
|
DIST_DIR='$(DIST_DIR)'\
|
2021-04-22 18:06:34 +01:00
|
|
|
GO="$(GO.MACRO)"\
|
2020-12-30 15:26:25 +00:00
|
|
|
GOPROXY='$(GOPROXY)'\
|
2022-03-28 15:05:19 +01:00
|
|
|
GOSUMDB='$(GOSUMDB)'\
|
2021-04-22 18:06:34 +01:00
|
|
|
PATH="$${PWD}/bin:$$( "$(GO.MACRO)" env GOPATH )/bin:$${PATH}"\
|
2021-04-02 11:44:55 +01:00
|
|
|
RACE='$(RACE)'\
|
2020-12-30 15:26:25 +00:00
|
|
|
SIGN='$(SIGN)'\
|
2022-10-04 14:02:55 +01:00
|
|
|
NEXTAPI='$(NEXTAPI)'\
|
2023-02-21 14:07:12 +00:00
|
|
|
VERBOSE="$(VERBOSE.MACRO)"\
|
2020-12-30 15:26:25 +00:00
|
|
|
VERSION='$(VERSION)'\
|
|
|
|
|
|
|
|
# Keep the line above blank.
|
|
|
|
|
2023-02-21 14:07:12 +00:00
|
|
|
# Keep this target first, so that a naked make invocation triggers a
|
|
|
|
# full build.
|
2020-12-30 15:26:25 +00:00
|
|
|
build: deps quick-build
|
|
|
|
|
|
|
|
quick-build: js-build go-build
|
|
|
|
|
2023-07-07 16:27:33 +01:00
|
|
|
ci: deps test go-bench go-fuzz
|
2020-12-30 15:26:25 +00:00
|
|
|
|
|
|
|
deps: js-deps go-deps
|
2020-12-08 15:23:35 +00:00
|
|
|
lint: js-lint go-lint
|
|
|
|
test: js-test go-test
|
|
|
|
|
2020-12-30 15:26:25 +00:00
|
|
|
# Here and below, keep $(SHELL) in quotes, because on Windows this will
|
|
|
|
# expand to something like "C:/Program Files/Git/usr/bin/sh.exe".
|
|
|
|
build-docker: ; $(ENV) "$(SHELL)" ./scripts/make/build-docker.sh
|
|
|
|
|
2021-05-21 12:55:42 +01:00
|
|
|
build-release: $(BUILD_RELEASE_DEPS_$(FRONTEND_PREBUILT))
|
2020-12-30 15:26:25 +00:00
|
|
|
$(ENV) "$(SHELL)" ./scripts/make/build-release.sh
|
|
|
|
|
|
|
|
clean: ; $(ENV) "$(SHELL)" ./scripts/make/clean.sh
|
|
|
|
init: ; git config core.hooksPath ./scripts/hooks
|
|
|
|
|
|
|
|
js-build:
|
|
|
|
$(NPM) $(NPM_FLAGS) run build-prod
|
|
|
|
js-deps:
|
2021-04-08 11:55:12 +01:00
|
|
|
$(NPM) $(NPM_INSTALL_FLAGS) ci
|
2021-01-28 11:02:38 +00:00
|
|
|
|
|
|
|
# TODO(a.garipov): Remove the legacy client tasks support once the new
|
|
|
|
# client is done and the old one is removed.
|
|
|
|
js-lint: ; $(NPM) $(NPM_FLAGS) run lint
|
|
|
|
js-test: ; $(NPM) $(NPM_FLAGS) run test
|
2020-07-09 17:54:53 +01:00
|
|
|
|
2023-07-07 16:27:33 +01:00
|
|
|
go-bench: ; $(ENV) "$(SHELL)" ./scripts/make/go-bench.sh
|
2020-12-30 15:26:25 +00:00
|
|
|
go-build: ; $(ENV) "$(SHELL)" ./scripts/make/go-build.sh
|
|
|
|
go-deps: ; $(ENV) "$(SHELL)" ./scripts/make/go-deps.sh
|
2023-07-07 16:27:33 +01:00
|
|
|
go-fuzz: ; $(ENV) "$(SHELL)" ./scripts/make/go-fuzz.sh
|
2020-12-30 15:26:25 +00:00
|
|
|
go-lint: ; $(ENV) "$(SHELL)" ./scripts/make/go-lint.sh
|
|
|
|
go-tools: ; $(ENV) "$(SHELL)" ./scripts/make/go-tools.sh
|
2020-07-09 17:54:53 +01:00
|
|
|
|
2021-04-02 11:44:55 +01:00
|
|
|
# TODO(a.garipov): Think about making RACE='1' the default for all
|
|
|
|
# targets.
|
|
|
|
go-test: ; $(ENV) RACE='1' "$(SHELL)" ./scripts/make/go-test.sh
|
|
|
|
|
2021-01-27 15:32:13 +00:00
|
|
|
go-check: go-tools go-lint go-test
|
|
|
|
|
2021-04-08 18:42:04 +01:00
|
|
|
# A quick check to make sure that all supported operating systems can be
|
|
|
|
# typechecked and built successfully.
|
|
|
|
go-os-check:
|
2021-04-22 18:06:34 +01:00
|
|
|
env GOOS='darwin' "$(GO.MACRO)" vet ./internal/...
|
|
|
|
env GOOS='freebsd' "$(GO.MACRO)" vet ./internal/...
|
2021-06-03 19:04:13 +01:00
|
|
|
env GOOS='openbsd' "$(GO.MACRO)" vet ./internal/...
|
2021-04-22 18:06:34 +01:00
|
|
|
env GOOS='linux' "$(GO.MACRO)" vet ./internal/...
|
|
|
|
env GOOS='windows' "$(GO.MACRO)" vet ./internal/...
|
2021-04-08 18:42:04 +01:00
|
|
|
|
2021-01-14 10:48:52 +00:00
|
|
|
openapi-lint: ; cd ./openapi/ && $(YARN) test
|
2021-01-27 15:32:13 +00:00
|
|
|
openapi-show: ; cd ./openapi/ && $(YARN) start
|
2021-05-19 18:31:20 +01:00
|
|
|
|
2023-02-21 14:07:12 +00:00
|
|
|
txt-lint: ; $(ENV) "$(SHELL)" ./scripts/make/txt-lint.sh
|