mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-17 00:30:37 -08:00
160 lines
3.5 KiB
Perl
160 lines
3.5 KiB
Perl
#!/usr/local/perl
|
|
#
|
|
# provides subroutines to compile or compile and link
|
|
# tests and test libraries.
|
|
#
|
|
# it should work at least on SunOS, Solaris and NT
|
|
#
|
|
|
|
1;
|
|
|
|
sub debug {
|
|
local ($text) = @_;
|
|
if ($DEBUG_INFO eq "on") {
|
|
print $text."\n";
|
|
}
|
|
}
|
|
|
|
%plat_link = ();
|
|
$plat_link{"sol2.4_sparc"} = "-lm";
|
|
|
|
sub compiler_settings {
|
|
if ($PLATFORM =~ "^nt_") {
|
|
$cc_command = "cl";
|
|
$cc_opts = "/DWIN32 /D_WINDOWS /W3 /Z7 /DMMQA_VERS_$INTERFACE_VERSION";
|
|
$cc_link = "$obj_dir/platform.o";
|
|
$cc_include = "/I$testlib_dir /I$MPS_INCLUDE_DIR";
|
|
$cc_conly = "/c";
|
|
$cc_obj = "/Fo";
|
|
$cc_exe = "/Fe";
|
|
$obj_suffix = ".obj";
|
|
$try_command = "";
|
|
} elsif ($PLATFORM =~ "^(sun|sol)") {
|
|
if ($PLATFORM =~ "^sol") {
|
|
$cc_link = "$obj_dir/platform.o -lm";
|
|
} else {
|
|
$cc_link = "$obj_dir/platform.o";
|
|
}
|
|
$cc_command = "gcc";
|
|
$cc_opts = "-ansi -pedantic -Wall -Wstrict-prototypes ".
|
|
"-Winline -Waggregate-return -Wnested-externs -Wcast-qual ".
|
|
"-Wshadow -Wmissing-prototypes -Wredundant-decls -Wcast-align ".
|
|
"-O -g -ggdb3 -DMMQA_VERS_$INTERFACE_VERSION";
|
|
$cc_include = "-I$testlib_dir -I$MPS_INCLUDE_DIR";
|
|
$cc_conly = "-c";
|
|
$cc_obj = "-o ";
|
|
$cc_exe = "-o ";
|
|
$obj_suffix = ".o";
|
|
$try_command = "sh -c ";
|
|
} else {
|
|
die "Sorry: I don't know how to compile on ".$PLATFORM."\n";
|
|
}
|
|
}
|
|
|
|
sub log_settings {
|
|
if ($PLATFORM =~ "^nt_") {
|
|
|
|
} elsif ($PLATFORM =~ "^(sun|sol)") {
|
|
$catcommand = "cat";
|
|
$comwrap = "sh -c \"ulimit -c 0; ";
|
|
$comwrapend = "\"";
|
|
$stdout_red = ">";
|
|
$err_red = "2>";
|
|
$stdout_dup = "| tee";
|
|
} else {
|
|
die "Sorry: I don't know how to take log files on ".$PLATFORM."n";
|
|
}
|
|
}
|
|
|
|
sub mysystem {
|
|
local ($command) = @_;
|
|
&debug("SYSTEM >>$command<<");
|
|
system($command);
|
|
}
|
|
|
|
sub log_system {
|
|
local ($command, $output, $logfile, $time0, $time1) = @_;
|
|
|
|
&log_settings;
|
|
$std_log = "$obj_dir/std_log.log";
|
|
$err_log = "$obj_dir/err_log.log";
|
|
|
|
&debug("LOG SYSTEM:\n c>$command\n o>$output\n l>$logfile");
|
|
|
|
$time0 = time;
|
|
|
|
if ($logfile) {
|
|
if ($output eq "no") {
|
|
&mysystem("$comwrap$command$comwrapend $stdout_red $std_log $err_red $err_log");
|
|
} else {
|
|
&mysystem("$comwrap$command$comwrapend $err_red $err_log $stdout_dup $std_log");
|
|
# there's no way to duplicate std_err as far as I know.
|
|
&mysystem("$catcommand $err_log");
|
|
}
|
|
&mysystem("$catcommand $std_log $err_log $stdout_red $logfile");
|
|
} else {
|
|
if ($output eq "no") {
|
|
ERROR;
|
|
} else {
|
|
&mysystem("$comwrap$command$comwrapend");
|
|
}
|
|
}
|
|
$time1 = time;
|
|
$testtotaltime = $time1-$time0;
|
|
}
|
|
|
|
sub compile {
|
|
local($srcfile, $objfile) = @_;
|
|
|
|
&compiler_settings;
|
|
$command = "$cc_command $cc_conly $cc_opts $cc_obj$objfile ".
|
|
"$srcfile $cc_include";
|
|
|
|
if (&mysystem($command)) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
sub compile_and_link {
|
|
local($srcfile, $exefile, $linkfiles) = @_;
|
|
|
|
&compiler_settings;
|
|
$linkfiles = " ".$linkfiles;
|
|
$linkfiles =~ s/ +/ $obj_dir\//g;
|
|
$linkfiles = $linkfiles." ";
|
|
$linkfiles =~ s/\.o /$obj_suffix /g;
|
|
|
|
$command = "$cc_command $cc_opts $cc_exe$exefile $srcfile ".
|
|
"$linkfiles $MPS_LINK_OBJ $cc_link $cc_include";
|
|
|
|
if (&mysystem($command)) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
sub try_test {
|
|
local ($exefile) = @_;
|
|
|
|
$testlogfile = "$obj_dir/tmp_log.log";
|
|
&log_system($exefile, "yes", $testlogfile);
|
|
|
|
&read_results($testlogfile);
|
|
&verdict;
|
|
&describe_test("result");
|
|
}
|
|
|
|
sub run_test {
|
|
local ($exefile) = @_;
|
|
|
|
$testlogfile = "$obj_dir/tmp_log.log";
|
|
&log_system($exefile, "no", $testlogfile);
|
|
|
|
&read_results($testlogfile);
|
|
&verdict;
|
|
&describe_test("full");
|
|
}
|
|
|