forked from TileDB-Inc/TileDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
111 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(CARGO_CMD cargo build -p tiledb-rust-api) | ||
set(TARGET_DIR "debug") | ||
else () | ||
set(CARGO_CMD cargo build --release -p tiledb-rust-api) | ||
set(TARGET_DIR "release") | ||
endif () | ||
|
||
set(TILEDB_RUST_API_H "${CMAKE_CURRENT_BINARY_DIR}/tiledb_rust_api.h") | ||
set(TILEDB_RUST_API_CXX "${CMAKE_CURRENT_BINARY_DIR}/tiledb_rust_api.cpp") | ||
set(TILEDB_RUST_API_LIB "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_DIR}/libtiledb_rust_api.a") | ||
|
||
add_custom_command( | ||
OUTPUT ${TILEDB_RUST_API_H} ${TILEDB_RUST_API_CXX} | ||
COMMAND MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} RUSTFLAGS="${RUST_FLAGS}" ${CARGO_CMD} | ||
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/tiledb-rust-api/src/lib.rs.h ${TILEDB_RUST_API_H} | ||
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/cxxbridge/tiledb-rust-api/src/lib.rs.cc ${TILEDB_RUST_API_CXX} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
add_custom_target(tiledb_rust_generated | ||
DEPENDS | ||
${TILEDB_RUST_API_H} | ||
${TILEDB_RUST_API_CXX} | ||
) | ||
|
||
add_library(tiledb_rust_bridge STATIC ${TILEDB_RUST_API_CXX}) | ||
add_dependencies(tiledb_rust_bridge tiledb_rust_generated) | ||
target_include_directories(tiledb_rust_bridge PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/..") | ||
target_link_libraries(tiledb_rust_bridge pthread dl ${TILEDB_RUST_API_LIB}) | ||
|
||
add_test( | ||
NAME tiledb_rust | ||
COMMAND CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} cargo test | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"crates/api", | ||
"crates/utils", | ||
] | ||
|
||
[workspace.package] | ||
edition = "2021" | ||
rust-version = "1.80" | ||
version = "0.1.0" | ||
|
||
[workspace.dependencies] | ||
cxx = "1.0" | ||
cxx-build = "1.0" | ||
|
||
tiledb-utils.path = "crates/utils" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "tiledb-rust-api" | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
cxx.workspace = true | ||
tiledb-utils.workspace = true | ||
|
||
[build-dependencies] | ||
cxx-build.workspace = true | ||
|
||
[lib] | ||
crate-type = ["staticlib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
let _ = cxx_build::bridge("src/lib.rs"); | ||
println!("cargo:rerun-if-changed=src/lib.rs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
#[cxx::bridge] | ||
mod ffi { | ||
#[namespace = "tiledb::rust"] | ||
extern "Rust" { | ||
fn timestamp_now_ms() -> u64; | ||
} | ||
} | ||
|
||
|
||
pub fn timestamp_now_ms() -> u64 { | ||
tiledb_utils::timestamp_now_ms() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "tiledb-utils" | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use std::time::SystemTime; | ||
|
||
pub fn timestamp_now_ms() -> u64 { | ||
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) { | ||
Ok(time) => time.as_millis() as u64, | ||
Err(_) => 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters