Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
37ec326
rust gravity node stuff
astrauc Jun 6, 2025
08dae6a
readme
astrauc Jun 9, 2025
a667bd9
readme
astrauc Jun 9, 2025
ff666bb
readme
astrauc Jun 9, 2025
7282566
notes as of 6/10/25
astrauc Jun 10, 2025
a45c38d
notes 6/10/25
astrauc Jun 10, 2025
b3afd68
gravity can now publish basic messages
astrauc Jun 12, 2025
3e25201
updates 6.12.25
astrauc Jun 12, 2025
7ccfaea
splitting into separate files
astrauc Jun 13, 2025
c647095
formatting
astrauc Jun 13, 2025
98a55c2
protobufs and better file distribution
astrauc Jun 13, 2025
e0f1e67
updates 06.13.25
astrauc Jun 13, 2025
4178027
some trivial GravityNode methods
astrauc Jun 24, 2025
c0fecc7
even more of the easy-to-implement stuff
astrauc Jun 25, 2025
1907f35
updates 6.25.25
astrauc Jun 25, 2025
f209762
all trivial GravityNode functions
astrauc Jun 26, 2025
91022d9
very very rough subscriber implementation
astrauc Jun 27, 2025
f81a4be
some basic GravityDataProduct implementations
astrauc Jun 27, 2025
b3eb8f0
updates 6.27.25
astrauc Jun 27, 2025
ed69891
formatting for README
astrauc Jun 27, 2025
b750be8
working for populate_message
astrauc Jun 30, 2025
d46a1bb
starting to reformat
astrauc Jun 30, 2025
bde3def
subscriber works as idiomatic rust!
astrauc Jul 2, 2025
68a4a9c
Merge pull request #1 from astrauc/subscriber
astrauc Jul 2, 2025
1da057c
cleaning up
astrauc Jul 2, 2025
468d2cb
more cleaning up
astrauc Jul 2, 2025
fe638f3
more cleaning up
astrauc Jul 2, 2025
04741a7
redefining populate_message to not modify gravity source code
astrauc Jul 2, 2025
8fac6d5
update 7.4.25
astrauc Jul 2, 2025
f0c5efd
subscribe/unsubscribe complete
astrauc Jul 3, 2025
277ac89
requestor/provider
astrauc Jul 3, 2025
3430615
now a library
astrauc Jul 7, 2025
9554347
gdp + futureresponse + more gn
astrauc Jul 8, 2025
d6df61c
some tests and bug fixes
astrauc Jul 10, 2025
144e441
some tests and bug fixes
astrauc Jul 10, 2025
ce34a73
starrting to clean up
astrauc Jul 14, 2025
8698418
cleaning up
astrauc Jul 14, 2025
246f83f
a few more tests
astrauc Jul 14, 2025
9f3bb66
split cpp src files
astrauc Jul 14, 2025
be345b0
function args to string slice instead of String
astrauc Jul 14, 2025
331405a
function args to string slice instead of String
astrauc Jul 14, 2025
dd30175
data product test
astrauc Jul 16, 2025
14edf41
delete
astrauc Jul 16, 2025
de8d1a9
&str as param
astrauc Jul 16, 2025
7752c01
weird heartbeat segfaults fixed (weakly tested)
astrauc Jul 17, 2025
f4b7101
cleaning
astrauc Jul 17, 2025
3c534b0
fn for optional params
astrauc Jul 17, 2025
b49c604
traits now take mutable refs to self
astrauc Jul 17, 2025
d0d3c94
drop/move tests
astrauc Jul 18, 2025
79e4b5b
general directories
astrauc Jul 18, 2025
0044684
new build strategy
astrauc Jul 22, 2025
16d122c
naming conventions
astrauc Jul 23, 2025
8773daa
moved cargo.toml to top level
astrauc Jul 23, 2025
7827dca
fix file paths
astrauc Jul 23, 2025
ede688c
added option to build libraries only
astrauc Jul 24, 2025
01a3436
partial static linking (gravity but not dependencies)
astrauc Jul 24, 2025
0cd6f79
protobuf linked statically (tested only on same machine)
astrauc Jul 24, 2025
f8da484
protobuf static
astrauc Jul 25, 2025
88d6b4a
protobuf static
astrauc Jul 25, 2025
768970f
fixing branching isues
astrauc Jul 25, 2025
080a22e
static zmq
astrauc Jul 25, 2025
b217b2f
remove fmt dependency (experimental)
astrauc Jul 25, 2025
0dbe9c7
clean
astrauc Jul 25, 2025
ebc61b0
option for building only library
astrauc Jul 25, 2025
6b9030f
license file
astrauc Jul 25, 2025
7d16961
categories
astrauc Jul 25, 2025
361e6ae
change outdir
astrauc Jul 25, 2025
1daeb9a
include directory
astrauc Jul 25, 2025
ce71f83
include directory
astrauc Jul 25, 2025
593a549
include directory
astrauc Jul 25, 2025
55d7fc6
include directory
astrauc Jul 25, 2025
9997a7a
adjust so only out_dir is modified
astrauc Jul 25, 2025
aee223c
starting rustdoc
astrauc Jul 25, 2025
bb5aa0c
docs
astrauc Jul 28, 2025
cac0a2c
change where to put autogenerated files
astrauc Jul 29, 2025
0973158
change where to put autogenerated files
astrauc Jul 29, 2025
111298b
change where to put autogenerated files
astrauc Jul 29, 2025
433c55d
fix build issues
astrauc Jul 30, 2025
8814d83
final gdp methods
astrauc Jul 30, 2025
1c3392d
warnings
astrauc Jul 30, 2025
1bfe515
warnings
astrauc Jul 30, 2025
33e22c8
warnings
astrauc Jul 30, 2025
3d9c0e9
target directrory
astrauc Jul 30, 2025
9b2277b
Merge pull request #5 from astrauc/static_cmake
astrauc Jul 30, 2025
6a49995
cleaning
astrauc Jul 31, 2025
d28fd7f
cleaning
astrauc Jul 31, 2025
3a1ff0d
request optional parameters migrated out of rust
astrauc Aug 1, 2025
116e00f
heartbeat listener optional params gone
astrauc Aug 1, 2025
74f28f1
subscription monitor optional params
astrauc Aug 1, 2025
6bcccd1
Merge branch 'aphysci:master' into master
astrauc Aug 1, 2025
502eb64
clear subscription monitornaming
astrauc Aug 1, 2025
3fe3c45
cmake build release mode
astrauc Aug 1, 2025
5031119
Merge branch 'master' of github.com:astrauc/gravity
astrauc Aug 1, 2025
349680c
add subscriber with Arc
astrauc Aug 5, 2025
55bc18c
add subscriber with Arc
astrauc Aug 5, 2025
e011715
unique ownership with tokens (subscriber)
astrauc Aug 6, 2025
9977215
wrappers
astrauc Aug 7, 2025
fa902d4
tokens fully implemented
astrauc Aug 7, 2025
7b1dcde
example start
astrauc Aug 8, 2025
0c99335
pubsub runnable example
astrauc Aug 8, 2025
f7e4bc1
basic service runnable example
astrauc Aug 8, 2025
86e1ed9
changing format of protobuf includes
astrauc Aug 8, 2025
4f34cd3
detokenize hb listerner and service provider
astrauc Aug 8, 2025
9232129
Merge branch 'aphysci:master' into master
astrauc Aug 8, 2025
d8f9f61
Merge pull request #8 from astrauc/arcs
astrauc Aug 8, 2025
7a11b7e
formatting
astrauc Aug 8, 2025
d02f6af
cleanups
astrauc Aug 11, 2025
cda366a
Merge branch 'aphysci:master' into master
astrauc Aug 13, 2025
d9235df
service example working
astrauc Aug 14, 2025
48b671e
forgot to add autogenerated protobufs...
astrauc Aug 14, 2025
b663049
dependencies in toml
astrauc Aug 14, 2025
56af042
remove Cargo.lock
astrauc Aug 14, 2025
d1f8c47
remove cmakelists
astrauc Aug 14, 2025
36b9566
cmake fix
astrauc Aug 15, 2025
d61e9ca
bad library include
astrauc Aug 18, 2025
0e4e1e0
gdp not mutable fixed
astrauc Aug 19, 2025
4215ea4
option to only build static libraries
astrauc Aug 20, 2025
bf8484b
fallback when no tags present
astrauc Aug 20, 2025
ab529b0
add mut keyword to some
astrauc Aug 20, 2025
e3b5c1e
clarifying build instructions
astrauc Aug 20, 2025
4efdaec
doc tests now succeed
astrauc Aug 21, 2025
3ad6f83
spdlog external/internal issue
astrauc Aug 21, 2025
6fc5da6
dependencies information
astrauc Aug 21, 2025
9b69f08
cargo/rustc dependency
astrauc Aug 22, 2025
5a7ae8c
note about cmake
astrauc Aug 22, 2025
6d9d008
updating and formatting rustdoc
astrauc Aug 22, 2025
2a932e2
Merge branch 'aphysci:master' into master
astrauc Aug 27, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include
target/
*.tgz
*.tar.gz
*.o
Expand Down Expand Up @@ -26,3 +27,4 @@ install
build
.vscode
.vs
Cargo.lock
25 changes: 18 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ option(GRAVITY_USE_EXTERNAL_PROTOBUF "Download, Build and Use an externally down
option(GRAVITY_USE_EXTERNAL_ZEROMQ "Download, build and use and externally downloaded ZeroMQ build")
option(GRAVITY_USE_EXTERNAL_SPDLOG "Download, build and use an externally downloaded Spdlog build")
option(BUILD_EXAMPLES_TESTS "Build Gravity examples and tests" ON)
option(BUILD_LIBRARY_ONLY "Only build the libraries, without components or tests")
option(BUILD_STATIC_LIBRARIES "Build libraries to link statically (useful for linking with Rust)")
option(SKIP_JAVA "Skip building Gravity Java wrapper")
option(SKIP_PYTHON "Skip building Gravity Python wrapper")
set(JAVA_HOME "" CACHE PATH "Path to JDK to use")
Expand Down Expand Up @@ -42,6 +44,11 @@ endif()
set(PUBLIC_STAGING_DIR ${CMAKE_BINARY_DIR}/staging)

macro(add_external_protobuf)
if (NOT BUILD_STATIC_LIBRARIES)
set(BUILD_SHARED_LIBS_PROTO ON)
else()
set(BUILD_SHARED_LIBS_PROTO OFF)
endif()
ExternalProject_Add(
protobuf_external
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/protobuf"
Expand All @@ -53,7 +60,7 @@ macro(add_external_protobuf)
LOG_OUTPUT_ON_FAILURE ON
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${PUBLIC_STAGING_DIR}
-Dprotobuf_BUILD_SHARED_LIBS:BOOL=ON
-Dprotobuf_BUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS_PROTO}
-Dprotobuf_MSVC_STATIC_RUNTIME:BOOL=OFF
-Dprotobuf_BUILD_TESTS:BOOL=OFF
-Dprotobuf_BUILD_EXAMPLES:BOOL=OFF
Expand All @@ -78,7 +85,7 @@ macro(add_external_libzmq)
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${PUBLIC_STAGING_DIR}
-DBUILD_SHARED:BOOL=ON
-DBUILD_STATIC:BOOL=OFF
-DBUILD_STATIC:BOOL=${BUILD_STATIC_LIBRARIES}
-DZMQ_BUILD_TESTS:BOOL=OFF
-DBUILD_TESTS:BOOL=OFF
BUILD_COMMAND cmake --build . --config $<$<CONFIG:Debug>:debug>$<$<CONFIG:Release>:release>
Expand Down Expand Up @@ -266,11 +273,13 @@ if (NOT depends)
set(GRAVITY_ROOT "${CMAKE_INSTALL_PREFIX}")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH_ALT_SEP})

