Skip to content

Instantly share code, notes, and snippets.

@Skarsnik

Skarsnik/plop.p6 Secret

Last active January 22, 2016 21:37
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Skarsnik/3da8fbf2d7532ca06bdd to your computer and use it in GitHub Desktop.
use NativeCall;
register-native-library('Gumbo', 'gumbo', v1); # could be register-native-library('Gumbo', ('gumbo', v1));
sub foo is native('Gumbo') { * }
use NativeCall;
my LibHandle \GUMBO = register-native-library('gumbo', v1);
sub foo is native(GUMBO);
@salortiz
Copy link

In my module I use

sub MyLibName {
    my $name = %*ENV<LIBLMDB> || 'liblmdb.so'; once note "Using $name"; $name;
}
constant LIB = &MyLibName;
...

And that results in:

[sog@monica p6-LMDB]$ perl6 -I lib t/01-basic.t 
1..49
ok 1 - The module can be use-d ok
Using liblmdb.so
ok 2 - Version LMDB 0.9.17: (November 30, 2015)
...
[sog@monica p6-LMDB]$ LIBLMDB="/home/sog/src/from-git/mdb/libraries/liblmdb/liblmdb.so" perl6 -I lib t/01-basic.t 
1..49
ok 1 - The module can be use-d ok
Using /home/sog/src/from-git/mdb/libraries/liblmdb/liblmdb.so
ok 2 - Version LMDB 0.9.70: (December 19, 2015)
...

Don't understand what are you trying to resolve.

@Skarsnik
Copy link
Author

Keep the native 'magic' (transforming foo into libfoo.so on unix, foo.dylib on os X...) while keeping a dynamic defined thing to give to NC.

Sure I can call guess_library_name myself in a sub and give it to the native trait, but it's an internal :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment