Permalink
Browse files

* Raw import of HsPerl5 0.0.6.

  • Loading branch information...
1 parent 961c88d commit 4034f2e76c12eb06c0d0c2646f23a93b865e1113 @audreyt audreyt committed Apr 13, 2010
Showing with 926 additions and 0 deletions.
  1. +86 −0 HsPerl5/Configure.PL
  2. +35 −0 HsPerl5/HsPerl5.cabal
  3. +18 −0 HsPerl5/LICENSE
  4. +13 −0 HsPerl5/README
  5. +8 −0 HsPerl5/Setup.lhs
  6. +353 −0 HsPerl5/p5embed.c
  7. +45 −0 HsPerl5/p5embed.h
  8. +16 −0 HsPerl5/perlxsi.c
  9. +302 −0 HsPerl5/src/Language/Perl5.hs
  10. +50 −0 HsPerl5/test.hs
View
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+
+use 5.006;
+use strict;
+use Cwd;
+use Config;
+use ExtUtils::Embed;
+
+my $embed_flags = "-I" . cwd();
+my $ccdlflags = "";
+my $flags = "$Config{ccflags} $Config{ccdlflags} ";
+
+if ($flags =~ /\S/) {
+ $flags =~ s{([\\"'])}{\\$1}g;
+ my @flags = grep { length $_ } split /\s+/, $flags;
+
+ if ($^O eq 'MSWin32') {
+ if ($Config{libperl} =~ /lib(\w+)\.a/) {
+ $embed_flags .= " -optl-l$1 ";
+ }
+ elsif (defined &Win32::BuildNumber) {
+ # We are on ActivePerl -- Kluge massively!
+
+ no warnings 'once';
+ our %MY_CONFIG = %Config;
+ *Config = *MY_CONFIG;
+ *Config::Config = *MY_CONFIG;
+ *ExtUtils::MM_Win32::Config = *MY_CONFIG;
+ *ExtUtils::MM_Unix::Config = *MY_CONFIG;
+
+ $Config{ccflags} =~ s/-libpath:"?(.*?)"? //g;
+ $Config{ccdlflags} =~ s/-libpath:"?(.*?)"? //g;
+ $Config{lddlflags} =~ s/-libpath:"?(.*?)"? //g;
+ $Config{ldflags} =~ s/-libpath:"?(.*?)"? //g
+ or die "ldflags: $Config{ldflags} does not contain -libpath:";
+
+ my $lib = "$1/$Config{libperl}";
+ $embed_flags .= " -optl\"$lib\" ";
+
+ $flags = "$Config{ccflags} $Config{ccdlflags}";
+ $flags =~ s{([\\"'])}{\\$1}g;
+ @flags = grep { length $_ } split /\s+/, $flags;
+ }
+ else {
+ warn "Unrecognized libperl shared library: $Config{libperl}, proceeding anyway...\n";
+ }
+
+ $ccdlflags .= (/^-[DIL]/ ? ' -optc' : ' -optl') . qq["$_" ] for @flags;
+ $embed_flags .= " -optc-Ddirent=DIRENT";
+ }
+ else {
+ $embed_flags .= " -optc$_" for grep length, split(/\s+/, ccopts());
+ $embed_flags .= " -optl$_" for grep length, split(/\s+/, ldopts());
+ }
+
+ $embed_flags .= " $_" for grep { /-[DIL]/ } split(/\s+/, ccopts());
+ $embed_flags .= " $_" for grep { /-[DIL]/ } split(/\s+/, ldopts());
+
+ if ($Config{osname} eq 'cygwin') {
+ my $cygpath = sub {
+ my $path = `cygpath -m @_`;
+ chomp $path;
+ return $path;
+ };
+ $embed_flags =~ s{(/usr/\S+)}{$cygpath->($1)}eg;
+ $embed_flags =~ s{/cygdrive/(\w)/}{$1:/}g;
+ #warn "** Cygwin embedding flags: embed_flags\n";
+ }
+}
+
+my @include_dirs = split(/\s+/, perl_inc());
+s/^-I// for @include_dirs;
+
+my @cc_options = map { /^-optc(.+)/ ? $1 : () } (split(/\s+/, $embed_flags), split(/\s+/, $ccdlflags));
+my @ld_options = map { /^-optl(.+)/ ? $1 : () } (split(/\s+/, $embed_flags), split(/\s+/, $ccdlflags));
+
+open INFO, ">HsPerl5.buildinfo" or die "Cannot write build info: $!";
+print INFO << ".";
+ghc-options: $embed_flags $ccdlflags
+include-dirs: @include_dirs
+cc-options: @cc_options
+ld-options: @ld_options
+.
+close INFO;
+
+xsinit();
View
@@ -0,0 +1,35 @@
+name: HsPerl5
+version: 0.0.6
+copyright: 2008 Audrey Tang
+license: BSD3
+license-file: LICENSE
+author: Audrey Tang <audreyt@audreyt.org>
+maintainer: Audrey Tang <audreyt@audreyt.org>
+synopsis: Haskell interface to embedded Perl 5 interpreter
+
+description: This module provides a Haskell interface to embedded Perl 5 interpreter.
+
+ Documentation and functionality is scarce at the moment; see test.hs for
+ some basic usage examples.
+
+ Currently supported features are:
+ * Function calls
+ * Method calls
+ * Module imports
+ * Callbacks
+
+ Eventually, the entirety of Pugs.Embed.Perl5 and Pugs.Run.Perl5 will be
+ carried into this module.
+
+stability: experimental
+build-type: Custom
+extensions: ForeignFunctionInterface, TypeSynonymInstances,
+ ScopedTypeVariables, FlexibleInstances,
+ UndecidableInstances, OverlappingInstances, IncoherentInstances
+exposed-modules: Language.Perl5
+build-depends: base
+extra-source-files: README test.hs Configure.PL p5embed.h perlxsi.c
+hs-source-dirs: src
+category: Language, Pugs
+c-sources: p5embed.c
+includes: p5embed.h
View
@@ -0,0 +1,18 @@
+Copyright 2008 by Audrey Tang
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,13 @@
+This module provides a Haskell interface to embedded Perl 5 interpreter.
+
+Documentation and functionality is scarce at the moment; see test.hs for
+some basic usage examples.
+
+Currently supported features are:
+ * Function calls
+ * Method calls
+ * Module imports
+ * Callbacks
+
+Eventually the entirety of Pugs.Embed.Perl5 and Pugs.Run.Perl5 will be
+carried into this module.
View
@@ -0,0 +1,8 @@
+#!/usr/bin/env runghc
+> import Distribution.Simple
+> import System.Cmd (rawSystem)
+>
+> main :: IO ()
+> main = writeBuildInfo >> defaultMainWithHooks defaultUserHooks
+> where
+> writeBuildInfo = rawSystem "perl" ["Configure.PL"]
Oops, something went wrong.

0 comments on commit 4034f2e

Please sign in to comment.