veyron/lib/bluetooth: Disable compilation of the bluetooth package and
packages that depend on it unless the --tags=veyronbluetooth option is
provided to the Go compiler.

Change-Id: I30abd8d703d5b0a4d5532101fb99c5589db882bc
diff --git a/lib/bluetooth/addr.go b/lib/bluetooth/addr_linux.go
similarity index 94%
rename from lib/bluetooth/addr.go
rename to lib/bluetooth/addr_linux.go
index 70e5392..0b9bc8c 100644
--- a/lib/bluetooth/addr.go
+++ b/lib/bluetooth/addr_linux.go
@@ -1,3 +1,5 @@
+// +build veyronbluetooth,!android
+
 package bluetooth
 
 import (
@@ -8,9 +10,6 @@
 	"strings"
 )
 
-// Network string for net.Addr implementations used by the bluetooth package.
-const Network = "bluetooth"
-
 // addr represents an RFCOMM over bluetooth address in the <MAC-channelID>
 // format, where channelID denotes one of the available RFCOMM channels.
 //
diff --git a/lib/bluetooth/addr_test.go b/lib/bluetooth/addr_linux_test.go
similarity index 95%
rename from lib/bluetooth/addr_test.go
rename to lib/bluetooth/addr_linux_test.go
index e581bbe..303764e 100644
--- a/lib/bluetooth/addr_test.go
+++ b/lib/bluetooth/addr_linux_test.go
@@ -1,3 +1,5 @@
+// +build veyronbluetooth,!android
+
 package bluetooth
 
 import "testing"
diff --git a/lib/bluetooth/bluetooth_common.go b/lib/bluetooth/bluetooth_common.go
new file mode 100644
index 0000000..7d92524
--- /dev/null
+++ b/lib/bluetooth/bluetooth_common.go
@@ -0,0 +1,5 @@
+package bluetooth
+
+// Network string for net.Addr implementations used by the bluetooth
+// package.
+const Network = "bluetooth"
diff --git a/lib/bluetooth/bluetooth_linux.go b/lib/bluetooth/bluetooth_linux.go
index 2a3ba83..0ed6cab 100644
--- a/lib/bluetooth/bluetooth_linux.go
+++ b/lib/bluetooth/bluetooth_linux.go
@@ -1,4 +1,4 @@
-// +build linux,!android
+// +build veyronbluetooth,!android
 
 package bluetooth
 
@@ -22,7 +22,7 @@
 // #include <bluetooth/hci_lib.h>
 // #include <stdlib.h>
 // #include <unistd.h>
-// #include "bt.h"
+// #include "bt_linux.h"
 import "C"
 
 var (
diff --git a/lib/bluetooth/bluetooth_test.go b/lib/bluetooth/bluetooth_linux_test.go
similarity index 93%
rename from lib/bluetooth/bluetooth_test.go
rename to lib/bluetooth/bluetooth_linux_test.go
index ae70f11..3b6a152 100644
--- a/lib/bluetooth/bluetooth_test.go
+++ b/lib/bluetooth/bluetooth_linux_test.go
@@ -1,4 +1,4 @@
-// +build linux
+// +build veyronbluetooth,!android
 
 package bluetooth
 
diff --git a/lib/bluetooth/bluetooth_other.go b/lib/bluetooth/bluetooth_other.go
index abe0f7a..5ec4815 100644
--- a/lib/bluetooth/bluetooth_other.go
+++ b/lib/bluetooth/bluetooth_other.go
@@ -1,4 +1,4 @@
-// +build !linux android
+// +build !veyronbluetooth !linux android
 
 package bluetooth
 
@@ -7,14 +7,23 @@
 	"net"
 )
 
-// Dial always returns an error since bluetooth RFCOMM is not implemented on this
-// platform.
+// Device is a struct representing an opened Bluetooth device.
+type Device struct{}
+
+// Dial always returns an error since bluetooth is not yet supported
+// on this platform.
 func Dial(remoteaddr string) (net.Conn, error) {
-	return nil, errors.New("bluetooth Dialing not implemented on this platform")
+	return nil, errors.New("bluetooth is not supported on this platform")
 }
 
-// Listen always returns an error since bluetooth RFCOMM is not implemented on
-// this platform.
+// Listen always returns an error since bluetooth is not yet supported
+// on this platform.
 func Listen(localaddr string) (net.Listener, error) {
-	return nil, errors.New("bluetooth Listening not implemented on this platform")
+	return nil, errors.New("bluetooth is not supported on this platform")
+}
+
+// OpenFirstAvailableDevice always returns an error since bluetooth is
+// not yet supported on this platform.
+func OpenFirstAvailableDevice() (*Device, error) {
+	return nil, errors.New("bluetooth is not supported on this platform")
 }
