-
Notifications
You must be signed in to change notification settings - Fork 60
Can't use cargo test
#91
Comments
This is going to be because we're excepting that the helix_runtime C library will be loaded already. The solution here would be to have cargo somehow load it from the gem directory. This isn't my area of expertise so I'm not sure how easy or hard that would be be. |
After much experimentation and learning, I was able to link to Helix from a C program using clang on macOS: #include <dlfcn.h>
#include <stdio.h>
int main() {
void *handle = dlopen("./native.bundle", RTLD_NOW);
if (!handle) goto end;
dlsym(handle, "HELIX_Qnil");
end:;
char *error = dlerror();
if (error) printf("%s\n", error);
dlclose(handle);
return !!error;
} clang -Wl,-force_load,/Users/alyssa/.rubies/ruby-2.4.1/lib/libruby-static.a \
-framework CoreFoundation -lgmp test.c I'll look more into this and see if I can reproduce it in Rust, and then try to make it more portable. |
Nice! I think with Rust you might just be able to set a linker argument (probably with build.rs) to point to the helix_runtime native bundle. |
I think we might want to expose a Cargo "feature" called |
Further investigation on my part reveals that even if I do manage to get @wycats's solution sounds like it would solve the problem, but I wonder if it might be a good idea to try to load helix_runtime from Rust in Init_native if it isn't present? (Is that even possible?) For future reference (maybe if someone's Googling obscure combinations of Rust commands and linker flags like I have been for the past few hours), here is the Cargo configuration I used to get it to link: [build]
rustflags = [
"-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup",
"-C", "link-arg=-rdynamic",
"-C", "link-arg=-force_load",
"-C", "link-arg=/Users/alyssa/.rubies/ruby-2.4.1/lib/libruby-static.a",
"-C", "link-arg=-framework",
"-C", "link-arg=CoreFoundation",
"-C", "link-arg=-lgmp",
]
|
When using Helix, I do most of my testing from Ruby. Sometimes, however, I want to test behaviour that I don't want to expose to Ruby, but still involves Helix objects. To do this, I expected to be able to use
cargo test
, something like this:cargo test
manages to compile this, but it won't run:The text was updated successfully, but these errors were encountered: