diff --git a/uniffi/Cargo.toml b/uniffi/Cargo.toml index ecc76fe738..5240fd0eb9 100644 --- a/uniffi/Cargo.toml +++ b/uniffi/Cargo.toml @@ -9,12 +9,12 @@ edition = "2018" # Re-exported dependencies used in generated Rust scaffolding files. anyhow = "1" bytes = "0.5" -ffi-support = "~0.4.2" +ffi-support = "0.4.0" lazy_static = "1.4" log = "0.4" # Regular dependencies -cargo_metadata = "0.11" -paste = "1.0" +# cargo_metadata = { git = "https://github.com/oli-obk/cargo_metadata", rev = "64ee6d1d169103ed60ae4de5ddf84da751e7d841" } +paste = "0.1" uniffi_bindgen = { path = "../uniffi_bindgen", optional = true } [features] diff --git a/uniffi/src/lib.rs b/uniffi/src/lib.rs index d4f4c406de..991209fe66 100644 --- a/uniffi/src/lib.rs +++ b/uniffi/src/lib.rs @@ -27,7 +27,7 @@ use anyhow::{bail, Result}; use bytes::buf::{Buf, BufMut}; use ffi_support::ByteBuffer; -use paste::paste; +use paste::*; use std::{collections::HashMap, convert::TryFrom, ffi::CString}; // It would be nice if this module was behind a cfg(test) guard, but it @@ -160,7 +160,7 @@ macro_rules! impl_via_ffi_for_num_primitive { ($($T:ty,)+) => { impl_via_ffi_for_num_primitive!($($T),+); }; ($($T:ty),*) => { $( - paste! { + paste::item! { unsafe impl ViaFfi for $T { type FfiType = Self; diff --git a/uniffi/src/testing.rs b/uniffi/src/testing.rs index 75750f5390..c72730575d 100644 --- a/uniffi/src/testing.rs +++ b/uniffi/src/testing.rs @@ -10,11 +10,11 @@ //! the `uniffi_macros` crate. use anyhow::{bail, Result}; -use cargo_metadata::Message; +// use cargo_metadata::Message; use lazy_static::lazy_static; use std::{ collections::HashMap, - path::Path, + path::{Path, PathBuf}, process::{Command, Stdio}, sync::Mutex, }; @@ -56,56 +56,7 @@ pub fn run_foreign_language_testcase(pkg_dir: &str, idl_file: &str, test_file: & /// Internally, this function does a bit of caching and concurrency management to avoid rebuilding /// the component for multiple testcases. pub fn ensure_compiled_cdylib(pkg_dir: &str) -> Result { - // Have we already compiled this component? - let mut compiled_components = COMPILED_COMPONENTS.lock().unwrap(); - if let Some(cdylib_file) = compiled_components.get(pkg_dir) { - return Ok(cdylib_file.to_string()); - } - // Nope, looks like we'll have to compile it afresh. - let mut cmd = Command::new("cargo"); - cmd.arg("build").arg("--message-format=json").arg("--lib"); - cmd.current_dir(pkg_dir); - cmd.stdout(Stdio::piped()); - let mut child = cmd.spawn()?; - let output = std::io::BufReader::new(child.stdout.take().unwrap()); - // Build the crate, looking for any cdylibs that it might produce. - let cdylibs = Message::parse_stream(output) - .filter_map(|message| match message { - Err(e) => Some(Err(e.into())), - Ok(Message::CompilerArtifact(artifact)) => { - if artifact.target.kind.iter().any(|item| item == "cdylib") { - Some(Ok(artifact)) - } else { - None - } - } - _ => None, - }) - .collect::>>()?; - if !child.wait()?.success() { - bail!("Failed to execute `cargo build`"); - } - // If we didn't just build exactly one cdylib, we're going to have a bad time. - match cdylibs.len() { - 0 => bail!("Crate did not produce any cdylibs, it must not be a uniffi component"), - 1 => (), - _ => bail!("Crate produced multiple cdylibs, it must not be a uniffi component"), - } - let cdylib_files: Vec<_> = cdylibs[0] - .filenames - .iter() - .filter(|nm| match nm.extension().unwrap_or_default().to_str() { - Some("dylib") | Some("so") => true, - _ => false, - }) - .collect(); - if cdylib_files.len() != 1 { - bail!("Failed to build exactly one cdylib file, it must not be a uniffi component"); - } - let cdylib_file = cdylib_files[0].to_string_lossy().into_owned(); - // Cache the result for subsequent tests. - compiled_components.insert(pkg_dir.to_string(), cdylib_file.clone()); - Ok(cdylib_file) + unimplemented!() } /// Execute the `uniffi-bindgen test` command. diff --git a/uniffi_bindgen/Cargo.toml b/uniffi_bindgen/Cargo.toml index 9b6814aaae..a6fe04c783 100644 --- a/uniffi_bindgen/Cargo.toml +++ b/uniffi_bindgen/Cargo.toml @@ -10,7 +10,7 @@ name = "uniffi-bindgen" path = "src/main.rs" [dependencies] -cargo_metadata = "0.11" +# cargo_metadata = { git = "https://github.com/oli-obk/cargo_metadata", rev = "64ee6d1d169103ed60ae4de5ddf84da751e7d841" } weedle = "0.11" anyhow = "1" askama = "0.10" diff --git a/uniffi_bindgen/src/lib.rs b/uniffi_bindgen/src/lib.rs index 23dd9fb5de..b09fbb4cdf 100644 --- a/uniffi_bindgen/src/lib.rs +++ b/uniffi_bindgen/src/lib.rs @@ -123,7 +123,7 @@ pub fn generate_component_scaffolding>( .canonicalize() .map_err(|e| anyhow!("Failed to find idl file: {:?}", e))?; let component = parse_idl(&idl_file)?; - ensure_versions_compatibility(&idl_file, manifest_path_override)?; + // ensure_versions_compatibility(&idl_file, manifest_path_override)?; let mut filename = Path::new(&idl_file) .file_stem() .ok_or_else(|| anyhow!("not a file"))? @@ -141,6 +141,7 @@ pub fn generate_component_scaffolding>( Ok(()) } +/* // If the crate for which we are generating bindings for depends on // a `uniffi` runtime version that doesn't agree with our own version, // the developer of that said crate will be in a world of pain. @@ -184,6 +185,7 @@ fn ensure_versions_compatibility( } Ok(()) } +*/ // Generate the bindings in the target languages that call the scaffolding // Rust code. diff --git a/uniffi_build/Cargo.toml b/uniffi_build/Cargo.toml index 652d069cc9..a770f524f8 100644 --- a/uniffi_build/Cargo.toml +++ b/uniffi_build/Cargo.toml @@ -6,7 +6,7 @@ license = "MPL-2.0" edition = "2018" [dependencies] -cargo_metadata = "0.11" +# cargo_metadata = { git = "https://github.com/oli-obk/cargo_metadata", rev = "64ee6d1d169103ed60ae4de5ddf84da751e7d841" } anyhow = "1" uniffi_bindgen = { path = "../uniffi_bindgen", optional = true }