diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 48b0bcef..ede4ebf1 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -72,6 +72,11 @@ mod ffi { fn script_is_ignored(pkg: &str, script: &str) -> bool; } + // testutils.rs + extern "Rust" { + fn testutils_entrypoint(argv: Vec) -> Result<()>; + } + /// Currently cxx-rs doesn't support mappings; like probably most projects, /// by far our most common case is a mapping from string -> string and since /// our data sizes aren't large, we serialize this as a vector of strings pairs. @@ -158,7 +163,7 @@ pub use self::progress::*; mod scripts; pub(crate) use self::scripts::*; mod testutils; -pub use self::testutils::*; +pub(crate) use self::testutils::*; mod treefile; pub use self::treefile::*; mod utils; diff --git a/rust/src/testutils.rs b/rust/src/testutils.rs index 062a9527..554b6e3a 100644 --- a/rust/src/testutils.rs +++ b/rust/src/testutils.rs @@ -208,28 +208,10 @@ fn update_os_tree(opts: &SyntheticUpgradeOpts) -> Result<()> { Ok(()) } -fn testutils_main(args: &[String]) -> Result<()> { +pub(crate) fn testutils_entrypoint(args: Vec) -> Result<()> { let opt = Opt::from_iter(args.iter()); match opt { Opt::GenerateSyntheticUpgrade(ref opts) => update_os_tree(opts)?, }; Ok(()) } - -mod ffi { - use super::*; - use glib_sys; - use libc; - - use crate::ffiutil::*; - - #[no_mangle] - pub extern "C" fn ror_testutils_entrypoint( - argv: *mut *mut libc::c_char, - gerror: *mut *mut glib_sys::GError, - ) -> libc::c_int { - let v: Vec = unsafe { glib::translate::FromGlibPtrContainer::from_glib_none(argv) }; - int_glib_error(testutils_main(&v), gerror) - } -} -pub use self::ffi::*; diff --git a/src/app/rpmostree-builtin-testutils.cxx b/src/app/rpmostree-builtin-testutils.cxx index 18f02e0f..1ac2a0ea 100644 --- a/src/app/rpmostree-builtin-testutils.cxx +++ b/src/app/rpmostree-builtin-testutils.cxx @@ -27,6 +27,7 @@ #include "rpmostree-builtins.h" #include "rpmostree-rpm-util.h" #include "rpmostree-rust.h" +#include "rpmostree-cxxrs.h" gboolean rpmostree_testutils_builtin_inject_pkglist (int argc, char **argv, @@ -51,11 +52,11 @@ rpmostree_builtin_testutils (int argc, char **argv, invocation, cancellable, error); else { - g_autoptr(GPtrArray) args = g_ptr_array_new (); - for (int i = 0; i < argc; i++) - g_ptr_array_add (args, argv[i]); - g_ptr_array_add (args, NULL); - return ror_testutils_entrypoint ((char**)args->pdata, error); + rust::Vec rustargv; + for (int i = 0; i < argc; i++) + rustargv.push_back(std::string(argv[i])); + rpmostreecxx::testutils_entrypoint (rustargv); + return TRUE; } }