OwO-Network / DeepLX

Powerful Free DeepL API, No Token Required
https://ssa.sx/deeplx
MIT License
6.64k stars 533 forks source link

makefile #2

Closed gedw99 closed 1 year ago

gedw99 commented 1 year ago

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 commented 1 year ago

Thanks. @gedw99

gedw99 commented 1 year ago

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 commented 1 year ago

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

gedw99 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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