7 # So we can get the return value of system()
12 use ExtUtils::CBuilder;
15 # TEST does not like extraneous output
16 my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
17 my ($source_file, $object_file, $lib_file);
19 my $b = ExtUtils::CBuilder->new(quiet => $quiet);
22 if ( ! $b->have_compiler ) {
23 plan skip_all => "no compiler available for testing";
29 ok $b, "created EU::CB object";
31 ok $b->have_compiler, "have_compiler";
33 $source_file = File::Spec->catfile('t', 'compilet.c');
36 open FH, "> $source_file" or die "Can't create $source_file: $!";
37 print FH "int boot_compilet(void) { return 1; }\n";
40 ok -e $source_file, "source file '$source_file' created";
42 $object_file = $b->object_file($source_file);
45 is $object_file, $b->compile(source => $source_file);
47 $lib_file = $b->lib_file($object_file);
50 my ($lib, @temps) = $b->link(objects => $object_file,
51 module_name => 'compilet');
55 for ($source_file, $object_file, $lib_file) {
61 1 while unlink 'COMPILET.LIS';
62 1 while unlink 'COMPILET.OPT';
65 my @words = $b->split_like_shell(' foo bar');
68 skip "MSWindows", 3 if $^O =~ m/MSWin/;
70 is( $words[0], 'foo' );
71 is( $words[1], 'bar' );
74 # include_dirs should be settable as string or list
78 @ISA = ('ExtUtils::CBuilder');
81 if ($^O eq "MSWin32") {
82 # ExtUtils::CBuilder::MSVC::write_compiler_script() puts the
83 # include_dirs into a response file and not the commandline
85 next unless /^\@"(.*)"$/;
86 open(my $fh, "<", $1) or next;
88 $saw = 1 if <$fh> =~ /another dir/;
92 $saw = 1 if grep {$_ =~ /another dir/} @_;
98 $s->compile(source => 'foo',
99 include_dirs => 'another dir');
103 $s->compile(source => 'foo',
104 include_dirs => ['a dir', 'another dir']);