Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0962a68
feat(android): wip implementation of the android patch system
nipsysdev Dec 3, 2025
9057365
refactor(android): cleanup up vibecoded code
nipsysdev Dec 5, 2025
f342abf
refactor(android): remove build sh script, let's only use cargo
nipsysdev Dec 5, 2025
a7983c9
refactor: remove unused config.toml
nipsysdev Dec 5, 2025
83f14be
fix(android): using git apply instead of patch command
nipsysdev Dec 5, 2025
c3a7dd1
feat(android): adding patches to toggle codex build git update/reset
nipsysdev Dec 5, 2025
c2d775a
fix(android): fix terminal patch
nipsysdev Dec 5, 2025
f3461fe
fix(android): fix some patches while removing the rest, starting over…
nipsysdev Dec 5, 2025
8ca75ba
fix(android): solve pthread issues
nipsysdev Dec 6, 2025
35e3241
feat(android): add more patches
nipsysdev Dec 7, 2025
9e7d8db
feat(android): finally working build with proper patching
nipsysdev Dec 7, 2025
3680a0b
refactor(android): extract android specific logic from build.rs
nipsysdev Dec 7, 2025
73bf91d
docs(android): update readme with basic android build instructions
nipsysdev Dec 7, 2025
c9b2c8c
feat(android): improve build system with dynamic Clang version detect…
nipsysdev Dec 9, 2025
5cff0c5
fix(android): add leopard cmake patch/fix
nipsysdev Dec 10, 2025
21093a3
feat(build): use static linking by default
nipsysdev Dec 10, 2025
9120283
docs(android): update readme
nipsysdev Dec 10, 2025
572ebef
fix(android): attempt to solve cmdLine & cmdCount unknown symbols issue
nipsysdev Dec 11, 2025
ba89f58
docs: update README
nipsysdev Dec 11, 2025
e5c8a4f
fix(android): disable LSE atomics detection on Android
nipsysdev Dec 11, 2025
829c593
feat(android): add support for x86_64
nipsysdev Dec 11, 2025
78e1b2a
fix(android): fix linking issues (pic)
nipsysdev Dec 12, 2025
76ce10d
fix(android): add missing endline in cmdline patch
nipsysdev Dec 12, 2025
c09fb7b
fix(android): improve cleaning build to handle static libraries
nipsysdev Dec 13, 2025
2d9c57e
refactor(build): rewrite cleaning logic
nipsysdev Dec 15, 2025
6225819
fix(android): attempt to make leveldb build properly for android
nipsysdev Dec 15, 2025
18e2188
fix: make cmdline symbols fix universal, move build related files to …
nipsysdev Dec 15, 2025
c7c5697
fix(build): cleanup build panic message
nipsysdev Dec 15, 2025
78701cd
feat(build): dynamically determine number of jobs for nim-codex build
nipsysdev Dec 15, 2025
9fdcffc
refactor(build): simplify invalid artifact detection & extract cleani…
nipsysdev Dec 16, 2025
bd6875c
chore(android): remove useless android-patches feature flag
nipsysdev Dec 29, 2025
ba9c2cb
chore: make cargo ignore vendor/nim-codex
nipsysdev Dec 29, 2025
98bb8e0
chore: update package version to 0.1.3-android-1
nipsysdev Dec 29, 2025
f41a38a
feat(build): migrate to using libstorage prebuilt binaries
nipsysdev Jan 15, 2026
ccd7db6
refactor: rename Codex to Storage following Logos rebranding
nipsysdev Jan 15, 2026
5e11a43
chore(libstorage): bump version
nipsysdev Jan 16, 2026
02511a2
chore: add debug logs
nipsysdev Jan 16, 2026
8fba9bb
refactor(build): Turn prebuilt binary handling into modular local/rem…
nipsysdev Jan 18, 2026
67f4a28
test(two_node_network): fix rebase leftover issues
nipsysdev Jan 19, 2026
f2babee
chore: cleanup comments/logs
nipsysdev Jan 19, 2026
ed0ac10
chore(gitignore): remove .last_built_architecture
nipsysdev Jan 19, 2026
6a9ee79
docs(readme): use placeholder for integration test name to avoid dupl…
nipsysdev Jan 19, 2026
b488913
feat(build): logging prebuilt binaries download progress
nipsysdev Jan 19, 2026
106413d
refactor(build): centralize build URLs and target platform mappings
nipsysdev Jan 19, 2026
bb328b5
refactor(build): minor refactoring around storage version env name
nipsysdev Jan 19, 2026
ff7497f
chore(deps): remove deps we dont need
nipsysdev Jan 19, 2026
d785157
feat(build): implement a proper caching system
nipsysdev Jan 19, 2026
efee262
refactor(build): remove old cache marker
nipsysdev Jan 19, 2026
fa800f2
chore(clippy): address warnings and errors
nipsysdev Jan 19, 2026
c4f5111
chore(hooks): add pre-commit & pre-push hooks
nipsysdev Jan 19, 2026
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
4 changes: 0 additions & 4 deletions .cargo/config.toml

