WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/Module/Install/API.pod
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,13 @@ B<inc> command takes a string to be passed to L<ExtUtils::MakeMaker>
as an C<INC> attribute. B<cc_inc_paths> is its alternative, and
takes an array of directories.

=head2 cc_flags (L<Module::Install::Compiler>)

cc_flags '-DFOO';

B<cc_flags> takes a string to be passed to
L<ExtUtils::MakeMaker> as a C<CCFLAGS> attribute.

=head2 cc_optimize_flags (L<Module::Install::Compiler>)

cc_optimize_flags '-O2';
Expand Down
7 changes: 7 additions & 0 deletions lib/Module/Install/Compiler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ sub ppport {
}
}

sub cc_flags {
my $self = shift;
$self->makemaker_args(
CCFLAGS => join ' ', @_
);
}

sub cc_files {
require Config;
my $self = shift;
Expand Down
26 changes: 25 additions & 1 deletion t/21_makemaker_args.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use Test::More;
use File::Spec;
use t::lib::Test;

plan tests => 45;
plan tests => 51;

# Let's see how MakeMaker behaves first

Expand Down Expand Up @@ -168,3 +168,27 @@ END_DSL
ok $inc && $inc =~ m{/usr/opt/include/}, "correct INC";
ok( kill_dist(), 'kill_dist' );
}


# inc
SCOPE: {
ok( create_dist( 'Foo', { 'Makefile.PL' => <<"END_DSL" }), 'create_dist' );
use inc::Module::Install 0.81;
name 'Foo';
perl_version '5.005';
all_from 'lib/Foo.pm';
cc_flags '-DFUN';
cc_files 'foo.c';
WriteAll;
END_DSL

ok( run_makefile_pl(), 'build_dist' );
my $file = makefile();
ok( -f $file, 'Makefile exists' );
my $content = _read($file);
ok( $content,'file is not empty');
my ($ccflags) = $content =~ /^CCFLAGS\s*=\s*(.+)$/m;
diag "CCFLAGS: $ccflags" if $ENV{TEST_VERBOSE};
ok $ccflags && $ccflags =~ m{-DFUN}, "correct CCFLAGS";
ok( kill_dist(), 'kill_dist' );
}