Skip to content

Commit

Permalink
build: use make (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBernier authored Dec 26, 2020
1 parent 0b4febd commit b617352
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ factom-cli
_obj
_test
bin
build
pkg
.idea
vendor/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ COPY . .
ARG GOOS=linux

# Build and install factom-cli
RUN ./build.sh
RUN make install

ENTRYPOINT ["/go/bin/factom-cli"]
4 changes: 3 additions & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM golang:1.15-alpine as builder

RUN apk add --no-cache git make gcc libc-dev

# Where factom-cli sources will live
WORKDIR $GOPATH/src/github.com/FactomProject/factom-cli

Expand All @@ -9,7 +11,7 @@ COPY . .
ARG GOOS=linux

# Build and install factom-cli
RUN ./build.sh
RUN make install

# Now squash everything
FROM alpine:3.12
Expand Down
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
REVISION = $(shell git describe --tags)
$(info Make factom-cli $(REVISION))

LDFLAGS := "-s -w -X main.FactomcliVersion=$(REVISION)"

default: factom-cli
install: factom-cli-install
all: factom-cli-darwin-amd64 factom-cli-windows-amd64.exe factom-cli-windows-386.exe factom-cli-linux-amd64 factom-cli-linux-arm64 factom-cli-linux-arm7

BUILD_FOLDER := build

factom-cli:
go build -trimpath -ldflags $(LDFLAGS)
factom-cli-install:
go install -trimpath -ldflags $(LDFLAGS)

factom-cli-darwin-amd64:
env GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags $(LDFLAGS) -o $(BUILD_FOLDER)/factom-cli-darwin-amd64-$(REVISION)
factom-cli-windows-amd64.exe:
env GOOS=windows GOARCH=amd64 go build -trimpath -ldflags $(LDFLAGS) -o $(BUILD_FOLDER)/factom-cli-windows-amd64-$(REVISION).exe
factom-cli-windows-386.exe:
env GOOS=windows GOARCH=386 go build -trimpath -ldflags $(LDFLAGS) -o $(BUILD_FOLDER)/factom-cli-windows-386-$(REVISION).exe
factom-cli-linux-amd64:
env GOOS=linux GOARCH=amd64 go build -trimpath -ldflags $(LDFLAGS) -o $(BUILD_FOLDER)/factom-cli-linux-amd64-$(REVISION)
factom-cli-linux-arm64:
env GOOS=linux GOARCH=arm64 go build -trimpath -ldflags $(LDFLAGS) -o $(BUILD_FOLDER)/factom-cli-linux-arm64-$(REVISION)
factom-cli-linux-arm7:
env GOOS=linux GOARCH=arm GOARM=7 go build -trimpath -ldflags $(LDFLAGS) -o $(BUILD_FOLDER)/factom-cli-linux-arm7-$(REVISION)

.PHONY: clean

clean:
rm -f factom-cli
rm -rf build
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ and transactions on the Factom blockchain by calling out to both
Zsh or Fish

## Package distribution
`factom-cli` is installed with the Factom package found
[here](https://github.com/FactomProject/distribution). This also installs
`factomd` and `factom-walletd`.

Binaries for your platform can be downloaded from the [GitHub release page](https://github.com/FactomProject/factom-cli/releases).

## Build and install

```
make install
```

To cross compile to all supported platforms:
```
./build.sh
make all
```
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

2 changes: 0 additions & 2 deletions build.sh

This file was deleted.

0 comments on commit b617352

Please sign in to comment.