]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl -w | |
2 | ###################################################################### | |
3 | # Compiles or links files | |
4 | # | |
5 | # This is a wrapper to facilitate the compilation of Git with MSVC | |
6 | # using GNU Make as the build system. So, instead of manipulating the | |
7 | # Makefile into something nasty, just to support non-space arguments | |
8 | # etc, we use this wrapper to fix the command line options | |
9 | # | |
10 | # Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com> | |
11 | ###################################################################### | |
12 | use strict; | |
13 | my @args = (); | |
14 | my @cflags = (); | |
15 | my @lflags = (); | |
16 | my $is_linking = 0; | |
17 | my $is_debug = 0; | |
18 | while (@ARGV) { | |
19 | my $arg = shift @ARGV; | |
20 | if ("$arg" eq "-DDEBUG") { | |
21 | # Some vcpkg-based libraries have different names for release | |
22 | # and debug versions. This hack assumes that -DDEBUG comes | |
23 | # before any "-l*" flags. | |
24 | $is_debug = 1; | |
25 | } | |
26 | if ("$arg" =~ /^-[DIMGOZ]/) { | |
27 | push(@cflags, $arg); | |
28 | } elsif ("$arg" eq "-o") { | |
29 | my $file_out = shift @ARGV; | |
30 | if ("$file_out" =~ /exe$/) { | |
31 | $is_linking = 1; | |
32 | # Create foo.exe and foo.pdb | |
33 | push(@args, "-OUT:$file_out"); | |
34 | } else { | |
35 | # Create foo.o and foo.o.pdb | |
36 | push(@args, "-Fo$file_out"); | |
37 | push(@args, "-Fd$file_out.pdb"); | |
38 | } | |
39 | } elsif ("$arg" eq "-lz") { | |
40 | if ($is_debug) { | |
41 | push(@args, "zlibd.lib"); | |
42 | } else{ | |
43 | push(@args, "zlib.lib"); | |
44 | } | |
45 | } elsif ("$arg" eq "-liconv") { | |
46 | push(@args, "libiconv.lib"); | |
47 | } elsif ("$arg" eq "-lcrypto") { | |
48 | push(@args, "libcrypto.lib"); | |
49 | } elsif ("$arg" eq "-lssl") { | |
50 | push(@args, "libssl.lib"); | |
51 | } elsif ("$arg" eq "-lcurl") { | |
52 | my $lib = ""; | |
53 | # Newer vcpkg definitions call this libcurl_imp.lib; Do we | |
54 | # need to use that instead? | |
55 | foreach my $flag (@lflags) { | |
56 | if ($flag =~ /^-LIBPATH:(.*)/) { | |
57 | foreach my $l ("libcurl_imp.lib", "libcurl.lib") { | |
58 | if (-f "$1/$l") { | |
59 | $lib = $l; | |
60 | last; | |
61 | } | |
62 | } | |
63 | } | |
64 | } | |
65 | push(@args, $lib); | |
66 | } elsif ("$arg" eq "-lexpat") { | |
67 | push(@args, "expat.lib"); | |
68 | } elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") { | |
69 | $arg =~ s/^-L/-LIBPATH:/; | |
70 | push(@lflags, $arg); | |
71 | } elsif ("$arg" =~ /^-[Rl]/) { | |
72 | # eat | |
73 | } elsif ("$arg" eq "-Werror") { | |
74 | push(@cflags, "-WX"); | |
75 | } elsif ("$arg" eq "-Wall") { | |
76 | # cl.exe understands -Wall, but it is really overzealous | |
77 | push(@cflags, "-W4"); | |
78 | # disable the "signed/unsigned mismatch" warnings; our source code violates that | |
79 | push(@cflags, "-wd4018"); | |
80 | push(@cflags, "-wd4245"); | |
81 | push(@cflags, "-wd4389"); | |
82 | # disable the "unreferenced formal parameter" warning; our source code violates that | |
83 | push(@cflags, "-wd4100"); | |
84 | # disable the "conditional expression is constant" warning; our source code violates that | |
85 | push(@cflags, "-wd4127"); | |
86 | # disable the "const object should be initialized" warning; these warnings affect only objects that are `static` | |
87 | push(@cflags, "-wd4132"); | |
88 | # disable the "function/data pointer conversion in expression" warning; our source code violates that | |
89 | push(@cflags, "-wd4152"); | |
90 | # disable the "non-constant aggregate initializer" warning; our source code violates that | |
91 | push(@cflags, "-wd4204"); | |
92 | # disable the "cannot be initialized using address of automatic variable" warning; our source code violates that | |
93 | push(@cflags, "-wd4221"); | |
94 | # disable the "possible loss of data" warnings; our source code violates that | |
95 | push(@cflags, "-wd4244"); | |
96 | push(@cflags, "-wd4267"); | |
97 | # disable the "array is too small to include a terminating null character" warning; we ab-use strings to initialize OIDs | |
98 | push(@cflags, "-wd4295"); | |
99 | # disable the "'<<': result of 32-bit shift implicitly converted to 64 bits" warning; our source code violates that | |
100 | push(@cflags, "-wd4334"); | |
101 | # disable the "declaration hides previous local declaration" warning; our source code violates that | |
102 | push(@cflags, "-wd4456"); | |
103 | # disable the "declaration hides function parameter" warning; our source code violates that | |
104 | push(@cflags, "-wd4457"); | |
105 | # disable the "declaration hides global declaration" warning; our source code violates that | |
106 | push(@cflags, "-wd4459"); | |
107 | # disable the "potentially uninitialized local variable '<name>' used" warning; our source code violates that | |
108 | push(@cflags, "-wd4701"); | |
109 | # disable the "unreachable code" warning; our source code violates that | |
110 | push(@cflags, "-wd4702"); | |
111 | # disable the "potentially uninitialized local pointer variable used" warning; our source code violates that | |
112 | push(@cflags, "-wd4703"); | |
113 | # disable the "assignment within conditional expression" warning; our source code violates that | |
114 | push(@cflags, "-wd4706"); | |
115 | # disable the "'inet_ntoa': Use inet_ntop() or InetNtop() instead" warning; our source code violates that | |
116 | push(@cflags, "-wd4996"); | |
117 | } elsif ("$arg" =~ /^-W[a-z]/) { | |
118 | # let's ignore those | |
119 | } else { | |
120 | push(@args, $arg); | |
121 | } | |
122 | } | |
123 | if ($is_linking) { | |
124 | push(@args, @lflags); | |
125 | unshift(@args, "link.exe"); | |
126 | } else { | |
127 | unshift(@args, "cl.exe"); | |
128 | push(@args, @cflags); | |
129 | } | |
130 | printf(STDERR "**** @args\n\n\n") if (!defined($ENV{'QUIET_GEN'})); | |
131 | exit (system(@args) != 0); |