-
-
Save plicease/4e64a414fb175a9358ee3dc50a0f8ba3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Path::Tiny qw( path ); | |
use ExtUtils::CBuilder; | |
use ExtUtils::ParseXS; | |
path('Foo.xs')->spew(<<'EOF'); | |
#include "EXTERN.h" | |
#include "perl.h" | |
#include "XSUB.h" | |
MODULE = Foo PACKAGE = Foo | |
const char *hello() | |
CODE: | |
RETVAL = "hello world\n"; | |
OUTPUT: | |
RETVAL | |
EOF | |
ExtUtils::ParseXS->new->process_file( | |
filename => 'Foo.xs', | |
output => 'Foo.c', | |
versioncheck => 0, | |
prototypes => 0, | |
); | |
my $cb = ExtUtils::CBuilder->new; | |
my $obj = $cb->compile( | |
source => 'Foo.c', | |
extra_compile_flags => [], | |
); | |
my $lib = $cb->link( | |
objects => [$obj], | |
module_name => 'Foo', | |
extra_linker_flags => [], | |
); | |
die 'link returned undef' unless defined $lib; | |
print "lib = $lib\n"; | |
die 'link returned file not there' unless -f $lib; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment