buildDateTime = $(shell date '+%Y-%m-%d %H:%M:%S')
gitCommitCode = $(shell git rev-list --full-history --all --abbrev-commit --max-count 1)
goVersion = $(shell go version)

run: build
	#./deployments/pbx-api-gin --level 2  --reportCaller  web -c ./configs/config.yaml
	./deployments/pbx-api-gin --level 5  --reportCaller  web -c ./configs/config.yaml
build: 
	go build -tags "pbx" -o ./deployments/pbx-api-gin ./cmd/main.go
swagger:
# 	swag init -d ./api/plugins/webuser,./api/commonModel,./api/admin/adminModel  -g swagger/swagger.go  -o ./web/swagger/webuser --instanceName webuser
# 	swag init -d ./api/plugins/api  -g swagger/swagger.go  -o ./web/swagger/api --instanceName api
# 	swag init -d ./api/admin,./api/commonModel  -g swagger/swagger.go  -o ./web/swagger/pbx --instanceName pbx
# 	swag init -d ./api/plugins/webuser,./api/admin/adminModel  -g swagger/swagger.go  -o ./web/swagger/webuser --instanceName webuser
# 	swag init -d ./api/plugins/api  -g swagger/swagger.go  -o ./web/swagger/api --instanceName api
	swag init -d ./api/admin  -g swagger/swagger.go  -o ./web/swagger/pbx --instanceName pbx

release:
	#cd web/www && find ./ui_pbx -type f  -name '*.js' | xargs gzip -k
	GOOS=linux GOARCH=amd64 go build -tags "webuser pbx pprof api" -ldflags "-X 'main.buildDateTime=$(buildDateTime)' -X 'main.gitCommitCode=$(gitCommitCode)' -X 'main.goVersion=${goVersion}' -s -w" -o ./deployments/crm-api ./cmd/main.go
release-arm:
	#cd web/www && find ./ui_pbx -type f  -name '*.js' | xargs gzip -k
	GOOS=linux GOARCH=arm go build -tags "webuser pbx pprof api" -ldflags "-X 'main.buildDateTime=$(buildDateTime)' -X 'main.gitCommitCode=$(gitCommitCode)' -X 'main.goVersion=${goVersion}' -s -w" -o ./deployments/crm-api-arm ./cmd/main.go

upx:
	upx -9 --lzma ./deployments/pbx-api-gin
scp:
	scp deployments/pbx-api-gin root@192.168.18.252:/usr/local/pbx-webserver/deployments
