Skip to content

Commit 0816b2f

Browse files
committed
[yugabyte#26695] OpenDocDB: Add BSON and BID libraries and build DocumentDB
Summary: Aging BSON and BID libraries to cmake and including the DocumentDB extension in the build. The extension is not available in aarch64 since the BID library is not available in this build type. This is an upstream restriction. Fixes yugabyte#26695 Jira: DB-16070 Test Plan: Jenkins Reviewers: esheng, asrivastava, #db-approvers, slingam Reviewed By: asrivastava, #db-approvers, slingam Subscribers: svc_phabricator, yql, ybase Differential Revision: https://phorge.dev.yugabyte.com/D43114
1 parent 4e4b838 commit 0816b2f

File tree

6 files changed

+82
-5
lines changed

6 files changed

+82
-5
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ else()
298298
message("CMake will not export the compilation database")
299299
endif()
300300

301+
if(NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
302+
set(YB_ENABLE_YSQL_DOCUMENTDB_EXT TRUE)
303+
ADD_CXX_FLAGS("-DYB_ENABLE_YSQL_DOCUMENTDB_EXT")
304+
endif()
305+
301306
# -------------------------------------------------------------------------------------------------
302307
# Build type (debug, release, fastdebug, etc.)
303308
# -------------------------------------------------------------------------------------------------

cmake_modules/FindBid.cmake

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) YugabyteDB, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4+
# in compliance with the License. You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software distributed under the License
9+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
# or implied. See the License for the specific language governing permissions and limitations
11+
# under the License.
12+
#
13+
14+
find_path(BID_INCLUDE_ROOT_DIR bid
15+
# make sure we don't accidentally pick up a different version
16+
NO_CMAKE_SYSTEM_PATH
17+
NO_SYSTEM_ENVIRONMENT_PATH)
18+
set(BID_INCLUDE_DIR "${BID_INCLUDE_ROOT_DIR}/bid")
19+
find_library(BID_STATIC_LIB libbid.a
20+
NO_CMAKE_SYSTEM_PATH
21+
NO_SYSTEM_ENVIRONMENT_PATH)
22+
23+
message(WARNING "BID_INCLUDE_DIR: ${BID_INCLUDE_DIR}")
24+
25+
include(FindPackageHandleStandardArgs)
26+
find_package_handle_standard_args(BID REQUIRED_VARS
27+
BID_STATIC_LIB BID_INCLUDE_DIR)

cmake_modules/FindBson.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) YugabyteDB, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4+
# in compliance with the License. You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software distributed under the License
9+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
# or implied. See the License for the specific language governing permissions and limitations
11+
# under the License.
12+
#
13+
14+
find_path(BSON_INCLUDE_ROOT_DIR libbson-1.0
15+
# make sure we don't accidentally pick up a different version
16+
NO_CMAKE_SYSTEM_PATH
17+
NO_SYSTEM_ENVIRONMENT_PATH)
18+
set(BSON_INCLUDE_DIR "${BSON_INCLUDE_ROOT_DIR}/libbson-1.0")
19+
find_library(BSON_STATIC_LIB libbson-static-1.0.a
20+
NO_CMAKE_SYSTEM_PATH
21+
NO_SYSTEM_ENVIRONMENT_PATH)
22+
23+
include(FindPackageHandleStandardArgs)
24+
find_package_handle_standard_args(BSON REQUIRED_VARS
25+
BSON_STATIC_LIB BSON_INCLUDE_DIR)