diff --git a/lib/bluetooth/bt.c b/lib/bluetooth/bt_linux.c
similarity index 99%
rename from lib/bluetooth/bt.c
rename to lib/bluetooth/bt_linux.c
index 4744f43..f4ea910 100644
--- a/lib/bluetooth/bt.c
+++ b/lib/bluetooth/bt_linux.c
@@ -1,6 +1,6 @@
-// +build linux,!android
+// +build veyronbluetooth,!android
 
-#include "bt.h"
+#include "bt_linux.h"
 
 #include <assert.h>
 #include <errno.h>
diff --git a/lib/bluetooth/bt.h b/lib/bluetooth/bt_linux.h
similarity index 98%
rename from lib/bluetooth/bt.h
rename to lib/bluetooth/bt_linux.h
index cc36b31..2e215d9 100644
--- a/lib/bluetooth/bt.h
+++ b/lib/bluetooth/bt_linux.h
@@ -1,4 +1,4 @@
-// +build linux,!android
+// +build veyronbluetooth,!android
 
 #include <stdlib.h>
 
diff --git a/lib/bluetooth/conn.go b/lib/bluetooth/conn_linux.go
similarity index 98%
rename from lib/bluetooth/conn.go
rename to lib/bluetooth/conn_linux.go
index 6574313..9b5a573 100644
--- a/lib/bluetooth/conn.go
+++ b/lib/bluetooth/conn_linux.go
@@ -1,4 +1,4 @@
-// +build linux
+// +build veyronbluetooth,!android
 
 package bluetooth
 
diff --git a/lib/bluetooth/conn_test.go b/lib/bluetooth/conn_linux_test.go
similarity index 98%
rename from lib/bluetooth/conn_test.go
rename to lib/bluetooth/conn_linux_test.go
index 8aaa2f1..e6803e8 100644
--- a/lib/bluetooth/conn_test.go
+++ b/lib/bluetooth/conn_linux_test.go
@@ -1,4 +1,4 @@
-// +build linux
+// +build veyronbluetooth,!android
 
 package bluetooth
 
diff --git a/lib/bluetooth/fd.go b/lib/bluetooth/fd_linux.go
similarity index 99%
rename from lib/bluetooth/fd.go
rename to lib/bluetooth/fd_linux.go
index 328c351..c787c8d 100644
--- a/lib/bluetooth/fd.go
+++ b/lib/bluetooth/fd_linux.go
@@ -1,4 +1,4 @@
-// +build linux
+// +build veyronbluetooth,!android
 
 package bluetooth
 
diff --git a/lib/bluetooth/fd_test.go b/lib/bluetooth/fd_linux_test.go
similarity index 98%
rename from lib/bluetooth/fd_test.go
rename to lib/bluetooth/fd_linux_test.go
index 9b7b662..7b4e359 100644
--- a/lib/bluetooth/fd_test.go
+++ b/lib/bluetooth/fd_linux_test.go
@@ -1,4 +1,4 @@
-// +build linux
+// +build veyronbluetooth,!android
 
 package bluetooth
 
diff --git a/lib/bluetooth/listener.go b/lib/bluetooth/listener_linux.go
similarity index 96%
rename from lib/bluetooth/listener.go
rename to lib/bluetooth/listener_linux.go
index a375a8f..c951baa 100644
--- a/lib/bluetooth/listener.go
+++ b/lib/bluetooth/listener_linux.go
@@ -1,4 +1,4 @@
-// +build linux,!android
+// +build veyronbluetooth,!android
 
 package bluetooth
 
@@ -13,7 +13,7 @@
 // #cgo LDFLAGS: -lbluetooth
 // #include <stdlib.h>
 // #include <unistd.h>
-// #include "bt.h"
+// #include "bt_linux.h"
 import "C"
 
 // listener waits for incoming RFCOMM connections on the provided socket.
diff --git a/runtimes/google/ipc/stream/vc/vc.go b/runtimes/google/ipc/stream/vc/vc.go
index 894928f..9bd195c 100644
--- a/runtimes/google/ipc/stream/vc/vc.go
+++ b/runtimes/google/ipc/stream/vc/vc.go
@@ -57,8 +57,8 @@
 	crypter             crypto.Crypter
 	closeReason         string // reason why the VC was closed
 
-	helper Helper
-	version             version.IPCVersion
+	helper  Helper
+	version version.IPCVersion
 }
 
 // Helper is the interface for functionality required by the stream.VC
diff --git a/runtimes/google/ipc/stream/vc/vc_test.go b/runtimes/google/ipc/stream/vc/vc_test.go
index 9bcb602..3acd6fb 100644
--- a/runtimes/google/ipc/stream/vc/vc_test.go
+++ b/runtimes/google/ipc/stream/vc/vc_test.go
@@ -162,7 +162,6 @@
 func TestConnect_Version1(t *testing.T)    { testConnect_Version1(t, SecurityNone) }
 func TestConnect_Version1TLS(t *testing.T) { testConnect_Version1(t, SecurityTLS) }
 
