Skip to content

Commit

Permalink
Merge branch 'main' into interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sitaowang1998 committed Nov 6, 2024
2 parents 0d59c62 + 6e1c7f1 commit 4cd6233
Show file tree
Hide file tree
Showing 24 changed files with 1,482 additions and 358 deletions.
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:jammy

WORKDIR /root

RUN mkdir -p ./tools/scripts/lib_install
COPY ./tools/scripts/lib_install ./tools/scripts/lib_install

RUN ./tools/scripts/lib_install/linux/install-dev.sh

RUN ./tools/scripts/lib_install/linux/install-lib.sh

# NOTE:
# - `task` doesn't have an apt/yum package so we use its install script.
# - We lock task's version since v3.40.0 and higher change the behaviour of how undefined variables
# are treated in `ref` statements, causing yscope-dev-utils' `validate-checksum` task to fail.
RUN sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin v3.39.2

# Remove cached files
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"build": {
"dockerfile": "Dockerfile",
"context": "..",
},
}
7 changes: 5 additions & 2 deletions .github/workflows/code-linting-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
lint:
strategy:
matrix:
os: ["macos-latest", "ubuntu-latest"]
os: ["ubuntu-latest"]
runs-on: "${{matrix.os}}"
steps:
- uses: "actions/checkout@v4"
Expand All @@ -31,8 +31,11 @@ jobs:
with:
python-version: "3.10"

# We lock task's version since v3.40.0 and higher change the behaviour of how undefined
# variables are treated in `ref` statements, causing yscope-dev-utils' `validate-checksum`
# task to fail.
- name: "Install task"
run: "npm install -g @go-task/cli"
run: "npm install -g @go-task/cli@3.39.2"

- if: "matrix.os == 'macos-latest'"
name: "Install coreutils (for md5sum)"
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ if(SPIDER_USE_STATIC_LIBS)
# NOTE: We can't statically link to MariaDBClient since it's GPL
message(AUTHOR_WARNING "MariaDBClient cannot be statically linked due to its license.")
endif()
find_package(MariaDBClient 3.1.0 REQUIRED)
if(MariaDBClient_FOUND)
message(STATUS "Found MariaDBClient ${MariaDBClient_VERSION}")
find_package(MariaDBClientCpp 1.0 REQUIRED)
if(MariaDBClientCpp_FOUND)
message(STATUS "Found MariaDBClientCpp ${MariaDBClientCpp_VERSION}")
else()
message(FATAL_ERROR "Could not find ${SPIDER_LIBS_STRING} libraries for MariaDBClient")
message(FATAL_ERROR "Could not find ${SPIDER_LIBS_STRING} libraries for MariaDBClientCpp")
endif()

# Add abseil-cpp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Follow the steps below to develop and contribute to the project.

## Requirements
* Python 3.10 or higher
* [Task] 3.38.0 or higher
* [Task] >= 3.38.0, < 3.40.0

## Set up
Initialize and update submodules:
Expand Down
123 changes: 0 additions & 123 deletions cmake/Modules/FindMariaDBClient.cmake

This file was deleted.

134 changes: 134 additions & 0 deletions cmake/Modules/FindMariaDBClientCpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Try to find MariaDBClientCpp
#
# Set MariaDBClientCpp_USE_STATIC_LIBS=ON to look for static libraries.
#
# Once done this will define:
# MariaDBClientCpp_FOUND - Whether MariaDBClient was found on the system
# MariaDBClientCpp_INCLUDE_DIR - The MariaDBClient include directories
# MariaDBClientCpp_VERSION - The version of MariaDBClient installed on the system
#
# Conventions:
# - Variables only for use within the script are prefixed with "mariadbclientcpp_"
# - Variables that should be externally visible are prefixed with "MariaDBClientCpp_"

set(mariadbclientcpp_LIBNAME "mariadbcpp")

include(cmake/Modules/FindLibraryDependencies.cmake)

# Run pkg-config
find_package(PkgConfig)
pkg_check_modules(mariadbclientcpp_PKGCONF QUIET "lib${mariadbclientcpp_LIBNAME}")

# Set include directory
find_path(
MariaDBClientCpp_INCLUDE_DIR
conncpp.hpp
HINTS
${mariadbclientcpp_PKGCONF_INCLUDEDIR}
PATH_SUFFIXES
mariadb
)

