From: Frank Li Date: Mon, 17 Aug 2009 13:13:56 GMT Subject: Re: Using VC build git (split patch) Message-ID: <1976ea660908170613ibb9a0fdr7ba630671a6b735f@mail.gmail.com> Thanks Dscho for reviewing my patch patient. I split my patch and read SumbittingPatchs. I try to use git format-patch -M --stdout origin/master | git imap-send to send patch directly according to guide. But imap-send has not ported to msysgit. From 2d5f52081d4d8916185ee2885cbf86604a9f54f3 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 17 Aug 2009 15:00:45 +0800 Subject: [PATCH 11/11] Add gitignore and ReadMe file for MSVC Build Add ReadMe to user how to build git with MSVC. Add gitignore to filter out files created file by MSVC. Signed-off-by: Frank Li --- compat/vcbuild/.gitignore | 3 +++ compat/vcbuild/ReadMe | 13 +++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) create mode 100644 compat/vcbuild/.gitignore create mode 100644 compat/vcbuild/ReadMe diff --git a/compat/vcbuild/.gitignore b/compat/vcbuild/.gitignore new file mode 100644 index 0000000..7796990 --- /dev/null +++ b/compat/vcbuild/.gitignore @@ -0,0 +1,3 @@ +Debug +Release +*.user \ No newline at end of file diff --git a/compat/vcbuild/ReadMe b/compat/vcbuild/ReadMe new file mode 100644 index 0000000..47c089e --- /dev/null +++ b/compat/vcbuild/ReadMe @@ -0,0 +1,13 @@ +The Steps of Build Git with VS2008 + +1. Create VC Build Environment. + + git clone git://repo.or.cz/gitbuild.git + + gitbuild include VS solution file and library such as zlib. + +2. Get Submodule + + git submodule update + +3. Open gitbuild\gitbuild.sln with VS2008. Then press F7. \ No newline at end of file -- 1.6.4.msysgit.0 From ceb73fc1cd4c32d30c2fd534009c507cf18704fa Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 16 Aug 2009 13:15:18 +0800 Subject: [PATCH 01/11] Fix build failure at VC because function declare use old style at regex.c regerror declare function argument type after function define. Signed-off-by: Frank Li --- compat/regex/regex.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/compat/regex/regex.c b/compat/regex/regex.c index 5ea0075..5728de1 100644 --- a/compat/regex/regex.c +++ b/compat/regex/regex.c @@ -4852,11 +4852,7 @@ regexec (preg, string, nmatch, pmatch, eflags) from either regcomp or regexec. We don't use PREG here. */ size_t -regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *preg; - char *errbuf; - size_t errbuf_size; +regerror (int errcode, const regex_t * preg, char * errbuf,size_t errbuf_size) { const char *msg; size_t msg_size; -- 1.6.4.msysgit.0 From 753c6790df6eca740c2d708c19301d117fbbb085 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 16 Aug 2009 13:34:03 +0800 Subject: [PATCH 02/11] Fix declare variable at mid of function Some compiler such as MSVC can't support declear variable at mid of funtion at c file. Signed-off-by: Frank Li --- compat/mingw.c | 16 ++++++++++++---- help.c | 3 ++- run-command.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index bed4178..75c74b1 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -123,13 +123,17 @@ int mingw_open (const char *filename, int oflags, ...) { va_list args; unsigned mode; + int fd; + va_start(args, oflags); mode = va_arg(args, int); va_end(args); if (!strcmp(filename, "/dev/null")) filename = "nul"; - int fd = open(filename, oflags, mode); + + fd = open(filename, oflags, mode); + if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) { DWORD attrs = GetFileAttributes(filename); if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) @@ -580,10 +584,11 @@ static char **get_path_split(void) static void free_path_split(char **path) { + char **p = path; + if (!path) return; - char **p = path; while (*p) free(*p++); free(path); @@ -1108,9 +1113,11 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out) #undef signal sig_handler_t mingw_signal(int sig, sig_handler_t handler) { + sig_handler_t old; + if (sig != SIGALRM) return signal(sig, handler); - sig_handler_t old = timer_fn; + old = timer_fn; timer_fn = handler; return old; } @@ -1197,8 +1204,9 @@ struct dirent *mingw_readdir(DIR *dir) if (dir->dd_handle == (long)INVALID_HANDLE_VALUE && dir->dd_stat == 0) { + DWORD lasterr; handle = FindFirstFileA(dir->dd_name, &buf); - DWORD lasterr = GetLastError(); + lasterr = GetLastError(); dir->dd_handle = (long)handle; if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES)) { errno = err_win_to_posix(lasterr); diff --git a/help.c b/help.c index 6c46d8b..399b0b4 100644 --- a/help.c +++ b/help.c @@ -127,7 +127,7 @@ static int is_executable(const char *name) return 0; #ifdef __MINGW32__ - /* cannot trust the executable bit, peek into the file instead */ +{ /* cannot trust the executable bit, peek into the file instead */ char buf[3] = { 0 }; int n; int fd = open(name, O_RDONLY); @@ -140,6 +140,7 @@ static int is_executable(const char *name) st.st_mode |= S_IXUSR; close(fd); } +} #endif return st.st_mode & S_IXUSR; } diff --git a/run-command.c b/run-command.c index ff3d8e2..d1df7ab 100644 --- a/run-command.c +++ b/run-command.c @@ -123,6 +123,7 @@ int start_command(struct child_process *cmd) exit(127); } #else +{ int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */ const char **sargv = cmd->argv; char **env = environ; @@ -186,6 +187,7 @@ int start_command(struct child_process *cmd) dup2(s1, 1), close(s1); if (s2 >= 0) dup2(s2, 2), close(s2); +} #endif if (cmd->pid < 0) { -- 1.6.4.msysgit.0 From 7edc5a10d29ec735dc302d110945ad70bac3d83f Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 16 Aug 2009 13:53:30 +0800 Subject: [PATCH 03/11] Define SNPRINTF_SIZE_CORR 1 when use MSVC build git There are not NUL at vsnprintf verstion of MSVC when rearch max len. Define vsnprintf to _vsnprintf. vsnprintf have deprecated. Signed-off-by: Frank Li --- compat/snprintf.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/compat/snprintf.c b/compat/snprintf.c index 6c0fb05..47b2b8a 100644 --- a/compat/snprintf.c +++ b/compat/snprintf.c @@ -6,7 +6,7 @@ * number of characters to write without the trailing NUL. */ #ifndef SNPRINTF_SIZE_CORR -#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4 +#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4 || defined(_MSC_VER) #define SNPRINTF_SIZE_CORR 1 #else #define SNPRINTF_SIZE_CORR 0 @@ -14,6 +14,11 @@ #endif #undef vsnprintf + +#if defined(_MSC_VER) +#define vsnprintf _vsnprintf +#endif + int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap) { char *s; -- 1.6.4.msysgit.0 From e82f2baea636dca70328e1e5161456bd61c21bec Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 16 Aug 2009 19:14:29 +0800 Subject: [PATCH 04/11] Add _MSC_VER predefine macro to make same behaviors with __MINGW32__ Enable MSVC build. MSVC have the save behaviors with msysgit. Signed-off-by: Frank Li --- help.c | 2 +- pager.c | 4 ++-- run-command.c | 8 ++++---- run-command.h | 2 +- setup.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/help.c b/help.c index 399b0b4..a311241 100644 --- a/help.c +++ b/help.c @@ -126,7 +126,7 @@ static int is_executable(const char *name) !S_ISREG(st.st_mode)) return 0; -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(_MSC_VER) { /* cannot trust the executable bit, peek into the file instead */ char buf[3] = { 0 }; int n; diff --git a/pager.c b/pager.c index 4921843..28122c5 100644 --- a/pager.c +++ b/pager.c @@ -9,7 +9,7 @@ static int spawned_pager; -#ifndef __MINGW32__ +#if !defined(__MINGW32__) && !defined(_MSC_VER) static void pager_preexec(void) { /* @@ -70,7 +70,7 @@ void setup_pager(void) pager_argv[2] = pager; pager_process.argv = pager_argv; pager_process.in = -1; -#ifndef __MINGW32__ +#if !defined(__MINGW32__) && !defined(_MSC_VER) pager_process.preexec_cb = pager_preexec; #endif if (start_command(&pager_process)) diff --git a/run-command.c b/run-command.c index d1df7ab..df139da 100644 --- a/run-command.c +++ b/run-command.c @@ -67,7 +67,7 @@ int start_command(struct child_process *cmd) trace_argv_printf(cmd->argv, "trace: run_command:"); -#ifndef __MINGW32__ +#if !defined(__MINGW32__) && !defined(_MSC_VER) fflush(NULL); cmd->pid = fork(); if (!cmd->pid) { @@ -294,7 +294,7 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const return run_command(&cmd); } -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(_MSC_VER) static __stdcall unsigned run_thread(void *data) { struct async *async = data; @@ -310,7 +310,7 @@ int start_async(struct async *async) return error("cannot create pipe: %s", strerror(errno)); async->out = pipe_out[0]; -#ifndef __MINGW32__ +#if !defined(__MINGW32__) && !defined(_MSC_VER) /* Flush stdio before fork() to avoid cloning buffers */ fflush(NULL); @@ -339,7 +339,7 @@ int start_async(struct async *async) int finish_async(struct async *async) { -#ifndef __MINGW32__ +#if !defined(__MINGW32__) && !defined(_MSC_VER) int ret = 0; if (wait_or_whine(async->pid)) diff --git a/run-command.h b/run-command.h index e345502..57a707b 100644 --- a/run-command.h +++ b/run-command.h @@ -79,7 +79,7 @@ struct async { int (*proc)(int fd, void *data); void *data; int out; /* caller reads from here and closes it */ -#ifndef __MINGW32__ +#if !defined(__MINGW32__) && !defined(_MSC_VER) pid_t pid; #else HANDLE tid; diff --git a/setup.c b/setup.c index e3781b6..14e3ca7 100644 --- a/setup.c +++ b/setup.c @@ -41,7 +41,7 @@ const char *prefix_path(const char *prefix, int len, const char *path) const char *prefix_filename(const char *pfx, int pfx_len, const char *arg) { static char path[PATH_MAX]; -#ifndef __MINGW32__ +#if !defined(__MINGW32__) && !defined(_MSC_VER) if (!pfx || !*pfx || is_absolute_path(arg)) return arg; memcpy(path, pfx, pfx_len); -- 1.6.4.msysgit.0 From 67a26d74abe9720b59c7cf56926b278f3c72a312 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 16 Aug 2009 20:57:10 +0800 Subject: [PATCH 05/11] Remove va_copy at MSVC because there are va_copy. MSVs have not implemented va_copy. remove va_copy at MSVC environment. It will malloc buffer each time. Signed-off-by: Frank Li --- compat/winansi.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/compat/winansi.c b/compat/winansi.c index 9217c24..6091138 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -3,7 +3,11 @@ */ #include +#ifdef _MSC_VER +#include +#else #include "../git-compat-util.h" +#endif /* Functions to be wrapped: @@ -310,9 +314,13 @@ static int winansi_vfprintf(FILE *stream, const char *format, va_list list) if (!console) goto abort; +#ifndef _MSC_VER va_copy(cp, list); len = vsnprintf(small_buf, sizeof(small_buf), format, cp); va_end(cp); +#else + len= sizeof(small_buf) ; +#endif if (len > sizeof(small_buf) - 1) { buf = malloc(len + 1); -- 1.6.4.msysgit.0 From 4f7ead893ef71510f5f0b96246692a049cd61d3b Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 16 Aug 2009 21:04:45 +0800 Subject: [PATCH 06/11] Add miss git-compat-util.h at regex.c and fnmatch.c Add git-compat-util.h to enable build at MSVC environment Signed-off-by: Frank Li --- compat/fnmatch/fnmatch.c | 4 ++++ compat/regex/regex.c | 4 ++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/compat/fnmatch/fnmatch.c b/compat/fnmatch/fnmatch.c index 14feac7..5cbd49c 100644 --- a/compat/fnmatch/fnmatch.c +++ b/compat/fnmatch/fnmatch.c @@ -16,6 +16,10 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef _MSC_VER +#include "git-compat-util.h" +#endif + #if HAVE_CONFIG_H # include #endif diff --git a/compat/regex/regex.c b/compat/regex/regex.c index 5728de1..2298a3a 100644 --- a/compat/regex/regex.c +++ b/compat/regex/regex.c @@ -20,6 +20,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* AIX requires this to be the first thing in the file. */ +#ifdef _MSC_VER +#include "git-compat-util.h" +#endif + #if defined (_AIX) && !defined (REGEX_MALLOC) #pragma alloca #endif -- 1.6.4.msysgit.0 From ee80ee9f5f62eded25405a6158ded556216723f4 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 17 Aug 2009 14:52:01 +0800 Subject: [PATCH 07/11] Add O_BINARY flag to open flag at mingw.c Windows will convert CR\LF and union code at text mode. Git doesn't like this. Add O_BINARY flag to open function Signed-off-by: Frank Li --- compat/mingw.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 75c74b1..d5fa0ed 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -132,7 +132,7 @@ int mingw_open (const char *filename, int oflags, ...) if (!strcmp(filename, "/dev/null")) filename = "nul"; - fd = open(filename, oflags, mode); + fd = open(filename, oflags | O_BINARY, mode); if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) { DWORD attrs = GetFileAttributes(filename); @@ -278,7 +278,7 @@ int mkstemp(char *template) char *filename = mktemp(template); if (filename == NULL) return -1; - return open(filename, O_RDWR | O_CREAT, 0600); + return open(filename, O_RDWR | O_CREAT | O_BINARY, 0600); } int gettimeofday(struct timeval *tv, void *tz) -- 1.6.4.msysgit.0 From 7783d7e2d367588b4b9f8d2aa32e3135af7d12a0 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 17 Aug 2009 14:54:31 +0800 Subject: [PATCH 08/11] Place __stdcall to correct position. MSVC require __stdcall is between return value and function name. ALL Win32 API definition is as TYPE WINAPI function name Signed-off-by: Frank Li --- compat/mingw.c | 4 ++-- run-command.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index d5fa0ed..0c9c793 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1017,7 +1017,7 @@ static sig_handler_t timer_fn = SIG_DFL; * length to call the signal handler. */ -static __stdcall unsigned ticktack(void *dummy) +static unsigned __stdcall ticktack(void *dummy) { while (WaitForSingleObject(timer_event, timer_interval) == WAIT_TIMEOUT) { if (timer_fn == SIG_DFL) @@ -1146,7 +1146,7 @@ void mingw_open_html(const char *unixpath) int link(const char *oldpath, const char *newpath) { - typedef BOOL WINAPI (*T)(const char*, const char*, LPSECURITY_ATTRIBUTES); + typedef BOOL (WINAPI *T)(const char*, const char*, LPSECURITY_ATTRIBUTES); static T create_hard_link = NULL; if (!create_hard_link) { create_hard_link = (T) GetProcAddress( diff --git a/run-command.c b/run-command.c index df139da..423b506 100644 --- a/run-command.c +++ b/run-command.c @@ -295,12 +295,12 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const } #if defined(__MINGW32__) || defined(_MSC_VER) -static __stdcall unsigned run_thread(void *data) +static unsigned __stdcall run_thread(void *data) { struct async *async = data; return async->proc(async->fd_for_proc, async->data); } -#endif +#endif /* __MINGW32__ || _MSC_VER */ int start_async(struct async *async) { -- 1.6.4.msysgit.0 From 6add8b13e7b5266ba4b125e826e78bed5f72b7f7 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 17 Aug 2009 14:56:26 +0800 Subject: [PATCH 09/11] Add MSVC porting header files. Add unix head file, dirent.h, unistd.h and time.h Add MSVC special porting head file msvc.h and msvc.c. Signed-off-by: Frank Li --- compat/msvc.c | 33 ++++++++++ compat/msvc.h | 95 +++++++++++++++++++++++++++++ compat/vcbuild/include/dirent.h | 127 +++++++++++++++++++++++++++++++++++++++ compat/vcbuild/include/unistd.h | 92 ++++++++++++++++++++++++++++ compat/vcbuild/sys/time.h | 21 +++++++ git-compat-util.h | 12 ++++- 6 files changed, 379 insertions(+), 1 deletions(-) create mode 100644 compat/msvc.c create mode 100644 compat/msvc.h create mode 100644 compat/vcbuild/include/dirent.h create mode 100644 compat/vcbuild/include/unistd.h create mode 100644 compat/vcbuild/sys/time.h diff --git a/compat/msvc.c b/compat/msvc.c new file mode 100644 index 0000000..80afd4d --- /dev/null +++ b/compat/msvc.c @@ -0,0 +1,33 @@ +#include "../git-compat-util.h" +#include "win32.h" +#include +#include "../strbuf.h" + +DIR *opendir(const char *name) +{ + int len; + DIR *p; + p = (DIR*)malloc(sizeof(DIR)); + memset(p, 0, sizeof(DIR)); + strncpy(p->dd_name, name, PATH_MAX); + len = strlen(p->dd_name); + p->dd_name[len] = '/'; + p->dd_name[len+1] = '*'; + + if (p == NULL) + return NULL; + + p->dd_handle = _findfirst(p->dd_name, &p->dd_dta); + + if (p->dd_handle == -1) { + free(p); + return NULL; + } + return p; +} +int closedir(DIR *dir) +{ + _findclose(dir->dd_handle); + free(dir); + return 0; +} diff --git a/compat/msvc.h b/compat/msvc.h new file mode 100644 index 0000000..6071565 --- /dev/null +++ b/compat/msvc.h @@ -0,0 +1,95 @@ +#ifndef __MSVC__HEAD +#define __MSVC__HEAD + +#define WINVER 0x0500 +#define _WIN32_WINNT 0x0500 +#define _WIN32_WINDOWS 0x0410 +#define _WIN32_IE 0x0700 +#define NTDDI_VERSION NTDDI_WIN2KSP1 +#include + +/*Configuration*/ + +#define NO_PREAD +#define NO_OPENSSL +#define NO_LIBGEN_H +#define NO_SYMLINK_HEAD +#define NO_IPV6 +#define NO_SETENV +#define NO_UNSETENV +#define NO_STRCASESTR +#define NO_STRLCPY +#define NO_MEMMEM +#define NO_C99_FORMAT +#define NO_STRTOUMAX +#define NO_MKDTEMP +#define NO_MKSTEMPS + +#define RUNTIME_PREFIX +#define NO_ST_BLOCKS_IN_STRUCT_STAT +#define NO_NSEC +#define USE_WIN32_MMAP +#define USE_NED_ALLOCATOR + +#define NO_REGEX + +#define NO_SYS_SELECT_H +#define NO_PTHEADS +#define HAVE_STRING_H 1 +#define STDC_HEADERS +#define NO_ICONV + +#define inline __inline +#define __inline__ __inline + +#define SNPRINTF_RETURNS_BOGUS + +#define SHA1_HEADER "mozilla-sha1\\sha1.h" + +#define ETC_GITCONFIG "%HOME%" + +#define NO_PTHREADS +#define NO_CURL + + +#define NO_STRTOUMAX +#define REGEX_MALLOC + + +#define GIT_EXEC_PATH "bin" +#define GIT_VERSION "1.6" +#define BINDIR "bin" +#define PREFIX "." +#define GIT_MAN_PATH "man" +#define GIT_INFO_PATH "info" +#define GIT_HTML_PATH "html" +#define DEFAULT_GIT_TEMPLATE_DIR "templates" + +#define NO_STRLCPY +#define NO_UNSETENV +#define NO_SETENV + +#define strdup _strdup +#define read _read +#define close _close +#define dup _dup +#define dup2 _dup2 +#define strncasecmp _strnicmp +#define strtoull _strtoui64 + +#define __attribute__(x) + +static __inline int strcasecmp (const char *s1, const char *s2) +{ + int size1=strlen(s1); + int sisz2=strlen(s2); + + return _strnicmp(s1,s2,sisz2>size1?sisz2:size1); +} + +#include "compat/mingw.h" +#undef ERROR +#undef stat +#define stat(x,y) mingw_lstat +#define stat _stat64 +#endif \ No newline at end of file diff --git a/compat/vcbuild/include/dirent.h b/compat/vcbuild/include/dirent.h new file mode 100644 index 0000000..a6b6f4c --- /dev/null +++ b/compat/vcbuild/include/dirent.h @@ -0,0 +1,127 @@ +/* + * DIRENT.H (formerly DIRLIB.H) + * This file has no copyright assigned and is placed in the Public Domain. + * This file is a part of the mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER within the package. + * + */ +#ifndef _DIRENT_H_ +#define _DIRENT_H_ + +/* All the headers include this file. */ +//#include <_mingw.h> + +#include + +#define PATH_MAX 512 + +#define __MINGW_NOTHROW + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +struct dirent +{ + long d_ino; /* Always zero. */ + unsigned short d_reclen; /* Always zero. */ + unsigned short d_namlen; /* Length of name in d_name. */ + char d_name[FILENAME_MAX]; /* File name. */ +}; + +/* + * This is an internal data structure. Good programmers will not use it + * except as an argument to one of the functions below. + * dd_stat field is now int (was short in older versions). + */ +typedef struct +{ + /* disk transfer area for this dir */ + struct _finddata_t dd_dta; + + /* dirent struct to return from dir (NOTE: this makes this thread + * safe as long as only one thread uses a particular DIR struct at + * a time) */ + struct dirent dd_dir; + + /* _findnext handle */ + long dd_handle; + + /* + * Status of search: + * 0 = not started yet (next entry to read is first entry) + * -1 = off the end + * positive = 0 based index of next entry + */ + int dd_stat; + + /* given path for dir with search pattern (struct is extended) */ + char dd_name[PATH_MAX+3]; +} DIR; + +DIR* __cdecl __MINGW_NOTHROW opendir (const char*); +struct dirent* __cdecl __MINGW_NOTHROW readdir (DIR*); +int __cdecl __MINGW_NOTHROW closedir (DIR*); +void __cdecl __MINGW_NOTHROW rewinddir (DIR*); +long __cdecl __MINGW_NOTHROW telldir (DIR*); +void __cdecl __MINGW_NOTHROW seekdir (DIR*, long); + + +/* wide char versions */ + +struct _wdirent +{ + long d_ino; /* Always zero. */ + unsigned short d_reclen; /* Always zero. */ + unsigned short d_namlen; /* Length of name in d_name. */ + wchar_t d_name[FILENAME_MAX]; /* File name. */ +}; + +/* + * This is an internal data structure. Good programmers will not use it + * except as an argument to one of the functions below. + */ +typedef struct +{ + /* disk transfer area for this dir */ + //struct _wfinddata_t dd_dta; + + /* dirent struct to return from dir (NOTE: this makes this thread + * safe as long as only one thread uses a particular DIR struct at + * a time) */ + struct _wdirent dd_dir; + + /* _findnext handle */ + long dd_handle; + + /* + * Status of search: + * 0 = not started yet (next entry to read is first entry) + * -1 = off the end + * positive = 0 based index of next entry + */ + int dd_stat; + + /* given path for dir with search pattern (struct is extended) */ + wchar_t dd_name[1]; +} _WDIR; + + + +_WDIR* __cdecl __MINGW_NOTHROW _wopendir (const wchar_t*); +struct _wdirent* __cdecl __MINGW_NOTHROW _wreaddir (_WDIR*); +int __cdecl __MINGW_NOTHROW _wclosedir (_WDIR*); +void __cdecl __MINGW_NOTHROW _wrewinddir (_WDIR*); +long __cdecl __MINGW_NOTHROW _wtelldir (_WDIR*); +void __cdecl __MINGW_NOTHROW _wseekdir (_WDIR*, long); + + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _DIRENT_H_ */ diff --git a/compat/vcbuild/include/unistd.h b/compat/vcbuild/include/unistd.h new file mode 100644 index 0000000..a0f59e6 --- /dev/null +++ b/compat/vcbuild/include/unistd.h @@ -0,0 +1,92 @@ +#ifndef _UNISTD_ +#define _UNISTD_ + +/* Win32 define for porting git*/ + +#ifndef _MODE_T_ +#define _MODE_T_ +typedef unsigned short _mode_t; + +#ifndef _NO_OLDNAMES +typedef _mode_t mode_t; +#endif +#endif /* Not _MODE_T_ */ + +#ifndef _SSIZE_T_ +#define _SSIZE_T_ +typedef long _ssize_t; + +#ifndef _OFF_T_ +#define _OFF_T_ +typedef long _off_t; + +#ifndef _NO_OLDNAMES +typedef _off_t off_t; +#endif +#endif /* Not _OFF_T_ */ + + +#ifndef _NO_OLDNAMES +typedef _ssize_t ssize_t; +#endif +#endif /* Not _SSIZE_T_ */ + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned uint32_t; +typedef long long int64_t; +typedef unsigned long long uint64_t; + +typedef long long intmax_t; +typedef unsigned long long uintmax_t; + +typedef int64_t off64_t; + +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +/* Some defines for _access nAccessMode (MS doesn't define them, but + * it doesn't seem to hurt to add them). */ +#define F_OK 0 /* Check for file existence */ +/* Well maybe it does hurt. On newer versions of MSVCRT, an access mode + of 1 causes invalid parameter error. */ +#define X_OK 0 /* MS access() doesn't check for execute permission. */ +#define W_OK 2 /* Check for write permission */ +#define R_OK 4 /* Check for read permission */ + +#define _S_IFIFO 0x1000 /* FIFO */ +#define _S_IFCHR 0x2000 /* Character */ +#define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */ +#define _S_IFDIR 0x4000 /* Directory */ +#define _S_IFREG 0x8000 /* Regular */ + +#define _S_IFMT 0xF000 /* File type mask */ + +#define _S_IXUSR _S_IEXEC +#define _S_IWUSR _S_IWRITE +#define _S_IRUSR _S_IREAD +#define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) + +#define S_IFIFO _S_IFIFO +#define S_IFCHR _S_IFCHR +#define S_IFBLK _S_IFBLK +#define S_IFDIR _S_IFDIR +#define S_IFREG _S_IFREG +#define S_IFMT _S_IFMT +#define S_IEXEC _S_IEXEC +#define S_IWRITE _S_IWRITE +#define S_IREAD _S_IREAD +#define S_IRWXU _S_IRWXU +#define S_IXUSR _S_IXUSR +#define S_IWUSR _S_IWUSR +#define S_IRUSR _S_IRUSR + + +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) + +#endif \ No newline at end of file diff --git a/compat/vcbuild/sys/time.h b/compat/vcbuild/sys/time.h new file mode 100644 index 0000000..6ed82c0 --- /dev/null +++ b/compat/vcbuild/sys/time.h @@ -0,0 +1,21 @@ +#ifndef _UTIME_H_ +#define _UTIME_H_ +/* + * Structure used by _utime function. + */ +struct _utimbuf +{ + time_t actime; /* Access time */ + time_t modtime; /* Modification time */ +}; + +#ifndef _NO_OLDNAMES +/* NOTE: Must be the same as _utimbuf above. */ +struct utimbuf +{ + time_t actime; + time_t modtime; +}; +#endif /* Not _NO_OLDNAMES */ + +#endif diff --git a/git-compat-util.h b/git-compat-util.h index 9f941e4..cb89294 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -77,8 +77,10 @@ #include #include #include +#ifndef _MSC_VER #include #include +#endif #include #include #include @@ -86,7 +88,12 @@ #include #include #include + +#ifndef _MSC_VER #include +#endif + +#ifndef _MSC_VER #ifndef __MINGW32__ #include #include @@ -114,7 +121,10 @@ #else /* __MINGW32__ */ /* pull in Windows compatibility stuff */ #include "compat/mingw.h" -#endif /* __MINGW32__ */ +#endif /* __MINGW32__ */ +#else /* _MSC_VER */ +#include "compat/msvc.h" +#endif /* _MSC_VER */ #ifndef NO_LIBGEN_H #include -- 1.6.4.msysgit.0 From 84c6da8e081b453c2ae64b1481ab385df5904c95 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 17 Aug 2009 14:59:46 +0800 Subject: [PATCH 10/11] Add MSVC Project file Add libgit.vcproj to build common library. Add git.vcproj to build git program. Signed-off-by: Frank Li --- compat/vcbuild/git/git.vcproj | 197 +++++ compat/vcbuild/libgit/libgit.vcproj | 1347 +++++++++++++++++++++++++++++++++++ 2 files changed, 1544 insertions(+), 0 deletions(-) create mode 100644 compat/vcbuild/git/git.vcproj create mode 100644 compat/vcbuild/libgit/libgit.vcproj diff --git a/compat/vcbuild/git/git.vcproj b/compat/vcbuild/git/git.vcproj new file mode 100644 index 0000000..6f85de3 --- /dev/null +++ b/compat/vcbuild/git/git.vcproj @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/compat/vcbuild/libgit/libgit.vcproj b/compat/vcbuild/libgit/libgit.vcproj new file mode 100644 index 0000000..bbc3aed --- /dev/null +++ b/compat/vcbuild/libgit/libgit.vcproj @@ -0,0 +1,1347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 1.6.4.msysgit.0