38 lines
1.0 KiB
Makefile
38 lines
1.0 KiB
Makefile
# Variables
|
|
CLIENT_PKG := ./cmd/eia-client
|
|
CLIENT_GEN_FILE := ./api/eiaapi.gen.go
|
|
GO_FORMATTER := gofumpt
|
|
IS_GNU_SED := $(shell sed --version >/dev/null 2>&1 && echo true || echo false)
|
|
|
|
.PHONY: all generate build install clean
|
|
|
|
# Default target
|
|
all: generate build
|
|
|
|
# Generate code
|
|
generate:
|
|
go generate ./...
|
|
ifeq ($(IS_GNU_SED), true)
|
|
# Fix errors in generated code with GNU sed
|
|
sed -E -i 's/Total[[:space:]]+\*int/Total *string/g' $(CLIENT_GEN_FILE)
|
|
sed -E -i 's/Command[[:space:]]+\*\[\]string/Command *string/g' $(CLIENT_GEN_FILE)
|
|
else
|
|
# Fix errors in generated code with BSD sed
|
|
sed -E -i '' 's/Total[[:space:]]+\*int/Total *string/g' $(CLIENT_GEN_FILE)
|
|
sed -E -i '' 's/Command[[:space:]]+\*\[\]string/Command *string/g' $(CLIENT_GEN_FILE)
|
|
endif
|
|
# Pretty it up
|
|
$(GO_FORMATTER) -w $(CLIENT_GEN_FILE)
|
|
|
|
# Build the client command binary
|
|
build: generate
|
|
go build -o bin/eia-client $(CLIENT_PKG)
|
|
|
|
# Install the client command binary
|
|
install: generate
|
|
go install -v $(CLIENT_PKG)
|
|
|
|
# Clean up generated files and build artifacts
|
|
clean:
|
|
rm -rf bin/eia-client
|