include(CTest)
add_subdirectory(test)
if (NOT BUILD_LIBRARY_ONLY)
include(CTest)
add_subdirectory(test)

set(CPACK_GENERATOR "TGZ")
include(CPack)
set(CPACK_GENERATOR "TGZ")
include(CPack)
endif()

message(STATUS "No external libraries - doing a toplevel build")
else()
Expand All @@ -286,6 +295,8 @@ else()
-DSKIP_JAVA=${SKIP_JAVA}
-DSKIP_PYTHON=${SKIP_PYTHON}
-DZMQ_HOME=${ZMQ_HOME}
-DBUILD_LIBRARY_ONLY=${BUILD_LIBRARY_ONLY}
-DBUILD_STATIC_LIBRARIES=${BUILD_STATIC_LIBRARIES}
-DGRAVITY_USE_EXTERNAL_PROTOBUF=${GRAVITY_USING_EXTERNAL_PROTOBUF}
-DGRAVITY_USE_EXTERNAL_ZEROMQ=${GRAVITY_USING_EXTERNAL_ZEROMQ}
-DGRAVITY_USE_EXTERNAL_SPDLOG=${GRAVITY_USING_EXTERNAL_SPDLOG}
Expand All @@ -306,7 +317,7 @@ else()



if (BUILD_EXAMPLES_TESTS)
if (BUILD_EXAMPLES_TESTS AND NOT BUILD_LIBRARY_ONLY)
ExternalProject_Add(
gravity_external_examples_tests
DEPENDS gravity_external
Expand Down
24 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "gravity"
version = "0.1.0"
edition = "2024"
description = "Rust bindings for the Gravity software framework"
readme = "README.md"
license-file = "LICENSE"
repository = "https://github.com/astrauc/gravity.git"
keywords = ["FFI", "C++", "Gravity"]
exclude = ["src/api/rust/target"]
build = "src/api/rust/build.rs"

[lib]
path = "src/api/rust/src/lib.rs"

[dependencies]
cxx = "1.0.158"
protobuf = "3.7.2"

[build-dependencies]
cxx-build = "1.0.158"
cmake = "0.1"
protobuf-codegen = "3.7.2"

15 changes: 9 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ endif()
add_subdirectory(keyvalue_parser)
add_subdirectory(api/protobufs)
add_subdirectory(api/cpp)

if (NOT SKIP_JAVA)
add_subdirectory(api/java/src/swig)
add_subdirectory(api/java/src/cpp)
add_subdirectory(api/java)
add_subdirectory(api/MATLAB)
endif()

add_subdirectory(components/cpp/ServiceDirectory)
add_subdirectory(components/cpp/Archiver)
add_subdirectory(components/cpp/ConfigServer)
add_subdirectory(components/cpp/LogRecorder)
add_subdirectory(components/cpp/Playback)
add_subdirectory(components/cpp/Relay)
if (NOT BUILD_LIBRARY_ONLY)
add_subdirectory(components/cpp/ServiceDirectory)
add_subdirectory(components/cpp/Archiver)
add_subdirectory(components/cpp/ConfigServer)
add_subdirectory(components/cpp/LogRecorder)
add_subdirectory(components/cpp/Playback)
add_subdirectory(components/cpp/Relay)
endif()

if (NOT SKIP_PYTHON)
add_subdirectory(api/python/src/swig)
Expand Down
17 changes: 13 additions & 4 deletions src/api/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ set(SRCS
"${CMAKE_CURRENT_LIST_DIR}/Utility.cpp")



add_library(${PROTO_LIB_NAME} SHARED ${PROTO_SRCS} ${PROTO_HDRS})
if (NOT BUILD_STATIC_LIBRARIES)
add_library(${PROTO_LIB_NAME} SHARED ${PROTO_SRCS} ${PROTO_HDRS})
else()
add_library(${PROTO_LIB_NAME} STATIC ${PROTO_SRCS} ${PROTO_HDRS})
endif()
target_link_libraries(${PROTO_LIB_NAME} PUBLIC protobuf::libprotobuf)
add_dependencies(${PROTO_LIB_NAME} ${LIB_NAME}_protos)
install(TARGETS ${PROTO_LIB_NAME} EXPORT ${PROJECT_NAME}-targets ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
Expand All @@ -118,7 +121,12 @@ endif()

add_definitions(-DGRAVITY_EXPORTS -D_USRDLL)
include_directories("${CMAKE_BINARY_DIR}")
add_library(${LIB_NAME} SHARED ${SRCS})
if (NOT BUILD_STATIC_LIBRARIES)
add_library(${LIB_NAME} SHARED ${SRCS})
else()
add_library(${LIB_NAME} STATIC ${SRCS})
endif()

add_dependencies(${LIB_NAME} ${PROTO_LIB_NAME})
gravity_add_dependency(${LIB_NAME})
target_include_directories(${LIB_NAME} INTERFACE
Expand Down Expand Up @@ -160,7 +168,8 @@ if (GIT_EXE)
message(STATUS "${GIT_EXE} FAILED: ${STATUS}")
else()
message(STATUS "${GIT_EXE} SUCCESS: ${OUTPUT2}")
add_custom_command(TARGET ${LIB_NAME} POST_BUILD COMMAND "${GIT_EXE}" describe --tag --dirty > "${CMAKE_BINARY_DIR}/VERSION.txt")
add_custom_command(TARGET ${LIB_NAME} POST_BUILD COMMAND "${GIT_EXE}" describe --tag --dirty > "${CMAKE_BINARY_DIR}/VERSION.txt"
|| echo "0.0.0-unknown" > "${CMAKE_BINARY_DIR}/VERSION.txt")
INSTALL(FILES "${CMAKE_BINARY_DIR}/VERSION.txt" DESTINATION .)
endif()
endif()
Expand Down
5 changes: 5 additions & 0 deletions src/api/rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target/
build/
Cargo.lock
*.log
Testing/
46 changes: 46 additions & 0 deletions src/api/rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Rust for Gravity

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this file at first glance - this covers the setup notes I asked for.


A Rust API for gravity

## Usage

### Dependencies

**Requires cargo 1.85 or later**
On linux, this can be easily installed through the following:
```sh
sudo apt install rustup
rustup update stable
```

Rustup will automatically install the latest stable release of rust compiler.


Before you add it to your ```Cargo.toml```, ensure that you have all the Gravity dependencies installed, specified in the [Gravity Build Guide](https://github.com/aphysci/gravity/wiki/GravitySetup).

Not all are necessary, just g++, cmake, bison, flex.

In linux:
```sh
sudo apt install cmake g++ bison flex
```
Using cmake version 4.x.x or later does not work with Gravity. apt installs version 3.28 which has been tested with Gravity and the Cargo build.

Then, add the crate to your Cargo.toml:
```toml
[dependencies]
gravity = { git = "REPOSITORY_URL" }
```

You are done! Now you can use Gravity from your Rust application!

> [!NOTE]
> Using Gravity this way does not create/run the ServiceDirectory. Follow the [Gravity Build Guide](https://github.com/aphysci/gravity/wiki/GravitySetup) to set that up.
>

## Tests
To run the unit tests, you need a Service Directory running. Then simply run ``` cargo test ```. As long you are not in the examples folder, the folder you run it in does not matter. (If you are in the examples it will run the specific example)

## Runnable examples

Once there is a ServiceDirectory setup, go into the example directory you want to run and ``` cargo run ```
16 changes: 16 additions & 0 deletions src/api/rust/bridge/RustFutureResponse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "RustFutureResponse.h"

namespace gravity {

std::shared_ptr<FutureResponse> rustNewFutureResponse(const char* arrayPtr, int size)
{
return std::shared_ptr<FutureResponse>(new FutureResponse(arrayPtr, size));
}

void rustSetResponse(const std::unique_ptr<FutureResponse>& fr, const std::unique_ptr<GravityDataProduct>& response)
{
fr->setResponse(*response);
}


} // namespace gravity
21 changes: 21 additions & 0 deletions src/api/rust/bridge/RustFutureResponse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef RUSTFUTURERESPONSE_H_
#define RUSTFUTURERESPONSE_H_


#include <FutureResponse.h>



namespace gravity
{
/* Future response things*/
std::shared_ptr<FutureResponse> rustNewFutureResponse(const char* arrayPtr, int size);

void rustSetResponse(const std::unique_ptr<FutureResponse>& fr, const std::unique_ptr<GravityDataProduct>& response);



} // namespace gravity


#endif
Loading
Loading