Makefile 6.2 KB

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