syncbase: Fix compilation of syncbase as a mojo service.
I have no idea how this was working for Adam without setting all the CGO
flags to link leveldb and snappy.
This depends on go/vcl/14260 for compiling leveldb and snappy with
-fPIC, which the compiler also requires.
Change-Id: I73168abe6a6805ad8f0079cba80588ae0bdae484
diff --git a/Makefile b/Makefile
index 35d9aa5..b8f4289 100644
--- a/Makefile
+++ b/Makefile
@@ -25,16 +25,26 @@
# Configure compiler and linker for Android.
GO_BIN := $(MOJO_DIR)/src/third_party/go/tool/android_arm/bin/go
GO_FLAGS := -tags=mojo -ldflags=-shared
+
MOJO_BUILD_DIR := $(MOJO_DIR)/src/out/android_Debug
MOJO_FLAGS := --android
MOJO_SHARED_LIB := $(PWD)/gen/lib/android/libsystem_thunk.a
+
+ SYNCBASE_LEVELDB_DIR := $(V23_ROOT)/third_party/cout/linux_amd64/leveldb
+ SYNCBASE_SNAPPY_DIR := $(V23_ROOT)/third_party/cout/linux_amd64/snappy
else
# Configure compiler and linker for Linux.
GO_BIN := $(MOJO_DIR)/src/third_party/go/tool/linux_amd64/bin/go
GO_FLAGS := -tags=mojo -ldflags=-shared -buildmode=c-shared
+
MOJO_FLAGS :=
MOJO_BUILD_DIR := $(MOJO_DIR)/src/out/Debug
MOJO_SHARED_LIB := $(PWD)/gen/lib/linux_amd64/libsystem_thunk.a
+
+ # TODO(nlacasse): Build leveldb and snappy libs for android, and put the
+ # correct paths below.
+ SYNCBASE_LEVELDB_DIR := $(V23_ROOT)/third_party/cout/linux_amd64/leveldb
+ SYNCBASE_SNAPPY_DIR := $(V23_ROOT)/third_party/cout/linux_amd64/snappy
endif
# Compiles a Go program and links against the Mojo C shared library.
@@ -45,17 +55,21 @@
#
# MOJO_GOPATH must be exported so it can be picked up by MOGO_BIN.
export MOJO_GOPATH := $(V23_GOPATH):$(PWD)/gen/go:$(PWD)/go:$(MOJO_BUILD_DIR)/gen/go
+# TODO(nlacasse): It's strange that go.py takes CGO_CFLAGS and CGO_LDFLAGS as
+# arguments, but other cgo settings (like CGO_CXXFLAGS) must be set with env
+# variables. I think these should all be env variables.
+export CGO_CXXFLAGS := -I$(SYNCBASE_LEVELDB_DIR)/include -I$(SYNCBASE_SNAPPY_DIR)/include
MOGO_BIN := $(MOJO_DIR)/src/mojo/go/go.py
define MOGO_BUILD
mkdir -p $(dir $2)
$(MOGO_BIN) $(MOJO_FLAGS) -- \
- $(GO_BIN) \
- $(shell mktemp -d) \
- $(PWD)/$(2) \
- $(MOJO_DIR)/src \
- $(PWD)/gen \
- "-I$(MOJO_DIR)/src" \
- "-L$(dir $(MOJO_SHARED_LIB)) -lsystem_thunk" \
+ "$(GO_BIN)" \
+ "$(shell mktemp -d)" \
+ "$(PWD)/$(2)" \
+ "$(MOJO_DIR)/src" \
+ "$(PWD)/gen" \
+ "-I$(MOJO_DIR)/src -I$(SYNCBASE_LEVELDB_DIR)/include -I$(SYNCBASE_SNAPPY_DIR)/include" \
+ "-L$(dir $(MOJO_SHARED_LIB)) -lsystem_thunk -L$(SYNCBASE_LEVELDB_DIR)/lib -L$(SYNCBASE_SNAPPY_DIR)/lib" \
build $(GO_FLAGS) $1
endef
diff --git a/dart/test/syncbase_test.dart b/dart/test/syncbase_test.dart
index 9924e74..558dead 100755
--- a/dart/test/syncbase_test.dart
+++ b/dart/test/syncbase_test.dart
@@ -11,7 +11,7 @@
// TODO(nlacasse): Switch to serving these files over http rather than
// directly from the filesystem, so they can be accessed by Android.
- String url = 'file://' + args[1].replaceFirst('dart/test/syncbase_test.dart', 'gen/mojo/synbase_server.mojo');
+ String url = 'file://' + args[1].replaceFirst('dart/test/syncbase_test.dart', 'gen/mojo/syncbase_server.mojo');
SyncbaseClient c = new SyncbaseClient(app, url);
diff --git a/tests b/tests
index 5f56e37..5bacde1 100644
--- a/tests
+++ b/tests
@@ -3,12 +3,15 @@
tests = [
{
"test": "dart/test/echo_test.dart",
- "type": "dart"
+ "type": "dart",
+ "timeout":5
},
-# TODO(nlacasse,sadovsky): Enable these tests once syncbase runs in a mojo
-# service.
-# {
-# "test": "dart/test/syncbase_test.dart",
-# "type": "dart"
-# }
+ # TODO(nlacasse): The syncbase tests run and pass, but then mojo_shell does
+ # not exit. I suspect some connection is not getting closed properly.
+ # More debugging is necessary.
+ #{
+ # "test": "dart/test/syncbase_test.dart",
+ # "type": "dart",
+ # "timeout": 5
+ #}
]