From 5918b5d79d46fbc1a5cb2b4460475382c4d076ad Mon Sep 17 00:00:00 2001 From: Hofer-Julian Date: Tue, 23 Apr 2024 11:53:53 +0200 Subject: [PATCH] Init Julia --- build/build.jl | 2 +- build/cli_wrapper/src/main.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/build.jl b/build/build.jl index 7915315b1..0c459ce21 100644 --- a/build/build.jl +++ b/build/build.jl @@ -67,7 +67,7 @@ function main() add_metadata(project_dir, license_file, output_dir, git_repo, readme) run(Cmd(`cargo build --release`; dir = "cli_wrapper")) ribasim = Sys.iswindows() ? "ribasim.exe" : "ribasim" - cp("cli_wrapper/target/release/$ribasim", "libribasim/$ribasim"; force = true) + cp("cli_wrapper/target/release/$ribasim", "ribasim/$ribasim"; force = true) end diff --git a/build/cli_wrapper/src/main.rs b/build/cli_wrapper/src/main.rs index b2b102361..3aa394c3f 100644 --- a/build/cli_wrapper/src/main.rs +++ b/build/cli_wrapper/src/main.rs @@ -46,19 +46,19 @@ fn main() -> ExitCode { "linux" => exe_dir.join("lib/libribasim.so"), _ => unimplemented!(), }; - unsafe { // Load the library let lib = Library::new(shared_lib_path).unwrap(); - // Load the function from the library + // Init Julia + let init_julia: Symbol i32> = + lib.get(b"init_julia").unwrap(); + init_julia(0, CString::default().as_ptr()); + + // Execute let execute: Symbol i32> = lib.get(b"execute").unwrap(); - - // Convert the path to a CString let toml_path_c = CString::new(cli.toml_path.to_str().unwrap()).unwrap(); - - // Call the function let exit_code = execute(toml_path_c.as_ptr()); // Return with same exit code as `execute` did