-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update build scripts since we need lumina-node types
- Loading branch information
1 parent
04093b8
commit 8a858d8
Showing
9 changed files
with
270 additions
and
183 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
#!/bin/bash | ||
|
||
cargo build -p native | ||
|
||
mkdir -p ./bindings | ||
mkdir -p ./ios | ||
|
||
cargo run --bin uniffi-bindgen generate --library ../target/debug/libnative.dylib --language swift --out-dir ./bindings | ||
|
||
cd .. | ||
|
||
for TARGET in \ | ||
aarch64-apple-darwin \ | ||
aarch64-apple-ios \ | ||
aarch64-apple-ios-sim \ | ||
x86_64-apple-darwin \ | ||
x86_64-apple-ios | ||
aarch64-apple-ios-sim | ||
do | ||
rustup target add $TARGET | ||
cargo build --release --target=$TARGET | ||
done | ||
|
||
mv ./bindings/nativeFFI.modulemap ./bindings/module.modulemap | ||
|
||
rm ./ios/Native.swift | ||
mv ./bindings/native.swift ./ios/Native.swift | ||
|
||
rm -rf "ios/Native.xcframework" | ||
|
||
cd node-uniffi | ||
|
||
rm -rf ./bindings ./ios | ||
mkdir -p ./bindings | ||
mkdir -p ./ios | ||
mkdir -p ./bindings/Headers | ||
|
||
cargo run --bin uniffi-bindgen generate --library ../target/debug/liblumina_node_uniffi.dylib --language swift --out-dir ./bindings | ||
|
||
cat "./bindings/lumina_node_uniffiFFI.modulemap" "./bindings/lumina_nodeFFI.modulemap" > "./bindings/Headers/module.modulemap" | ||
|
||
cp ./bindings/*.h ./bindings/Headers/ | ||
|
||
rm -rf "ios/lumina.xcframework" | ||
|
||
xcodebuild -create-xcframework \ | ||
-library ../target/aarch64-apple-ios-sim/release/libnative.a -headers ./bindings \ | ||
-library ../target/aarch64-apple-ios/release/libnative.a -headers ./bindings \ | ||
-output "ios/Native.xcframework" | ||
|
||
rm -rf bindings | ||
-library ../target/aarch64-apple-ios-sim/release/liblumina_node_uniffi.a -headers ./bindings/Headers \ | ||
-library ../target/aarch64-apple-ios/release/liblumina_node_uniffi.a -headers ./bindings/Headers \ | ||
-output "ios/lumina.xcframework" | ||
|
||
cp ./bindings/*.swift ./ios/ | ||
|
||
rm -rf bindings | ||
|
||
echo "iOS build complete" |
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,72 @@ | ||
use lumina_node::NodeError; | ||
use thiserror::Error; | ||
|
||
/// Result type alias for LuminaNode operations that can fail with a LuminaError | ||
pub type Result<T> = std::result::Result<T, LuminaError>; | ||
|
||
/// Represents all possible errors that can occur in the LuminaNode. | ||
#[derive(Error, Debug, uniffi::Error)] | ||
pub enum LuminaError { | ||
/// Error returned when trying to perform operations on a node that isn't running | ||
#[error("Node is not running")] | ||
NodeNotRunning, | ||
|
||
/// Error returned when network operations fail | ||
#[error("Network error: {msg}")] | ||
NetworkError { | ||
/// Description of the network error | ||
msg: String, | ||
}, | ||
|
||
/// Error returned when storage operations fail | ||
#[error("Storage error: {msg}")] | ||
StorageError { | ||
/// Description of the storage error | ||
msg: String, | ||
}, | ||
|
||
/// Error returned when trying to start a node that's already running | ||
#[error("Node is already running")] | ||
AlreadyRunning, | ||
|
||
/// Error returned when a mutex lock operation fails | ||
#[error("Lock error")] | ||
LockError, | ||
|
||
/// Error returned when a hash string is invalid or malformed | ||
#[error("Invalid hash format: {msg}")] | ||
InvalidHash { | ||
/// Description of why the hash is invalid | ||
msg: String, | ||
}, | ||
|
||
/// Error returned when a header is invalid or malformed | ||
#[error("Invalid header format: {msg}")] | ||
InvalidHeader { | ||
/// Description of why the header is invalid | ||
msg: String, | ||
}, | ||
|
||
/// Error returned when storage initialization fails | ||
#[error("Storage initialization failed: {msg}")] | ||
StorageInit { | ||
/// Description of why storage initialization failed | ||
msg: String, | ||
}, | ||
} | ||
|
||
impl From<NodeError> for LuminaError { | ||
fn from(error: NodeError) -> Self { | ||
LuminaError::NetworkError { | ||
msg: error.to_string(), | ||
} | ||
} | ||
} | ||
|
||
impl From<libp2p::multiaddr::Error> for LuminaError { | ||
fn from(e: libp2p::multiaddr::Error) -> Self { | ||
LuminaError::NetworkError { | ||
msg: format!("Invalid multiaddr: {}", e), | ||
} | ||
} | ||
} |
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
Oops, something went wrong.