mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-16 00:01:05 -08:00
195 lines
4.5 KiB
Perl
195 lines
4.5 KiB
Perl
#!/usr/local/perl
|
|
# $HopeName: MMQA_harness!script:compile(trunk.22) $
|
|
#
|
|
# 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";
|
|
}
|
|
}
|
|
|
|
sub compiler_settings {
|
|
if ($PLATFORM =~ "^nt_") {
|
|
&settings_nt();
|
|
if ($PLATFORM =~ "^nt_x86_cap") {
|
|
&settings_nt_cap();
|
|
} elsif ($PLATFORM =~ "^nt_x86_coff") {
|
|
&settings_nt_coff();
|
|
}
|
|
} elsif ($PLATFORM =~ "^so|^linux") {
|
|
&settings_unix();
|
|
if ($PLATFORM =~ "^sos8gp") {
|
|
&settings_gprof();
|
|
}
|
|
} elsif ($PLATFORM =~ "::unix") {
|
|
&logcomment("I don't know anything specific about $PLATFORM --");
|
|
&logcomment("using generic unix/gcc settings.");
|
|
&settings_unix();
|
|
} else {
|
|
die "Sorry: I don't know how to use ".$PLATFORM."\n";
|
|
}
|
|
}
|
|
|
|
sub settings_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_def = "/D";
|
|
$cc_defeq = "=";
|
|
$cc_conly = "/c";
|
|
$cc_obj = "/Fo";
|
|
$cc_exe = "/Fe";
|
|
$cc_objandexe = 1;
|
|
$obj_suffix = ".obj";
|
|
$try_command = "";
|
|
$catcommand = "$script_dir/ntx86bin/cat.exe";
|
|
$comwrap = "\"";
|
|
$comwrapend = "\"";
|
|
$stdout_red = ">";
|
|
$err_red = "2>";
|
|
$stdout_dup = "| $script_dir/ntx86bin/tee.exe";
|
|
$stdin_red = "<";
|
|
}
|
|
|
|
sub settings_nt_cap {
|
|
$cc_opts = "$cc_opts /Gh";
|
|
$cc_link = "$cc_link CAP.lib";
|
|
$cc_link_opts = "/link /NODEFAULTLIB:LIBCMT /debugtype:coff /debug:mapped,partial";
|
|
}
|
|
|
|
sub settings_nt_coff {
|
|
$cc_link_opts = "/link /NODEFAULTLIB:LIBCMT /debugtype:coff /debug:full";
|
|
}
|
|
|
|
sub settings_unix {
|
|
$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";
|
|
$cc_include = "-I$testlib_dir -I$MPS_INCLUDE_DIR";
|
|
$cc_def = "-D";
|
|
$cc_defeq = "=";
|
|
$cc_conly = "-c";
|
|
$cc_obj = "-o ";
|
|
$cc_exe = "-o ";
|
|
$cc_objandexe = 0;
|
|
$obj_suffix = ".o";
|
|
$try_command = "sh -c ";
|
|
$catcommand = "cat";
|
|
$comwrap = "sh -c \"ulimit -c 0; ";
|
|
$comwrapend = "\"";
|
|
$stdout_red = ">";
|
|
$err_red = "2>";
|
|
$stdout_dup = "| tee";
|
|
$stdin_red = "<";
|
|
}
|
|
|
|
sub settings_gprof {
|
|
$cc_opts = "-pg ".$cc_opts;
|
|
}
|
|
|
|
sub mysystem {
|
|
local ($command) = @_;
|
|
$command =~ s/(\S)\//$1$dirsep/g;
|
|
&debug("SYSTEM >>$command<<");
|
|
system($command);
|
|
}
|
|
|
|
sub log_system {
|
|
local ($command, $output, $logfile, $stdin, $time0, $time1) = @_;
|
|
|
|
$std_log = "$obj_dir/std_log.log";
|
|
$err_log = "$obj_dir/err_log.log";
|
|
|
|
&debug("LOG SYSTEM:\n c>$command\n i<$stdin\n o>$output\n l>$logfile");
|
|
|
|
if ($stdin eq "STDIN") {
|
|
$stdin = "";
|
|
} else {
|
|
$stdin = $stdin_red." ".$stdin;
|
|
}
|
|
|
|
$time0 = time;
|
|
|
|
if ($logfile ne "no") {
|
|
if ($output eq "no") {
|
|
&mysystem("$comwrap$command$comwrapend $stdin $stdout_red $std_log $err_red $err_log");
|
|
} else {
|
|
&mysystem("$comwrap$command$comwrapend $stdin $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 $stdin");
|
|
}
|
|
}
|
|
$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, $hashdefs) = @_;
|
|
|
|
&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";
|
|
|
|
$hashdefs = "";
|
|
foreach (keys %parmdefs) {
|
|
$hashdefs .= $cc_def.$_.$cc_defeq.$parmdefs{$_}." ";
|
|
}
|
|
chop $hashdefs;
|
|
|
|
if ($cc_objandexe) {
|
|
$comobjfspec = "$cc_obj$objfile "
|
|
} else {
|
|
$comobjfspec = ""
|
|
}
|
|
|
|
$command = "$cc_command $cc_opts $hashdefs $comobjfspec$cc_exe$exefile ".
|
|
"$srcfile $linkfiles $MPS_LINK_OBJ $cc_link $cc_include $cc_link_opts";
|
|
|
|
if (&mysystem($command)) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|