Merge pull request #773 from jeffhostetler/vs2015

Build with VS2015
This commit is contained in:
Johannes Schindelin
2017-01-10 23:37:31 +01:00
17 changed files with 827 additions and 24 deletions

View File

@@ -1227,6 +1227,160 @@ static char *path_lookup(const char *cmd, char **path, int exe_only)
return prog;
}
#if defined(_MSC_VER)
/*
* Build an environment block combining the inherited environment
* merged with the given list of settings.
*
* Values of the form "KEY=VALUE" in deltaenv override inherited values.
* Values of the form "KEY" in deltaenv delete inherited values.
*
* We return a contiguous block of UNICODE strings with a final trailing
* zero word.
*/
static wchar_t *make_environment_block(char **deltaenv)
{
/*
* The CRT (at least as of UCRT) secretly declares "_wenviron"
* as a function that returns a pointer to a mostly static table.
* Grab the pointer and cache it for the duration of our loop.
*/
extern wchar_t **_wenviron;
const wchar_t **my_wenviron = _wenviron;
/*
* Internally, we create normal 'C' arrays of strings (pointing
* into the blocks) to help with some of the de-dup work.
*/
wchar_t **wptrs_ins = NULL;
wchar_t **wptrs_del = NULL;
wchar_t *wblock_ins = NULL;
wchar_t *wblock_del = NULL;
wchar_t *wend_ins;
wchar_t *wend_del;
wchar_t *w_ins;
wchar_t *w_del;
int maxlen = 0;
int nr_delta = 0;
int nr_delta_ins = 0;
int nr_delta_del = 0;
int nr_wenv = 0;
int j, k, k_ins, k_del;
/*
* Count the number of inserts and deletes in the deltaenv list.
* Allocate 'C' arrays for inserts and deletes.
* Also estimate the block size of our results.
*/
if (deltaenv && deltaenv[0] && *deltaenv[0]) {
for (k = 0; deltaenv && deltaenv[k] && *deltaenv[k]; k++) {
if (strchr(deltaenv[k], '=') == NULL)
nr_delta_del++;
else {
maxlen += strlen(deltaenv[k]) + 1;
nr_delta_ins++;
}
}
if (nr_delta_ins)
wptrs_ins = (wchar_t**)calloc(nr_delta_ins + 1, sizeof(wchar_t*));
if (nr_delta_del)
wptrs_del = (wchar_t**)calloc(nr_delta_del + 1, sizeof(wchar_t*));
nr_delta = nr_delta_ins + nr_delta_del;
}
while (my_wenviron && my_wenviron[nr_wenv] && *my_wenviron[nr_wenv])
maxlen += wcslen(my_wenviron[nr_wenv++]) + 1;
maxlen++;
/*
* Allocate blocks for inserted and deleted items.
* The individual pointers in the 'C' arrays will point into here.
* We will use the wblock_ins as the final result.
*/
if (nr_delta_del) {
wblock_del = (wchar_t*)calloc(maxlen, sizeof(wchar_t));
wend_del = wblock_del + maxlen;
w_del = wblock_del;
}
wblock_ins = (wchar_t*)calloc(maxlen, sizeof(wchar_t));
wend_ins = wblock_ins + maxlen;
w_ins = wblock_ins;
/*
* deltaenv values override inherited environment, so put them
* in the result list first (so that we can de-dup using the
* wide versions of them.
*
* Items in the deltaenv list that DO NOT contain an "=" are
* treated as unsetenv.
*
* I'm going assume that there are no duplicates in deltaenv itself.
*/
k_ins = 0;
k_del = 0;
for (k = 0; k < nr_delta; k++) {
if (strchr(deltaenv[k], '=') == NULL) {
wptrs_del[k_del++] = w_del;
w_del += xutftowcs(w_del, deltaenv[k], (wend_del - w_del));
*w_del++ = L'='; /* append '=' to make lookup easier in next step. */
*w_del++ = 0;
} else {
wptrs_ins[k_ins++] = w_ins;
w_ins += xutftowcs(w_ins, deltaenv[k], (wend_ins - w_ins)) + 1;
}
}
assert(k_ins == nr_delta_ins);
assert(k_del == nr_delta_del);
/*
* Walk the inherited environment and copy over unique, non-deleted
* ones into the result set. Note that we only have to de-dup WRT
* the values from deltaenv, because the inherited set should be unique.
*/
for (j = 0; j < nr_wenv; j++) {
const wchar_t *v_j = my_wenviron[j];
wchar_t *v_j_eq = wcschr(v_j, L'=');
int len_j_eq, len_j;
if (!v_j_eq)
continue; /* should not happen */
len_j_eq = v_j_eq + 1 - v_j; /* length(v_j) including '=' */
/* lookup v_j in list of to-delete vars */
for (k_del = 0; k_del < nr_delta_del; k_del++) {
if (wcsnicmp(v_j, wptrs_del[k_del], len_j_eq) == 0)
goto skip_it;
}
/* lookup v_j in deltaenv portion of result set */
for (k_ins = 0; k_ins < nr_delta_ins; k_ins++) {
if (wcsnicmp(v_j, wptrs_ins[k_ins], len_j_eq) == 0)
goto skip_it;
}
/* item is unique, add it to results. */
len_j = wcslen(v_j);
memcpy(w_ins, v_j, len_j * sizeof(wchar_t));
w_ins += len_j + 1;
skip_it:
;
}
if (wptrs_ins)
free(wptrs_ins);
if (wptrs_del)
free(wptrs_del);
if (wblock_del)
free(wblock_del);
return wblock_ins;
}
#else
static int do_putenv(char **env, const char *name, int size, int free_old);
/* used number of elements of environ array, including terminating NULL */
@@ -1273,6 +1427,7 @@ static wchar_t *make_environment_block(char **deltaenv)
free(tmpenv);
return wenvblk;
}
#endif
static void do_unset_environment_variables(void)
{
@@ -1478,7 +1633,10 @@ static int try_shell_exec(const char *cmd, char *const *argv)
prog = path_lookup(interpr, path, 1);
if (prog) {
int argc = 0;
const char **argv2;
#ifndef _MSC_VER
const
#endif
char **argv2;
while (argv[argc]) argc++;
ALLOC_ARRAY(argv2, argc + 1);
argv2[0] = (char *)cmd; /* full path to the script file */
@@ -1554,6 +1712,70 @@ int mingw_kill(pid_t pid, int sig)
return -1;
}
#if defined(_MSC_VER)
/* UTF8 versions of getenv and putenv (and unsetenv).
* Internally, they use the CRT's stock UNICODE routines
* to avoid data loss.
*
* Unlike the mingw version, we DO NOT directly write to
* the CRT variables. We also DO NOT try to manage/replace
* the CRT storage.
*/
char *msc_getenv(const char *name)
{
int len_key, len_value;
wchar_t *w_key;
char *value;
const wchar_t *w_value;
if (!name || !*name)
return NULL;
len_key = strlen(name) + 1;
w_key = calloc(len_key, sizeof(wchar_t));
xutftowcs(w_key, name, len_key);
w_value = _wgetenv(w_key);
free(w_key);
if (!w_value)
return NULL;
len_value = wcslen(w_value) * 3 + 1;
value = calloc(len_value, sizeof(char));
xwcstoutf(value, w_value, len_value);
/* TODO Warning: We return "value" which is an allocated
* value and the caller is NOT expecting to have to free
* it, so we leak memory.
*/
return value;
}
int msc_putenv(const char *name)
{
int len, result;
char *equal;
wchar_t *wide;
if (!name || !*name)
return 0;
len = strlen(name);
equal = strchr(name, '=');
wide = calloc(len+1+!equal, sizeof(wchar_t));
xutftowcs(wide, name, len+1);
if (!equal)
wcscat(wide, L"=");
result = _wputenv(wide);
free(wide);
return result;
}
#else
/*
* Compare environment entries by key (i.e. stopping at '=' or '\0').
*/
@@ -1682,6 +1904,8 @@ int mingw_putenv(const char *namevalue)
return 0;
}
#endif
/*
* Note, this isn't a complete replacement for getaddrinfo. It assumes
* that service contains a numerical port, or that it is null. It
@@ -2240,8 +2464,34 @@ int mingw_raise(int sig)
sigint_fn(SIGINT);
return 0;
#if defined(_MSC_VER)
/*
* <signal.h> in the CRT defines 8 signals as being
* supported on the platform. Anything else causes
* an "Invalid signal or error" (which in DEBUG builds
* causes the Abort/Retry/Ignore dialog). We by-pass
* the CRT for things we already know will fail.
*/
/*case SIGINT:*/
case SIGILL:
case SIGFPE:
case SIGSEGV:
case SIGTERM:
case SIGBREAK:
case SIGABRT:
case SIGABRT_COMPAT:
return raise(sig);
default:
errno = EINVAL;
return -1;
#else
default:
return raise(sig);
#endif
}
}
@@ -2339,7 +2589,10 @@ typedef struct _REPARSE_DATA_BUFFER {
DWORD ReparseTag;
WORD ReparseDataLength;
WORD Reserved;
_ANONYMOUS_UNION union {
#ifndef _MSC_VER
_ANONYMOUS_UNION
#endif
union {
struct {
WORD SubstituteNameOffset;
WORD SubstituteNameLength;
@@ -2717,6 +2970,7 @@ int handle_long_path(wchar_t *path, int len, int max_path, int expand)
}
}
#if !defined(_MSC_VER)
/*
* Disable MSVCRT command line wildcard expansion (__getmainargs called from
* mingw startup code, see init.c in mingw runtime).
@@ -2729,6 +2983,7 @@ typedef struct {
extern int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob,
_startupinfo *si);
#endif
static NORETURN void die_startup(void)
{
@@ -2806,6 +3061,95 @@ static void maybe_redirect_std_handles(void)
GENERIC_WRITE, FILE_FLAG_NO_BUFFERING);
}
#if defined(_MSC_VER)
/*
* This routine sits between wmain() and "main" in git.exe.
* We receive UNICODE (wchar_t) values for argv and env.
*
* To be more compatible with the core git code, we convert
* argv into UTF8 and pass them directly to the "main" routine.
*
* We don't bother converting the given UNICODE env vector,
* but rather leave them in the CRT. We replaced the various
* getenv/putenv routines to pull them directly from the CRT.
*
* This is unlike the MINGW version:
* [] It does the UNICODE-2-UTF8 conversion on both sets and
* stuffs the values back into the CRT using exported symbols.
* [] It also maintains a private copy of the environment and
* tries to track external changes to it.
*/
int msc_startup(int argc, wchar_t **w_argv, wchar_t **w_env)
{
char **my_utf8_argv = NULL, **save = NULL;
char *buffer = NULL;
int maxlen;
int k, exit_status;
#ifdef USE_MSVC_CRTDBG
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
maybe_redirect_std_handles();
/* determine size of argv conversion buffer */
maxlen = wcslen(_wpgmptr);
for (k = 1; k < argc; k++)
maxlen = max(maxlen, wcslen(w_argv[k]));
/* allocate buffer (wchar_t encodes to max 3 UTF-8 bytes) */
maxlen = 3 * maxlen + 1;
buffer = malloc_startup(maxlen);
/*
* Create a UTF-8 version of w_argv. Also create a "save" copy
* to remember all the string pointers because parse_options()
* will remove claimed items from the argv that we pass down.
*/
ALLOC_ARRAY(my_utf8_argv, argc + 1);
ALLOC_ARRAY(save, argc + 1);
save[0] = my_utf8_argv[0] = wcstoutfdup_startup(buffer, _wpgmptr, maxlen);
for (k = 1; k < argc; k++)
save[k] = my_utf8_argv[k] = wcstoutfdup_startup(buffer, w_argv[k], maxlen);
save[k] = my_utf8_argv[k] = NULL;
free(buffer);
/* fix Windows specific environment settings */
setup_windows_environment();
unset_environment_variables = xstrdup("PERL5LIB");
/* initialize critical section for waitpid pinfo_t list */
InitializeCriticalSection(&pinfo_cs);
InitializeCriticalSection(&phantom_symlinks_cs);
/* set up default file mode and file modes for stdin/out/err */
_fmode = _O_BINARY;
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
_setmode(_fileno(stderr), _O_BINARY);
/* initialize Unicode console */
winansi_init();
/* init length of current directory for handle_long_path */
current_directory_len = GetCurrentDirectoryW(0, NULL);
/* invoke the real main() using our utf8 version of argv. */
exit_status = msc_main(argc, my_utf8_argv);
for (k = 0; k < argc; k++)
free(save[k]);
free(save);
free(my_utf8_argv);
return exit_status;
}
#else
void mingw_startup(void)
{
int i, maxlen, argc;
@@ -2885,6 +3229,8 @@ void mingw_startup(void)
current_directory_len = GetCurrentDirectoryW(0, NULL);
}
#endif
int uname(struct utsname *buf)
{
unsigned v = (unsigned)GetVersion();

View File

@@ -265,12 +265,53 @@ char *mingw_getcwd(char *pointer, int len);
#error "NO_UNSETENV is incompatible with the MinGW startup code!"
#endif
#if defined(_MSC_VER)
/*
* We bind *env() routines (even the mingw_ ones) to private msc_ versions.
* These talk to the CRT using UNICODE/wchar_t, but maintain the original
* narrow-char API.
*
* Note that the MSCRT maintains both ANSI (getenv()) and UNICODE (_wgetenv())
* routines and stores both versions of each environment variable in parallel
* (and secretly updates both when you set one or the other), but it uses CP_ACP
* to do the conversion rather than CP_UTF8.
*
* Since everything in the git code base is UTF8, we define the msc_ routines
* to access the CRT using the UNICODE routines and manually convert them to
* UTF8. This also avoids round-trip problems.
*
* This also helps with our linkage, since "_wenviron" is publicly exported
* from the CRT. But to access "_environ" we would have to statically link
* to the CRT (/MT).
*
* We also use "wmain(argc,argv,env)" and get the initial UNICODE setup for us.
* This avoids the need for the msc_startup() to import and convert the
* inherited environment.
*
* We require NO_SETENV (and let gitsetenv() call our msc_putenv).
*/
#define getenv msc_getenv
#define putenv msc_putenv
#define unsetenv msc_putenv
#define mingw_getenv msc_getenv
#define mingw_putenv msc_putenv
char *msc_getenv(const char *name);
int msc_putenv(const char *name);
#ifndef NO_SETENV
#error "NO_SETENV is required for MSC startup code!"
#endif
#else
char *mingw_getenv(const char *name);
#define getenv mingw_getenv
int mingw_putenv(const char *namevalue);
#define putenv mingw_putenv
#define unsetenv mingw_putenv
#endif
int mingw_gethostname(char *host, int namelen);
#define gethostname mingw_gethostname
@@ -353,11 +394,13 @@ static inline long long filetime_to_hnsec(const FILETIME *ft)
#ifndef __MINGW64_VERSION_MAJOR
#define off_t off64_t
#define lseek _lseeki64
#ifndef _MSC_VER
struct timespec {
time_t tv_sec;
long tv_nsec;
};
#endif
#endif
static inline void filetime_to_timespec(const FILETIME *ft, struct timespec *ts)
{
@@ -647,7 +690,26 @@ extern CRITICAL_SECTION pinfo_cs;
/*
* A replacement of main() that adds win32 specific initialization.
*
* Note that the end of these macros are unterminated so that the
* brace group following the use of the macro is the body of the
* function.
*/
#if defined(_MSC_VER)
int msc_startup(int argc, wchar_t **w_argv, wchar_t **w_env);
extern int msc_main(int argc, const char **argv);
#define main(c,v) dummy_decl_msc_main(void); \
int wmain(int my_argc, \
wchar_t **my_w_argv, \
wchar_t **my_w_env) \
{ \
return msc_startup(my_argc, my_w_argv, my_w_env); \
} \
int msc_main(c, v)
#else
void mingw_startup(void);
#define main(c,v) dummy_decl_mingw_main(void); \
@@ -659,6 +721,8 @@ int main(int argc, const char **argv) \
} \
static int mingw_main(c,v)
#endif
/*
* Used by Pthread API implementation for Windows
*/

View File

@@ -24,6 +24,15 @@ static __inline int strcasecmp (const char *s1, const char *s2)
#undef ERROR
#ifdef _MSC_VER
#define ftello _ftelli64
typedef int sigset_t;
/* open for reading, writing, or both (not in fcntl.h) */
#define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR)
#endif
#include "compat/mingw.h"
#endif

1
compat/vcbuild/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
GEN.*

147
compat/vcbuild/Makefile Normal file
View File

@@ -0,0 +1,147 @@
## Makefile to install nuget package dependencies.
##################################################################
INST=GEN.DEPS
INST_INC=$(INST)/include
INST_LIB=$(INST)/lib
INST_BIN=$(INST)/bin
PKGDIR=GEN.PKGS
NUGET ?= nuget.exe
ifneq ($(shell $(NUGET) help 2>/dev/null; echo $$?),0)
NUGET := /usr/src/build-extra/nuget/nuget.exe
endif
##################################################################
all: unpack expat libssh libssh_redist curl curl_redist openssl zlib \
libiconv libiconv_redist
unpack:
[ -d $(PKGDIR) ] || mkdir $(PKGDIR)
"$(NUGET)" restore packages.config -ConfigFile nuget.config \
-NonInteractive -OutputDirectory $(PKGDIR)
insdir:
[ -d $(INST) ] || mkdir $(INST)
[ -d $(INST_INC) ] || mkdir $(INST_INC)
[ -d $(INST_BIN) ] || mkdir $(INST_BIN)
[ -d $(INST_LIB) ] || mkdir $(INST_LIB)
##################################################################
## We place the expat headers in their own subdirectory.
## The custom is to reference <expat.h>, so compile with:
## -I$(INST_INC)/expat
EXPAT_VER=2.1.0.11
EXPAT_ROOT=$(PKGDIR)/expat.$(EXPAT_VER)/build/native
EXPAT_INC=$(EXPAT_ROOT)/include
EXPAT_LIB=$(EXPAT_ROOT)/lib/v110/x64/Release/dynamic/utf8
expat: insdir
[ -d $(INST_INC)/expat ] || mkdir $(INST_INC)/expat
cp -r $(EXPAT_INC)/* $(INST_INC)/expat/
cp -r $(EXPAT_LIB)/* $(INST_LIB)/
##################################################################
LIBICONV_VER=1.14.0.11
LIBICONV_ROOT=$(PKGDIR)/libiconv.$(LIBICONV_VER)/build/native
LIBICONV_INC=$(LIBICONV_ROOT)/include
LIBICONV_LIB=$(LIBICONV_ROOT)/lib/v110/x64/Release/dynamic/cdecl
libiconv: insdir
cp -r $(LIBICONV_INC)/* $(INST_INC)/
cp -r $(LIBICONV_LIB)/libiconv.lib $(INST_LIB)/iconv.lib
LIBICONV_REDIST_ROOT=$(PKGDIR)/libiconv.redist.$(LIBICONV_VER)/build/native
LIBICONV_REDIST_BIN=$(LIBICONV_REDIST_ROOT)/bin/v110/x64/Release/dynamic/cdecl
libiconv_redist: insdir
cp -r $(LIBICONV_REDIST_BIN)/* $(INST_BIN)/
##################################################################
LIBSSH_VER=1.4.3.3
LIBSSH_ROOT=$(PKGDIR)/libssh2.$(LIBSSH_VER)/build/native
LIBSSH_INC=$(LIBSSH_ROOT)/include
LIBSSH_LIB=$(LIBSSH_ROOT)/lib/v110/x64/Release/dynamic/cdecl
libssh: insdir
[ -d $(INST_INC)/libssh2 ] || mkdir $(INST_INC)/libssh2
cp -r $(LIBSSH_INC)/* $(INST_INC)/libssh2
cp -r $(LIBSSH_LIB)/* $(INST_LIB)/
LIBSSH_REDIST_ROOT=$(PKGDIR)/libssh2.redist.$(LIBSSH_VER)/build/native
LIBSSH_REDIST_BIN=$(LIBSSH_REDIST_ROOT)/bin/v110/x64/Release/dynamic/cdecl
libssh_redist: insdir
cp -r $(LIBSSH_REDIST_BIN)/* $(INST_BIN)/
##################################################################
## We place the curl headers in their own subdirectory.
## The custom is to reference <curl/curl.h>, so compile with:
## -I$(INST_INC)
CURL_VER=7.30.0.2
CURL_ROOT=$(PKGDIR)/curl.$(CURL_VER)/build/native
CURL_INC=$(CURL_ROOT)/include/curl
CURL_LIB=$(CURL_ROOT)/lib/v110/x64/Release/dynamic
curl: insdir
[ -d $(INST_INC)/curl ] || mkdir $(INST_INC)/curl
cp -r $(CURL_INC)/* $(INST_INC)/curl
cp -r $(CURL_LIB)/* $(INST_LIB)/
CURL_REDIST_ROOT=$(PKGDIR)/curl.redist.$(CURL_VER)/build/native
CURL_REDIST_BIN=$(CURL_REDIST_ROOT)/bin/v110/x64/Release/dynamic
curl_redist: insdir
cp -r $(CURL_REDIST_BIN)/* $(INST_BIN)/
##################################################################
## We place the openssl headers in their own subdirectory.
## The custom is to reference <openssl/sha.h>, so compile with:
## -I$(INST_INC)
OPENSSL_VER=1.0.2.1
OPENSSL_ROOT=$(PKGDIR)/openssl.v140.windesktop.msvcstl.dyn.rt-dyn.x64.$(OPENSSL_VER)
OPENSSL_INC=$(OPENSSL_ROOT)/build/native/include/openssl
OPENSSL_LIB=$(OPENSSL_ROOT)/lib/native/v140/windesktop/msvcstl/dyn/rt-dyn/x64/release
openssl: insdir
[ -d $(INST_INC)/openssl ] || mkdir $(INST_INC)/openssl
cp -r $(OPENSSL_INC)/* $(INST_INC)/openssl
cp -r $(OPENSSL_LIB)/*.lib $(INST_LIB)/
cp -r $(OPENSSL_LIB)/*.dll $(INST_BIN)/
cp -r $(OPENSSL_LIB)/*.pdb $(INST_BIN)/
##################################################################
## We place the zlib headers in their own subdirectory.
## The custom is to reference <zlib.h>, so compile with:
## -I$(INST_INC)/zlib
ZLIB_VER=1.2.8.8
ZLIB_ROOT=$(PKGDIR)/zlib.v140.windesktop.msvcstl.dyn.rt-dyn.$(ZLIB_VER)
ZLIB_INC=$(ZLIB_ROOT)/build/native/include
ZLIB_LIB=$(ZLIB_ROOT)/lib/native/v140/windesktop/msvcstl/dyn/rt-dyn/x64/RelWithDebInfo
zlib: insdir
[ -d $(INST_INC)/zlib ] || mkdir $(INST_INC)/zlib
cp -r $(ZLIB_INC)/* $(INST_INC)/zlib
cp -r $(ZLIB_LIB)/*.lib $(INST_LIB)/
cp -r $(ZLIB_LIB)/*.dll $(INST_BIN)/
cp -r $(ZLIB_LIB)/*.pdb $(INST_BIN)/
##################################################################
clean:
rm -rf $(INST)
clobber: clean
rm -rf $(PKGDIR)

View File

@@ -0,0 +1,54 @@
Instructions for building Git for Windows using VS2015.
================================================================
Installing third-party dependencies:
====================================
[1] Install nuget.exe somewhere on your system and add it to your PATH.
https://docs.nuget.org/consume/command-line-reference
https://dist.nuget.org/index.html
[2] Download required nuget packages for third-party libraries.
Using a terminal window, type:
make -C compat/vcbuild
This will download the packages, unpack them into GEN.PKGS,
and populate the {include, lib, bin} directories in GEN.DEPS.
Building Git for Windows using VS2015:
======================================
[3] Build 64-bit version of Git for Windows.
Using a terminal window:
make MSVC=1 DEBUG=1
[4] Add compat/vcbuild/GEN.DEPS/bin to your PATH.
[5] You should then be able to run the test suite and any interactive
commands.
[6] To debug/profile in VS, open the git.exe in VS and run/debug
it. (Be sure to add GEN.DEPS/bin to the PATH in the debug
dialog.)
TODO List:
==========
[A] config.mak.uname currently contains hard-coded paths
to the various MSVC and SDK libraries for the 64-bit
version of the compilers and libaries.
See: SANE_TOOL_PATH, MSVC_DEPS, MSVC_SDK*, MSVC_VCDIR.
Long term, we need to figure out how to properly import
values for %VCINSTALLDIR%, %LIB%, %LIBPATH%, and the
other values normally set by "vsvars32.bat" when a
developer command prompt is started. This would also
allow us to switch between 32- and 64-bit tool chains.
[B] We need to build SLN or VCPROJ files.

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<!--
Used to specify the default location to expand packages.
See: NuGet.exe help install
See: NuGet.exe help update
-->
<add key="repositoryPath" value="Nupkg" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="False" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<activePackageSource>
<!-- this tells only one given source is active -->
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
</configuration>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="curl" version="7.30.0.2" />
<package id="curl.redist" version="7.30.0.2" />
<package id="expat" version="2.1.0.11" />
<package id="libiconv" version="1.14.0.11" />
<package id="libiconv.redist" version="1.14.0.11" />
<package id="libssh2" version="1.4.3.3" />
<package id="libssh2.redist" version="1.4.3.3" />
<package id="openssl" version="1.0.2.1" />
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn" version="1.0.2.1" />
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn.x64" version="1.0.2.0" />
<package id="openssl.v120.windesktop.msvcstl.dyn.rt-dyn.x86" version="1.0.2.1" />
<package id="openssl.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.0.2.1" />
<package id="openssl.v140.windesktop.msvcstl.dyn.rt-dyn.x64" version="1.0.2.1" />
<package id="openssl.v140.windesktop.msvcstl.dyn.rt-dyn.x86" version="1.0.2.1" />
<package id="zlib" version="1.2.8.8" />
<package id="zlib.v120.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" />
<package id="zlib.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" />
</packages>

View File

@@ -12,18 +12,22 @@
use strict;
my @args = ();
my @cflags = ();
my @lflags = ();
my $is_linking = 0;
while (@ARGV) {
my $arg = shift @ARGV;
if ("$arg" =~ /^-[DIMGO]/) {
if ("$arg" =~ /^-[DIMGOZ]/) {
push(@cflags, $arg);
} elsif ("$arg" eq "-o") {
my $file_out = shift @ARGV;
if ("$file_out" =~ /exe$/) {
$is_linking = 1;
# Create foo.exe and foo.pdb
push(@args, "-OUT:$file_out");
} else {
# Create foo.o and foo.o.pdb
push(@args, "-Fo$file_out");
push(@args, "-Fd$file_out.pdb");
}
} elsif ("$arg" eq "-lz") {
push(@args, "zlib.lib");
@@ -35,9 +39,11 @@ while (@ARGV) {
push(@args, "ssleay32.lib");
} elsif ("$arg" eq "-lcurl") {
push(@args, "libcurl.lib");
} elsif ("$arg" eq "-lexpat") {
push(@args, "libexpat.lib");
} elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") {
$arg =~ s/^-L/-LIBPATH:/;
push(@args, $arg);
push(@lflags, $arg);
} elsif ("$arg" =~ /^-R/) {
# eat
} else {
@@ -45,10 +51,11 @@ while (@ARGV) {
}
}
if ($is_linking) {
push(@args, @lflags);
unshift(@args, "link.exe");
} else {
unshift(@args, "cl.exe");
push(@args, @cflags);
}
#printf("**** @args\n");
printf(STDERR "**** @args\n\n\n") if (!defined($ENV{'QUIET_GEN'}));
exit (system(@args) != 0);

View File

@@ -513,7 +513,20 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
#ifdef DETECT_MSYS_TTY
#include <winternl.h>
#if defined(_MSC_VER)
typedef struct _OBJECT_NAME_INFORMATION
{
UNICODE_STRING Name;
WCHAR NameBuffer[0];
} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
#define ObjectNameInformation 1
#else
#include <ntstatus.h>
#endif
static void detect_msys_tty(int fd)
{