croupier/go: Improve Makefile
The build and tests can now occur without needing special `go get` or
GOPATH setups. A clean target was added as well.
The other Makefile can be removed too, though we will leave it in if
it is still needed.
Change-Id: Ifc5100f639fcfa181dd956da18ca218b1d9d3442
diff --git a/go/.gitignore b/go/.gitignore
new file mode 100644
index 0000000..02f3357
--- /dev/null
+++ b/go/.gitignore
@@ -0,0 +1,3 @@
+credentials/
+tmp/syncbase/
+assets
diff --git a/go/Makefile b/go/Makefile
index 8e58388..c5bccc7 100644
--- a/go/Makefile
+++ b/go/Makefile
@@ -5,9 +5,7 @@
PATH := ./bin/:$(PATH)
go_files := $(shell find ./src -name "*.go")
-.PHONY:
-start: all
- st --port $(port) --host $(host) --dir public --no-cache --index index.html
+export GOPATH := $(JIRI_ROOT)/release/projects/croupier/go:$(GOPATH)
bin/principal:
jiri go build -a -o $@ v.io/x/ref/cmd/principal
@@ -38,17 +36,47 @@
--v23.credentials=credentials \
--v23.permissions.literal='{"Admin":{"In":["..."]},"Write":{"In":["..."]},"Read":{"In":["..."]},"Resolve":{"In":["..."]},"Debug":{"In":["..."]}}'
-test:
+test: src/golang.org/x/mobile/cmd/gomobile vet
jiri go test hearts/...
-fmt:
+fmt: src/golang.org/x/mobile/cmd/gomobile
jiri go fmt hearts/...
-vet:
+vet: src/golang.org/x/mobile/cmd/gomobile
jiri go vet hearts/...
-all: fmt
+# This project depends on gomobile, which is retrieved by `go get`.
+# Note: gomobile is gotten to the src/golang.org area because of how this
+# Makefile sets its GOPATH, which makes it easier to delete.
+src/golang.org/x/mobile/cmd/gomobile:
+ go get golang.org/x/mobile/cmd/gomobile
+
+# Builds the Hearts binary.
+bin/hearts: $(go_files) src/golang.org/x/mobile/cmd/gomobile | fmt
+ jiri go build -a -o $@ hearts
+
+# It seems that gomobile expects assets to be part of the working directory.
+# This symlink copies the src/hearts/assets folder down.
+assets:
+ ln -sf src/hearts/assets assets
+
+.PHONY: hearts
+hearts: bin/hearts assets credentials
+ bin/hearts \
+ --v23.tcp.address=:$(syncbase_port) \
+ --v23.credentials=credentials
+
+.PHONY: clean
+clean:
+ rm -f assets
+ rm -rf bin
+ rm -rf credentials
+ rm -rf pkg
+ rm -rf src/golang.org/x/mobile/cmd/gomobile
+ rm -rf tmp/syncbase
+
+all: bin/hearts
# Switch mountpoints by replacing the --name flag in syncbase with the following line:
-#
-#--name=/192.168.86.254:8101/croupier/$(name) \
\ No newline at end of file
+#
+#--name=/192.168.86.254:8101/croupier/$(name) \
diff --git a/go/src/hearts/logic/table/table.go b/go/src/hearts/logic/table/table.go
index 383de1b..25ea103 100644
--- a/go/src/hearts/logic/table/table.go
+++ b/go/src/hearts/logic/table/table.go
@@ -180,7 +180,6 @@
return "Must follow suit"
}
}
- return "Invalid play"
}
// Returns true if all players have their initial dealt hands