blob: ccfe4ee182e14a71c593d8989bf56b1f8dabea54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#! perl -w
BEGIN {
if ($ENV{PERL_CORE}) {
chdir 't' if -d 't';
chdir '../lib/ExtUtils/CBuilder'
or die "Can't chdir to lib/ExtUtils/CBuilder: $!";
@INC = qw(../..);
}
}
use strict;
use Test;
BEGIN {
if ($^O eq 'MSWin32') {
print "1..0 # Skipped: link_executable() is not implemented yet on Win32\n";
exit;
}
if ($^O eq 'VMS') {
# So we can get the return value of system()
require vmsish;
import vmsish;
}
plan tests => 5;
}
use ExtUtils::CBuilder;
use File::Spec;
# TEST doesn't like extraneous output
my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
my $b = ExtUtils::CBuilder->new(quiet => $quiet);
ok $b;
my $source_file = File::Spec->catfile('t', 'compilet.c');
{
local *FH;
open FH, "> $source_file" or die "Can't create $source_file: $!";
print FH "int main(void) { return 11; }\n";
close FH;
}
ok -e $source_file;
# Compile
my $object_file;
ok $object_file = $b->compile(source => $source_file);
# Link
my ($exe_file, @temps);
($exe_file, @temps) = $b->link_executable(objects => $object_file);
ok $exe_file;
# Try the executable
ok my_system($exe_file), 11;
# Clean up
unlink $source_file;
sub my_system {
my $cmd = shift;
if ($^O eq 'VMS') {
return system("mcr $cmd");
}
return system($cmd) >> 8;
}
|