diff --git a/CMakeLists.txt b/CMakeLists.txt index 813cbc12596f4a1b2568aa8a8aa78111530aa04a..3ea2de8a737e457da92bd388657a901c5d6b779f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,9 +335,15 @@ add_dependencies(build_bundled_libs cjson) # LibYAML # -include(BuildLibYAML) -libyaml_build() -add_dependencies(build_bundled_libs yaml) +option(ENABLE_BUNDLED_LIBYAML "Enable building of the bundled libyaml" ON) +if (ENABLE_BUNDLED_LIBYAML) + include(BuildLibYAML) + libyaml_build() + add_dependencies(build_bundled_libs yaml) +else() + set(LIBYAML_FIND_REQUIRED ON) + find_package(LibYAML) +endif() # # Third-Party misc @@ -412,6 +418,7 @@ message (STATUS "ENABLE_BUNDLED_LUAJIT: ${ENABLE_BUNDLED_LUAJIT}") message (STATUS "ENABLE_BUNDLED_LIBEV: ${ENABLE_BUNDLED_LIBEV}") message (STATUS "ENABLE_BUNDLED_LIBEIO: ${ENABLE_BUNDLED_LIBEIO}") message (STATUS "ENABLE_BUNDLED_LIBCORO: ${ENABLE_BUNDLED_LIBCORO}") +message (STATUS "ENABLE_BUNDLED_LIBYAML: ${ENABLE_BUNDLED_LIBYAML}") message (STATUS "ENABLE_DOC: ${ENABLE_DOC}") list_optional_packages() if (TARGET_OS_DARWIN) diff --git a/cmake/BuildLibYAML.cmake b/cmake/BuildLibYAML.cmake index bca7910d7a29ac95ff7dea2b44219ec0ccac80b7..b6d6685d89c85aa910420b01ae0547671381b719 100644 --- a/cmake/BuildLibYAML.cmake +++ b/cmake/BuildLibYAML.cmake @@ -1,31 +1,25 @@ # -# A macro to build the bundled liblua-yaml +# A macro to build the bundled libyaml macro(libyaml_build) - set(yaml_src ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/lyaml.cc - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/api.c - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/dumper.c - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/emitter.c - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/loader.c - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/parser.c - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/reader.c - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/scanner.c - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/writer.c - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/b64.c) - - set_source_files_properties(${yaml_src} PROPERTIES COMPILE_FLAGS - "-std=c99 -I\"${PROJECT_SOURCE_DIR}/third_party/lua-yaml\"") - set_source_files_properties( - ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/lyaml.cc - PROPERTIES COMPILE_FLAGS - "-std=gnu++0x -D__STDC_FORMAT_MACROS=1 -D__STDC_LIMIT_MACROS=1") + set(yaml_src ${PROJECT_SOURCE_DIR}/third_party/libyaml/api.c + ${PROJECT_SOURCE_DIR}/third_party/libyaml/dumper.c + ${PROJECT_SOURCE_DIR}/third_party/libyaml/emitter.c + ${PROJECT_SOURCE_DIR}/third_party/libyaml/loader.c + ${PROJECT_SOURCE_DIR}/third_party/libyaml/parser.c + ${PROJECT_SOURCE_DIR}/third_party/libyaml/reader.c + ${PROJECT_SOURCE_DIR}/third_party/libyaml/scanner.c + ${PROJECT_SOURCE_DIR}/third_party/libyaml/writer.c) add_library(yaml STATIC ${yaml_src}) - set(LIBYAML_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/third_party/lua-yaml) + set(LIBYAML_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/third_party/libyaml) set(LIBYAML_LIBRARIES yaml) - message(STATUS "Use bundled Lua-YAML library: ${LIBYAML_LIBRARIES}") + # A workaround for config.h + set_target_properties(yaml PROPERTIES COMPILE_DEFINITIONS "HAVE_CONFIG_H") + include_directories(${LIBYAML_INCLUDE_DIR}) - unset(lua_yaml_src) + message(STATUS "Use bundled libyaml library") + unset(yaml_src) endmacro(libyaml_build) diff --git a/cmake/FindLibYAML.cmake b/cmake/FindLibYAML.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8abe5f9f0ec95cf217f1e09b1402e65486ab74d1 --- /dev/null +++ b/cmake/FindLibYAML.cmake @@ -0,0 +1,17 @@ +find_path(LIBYAML_INCLUDE_DIR + NAMES yaml.h +) + +find_library(LIBYAML_LIBRARY + NAMES yaml +) + +set(LIBYAML_INCLUDE_DIRS "${LIBYAML_INCLUDE_DIR}") +set(LIBYAML_LIBRARIES "${LIBYAML_LIBRARY}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibYAML REQUIRED_VARS + LIBYAML_LIBRARIES LIBYAML_INCLUDE_DIRS) + +mark_as_advanced(LIBYAML_LIBRARY LIBYAML_LIBRARIES + LIBYAML_INCLUDE_DIR LIBYAML_INCLUDE_DIRS) diff --git a/debian/control b/debian/control index 8517437e047811cb63ca82352461e9f0a32425fe..e7c54e0dbc45595598348c8c6b3d7025bf9bcaa0 100644 --- a/debian/control +++ b/debian/control @@ -7,6 +7,7 @@ Build-Depends: cdbs, debhelper (>= 8), cmake, libreadline-dev, libncurses5-dev, + libyaml-dev, libiberty-dev | binutils-dev, libbfd-dev | binutils-dev Section: database @@ -47,7 +48,7 @@ Description: Tarantool in-memory database - common files Package: tarantool Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 Priority: optional -Depends: ${shlibs:Depends}, ${misc:Depends}, binutils, libgomp1 +Depends: ${shlibs:Depends}, ${misc:Depends}, binutils, libgomp1, libyaml-0-2 Replaces: tarantool-lts Conflicts: tarantool-lts-common, tarantool-lts, diff --git a/debian/copyright b/debian/copyright index ed0b59d5d102672f42726ab11d52c187b3c0e192..88dbc12b5f5ae57ba86469cc3e5c904710d48971 100644 --- a/debian/copyright +++ b/debian/copyright @@ -350,11 +350,11 @@ License: Public-Domain This is a portable ANSI C implementation of MurmurHash3_x86_32 (Murmur3A) with support for progressive processing. -Files: third_party/lua-yaml/* +Files: third_party/libyaml/* Copyright: 2006, Kirill Simonov <xi@resolvent.net> License: Expat -Files: third_party/lua-yaml/lyaml.cc +Files: third_party/lua-yaml/* Copyright: 2009, Andrew Danforth <acd@weirdness.net> License: Expat diff --git a/debian/rules b/debian/rules index 31f85824de00a4b582664354081154963eec380a..2af3f1c2ca644785b6dd92aa2d70f6b52ced6859 100755 --- a/debian/rules +++ b/debian/rules @@ -15,7 +15,8 @@ DEB_CMAKE_NORMAL_ARGS := -DCMAKE_INSTALL_PREFIX="$(DEB_CMAKE_INSTALL_PREFIX)" \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DCMAKE_INSTALL_SYSCONFDIR=/etc \ -DCMAKE_INSTALL_LOCALSTATEDIR=/var \ - -DCMAKE_INSTALL_LIBDIR=/usr/lib + -DCMAKE_INSTALL_LIBDIR=/usr/lib \ + -DENABLE_BUNDLED_LIBYAML=OFF # -DCMAKE_C_FLAGS="$(CFLAGS)" \ # -DCMAKE_LD_FLAGS="$(LDFLAGS)" \ # -DENABLE_STATIC=ON diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1275dc8395e2e52d1d4cfd919115436bff39a639..9eb1305d99fbca7d93c864de74e546c57ca3e4ea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -113,6 +113,8 @@ set (server_sources lua/fio.cc lua/clock.c ${lua_sources} + ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/lyaml.cc + ${PROJECT_SOURCE_DIR}/third_party/lua-yaml/b64.c ) set(api_headers diff --git a/third_party/libyaml/LICENSE b/third_party/libyaml/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..050ced23f688452a6333a44de9b7cae80ec494d5 --- /dev/null +++ b/third_party/libyaml/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2006 Kirill Simonov + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third_party/lua-yaml/README.LibYAML b/third_party/libyaml/README similarity index 94% rename from third_party/lua-yaml/README.LibYAML rename to third_party/libyaml/README index a762f97ce833b9b80dc18cdec23716d29ffe6cc3..d35ebcc99b4f8fc838bf4cce27f0144a25657206 100644 --- a/third_party/lua-yaml/README.LibYAML +++ b/third_party/libyaml/README @@ -1,7 +1,5 @@ LibYAML - A C library for parsing and emitting YAML. -The project is in an early stage of development. - To build and install the library, run: $ ./configure $ make diff --git a/third_party/lua-yaml/api.c b/third_party/libyaml/api.c similarity index 100% rename from third_party/lua-yaml/api.c rename to third_party/libyaml/api.c diff --git a/third_party/libyaml/config.h b/third_party/libyaml/config.h new file mode 100644 index 0000000000000000000000000000000000000000..2459f4928f9a8b5e4e621b0f4f954fa58d2cb5cb --- /dev/null +++ b/third_party/libyaml/config.h @@ -0,0 +1,4 @@ +#define YAML_VERSION_MAJOR 0 +#define YAML_VERSION_MINOR 1 +#define YAML_VERSION_PATCH 6 +#define YAML_VERSION_STRING "0.1.6" diff --git a/third_party/lua-yaml/dumper.c b/third_party/libyaml/dumper.c similarity index 100% rename from third_party/lua-yaml/dumper.c rename to third_party/libyaml/dumper.c diff --git a/third_party/lua-yaml/emitter.c b/third_party/libyaml/emitter.c similarity index 100% rename from third_party/lua-yaml/emitter.c rename to third_party/libyaml/emitter.c diff --git a/third_party/lua-yaml/loader.c b/third_party/libyaml/loader.c similarity index 100% rename from third_party/lua-yaml/loader.c rename to third_party/libyaml/loader.c diff --git a/third_party/lua-yaml/parser.c b/third_party/libyaml/parser.c similarity index 100% rename from third_party/lua-yaml/parser.c rename to third_party/libyaml/parser.c diff --git a/third_party/lua-yaml/reader.c b/third_party/libyaml/reader.c similarity index 100% rename from third_party/lua-yaml/reader.c rename to third_party/libyaml/reader.c diff --git a/third_party/lua-yaml/scanner.c b/third_party/libyaml/scanner.c similarity index 99% rename from third_party/lua-yaml/scanner.c rename to third_party/libyaml/scanner.c index 88d4fa5df24cb68f752135978f5f17e7e68810a1..5ec0be086d27a8f175ffecd28239118aca100580 100644 --- a/third_party/lua-yaml/scanner.c +++ b/third_party/libyaml/scanner.c @@ -1105,13 +1105,6 @@ yaml_parser_save_simple_key(yaml_parser_t *parser) int required = (!parser->flow_level && parser->indent == (ptrdiff_t)parser->mark.column); - /* - * A simple key is required only when it is the first token in the current - * line. Therefore it is always allowed. But we add a check anyway. - */ - - assert(parser->simple_key_allowed || !required); /* Impossible. */ - /* * If the current position may start a simple key, save it. */ diff --git a/third_party/lua-yaml/writer.c b/third_party/libyaml/writer.c similarity index 100% rename from third_party/lua-yaml/writer.c rename to third_party/libyaml/writer.c diff --git a/third_party/lua-yaml/yaml.h b/third_party/libyaml/yaml.h similarity index 99% rename from third_party/lua-yaml/yaml.h rename to third_party/libyaml/yaml.h index 9990682535c0ddb01e6133add32f10d2877efad9..5a04d36d4158a0ae8483a693ab42cb169ff45c5b 100644 --- a/third_party/lua-yaml/yaml.h +++ b/third_party/libyaml/yaml.h @@ -26,7 +26,7 @@ extern "C" { /** The public API declaration. */ -#ifdef WIN32 +#ifdef _WIN32 # if defined(YAML_DECLARE_STATIC) # define YAML_DECLARE(type) type # elif defined(YAML_DECLARE_EXPORT) @@ -165,9 +165,6 @@ typedef enum yaml_scalar_style_e { /** Let the emitter choose the style. */ YAML_ANY_SCALAR_STYLE, - /** The verbatim scalar style. */ - YAML_VERBATIM_SCALAR_STYLE, - /** The plain scalar style. */ YAML_PLAIN_SCALAR_STYLE, diff --git a/third_party/lua-yaml/yaml_private.h b/third_party/libyaml/yaml_private.h similarity index 99% rename from third_party/lua-yaml/yaml_private.h rename to third_party/libyaml/yaml_private.h index f4e790423ec03b4c23118907448ebbc16c29dfcd..f0e10010242a59f6e9c2e7d8ceca0fd198786bd4 100644 --- a/third_party/lua-yaml/yaml_private.h +++ b/third_party/libyaml/yaml_private.h @@ -1,7 +1,3 @@ -#define YAML_VERSION_MAJOR 0 -#define YAML_VERSION_MINOR 1 -#define YAML_VERSION_PATCH 6 -#define YAML_VERSION_STRING "0.1.6" #if HAVE_CONFIG_H #include <config.h> @@ -246,9 +242,9 @@ yaml_string_join( (string).pointer[offset] <= (yaml_char_t) 'f') ? \ ((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \ ((string).pointer[offset] - (yaml_char_t) '0')) - + #define AS_HEX(string) AS_HEX_AT((string),0) - + /* * Check if the character is ASCII. */ diff --git a/third_party/lua-yaml/lyaml.cc b/third_party/lua-yaml/lyaml.cc index ac7f59b0ab81c9dc82e791f30d042b35c7735220..812f805d72dc104a411f23fba28513f683edddba 100644 --- a/third_party/lua-yaml/lyaml.cc +++ b/third_party/lua-yaml/lyaml.cc @@ -673,6 +673,10 @@ static yaml_scalar_style_t analyze_string(struct lua_yaml_dumper *dumper, else if (allowSingleQuoted) return YAML_SINGLE_QUOTED_SCALAR_STYLE; return YAML_DOUBLE_QUOTED_SCALAR_STYLE; + + /* TODO: Probably causes https://github.com/tarantool/tarantool/issues/354 */ + (void) flowIndicators; + (void) lineBreaks; } static int dump_node(struct lua_yaml_dumper *dumper) @@ -681,7 +685,7 @@ static int dump_node(struct lua_yaml_dumper *dumper) const char *str = NULL; yaml_char_t *tag = NULL; yaml_event_t ev; - yaml_event_t *evp; + //yaml_event_t *evp; yaml_scalar_style_t style = YAML_PLAIN_SCALAR_STYLE; int is_binary = 0; char buf[FPCONV_G_FMT_BUFSIZE];