This file was deleted.

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ src/ffi/bindings.rs

# Test output
/tests/output/
/examples/output/

# Environment files
.env
Expand All @@ -47,4 +46,4 @@ src/ffi/bindings.rs
*.debug

# LLM
.kilocode
.kilocode
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

43 changes: 28 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
[package]
name = "codex-bindings"
version = "0.1.3"
name = "storage-bindings"
version = "0.2.0"
edition = "2021"
description = "Rust bindings for Codex, the Decentralized Durability Engine"
description = "Rust bindings for Storage, the Decentralized Durability Engine"
license = "MIT"
repository = "https://github.com/nipsysdev/codex-rust-bindings"
homepage = "https://codex.storage"
keywords = ["codex", "storage", "p2p", "distributed"]
repository = "https://github.com/nipsysdev/storage-rust-bindings"
homepage = "https://logos.co/tech-stack"
keywords = ["storage", "p2p", "distributed"]
categories = ["api-bindings", "network-programming"]

# Prebuilt binary version pinning
# Set this to a specific version from https://github.com/nipsysdev/logos-storage-nim-bin/releases
# Format: <branch>-<commit-hash> (e.g., "master-60861d6a")
# Leave empty or comment out to use the latest release
[package.metadata.prebuilt]
libstorage = "master-1acedcf"

[lib]
name = "codex_bindings"
name = "storage_bindings"
crate-type = ["cdylib", "rlib"]

[dependencies]
libc = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "2.0"
log = "0.4"
chrono = { version = "0.4", features = ["serde"] }
once_cell = "1.21"
bytesize = "2.1"
futures = "0.3"

Expand All @@ -31,16 +35,25 @@ optional = true

[build-dependencies]
bindgen = "0.72"
pkg-config = "0.3"
reqwest = { version = "0.12", features = ["blocking", "json"] }
flate2 = "1.0"
tar = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sha2 = "0.10"
hex = "0.4"
cc = "1.2"
dirs = "6.0"

[dev-dependencies]
tempfile = "3.23"
tokio-test = "0.4"
env_logger = "0.10"
tokio = { version = "1", features = ["macros", "io-util", "rt-multi-thread"] }
tokio = { version = "1", features = [
"macros",
"io-util",
"rt-multi-thread",
"time",
] }

[features]
default = ["tokio"]
static-linking = []
dynamic-linking = []
145 changes: 105 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,152 @@
# Codex Rust Bindings
# Storage Rust Bindings

This repository provides Rust bindings for the Codex library, enabling seamless integration with Rust projects.
This repository provides Rust bindings for the Storage library, enabling seamless integration with Rust projects.

## Usage

Include in your Cargo project:

```toml
[dependencies]
codex-bindings = "0.1.3"
storage-bindings = "0.2.0"
```

