Re: [PATCH] MakeMaker, XS and C++

2003-12-03 Thread Nick Ing-Simmons
Michael G Schwern [EMAIL PROTECTED] writes:
On Thu, Nov 27, 2003 at 03:58:13PM +, Nick Ing-Simmons wrote:
 Does Module::Build do nested modules yet?

Dunno.  Why is this relevant?

Because Tk:: and Audio:: (my two major XS modules on CPAN) are 
both structured that way.

When Module::Build has a way to handle nested modules then 
I as the de-facto XS expert can lead the heard down the M::B route.



Re: [PATCH] MakeMaker, XS and C++

2003-12-03 Thread Michael G Schwern
On Wed, Dec 03, 2003 at 10:50:34AM +, Nick Ing-Simmons wrote:
 Michael G Schwern [EMAIL PROTECTED] writes:
 On Thu, Nov 27, 2003 at 03:58:13PM +, Nick Ing-Simmons wrote:
  Does Module::Build do nested modules yet?
 
 Dunno.  Why is this relevant?
 
 Because Tk:: and Audio:: (my two major XS modules on CPAN) are 
 both structured that way.
 
 When Module::Build has a way to handle nested modules then 
 I as the de-facto XS expert can lead the heard down the M::B route.

Then you'd best get a-patchin'! ;)


-- 
Michael G Schwern[EMAIL PROTECTED]  http://www.pobox.com/~schwern/
What's a classy place like this doing around a low-life like you?


Re: [PATCH] MakeMaker, XS and C++

2003-12-02 Thread Salvador Fandiño
Nicholas Clark wrote:

I don't think that using make is not a problem at all is a valid argument.
ExtUtils::MakeMaker already jumps through a lot of hoops to (try to) make
portable makefiles. For example, we had a load of fun trying to work out
why SDBMFile broke on a MakeMaker change. It worked on Linux, but not
FreeBSD. Not the two most distant OSes in the world.
The perl5 core doesn't have a single Makefile for all of Unix and Win32.
In fact, it doesn't have a single Makefile for Win32. Every make is
different. Sometimes those differences bite.
ok, make has more problems than just existential ones, but that 
does not invalidate my point: using make also has some benefits.

I'm not against Module::Build. I just think that both builders 
can coexist. M::B will be better in some cases and EU::MM in 
others. Let the programmer decide which one he prefers to use.

Perl motto is TMTOWTDI, isn't it?

- Salva.



Re: [PATCH] MakeMaker, XS and C++

2003-12-02 Thread Michael G Schwern
On Fri, Nov 28, 2003 at 07:10:38PM +, Ed Avis wrote:
 On Thu, 27 Nov 2003, Salvador Fandiño wrote:
 
 Actually, most C/C++ developers should feel more comfortable using
 and customizing ExtUtils::MakeMaker/make than Module::Build and not
 because EU::MM has been there forever and M::B is new but because
 they can look at the generated Makefile and understand it.
 
 LOL!

*chuckle*  Yeah, my sentiments exactly.  Like any crufty automated code
generation tool, MM's output is a tad obfuscated.

Anyhow, if we do our job right nobody should have to look at the Makefile.


-- 
Michael G Schwern[EMAIL PROTECTED]  http://www.pobox.com/~schwern/
Stupid am I?  Stupid like a fox!


Re: [PATCH] MakeMaker, XS and C++

2003-12-02 Thread Michael G Schwern
On Thu, Nov 27, 2003 at 03:58:13PM +, Nick Ing-Simmons wrote:
 Does Module::Build do nested modules yet?

Dunno.  Why is this relevant?


-- 
Michael G Schwern[EMAIL PROTECTED]  http://www.pobox.com/~schwern/
The eye opening delightful morning taste of expired cheese bits in sour milk!


Re: [PATCH] MakeMaker, XS and C++

2003-12-02 Thread Michael G Schwern
On Thu, Nov 27, 2003 at 02:04:56AM -0800, Salvador Fandiño wrote:
 well, Module::Build biggest strength is that it?s a pure Perl module
 that doesn't depend on an external tool like make but for C/C++
 modules you will need a development environment anyway and using make
 is not a problem at all.

In this context, Module::Build's strength is that its not a crufty
monster that's being prepped for mothballing.  MM is.  I really have no
desire to add or maintain new functionality to MM.  Especially functionality 
that's missing from Module::Build.  Double especially new functionality that
has to do with compilers, the most frightening, least documented and least
tested part of MM.  Unless you want to debug C++ builds on VMS for me? :)

I really don't want to open this maintenance can of worms without a really
good reason.  I'd suggest you have a look at putting the functionality into
MB instead.  Its really quite a clean architecture.  I've found it
infinately easier to work with than MM. 


 Actually, most C/C++ developers should feel more comfortable using
 and customizing ExtUtils::MakeMaker/make than Module::Build and not
 because EU::MM has been there forever and M::B is new but because
 they can look at the generated Makefile and understand it. 

I've never found the people can understand Makefiles argument terribly
compelling, even if true.  Besides, plain Makefiles aren't portable.


-- 
Michael G Schwern[EMAIL PROTECTED]  http://www.pobox.com/~schwern/
Do not try comedy at home!  Milk  Cheese are advanced experts!  Attempts at
comedy can be dangerously unfunny!


RE: [PATCH] MakeMaker, XS and C++

2003-11-30 Thread Paul Marquess
From: Nick Ing-Simmons [mailto:[EMAIL PROTECTED]

 
 
 Michael G Schwern [EMAIL PROTECTED] writes:
 On Wed, Nov 26, 2003 at 07:40:57PM +, Salvador Fandio wrote:
  A new version of the C++ support for MakeMaker patch is ready.
 
 The more I think about this the more nervous I get at putting 
 all this new
 functionality into MakeMaker in a part that's not very well understood
 (XS module building) 
 
 Some of us understand it ;-)

Indeed. The interface provided by the -C++ option in xsubpp does make it dead easy to 
map a C++ class to the Perl equivalent.

The only issue I had was the lack of generic C++ exception to Perl exception mapping 
code. In the end I had to wrap all my XSUBs in something like this


void
SomeClass::SomeMethod()
INIT:
try {
CLEANUP:
}
catch (err  e)
  {
  // map C++ exception to Perl exception
  }
catch (...)
  {
  // map C++ exception to Perl exception
  }

  
This works fine, but it doesn't half bloat the code. 

Paul



Re: [PATCH] MakeMaker, XS and C++

2003-11-29 Thread Nicholas Clark
On Thu, Nov 27, 2003 at 02:04:56AM -0800, Salvador Fandiño wrote:

 well, Module::Build biggest strength is that it?s a pure Perl module
 that doesn't depend on an external tool like make but for C/C++
 modules you will need a development environment anyway and using make
 is not a problem at all.

I don't think that using make is not a problem at all is a valid argument.
ExtUtils::MakeMaker already jumps through a lot of hoops to (try to) make
portable makefiles. For example, we had a load of fun trying to work out
why SDBMFile broke on a MakeMaker change. It worked on Linux, but not
FreeBSD. Not the two most distant OSes in the world.

The perl5 core doesn't have a single Makefile for all of Unix and Win32.
In fact, it doesn't have a single Makefile for Win32. Every make is
different. Sometimes those differences bite.

More practical things like nested modules and the level of CPAN support
are reasonable reasons. But they need to be addressed in Module::Build,
rather than continuing to add blocks to the top of the MM tower.

Nicholas Clark


Re: [PATCH] MakeMaker, XS and C++

2003-11-27 Thread Michael G Schwern
On Wed, Nov 26, 2003 at 07:40:57PM +, Salvador Fandiño wrote:
 A new version of the C++ support for MakeMaker patch is ready.

The more I think about this the more nervous I get at putting all this new
functionality into MakeMaker in a part that's not very well understood
(XS module building) while I'm trying to wind down development.

Sorry to ask this so late in the process, but is there a good reason this 
couldn't be done with Module::Build instead?  And because lots of people
use MakeMaker isn't one of them.


-- 
Michael G Schwern[EMAIL PROTECTED]  http://www.pobox.com/~schwern/
Playstation?  Of course Perl runs on Playstation.
-- Jarkko Hietaniemi


Re: [PATCH] MakeMaker, XS and C++

2003-11-27 Thread Nick Ing-Simmons
Michael G Schwern [EMAIL PROTECTED] writes:
On Wed, Nov 26, 2003 at 07:40:57PM +, Salvador Fandio wrote:
 A new version of the C++ support for MakeMaker patch is ready.

The more I think about this the more nervous I get at putting all this new
functionality into MakeMaker in a part that's not very well understood
(XS module building) 

Some of us understand it ;-)

while I'm trying to wind down development.

Sorry to ask this so late in the process, but is there a good reason this 
couldn't be done with Module::Build instead?  

