Tools written in Go for interfacing with Xiaomi Flora sensors for IoT use cases.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
2.1 KiB

  1. .POSIX:
  2. MIFLORA_ADDR?=00:00:00:00:00:00
  3. MIFLORAD_VERSION?=master
  4. RUN_COMMAND=miflorad
  5. RUN_OPTIONS=$(MIFLORA_ADDR)
  6. .PHONY: all
  7. all: clean build test
  8. .PHONY: run
  9. run: clean build test
  10. sudo cmd/$(RUN_COMMAND)/$(RUN_COMMAND) $(RUN_OPTIONS)
  11. .PHONY: clean
  12. clean:
  13. rm -f cmd/miflorad/miflorad
  14. rm -f cmd/munin-miflora/munin-miflora
  15. rm -f cmd/munin-miflora-gatt/munin-miflora-gatt
  16. .PHONY: build
  17. build: cmd/miflorad/miflorad cmd/munin-miflora/munin-miflora cmd/munin-miflora-gatt/munin-miflora-gatt
  18. .PHONY: test
  19. test: build
  20. cd cmd/miflorad && go test -v -race && cd ../..
  21. cd common && go test -v -race && cd ..
  22. .PHONY: remote-run
  23. remote-run: clean
  24. cd cmd/$(RUN_COMMAND) && CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w" && cd ../..
  25. file cmd/$(RUN_COMMAND)/$(RUN_COMMAND)
  26. scp cmd/$(RUN_COMMAND)/$(RUN_COMMAND) extzero:$(RUN_COMMAND)
  27. ssh extzero "./$(RUN_COMMAND) $(RUN_OPTIONS)"
  28. .PHONY: release
  29. release:
  30. mkdir -p pkg
  31. cd cmd/miflorad && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-amd64" -ldflags="-s -w -X main.version=$(MIFLORAD_VERSION)" && cd ../..
  32. cd cmd/miflorad && CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-arm" -ldflags="-s -w -X main.version=$(MIFLORAD_VERSION)" && cd ../..
  33. # github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --prerelease --github-repository "cmur2/miflorad"
  34. github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --github-repository "cmur2/miflorad"
  35. .PHONY: cmd/miflorad/miflorad
  36. cmd/miflorad/miflorad:
  37. cd cmd/miflorad && CGO_ENABLED=0 go build -buildmode=pie -ldflags "-X main.version=$(MIFLORAD_VERSION)" && cd ../..
  38. .PHONY: cmd/munin-miflora/munin-miflora
  39. cmd/munin-miflora/munin-miflora:
  40. cd cmd/munin-miflora && CGO_ENABLED=0 go build -buildmode=pie && cd ../..
  41. .PHONY: cmd/munin-miflora-gatt/munin-miflora-gatt
  42. cmd/munin-miflora-gatt/munin-miflora-gatt:
  43. cd cmd/munin-miflora-gatt && CGO_ENABLED=0 go build -buildmode=pie && cd ../..