Skip to content

Commit

Permalink
Merge pull request #3 from chdb-io/fixPipeline
Browse files Browse the repository at this point in the history
Fix pipeline
  • Loading branch information
auxten committed Dec 30, 2023
2 parents 16ed1f8 + 87030b6 commit 4d1773b
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 18 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ jobs:
sudo ldconfig
- name: Build
run: cargo build --verbose
env:
RUST_BACKTRACE: full
- name: Run tests
run: cargo run
run: cargo run --example basic
env:
RUST_BACKTRACE: full
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
<a href="https://chdb.fly.dev" target="_blank">
<img src="https://avatars.githubusercontent.com/u/132536224" width=130 />
</a>
<img src="https://avatars.githubusercontent.com/u/132536224" width=130 />

[![Rust](https://github.com/chdb-io/chdb-rust/actions/workflows/rust.yml/badge.svg)](https://github.com/chdb-io/chdb-rust/actions/workflows/rust.yml)

# chdb-rust <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Rust_programming_language_black_logo.svg/1024px-Rust_programming_language_black_logo.svg.png" height=20 />
Experimental [chDB](https://github.com/auxten/chdb) FFI bindings for Rust
Experimental [chDB](https://github.com/chdb-io/chdb) FFI bindings for Rust
### Status

- experimental, unstable, subject to changes
- requires [`libchdb`](https://github.com/chdb-io/chdb) on the system
- ffi hack for testing. not a proper library or crate!
- Experimental, unstable, subject to changes
- Requires [`libchdb`](https://github.com/chdb-io/chdb) on the system

#### Build binding
```bash
cargo build
cargo run
./update_libchdb.sh
RUST_BACKTRACE=full cargo build --verbose
cargo run --example basic
```

:wave: _Rust developer? Jump in and help us evolve this example into a stable crate!_
75 changes: 69 additions & 6 deletions src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/* automatically generated by rust-bindgen 0.65.1 */

pub const __WORDSIZE: u32 = 64;
pub const __DARWIN_ONLY_64_BIT_INO_T: u32 = 1;
pub const __DARWIN_ONLY_64_BIT_INO_T: u32 = 0;
pub const __DARWIN_ONLY_UNIX_CONFORMANCE: u32 = 1;
pub const __DARWIN_ONLY_VERS_1050: u32 = 1;
pub const __DARWIN_ONLY_VERS_1050: u32 = 0;
pub const __DARWIN_UNIX03: u32 = 1;
pub const __DARWIN_64_BIT_INO_T: u32 = 1;
pub const __DARWIN_VERS_1050: u32 = 1;
pub const __DARWIN_NON_CANCELABLE: u32 = 0;
pub const __DARWIN_SUF_64_BIT_INO_T: &[u8; 9usize] = b"$INODE64\0";
pub const __DARWIN_SUF_1050: &[u8; 6usize] = b"$1050\0";
pub const __DARWIN_SUF_EXTSN: &[u8; 14usize] = b"$DARWIN_EXTSN\0";
pub const __DARWIN_C_ANSI: u32 = 4096;
pub const __DARWIN_C_FULL: u32 = 900000;
pub const __DARWIN_C_LEVEL: u32 = 900000;
pub const __STDC_WANT_LIB_EXT1__: u32 = 1;
pub const __DARWIN_NO_LONG_LONG: u32 = 0;
pub const _DARWIN_FEATURE_64_BIT_INODE: u32 = 1;
pub const _DARWIN_FEATURE_ONLY_64_BIT_INODE: u32 = 1;
pub const _DARWIN_FEATURE_ONLY_VERS_1050: u32 = 1;
pub const _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE: u32 = 1;
pub const _DARWIN_FEATURE_UNIX_CONFORMANCE: u32 = 3;
pub const __has_ptrcheck: u32 = 0;
Expand Down Expand Up @@ -75,7 +75,7 @@ pub const WINT_MAX: u32 = 2147483647;
pub const SIG_ATOMIC_MIN: i32 = -2147483648;
pub const SIG_ATOMIC_MAX: u32 = 2147483647;
pub type wchar_t = ::std::os::raw::c_int;
pub type max_align_t = f64;
pub type max_align_t = u128;
pub type int_least8_t = i8;
pub type int_least16_t = i16;
pub type int_least32_t = i32;
Expand Down Expand Up @@ -735,4 +735,67 @@ extern "C" {
extern "C" {
pub fn free_result(result: *mut local_result);
}
pub type __builtin_va_list = *mut ::std::os::raw::c_char;
pub type __builtin_va_list = [__va_list_tag; 1usize];
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __va_list_tag {
pub gp_offset: ::std::os::raw::c_uint,
pub fp_offset: ::std::os::raw::c_uint,
pub overflow_arg_area: *mut ::std::os::raw::c_void,
pub reg_save_area: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout___va_list_tag() {
const UNINIT: ::std::mem::MaybeUninit<__va_list_tag> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<__va_list_tag>(),
24usize,
concat!("Size of: ", stringify!(__va_list_tag))
);
assert_eq!(
::std::mem::align_of::<__va_list_tag>(),
8usize,
concat!("Alignment of ", stringify!(__va_list_tag))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).gp_offset) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__va_list_tag),
"::",
stringify!(gp_offset)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).fp_offset) as usize - ptr as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(__va_list_tag),
"::",
stringify!(fp_offset)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).overflow_arg_area) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__va_list_tag),
"::",
stringify!(overflow_arg_area)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).reg_save_area) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__va_list_tag),
"::",
stringify!(reg_save_area)
)
);
}
43 changes: 43 additions & 0 deletions update_libchdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

#!/bin/bash

# Get the newest release version
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/chdb-io/chdb/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

# Download the correct version based on the platform
case "$(uname -s)" in
Linux)
if [[ $(uname -m) == "aarch64" ]]; then
PLATFORM="linux-aarch64-libchdb.tar.gz"
else
PLATFORM="linux-x86_64-libchdb.tar.gz"
fi
;;
Darwin)
if [[ $(uname -m) == "arm64" ]]; then
PLATFORM="macos-arm64-libchdb.tar.gz"
else
PLATFORM="macos-x86_64-libchdb.tar.gz"
fi
;;
*)
echo "Unsupported platform"
exit 1
;;
esac

DOWNLOAD_URL="https://github.com/chdb-io/chdb/releases/download/$LATEST_RELEASE/$PLATFORM"

echo "Downloading $PLATFORM from $DOWNLOAD_URL"

# Download the file
curl -L -o libchdb.tar.gz $DOWNLOAD_URL

# Untar the file
tar -xzf libchdb.tar.gz

# Set execute permission for libchdb.so
chmod +x libchdb.so

# Clean up
rm -f libchdb.tar.gz

0 comments on commit 4d1773b

Please sign in to comment.