Skip to content

Commit

Permalink
chore: add make install (#52)
Browse files Browse the repository at this point in the history
chore: make install

Signed-off-by: Henry Wang <[email protected]>
  • Loading branch information
henry118 authored Sep 20, 2024
1 parent e282c25 commit 3017cf4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ GFLAGS ?= --race --randomize-all --randomize-suites
BIN = $(PWD)/bin
FINCH_DAEMON_PROJECT_ROOT ?= $(shell pwd)

# Base path used to install.
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin

BINARY = $(addprefix bin/,finch-daemon)

.PHONY: build
build::
build:
$(eval PACKAGE := github.com/runfinch/finch-daemon)
$(eval VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags))
$(eval GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi))
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)")
GOOS=linux go build -ldflags $(LDFLAGS) -v -o bin/finch-daemon $(PACKAGE)/cmd/finch-daemon
GOOS=linux go build -ldflags $(LDFLAGS) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon

.PHONY: linux
linux:
Expand All @@ -23,15 +29,22 @@ endif

.PHONY: start
start: linux build unlink
sudo bin/finch-daemon --debug --socket-owner $${UID}
sudo $(BINARY) --debug --socket-owner $${UID}

DLV=$(BIN)/dlv
$(DLV):
GOBIN=$(BIN) go install github.com/go-delve/delve/cmd/dlv@latest

.PHONY: start-debug
start-debug: linux build $(DLV) unlink
sudo $(DLV) --listen=:2345 --headless=true --api-version=2 exec ./bin/finch-daemon -- --debug --socket-owner $${UID}
sudo $(DLV) --listen=:2345 --headless=true --api-version=2 exec $(BINARY) -- --debug --socket-owner $${UID}

install: linux
install -d $(DESTDIR)$(BINDIR)
install $(BINARY) $(DESTDIR)$(BINDIR)

uninstall:
@rm -f $(addprefix $(DESTDIR)$(BINDIR)/,$(notdir $(BINARY)))

# Unlink the unix socket if the link does not get cleaned up properly (or if finch-daemon is already running)
.PHONY: unlink
Expand Down
4 changes: 2 additions & 2 deletions finch.service
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[Unit]
Description=finch daemon %I
Description=finch daemon
Documentation=https://runfinch.com
After=network.target local-fs.target containerd.service
Wants=network.target containerd.service

[Service]
ExecStart=/usr/local/bin/finch-daemon --debug --socket-owner %i
ExecStart=/usr/local/bin/finch-daemon --debug

Type=notify
Delegate=yes
Expand Down

0 comments on commit 3017cf4

Please sign in to comment.