From 45682c90d6b60e6ff2dafa8c9080e16998e34970 Mon Sep 17 00:00:00 2001 From: Page Fault Date: Sun, 12 Jul 2020 16:36:46 +0000 Subject: [PATCH] fix makefile --- .github/workflows/dev-build.yml | 4 +- .github/workflows/release-build.yml | 7 +-- Makefile | 83 ++++++++++++----------------- {build => component}/api.go | 0 {build => component}/base.go | 0 {build => component}/client.go | 0 {build => component}/custom.go | 0 {build => component}/forward.go | 0 {build => component}/mysql.go | 0 {build => component}/nat.go | 0 {build => component}/other.go | 0 {build => component}/server.go | 0 docs/content/basic/full-config.md | 2 - main.go | 2 +- redirector/redirector_test.go | 39 +++++++------- 15 files changed, 57 insertions(+), 80 deletions(-) rename {build => component}/api.go (100%) rename {build => component}/base.go (100%) rename {build => component}/client.go (100%) rename {build => component}/custom.go (100%) rename {build => component}/forward.go (100%) rename {build => component}/mysql.go (100%) rename {build => component}/nat.go (100%) rename {build => component}/other.go (100%) rename {build => component}/server.go (100%) diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index bc389b6..ecc1e82 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -27,5 +27,5 @@ jobs: - name: Upload Binary uses: actions/upload-artifact@v1 with: - name: bin-${{ matrix.platform }} - path: ./bin/ + name: build-${{ matrix.platform }} + path: ./build/ diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index beb4d6d..c6a992f 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -31,9 +31,4 @@ jobs: tag_name="${GITHUB_REF##*/}" hub release create -p -d "${assets[@]}" -m "$tag_name" "$tag_name" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload binary - uses: actions/upload-artifact@v1 - with: - name: dist-release - path: ./bin \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index 3cd4489..56792d0 100644 --- a/Makefile +++ b/Makefile @@ -1,41 +1,31 @@ NAME := trojan-go PACKAGE_NAME := github.com/p4gefau1t/trojan-go -VERSION := `echo git describe --dirty` -COMMIT := `echo git rev-parse HEAD` +VERSION := `git describe --dirty` +COMMIT := `git rev-parse HEAD` -GOPATH ?= -ifneq ($(strip $(GOPATH)), ) - GO_DIR := $(GOPATH)/bin/ -endif - -MAKEDEPEND = $(GODIR)go +MAKEDEPEND = $(GO_DIR)go GO_MINIMUM := go1.14 GO_VERSION != $(GO_DIR)go version | cut -d' ' -f3 -GOMETALINTER := $(GO_DIR)gometalinter PLATFORM := linux -BIN_DIR := bin +BUILD_DIR := build VAR_SETTING := -X $(PACKAGE_NAME)/constant.Version=$(VERSION) -X $(PACKAGE_NAME)/constant.Commit=$(COMMIT) -GOBUILD = env CGO_ENABLED=0 $(GO_DIR)go build -tags "full" -ldflags="-s -w $(VAR_SETTING)" -o $(BIN_DIR) +GOBUILD = env CGO_ENABLED=0 $(GO_DIR)go build -tags "full" -ldflags="-s -w $(VAR_SETTING)" -o $(BUILD_DIR) .PHONY: depends trojan-go release normal: clean trojan-go -depends: geosite.dat geoip.dat +depends: $(info GO_DIR: $(GO_DIR)) - $(info Current Go Verison: $(GO_VERSION)) + $(info Current Go Version: $(GO_VERSION)) ifneq ($(GO_VERSION), $(lastword $(sort $(GO_MINIMUM) $(GO_VERSION)))) - $(error Requires $(GO_MINIMUM) for module fingerprint/tls) + $(error Requires $(GO_MINIMUM)) endif -realclean: distclean - rm -f *.dat - -distclean: clean - rm -f *.zip - clean: - rm -rf $(BIN_DIR) + rm -rf $(BUILD_DIR) + rm -f *.zip + rm -f *.dat geoip.dat: wget https://github.com/v2ray/geoip/raw/release/geoip.dat @@ -43,23 +33,18 @@ geoip.dat: geosite.dat: wget https://github.com/v2ray/domain-list-community/raw/release/dlc.dat -O geosite.dat -lint: - $(GO_DIR)go get -u github.com/alecthomas/gometalinter - $(GOMETALINTER) --install &> /dev/null - $(GOMETALINTER) ./... --vendor - test: depends @$(GO_DIR)go test ./... trojan-go: depends - mkdir -p $(BIN_DIR) + mkdir -p $(BUILD_DIR) $(GOBUILD) -install: $(BIN_DIR)/$(NAME) geoip.dat geosite.dat +install: $(BUILD_DIR)/$(NAME) geoip.dat geosite.dat mkdir -p /etc/$(NAME) mkdir -p /usr/share/$(NAME) cp example/*.json /etc/$(NAME) - cp $(BIN_DIR)/$(NAME) /usr/bin/$(NAME) + cp $(BUILD_DIR)/$(NAME) /usr/bin/$(NAME) cp example/$(NAME).service /usr/lib/systemd/system/ cp example/$(NAME)@.service /usr/lib/systemd/system/ systemctl daemon-reload @@ -79,85 +64,85 @@ uninstall: rm /usr/bin/geosite.dat %.zip: % geosite.dat geoip.dat - @zip -du $(NAME)-$@ -j $(BIN_DIR)/$