Permalink
Browse files

Load the perl5 side interop support from a directory relative to the

.net side dll.
  • Loading branch information...
1 parent ad83416 commit 586845481b360320735dba8e28ee1486ffbfb51d Paweł Murias committed Feb 22, 2012
Showing with 10 additions and 4 deletions.
  1. +5 −2 lib/Perl5Interpreter.cs
  2. +5 −2 lib/p5embed.c
View
@@ -1,11 +1,12 @@
using Niecza;
using System.Runtime.InteropServices;
using System;
+using System.IO;
using Niecza.Serialization;
public class Perl5Interpreter : IForeignInterpreter {
[DllImport("p5embed", EntryPoint="p5embed_initialize")]
- public static extern void Initialize();
+ public static extern void Initialize(string p5lib);
[DllImport("p5embed", EntryPoint="p5embed_dispose")]
public static extern void Dispose();
@@ -84,7 +85,9 @@ int argument_n
}
public Perl5Interpreter() {
- Initialize();
+ string location = System.Reflection.Assembly.GetExecutingAssembly().Location;
+ string p5lib = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(location)),"perl5");
+ Initialize(p5lib);
}
~Perl5Interpreter() {
Dispose();
View
@@ -17,7 +17,7 @@ xs_init(pTHX)
}
static PerlInterpreter *my_perl;
-void p5embed_initialize()
+void p5embed_initialize(char* p5lib)
{
int argc = 1;
char *argv0[] = { "perl", NULL, 0 };
@@ -28,7 +28,10 @@ void p5embed_initialize()
char *embedding[] = { "", "-e", "0" };
perl_parse(my_perl, xs_init, 3, embedding, NULL);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
- eval_pv("use lib 'perl5';use Niecza::Interoperability",TRUE);
+ AV* INC = get_av("INC",0);
+ SV* p5lib_sv = newSVpv(p5lib,0);
+ av_push(INC,p5lib_sv);
+ eval_pv("use Niecza::Interoperability",TRUE);
}
SV* p5embed_eval(char* code) {

0 comments on commit 5868454

Please sign in to comment.