Skip to content

Commit 010f61f

Browse files
jeffhostetlerdscho
authored andcommitted
msvc: update Makefile and compiler settings for VS2015
Signed-off-by: Jeff Hostetler <[email protected]>
1 parent a4df7c2 commit 010f61f

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ endif
11051105

11061106
ifdef SANE_TOOL_PATH
11071107
SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH))
1108-
BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|'
1108+
BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix "$(SANE_TOOL_PATH_SQ)"|'
11091109
PATH := $(SANE_TOOL_PATH):${PATH}
11101110
else
11111111
BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'

config.mak.uname

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ endif
331331
ifeq ($(uname_S),Windows)
332332
GIT_VERSION := $(GIT_VERSION).MSVC
333333
pathsep = ;
334+
# Prepend MSVC 64-bit tool-chain to PATH.
335+
#
336+
# A regular Git Bash *does not* have cl.exe in its $PATH. As there is a
337+
# link.exe next to, and required by, cl.exe, we have to prepend this
338+
# onto the existing $PATH.
339+
#
340+
SANE_TOOL_PATH ?= /c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64
334341
HAVE_ALLOCA_H = YesPlease
335342
NO_PREAD = YesPlease
336343
NEEDS_CRYPTO_WITH_SSL = YesPlease
@@ -347,7 +354,13 @@ ifeq ($(uname_S),Windows)
347354
NO_ICONV = YesPlease
348355
NO_STRTOUMAX = YesPlease
349356
NO_MKDTEMP = YesPlease
350-
SNPRINTF_RETURNS_BOGUS = YesPlease
357+
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
358+
# so we don't need this.
359+
#
360+
# TODO If we want to support older compilers, we need to make this
361+
# TODO conditional on the compiler version.
362+
#
363+
# SNPRINTF_RETURNS_BOGUS = YesPlease
351364
NO_SVN_TESTS = YesPlease
352365
RUNTIME_PREFIX = YesPlease
353366
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
@@ -370,22 +383,46 @@ ifeq ($(uname_S),Windows)
370383
CC = compat/vcbuild/scripts/clink.pl
371384
AR = compat/vcbuild/scripts/lib.pl
372385
CFLAGS =
373-
BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
386+
BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
374387
COMPAT_OBJS = compat/msvc.o compat/winansi.o \
375388
compat/win32/pthread.o compat/win32/syslog.o \
376389
compat/win32/dirent.o compat/win32/fscache.o
377-
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
390+
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
378391
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
379-
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj
392+
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
380393
PTHREAD_LIBS =
381394
lib =
395+
# Path to the unpacked third-party libraries
396+
MSVC_DEPS = compat/vcbuild/GEN.DEPS
397+
# Compensate for lack of %VCINSTALLDIR%, %LIB%, %LIBPATH%, and etc.
398+
# since vcvars*.bat did not get a chance to setup the environment of
399+
# the user's shell window.
400+
#
401+
# TODO If we ask the user to launch a "x64 Native" command prompt
402+
# TODO and then have it start a git-bash window, these could be
403+
# TODO inherited. So we wouldn't need to add these lines here.
404+
#
405+
MSVC_SDK81 = "c:/Program Files (x86)/Windows Kits/8.1"
406+
MSVC_SDK10 = "c:/Program Files (x86)/Windows Kits/10"
407+
MSVC_VCDIR = "c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC"
408+
BASIC_CFLAGS += \
409+
-I$(MSVC_DEPS)/include -I$(MSVC_DEPS)/include/expat -I$(MSVC_DEPS)/include/zlib \
410+
-L$(MSVC_DEPS)/lib \
411+
-I$(MSVC_SDK81)/Include/um -I$(MSVC_SDK81)/Include/shared \
412+
-L$(MSVC_SDK81)/lib/winv6.3/um/x64 \
413+
-I$(MSVC_SDK10)/Include/10.0.10240.0/ucrt \
414+
-L$(MSVC_SDK10)/lib/10.0.10240.0/ucrt/x64 \
415+
-I$(MSVC_VCDIR)/INCLUDE \
416+
-L$(MSVC_VCDIR)/lib/amd64
417+
# Optionally enable memory leak reporting.
418+
# BASIC_CLFAGS += -DUSE_MSVC_CRTDBG
382419
BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1
383420
ifndef DEBUG
384421
BASIC_CFLAGS += -GL -Os -MD
385422
BASIC_LDFLAGS += -LTCG
386423
AR += -LTCG
387424
else
388-
BASIC_CFLAGS += -Zi -MDd
425+
BASIC_CFLAGS += -Zi -MDd -DDEBUG -D_DEBUG
389426
endif
390427
X = .exe
391428

git-compat-util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#ifndef GIT_COMPAT_UTIL_H
22
#define GIT_COMPAT_UTIL_H
33

4+
#ifdef USE_MSVC_CRTDBG
5+
/*
6+
* For these to work they must appear very early in each
7+
* file -- before most of the standard header files.
8+
*/
9+
#include <stdlib.h>
10+
#include <crtdbg.h>
11+
#endif
12+
413
#define _FILE_OFFSET_BITS 64
514

615

0 commit comments

Comments
 (0)