Makefile 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. BUILD_PATH ?= _build
  2. PACKAGES_PATH ?= _packages
  3. VERSION := $(shell git describe --tags --always)
  4. ARCH := $(shell go env GOARCH)
  5. OS := $(shell go env GOOS)
  6. PACKAGE_NAME := kuiper-$(VERSION)-$(OS)-$(ARCH)
  7. GO := GO111MODULE=on go
  8. TARGET ?= lfedge/ekuiper
  9. export KUIPER_SOURCE := $(shell pwd)
  10. .PHONY: build
  11. build: build_without_edgex
  12. .PHONY:pkg
  13. pkg: pkg_without_edgex
  14. @if [ "$$(uname -s)" = "Linux" ]; then make -C deploy/packages; fi
  15. .PHONY: build_prepare
  16. build_prepare:
  17. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/bin
  18. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc
  19. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/sources
  20. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/sinks
  21. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/services
  22. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/services/schemas
  23. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/data
  24. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins
  25. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins/sources
  26. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins/sinks
  27. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins/functions
  28. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins/portable
  29. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins/wasm
  30. @mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/log
  31. @cp -r etc/* $(BUILD_PATH)/$(PACKAGE_NAME)/etc
  32. .PHONY: build_without_edgex
  33. build_without_edgex: build_prepare
  34. GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -o kuiper cmd/kuiper/main.go
  35. GO111MODULE=on CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -o kuiperd cmd/kuiperd/main.go
  36. @if [ "$$(uname -s)" = "Linux" ] && [ ! -z $$(which upx) ]; then upx ./kuiper; upx ./kuiperd; fi
  37. @mv ./kuiper ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
  38. @echo "Build successfully"
  39. .PHONY: pkg_without_edgex
  40. pkg_without_edgex: build_without_edgex
  41. @make real_pkg
  42. .PHONY: build_with_edgex
  43. build_with_edgex: build_prepare
  44. GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags "edgex include_nats_messaging" -o kuiper cmd/kuiper/main.go
  45. GO111MODULE=on CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags "edgex include_nats_messaging" -o kuiperd cmd/kuiperd/main.go
  46. @if [ "$$(uname -s)" = "Linux" ] && [ ! -z $$(which upx) ]; then upx ./kuiper; upx ./kuiperd; fi
  47. @mv ./kuiper ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
  48. @echo "Build successfully"
  49. .PHONY: build_with_edgex_and_script
  50. build_with_edgex_and_script: build_prepare
  51. GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags "edgex include_nats_messaging" -o kuiper cmd/kuiper/main.go
  52. GO111MODULE=on CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags "edgex include_nats_messaging script" -o kuiperd cmd/kuiperd/main.go
  53. @if [ "$$(uname -s)" = "Linux" ] && [ ! -z $$(which upx) ]; then upx ./kuiper; upx ./kuiperd; fi
  54. @mv ./kuiper ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
  55. @echo "Build successfully"
  56. .PHONY: pkg_with_edgex
  57. pkg_with_edgex: build_with_edgex
  58. @make real_pkg
  59. .PHONY: build_core
  60. build_core: build_prepare
  61. GO111MODULE=on CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags core -o kuiperd cmd/kuiperd/main.go
  62. @if [ "$$(uname -s)" = "Linux" ] && [ ! -z $$(which upx) ]; then upx ./kuiperd; fi
  63. @mv ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
  64. @echo "Build successfully"
  65. .PHONY: pkg_core
  66. pkg_core: build_core
  67. @mkdir -p $(PACKAGES_PATH)
  68. @cd $(BUILD_PATH) && zip -rq $(PACKAGE_NAME)-core.zip $(PACKAGE_NAME)
  69. @cd $(BUILD_PATH) && tar -czf $(PACKAGE_NAME)-core.tar.gz $(PACKAGE_NAME)
  70. @mv $(BUILD_PATH)/$(PACKAGE_NAME)-core.zip $(BUILD_PATH)/$(PACKAGE_NAME)-core.tar.gz $(PACKAGES_PATH)
  71. @echo "Package core success"
  72. .PHONY: real_pkg
  73. real_pkg:
  74. @mkdir -p $(PACKAGES_PATH)
  75. @cd $(BUILD_PATH) && zip -rq $(PACKAGE_NAME).zip $(PACKAGE_NAME)
  76. @cd $(BUILD_PATH) && tar -czf $(PACKAGE_NAME).tar.gz $(PACKAGE_NAME)
  77. @mv $(BUILD_PATH)/$(PACKAGE_NAME).zip $(BUILD_PATH)/$(PACKAGE_NAME).tar.gz $(PACKAGES_PATH)
  78. @echo "Package build success"
  79. .PHONY: build_with_wasm
  80. build_with_wasm: build_prepare
  81. GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -o kuiper cmd/kuiper/main.go
  82. GO111MODULE=on CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags "wasmedge" -o kuiperd cmd/kuiperd/main.go
  83. @if [ "$$(uname -s)" = "Linux" ] && [ ! -z $$(which upx) ]; then upx ./kuiper; upx ./kuiperd; fi
  84. @mv ./kuiper ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
  85. @echo "Build successfully"
  86. .PHONY: docker
  87. docker:
  88. docker buildx build --no-cache --platform=linux/amd64 -t $(TARGET):$(VERSION) -f deploy/docker/Dockerfile . --load
  89. docker buildx build --no-cache --platform=linux/amd64 -t $(TARGET):$(VERSION)-slim -f deploy/docker/Dockerfile-slim . --load
  90. docker buildx build --no-cache --platform=linux/amd64 -t $(TARGET):$(VERSION)-dev -f deploy/docker/Dockerfile-dev . --load
  91. PLUGINS := sinks/influx \
  92. sinks/influx2 \
  93. sinks/zmq \
  94. sinks/kafka \
  95. sinks/image \
  96. sinks/sql \
  97. sources/random \
  98. sources/zmq \
  99. sources/sql \
  100. sources/video \
  101. sinks/tdengine \
  102. functions/accumulateWordCount \
  103. functions/countPlusOne \
  104. functions/image \
  105. functions/geohash \
  106. functions/echo \
  107. functions/labelImage \
  108. functions/tfLite
  109. .PHONY: plugins $(PLUGINS)
  110. plugins: $(PLUGINS)
  111. $(PLUGINS): PLUGIN_TYPE = $(word 1, $(subst /, , $@))
  112. $(PLUGINS): PLUGIN_NAME = $(word 2, $(subst /, , $@))
  113. $(PLUGINS):
  114. @$(CURDIR)/build-plugins.sh $(PLUGIN_TYPE) $(PLUGIN_NAME)
  115. .PHONY: clean
  116. clean:
  117. @rm -rf cross_build.tar linux_amd64 linux_arm64 linux_arm_v7 linux_386
  118. @rm -rf _build _packages _plugins
  119. tidy:
  120. @echo "go mod tidy"
  121. go mod tidy && git diff go.mod go.sum
  122. lint:tools/lint/bin/golangci-lint
  123. @echo "linting"
  124. tools/lint/bin/golangci-lint run ./... ./extensions/... ./tools/kubernetes/...
  125. cd sdk/go && ../../tools/lint/bin/golangci-lint run
  126. tools/lint/bin/golangci-lint:
  127. GOBIN=$(shell pwd)/tools/lint/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest