[Tarantool-patches] [PATCH v2 1/4] refactoring: extract mpstream into a separate library
Serge Petrenko
sergepetrenko at tarantool.org
Fri Apr 10 02:50:39 MSK 2020
mpstream is part of core library, which, since the introduction of
messagepack extension types, leads to circular dependencies between core
and any other library having extension type encoding/decoding methods
(e.g. uuid library which will soon be expanded with such methods).
Prerequisite #4268
---
src/CMakeLists.txt | 2 +-
src/box/CMakeLists.txt | 2 +-
src/box/lua/call.c | 2 +-
src/box/lua/misc.cc | 2 +-
src/box/lua/net_box.c | 2 +-
src/box/lua/tuple.c | 2 +-
src/box/sql.c | 3 +--
src/box/sql/func.c | 2 +-
src/box/sql/vdbe.c | 2 +-
src/box/sql/vdbemem.c | 2 +-
src/box/xrow.c | 2 +-
src/lib/CMakeLists.txt | 1 +
src/lib/core/CMakeLists.txt | 1 -
src/lib/mpstream/CMakeLists.txt | 2 ++
src/lib/{core => mpstream}/mpstream.c | 2 +-
src/lib/{core => mpstream}/mpstream.h | 0
src/lib/msgpuck | 2 +-
src/lua/msgpack.c | 2 +-
18 files changed, 17 insertions(+), 16 deletions(-)
create mode 100644 src/lib/mpstream/CMakeLists.txt
rename src/lib/{core => mpstream}/mpstream.c (99%)
rename src/lib/{core => mpstream}/mpstream.h (100%)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7d865472d..de9680bcc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -170,7 +170,7 @@ set_source_files_compile_flags(${server_sources})
add_library(server STATIC ${server_sources})
add_dependencies(server build_bundled_libs)
target_link_libraries(server core coll http_parser bit uri uuid swim swim_udp
- swim_ev crypto)
+ swim_ev crypto mpstream)
# Rule of thumb: if exporting a symbol from a static library, list the
# library here.
diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt
index 56758bd2f..6688303a9 100644
--- a/src/box/CMakeLists.txt
+++ b/src/box/CMakeLists.txt
@@ -34,7 +34,7 @@ target_link_libraries(vclock core)
add_library(xrow STATIC xrow.c iproto_constants.c)
target_link_libraries(xrow server core small vclock misc box_error
- scramble ${MSGPUCK_LIBRARIES})
+ scramble mpstream ${MSGPUCK_LIBRARIES})
add_library(tuple STATIC
tuple.c
diff --git a/src/box/lua/call.c b/src/box/lua/call.c
index 5d3579eff..1d294948c 100644
--- a/src/box/lua/call.c
+++ b/src/box/lua/call.c
@@ -45,7 +45,7 @@
#include "box/lua/tuple.h"
#include "small/obuf.h"
#include "trivia/util.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
/**
* A helper to find a Lua function by name and put it
diff --git a/src/box/lua/misc.cc b/src/box/lua/misc.cc
index 79b6cfe3a..4348dcbb2 100644
--- a/src/box/lua/misc.cc
+++ b/src/box/lua/misc.cc
@@ -40,7 +40,7 @@
#include "box/tuple.h"
#include "box/tuple_format.h"
#include "box/lua/tuple.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
static uint32_t CTID_STRUCT_TUPLE_FORMAT_PTR;
diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c
index c7bd016c3..0b6c362ae 100644
--- a/src/box/lua/net_box.c
+++ b/src/box/lua/net_box.c
@@ -47,7 +47,7 @@
#include "coio.h"
#include "box/errcode.h"
#include "lua/fiber.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
#include "misc.h" /* lbox_check_tuple_format() */
#define cfg luaL_msgpack_default
diff --git a/src/box/lua/tuple.c b/src/box/lua/tuple.c
index 1e3c3d65c..4b0701edf 100644
--- a/src/box/lua/tuple.c
+++ b/src/box/lua/tuple.c
@@ -42,7 +42,7 @@
#include "box/tuple_convert.h"
#include "box/errcode.h"
#include "json/json.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
/** {{{ box.tuple Lua library
*
diff --git a/src/box/sql.c b/src/box/sql.c
index 1256df856..fa41b4517 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -35,7 +35,6 @@
#include "sql/sqlInt.h"
#include "sql/tarantoolInt.h"
#include "sql/vdbeInt.h"
-#include "mpstream.h"
#include "index.h"
#include "info/info.h"
@@ -53,7 +52,7 @@
#include "xrow.h"
#include "iproto_constants.h"
#include "fk_constraint.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
#include "sql_stmt_cache.h"
static sql *db = NULL;
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index 6e724c824..e3a6e8875 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -51,7 +51,7 @@
#include "box/tuple.h"
#include "lua/msgpack.h"
#include "lua/utils.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
/*
* Return the collating function associated with a function.
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index e8a029a8a..1296dbbbe 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -50,7 +50,7 @@
#include "tarantoolInt.h"
#include "msgpuck/msgpuck.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
#include "box/schema.h"
#include "box/space.h"
diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c
index aad030df9..18fe958a2 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -41,7 +41,7 @@
#include "tarantoolInt.h"
#include "box/schema.h"
#include "box/tuple.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
#ifdef SQL_DEBUG
/*
diff --git a/src/box/xrow.c b/src/box/xrow.c
index be026a43c..a494d1f46 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -42,7 +42,7 @@
#include "vclock.h"
#include "scramble.h"
#include "iproto_constants.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
static_assert(IPROTO_DATA < 0x7f && IPROTO_METADATA < 0x7f &&
IPROTO_SQL_INFO < 0x7f, "encoded IPROTO_BODY keys must fit into "\
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index b306634e7..61b87fb9e 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -12,6 +12,7 @@ add_subdirectory(uuid)
add_subdirectory(coll)
add_subdirectory(crypto)
add_subdirectory(swim)
+add_subdirectory(mpstream)
if(ENABLE_BUNDLED_MSGPUCK)
add_subdirectory(msgpuck EXCLUDE_FROM_ALL)
endif()
diff --git a/src/lib/core/CMakeLists.txt b/src/lib/core/CMakeLists.txt
index 3f13ff904..13ed1e7ab 100644
--- a/src/lib/core/CMakeLists.txt
+++ b/src/lib/core/CMakeLists.txt
@@ -25,7 +25,6 @@ set(core_sources
util.c
random.c
trigger.cc
- mpstream.c
port.c
decimal.c
mp_decimal.c
diff --git a/src/lib/mpstream/CMakeLists.txt b/src/lib/mpstream/CMakeLists.txt
new file mode 100644
index 000000000..60ed20030
--- /dev/null
+++ b/src/lib/mpstream/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(mpstream STATIC mpstream.c)
+target_link_libraries(mpstream core uuid ${MSGPUCK_LIBRARIES})
diff --git a/src/lib/core/mpstream.c b/src/lib/mpstream/mpstream.c
similarity index 99%
rename from src/lib/core/mpstream.c
rename to src/lib/mpstream/mpstream.c
index 2be1797d0..a737212c1 100644
--- a/src/lib/core/mpstream.c
+++ b/src/lib/mpstream/mpstream.c
@@ -33,7 +33,7 @@
#include <assert.h>
#include <stdint.h>
#include "msgpuck.h"
-#include "mp_decimal.h"
+#include "core/mp_decimal.h"
void
mpstream_reserve_slow(struct mpstream *stream, size_t size)
diff --git a/src/lib/core/mpstream.h b/src/lib/mpstream/mpstream.h
similarity index 100%
rename from src/lib/core/mpstream.h
rename to src/lib/mpstream/mpstream.h
diff --git a/src/lib/msgpuck b/src/lib/msgpuck
index 8ae606a16..e476ad192 160000
--- a/src/lib/msgpuck
+++ b/src/lib/msgpuck
@@ -1 +1 @@
-Subproject commit 8ae606a1636dd89b2d61b154e5a1db03dce91657
+Subproject commit e476ad19281b29d2ee3e11e74c564c0eceea37d5
diff --git a/src/lua/msgpack.c b/src/lua/msgpack.c
index edbc15b72..73ed3ece6 100644
--- a/src/lua/msgpack.c
+++ b/src/lua/msgpack.c
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
#include "lua/msgpack.h"
-#include "mpstream.h"
+#include "mpstream/mpstream.h"
#include "lua/utils.h"
#if defined(LUAJIT)
--
2.21.1 (Apple Git-122.3)
More information about the Tarantool-patches
mailing list