Skip to content

Commit

Permalink
fix(cpp-client) Update C++ and R client (#5807)
Browse files Browse the repository at this point in the history
Co-authored-by: Corey Kosak <kosak@users.noreply.github.com>
Co-authored-by: Alex Peters <80283343+alexpeters1208@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 18, 2024
1 parent d74b515 commit 1d25255
Show file tree
Hide file tree
Showing 31 changed files with 3,735 additions and 161 deletions.
5 changes: 4 additions & 1 deletion R/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ def rClientSite = Docker.registerDockerTask(project, 'rClientSite') {
runCommand("mkdir -p ${prefix}/src/rdeephaven/docs")
runCommand('''echo "status = tryCatch(" \
" {" \
" install.packages('pkgdown', repos='https://cran.r-project.org'); " \
" install.packages('devtools'); " \
" require(devtools); " \
" remove.packages('pkgdown'); " \
" devtools::install_version('pkgdown', version='2.0.0', repos='https://cran.r-project.org'); " \
" 0" \
" }," \
" error=function(e) 1," \
Expand Down
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ mention the version explicitly. These files are listed below:
#
gradle.properties
R/rdeephaven/DESCRIPTION
cpp-client/deephaven/CMakeLists.txt
```

This leaves the files "ready" for the next regular release, and also ensures any build done from
Expand Down
101 changes: 55 additions & 46 deletions cpp-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,48 @@ on them anymore so we do not guarantee they are current for those platforms.
Instructions for Linux are below. Instructions for Windows are in the section
that follows.

# Before you build the client

To actually use Deephaven, for example running these examples and unit
tests, you will eventually need to have a server running. If you have
an existing server running Deephaven Core, you should be able to
connect to that. However, if you don't have one, you can follow the
instructions here: https://deephaven.io/core/docs/how-to-guides/launch-build/.

Note that it is only possible to build a server on Linux. Building a server on
Windows is not currently supported.

You can build and install client libraries, tests, and examples
without having a server installed. However you will eventually need to
connect a server when you want to run them.

# Building the C++ client on Ubuntu 22.04

1. Start with an Ubuntu 22.04 install

2. Get Deephaven running by following the instructions here: https://deephaven.io/core/docs/how-to-guides/launch-build/

3. Get build tools
2. Get build tools
```
sudo apt update
sudo apt install curl git g++ cmake make build-essential zlib1g-dev libbz2-dev libssl-dev pkg-config
```

See the notes at the end of this document if you need the equivalent packages for Fedora.

4. Make a new directory for the Deephaven source code and assign that directory
3. Make a new directory for the Deephaven source code and assign that directory
to a temporary shell variable. This will make subsequent build steps easier.
```
export DHSRC=$HOME/src/deephaven
mkdir -p $DHSRC
cd $DHSRC
```

5. Clone deephaven-core sources.
4. Clone deephaven-core sources.
```
cd $DHSRC
git clone https://github.com/deephaven/deephaven-core.git
```

6. Build and install dependencies for Deephaven C++ client.
5. Build and install dependencies for Deephaven C++ client.

The `build-dependencies.sh` script in this directory downloads,
builds and installs the dependent libraries
Expand Down Expand Up @@ -100,7 +113,7 @@ that follows.
`CMAKE_PREFIX_PATH`. This file is intended to be `source`'d
from a shell where you plan to build the C++ client.

7. Build and install Deephaven C++ client. Running `build-dependencies.sh` should have
6. Build and install Deephaven C++ client. Running `build-dependencies.sh` should have
created an `env.sh` file that we source below to set relevant environment variables for
the build.

Expand Down Expand Up @@ -132,7 +145,7 @@ that follows.
VERBOSE=1 make -j$NCPUS install 2>&1 | tee make-install.log
```

8. Run one Deephaven example which uses the installed client.
7. Run one Deephaven example which uses the installed client.
This is a smoke test that the basic functionality
is working end to end, and the build is properly configured.
Note this assumes Deephaven server is running (see step 2),
Expand All @@ -144,7 +157,7 @@ that follows.
./hello_world
```

9. (Optional) run the unit tests
8. (Optional) run the unit tests
This assumes the build created on step 7 is available in the same directory.

```
Expand All @@ -153,25 +166,25 @@ that follows.
./tests
```

10. Building in different distributions or with older toolchains.
While we don't support other linux distributions or GCC versions earlier
than 11, this section provides some notes that may help you
in that situation.

* GCC 8 mixed with older versions of GNU as/binutils may fail to compile
`roaring.c` with an error similar to:
```
/tmp/cczCvQKd.s: Assembler messages:
/tmp/cczCvQKd.s:45826: Error: no such instruction: `vpcompressb %zmm0,%zmm1{%k2}'
/tmp/cczCvQKd.s:46092: Error: no such instruction: `vpcompressb %zmm0,%zmm1{%k1}'
```
In that case, add `-DCMAKE_C_FLAGS=-DCROARING_COMPILER_SUPPORTS_AVX512=0`
to the list of arguments to `cmake`.

* Some platforms combining old versions of GCC and cmake may fail
to set the cmake C++ standard to 17 without explicitly adding
`-DCMAKE_CXX_STANDARD=17` to the list of arguments to `cmake`.
Note the default mode for C++ is `-std=gnu++17` for GCC 11.
9. Building in different distributions or with older toolchains.
While we don't support other linux distributions or GCC versions earlier
than 11, this section provides some notes that may help you
in that situation.

* GCC 8 mixed with older versions of GNU as/binutils may fail to compile
`roaring.c` with an error similar to:
```
/tmp/cczCvQKd.s: Assembler messages:
/tmp/cczCvQKd.s:45826: Error: no such instruction: `vpcompressb %zmm0,%zmm1{%k2}'
/tmp/cczCvQKd.s:46092: Error: no such instruction: `vpcompressb %zmm0,%zmm1{%k1}'
```
In that case, add `-DCMAKE_C_FLAGS=-DCROARING_COMPILER_SUPPORTS_AVX512=0`
to the list of arguments to `cmake`.

* Some platforms combining old versions of GCC and cmake may fail
to set the cmake C++ standard to 17 without explicitly adding
`-DCMAKE_CXX_STANDARD=17` to the list of arguments to `cmake`.
Note the default mode for C++ is `-std=gnu++17` for GCC 11.

Notes
(1) The standard assumptions for `Debug` and `Release` apply here.
Expand Down Expand Up @@ -207,27 +220,23 @@ Notes

# Building the C++ client on Windows 10 / Windows 11

1. Get Deephaven running by following the instructions here:

https://deephaven.io/core/docs/how-to-guides/launch-build/

2. Install Visual Studio 2022 Community Edition (or Professional, or Enterprise)
1. Install Visual Studio 2022 Community Edition (or Professional, or Enterprise)
from here:

https://visualstudio.microsoft.com/downloads/

When the installer runs, select the workload "Desktop development with C++"

3. Use your preferred version of git, or install Git from here:
2. Use your preferred version of git, or install Git from here:

https://git-scm.com/download/win

4. We will do the actual build process inside a Visual Studio developer
3. We will do the actual build process inside a Visual Studio developer
command prompt. Run the developer command prompt by navigating here:

Start -> V -> Visual Studio 2022 -> Developer Command Prompt for VS 2022

5. Make a 'dhsrc' directory that will hold the two repositories: the vcpkg
4. Make a 'dhsrc' directory that will hold the two repositories: the vcpkg
package manager and Deephaven Core. Then make a 'dhinstall' directory that
will hold the libraries and executables that are the result of this
build process.
Expand All @@ -236,7 +245,7 @@ Notes
mkdir %HOMEDRIVE%%HOMEPATH%\dhinstall
```

6. Use git to clone the two repositories mentioned above.
5. Use git to clone the two repositories mentioned above.
If you are using Git for Windows, you can run the "Git Bash Shell"
and type these commands into it:
```
Expand All @@ -245,7 +254,7 @@ Notes
git clone https://github.com/deephaven/deephaven-core.git
```

7. Come back to the Visual Studio developer command prompt and do the
6. Come back to the Visual Studio developer command prompt and do the
one-time installation steps for vcpkg. Do not forget to set VCPKG_ROOT,
as our build scripts rely on it being set correctly.
```
Expand All @@ -254,24 +263,24 @@ Notes
set VCPKG_ROOT=%HOMEDRIVE%%HOMEPATH%\dhsrc\vcpkg
```

8. Change to the Deephaven core directory and build/install the dependent
7. Change to the Deephaven core directory and build/install the dependent
packages. On my computer this process took about 20 minutes.
```
cd /d %HOMEDRIVE%%HOMEPATH%\dhsrc\deephaven-core\cpp-client\deephaven
%VCPKG_ROOT%\vcpkg.exe install --triplet x64-windows
```

9. Now configure the build for Deephaven Core:
8. Now configure the build for Deephaven Core:
```
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=%HOMEDRIVE%%HOMEPATH%/dhinstall -DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=%HOMEDRIVE%%HOMEPATH%/dhinstall -DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
```

10. Finally, build and install Deephaven Core:
```
cmake --build build --target install
```
9. Finally, build and install Deephaven Core:
```
cmake --build build --target install
```

11. Run the tests.
10. Run the tests.
First, make sure Deephaven is running. If your Deephaven instance
is running somewhere other than the default location of localhost:10000,
then set these environment variables appropriately:
Expand Down
2 changes: 2 additions & 0 deletions cpp-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def buildCppClientImage = Docker.registerDockerTask(project, 'cppClient') {
include 'cpp-tests-to-junit.sh'
include 'build-dependencies.sh'
include 'deephaven/CMakeLists.txt'
include 'deephaven/cmake/**'
include 'deephaven/dhcore/**'
include 'deephaven/dhclient/**'
include 'deephaven/examples/**'
Expand All @@ -87,6 +88,7 @@ def buildCppClientImage = Docker.registerDockerTask(project, 'cppClient') {
${prefix}/log
""")
copyFile('deephaven/CMakeLists.txt', "${prefix}/src/deephaven/")
copyFile('deephaven/cmake/', "${prefix}/src/deephaven/cmake/")
copyFile('deephaven/dhcore/', "${prefix}/src/deephaven/dhcore/")
copyFile('deephaven/dhclient/', "${prefix}/src/deephaven/dhclient/")
copyFile('deephaven/examples/', "${prefix}/src/deephaven/examples/")
Expand Down
38 changes: 35 additions & 3 deletions cpp-client/deephaven/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ endif()

project(deephaven)

set(deephaven_VERSION 0.36.0)
set(CMAKE_CXX_STANDARD 17)

# for CMAKE_INSTALL_{dir}
Expand Down Expand Up @@ -40,15 +41,46 @@ if(NOT DHCORE_ONLY)
)

install(TARGETS dhclient dhcore dhcore_static dhclient_tests
EXPORT deephavenConfig
EXPORT deephavenTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(EXPORT deephavenConfig
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/deephaven
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/deephaven/deephavenConfigVersion.cmake"
VERSION ${deephaven_VERSION}
COMPATIBILITY AnyNewerVersion
)

export(EXPORT deephavenTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/deephaven/deephavenTargets.cmake"
NAMESPACE deephaven::
)
configure_file(cmake/deephavenConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/deephaven/deephavenConfig.cmake"
COPYONLY
)

set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/deephaven)
install(EXPORT deephavenTargets
FILE
deephavenTargets.cmake
NAMESPACE
deephaven::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
cmake/deephavenConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/deephaven/deephavenConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)

endif()
9 changes: 9 additions & 0 deletions cpp-client/deephaven/cmake/deephavenConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include(CMakeFindDependencyMacro)
find_dependency(Arrow 16.0.0)
find_dependency(ArrowFlight 16.0.0)
find_dependency(Immer)
find_dependency(Protobuf)
find_dependency(gRPC 1.63.0)
find_dependency(Threads)

include("${CMAKE_CURRENT_LIST_DIR}/deephavenTargets.cmake")
16 changes: 11 additions & 5 deletions cpp-client/deephaven/dhclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(GNUInstallDirs)

find_package(Arrow CONFIG REQUIRED)
find_package(ArrowFlight CONFIG REQUIRED HINTS ${Arrow_DIR})
find_package(Immer REQUIRED)
find_package(Immer CONFIG REQUIRED)
find_package(Protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)
find_package(Threads REQUIRED)
Expand Down Expand Up @@ -44,6 +44,13 @@ set(ALL_FILES
include/public/deephaven/client/flight.h
include/public/deephaven/client/update_by.h

src/interop/client_interop.cc
src/interop/client_options_interop.cc
src/interop/update_by_interop.cc
include/public/deephaven/client/interop/client_interop.h
include/public/deephaven/client/interop/client_options_interop.h
include/public/deephaven/client/interop/update_by_interop.h

src/subscription/subscribe_thread.cc

include/private/deephaven/client/subscription/subscribe_thread.h
Expand Down Expand Up @@ -126,7 +133,6 @@ target_link_libraries(dhclient PUBLIC deephaven::dhcore)

target_link_libraries(dhclient PUBLIC ArrowFlight::arrow_flight_shared)
target_link_libraries(dhclient PUBLIC Arrow::arrow_shared)
target_link_libraries(dhclient PUBLIC immer)
target_link_libraries(dhclient PUBLIC protobuf::libprotobuf)
target_link_libraries(dhclient PUBLIC gRPC::grpc++)
target_link_libraries(dhclient PUBLIC Threads::Threads)
target_link_libraries(dhclient PRIVATE protobuf::libprotobuf)
target_link_libraries(dhclient PRIVATE gRPC::grpc++)
target_link_libraries(dhclient PRIVATE Threads::Threads)
Loading

0 comments on commit 1d25255

Please sign in to comment.