diff --git a/Builds/VisualStudio2012/RippleD.props b/Builds/VisualStudio2012/RippleD.props
index 0dbe1245ab..04758bdfe3 100644
--- a/Builds/VisualStudio2012/RippleD.props
+++ b/Builds/VisualStudio2012/RippleD.props
@@ -12,7 +12,7 @@
- USE_LEVELDB;BOOST_TEST_ALTERNATIVE_INIT_API;BOOST_TEST_NO_MAIN;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)
+ BOOST_TEST_ALTERNATIVE_INIT_API;BOOST_TEST_NO_MAIN;_WIN32_WINNT=0x0600;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)
true
Level3
$(RepoDir);$(RepoDir)\src\cpp\protobuf\src;$(RepoDir)\src\cpp\protobuf\vsprojects;$(RepoDir)\build\proto;$(RepoDir)\Subtrees;$(RepoDir)\Subtrees\leveldb;$(RepoDir)\Subtrees\leveldb\include;$(RepoDir)\Subtrees\beast;%(AdditionalIncludeDirectories)
diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj
index f7a8687bb8..76cfae2dba 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj
+++ b/Builds/VisualStudio2012/RippleD.vcxproj
@@ -169,6 +169,12 @@
+
+ Level4
+ Level4
+ Level4
+ Level4
+
true
true
@@ -728,12 +734,6 @@
true
true
-
- true
- true
- true
- true
-
true
true
@@ -753,19 +753,6 @@
true
-
- true
- true
- true
- true
-
-
- true
- true
- true
- true
-
-
%(AdditionalIncludeDirectories)
%(AdditionalIncludeDirectories)
@@ -1511,8 +1498,6 @@
-
-
@@ -1561,7 +1546,6 @@
-
@@ -1571,8 +1555,7 @@
-
-
+
diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters
index 2d7b4c52ef..6dd34c20d1 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters
@@ -7,9 +7,6 @@
{290b7b39-a4e6-4b8b-b464-d1e458562fdd}
-
- {60c3631e-8855-4a61-bdd3-9892d96242d5}
-
{83e0c1a9-5ac4-4c68-ba62-45e24bf60c85}
@@ -82,15 +79,6 @@
{786657f9-b1b3-483c-a8e6-863cc2e02eb8}
-
- {7f76ce57-c428-487e-97a0-979c0990a81d}
-
-
- {a5190241-c5bc-4e23-8ef1-6adf757c75e3}
-
-
- {b6175f9a-7d46-4b57-877f-f58b0b3bba89}
-
{97c96b68-70fd-4679-89fc-c1c8c87c265e}
@@ -145,11 +133,11 @@
{9cd9dfb0-daa3-474e-b1c7-b048f5b85e71}
+
+ {6bbe236f-79ff-4e30-928c-bf5f302b3a21}
+
-
- 0. Third Party Code\SQLite
-
0. Third Party Code\LevelDB
@@ -306,21 +294,12 @@
1. Modules\ripple_basics
-
- 2. %28Unused%29\ripple_ledger
-
2. %28Unused%29\ripple_client
1. Modules\ripple_app\_unfactored\transactions
-
- 2. %28Unused%29\ripple_db
-
-
- 2. %28Unused%29\ripple_net
-
1. Modules\ripple_app\_unfactored\contracts
@@ -903,6 +882,9 @@
1. Modules\ripple_app\_unfactored\db
+
+ 1. Modules\ripple_sqlite
+
@@ -1073,21 +1055,12 @@
1. Modules\ripple_basics
-
- 2. %28Unused%29\ripple_ledger
-
2. %28Unused%29\ripple_client
1. Modules\ripple_app\_unfactored\transactions
-
- 2. %28Unused%29\ripple_db
-
-
- 2. %28Unused%29\ripple_net
-
1. Modules\ripple_app\_unfactored\contracts
@@ -1503,12 +1476,6 @@
1. Modules\ripple_basics\utility
-
- 0. Third Party Code\SQLite
-
-
- 0. Third Party Code\SQLite
-
1. Modules\ripple_data\protocol
@@ -1728,6 +1695,9 @@
1. Modules\ripple_app\_unfactored\db
+
+ 1. Modules\ripple_sqlite
+
diff --git a/SConstruct b/SConstruct
index 2e8ba4d58c..affe0a9c97 100644
--- a/SConstruct
+++ b/SConstruct
@@ -158,9 +158,11 @@ DEBUGFLAGS = ['-g', '-DDEBUG']
BOOSTFLAGS = ['-DBOOST_TEST_DYN_LINK', '-DBOOST_FILESYSTEM_NO_DEPRECATED']
env.Append(LINKFLAGS = ['-rdynamic', '-pthread'])
-env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE=1'])
+env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts'])
env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS)
-env.Append(CXXFLAGS = ['-DUSE_LEVELDB'])
+
+# RTTI is required for Beast and CountedObject.
+#
env.Append(CXXFLAGS = ['-frtti'])
if (int(GCC_VERSION[0]) > 4 or (int(GCC_VERSION[0]) == 4 and int(GCC_VERSION[1]) >= 7)):
diff --git a/Subtrees/README.md b/Subtrees/README.md
index a645a97a35..75c170dc28 100644
--- a/Subtrees/README.md
+++ b/Subtrees/README.md
@@ -43,3 +43,10 @@ master
**NOTE** Linux builds use the protobuf installed in /usr/lib. This will be
fixed in a future revision.
+
+## SQLite
+
+Not technically a subtree but included here because it is a direct
+copy of the official SQLite distributions available here:
+
+http://sqlite.org/download.html
diff --git a/src/cpp/database/sqlite3.c b/Subtrees/sqlite/sqlite3.c
similarity index 100%
rename from src/cpp/database/sqlite3.c
rename to Subtrees/sqlite/sqlite3.c
diff --git a/src/cpp/database/sqlite3.h b/Subtrees/sqlite/sqlite3.h
similarity index 100%
rename from src/cpp/database/sqlite3.h
rename to Subtrees/sqlite/sqlite3.h
diff --git a/src/cpp/database/sqlite3ext.h b/Subtrees/sqlite/sqlite3ext.h
similarity index 100%
rename from src/cpp/database/sqlite3ext.h
rename to Subtrees/sqlite/sqlite3ext.h
diff --git a/modules/ripple_app/ripple_app.cpp b/modules/ripple_app/ripple_app.cpp
index 48f90d8479..14a7f108f1 100644
--- a/modules/ripple_app/ripple_app.cpp
+++ b/modules/ripple_app/ripple_app.cpp
@@ -83,10 +83,9 @@
#include
#include
-// for SqliteDatabase.cpp
-#include "src/cpp/database/sqlite3.h"
-//------------------------------------------------------------------------------
+
+#include "../modules/ripple_sqlite/ripple_sqlite.h" // for SqliteDatabase.cpp
// VFALCO TODO fix these warnings!
#ifdef _MSC_VER
diff --git a/modules/ripple_sqlite/ripple_sqlite.c b/modules/ripple_sqlite/ripple_sqlite.c
new file mode 100644
index 0000000000..1a0503018a
--- /dev/null
+++ b/modules/ripple_sqlite/ripple_sqlite.c
@@ -0,0 +1,65 @@
+//------------------------------------------------------------------------------
+/*
+ Copyright (c) 2011-2013, OpenCoin, Inc.
+*/
+//==============================================================================
+
+/** Add this to get the @ref ripple_sqlite module.
+
+ @file ripple_sqlite.cpp
+ @ingroup ripple_sqlite
+*/
+
+// This prevents sqlite.h from being included
+//
+#define RIPPLE_SQLITE_MODULE_INCLUDED 1
+
+#include "ripple_sqlite.h"
+
+#if BEAST_MSVC
+#pragma warning (push)
+#pragma warning (disable: 4100) /* unreferenced formal parameter */
+#pragma warning (disable: 4127) /* conditional expression is constant */
+#pragma warning (disable: 4232) /* nonstandard extension used: dllimport address */
+#pragma warning (disable: 4244) /* conversion from 'int': possible loss of data */
+#pragma warning (disable: 4701) /* potentially uninitialized variable */
+#pragma warning (disable: 4706) /* assignment within conditional expression */
+#endif
+
+/* When compiled with SQLITE_THREADSAFE=1, SQLite operates in serialized mode.
+ In this mode, SQLite can be safely used by multiple threads with no restriction.
+
+ VFALCO NOTE This implies a global mutex!
+
+ NOTE Windows builds never had the threading model set. However, SQLite
+ defaults to Serialized (SQLITE_THREADSAFE == 1). Does Ripple need
+ Serialized mode? Because Ripple already uses a mutex with every
+ instance of the sqlite database session object.
+*/
+#define SQLITE_THREADSAFE 1
+
+/* When compiled with SQLITE_THREADSAFE=2, SQLite can be used in a
+ multithreaded program so long as no two threads attempt to use the
+ same database connection at the same time.
+
+ VFALCO NOTE This is the preferred threading model.
+
+ TODO Determine if Ripple can support this model.
+*/
+//#define SQLITE_THREADSAFE 2
+
+// VFALCO TODO Move this into Beast
+#define BEAST_PP_STR2_(x) #x
+#define BEAST_PP_STR1_(x) BEAST_PP_STR2_(x)
+#define BEAST_FILEANDLINE_ __FILE__ "("BEAST_PP_STR1_(__LINE__)"): warning:"
+
+// VFALCO TODO We should try running with SQLITE_THREADSAFE==2 and see what happens.
+#if SQLITE_THREADSAFE != 2
+#pragma message(BEAST_FILEANDLINE_"Possible performance issue, SQLITE_THREADSAFE != 2")
+#endif
+
+#include "sqlite/sqlite3.c"
+
+#if BEAST_MSVC
+#pragma warning (pop)
+#endif
diff --git a/modules/ripple_sqlite/ripple_sqlite.h b/modules/ripple_sqlite/ripple_sqlite.h
new file mode 100644
index 0000000000..c5ddd97e48
--- /dev/null
+++ b/modules/ripple_sqlite/ripple_sqlite.h
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+/*
+ Copyright (c) 2011-2013, OpenCoin, Inc.
+*/
+//==============================================================================
+
+/** Include this to get the @ref ripple_sqlite module.
+
+ @file ripple_sqlite.h
+ @ingroup ripple_sqlite
+*/
+
+/** Sqlite3 support.
+
+ This module brings in the Sqlite embedded database engine.
+
+ @defgroup ripple_sqlite
+*/
+
+#ifndef RIPPLE_SQLITE_RIPPLEHEADER
+#define RIPPLE_SQLITE_RIPPLEHEADER
+
+#include "beast/modules/beast_core/system/beast_TargetPlatform.h"
+
+#if ! RIPPLE_SQLITE_MODULE_INCLUDED
+#include "sqlite/sqlite3.h"
+#endif
+
+#endif