Files

62 lines
1.4 KiB
Makefile
Raw Permalink Normal View History

#! /usr/bin/make -f
2023-04-12 13:51:35 +03:00
# Project variables.
VERSION := $(shell git describe --tags 2>/dev/null || git describe --all)
BUILD := $(shell git rev-parse --short HEAD)
PROJECT_NAME := $(shell basename "$(PWD)")
BUILD_TARGETS := $(shell find cmd -name \*main.go | awk -F'/' '{print $$0}')
2023-04-12 13:51:35 +03:00
# Use linker flags to provide version/build settings
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"
2023-04-12 13:51:35 +03:00
# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent
# Go files.
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
# Common commands.
2025-12-31 22:21:30 -08:00
all: fmt test
2023-04-12 13:51:35 +03:00
build:
@echo " > Building main.go to bin/assets"
go build $(LDFLAGS) -o bin/assets ./cmd
test:
@echo " > Running unit tests"
2023-04-12 13:51:35 +03:00
go test -cover -race -coverprofile=coverage.txt -covermode=atomic -v ./...
fmt:
@echo " > Format all go files"
2023-04-12 13:51:35 +03:00
gofmt -w ${GOFMT_FILES}
lint-install:
ifeq (,$(wildcard test -f bin/golangci-lint))
@echo " > Installing golint"
2023-01-03 17:22:56 +02:00
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.50.1
endif
lint: lint-install
@echo " > Running golint"
bin/golangci-lint run --timeout=2m
# Assets commands.
2023-04-12 13:51:35 +03:00
check: build
bin/assets check
2023-04-12 13:51:35 +03:00
fix: build
bin/assets fix
2023-04-12 13:51:35 +03:00
update-auto: build
bin/assets update-auto
# Helper commands.
2023-04-12 13:51:35 +03:00
add-token: build
bin/assets add-token $(asset_id)
2023-04-12 13:51:35 +03:00
add-tokenlist: build
bin/assets add-tokenlist $(asset_id)
2023-04-12 13:51:35 +03:00
add-tokenlist-extended: build
bin/assets add-tokenlist-extended $(asset_id)