Re: build inline program with pp

[email protected] ("Sisyphus")
Newsgroups perl.inline
Message-ID <570972BBDD334047841BEFEE7C9B4DC1@desktop2>
----- Original Message ----- 
From: "Xiao Yafeng" <[email protected]>
To: "inline" <[email protected]>
Sent: Friday, April 20, 2012 2:16 AM
Subject: Re: build inline program with pp


> well, I decide to translate it into a XS module via C2XS, then "recompile"
> to a exe by pp to work around.

That's the way I would do it, too.

There's actually a bug report about the PAR & Inline problem at
https://rt.cpan.org/Public/Bug/Display.html?id=17415

and a simple patch:

###########################
--- Inline.pm 1 Feb 2006 11:12:52 -0000 1.1
+++ Inline.pm 1 Feb 2006 15:10:56 -0000
@@ -453,10 +453,12 @@
     $o->{API}{modpname} = File::Spec->catdir(@modparts);

     my $suffix = $Config{dlext};
+    unless ($ENV{PAR_INITIALIZED}) {
     my $obj = File::Spec->catfile($realpath,'auto',$o->{API}{modpname},
                                   "$o->{API}{modfname}.$suffix");
     croak M30_error_no_obj($o->{CONFIG}{NAME}, $o->{API}{pkg},
       $realpath) unless -f $obj;
+    }

     @{$o->{CONFIG}}{qw( PRINT_INFO
    REPORTBUG
#############################

I don't know exactly what problem that solves, but I can't see how it would 
solve the issues with 'pp'. (Though I don't think I've actually tested it.)

I did once fiddle about with pp and Inline, and got it to work. I now forget 
the details.

You would probably want to use the 'NAME' config option in the Inline 
script - that way you know in advance the name of the _Inline/lib/auto 
folder that contains the binaries, and the names of the files inside that 
folder.

Then I think it's a matter of getting pp to pack in those files, in such a 
way that the Inline script can locate them.

> anyways, thanks!
>
> BTW: just a thought, can we make c2xs program(not a function) like cpanm
> does?
>
> c2xs --package-name XYZ --module-name XYZ --par-file parfile --source-file
> etc...
>
> it would be more handy.

Should be able to do that - though I don't understand what the '--par-file' 
arg is supposed to do.

I'd probably have it such that you'd do:

c2xs --p=XYZ --m=XYZ --bd=./build

If not supplied, the --bd arg (which specifies the build directory - where 
the created files will be written to) would default to '.', and the --p arg 
would default to whatever --m is. The --m arg would be compulsory.

Any additional args would just be the same as the args supplied to the hash 
reference that c2xs() takes as its last argument.

eg:

c2xs --m=XYZ --write_makefile_pl=1 --inc=-I/here -I/there --write_pm=1
would equate to:
c2xs('XYZ', 'XYZ', '.', {WRITE_MAKEFILE_PL=>1, INC=>'-I/here -I/there', 
WRITE_PM=>1});

Would that be ok ? If not, let me know - I don't have any definite rules 
about this. (Error checking would be built in, of course.)

The fact that some of the allowable options can contain whitespace (such as 
INC in the above example) adds to the challenge - but I  can handle that 
without too much trouble, I think.

Cheers,
Rob
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.