-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
GNUmakefile
112 lines (91 loc) · 3.46 KB
/
GNUmakefile
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
.DEFAULT_GOAL := build
ENVIRONMENT ?= release
REPO := smartcontract/chainlink
COMMIT_SHA ?= $(shell git rev-parse HEAD)
VERSION = $(shell cat VERSION)
GOBIN ?= $(GOPATH)/bin
GO_LDFLAGS := $(shell tools/bin/ldflags)
GOFLAGS = -ldflags "$(GO_LDFLAGS)"
DOCKERFILE := core/chainlink.Dockerfile
DOCKER_TAG ?= latest
# SGX is disabled by default, but turned on when building from Docker
SGX_ENABLED ?= no
SGX_SIMULATION ?= yes
SGX_ENCLAVE := enclave.signed.so
SGX_TARGET := ./core/sgx/target/$(ENVIRONMENT)/
ifneq (,$(filter yes true,$(SGX_ENABLED)))
GOFLAGS += -tags=sgx_enclave
SGX_BUILD_ENCLAVE := $(SGX_ENCLAVE)
DOCKERFILE := core/chainlink-sgx.Dockerfile
REPO := $(REPO)-sgx
else
SGX_BUILD_ENCLAVE :=
endif
TAGGED_REPO := $(REPO):$(DOCKER_TAG)
.PHONY: install
install: operator-ui-autoinstall install-chainlink-autoinstall ## Install chainlink and all its dependencies.
.PHONY: install-git-hooks
install-git-hooks:
git config core.hooksPath .githooks
.PHONY: install-chainlink-autoinstall
install-chainlink-autoinstall: | gomod install-chainlink
.PHONY: operator-ui-autoinstall
operator-ui-autoinstall: | yarndep operator-ui
.PHONY: gomod
gomod: ## Ensure chainlink's go dependencies are installed.
@if [ -z "`which gencodec`" ]; then \
go get github.com/smartcontractkit/gencodec; \
fi || true
go mod download
.PHONY: yarndep
yarndep: ## Ensure all yarn dependencies are installed
yarn install --frozen-lockfile
./tools/bin/restore-solc-cache
.PHONY: gen-builder-cache
gen-builder-cache: gomod # generate a cache for the builder image
yarn install --frozen-lockfile
./tools/bin/restore-solc-cache
.PHONY: install-chainlink
install-chainlink: chainlink ## Install the chainlink binary.
cp $< $(GOBIN)/chainlink
chainlink: $(SGX_BUILD_ENCLAVE) operator-ui ## Build the chainlink binary.
CGO_ENABLED=0 go run packr/main.go "${CURDIR}/core/eth" ## embed contracts in .go file
go build $(GOFLAGS) -o $@ ./core/
.PHONY: operator-ui
operator-ui: ## Build the static frontend UI.
yarn setup:chainlink
CHAINLINK_VERSION="$(VERSION)@$(COMMIT_SHA)" yarn workspace @chainlink/operator-ui build
CGO_ENABLED=0 go run packr/main.go "${CURDIR}/core/services"
.PHONY: go-solidity-wrappers
go-solidity-wrappers: ## Recompiles solidity contracts and their go wrappers
yarn workspace @chainlink/contracts compile
go generate ./...
go run ./packr/main.go ./core/eth/
.PHONY: docker
docker: ## Build the docker image.
docker build \
--build-arg ENVIRONMENT=$(ENVIRONMENT) \
--build-arg COMMIT_SHA=$(COMMIT_SHA) \
--build-arg SGX_SIMULATION=$(SGX_SIMULATION) \
-t $(TAGGED_REPO) \
-f $(DOCKERFILE) \
.
.PHONY: dockerpush
dockerpush: ## Push the docker image to dockerhub
docker push $(TAGGED_REPO)
.PHONY: $(SGX_ENCLAVE)
$(SGX_ENCLAVE):
@ENVIRONMENT=$(ENVIRONMENT) SGX_ENABLED=$(SGX_ENABLED) SGX_SIMULATION=$(SGX_SIMULATION) make -C core/sgx/
@ln -f $(SGX_TARGET)/libadapters.so core/sgx/target/libadapters.so
.PHONY: enclave
enclave: $(SGX_ENCLAVE)
help:
@echo ""
@echo " .__ .__ .__ .__ __"
@echo " ____ | |__ _____ |__| ____ | | |__| ____ | | __"
@echo " _/ ___\| | \\\\\\__ \ | |/ \| | | |/ \| |/ /"
@echo " \ \___| Y \/ __ \| | | \ |_| | | \ <"
@echo " \___ >___| (____ /__|___| /____/__|___| /__|_ \\"
@echo " \/ \/ \/ \/ \/ \/"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'