ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ExtUtils-CXX/CXX.pm
(Generate patch)

Comparing ExtUtils-CXX/CXX.pm (file contents):
Revision 1.1 by root, Mon Aug 14 04:30:22 2017 UTC vs.
Revision 1.4 by root, Sun Nov 18 01:23:04 2018 UTC

43 43
44(There is also a C<$PERL_CXX> which takes precedence over C<$CXX>). 44(There is also a C<$PERL_CXX> which takes precedence over C<$CXX>).
45 45
46The important thing is that the chosen C++ compiler compiles files with 46The important thing is that the chosen C++ compiler compiles files with
47a F<.c> ending as C++ - a generic compiler wrapper such as F<gcc> that 47a F<.c> ending as C++ - a generic compiler wrapper such as F<gcc> that
48detects the lafguage by the file extension will I<not> work. 48detects the language by the file extension will I<not> work.
49 49
50In the absence of these variables, it will do the following 50In the absence of these variables, it will do the following
51transformations on what it guesses will be the compiler name: 51transformations on what it guesses will be the compiler name:
52 52
53 gcc => g++ 53 gcc => g++
64 64
65package ExtUtils::CXX; 65package ExtUtils::CXX;
66 66
67use common::sense; 67use common::sense;
68 68
69our $VERSION = 0.02; 69our $VERSION = '1.0';
70 70
71use parent Exporter::; 71use Exporter 'import';
72 72
73our @EXPORT = qw(extutils_cxx); 73our @EXPORT = qw(extutils_cxx);
74
75use ExtUtils::MakeMaker::Config ();
74 76
75=item extutils_cxx BLOCK; 77=item extutils_cxx BLOCK;
76 78
77This function temporarily does hideous things so you can call 79This function temporarily does hideous things so you can call
78C<WriteMakefile> or similar functions in the BLOCK normally. See the 80C<WriteMakefile> or similar functions in the BLOCK normally. See the
88 xlc => "xlC", 90 xlc => "xlC",
89 cc => "g++", 91 cc => "g++",
90 c89 => "g++", 92 c89 => "g++",
91); 93);
92 94
95our $PREFIX = qr{(?:\S+[\/\\])? (?:ccache|distcc)}x;
96
93sub _ccrepl { 97sub _ccrepl {
94 my ($cfgvar, $env) = @_; 98 my ($cfgvar, $env) = @_;
95 99
96 my $tie = tied %Config; 100 my $tie = tied %Config;
97 101
102 if ($env) { 106 if ($env) {
103 $val =~ s/^\S+/$env/; 107 $val =~ s/^\S+/$env/;
104 } else { 108 } else {
105 keys %cc; 109 keys %cc;
106 while (my ($k, $v) = each %cc) { 110 while (my ($k, $v) = each %cc) {
107 $val =~ s/^ (\S*[\/\\])? $k (-|\s|\d|$) /$1$v$2/x 111 $val =~ s/^ ((?:$PREFIX\s+)? \S*[\/\\])? $k (-|\s|\d|$) /$1$v$2/x
108 and goto done; 112 and goto done;
109 } 113 }
110 114
111 $val =~ s/^\S+/g++/; 115 $val =~ s/^($PREFIX\s+)? \S+/$1g++/x;
112 116
113 done: ; 117 done: ;
114 } 118 }
115 119
116 $tie->{$cfgvar} = $val; 120 $tie->{$cfgvar} = $val;
124 128
125 my $tie = tied %Config; 129 my $tie = tied %Config;
126 130
127 # now dive into internals of Config and temporarily patch those values 131 # now dive into internals of Config and temporarily patch those values
128 132
129 $tie->{ld} = "/uasr/bin/gcc-4.6 -O";
130 local $tie->{cc} = $Config{cc}; _ccrepl cc => "CXX"; 133 local $tie->{cc} = $Config{cc}; _ccrepl cc => "CXX";
131 local $tie->{ld} = $Config{ld}; _ccrepl ld => ($ENV{PERL_CXXLD} ? "CXXLD" : "CXX"); 134 local $tie->{ld} = $Config{ld}; _ccrepl ld => ($ENV{PERL_CXXLD} ? "CXXLD" : "CXX");
135
136 local $ExtUtils::MakeMaker::Config::Config{cc} = $tie->{cc};
137 local $ExtUtils::MakeMaker::Config::Config{ld} = $tie->{ld};
132 138
133 eval { 139 eval {
134 $cb->(); 140 $cb->();
135 }; 141 };
136 die if $@; 142 die if $@;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines