Skip to content

Commit

Permalink
Update UniFFI library access
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniusnaumann committed Jun 17, 2024
1 parent ff502b7 commit 746919d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use crate::Result;
use camino::Utf8Path;
use uniffi_bindgen::{bindings::TargetLanguage, BindingGeneratorDefault};
use uniffi_bindgen::bindings::SwiftBindingGenerator;

use crate::recreate_dir;

Expand All @@ -22,10 +22,7 @@ pub fn generate_bindings(lib_path: &Utf8Path) -> Result<()> {
let uniffi_outputs = uniffi_bindgen::library_mode::generate_bindings(
lib_path,
None,
&BindingGeneratorDefault {
target_languages: vec![TargetLanguage::Swift],
try_format_code: false,
},
&SwiftBindingGenerator {},
None,
out_dir,
false,
Expand All @@ -37,7 +34,7 @@ pub fn generate_bindings(lib_path: &Utf8Path) -> Result<()> {
.open(headers.join("module.modulemap"))?;

for output in uniffi_outputs {
let crate_name = output.crate_name;
let crate_name = output.ci.crate_name();
fs::copy(
out_dir.join(format!("{crate_name}.swift")),
sources.join(format!("{crate_name}.swift")),
Expand Down
15 changes: 0 additions & 15 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub(crate) fn metadata() -> &'static Metadata {

pub(crate) trait MetadataExt {
fn target_dir(&self) -> Cow<Utf8Path>;
fn uniffi_crates(&self) -> Vec<&Package>;
fn current_crate(&self) -> Option<&Package>;
}

Expand All @@ -37,20 +36,6 @@ impl MetadataExt for Metadata {
}
}

/// Returns the package metadata for all crates that depend on UniFFI and are below, at or above the current working directory.
fn uniffi_crates(&self) -> Vec<&Package> {
let cwd = std::env::current_dir().unwrap();
// TODO: also include crates that are above the current working directory
let crates: Vec<_> = self
.workspace_packages()
.into_iter()
.filter(|package| package.manifest_path.starts_with(&cwd))
// TODO: Filter out the crates that depend on UniFFI
.collect();

crates
}

/// Returns the package metadata for the crate currently at or above the current working directory.
fn current_crate(&self) -> Option<&Package> {
let cwd = std::env::current_dir().unwrap();
Expand Down

0 comments on commit 746919d

Please sign in to comment.