diff --git a/.githooks/commit-msg b/.githooks/commit-msg index d4e5c43..e1def12 100755 --- a/.githooks/commit-msg +++ b/.githooks/commit-msg @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python import sys diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 5b23b32..cc13207 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -22,13 +22,21 @@ the general direction and roadmap of this project without asking. The preferred way to communicate is probably via Discord or GitHub issues. -=== Dev environment setup and clean build - Fedora +=== Dev environment setup and clean build ``` +# Step1: setup compile env +# - Fedora dnf install git go protobuf-compiler make -y +# - Windows with chocolatey +choco install git go protoc make python nodejs-lts -y + +# Step2: clone and setup repo git clone https://github.com/OliveTin/OliveTin.git cd OliveTin +make githooks +# Step3: compile binary for current dev env (OS, ARCH) # `make grpc` will also run `make go-tools`, which installs "buf". This binary # will be put in your GOPATH/bin/, which should be on your path. buf is used to # generate the protobuf / grpc stubs. diff --git a/Makefile b/Makefile index 8491e5f..ad55dc5 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,26 @@ -compile: daemon-compile-x64-lin +define delete-files + python -c "import shutil;shutil.rmtree('$(1)', ignore_errors=True)" +endef + +compile: daemon-compile-currentenv + +daemon-compile-currentenv: + go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin daemon-compile-armhf: - GOARCH=arm GOARM=6 go build -o OliveTin.armhf github.com/OliveTin/OliveTin/cmd/OliveTin + go env -w GOARCH=arm GOARM=6 + go build -o OliveTin.armhf github.com/OliveTin/OliveTin/cmd/OliveTin + go env -u GOARCH GOARM daemon-compile-x64-lin: - GOOS=linux go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin + go env -w GOOS=linux + go build -o OliveTin github.com/OliveTin/OliveTin/cmd/OliveTin + go env -u GOOS daemon-compile-x64-win: - GOOS=windows GOARCH=amd64 go build -o OliveTin.exe github.com/OliveTin/OliveTin/cmd/OliveTin + go env -w GOOS=windows GOARCH=amd64 + go build -o OliveTin.exe github.com/OliveTin/OliveTin/cmd/OliveTin + go env -u GOOS GOARCH daemon-compile: daemon-compile-armhf daemon-compile-x64-lin daemon-compile-x64-win @@ -27,7 +40,7 @@ it: cd integration-tests && make githooks: - cp -v .githooks/* .git/hooks/ + git config --local core.hooksPath .githooks go-tools: go install "github.com/bufbuild/buf/cmd/buf" @@ -68,16 +81,23 @@ devcontainer: compile podman-image podman-container webui-codestyle: cd webui.dev && npm install - cd webui.dev && ./node_modules/.bin/eslint main.js js/* - cd webui.dev && ./node_modules/.bin/stylelint style.css + cd webui.dev && npx eslint main.js js/* + cd webui.dev && npx stylelint style.css webui-dist: - rm -rf webui webui.dev/dist + $(call delete-files,webui) + $(call delete-files,webui.dev/dist) cd webui.dev && npm install - cd webui.dev && parcel build --public-url "." && mv dist ../webui - cp webui.dev/*.png webui/ + cd webui.dev && npx parcel build --public-url "." + python -c "import shutil;shutil.move('webui.dev/dist', 'webui')" + python -c "import shutil;import glob;[shutil.copy(f, 'webui') for f in glob.glob('webui.dev/*.png')]" clean: - rm -rf dist OliveTin OliveTin.armhf OliveTin.exe reports gen + $(call delete-files,dist) + $(call delete-files,OliveTin) + $(call delete-files,OliveTin.armhf) + $(call delete-files,OliveTin.exe) + $(call delete-files,reports) + $(call delete-files,gen) .PHONY: grpc