-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (47 loc) · 1.7 KB
/
Makefile
File metadata and controls
62 lines (47 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
GO := go
BIN_DIR := bin
BIN := $(BIN_DIR)/gryph
SHELL := /bin/bash
GITCOMMIT := $(shell git rev-parse HEAD)
VERSION := "$(shell git describe --tags --abbrev=0 2>/dev/null || echo v0.0.0)-$(shell git rev-parse --short HEAD)"
GO_CFLAGS=-X 'github.com/safedep/gryph/internal/version.Commit=$(GITCOMMIT)' -X 'github.com/safedep/gryph/internal/version.Version=$(VERSION)'
GO_LDFLAGS=-ldflags "-w $(GO_CFLAGS)"
.PHONY: all deps generate generate-schema verify-schema gryph clean test
all: gryph
# Install dependencies
deps:
$(GO) mod download
$(GO) mod tidy
# Generate ent code
generate:
$(GO) generate ./storage/ent/...
# Generate Event JSON Schema
generate-schema:
$(GO) run ./cmd/jsonschema-gen
# Update bundled pricing data from models.dev
update-pricing:
$(GO) run pricing/scripts/update-pricing.go
# Verify Event JSON Schema is up-to-date
verify-schema: generate-schema
@git diff --exit-code schema/event.schema.json || (echo "ERROR: schema/event.schema.json is out of date. Run 'make generate-schema' and commit the result." && exit 1)
# Build gryph binary
gryph: create_bin
$(GO) build ${GO_LDFLAGS} -o $(BIN) ./cmd/gryph
create_bin:
mkdir -p $(BIN_DIR)
clean:
rm -rf $(BIN_DIR)
test:
$(GO) test ./...
# Format code
fmt:
$(GO) fmt ./...
# Run linter
lint:
golangci-lint run
# Build for all platforms
build-all: create_bin
GOOS=darwin GOARCH=amd64 $(GO) build ${GO_LDFLAGS} -o $(BIN_DIR)/gryph-darwin-amd64 ./cmd/gryph
GOOS=darwin GOARCH=arm64 $(GO) build ${GO_LDFLAGS} -o $(BIN_DIR)/gryph-darwin-arm64 ./cmd/gryph
GOOS=linux GOARCH=amd64 $(GO) build ${GO_LDFLAGS} -o $(BIN_DIR)/gryph-linux-amd64 ./cmd/gryph
GOOS=windows GOARCH=amd64 $(GO) build ${GO_LDFLAGS} -o $(BIN_DIR)/gryph-windows-amd64.exe ./cmd/gryph