Skip to content

Commit

Permalink
Makefile: add xcompile and package
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Mar 22, 2016
1 parent 400ce90 commit 0beb1e2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TEST?=$(shell GO15VENDOREXPERIMENT=1 go list -f '{{.ImportPath}}/...' ./... | grep -v /vendor/ | sed "s|$(shell go list -f '{{.ImportPath}}' .)|.|g" | sed "s/\.\/\.\.\./\.\//g")
VET?=$(shell echo ${TEST} | sed "s/\.\.\.//g" | sed "s/\.\/ //g")
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
NAME=$(shell awk -F\" '/^const Name/ { print $$2 }' cmd/version.go)
VERSION=$(shell awk -F\" '/^const Version/ { print $$2 }' cmd/version.go)

all: test vaultfs

Expand Down Expand Up @@ -58,4 +60,25 @@ fmt:
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

xcompile: test
@rm -rf build/
@mkdir -p build
gox \
-os="darwin" \
-os="dragonfly" \
-os="freebsd" \
-os="linux" \
-os="openbsd" \
-os="solaris" \
-os="windows" \
-output="build/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)"

package: xcompile
$(eval FILES := $(shell ls build))
@mkdir -p build/tgz
for f in $(FILES); do \
(cd $(shell pwd)/build && tar -zcvf tgz/$$f.tar.gz $$f); \
echo $$f; \
done

.PHONY: all test vet fmt fmtcheck lint
40 changes: 40 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright © 2016 Asteris
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// Name describes the name of this tool
const Name = "vaultfs"

// Version describes the version of this tool
const Version = "1.0.0"

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "A brief description of your command",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("%s %s", Name, Version)
},
}

func init() {
RootCmd.AddCommand(versionCmd)
}

0 comments on commit 0beb1e2

Please sign in to comment.