# Handle static libraries
if(MariaDBClientCpp_USE_STATIC_LIBS)
# Save current value of CMAKE_FIND_LIBRARY_SUFFIXES
set(mariadbclientcpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})

# Temporarily change CMAKE_FIND_LIBRARY_SUFFIXES to static library suffix
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
else()
# mariadb-connector-cpp uses .dylib for dynamic library, at least on macOS
set(mariadbclientcpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES
.so
.dylib
)
endif()

# Find library
find_library(
MariaDBClientCpp_LIBRARY
NAMES
${mariadbclientcpp_LIBNAME}
HINTS
${mariadbclientcpp_PKGCONF_LIBDIR}
PATH_SUFFIXES
mariadb
)
if(MariaDBClientCpp_LIBRARY)
# NOTE: This must be set for find_package_handle_standard_args to work
set(MariaDBClientCpp_FOUND ON)
endif()

if(MariaDBClientCpp_USE_STATIC_LIBS)
findstaticlibrarydependencies(${mariadbclientcpp_LIBNAME} mariadbclientcpp
"${mariadbclientcpp_PKGCONF_STATIC_LIBRARIES}"
)

# Restore original value of CMAKE_FIND_LIBRARY_SUFFIXES
set(CMAKE_FIND_LIBRARY_SUFFIXES ${mariadbclientcpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
unset(mariadbclientcpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${mariadbclientcpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
unset(mariadbclientcpp_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
endif()

finddynamiclibrarydependencies(mariadbclientcpp "${mariadbclientcpp_DYNAMIC_LIBS}")

# Set version
set(MariaDBClientCpp_VERSION ${mariadbclientcpp_PKGCONF_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
MariaDBClientCpp
REQUIRED_VARS
MariaDBClientCpp_INCLUDE_DIR
VERSION_VAR MariaDBClientCpp_VERSION
)

if(NOT TARGET MariaDBClientCpp::MariaDBClientCpp)
# Add library to build
if(MariaDBClientCpp_FOUND)
if(MariaDBClientCpp_USE_STATIC_LIBS)
add_library(MariaDBClientCpp::MariaDBClientCpp STATIC IMPORTED GLOBAL)
else()
# NOTE: We use UNKNOWN so that if the user doesn't have the SHARED
# libraries installed, we can still use the STATIC libraries
add_library(MariaDBClientCpp::MariaDBClientCpp UNKNOWN IMPORTED GLOBAL)
endif()
endif()

# Set include directories for library
if(MariaDBClientCpp_INCLUDE_DIR)
set_target_properties(
MariaDBClientCpp::MariaDBClientCpp
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${MariaDBClientCpp_INCLUDE_DIR}"
"${MariaDBClientCpp_INCLUDE_DIR}/conncpp"
"${MariaDBClientCpp_INCLUDE_DIR}/conncpp/compat"
)
endif()

# Set location of library
if(EXISTS "${MariaDBClientCpp_LIBRARY}")
set_target_properties(
MariaDBClientCpp::MariaDBClientCpp
PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES
"CXX"
IMPORTED_LOCATION
"${MariaDBClientCpp_LIBRARY}"
)

# Add component's dependencies for linking
if(mariadbclientcpp_LIBRARY_DEPENDENCIES)
set_target_properties(
MariaDBClientCpp::MariaDBClientCpp
PROPERTIES
INTERFACE_LINK_LIBRARIES
"${mariadbclientcpp_LIBRARY_DEPENDENCIES}"
)
endif()
endif()
endif()
4 changes: 2 additions & 2 deletions dep-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ tasks:
lib_install_mac:
internal: true
platforms: ["darwin"]
dir: "{{.G_SCRIPT_DIR}}/macOS"
dir: "{{.G_SCRIPT_DIR}}/lib_install/macOS"
cmds:
- "./install-lib.sh"

lib_install_linux:
internal: true
platforms: ["linux"]
dir: "{{.G_SCRIPT_DIR}}/linux"
dir: "{{.G_SCRIPT_DIR}}/lib_install/linux"
cmds:
- "./install-lib.sh"
1 change: 1 addition & 0 deletions src/spider/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ target_link_libraries(
Boost::boost
absl::flat_hash_map
)
target_link_libraries(spider_core PRIVATE fmt::fmt)

set(SPIDER_CLIENT_SHARED_SOURCES
client/Data.cpp
Expand Down
Loading

0 comments on commit 4cd6233

Please sign in to comment.