Host snippets with a git backend. Like Gists but OpenSource. https://gist.sigpipe.me/
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.

Makefile 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. LDFLAGS += -X "dev.sigpipe.me/dashie/git.txt/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
  2. LDFLAGS += -X "dev.sigpipe.me/dashie/git.txt/setting.BuildGitHash=$(shell git rev-parse HEAD)"
  3. OS := $(shell uname)
  4. ifeq ($(OS), Windows_NT)
  5. EXECUTABLE := git_txt.exe
  6. else
  7. EXECUTABLE := git_txt
  8. endif
  9. DATA_FILES := $(shell find conf | sed 's/ /\\ /g')
  10. DIST := dist
  11. BUILD_FLAGS:=-o $(EXECUTABLE) -v
  12. TAGS=sqlite
  13. NOW=$(shell date -u '+%Y%m%d%I%M%S')
  14. GOVET=go vet
  15. GOLINT=golint -set_exit_status
  16. GO ?= go
  17. GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
  18. PACKAGES ?= $(filter-out dev.sigpipe.me/dashie/git.txt/integrations,$(shell go list ./... | grep -v /vendor/))
  19. XGO_DEPS = "--deps=https://s3.sigpipe.me/tarballs/1-mingw-libgnurx-2.5.1-src.tar.gz https://s3.sigpipe.me/tarballs/2-file-5.32.tar.gz"
  20. #XGO_DEPS += "--deps=https://github.com/libgit2/libgit2/archive/maint/v0.25.zip"
  21. ifneq ($(DRONE_TAG),)
  22. VERSION ?= $(subst v,,$(DRONE_TAG))
  23. else
  24. ifneq ($(DRONE_BRANCH),)
  25. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  26. else
  27. VERSION ?= master
  28. endif
  29. endif
  30. ### Targets
  31. .PHONY: build clean
  32. all: build
  33. check: test
  34. web: build
  35. ./$(EXECUTABLE) web
  36. vet:
  37. $(GOVET) git.txt.go
  38. lint:
  39. @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  40. $(GO) get -u github.com/golang/lint/golint; \
  41. fi
  42. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  43. build:
  44. $(GO) build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)'
  45. build-dev: govet
  46. $(GO) build $(BUILD_FLAGS) -tags '$(TAGS)'
  47. build-dev-race: govet
  48. $(GO) build $(BUILD_FLAGS) -race -tags '$(TAGS)'
  49. clean:
  50. $(GO) clean -i ./...
  51. clean-mac: clean
  52. find . -name ".DS_Store" -delete
  53. test:
  54. $(GO) test -cover -v $(PACKAGES)
  55. .PHONY: misspell-check
  56. misspell-check:
  57. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  58. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  59. fi
  60. misspell -error -i unknwon $(GOFILES)
  61. .PHONY: misspell
  62. misspell:
  63. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  64. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  65. fi
  66. misspell -w -i unknwon $(GOFILES)
  67. .PHONY: release
  68. release: release-dirs release-windows release-linux release-copy release-check
  69. .PHONY: release-dirs
  70. release-dirs:
  71. mkdir -p $(DIST)/binaries $(DIST)/release
  72. .PHONY: release-windows
  73. release-windows:
  74. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  75. $(GO) get -u github.com/karalabe/xgo; \
  76. fi
  77. xgo $(XGO_DEPS) --image=xgo-git2go-windows -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out git.txt-$(VERSION) .
  78. ifeq ($(CI),drone)
  79. mv /build/* $(DIST)/binaries
  80. endif
  81. .PHONY: release-linux
  82. release-linux:
  83. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  84. $(GO) get -u github.com/karalabe/xgo; \
  85. fi
  86. xgo $(XGO_DEPS) --image=xgo-git2go-linux -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out git.txt-$(VERSION) .
  87. ifeq ($(CI),drone)
  88. mv /build/* $(DIST)/binaries
  89. endif
  90. # No git2go image available for the moment
  91. .PHONY: release-darwin
  92. release-darwin:
  93. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  94. $(GO) get -u github.com/karalabe/xgo; \
  95. fi
  96. xgo $(XGO_DEPS) -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out git.txt-$(VERSION) .
  97. ifeq ($(CI),drone)
  98. mv /build/* $(DIST)/binaries
  99. endif
  100. .PHONY: release-copy
  101. release-copy:
  102. $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
  103. .PHONY: release-check
  104. release-check:
  105. cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
  106. # This is an ugly hack, we will not need that when xgo will support cmake and sources-order
  107. release-lx64: release-dirs release-build-lx64 release-copy release-check release-pack-lx64
  108. release-build-lx64:
  109. cp $(EXECUTABLE) $(DIST)/binaries/$(EXECUTABLE)-linux-x86_64
  110. cp -r conf $(DIST)/release/
  111. cp README.md LICENSE* $(DIST)/release/
  112. release-pack-lx64:
  113. cd $(DIST)/release; tar czvf git.txt_$(VERSION).tgz $(EXECUTABLE)-linux-x86_64 conf README.md LICENSE*