-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgotest.pm
31 lines (28 loc) · 954 Bytes
/
gotest.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package gotest;
our $VERSION = '0.01';
# Preload the libadd so file
# We need to do this manually, since otherwise it'll
# follow ld's default behavior and look in either LD_LIBRARY_PATH
# (which won't have our arch/auto/gotest directory)
# or in paths hard-coded into the library
# (which is even less obvious than doing a relative search from this PM)
{
use File::Basename;
use DynaLoader;
my (undef, $dir) = fileparse(__FILE__);
my @reldirs = qw(../arch/auto auto);
my @libs = qw(libadd.so libsub.so);
for my $libname (@libs) {
my $lib;
for my $reldir (@reldirs) {
my $libpath = "$dir/" . $reldir . "/" . __PACKAGE__ . "/$libname";
# The '1' is necessary to make the symbols visible to the upcoming load
$lib = DynaLoader::dl_load_file($libpath, 1);
last if $lib;
}
die "Couldn't load generated Go library $libname" unless defined $lib;
}
}
use XSLoader;
XSLoader::load('gotest', $VERSION);
1;