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 #2

Closed
gedw99 opened this issue Jan 25, 2023 · 6 comments
Closed

makefile #2

gedw99 opened this issue Jan 25, 2023 · 6 comments

Comments

@gedw99
Copy link

gedw99 commented Jan 25, 2023

you can put this into repo if you want.

everything works.... your description in the readme make it easy to make this work.

MAC only. can make it work on Windows and Linux with a bit more work.



BIN_NAME=deeplx
BIN_FSPATH_NAME=.bin
BIN_FSPATH=$(BIN_FSPATH_NAME)
BIN=$(BIN_FSPATH)/$(BIN_NAME)

build:
	go build -o $(BIN) .
	# .bin
build-cross:
	chmod +x ./.cross_compile.sh
	 ./.cross_compile.sh
	# dist

WEB_URL=http://0.0.0.0:1199
build-run: $(BUILD)
	$(BIN) -h
	# http://localhost:1199/

run-test:
	@echo ""
	@echo "GET"
	curl -H "Content-Type: application/json" -X GET $(WEB_URL)/

	@echo ""
	@echo "POST"
	curl -d '{"text":"hello", "source_lang":"EN", "target_lang":"DE"}' -H "Content-Type: application/json" -X POST $(WEB_URL)/translate
	# {"code":200,"data":"hallo","id":157799001}%  

## install to bin

BIN_MAC_INSTALL_FSPATH=/usr/local/bin/$(BIN_NAME)
BIN_MAC_INSTALL_WHICH=$(shell which $(BIN_NAME))

bin-print:
	@echo ""
	@echo "BIN_MAC_INSTALL_FSPATH:        $(BIN_MAC_INSTALL_FSPATH)"
	@echo "BIN_MAC_INSTALL_WHICH          $(BIN_MAC_INSTALL_WHICH)"

bin-install:
	#sudo mv deeplx_darwin_amd64 /usr/local/bin/deeplx
	sudo cp $(BIN) $(BIN_MAC_INSTALL_FSPATH)
bin-install-del:
	rm -f $(BIN_MAC_INSTALL_WHICH)
bin-start:
	$(BIN_MAC_INSTALL_WHICH)
bin-test:
	$(MAKE) run-test
	


### install as service

SERVICE_MAC_PLIST_NAME=me.missuo.deeplx.plist
SERVICE_MAC_LAUNCH_AGENTS_FSPATH=$(HOME)/Library/LaunchAgents
SERVICE_MAC=$(SERVICE_MAC_LAUNCH_AGENTS_FSPATH)/$(SERVICE_MAC_PLIST_NAME)

service-print:
	@echo ""
	@echo "SERVICE_MAC_LAUNCH_AGENTS_FSPATH:    $(SERVICE_MAC_LAUNCH_AGENTS_FSPATH)"
	@echo "SERVICE_MAC_PLIST_NAME:              $(SERVICE_MAC_PLIST_NAME)"
	@echo "SERVICE_MAC:                         $(SERVICE_MAC)"
	@echo ""
service-print-list:
	# check ours is there
	ls -al $(SERVICE_MAC_LAUNCH_AGENTS_FSPATH)
service-install:
	cp $(REPO_NAME)/$(SERVICE_MAC_PLIST_NAME) $(SERVICE_MAC)
	launchctl load $(SERVICE_MAC)
service-install-del:
	launchctl unload $(SERVICE_MAC)
	rm -f  $(SERVICE_MAC)
service-test:
	$(MAKE) run-test
service-start:
	@echo "service start"
	launchctl start $(SERVICE_MAC)
service-stop:
	@echo "service stop"
	launchctl stop $(SERVICE_MAC)
@missuo
Copy link
Member

missuo commented Jan 30, 2023

Thanks. @gedw99

@gedw99
Copy link
Author

gedw99 commented Jan 31, 2023

https://github.com/gedw99/sc-make/blob/main/assets/.sc-make/make/go.mk#L113 Shows one way to switch based on OS.

You can then modify the BIN names based on the OS . Like needing .exe for windows

@missuo
Copy link
Member

missuo commented Jan 31, 2023

I don't seem to need this makefile, I can implement it via Action to compile all versions automatically every time I push.

@gedw99
Copy link
Author

gedw99 commented Jan 31, 2023

All the the GitHub Workflows can just call your make targets too.

example: https://github.com/gedw99/sc-make/blob/main/.github/workflows/ci.yaml

The CI is calling this: https://github.com/gedw99/sc-make/blob/main/makefile#L17

@gedw99
Copy link
Author

gedw99 commented Jan 31, 2023

I don't seem to need this makefile, I can implement it via Action to compile all versions automatically every time I push.

It’s better imho to do the opposite.

the GitHub action I gave you is generic and calls the makefike.

the advantage is that whatever working on your laptop is exactly what happens on GitHub CI

@missuo
Copy link
Member

missuo commented Feb 1, 2023

Can you create a new pull request? I can learn it.

@missuo missuo closed this as completed Feb 11, 2023
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

2 participants