Fix make targets to actually work on macOS

pull/247/head
Philipp Heckel 2022-05-21 10:08:33 -04:00
parent c33065151e
commit 4c5d40e4c9
2 changed files with 68 additions and 52 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
dist/ dist/
build/ build/
.idea/ .idea/
.vscode/
*.swp *.swp
server/docs/ server/docs/
server/site/ server/site/

View File

@ -16,7 +16,7 @@ help:
@echo " make build - Build web app, documentation and server/client" @echo " make build - Build web app, documentation and server/client"
@echo " make clean - Clean build/dist folders" @echo " make clean - Clean build/dist folders"
@echo @echo
@echo "Build server & client (not release version):" @echo "Build server & client (using GoReleaser, not release version):"
@echo " make cli - Build server & client (all architectures)" @echo " make cli - Build server & client (all architectures)"
@echo " make cli-linux-amd64 - Build server & client (Linux, amd64 only)" @echo " make cli-linux-amd64 - Build server & client (Linux, amd64 only)"
@echo " make cli-linux-armv6 - Build server & client (Linux, armv6 only)" @echo " make cli-linux-armv6 - Build server & client (Linux, armv6 only)"
@ -24,8 +24,11 @@ help:
@echo " make cli-linux-arm64 - Build server & client (Linux, arm64 only)" @echo " make cli-linux-arm64 - Build server & client (Linux, arm64 only)"
@echo " make cli-windows-amd64 - Build client (Windows, amd64 only)" @echo " make cli-windows-amd64 - Build client (Windows, amd64 only)"
@echo " make cli-darwin-all - Build client (macOS, arm64+amd64 universal binary)" @echo " make cli-darwin-all - Build client (macOS, arm64+amd64 universal binary)"
@echo " make cli-devonly-server - Build client & server (without GoReleaser, on current architecture)" @echo
@echo " make cli-devonly-noserver - Build client only (without GoReleaser, on current architecture)" @echo "Build server & client (without GoReleaser):"
@echo " make cli-linux-server - Build client & server (no GoReleaser, current arch, Linux)"
@echo " make cli-darwin-server - Build client & server (no GoReleaser, current arch, macOS)"
@echo " make cli-client - Build client only (no GoReleaser, current arch, Linux/macOS/Windows)"
@echo @echo
@echo "Build web app:" @echo "Build web app:"
@echo " make web - Build the web app" @echo " make web - Build the web app"
@ -134,20 +137,32 @@ cli-windows-amd64: cli-deps-static-sites
cli-darwin-all: cli-deps-static-sites cli-darwin-all: cli-deps-static-sites
goreleaser build --snapshot --rm-dist --debug --id ntfy_darwin_all goreleaser build --snapshot --rm-dist --debug --id ntfy_darwin_all
cli-devonly-server: cli-deps-static-sites cli-linux-server: cli-deps-static-sites
# This is a target to build the CLI (including the server) manually. This should work on macOS, too. # This is a target to build the CLI (including the server) manually.
mkdir -p dist/ntfy_devonly_server server/docs # Use this for development, if you really don't want to install GoReleaser ...
mkdir -p dist/ntfy_linux_server server/docs
CGO_ENABLED=1 go build \ CGO_ENABLED=1 go build \
-o dist/ntfy_devonly_server/ntfy \ -o dist/ntfy_linux_server/ntfy \
-tags sqlite_omit_load_extension,osusergo,netgo \ -tags sqlite_omit_load_extension,osusergo,netgo \
-ldflags \ -ldflags \
"-linkmode=external -extldflags=-static -s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD) -X main.date=$(shell date +%s)" "-linkmode=external -extldflags=-static -s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD) -X main.date=$(shell date +%s)"
cli-devonly-noserver: cli-deps-static-sites cli-darwin-server: cli-deps-static-sites
# This is a target to build the CLI (excluding the server) manually. This should work on macOS, too. # This is a target to build the CLI (including the server) manually.
mkdir -p dist/ntfy_devonly_noserver server/docs # Use this for macOS/iOS development, so you have a local server to test with.
mkdir -p dist/ntfy_darwin_server server/docs
CGO_ENABLED=1 go build \
-o dist/ntfy_darwin_server/ntfy \
-tags sqlite_omit_load_extension,osusergo,netgo \
-ldflags \
"-linkmode=external -s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD) -X main.date=$(shell date +%s)"
cli-client: cli-deps-static-sites
# This is a target to build the CLI (excluding the server) manually. This should work on Linux/macOS/Windows.
# Use this for development, if you really don't want to install GoReleaser ...
mkdir -p dist/ntfy_client server/docs
CGO_ENABLED=0 go build \ CGO_ENABLED=0 go build \
-o dist/ntfy_devonly_noserver/ntfy \ -o dist/ntfy_client/ntfy \
-tags noserver \ -tags noserver \
-ldflags \ -ldflags \
"-X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD) -X main.date=$(shell date +%s)" "-X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD) -X main.date=$(shell date +%s)"