@@ -32,6 +32,13 @@ COMMIT ?= $(shell git rev-parse --short HEAD)
3232.PHONY : all
3333all : build
3434
35+ # # help: print this help message
36+ .PHONY : help
37+ help :
38+ @echo ' Usage:'
39+ @sed -n ' s/^##//p' ${MAKEFILE_LIST} | column -t -s ' :' | sed -e ' s/^/ /'
40+
41+ # # init: check the environment variables
3542init :
3643ifeq ($(FCM_CREDENTIAL ) ,)
3744 @echo "Missing FCM_CREDENTIAL Parameter"
@@ -43,117 +50,109 @@ ifeq ($(FCM_TEST_TOKEN),)
4350endif
4451 @echo "Already set FCM_CREDENTIAL and endif global variable."
4552
46- vet :
47- $(GO ) vet ./...
48-
49- embedmd :
50- @hash embedmd > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
51- $(GO ) install github.com/campoy/embedmd@master; \
52- fi
53- embedmd -d * .md
54-
53+ # # install: install the gorush binary
5554.PHONY : install
5655install : $(GOFILES )
5756 $(GO ) install -v -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)'
5857 @echo " \n==>\033[32m Installed gorush to ${GOPATH} /bin/gorush\033[m"
5958
59+ # # build: build the gorush binary
6060.PHONY : build
6161build : $(EXECUTABLE )
6262
6363.PHONY : $(EXECUTABLE )
6464$(EXECUTABLE ) : $(GOFILES )
6565 $(GO ) build -v -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/$@
6666
67+ # # test: run the tests
6768.PHONY : test
6869test : init
6970 @$(GO ) test -v -cover -tags $(TAGS ) -coverprofile coverage.txt ./... && echo " \n==>\033[32m Ok\033[m\n" || exit 1
7071
71- release : release-dirs release-build release-copy release-compress release-check
72-
73- release-dirs :
74- mkdir -p $(DIST ) /binaries $(DIST ) /release
75-
76- release-build :
77- @hash gox > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
78- $(GO ) install github.com/mitchellh/
[email protected] ; \ 79- fi
80- gox -os=" $( TARGETS) " -arch=" $( ARCHS) " -tags=" $( TAGS) " -ldflags=" $( EXTLDFLAGS) -s -w $( LDFLAGS) " -output=" $( DIST) /binaries/$( EXECUTABLE) -$( VERSION) -{{.OS}}-{{.Arch}}"
81-
82- .PHONY : release-compress
83- release-compress :
84- @hash gxz > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
85- $(GO ) install github.com/ulikunitz/xz/cmd/
[email protected] ; \ 86- fi
87- cd $(DIST ) /release/; for file in ` find . -type f -name " *" ` ; do echo " compressing $$ {file}" && gxz -k -9 $$ {file}; done ;
88-
89- release-copy :
90- $(foreach file,$(wildcard $(DIST ) /binaries/$(EXECUTABLE ) -* ) ,cp $(file ) $(DIST ) /release/$(notdir $(file ) ) ;)
91-
92- release-check :
93- cd $(DIST ) /release; $(foreach file,$(wildcard $(DIST ) /release/$(EXECUTABLE ) -* ) ,sha256sum $(notdir $(file ) ) > $(notdir $(file ) ) .sha256;)
94-
72+ # # build_linux_amd64: build the gorush binary for linux amd64
9573build_linux_amd64 :
9674 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE )
9775
76+ # # build_linux_i386: build the gorush binary for linux i386
9877build_linux_i386 :
9978 CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -a -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/i386/$(DEPLOY_IMAGE )
10079
80+ # # build_linux_arm64: build the gorush binary for linux arm64
10181build_linux_arm64 :
10282 CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm64/$(DEPLOY_IMAGE )
10383
84+ # # build_linux_arm: build the gorush binary for linux arm
10485build_linux_arm :
10586 CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -a -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE )
10687
88+ # # build_linux_lambda: build the gorush binary for linux lambda
10789build_linux_lambda :
10890 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags ' lambda' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/lambda/$(DEPLOY_IMAGE )
10991
92+ # # build_darwin_amd64: build the gorush binary for darwin amd64
11093build_darwin_amd64 :
11194 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/darwin/amd64/$(DEPLOY_IMAGE )
11295
96+ # # build_darwin_i386: build the gorush binary for darwin i386
11397build_darwin_i386 :
11498 CGO_ENABLED=0 GOOS=darwin GOARCH=386 go build -a -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/darwin/i386/$(DEPLOY_IMAGE )
11599
100+ # # build_darwin_arm64: build the gorush binary for darwin arm64
116101build_darwin_arm64 :
117102 CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -a -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/darwin/arm64/$(DEPLOY_IMAGE )
118103
104+ # # build_darwin_arm: build the gorush binary for darwin arm
119105build_darwin_arm :
120106 CGO_ENABLED=0 GOOS=darwin GOARCH=arm GOARM=7 go build -a -tags ' $(TAGS)' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/darwin/arm/$(DEPLOY_IMAGE )
121107
108+ # # build_darwin_lambda: build the gorush binary for darwin lambda
122109build_darwin_lambda :
123110 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -tags ' lambda' -ldflags ' $(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/darwin/lambda/$(DEPLOY_IMAGE )
124111
112+ # # clean: cleans up the project directory
113+ # Cleans up the project directory by performing the following actions:
114+ # - Runs `go clean` with the `-modcache`, `-x`, and `-i` flags to clean the module cache and remove installed packages.
115+ # - Deletes all files named `coverage.txt` in the project directory and its subdirectories.
116+ # - Deletes all files with the `.tar.gz` extension in the project directory and its subdirectories.
117+ # - Deletes all files with the `.db` extension in the project directory and its subdirectories.
118+ # - Removes the `release`, `dist`, and `.cover` directories if they exist.
125119clean :
126120 $(GO ) clean -modcache -x -i ./...
127121 find . -name coverage.txt -delete
128122 find . -name * .tar.gz -delete
129123 find . -name * .db -delete
130124 -rm -rf release dist .cover
131125
126+ # # proto_install: install the protoc-gen-go and protoc-gen-go-grpc
132127.PHONY : proto_install
133128proto_install :
134129 $(GO ) install google.golang.org/protobuf/cmd/protoc-gen-go@$(PROTOC_GEN_GO )
135130 $(GO ) install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_GEN_GO_GRPC )
136131
132+ # # generate_proto_js: generate the proto file for nodejs
137133generate_proto_js :
138134 npm install grpc-tools
139135 protoc -I rpc/proto rpc/proto/gorush.proto --js_out=import_style=commonjs,binary:rpc/example/node/ --grpc_out=rpc/example/node/ --plugin=protoc-gen-grpc=" node_modules/.bin/grpc_tools_node_protoc_plugin"
140136
137+ # # generate_proto_go: generate the proto file for golang
141138generate_proto_go :
142139 protoc -I rpc/proto rpc/proto/gorush.proto --go_out=rpc/proto --go-grpc_out=require_unimplemented_servers=false:rpc/proto
143140
141+ # # generate_proto: generate the proto file for golang and nodejs
144142generate_proto : generate_proto_go generate_proto_js
145143
146- # install air command
144+ # # air: install air for hot reload
147145.PHONY : air
148146air :
149147 @hash air > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
150148 $(GO ) install github.com/cosmtrek/air@latest; \
151149 fi
152150
153- # run air
151+ # # dev: run the air for hot reload
154152.PHONY : dev
155153dev : air
156154 air --build.cmd " make" --build.bin release/gorush
157155
156+ # # version: print the version
158157version :
159158 @echo $(VERSION )
0 commit comments