Skip to content
Merged
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
46 changes: 33 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.22)
project(bsonsearch)

set(MONGOC_VERSION "2.2.1")
# Default cmake includes all features and modules
# Optional "lite" version available with only bson and pcre dependencies
# mkdir cmake-build-lite && cd cmake-build-lite
Expand All @@ -16,23 +16,39 @@ project(bsonsearch)

include_directories(
${CMAKE_BINARY_DIR}/usr/include/
${CMAKE_BINARY_DIR}/usr/include/bson-2.1.2
${CMAKE_BINARY_DIR}/usr/include/bson-${MONGOC_VERSION}
lib/
/usr/include/
)
list(APPEND CMAKE_REQUIRED_INCLUDES
${CMAKE_BINARY_DIR}/usr/include/
/opt/homebrew/include/
)
if(EXISTS "/opt/homebrew/include")
message("/opt/homebrew exists, adding it to include path")
list(APPEND CMAKE_REQUIRED_INCLUDES
/opt/homebrew/include/
)
endif()

# RHEL-based systems use lib64
if(EXISTS "/usr/lib64")
message("---- appears to be RHEL-based system")
LINK_DIRECTORIES(
${CMAKE_BINARY_DIR}/usr/lib
${CMAKE_BINARY_DIR}/usr/lib64
/usr/local/lib/
/usr/lib64/
lib/acceleration/
)
else()
LINK_DIRECTORIES(
${CMAKE_BINARY_DIR}/usr/lib
/usr/local/lib/
/usr/local/lib/
lib/acceleration/
)
endif()

LINK_DIRECTORIES(
${CMAKE_BINARY_DIR}/usr/lib
${CMAKE_BINARY_DIR}/usr/lib64
/usr/local/lib/
/usr/lib64/
/usr/local/lib/
lib/acceleration/
)


## SECTION 1 -- COMPILE Checks
Expand All @@ -57,7 +73,7 @@ option(include-text "include-text" OFF)

option(include-ip "include-ip" OFF)
option(include-yara "include-yara" OFF)
option(include-crypt "include-crypt" OFF)
option(include-crypt "include-crypt" ON)

option(include-modules "include-modules" ON)
CMAKE_DEPENDENT_OPTION(include-math "include-math" ON "include-modules" OFF)
Expand All @@ -77,6 +93,10 @@ if (APPLE OR build-dependencies)
message("-- requested dukjs with -D include-dukjs")
add_definitions(-DWITH_DUKJS)
endif()
if (include-crypt)
message("-- requested libsodium with -D include-crypt")
add_definitions(-DWITH_CRYPT)
endif ()
endif()

add_subdirectory(third-party)
Expand All @@ -93,7 +113,7 @@ else()
return()
endif()
message("-- Looking for include file bson.h")
find_path(HAVE_BSON_H bson.h PATHS third-party/usr/include/bson-2.1.2/bson )
find_path(HAVE_BSON_H bson.h PATHS third-party/usr/include/bson-${MONGOC_VERSION}/bson )
if(NOT HAVE_BSON_H)
message(SEND_ERROR "BSON is required, stopping")
return()
Expand Down
2 changes: 1 addition & 1 deletion bsonsearch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ file(COPY "${CMAKE_SOURCE_DIR}/setup.py" DESTINATION "${CMAKE_BINARY_DIR}/")