I don't think so. 

Does Module::Build do nested modules yet?

And because lots of people
use MakeMaker isn't one of them.



Re: [PATCH] MakeMaker, XS and C++

2003-11-27 Thread Salvador Fandiño
Hi,

A new version of the C++ support for MakeMaker patch is ready.

It's available from here:
  http://www.nondoc.org/perl/mm-cxx-0.11.patch.gz
And the full patched ExtUtil::MakeMaker package is here:
  http://www.nondoc.org/perl/ExtUtils-MakeMaker-6.22_02.tar.gz
I have included most of the changes suggested by Nick Ing-Simmons 
and corrected some problems from the previous version.

It's tested on Linux+gcc and Windows+MSVC and only support for 
these platforms is really fully implemented.

I have added two new modules to ExtUtils:
- ExtUtils::Cxx that looks for the C++ compiler and checks that 
it works
- ExtUtils::Which that looks for an executable file on the path.

To add support for different OS/compiler combination 
ExtUtils::Cxx internal data has to be updated.

MakeMaker looks for the C++ compiler only when C++ sources are 
detected. For C or pure Perl modules MakeMaker does the same as 
before.

Only old C++ modules with hard coded compiler settings should be 
affected or broken by this patch.

Bye,

  - Salvador.



Re: [PATCH] MakeMaker, XS and C++

2003-11-22 Thread Rafael Garcia-Suarez
Michael G Schwern wrote:
 The major reason I've been avoiding putting any XS tests into MakeMaker
 is being able to reliably determine if the user has a working compiler
 and what that compiler is.  Perl has it easy, the user obviously has a
 C compiler, the one they're using to compile perl!

That's of course an easy assumption, but it's not true, esp. if you
use most commercial unixes, which ship with perl but without a compiler
by default.


Re: [PATCH] MakeMaker, XS and C++

2003-11-22 Thread Nick Ing-Simmons
Rafael Garcia-Suarez [EMAIL PROTECTED] writes:
Michael G Schwern wrote:
 The major reason I've been avoiding putting any XS tests into MakeMaker
 is being able to reliably determine if the user has a working compiler
 and what that compiler is.  Perl has it easy, the user obviously has a
 C compiler, the one they're using to compile perl!

That's of course an easy assumption, but it's not true, esp. if you
use most commercial unixes, which ship with perl but without a compiler
by default.

I think you are agreeing with Michael!
His point that when building _perl_ it is appropriate to build an XS test
as we know we have the compiler we are building perl with.
However, for MakeMaker in the wild as you point out the compiler may not 
be present. So install of MakerMaker cannot always pass XS building tests.

However, if someone is trying to build an XS extension they had better
have a compiler. So MakeMaker could have code to probe for compiler 
and find one that works and then pass that on to XS rules for C, C++.
If it can't find one then process can fail at Makefile.PL time 



Re: [PATCH] MakeMaker, XS and C++

2003-11-21 Thread Nick Ing-Simmons
Salvador Fandio [EMAIL PROTECTED] writes:
Hi,

Now that 5.8.2 has been released, Michael G Schwern has accepted to
consider my patch to add support for C++ modules for inclusion on
MakeMaker but he has requested me to get it reviewed by somebody on
here first so...

A new version of the patch is available from here:
  http://www.nondoc.org/perl/cxx-0.10.patch.gz

C++ modules are expected to contain a .xss file instead of the usual
.xs one. That file is preprocessed by xsubpp to a .cpp file and then
compiled by the C++ compiler.

Good patch in general - a few questions/comments:

xsubpp has a -C++ option - is the some reason that you don't use
that when processing a .xss file ?
(I forget what it does in detail but I have found it useful in the past.)

+# Use some heuristics to find the C++ compiler and linker:
+
+if ( $Config{ccname} =~ /gcc/i) {
+  my($vol, $dir, $file) = File::Spec-splitpath($self-{CC});
+  $self-{CXX} ||= $dir eq '' ? 'c++' : File::Spec-join($vol, $dir, 'c++');
+  $self-{CXXLD} ||= $self-{CXX};
+} else {
+  $self-{CXX} ||= $self-{CC};
+  $self-{CXXLD} ||= $self-{LD};
+}
+

If $Config{cc} is 'gcc' you should probaly try/use 'g++' - there may be
a system c++ which does not match the gcc.


+This target is stubbed out.  Not sure why.
+
+=cut
+
+sub xss_o {
+return ''
+}
+

