Skip to content

Commit 610e060

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge pull request #2974 from derrickstolee/maintenance-and-headless
Include Windows-specific maintenance and headless-git
2 parents f51340a + dd08e68 commit 610e060

File tree

7 files changed

+107
-10
lines changed

7 files changed

+107
-10
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -3778,12 +3778,15 @@ ifdef MSVC
37783778
$(RM) $(patsubst %.o,%.o.pdb,$(OBJECTS))
37793779
$(RM) headless-git.o.pdb
37803780
$(RM) $(patsubst %.exe,%.pdb,$(OTHER_PROGRAMS))
3781+
$(RM) $(patsubst %.exe,%.ilk,$(OTHER_PROGRAMS))
37813782
$(RM) $(patsubst %.exe,%.iobj,$(OTHER_PROGRAMS))
37823783
$(RM) $(patsubst %.exe,%.ipdb,$(OTHER_PROGRAMS))
37833784
$(RM) $(patsubst %.exe,%.pdb,$(PROGRAMS))
3785+
$(RM) $(patsubst %.exe,%.ilk,$(PROGRAMS))
37843786
$(RM) $(patsubst %.exe,%.iobj,$(PROGRAMS))
37853787
$(RM) $(patsubst %.exe,%.ipdb,$(PROGRAMS))
37863788
$(RM) $(patsubst %.exe,%.pdb,$(TEST_PROGRAMS))
3789+
$(RM) $(patsubst %.exe,%.ilk,$(TEST_PROGRAMS))
37873790
$(RM) $(patsubst %.exe,%.iobj,$(TEST_PROGRAMS))
37883791
$(RM) $(patsubst %.exe,%.ipdb,$(TEST_PROGRAMS))
37893792
$(RM) compat/vcbuild/MSVC-DEFS-GEN

compat/vcbuild/find_vs_env.bat

+7
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ REM ================================================================
9999

100100
SET sdk_dir=%WindowsSdkDir%
101101
SET sdk_ver=%WindowsSDKVersion%
102+
SET sdk_ver_bin_dir=%WindowsSdkVerBinPath%%tgt%
102103
SET si=%sdk_dir%Include\%sdk_ver%
103104
SET sdk_includes=-I"%si%ucrt" -I"%si%um" -I"%si%shared"
104105
SET sl=%sdk_dir%lib\%sdk_ver%
@@ -130,6 +131,7 @@ REM ================================================================
130131

131132
SET sdk_dir=%WindowsSdkDir%
132133
SET sdk_ver=%WindowsSDKVersion%
134+
SET sdk_ver_bin_dir=%WindowsSdkVerBinPath%bin\amd64
133135
SET si=%sdk_dir%Include\%sdk_ver%
134136
SET sdk_includes=-I"%si%ucrt" -I"%si%um" -I"%si%shared" -I"%si%winrt"
135137
SET sl=%sdk_dir%lib\%sdk_ver%
@@ -160,6 +162,11 @@ REM ================================================================
160162
echo msvc_includes=%msvc_includes%
161163
echo msvc_libs=%msvc_libs%
162164

165+
echo sdk_ver_bin_dir=%sdk_ver_bin_dir%
166+
SET X1=%sdk_ver_bin_dir:C:=/C%
167+
SET X2=%X1:\=/%
168+
echo sdk_ver_bin_dir_msys=%X2%
169+
163170
echo sdk_includes=%sdk_includes%
164171
echo sdk_libs=%sdk_libs%
165172

compat/vcbuild/scripts/clink.pl

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
my @lflags = ();
1616
my $is_linking = 0;
1717
my $is_debug = 0;
18+
my $is_gui = 0;
1819
while (@ARGV) {
1920
my $arg = shift @ARGV;
2021
if ("$arg" eq "-DDEBUG") {
@@ -67,7 +68,11 @@
6768
}
6869
push(@args, $lib);
6970
} elsif ("$arg" eq "-lexpat") {
71+
if ($is_debug) {
72+
push(@args, "libexpatd.lib");
73+
} else {
7074
push(@args, "libexpat.lib");
75+
}
7176
} elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") {
7277
$arg =~ s/^-L/-LIBPATH:/;
7378
push(@lflags, $arg);
@@ -119,11 +124,23 @@
119124
push(@cflags, "-wd4996");
120125
} elsif ("$arg" =~ /^-W[a-z]/) {
121126
# let's ignore those
127+
} elsif ("$arg" eq "-fno-stack-protector") {
128+
# eat this
129+
} elsif ("$arg" eq "-mwindows") {
130+
$is_gui = 1;
122131
} else {
123132
push(@args, $arg);
124133
}
125134
}
126135
if ($is_linking) {
136+
if ($is_gui) {
137+
push(@args, "-ENTRY:wWinMainCRTStartup");
138+
push(@args, "-SUBSYSTEM:WINDOWS");
139+
} else {
140+
push(@args, "-ENTRY:wmainCRTStartup");
141+
push(@args, "-SUBSYSTEM:CONSOLE");
142+
}
143+
127144
push(@args, @lflags);
128145
unshift(@args, "link.exe");
129146
} else {

compat/vcbuild/scripts/rc.pl

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/perl -w
2+
######################################################################
3+
# Compile Resources on Windows
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+
######################################################################
11+
use strict;
12+
my @args = ();
13+
my @input = ();
14+
15+
while (@ARGV) {
16+
my $arg = shift @ARGV;
17+
if ("$arg" =~ /^-[dD]/) {
18+
# GIT_VERSION gets passed with too many
19+
# layers of dquote escaping.
20+
$arg =~ s/\\"/"/g;
21+
22+
push(@args, $arg);
23+
24+
} elsif ("$arg" eq "-i") {
25+
my $arg = shift @ARGV;
26+
# TODO complain if NULL or is dashed ??
27+
push(@input, $arg);
28+
29+
} elsif ("$arg" eq "-o") {
30+
my $arg = shift @ARGV;
31+
# TODO complain if NULL or is dashed ??
32+
push(@args, "-fo$arg");
33+
34+
} else {
35+
push(@args, $arg);
36+
}
37+
}
38+
39+
push(@args, "-nologo");
40+
push(@args, "-v");
41+
push(@args, @input);
42+
43+
unshift(@args, "rc.exe");
44+
printf("**** @args\n");
45+
46+
exit (system(@args) != 0);

config.mak.uname

+4-2
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ ifeq ($(uname_S),Windows)
440440
# link.exe next to, and required by, cl.exe, we have to prepend this
441441
# onto the existing $PATH.
442442
#
443-
SANE_TOOL_PATH ?= $(msvc_bin_dir_msys)
443+
SANE_TOOL_PATH ?= $(msvc_bin_dir_msys):$(sdk_ver_bin_dir_msys)
444444
HAVE_ALLOCA_H = YesPlease
445445
NO_PREAD = YesPlease
446446
NEEDS_CRYPTO_WITH_SSL = YesPlease
@@ -502,12 +502,14 @@ endif
502502
compat/win32/trace2_win32_process_info.o \
503503
compat/win32/dirent.o
504504
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DENSURE_MSYSTEM_IS_SET -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
505-
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
505+
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO
506506
# invalidcontinue.obj allows Git's source code to close the same file
507507
# handle twice, or to access the osfhandle of an already-closed stdout
508508
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
509509
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
510+
GITLIBS += git.res
510511
PTHREAD_LIBS =
512+
RC = compat/vcbuild/scripts/rc.pl
511513
lib =
512514
BASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)
513515
ifndef DEBUG

contrib/buildsystems/Generators/Vcxproj.pm

