2009-09-16 10:20:28 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
######################################################################
|
|
|
|
# Compiles or links files
|
|
|
|
#
|
|
|
|
# This is a wrapper to facilitate the compilation of Git with MSVC
|
|
|
|
# using GNU Make as the build system. So, instead of manipulating the
|
|
|
|
# Makefile into something nasty, just to support non-space arguments
|
|
|
|
# etc, we use this wrapper to fix the command line options
|
|
|
|
#
|
|
|
|
# Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com>
|
|
|
|
######################################################################
|
|
|
|
use strict;
|
|
|
|
my @args = ();
|
|
|
|
my @cflags = ();
|
|
|
|
my $is_linking = 0;
|
|
|
|
while (@ARGV) {
|
|
|
|
my $arg = shift @ARGV;
|
|
|
|
if ("$arg" =~ /^-[DIMGO]/) {
|
|
|
|
push(@cflags, $arg);
|
|
|
|
} elsif ("$arg" eq "-o") {
|
|
|
|
my $file_out = shift @ARGV;
|
|
|
|
if ("$file_out" =~ /exe$/) {
|
|
|
|
$is_linking = 1;
|
|
|
|
push(@args, "-OUT:$file_out");
|
|
|
|
} else {
|
|
|
|
push(@args, "-Fo$file_out");
|
|
|
|
}
|
|
|
|
} elsif ("$arg" eq "-lz") {
|
|
|
|
push(@args, "zlib.lib");
|
|
|
|
} elsif ("$arg" eq "-liconv") {
|
|
|
|
push(@args, "iconv.lib");
|
2009-10-21 19:04:51 +02:00
|
|
|
} elsif ("$arg" eq "-lcrypto") {
|
|
|
|
push(@args, "libeay32.lib");
|
|
|
|
push(@args, "ssleay32.lib");
|
2009-09-16 10:20:28 +02:00
|
|
|
} elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") {
|
|
|
|
$arg =~ s/^-L/-LIBPATH:/;
|
|
|
|
push(@args, $arg);
|
|
|
|
} elsif ("$arg" =~ /^-R/) {
|
|
|
|
# eat
|
|
|
|
} else {
|
|
|
|
push(@args, $arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($is_linking) {
|
|
|
|
unshift(@args, "link.exe");
|
|
|
|
} else {
|
|
|
|
unshift(@args, "cl.exe");
|
|
|
|
push(@args, @cflags);
|
|
|
|
}
|
|
|
|
#printf("**** @args\n");
|
Fix the exit code of MSVC build scripts on cygwin
During an MSVC build on cygwin, the make program did not notice
when the compiler or linker exited with an error. This was caused
by the scripts exiting with the value returned by system() directly.
On POSIX-like systems, such as cygwin, the return value of system()
has the exit code of the executed command encoded in the first byte
(ie the value is shifted up by 8 bits). This allows the bottom
7 bits to contain the signal number of a terminated process, while
the eighth bit indicates whether a core-dump was produced. (A value
of -1 indicates that the command failed to execute.)
The make program, however, expects the exit code to be encoded in the
bottom byte. Futhermore, it apparently masks off and ignores anything
in the upper bytes.
However, these scripts are (naturally) intended to be used on the
windows platform, where we can not assume POSIX-like semantics from
a perl implementation (eg ActiveState). So, in general, we can not
assume that shifting the return value right by eight will get us
the exit code.
In order to improve portability, we assume that a zero return from
system() indicates success, whereas anything else indicates failure.
Since we don't need to know the exact exit code from the compiler
or linker, we simply exit with 0 (success) or 1 (failure).
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-08 17:33:31 +02:00
|
|
|
exit (system(@args) != 0);
|