1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-16 08:10:43 -08:00
emacs/mps/qa/test/script/compile
Richard Tucker e88921e864 Add support for profiling on nt with cap
Copied from Perforce
 Change: 19560
 ServerID: perforce.ravenbrook.com
1998-06-01 17:01:16 +01:00

165 lines
4 KiB
Perl

#!/usr/local/perl
# $HopeName: MMQA_harness!script:compile(trunk.19) $
#
# 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_") {
$dirsep = "\\";
$cc_command = "cl";
$cc_opts = "/nologo /DWIN32 /D_WINDOWS /W3 /Zi /Oy- /DMMQA_VERS_$INTERFACE_VERSION";
$cc_link = "$obj_dir/platform.obj";
$cc_link_opts = "/link /NODEFAULTLIB:LIBCMT /debugtype:both /pdb:none /debug:full";
$cc_include = "/I$testlib_dir /I$MPS_INCLUDE_DIR";
$cc_conly = "/c";
$cc_obj = "/Fo";
$cc_exe = "/Fe";
$cc_objandexe = 1;
$obj_suffix = ".obj";
$try_command = "";
if ($PLATFORM eq "nt_x86_cap") {
$cc_opts = "$cc_opts /Gh";
$cc_link = "$cc_link CAP.lib";
$cc_link_opts = "/link /NODEFAULTLIB:LIBCMT /debugtype:coff /debug:mapped,partial";
} elsif ($PLATFORM eq "nt_x86_coff") {
$cc_link_opts = "/link /NODEFAULTLIB:LIBCMT /debugtype:coff /debug:full";
}
} elsif ($PLATFORM =~ "^so") {
$dirsep = "/";
$cc_link = "$obj_dir/platform.o -lm";
$cc_link_opts = "-z muldefs";
$cc_command = "gcc";
$cc_opts = "-ansi -pedantic -Wall -Wstrict-prototypes ".
"-Winline -Waggregate-return -Wnested-externs -Wcast-qual ".
"-Wshadow -Wmissing-prototypes -Wcast-align ".
"-O -g -ggdb3 -DMMQA_VERS_$INTERFACE_VERSION";
if ($PLATFORM eq "sos8gp") {
$cc_opts = "-pg ".$cc_opts;
}
$cc_include = "-I$testlib_dir -I$MPS_INCLUDE_DIR";
$cc_conly = "-c";
$cc_obj = "-o ";
$cc_exe = "-o ";
$cc_objandexe = 0;
$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_") {
$catcommand = "cat";
$comwrap = "\"";
$comwrapend = "\"";
$stdout_red = ">";
$err_red = "2>";
$stdout_dup = "| $script_dir/ntx86bin/tee.exe";
} elsif ($PLATFORM =~ "^so") {
$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) = @_;
$command =~ s/(\S)\//$1$dirsep/g;
&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 ne "no") {
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") {
die "Silly attempt to run test and ignore results.\n";
} 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, $objfile) = @_;
&compiler_settings;
unless ($linkfiles) {$linkfiles =""};
$linkfiles = " ".$linkfiles;
$linkfiles =~ s/ +(\S)/ $obj_dir\/$1/g;
$linkfiles = $linkfiles." ";
$linkfiles =~ s/\.o /$obj_suffix /g;
$objfile = "$obj_dir/tmp_obj$obj_suffix";
if ($cc_objandexe) {
$comobjfspec = "$cc_obj$objfile "
} else {
$comobjfspec = ""
}
$command = "$cc_command $cc_opts $comobjfspec$cc_exe$exefile ".
"$srcfile $linkfiles $MPS_LINK_OBJ $cc_link $cc_include $cc_link_opts";
if (&mysystem($command)) {
return 0;
} else {
return 1;
}
}