Jelajahi Sumber

Add the makefile

Vadim Markovtsev 7 tahun lalu
induk
melakukan
8bda44b90e
2 mengubah file dengan 23 tambahan dan 0 penghapusan
  1. 16 0
      Makefile
  2. 7 0
      cmd/hercules/main.go

+ 16 - 0
Makefile

@@ -0,0 +1,16 @@
+all: ${GOPATH}/src/gopkg.in/bblfsh/client-go.v2 ${GOPATH}/bin/hercules
+
+test: all
+	go test gopkg.in/src-d/hercules.v3
+
+.ONESHELL:
+${GOPATH}/src/gopkg.in/bblfsh/client-go.v2:
+	go get -v gopkg.in/bblfsh/client-go.v2/...
+	cd $$GOPATH/src/gopkg.in/bblfsh/client-go.v2
+	make dependencies
+
+.ONESHELL:
+${GOPATH}/bin/hercules:
+	cd ${GOPATH}/src/gopkg.in/src-d/hercules.v3
+	go get -ldflags "-X gopkg.in/src-d/hercules.v3.GIT_HASH=$$(git rev-parse HEAD)" gopkg.in/src-d/hercules.v3/cmd/hercules
+	${GOPATH}/bin/hercules -version

+ 7 - 0
cmd/hercules/main.go

@@ -142,6 +142,7 @@ func loadPlugins() {
 
 func main() {
 	loadPlugins()
+	var printVersion bool
 	var protobuf bool
 	var profile bool
 	var commitsFile string
@@ -151,9 +152,15 @@ func main() {
 		"--first-parent. The format is the list of hashes, each hash on a "+
 		"separate line. The first hash is the root.")
 	flag.BoolVar(&protobuf, "pb", false, "The output format will be Protocol Buffers instead of YAML.")
+	flag.BoolVar(&printVersion, "version", false, "Print version information and exit.")
 	facts, deployChoices := hercules.Registry.AddFlags()
 	flag.Parse()
 
+	if printVersion {
+		fmt.Printf("Version: 3\nGit:     %s\n", hercules.GIT_HASH)
+		return
+	}
+
 	if profile {
 		go http.ListenAndServe("localhost:6060", nil)
 		prof, _ := os.Create("hercules.pprof")