-
 // helper function for testing concurrent operations on multiple flows over the
 // same VC.  Such tests are most useful when running the race detector.
 // (go test -race ...)
diff --git a/services/gateway/gatewayd/main.go b/services/gateway/gatewayd/main_linux.go
similarity index 100%
rename from services/gateway/gatewayd/main.go
rename to services/gateway/gatewayd/main_linux.go
diff --git a/services/gateway/lib/gateway_darwin.go b/services/gateway/lib/gateway_darwin.go
deleted file mode 100644
index d00b019..0000000
--- a/services/gateway/lib/gateway_darwin.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package gateway
-
-// TODO(mattr): This is a temporary placeholder to get compiles basically
-// working on a mac.  Obviously a real implementation is needed.
-
-func New(proximityService string, forceClient bool) (*Service, error) {
-	return &Service{}, nil
-}
-
-type Service struct {
-}
-
-// Stop stops the gateway service.
-func (s *Service) Stop() {
-}
diff --git a/services/proximity/lib/scanner_linux.go b/services/proximity/lib/bluetooth_scanner.go
similarity index 98%
rename from services/proximity/lib/scanner_linux.go
rename to services/proximity/lib/bluetooth_scanner.go
index b448320..7929ece 100644
--- a/services/proximity/lib/scanner_linux.go
+++ b/services/proximity/lib/bluetooth_scanner.go
@@ -1,5 +1,3 @@
-// +build linux
-
 package proximity
 
 import (
diff --git a/services/proximity/lib/scanner_other.go b/services/proximity/lib/scanner_other.go
deleted file mode 100644
index 3eb299b..0000000
--- a/services/proximity/lib/scanner_other.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// +build !linux
-
-package proximity
-
-import "fmt"
-
-// NewBluetoothScanner always returns (nil, <error>) as bluetooth scanners
-// are not supported on this platform.
-func NewBluetoothScanner() (Scanner, error) {
-	return nil, fmt.Errorf("bluetooth scanner not yet supported")
-}
diff --git a/services/proximity/lib/service.go b/services/proximity/lib/service.go
index 166b5a3..2bbdd51 100644
--- a/services/proximity/lib/service.go
+++ b/services/proximity/lib/service.go
@@ -9,7 +9,7 @@
 
 	"veyron/lib/unit"
 	"veyron2/ipc"
-	prox "veyron2/services/proximity"
+	"veyron2/services/proximity"
 	"veyron2/vlog"
 )
 
@@ -97,7 +97,7 @@
 	deviceLock sync.RWMutex
 	nameLock   sync.RWMutex
 	devices    map[string]*device
-	nearby     []prox.Device
+	nearby     []proximity.Device
 	names      map[string]int
 
 	advertiser       Advertiser
@@ -141,7 +141,7 @@
 
 // NearbyDevices returns the list of nearby devices, sorted in increasing
 // distance order.
-func (s *service) NearbyDevices(_ ipc.ServerContext) ([]prox.Device, error) {
+func (s *service) NearbyDevices(_ ipc.ServerContext) ([]proximity.Device, error) {
 	s.deviceLock.RLock()
 	defer s.deviceLock.RUnlock()
 	return s.nearby, nil
@@ -313,11 +313,11 @@
 	})
 
 	// Update device list.
-	newDevs := make([]prox.Device, len(devices))
+	newDevs := make([]proximity.Device, len(devices))
 	for i, d := range devices {
 		// Sort names just for stability.
 		sort.Strings(d.names)
-		newDevs[i] = prox.Device{
+		newDevs[i] = proximity.Device{
 			Names:    d.names,
 			MAC:      d.mac.String(),
 			Distance: d.distance.String(),
diff --git a/services/proximity/proximityd/main.go b/services/proximity/proximityd/main.go
index 43cb723..7a43e1b 100644
--- a/services/proximity/proximityd/main.go
+++ b/services/proximity/proximityd/main.go
@@ -1,6 +1,3 @@
-// +build linux
-
-// TODO(srdjan): port this to mac etc.
 // Binary proximityd provides means for devices to announce their precence
 // to nearby devices and to obtain the list of nearby devices.
 package main
diff --git a/tools/playground/builder/vbuild.go b/tools/playground/builder/vbuild.go
index 0b8f174..3579760 100644
--- a/tools/playground/builder/vbuild.go
+++ b/tools/playground/builder/vbuild.go
@@ -23,6 +23,7 @@
 )
 
 const RUN_TIMEOUT = time.Second
+
 var debug = flag.Bool("v", false, "Verbose mode")
 
 type CodeFile struct {