To learn how to use those bindings, take a look at the [example project](https://github.com/nipsysdev/example-codex-rust-bindings) or the [integration tests](./tests/).
To learn how to use those bindings, take a look at the [example project](https://github.com/nipsysdev/example-storage-rust-bindings) or the [integration tests](./tests/) directory.

## Building

### Requirements
Building will automatically:

This crate automatically builds the required libcodex library during compilation, so you don't need to install nim-codex separately. However, you will need:
1. Fetch the latest prebuilt libstorage binary for your platform from GitHub
2. Generate Rust bindings and compile the crate

- **Rust and Cargo**
- **Git**
- **Make**
- **C compiler**
**Note**: The first build will download the prebuilt binary (~50MB). Subsequent builds will use the cached version.

Building will automatically:
## Caching

1. Clone the nim-codex repository and it's submodules
2. Build the Nim compiler from source
3. Build libcodex with the Nim compiler
4. Generate Rust bindings and compile the crate
Prebuilt binaries are automatically cached to improve build performance and reduce network usage.

**Note**: The first build may take 10-20 minutes as it needs to build the Nim compiler from source. Subsequent builds will be much faster.
### Cache Location

### Building from source
Prebuilt binaries are cached in a platform-specific location:

- **Linux**: `~/.cache/storage-bindings/`
- **macOS**: `~/Library/Caches/storage-bindings/`
- **Windows**: `%LOCALAPPDATA%\storage-bindings\cache\`

The cache is organized by version and platform:

```
~/.cache/storage-bindings/
├── master-1acedcf/
│ ├── linux-amd64/
│ │ ├── libstorage.a
│ │ ├── libstorage.h
│ │ └── SHA256SUMS.txt
│ └── darwin-arm64/
│ └── ...
└── master-2b3d4e5/
└── ...
```

### Managing the Cache

#### Force Re-download

To force a fresh download without clearing the cache:

```bash
cargo build --release
# or, for debug
cargo build
STORAGE_BINDINGS_FORCE_DOWNLOAD=1 cargo build
```

### Other Cargo Commands
#### Clean Entire Cache

To remove all cached binaries:

```bash
# Run all tests
cargo test
# Linux/macOS
rm -rf ~/.cache/storage-bindings/

# Windows
rmdir /s /q %LOCALAPPDATA%\storage-bindings\cache

# Run unit tests
cargo test-unit
# Or using the build script
STORAGE_BINDINGS_CLEAN_CACHE=1 cargo build
```

# Run integration tests
cargo test-integration
### Supported Platforms

# Run doctests
cargo test-doc
- Linux x86_64 (x86_64-unknown-linux-gnu)
- Linux ARM64 (aarch64-unknown-linux-gnu)

### Libstorage Version Pinning

**Option 1: Cargo.toml metadata**

Add to your `Cargo.toml`:

```toml
[package.metadata.prebuilt]
libstorage = "master-60861d6a"
```

## Linking Modes
**Option 2: Environment variable (for local overrides)**

This crate supports two linking modes via Cargo features:
```bash
export LOGOS_STORAGE_VERSION=master-60861d6a
cargo build
```

### Dynamic Linking (Default)
Available versions can be found at: https://github.com/nipsysdev/logos-storage-nim-bin/releases

### Building from source

```bash
cargo build --release
# or, for debug
cargo build
# or explicitly
cargo build --features dynamic-linking
```

### Static Linking
### Building using local libraries

To use locally built libraries instead of downloading from GitHub, set the `STORAGE_BINDINGS_LOCAL_LIBS` environment variable to the path of the dist folder:

```bash
cargo build --features static-linking
export STORAGE_BINDINGS_LOCAL_LIBS=/path/to/logos-storage-nim-bin/dist/master-50bd1839-linux-amd64
cargo build
```

### In your Cargo.toml
### Testing

```toml
[dependencies]
codex-bindings = { version = "0.1.3", features = ["static-linking"] }
The library includes comprehensive integration tests that demonstrate all major functionality.

#### Running All Tests

```bash
# Run all tests (unit tests + integration tests)
cargo test
```

#### Running Specific Tests

```bash
# Run only unit tests
cargo test --lib

# Run only integration tests
cargo test --test $test_name
```

#### Available Integration Tests

- **basic_usage**: Demonstrates basic upload/download functionality
- **chunk_operations**: Shows chunk-based upload and download operations
- **debug_operations**: Demonstrates debug operations and logging
- **p2p_networking**: Shows P2P networking operations
- **storage_management**: Demonstrates storage management operations
- **two_node_network**: Shows two-node network setup and data transfer
- **thread_safe_tests**: Tests thread-safe node lifecycle and concurrent operations

## License

[MIT](./LICENSE)
Loading