Selaa lähdekoodia

feature: support basic dev tasks in Windows (#364)

* feature: support basic dev tasks in Windows

* feature: support front-end targets in Windows

---------

Co-authored-by: wushuzh <wushuzh@outlook.com>
wushuzh 1 vuosi sitten
vanhempi
commit
b50824a705
3 muutettua tiedostoa jossa 41 lisäystä ja 13 poistoa
  1. 1 1
      .githooks/commit-msg
  2. 9 1
      CONTRIBUTING.adoc
  3. 31 11
      Makefile

+ 1 - 1
.githooks/commit-msg

@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 
 
 import sys
 import sys
 
 

+ 9 - 1
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.
 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
 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
 git clone https://github.com/OliveTin/OliveTin.git
 cd OliveTin
 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
 # `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
 # will be put in your GOPATH/bin/, which should be on your path. buf is used to
 # generate the protobuf / grpc stubs.
 # generate the protobuf / grpc stubs.

+ 31 - 11
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:
 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:
 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:
 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
 daemon-compile: daemon-compile-armhf daemon-compile-x64-lin daemon-compile-x64-win
 
 
@@ -27,7 +40,7 @@ it:
 	cd integration-tests && make
 	cd integration-tests && make
 
 
 githooks:
 githooks:
-	cp -v .githooks/* .git/hooks/
+	git config --local core.hooksPath .githooks
 
 
 go-tools:
 go-tools:
 	go install "github.com/bufbuild/buf/cmd/buf"
 	go install "github.com/bufbuild/buf/cmd/buf"
@@ -68,16 +81,23 @@ devcontainer: compile podman-image podman-container
 
 
 webui-codestyle:
 webui-codestyle:
 	cd webui.dev && npm install
 	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:
 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 && 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:
 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
 .PHONY: grpc