Browse Source

My own makefile.

ZRY 1 year ago
parent
commit
ed2bcbf645
3 changed files with 44 additions and 56 deletions
  1. 2 0
      .gitignore
  2. 8 0
      .idea/.gitignore
  3. 34 56
      Makefile

+ 2 - 0
.gitignore

@@ -25,3 +25,5 @@ _testmain.go
 cover
 /_bin/
 /elvish
+
+/dist

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 34 - 56
Makefile

@@ -1,56 +1,34 @@
-ELVISH_MAKE_BIN ?= $(or $(GOBIN),$(shell go env GOPATH)/bin)/elvish$(shell go env GOEXE)
-ELVISH_MAKE_BIN := $(subst \,/,$(ELVISH_MAKE_BIN))
-ELVISH_MAKE_PKG ?= ./cmd/elvish
-
-default: test get
-
-# This target emulates the behavior of "go install ./cmd/elvish", except that
-# the build output and the main package to build can be overridden with
-# environment variables.
-get:
-	mkdir -p $(shell dirname $(ELVISH_MAKE_BIN))
-	go build -o $(ELVISH_MAKE_BIN) $(ELVISH_MAKE_PKG)
-
-generate:
-	go generate ./...
-
-# Run unit tests, with race detection if the platform supports it.
-test:
-	go test $(shell ./tools/run-race.sh) ./...
-	cd website; go test $(shell ./tools/run-race.sh) ./...
-
-# Generate a basic test coverage report, and open it in the browser. See also
-# https://apps.codecov.io/gh/elves/elvish/.
-cover:
-	go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
-	./tools/prune-cover.sh .codecov.yml cover
-	go tool cover -html=cover
-	go tool cover -func=cover | tail -1 | awk '{ print "Overall coverage:", $$NF }'
-
-# Ensure the style of Go and Markdown source files is consistent.
-style:
-	find . -name '*.go' | xargs goimports -w
-	find . -name '*.go' | xargs gofmt -s -w
-	find . -name '*.md' | xargs go run src.elv.sh/cmd/elvmdfmt -w -width 80
-
-# Check if the style of the Go and Markdown files is correct without modifying
-# those files.
-checkstyle: checkstyle-go checkstyle-md
-
-checkstyle-go:
-	./tools/checkstyle-go.sh
-
-checkstyle-md:
-	./tools/checkstyle-md.sh
-
-lint:
-	./tools/lint.sh
-
-codespell:
-	codespell --skip .git
-
-check-content:
-	./tools/check-content.sh
-
-.SILENT: checkstyle-go checkstyle-md lint
-.PHONY: default get generate test cover style checkstyle checkstyle-go checkstyle-md lint codespell check-content
+GO_BIN = go
+PKGNAME = src.elv.sh
+SRC = cmd/elvish
+DIST = dist
+BIN_NAME = elvish
+
+build = GO111MODULE=on GOOS=$(1) GOARCH=$(2) $(GO_BIN) build -o $(3) $(PKGNAME)/$(4)
+
+.PHONY : all
+.PHONY : linux_amd64
+.PHONY : windows_amd64
+.PHONY : linux_arm
+.PHONY : linux_arm64
+.PHONY : deps
+
+all : linux_amd64 windows_amd64 linux_arm linux_arm64
+
+linux_amd64 : $(DIST)/$(BIN_NAME)_linux_amd64
+linux_amd64 : $(DIST)/$(BIN_NAME)_linux_arm64
+linux_amd64 : $(DIST)/$(BIN_NAME)_linux_arm
+linux_amd64 : $(DIST)/$(BIN_NAME)_windows_amd64.exe
+
+$(DIST)/$(BIN_NAME)_linux_amd64 : $(SRC)/
+	$(call build,linux,amd64,$@,$^)
+
+$(DIST)/$(BIN_NAME)_linux_arm64 : $(SRC)/
+	$(call build,linux,arm64,$@,$^)
+
+
+$(DIST)/$(BIN_NAME)_linux_arm : $(SRC)/
+	$(call build,linux,arm,$@,$^)
+
+$(DIST)/$(BIN_NAME)_windows_amd64.exe : $(SRC)/
+	$(call build,windows,amd64,$@,$^)