Permalink
Browse files

Make the perl5 interop work outside the niecza directory and hopefull…

…y on Mac OS X too (not tested yet).
  • Loading branch information...
1 parent e9ac09d commit bef38b1f2f54417d5c84a027ad5d29e24dfa5a4a @pmurias pmurias committed Jan 27, 2012
Showing with 36 additions and 16 deletions.
  1. +2 −1 Makefile
  2. +15 −15 lib/Perl5Interpreter.cs
  3. +19 −0 perl5/build_interop
View
@@ -60,7 +60,8 @@ obj/Perl5Interpreter.dll: obj/Run.Kernel.dll lib/Perl5Interpreter.cs
$(CSC) /target:library /lib:obj /out:obj/Perl5Interpreter.dll /r:Run.Kernel.dll lib/Perl5Interpreter.cs
obj/p5embed.so: lib/p5embed.c
- cc -shared -o obj/p5embed.so lib/p5embed.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
+ perl perl5/build_interop
+
aot: all
mono --aot run/*.dll obj/Run.CORE.dll run/Niecza.exe
@@ -4,49 +4,49 @@
using Niecza.Serialization;
public class Perl5Interpreter : IForeignInterpreter {
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_initialize")]
+ [DllImport("p5embed", EntryPoint="p5embed_initialize")]
public static extern void Initialize();
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_dispose")]
+ [DllImport("p5embed", EntryPoint="p5embed_dispose")]
public static extern void Dispose();
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_eval")]
+ [DllImport("p5embed", EntryPoint="p5embed_eval")]
public static extern IntPtr EvalPerl5(string code);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvIV")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvIV")]
public static extern int SvIV(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvPV_nolen")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvPV_nolen")]
public static extern string SvPV_nolen(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvPVutf8_nolen")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvPVutf8_nolen")]
public static extern IntPtr SvPVutf8_nolen(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvPVutf8_length")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvPVutf8_length")]
public static extern int SvPVutf8_length(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvNV")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvNV")]
public static extern double SvNV(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvIOKp")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvIOKp")]
public static extern int SvIOKp(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvNOKp")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvNOKp")]
public static extern int SvNOKp(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvPOKp")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvPOKp")]
public static extern int SvPOKp(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvOK")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvOK")]
public static extern int SvOK(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_newSVpvn")]
+ [DllImport("p5embed", EntryPoint="p5embed_newSVpvn")]
public static extern IntPtr newSVpvn(IntPtr s,int length);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_SvUTF8_on")]
+ [DllImport("p5embed", EntryPoint="p5embed_SvUTF8_on")]
public static extern void SvUTF8_on(IntPtr sv);
- [DllImport("obj/p5embed.so", EntryPoint="p5embed_subcall")]
+ [DllImport("p5embed", EntryPoint="p5embed_subcall")]
public static extern IntPtr SubCall(
int context,
IntPtr[] arguments,
View
@@ -0,0 +1,19 @@
+#!perl
+use Config;
+use File::Spec::Functions qw(rel2abs);
+my $path = "obj/p5embed.$Config{so}";
+my $full_path = rel2abs($path);
+open(my $config,">obj/Perl5Interpreter.dll.config");
+print $config <<END;
+ <configuration>
+ <dllmap dll="p5embed" target="$full_path" />
+</configuration>
+END
+
+my $ccopts = `perl -MExtUtils::Embed -e ccopts`;
+my $ldopts = `perl -MExtUtils::Embed -e ldopts`;
+chomp($ccopts);
+chomp($ldopts);
+
+my $cc = "$Config{cc} -m32 -shared";
+system("$cc lib/p5embed.c -o $path $ccopts $ldopts");

0 comments on commit bef38b1

Please sign in to comment.