Make sure to have cloned the SDK repository and have the submodules appropriately synced (git submodule update --init --recursive
).
The C++ core utilizes the CMake Package Manager (CPM) to include depencies. These can be set to a cache directory and can be used for future builds. Periodically the dependencies should be updated. So, in general it is good practice to configure the build environment by setting the CPM cache.
npm run prebuild -- --configure --set-cpm-cache --use-boringssl
Note: Section under construction
Set the cache directory CXXCBC_CACHE_DIR
:
export CXXCBC_CACHE_DIR=$PWD/deps/couchbase-cxx-cache
Remove the cache directory
rm -rf $CXXCBC_CACHE_DIR
Configure the build:
$ npx cmake-js configure \
--runtime node \
--runtime-version $(node --version) \
--CDUSE_STATIC_OPENSSL=OFF \
--CDCPM_DOWNLOAD_ALL=OFF \
--CDCPM_USE_NAMED_CACHE_DIRECTORIES=ON \
--CDCPM_USE_LOCAL_PACKAGES=OFF \
--CDCPM_SOURCE_CACHE=$CXXCBC_CACHE_DIR
npm run prebuild -- --use-boringssl
Note: Section under construction
NOTE: If using the
compile
command, the build will automatically clean and re-execute a build upon a failure. Use thebuild
command to only attempt a single build.
Set the cache directory (if it has not already been set) CXXCBC_CACHE_DIR
:
export CXXCBC_CACHE_DIR=$PWD/deps/couchbase-cxx-cache
npx cmake-js compile \
--runtime node \
--runtime-version $(node --version) \
--CDUSE_STATIC_OPENSSL=OFF \
--CDCPM_DOWNLOAD_ALL=OFF \
--CDCPM_USE_NAMED_CACHE_DIRECTORIES=ON \
--CDCPM_USE_LOCAL_PACKAGES=OFF \
--CDCPM_SOURCE_CACHE=$CXXCBC_CACHE_DIR
IMPORTANT: Autogen is only needed for maintainers of the library. If not making updates to the core bindings, running the autogen tooling should NOT be required.
Move into the tools
directory prior to running any autogen commands.
NOTE: Python >= 3.9 required
Setup virtual env:
python3 -m venv <path to virtualenv>
Example: python3 -m venv $(pwd)/couchnode
Activate virtual env:
source <path to virtualenv>/bin/activate
Example: source $(pwd)/couchnode/bin/activate
Install clang
from PyPI:
python3 -m pip install clang
Generate bindings.json
. If no arguments are passed in the binding generator will attempt to determine the necessary version, lib directory, include directory and system headers directory.
python3 gen-bindings-json.py
Alternatively, options can be provided (or ENV variables may be set):
python gen-bindings-json.py -v $(llvm-config --version) \
-i $(llvm-config --includedir) \
-l $(llvm-config --libdir) \
-s $(xcrun --show-sdk-path)
Available Environment Variables:
CN_LLVM_VERSION
: LLVM versionCN_LLVM_INCLUDE
: LLVM include directory pathCN_LLVM_LIB
: LLVM lib directory pathCN_SYS_HEADERS
: System headers path
Populate SDK autogen code sections:
node gen-bindings.js.js
On MacOS, make sure LLVM clang-format is used (configure the PATH appropriately):
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
NOTE: Be aware of the current working directory (commands below assume the CWD is
tools
).
clang-format -i ../src/connection.cpp
clang-format -i ../src/connection.hpp
clang-format -i ../src/connection_autogen.cpp
clang-format -i ../src/constants.cpp
clang-format -i ../src/jstocbpp_autogen.hpp
NOTE: Be aware of the current working directory (commands below assume the CWD is
tools
).
npx prettier --write ../lib/binding.ts
rm bindings.json
This should rarely be needed (e.g. updating the autogen logic).
NOTE: Be aware of the current working directory (commands below assume the CWD is
tools
).
Install autopep8
from PyPI:
python3 -m pip install autopep8
autopep8 -i -a -a --max-line-length 120 gen-bindings-json.py
npx prettier --write gen-bindings-js.js
If a virtualenv was setup (hopefully it was ;)), deactivate and the environment
deactivate
rm -rf <path to virtualenv>
Example: deactivate && rm -rf $(pwd)/couchnode