Skip to content

Commit

Permalink
Add make release.
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed May 6, 2015
1 parent cd66d2c commit 647799a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 37 deletions.
23 changes: 1 addition & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
bin
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
TEST=.
BENCH=.
COVERPROFILE=/tmp/c.out
VERSION=0.1.0
GOLDFLAGS="-X main.version $(VERSION)"

# http://cloc.sourceforge.net/
cloc:
@cloc --not-match-f='Makefile|_test.go' .
default:

cover: fmt
go test -coverprofile=$(COVERPROFILE) -test.run=$(TEST) .
go tool cover -html=$(COVERPROFILE)
rm $(COVERPROFILE)
release: release-windows release-darwin release-linux

fmt:
@go fmt ./...
release-windows:
mkdir -p bin/windows/amd64
GOOS=windows GOARCH=amd64 go build -ldflags=$(GOLDFLAGS) -o bin/windows/amd64/ego ./cmd/ego

test: fmt
@go test -v -cover -test.run=$(TEST)
release-darwin:
mkdir -p bin/darwin/amd64
GOOS=darwin GOARCH=amd64 go build -ldflags=$(GOLDFLAGS) -o bin/darwin/amd64/ego ./cmd/ego

.PHONY: cloc cover fmt test
release-linux:
mkdir -p bin/linux/amd64
GOOS=linux GOARCH=amd64 go build -ldflags=$(GOLDFLAGS) -o bin/linux/amd64/ego ./cmd/ego

.PHONY: default release
10 changes: 10 additions & 0 deletions cmd/ego/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,22 @@ import (
"github.com/benbjohnson/ego"
)

// version is set by the makefile during build.
var version string

func main() {
outfile := flag.String("o", "ego.go", "output file")
pkgname := flag.String("package", "", "package name")
versionFlag := flag.Bool("version", false, "print version")
flag.Parse()
log.SetFlags(0)

// If the version flag is set then print the version.
if *versionFlag {
fmt.Printf("ego v%s\n", version)
return
}

// If no paths are provided then use the present working directory.
roots := flag.Args()
if len(roots) == 0 {
Expand Down

0 comments on commit 647799a

Please sign in to comment.