+25-3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ sub createProject {
8989
$defines =~ s/>/>/g;
9090
$defines =~ s/\'//g;
9191

92+
my $rcdefines = $defines;
93+
$rcdefines =~ s/(?<!\\)"/\\$&/g;
94+
95+
my $entrypoint = 'wmainCRTStartup';
96+
my $subsystem = 'Console';
97+
if (grep /^-mwindows$/, @{$$build_structure{"$prefix${name}_LFLAGS"}}) {
98+
$entrypoint = 'wWinMainCRTStartup';
99+
$subsystem = 'Windows';
100+
}
101+
92102
my $dir = $vcxproj;
93103
$dir =~ s/\/[^\/]*$//;
94104
die "Could not create the directory $dir for $label project!\n" unless (-d "$dir" || mkdir "$dir");
@@ -176,9 +186,9 @@ sub createProject {
176186
<AdditionalLibraryDirectories>\$(VCPKGLibDirectory);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
177187
<AdditionalDependencies>\$(VCPKGLibs);\$(AdditionalDependencies)</AdditionalDependencies>
178188
<AdditionalOptions>invalidcontinue.obj %(AdditionalOptions)</AdditionalOptions>
179-
<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>
189+
<EntryPointSymbol>$entrypoint</EntryPointSymbol>
180190
<ManifestFile>$cdup\\compat\\win32\\git.manifest</ManifestFile>
181-
<SubSystem>Console</SubSystem>
191+
<SubSystem>$subsystem</SubSystem>
182192
</Link>
183193
EOM
184194
if ($target eq 'libgit') {
@@ -203,6 +213,9 @@ EOM
203213
<PreprocessorDefinitions>WIN32;_DEBUG;$defines;%(PreprocessorDefinitions)</PreprocessorDefinitions>
204214
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
205215
</ClCompile>
216+
<ResourceCompile>
217+
<PreprocessorDefinitions>WIN32;_DEBUG;$rcdefines;%(PreprocessorDefinitions)</PreprocessorDefinitions>
218+
</ResourceCompile>
206219
<Link>
207220
<GenerateDebugInformation>true</GenerateDebugInformation>
208221
</Link>
@@ -216,6 +229,9 @@ EOM
216229
<FunctionLevelLinking>true</FunctionLevelLinking>
217230
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
218231
</ClCompile>
232+
<ResourceCompile>
233+
<PreprocessorDefinitions>WIN32;NDEBUG;$rcdefines;%(PreprocessorDefinitions)</PreprocessorDefinitions>
234+
</ResourceCompile>
219235
<Link>
220236
<GenerateDebugInformation>true</GenerateDebugInformation>
221237
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -225,9 +241,15 @@ EOM
225241
<ItemGroup>
226242
EOM
227243
foreach(@sources) {
228-
print F << "EOM";
244+
if (/\.rc$/) {
245+
print F << "EOM";
246+
<ResourceCompile Include="$_" />
247+
EOM
248+
} else {
249+
print F << "EOM";
229250
<ClCompile Include="$_" />
230251
EOM
252+
}
231253
}
232254
print F << "EOM";
233255
</ItemGroup>

contrib/buildsystems/engine.pl

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ sub parseMakeOutput
165165
next;
166166
}
167167

168-
if($text =~ / -c /) {
168+
if($text =~ / -c / || $text =~ / -i \S+\.rc /) {
169169
# compilation
170170
handleCompileLine($text, $line);
171171

@@ -263,16 +263,15 @@ sub handleCompileLine
263263
if ("$part" eq "-o") {
264264
# ignore object file
265265
shift @parts;
266-
} elsif ("$part" eq "-c") {
266+
} elsif ("$part" eq "-c" || "$part" eq "-i" || "$part" =~ /^-fno-/) {
267267
# ignore compile flag
268-
} elsif ("$part" eq "-c") {
269268
} elsif ($part =~ /^.?-I/) {
270269
push(@incpaths, $part);
271270
} elsif ($part =~ /^.?-D/) {
272271
push(@defines, $part);
273272
} elsif ($part =~ /^-/) {
274273
push(@cflags, $part);
275-
} elsif ($part =~ /\.(c|cc|cpp)$/) {
274+
} elsif ($part =~ /\.(c|cc|cpp|rc)$/) {
276275
$sourcefile = $part;
277276
} else {
278277
die "Unhandled compiler option @ line $lineno: $part";
@@ -359,7 +358,7 @@ sub handleLinkLine
359358
push(@libs, $part);
360359
} elsif ($part eq 'invalidcontinue.obj') {
361360
# ignore - known to MSVC
362-
} elsif ($part =~ /\.o$/) {
361+
} elsif ($part =~ /\.(o|res)$/) {
363362
push(@objfiles, $part);
364363
} elsif ($part =~ /\.obj$/) {
365364
# do nothing, 'make' should not be producing .obj, only .o files
@@ -373,6 +372,7 @@ sub handleLinkLine
373372
my $sourcefile = $_;
374373
$sourcefile =~ s/^headless-git\.o$/compat\/win32\/headless.c/;
375374
$sourcefile =~ s/\.o$/.c/;
375+
$sourcefile =~ s/\.res$/.rc/;
376376
push(@sources, $sourcefile);
377377
push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}});
378378
push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}});

0 commit comments

Comments
 (0)