Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makefile so it works on darwin and windows arm64 #522

Open
gedw99 opened this issue Jul 18, 2024 · 0 comments
Open

makefile so it works on darwin and windows arm64 #522

gedw99 opened this issue Jul 18, 2024 · 0 comments

Comments

@gedw99
Copy link

gedw99 commented Jul 18, 2024

The make file now works on darwin and windows arm64.

I tested on these desktops also.

will can also do android and iOS with a web view later...

NAME=plugnmeet-server
BASE_OS_NAME:=$(shell go env GOOS)
BASE_OS_ARCH:=$(shell go env GOARCH)
BINDIR=bin
FILE_PATH=cmd/server/*.go
GOBUILD=CGO_ENABLED=0 go build -ldflags '-w -s -buildid='
# The -w and -s flags reduce binary sizes by excluding unnecessary symbols and debug info
# The -buildid= flag makes builds reproducible

export PATH:=$(PATH):$(BINDIR)

darwin-amd64:
	GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(FILE_PATH)
darwin-arm64:
	GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(FILE_PATH)

linux-amd64:
	GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(FILE_PATH)
linux-arm64:
	GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(FILE_PATH)

windows-amd64:
	GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(FILE_PATH)
windows-arm64:
	GOARCH=arm64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(FILE_PATH)

bin: $(BASE_OS_NAME)-$(BASE_OS_ARCH)

run:
	$(NAME)-$(BASE_OS_NAME)-$(BASE_OS_ARCH) --config config_sample.yaml

releases: darwin-amd64 darwin-arm64 linux-amd64 linux-arm64 windows-amd64 windows-arm64
	chmod +x $(BINDIR)/$(NAME)-*
	zip -m -j $(BINDIR)/$(NAME)-darwin-amd64.zip $(BINDIR)/$(NAME)-darwin-amd64
	zip -m -j $(BINDIR)/$(NAME)-darwin-arm64.zip $(BINDIR)/$(NAME)-darwin-arm64

	zip -m -j $(BINDIR)/$(NAME)-linux-amd64.zip $(BINDIR)/$(NAME)-linux-amd64
	zip -m -j $(BINDIR)/$(NAME)-linux-arm64.zip $(BINDIR)/$(NAME)-linux-arm64

	zip -m -j $(BINDIR)/$(NAME)-windows-amd64.zip $(BINDIR)/$(NAME)-windows-amd64.exe
	zip -m -j $(BINDIR)/$(NAME)-windows-arm64.zip $(BINDIR)/$(NAME)-windows-arm64.exe

clean:
	rm $(BINDIR)/*

# Remove trailing {} from the release upload url
GITHUB_UPLOAD_URL=$(shell echo $${GITHUB_RELEASE_UPLOAD_URL%\{*})

upload: releases
	curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/zip" --data-binary @$(BINDIR)/$(NAME)-darwin-amd64.zip  "$(GITHUB_UPLOAD_URL)?name=$(NAME)-darwin-amd64.zip"
	curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/zip" --data-binary @$(BINDIR)/$(NAME)-darwin-arm64.zip  "$(GITHUB_UPLOAD_URL)?name=$(NAME)-darwin-arm64.zip"

	curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/zip" --data-binary @$(BINDIR)/$(NAME)-linux-amd64.zip  "$(GITHUB_UPLOAD_URL)?name=$(NAME)-linux-amd64.zip"
	curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/zip" --data-binary @$(BINDIR)/$(NAME)-linux-arm64.zip  "$(GITHUB_UPLOAD_URL)?name=$(NAME)-linux-arm64.zip"
	
	curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/zip" --data-binary @$(BINDIR)/$(NAME)-windows-amd64.zip "$(GITHUB_UPLOAD_URL)?name=$(NAME)-windows-amd64.zip"
	curl -H "Authorization: token $(GITHUB_TOKEN)" -H "Content-Type: application/zip" --data-binary @$(BINDIR)/$(NAME)-windows-arm64.zip "$(GITHUB_UPLOAD_URL)?name=$(NAME)-windows-arm64.zip"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant