Skip to content

Commit

Permalink
Improved make file and documented.
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoathaydes committed Jan 6, 2018
1 parent 9282b8d commit 50c8e6c
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 16 deletions.
38 changes: 35 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
.PHONY: all
all: test
all: test install

ifeq ($(GOPATH),)
GOPATH=~/go
endif

GODEP=$(GOPATH)/src/github.com/golang/dep/cmd/dep

# get dep if necessary
$(GODEP):
go get -u github.com/golang/dep/cmd/dep

# download all dependencies into the vendor dir
vendor: $(GODEP) Gopkg.toml Gopkg.lock
dep ensure

# runs all tests and benchmarks
.PHONY: bench
bench:
bench: vendor
go test -bench .
cd encryption && go test -bench=.

# runs all tests
.PHONY: test
test:
test: vendor
go test ./...

# installs go-hash
.PHONY: install
install: vendor
go install

# build a smaller executable without symbols and debug info for all supported OSs and ARCHs
.PHONY: release release-linux release-windows release-darwin

Expand All @@ -27,3 +46,16 @@ release-darwin:
env GOOS=darwin env GOARCH=amd64 go build -ldflags "-s -w" -o releases/go-hash-darwin-amd64

release: test release-linux release-windows release-darwin

# clean build artifacts, i.e. everything that is not source code, including the vendor directory.
# Does not remove the installed binary.
.PHONY: clean
clean:
rm -f go-hash
rm -rf vendor
rm -rf releases

# uninstall the go-hash binary
.PHONY: uninstall
uninstall:
rm -f $(GOPATH)/bin/go-hash
55 changes: 42 additions & 13 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -364,31 +364,34 @@ adapted from PasswordSafe's
## Building

The [releases page](https://github.com/renatoathaydes/go-hash/releases) contains executables for several platforms
but if your platform is not included or you want to build from source, just clone this repository and build it as follows:
but if your platform is not included or you want to build from source, just clone this repository and build it as explained below.

### Clone this repo

* Using git:

```
git clone [email protected]:renatoathaydes/go-hash.git
cd go-hash
```

# install dep if you don't have it
go get -u github.com/golang/dep/cmd/dep
# sync dependencies
dep ensure
* Using Go:

# build or install
go build
```
go get -u github.com/renatoathaydes/go-hash
cd $GOPATH/src/github.com/renatoathaydes/go-hash
```

To run the tests:
### Build using make

The easiest way to build is with make. From the root directory, just run it:

```
make
# or
go test ./..
```

This will get anything else required to build, then build, install and run the tests.

To run the benchmarks:

```
Expand All @@ -402,3 +405,29 @@ make release
```

The local release files go in the `releases` folder.

> To see a list of all targets, in a shell that supports it (most shells), just type `make ` and hit Tab.
Otherwise, see the [Makefile](Makefile).

### Build with just go

Make is not necessary to build, it's just use for convenience.

If you don't have make or just don't want to use it, here's how to build go-hash without it:

```
# install dep if you don't have it
go get -u github.com/golang/dep/cmd/dep
# sync dependencies
dep ensure
# build or install
go build
```

Run tests with:

```
go test ./...
```

0 comments on commit 50c8e6c

Please sign in to comment.