-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from desmos-labs/riccardo/makefile-improvements
Makefile improvements
- Loading branch information
Showing
10 changed files
with
124 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
LEDGER_ENABLED ?= true | ||
|
||
build_tags = netgo | ||
ifeq ($(LEDGER_ENABLED),true) | ||
ifeq ($(OS),Windows_NT) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
### | ||
# Find OS and Go environment | ||
# GO contains the Go binary | ||
# FS contains the OS file separator | ||
### | ||
ifeq ($(OS),Windows_NT) | ||
GO := $(shell where go.exe 2> NUL) | ||
FS := "\\" | ||
else | ||
GO := $(shell command -v go 2> /dev/null) | ||
FS := "/" | ||
endif | ||
|
||
ifeq ($(GO),) | ||
$(error could not find go. Is it in PATH? $(GO)) | ||
endif | ||
|
||
GOPATH ?= $(shell $(GO) env GOPATH) | ||
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com | ||
GOLANGCI_LINT_HASHSUM := 8d21cc95da8d3daf8321ac40091456fc26123c964d7c2281d339d431f2f4c840 | ||
|
||
### | ||
# Functions | ||
### | ||
|
||
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd) | ||
|
||
### | ||
# tools | ||
### | ||
|
||
TOOLS_DESTDIR ?= $(GOPATH)/bin | ||
|
||
GOLANGCI_LINT = $(TOOLS_DESTDIR)/golangci-lint | ||
|
||
all: tools | ||
|
||
tools: golangci-lint | ||
|
||
golangci-lint: $(GOLANGCI_LINT) | ||
$(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh | ||
@echo "Installing golangci-lint..." | ||
@bash $(mkfile_dir)/install-golangci-lint.sh $(TOOLS_DESTDIR) $(GOLANGCI_LINT_HASHSUM) | ||
|
||
|
||
|
||
tools-clean: | ||
rm -f $(GOLANGCI_LINT) | ||
rm -f tools-stamp | ||
|
||
.PHONY: all tools tools-clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
installer="$(mktemp)" | ||
trap "rm -f ${installer}" EXIT | ||
|
||
GOBIN="${1}" | ||
CURL="$(which curl)" | ||
HASHSUM="${2}" | ||
|
||
f_sha256() { | ||
local l_file | ||
l_file=$1 | ||
python -sBc "import hashlib;print(hashlib.sha256(open('$l_file','rb').read()).hexdigest())" | ||
} | ||
|
||
get_latest_release() { | ||
"${CURL}" --silent "https://api.github.com/repos/$1/releases/latest" | \ | ||
grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | ||
} | ||
|
||
VERSION="$(get_latest_release golangci/golangci-lint)" | ||
|
||
echo "Downloading golangci-lint ${VERSION} installer ..." >&2 | ||
"${CURL}" -sfL "https://raw.githubusercontent.com/golangci/golangci-lint/${VERSION}/install.sh" > "${installer}" | ||
|
||
echo "Checking hashsum ..." >&2 | ||
[ "${HASHSUM}" = "$(f_sha256 ${installer})" ] | ||
chmod +x "${installer}" | ||
|
||
echo "Launching installer ..." >&2 | ||
exec "${installer}" -d -b "${GOBIN}" "${VERSION}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters