Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql support [DO NOT MERGE] #442

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Builds/CMake/FindMySQL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# - Find MySQL
find_path(MYSQL_INCLUDE_DIR
NAMES mysql.h
PATHS
/usr/include/mysql
/usr/local/include/mysql
/opt/mysql/mysql/include
DOC "MySQL include directory"
)

find_library(MYSQL_LIBRARY
NAMES mysqlclient
PATHS
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/mysql
/usr/local/lib/mysql
/opt/mysql/mysql/lib
DOC "MySQL client library"
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MySQL
REQUIRED_VARS
MYSQL_LIBRARY
MYSQL_INCLUDE_DIR
)

if(MYSQL_FOUND)
set(MYSQL_INCLUDE_DIRS ${MYSQL_INCLUDE_DIR})
set(MYSQL_LIBRARIES ${MYSQL_LIBRARY})

# Create an imported target
if(NOT TARGET MySQL::MySQL)
add_library(MySQL::MySQL UNKNOWN IMPORTED)
set_target_properties(MySQL::MySQL PROPERTIES
IMPORTED_LOCATION "${MYSQL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MYSQL_INCLUDE_DIR}"
)
endif()

mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARY)
else()
message(FATAL_ERROR "Could not find MySQL development files")
endif()

message(STATUS "Using MySQL include dir: ${MYSQL_INCLUDE_DIR}")
message(STATUS "Using MySQL library: ${MYSQL_LIBRARY}")
1 change: 1 addition & 0 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ target_sources (rippled PRIVATE
#]===============================]
src/ripple/nodestore/backend/CassandraFactory.cpp
src/ripple/nodestore/backend/RWDBFactory.cpp
src/ripple/nodestore/backend/MySQLFactory.cpp
src/ripple/nodestore/backend/MemoryFactory.cpp
src/ripple/nodestore/backend/FlatmapFactory.cpp
src/ripple/nodestore/backend/NuDBFactory.cpp
Expand Down
56 changes: 56 additions & 0 deletions Builds/CMake/deps/MySQL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#[===================================================================[
dep: MySQL
MySQL client library integration for rippled (static linking)
#]===================================================================]
# Create an IMPORTED target for MySQL
add_library(mysql_client UNKNOWN IMPORTED)

# Find MySQL client library and headers
find_path(MYSQL_INCLUDE_DIR
NAMES mysql.h
PATHS
/usr/include/mysql
/usr/local/include/mysql
/opt/mysql/mysql/include
DOC "MySQL include directory"
)

# Modified to specifically look for static library
find_library(MYSQL_LIBRARY
NAMES libmysqlclient.a mysqlclient.a # Look for static libraries first
PATHS
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/mysql
/usr/local/lib/mysql
/opt/mysql/mysql/lib
DOC "MySQL client static library"
NO_DEFAULT_PATH # Prevents finding dynamic library first
)

# Set properties on the imported target
if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
set_target_properties(mysql_client PROPERTIES
IMPORTED_LOCATION "${MYSQL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MYSQL_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" # Added for static linking
IMPORTED_LINK_INTERFACE_MULTIPLICITY "1" # Added for static linking
)
message(STATUS "Found MySQL include dir: ${MYSQL_INCLUDE_DIR}")
message(STATUS "Found MySQL library: ${MYSQL_LIBRARY}")
else()
message(FATAL_ERROR "Could not find MySQL static development files. Please install libmysqlclient-dev")
endif()

# Add MySQL backend source to rippled sources
list(APPEND rippled_src
src/ripple/nodestore/backend/MySQLBackend.cpp)

# Link MySQL to rippled
target_link_libraries(ripple_libs
INTERFACE
mysql_client
)

# Create an alias target for consistency with other deps
add_library(deps::mysql ALIAS mysql_client)
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ include(deps/gRPC)
include(deps/cassandra)
include(deps/Postgres)
include(deps/WasmEdge)
include(deps/MySQL)

###

Expand Down
9 changes: 8 additions & 1 deletion build-full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ fi
mkdir .nih_c;
mkdir .nih_toolchain;
cd .nih_toolchain &&
yum install -y wget lz4 lz4-devel git llvm13-static.x86_64 llvm13-devel.x86_64 devtoolset-10-binutils zlib-static ncurses-static -y \
(cat > /etc/yum.repos.d/MariaDB.repo << EOF
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF ) &&
yum install -y wget lz4 lz4-devel git llvm13-static.x86_64 llvm13-devel.x86_64 devtoolset-10-binutils zlib-static ncurses-static MariaDB-devel MariaDB-shared -y \
devtoolset-7-gcc-c++ \
devtoolset-9-gcc-c++ \
devtoolset-10-gcc-c++ \
Expand Down
Loading
Loading