I think because you get less re-re-builds if the rules stack.
i.e. one rule 
.xss - .cpp
and then one 
.cpp - .o 

and let make figure out to chain the two rules.
If you do a direct .xss - .o rule as well make can get confused as 
to which one to use, it may depend if an old .cpp is about from 
an prior run and the guts of rules must match.

+=item CXXLD
+
+Program to be used to link C++ libraries for dynamic loading.
+
+Defaults to $Config{ld}.

I think it should default to being the compiler you found i.e. CXXCMD. 



Two new variables can be used on Makefile.PL: CXX to set the C++
compiler and CXXLD to set the linker to be used for C++ modules. As
there isn't any information available from Config.pm about the C++
compiler, linker, libs, etc., I had to  use some heuristics to find
default values for those variables from the C config. Also, new hints
should be added for compilers others than gcc and MSVC and support
for other vars (CXXFLAGS, CXXLIBS?) could be needed.

The user can also set CXX and CXXLD himself when running Makefile.PL
from the command line (or even set them on CPAN.pm config).

Deducting C++ compiler config from info on Config.pm is not bullet
proof but the only alternative would be to run some kind of
auto-config process, that doesn't seem easy to implement... any
volunteer?

It isn't too hard to have/write a tiny C++ file and try the c++ command
you find.

open(my $fh,test.cpp) || die;
print $fh 'END';
#include iostream
int main(int argc,char *argv[])
{
 std::cout  It works\n;
 return 0;
}
END
close($fh);
if (system($cpp_to_try,test.cpp) == 0)
 {
  # that will do 
 }



Re: [PATCH] MakeMaker, XS and C++

2003-11-21 Thread Fandiño
Hi,

Now that 5.8.2 has been released, Michael G Schwern has accepted to
consider my patch to add support for C++ modules for inclusion on
MakeMaker but he has requested me to get it reviewed by somebody on
here first so...

A new version of the patch is available from here:
  http://www.nondoc.org/perl/cxx-0.10.patch.gz

The full ExtUtils::MakeMaker+patch package is here:
  http://www.nondoc.org/perl/ExtUtils-MakeMaker-6.22_01.tar.gz

An a simple sample C++ module to test here:
  http://www.nondoc.org/perl/CxxTest-0.01.tar.gz

I have already been able to test it on Windows+VC6 and Linux+gcc for
perls 5.6.2, 5.8.0 and 5.8.2.

C++ modules are expected to contain a .xss file instead of the usual
.xs one. That file is preprocessed by xsubpp to a .cpp file and then
compiled by the C++ compiler.

Two new variables can be used on Makefile.PL: CXX to set the C++
compiler and CXXLD to set the linker to be used for C++ modules. As
there isn't any information available from Config.pm about the C++
compiler, linker, libs, etc., I had to  use some heuristics to find
default values for those variables from the C config. Also, new hints
should be added for compilers others than gcc and MSVC and support
for other vars (CXXFLAGS, CXXLIBS?) could be needed.

The user can also set CXX and CXXLD himself when running Makefile.PL
from the command line (or even set them on CPAN.pm config).

Deducting C++ compiler config from info on Config.pm is not bullet
proof but the only alternative would be to run some kind of
auto-config process, that doesn't seem easy to implement... any
volunteer?

Cheers,

  - Salva.



--- Michael G Schwern [EMAIL PROTECTED] wrote:
 On Fri, Nov 14, 2003 at 05:37:33AM -0800, Salvador Fandiño wrote:
Here is the patch for the current version of MakeMaker.

I have updated all the MM_* modules but only tested on Unix.

BTW, I believe there was a bug in the xs_c rule on MM_VMS.pm
 that
   was
missing the .c termination for the generated file. I have
 also
changed it but somebody with more VMS experience should check
 it
   is
ok.
   
   I'm putting this patch on hold because I'm trying to shove a
 stable
   release
   out the door for 5.8.1.  It effects XS voodoo that I don't
   understand and 
   isn't covered by the tests.

   Sorry. :(  I'll consider it after 5.8.1.  Remind me.
  
  5.8.2 is out, so I think it's time to remind you about this patch
 ;-)
 
 Ok, but I still don't understand it.  You've have to get someone
 else on 
 here who groks XS and C++ to look it over.
 
 
 -- 
 Michael G Schwern[EMAIL PROTECTED] 
 http://www.pobox.com/~schwern/
 Cottleston, Cottleston, Cottleston Pie.
 A fly can't bird, but a bird can fly.
 Ask me a riddle and I reply:
 Cottleston, Cottleston, Cottleston Pie.



