-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
64 lines (51 loc) · 1.88 KB
/
Makefile
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
NAME = blockchain-service
CONTRACTNAME = FtDiploma
ETHSERV = eth-server
APICLIENT = blockchain-service
NONE = \033[0m
RED = \033[31m
GREEN = \033[32m
YELLOW = \033[33m
BLUE = \033[34m
MAGENTA = \033[35m
CYAN = \033[36m
.PHONY: all install testing run update-contract clean clean-contract docker-stop docker-clean docker-remake re
all: install run
install:
go mod tidy
@echo "$(YELLOW)Compiling $(NAME) in golang!$(NONE)"
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o $(NAME)
@echo "$(GREEN)$(NAME) ready!$(NONE)"
docker build -f config/Dockerfile.app -t $(APICLIENT) .
run:
docker-compose up
testing:
go test -v ./src/rest/handlers ./src/dao/diplomas ./src/account/
docker build -f config/Dockerfile.server -t $(ETHSERV) .
docker run --add-host=$(ETHSERV):172.17.0.1 --name $(ETHSERV) -ti -p 9545:9545 -d $(ETHSERV)
$(shell sleep 10)
truffle test --network localhost
update-contract:
@echo "$(YELLOW)Compiling the smart-contract in solidity!$(NONE)"
truffle compile
@echo "$(YELLOW)Compiling the smart-contract in golang!$(NONE)"
solcjs --abi contracts/$(CONTRACTNAME).sol > $(CONTRACTNAME).abi
solcjs --bin contracts/$(CONTRACTNAME).sol > $(CONTRACTNAME).bin
abigen --bin=contracts_$(CONTRACTNAME)_sol_$(CONTRACTNAME).bin --abi=contracts_$(CONTRACTNAME)_sol_$(CONTRACTNAME).abi --pkg=diploma --out=$(CONTRACTNAME).go
sed -i 's/diploma/contracts/' $(CONTRACTNAME).go
mv $(CONTRACTNAME).go ./src/dao/contracts/$(CONTRACTNAME).go
clean:
@echo "$(YELLOW)Cleaning...$(NONE)"
rm $(NAME)
clean-contract:
rm $(CONTRACTNAME).bin
rm $(CONTRACTNAME).abi
rm contracts_$(CONTRACTNAME)_sol_$(CONTRACTNAME).abi
rm contracts_$(CONTRACTNAME)_sol_$(CONTRACTNAME).bin
docker-stop:
docker stop $(APICLIENT)
docker rm $(APICLIENT)
docker-rm:
docker image rm $(APICLIENT)
docker-remake: docker-stop docker-rm install
re: docker-stop docker-rm all