cmake_modules/YugabyteFindThirdParty.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,19 @@ macro(yb_find_third_party_dependencies)
410410
ADD_THIRDPARTY_LIB(clockbound
411411
STATIC_LIB ${CLOCKBOUND_STATIC_LIB}
412412
INCLUDE_DIRS ${CLOCKBOUND_INCLUDE_DIR})
413+
414+
## Bson
415+
find_package(Bson REQUIRED)
416+
include_directories(SYSTEM ${BSON_INCLUDE_DIR})
417+
ADD_THIRDPARTY_LIB(bson
418+
STATIC_LIB "${BSON_STATIC_LIB}")
419+
420+
## Bid
421+
if(NOT "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
422+
find_package(Bid REQUIRED)
423+
include_directories(SYSTEM ${BID_INCLUDE_DIR})
424+
ADD_THIRDPARTY_LIB(bid
425+
STATIC_LIB "${BID_STATIC_LIB}")
426+
endif()
427+
413428
endmacro()

src/postgres/third-party-extensions/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ DIRS = \
1212
wal2json \
1313
pgtap \
1414

15+
ifeq ($(YB_ENABLE_YSQL_DOCUMENTDB_EXT),TRUE)
16+
documentdb
17+
endif
18+
1519
BUILDDIRS = $(DIRS:%=build-%)
1620
INSTALLDIRS = $(DIRS:%=install-%)
1721
CLEANDIRS = $(DIRS:%=clean-%)

src/postgres/third-party-extensions/documentdb/Makefile.cflags

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22

3-
LIBBSON := $(shell pkg-config --cflags libbson-static-1.0)
4-
INTEL_DECIMAL_MATH_LIB = $(shell pkg-config --cflags intelmathlib)
3+
# YB: Bson and BID are linked through YugabyteDB thirdparty
4+
# LIBBSON := -pthread -DBSON_STATIC -isystem /usr/local/include/libbson-1.0
5+
# INTEL_DECIMAL_MATH_LIB = $(shell pkg-config --cflags intelmathlib)
56
PCRE2_LIB = $(shell pkg-config --cflags libpcre2-8)
67

78
DOCUMENTDB_CORE_DIR = $(OSS_SRC_DIR)/pg_documentdb_core
@@ -13,7 +14,7 @@ DOCUMENTDB_INC_DIR = $(DOCUMENTDB_DIR)/include
1314
DOCUMENTDB_DISTRIBUTED_INC_DIR = $(DOCUMENTDB_DISTRIBUTED_DIR)/include
1415

1516

16-
PG_CPPFLAGS = $(LIBBSON) -I$(libpq_srcdir) $(INTEL_DECIMAL_MATH_LIB) $(PCRE2_LIB) -Isrc -Iinclude -Ibuild/include/
17+
PG_CPPFLAGS = -I$(libpq_srcdir) $(PCRE2_LIB) -Isrc -Iinclude -Ibuild/include/
1718
PG_LDFLAGS = $(shell pkg-config --static --libs --cflags libbson-static-1.0) $(shell pkg-config --static --libs --cflags intelmathlib) $(shell pkg-config --static --libs --cflags libpcre2-8) -L/usr/lib
1819
PG_LDFLAGS += -Wl,-rpath=$(shell $(PG_CONFIG) --pkglibdir)
1920

@@ -36,9 +37,9 @@ PG_LDFLAGS += -l:pg_documentdb_distributed.so -L $(DOCUMENTDB_DISTRIBUTED_DIR)
3637
endif
3738

3839
ifeq ($(CC),gcc)
39-
PG_CFLAGS = -std=gnu99 -Wall -Wextra -Werror -Wno-declaration-after-statement -Wno-unused-parameter -Wno-implicit-fallthrough $(LIBBSON) $(INTEL_DECIMAL_MATH_LIB) $(PCRE2_LIB)
40+
PG_CFLAGS = -std=gnu99 -Wall -Wextra -Werror -Wno-declaration-after-statement -Wno-unused-parameter -Wno-implicit-fallthrough $(PCRE2_LIB)
4041
else
41-
PG_CFLAGS = -std=gnu99 -Wall -Wextra -Werror -Wno-declaration-after-statement -Wno-unused-parameter -Wno-implicit-fallthrough $(LIBBSON) $(INTEL_DECIMAL_MATH_LIB) $(PCRE2_LIB)
42+
PG_CFLAGS = -std=gnu99 -Wall -Wextra -Werror -Wno-declaration-after-statement -Wno-unused-parameter -Wno-implicit-fallthrough $(PCRE2_LIB)
4243
endif
4344

4445
ifneq ($(SKIP_API_SCHEMA),yes)

0 commit comments

Comments
 (0)