add_custom_target(pybsonsearch
ALL
COMMAND LIB_DIR=${CMAKE_BINARY_DIR}:${CMAKE_BINARY_DIR}/usr/lib/ INCLUDE_DIR=${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/lib/:${CMAKE_BINARY_DIR}/usr/include/:${CMAKE_BINARY_DIR}/usr/include/bson-2.1.2 ${Python_EXECUTABLE} -m build;
COMMAND LIB_DIR=${CMAKE_BINARY_DIR}:${CMAKE_BINARY_DIR}/usr/lib/ INCLUDE_DIR=${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/lib/:${CMAKE_BINARY_DIR}/usr/include/:${CMAKE_BINARY_DIR}/usr/include/bson-${MONGOC_VERSION} ${Python_EXECUTABLE} -m build;
COMMAND rm -rf bsonsearch
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Making the python library via cmake is a confusing"
Expand Down
11 changes: 11 additions & 0 deletions lib/tests/bsoncompare_projection.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ int
main (int argc,
char *argv[])
{


//test foundin command with deep doc

do {
BSON_ASSERT(test_bson_api("{\"a\": {\"x\": {\"f\":{\"i\": 1}}, \"y\": {\"f\":{\"j\": 2}}, \"z\": {\"f\":{\"k\": 3}}}}",
"{\"$project\":{\"a\":{\"$foundin\":[\"a.$any.f\"]}}}",
"{ \"a\" : [ { \"i\" : 1 }, { \"j\" : 2 }, { \"k\" : 3 } ] }"));
}while(false);//*/


//FIXED: too many embedded dict are failing.
do {
//project follows at least once checking.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "bsonsearch"
version = "2.1.2"
version = "2.2.1"
description = "compare BSON/JSON documents locally"
requires-python = ">=3.11"
dependencies = []
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from os import environ

include_dirs = [
f"/usr/include/bson-{environ.get('BSON_VERSION', '2.1.2')}/",
f"/usr/local/include/bson-{environ.get('BSON_VERSION', '2.1.2')}/",
f"/opt/homebrew/include/bson-{environ.get('BSON_VERSION', '2.1.2')}/",
f"/usr/include/bson-{environ.get('BSON_VERSION', '2.2.1')}/",
f"/usr/local/include/bson-{environ.get('BSON_VERSION', '2.2.1')}/",
f"/opt/homebrew/include/bson-{environ.get('BSON_VERSION', '2.2.1')}/",
"/opt/homebrew/include/",
"/usr/local/"
]
Expand Down
22 changes: 18 additions & 4 deletions third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (APPLE OR build-dependencies)
cmake_policy(SET CMP0135 NEW)
endif()

include_directories(${CMAKE_BINARY_DIR}/ ${CMAKE_BINARY_DIR}/usr/include/ ${CMAKE_BINARY_DIR}/usr/include/bson-2.1.2 /usr/include/ lib/ lib/acceleration/)
include_directories(${CMAKE_BINARY_DIR}/ ${CMAKE_BINARY_DIR}/usr/include/ ${CMAKE_BINARY_DIR}/usr/include/bson-${MONGOC_VERSION} /usr/include/ lib/ lib/acceleration/)
list(APPEND CMAKE_REQUIRED_INCLUDES
${CMAKE_BINARY_DIR}/usr/include/
${CMAKE_BINARY_DIR}/third-party
Expand All @@ -27,11 +27,23 @@ if (APPLE OR build-dependencies)
move_file(${CMAKE_SOURCE_DIR}/third-party/pcre-8.45.tar.gz)
move_file(${CMAKE_SOURCE_DIR}/third-party/duktape-2.7.0.tar.xz)
move_file(${CMAKE_SOURCE_DIR}/third-party/discodb-0.9.5.tar.gz)
move_file(${CMAKE_SOURCE_DIR}/third-party/mongo-c-driver-2.1.2.tar.gz)
move_file(${CMAKE_SOURCE_DIR}/third-party/libsodium-1.0.20.tar.gz)
move_file(${CMAKE_SOURCE_DIR}/third-party/mongo-c-driver-${MONGOC_VERSION}.tar.gz)
file(COPY "${CMAKE_SOURCE_DIR}/third-party/uthash.h" DESTINATION "${CMAKE_BINARY_DIR}/usr/include")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/third-party/discodb_build")


ExternalProject_Add(
ExternalSodium # Name for the external project
URL "file:///${CMAKE_SOURCE_DIR}/third-party/libsodium-1.0.20.tar.gz" # Path to your tarball
URL_HASH "SHA256=ebb65ef6ca439333c2bb41a0c1990587288da07f6c7fd07cb3a18cc18d30ce19"
SOURCE_DIR "${CMAKE_BINARY_DIR}/third-party/sodium_src"
BINARY_DIR "${CMAKE_BINARY_DIR}/third-party/sodium_src"
INSTALL_DIR "${CMAKE_BINARY_DIR}/usr"
CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/usr
BUILD_COMMAND make
INSTALL_COMMAND make install
)

ExternalProject_Add(
ExternalPCRE # Name for the external project
Expand All @@ -43,6 +55,7 @@ if (APPLE OR build-dependencies)
CONFIGURE_COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/usr --enable-utf --enable-jit=auto --enable-pcre32 --enable-pcre16 --enable-pcre8 --disable-cpp --enable-newline-is-anycrlf --with-match-limit=100;
BUILD_COMMAND make
INSTALL_COMMAND make install
DEPENDS ExternalSodium
)


Expand All @@ -57,6 +70,7 @@ if (APPLE OR build-dependencies)
BUILD_COMMAND make -f Makefile.sharedlibrary INSTALL_PREFIX=${CMAKE_BINARY_DIR}/usr
INSTALL_COMMAND make -f Makefile.sharedlibrary INSTALL_PREFIX=${CMAKE_BINARY_DIR}/usr install
BUILD_BYPRODUCTS "${CMAKE_BINARY_DIR}/third-party/usr/libduktape.so"
DEPENDS ExternalSodium
)
add_custom_target(ExternalDuktapeDebuggerFix
COMMAND cp usr/lib/libduktape*.so .;
Expand Down Expand Up @@ -112,8 +126,8 @@ if (APPLE OR build-dependencies)
)
ExternalProject_Add(
mongoccompile # Name for the external project
URL "file:///${CMAKE_SOURCE_DIR}/third-party/mongo-c-driver-2.1.2.tar.gz" # Path to your tarball
URL_HASH "SHA256=faf1666b0447b6108211a5ff74cd354d982edc9d89727cfd651b2ce6ef319531"
URL "file:///${CMAKE_SOURCE_DIR}/third-party/mongo-c-driver-${MONGOC_VERSION}.tar.gz" # Path to your tarball
URL_HASH "SHA256=bc56f9acd91454eca5121e030fc1bb236283a94f4522b749beeb55e5e30343fb"
SOURCE_DIR "${CMAKE_BINARY_DIR}/third-party/mongoc_src"
BINARY_DIR "${CMAKE_BINARY_DIR}/third-party/mongoc_build"
INSTALL_DIR "${CMAKE_BINARY_DIR}/usr"
Expand Down
3 changes: 3 additions & 0 deletions third-party/libsodium-1.0.20.tar.gz
Git LFS file not shown
3 changes: 3 additions & 0 deletions third-party/mongo-c-driver-2.2.0.tar.gz
Git LFS file not shown
3 changes: 3 additions & 0 deletions third-party/mongo-c-driver-2.2.1.tar.gz
Git LFS file not shown
Loading