Discussion:
build inline program with pp
Xiao Yafeng
2012-04-18 09:35:46 UTC
Permalink
Hi all,

I have a Inline program which have to be built in visual studio
environment. how can I wrap it in pp? I mean, I don't want the exe which pp
create rebuild C function on other machines.(coz it would fail), just use
what I build.

Please enlighten me. Thanks.
Xiao Yafeng
2012-04-19 16:16:26 UTC
Permalink
well, I decide to translate it into a XS module via C2XS, then "recompile"
to a exe by pp to work around.

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.
Post by Xiao Yafeng
Hi all,
I have a Inline program which have to be built in visual studio
environment. how can I wrap it in pp? I mean, I don't want the exe which pp
create rebuild C function on other machines.(coz it would fail), just use
what I build.
Please enlighten me. Thanks.
Sisyphus
2012-04-20 02:37:17 UTC
Permalink
----- Original Message -----
From: "Xiao Yafeng" <xyf.xiao-***@public.gmane.org>
To: "inline" <inline-***@public.gmane.org>
Sent: Friday, April 20, 2012 2:16 AM
Subject: Re: build inline program with pp
Post by Xiao Yafeng
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.
Post by Xiao Yafeng
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
Xiao Yafeng
2012-04-20 03:11:41 UTC
Permalink
Post by Sisyphus
Sent: Friday, April 20, 2012 2:16 AM
Subject: Re: build inline program with pp
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.
I guess it's because pp changes program file name into a random name. but
no idea how to prove it.
Post by Sisyphus
Should be able to do that - though I don't understand what the
'--par-file' arg is supposed to do.
--par-file could refer to a file containing all parameters needed. IMHO, it
not only reduces command type but also can help us around the issue of
space in pars name.
David Oswald
2012-04-20 04:15:11 UTC
Permalink
Post by Sisyphus
c2xs --m=XYZ --write_makefile_pl=1 --inc=-I/here -I/there --write_pm=1
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.)
...while you're at it... (I'm sure you know what will come next):
InlineX::CPP2XS would benefit from similar treatment.

Would it make sense for the command-line version to exist within the
App:: namespace? App::InlineX::CPP2XS, for example.

As for how it should be invoked... sane defaults, easily overridden
from the command line (my vote).
--
David Oswald
daoswald-***@public.gmane.org
Xiao Yafeng
2012-04-20 04:38:44 UTC
Permalink
Post by David Oswald
Would it make sense for the command-line version to exist within the
App:: namespace? App::InlineX::CPP2XS, for example.
If put under App namespace, I suggest it may be called App::C2XS/
App::CPP2XS, coz it seems not related to Inline, from end user perspective.
Sisyphus
2012-04-21 13:49:56 UTC
Permalink
Hi all,

Just uploaded InlineX-C2XS-0.18 to CPAN.

It contains a utility named 'c2xs'. Give it a try and see what needs doing.

After installing, run 'c2xs --help' for the list of options.

Cheers,
Rob
Xiao Yafeng
2012-04-21 17:14:37 UTC
Permalink
great update! I've tried and it works very well on my machine! thanks, Rob!
Post by Xiao Yafeng
Hi all,
Just uploaded InlineX-C2XS-0.18 to CPAN.
It contains a utility named 'c2xs'. Give it a try and see what needs doing.
After installing, run 'c2xs --help' for the list of options.
Cheers,
Rob
Sisyphus
2012-04-22 09:15:40 UTC
Permalink
----- Original Message -----
From: "Xiao Yafeng" <xyf.xiao-***@public.gmane.org>
To: "Sisyphus" <sisyphus1-sFbbPxZDHXw0n/***@public.gmane.org>
Cc: "David Oswald" <daoswald-***@public.gmane.org>; <inline-***@public.gmane.org>
Sent: Sunday, April 22, 2012 3:14 AM
Subject: Re: build inline program with pp
Post by Xiao Yafeng
great update! I've tried and it works very well on my machine! thanks, Rob!
You're welcome, Xiao !
Let me know if you strike any bugs, or find something you would like to be
done differently.

I'll upload a new InlineX::CPP2XS that contains a similar utility within the
next few days.

Cheers,
Rob

Sisyphus
2012-04-20 09:05:44 UTC
Permalink
----- Original Message -----
From: "David Oswald" <daoswald-***@public.gmane.org>
To: <inline-***@public.gmane.org>; "Sisyphus" <sisyphus1-sFbbPxZDHXw0n/***@public.gmane.org>
Sent: Friday, April 20, 2012 2:15 PM
Subject: Re: build inline program with pp
Post by David Oswald
Post by Sisyphus
c2xs --m=XYZ --write_makefile_pl=1 --inc=-I/here -I/there --write_pm=1
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.)
InlineX::CPP2XS would benefit from similar treatment.
Yes, I'll duplicate it there.
Post by David Oswald
Would it make sense for the command-line version to exist within the
App:: namespace? App::InlineX::CPP2XS, for example.
All I was going to do was have, as part of InlineX::C2XS, a perl script
named 'c2xs' (converted by pl2bat.bat to 'c2xs.bat' for Windows).
It would just check and parse the commandline arguments then, based on those
arguments, make the appropriate call to InlineX::C2XS::c2xs().

Just like h2xs/h2xs.bat, perldoc/perldoc.bat, html2pod/html2pod.bat, etc.,
c2xs/c2xs.bat would be installed into perl/bin (when 'make install' is run
for InlineX::C2XS).

I don't know exactly how to implement that yet but other modules do similar
things - eg PDL has perldl/perldl.bat. I should be able to work out how this
is achieved by studying the way that PDL goes about it.

Cheers,
Rob
David Mertens
2012-04-20 12:25:27 UTC
Permalink
As I understand it, this is built into ExtUtils:MakeMaker and
Module::Build. Scripts in the dist's bin or script directories are added to
some directory in blib and (on Windows) battified.
Post by Sisyphus
Sent: Friday, April 20, 2012 2:15 PM
Subject: Re: build inline program with pp
Post by Sisyphus
c2xs --m=XYZ --write_makefile_pl=1 --inc=-I/here -I/there --write_pm=1
Post by Sisyphus
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.)
InlineX::CPP2XS would benefit from similar treatment.
Yes, I'll duplicate it there.
Would it make sense for the command-line version to exist within the
Post by Sisyphus
App:: namespace? App::InlineX::CPP2XS, for example.
All I was going to do was have, as part of InlineX::C2XS, a perl script
named 'c2xs' (converted by pl2bat.bat to 'c2xs.bat' for Windows).
It would just check and parse the commandline arguments then, based on
those arguments, make the appropriate call to InlineX::C2XS::c2xs().
Just like h2xs/h2xs.bat, perldoc/perldoc.bat, html2pod/html2pod.bat, etc.,
c2xs/c2xs.bat would be installed into perl/bin (when 'make install' is run
for InlineX::C2XS).
I don't know exactly how to implement that yet but other modules do
similar things - eg PDL has perldl/perldl.bat. I should be able to work out
how this is achieved by studying the way that PDL goes about it.
Cheers,
Rob
Loading...