-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathmakefile
More file actions
92 lines (74 loc) · 2.33 KB
/
makefile
File metadata and controls
92 lines (74 loc) · 2.33 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
VERSION ?= v6.2.1
IMAGE ?= mydaemon
HOST_PORT ?= 8080
GOOS ?= linux
GOARCH ?= amd64
# Detect OS
ifeq ($(OS),Windows_NT)
SHELL := pwsh
IS_WINDOWS := 1
else
IS_WINDOWS := 0
endif
# Only define SNET_CONFIG for docker-run on host
ifeq ($(IS_WINDOWS),1)
SNET_CONFIG := $(shell pwsh -Command "Write-Output $$PWD")/snet-config
else
SNET_CONFIG := $(PWD)/snet-config
endif
.PHONY: build release run test clean build_in_docker gen lint help
define RUN_SCRIPT
$(if $(IS_WINDOWS),pwsh -File ./scripts/powershell/$(1).ps1 $(2),bash ./scripts/$(1) $(2))
endef
gen:
$(call RUN_SCRIPT,install_deps)
gen-artifacts:gen
install-deps:gen
# Build the project
build:
gen
$(call RUN_SCRIPT,build,$(GOOS) $(GOARCH) $(VERSION))
build-in-docker:
$(call RUN_SCRIPT,build_in_docker)
# Build a Docker image from source
docker-build:
docker build -f docker/Dockerfile.build -t $(IMAGE):$(VERSION) .
# Build a Docker image from GitHub releases
docker-release:
docker build -f docker/Dockerfile.release -t $(IMAGE):$(VERSION) .
docker-run:
ifeq ($(IS_WINDOWS),1)
SNET_CONFIG := $(shell pwsh -Command "Write-Output $$PWD")/snet-config
else
SNET_CONFIG := $(PWD)/snet-config
endif
ifeq ($(wildcard $(SNET_CONFIG)/snetd.config.json),)
$(error "snet-config/snetd.config.json not found! Create config before docker-run")
endif
docker run --rm -it -v "$(SNET_CONFIG):/etc/singnet:ro" -p $(HOST_PORT):$(HOST_PORT) $(IMAGE):$(VERSION)
lint:
golangci-lint run
# Run tests
test:
go test ./...
clean:
ifeq ($(OS),Windows_NT)
del /Q /S build
else
rm -rf build
endif
help:
@echo "Available make targets:"
@echo " build - Build the daemon binary, Example: make build GOOS=linux GOARCH=amd64 VERSION=v6.2.1"
@echo " release - Build release version"
@echo " run - Run the daemon locally"
@echo " build_in_docker - Build the daemon inside Docker"
@echo " docker-build - Build Docker image from source"
@echo " docker-release - Build Docker image from GitHub release"
@echo " docker-run - Run Docker container with daemon"
@echo " gen - Generate proto and smart-contract bindings"
@echo " lint - Run linter"
@echo " test - Run tests"
@echo " clean - Remove build artifacts"
@echo " gen-artifacts - Alias for gen"
@echo " install-deps - Alias for gen"