Re: [PATCH] MakeMaker, XS and C++

2003-11-21 Thread Michael G Schwern
On Fri, Nov 21, 2003 at 10:56:19AM +, Nick Ing-Simmons wrote:
 The only reliable solution would be to include a C++ test module 
 and try to build and check it with different configurations until 
 one succeeds.
 
 Certainly an option - perl has a XS test extension, we could 
 add a C++ test extension to MakeMaker - it does not have to be huge
 after all!

The major reason I've been avoiding putting any XS tests into MakeMaker
is being able to reliably determine if the user has a working compiler
and what that compiler is.  Perl has it easy, the user obviously has a
C compiler, the one they're using to compile perl!

Only if the probing for a compiler can be done without too many false
negatives might I consider it.  Module::Build has something that seems to
be working, it might be worth looking into.


-- 
Michael G Schwern[EMAIL PROTECTED]  http://www.pobox.com/~schwern/
May you eat three balanced meals a day and have healthful, regular bowel 
movements.
-- Gimlet, son of Groin, Bored of the Rings


Re: [PATCH] MakeMaker, XS and C++

2003-11-14 Thread Fandiño
Hi Michael,

--- Michael G Schwern [EMAIL PROTECTED] wrote:
 On Thu, Mar 20, 2003 at 02:16:35AM -0800, Salvador Fandiño wrote:
  Here is the patch for the current version of MakeMaker.
  
  I have updated all the MM_* modules but only tested on Unix.
  
  BTW, I believe there was a bug in the xs_c rule on MM_VMS.pm that
 was
  missing the .c termination for the generated file. I have also
  changed it but somebody with more VMS experience should check it
 is
  ok.
 
 I'm putting this patch on hold because I'm trying to shove a stable
 release
 out the door for 5.8.1.  It effects XS voodoo that I don't
 understand and 
 isn't covered by the tests.
  
 Sorry. :(  I'll consider it after 5.8.1.  Remind me.

5.8.2 is out, so I think it's time to remind you about this patch ;-)

- Salva



Re: [PATCH] MakeMaker, XS and C++

2003-11-14 Thread Michael G Schwern
On Fri, Nov 14, 2003 at 05:37:33AM -0800, Salvador Fandiño wrote:
   Here is the patch for the current version of MakeMaker.
   
   I have updated all the MM_* modules but only tested on Unix.
   
   BTW, I believe there was a bug in the xs_c rule on MM_VMS.pm that
  was
   missing the .c termination for the generated file. I have also
   changed it but somebody with more VMS experience should check it
  is
   ok.
  
  I'm putting this patch on hold because I'm trying to shove a stable
  release
  out the door for 5.8.1.  It effects XS voodoo that I don't
  understand and 
  isn't covered by the tests.
   
  Sorry. :(  I'll consider it after 5.8.1.  Remind me.
 
 5.8.2 is out, so I think it's time to remind you about this patch ;-)

Ok, but I still don't understand it.  You've have to get someone else on 
here who groks XS and C++ to look it over.


-- 
Michael G Schwern[EMAIL PROTECTED]  http://www.pobox.com/~schwern/
Cottleston, Cottleston, Cottleston Pie.
A fly can't bird, but a bird can fly.
Ask me a riddle and I reply:
Cottleston, Cottleston, Cottleston Pie.


Re: [PATCH] MakeMaker, XS and C++

2003-04-03 Thread Michael G Schwern
On Thu, Mar 20, 2003 at 02:16:35AM -0800, Salvador Fandiño wrote:
 Here is the patch for the current version of MakeMaker.
 
 I have updated all the MM_* modules but only tested on Unix.
 
 BTW, I believe there was a bug in the xs_c rule on MM_VMS.pm that was
 missing the .c termination for the generated file. I have also
 changed it but somebody with more VMS experience should check it is
 ok.

I'm putting this patch on hold because I'm trying to shove a stable release
out the door for 5.8.1.  It effects XS voodoo that I don't understand and 
isn't covered by the tests.
 
Sorry. :(  I'll consider it after 5.8.1.  Remind me.


-- 
Congratulations, you're a thieving bastard... Now give me back my pants.
That's MISTER Pants!
-- Ian's Adventures In Morrowind
   http://www.machall.com/morrowind/page3.html