Skip to content

Fix the msvc-build scripts (specifically those creating VS projects) for g4w-sdk / g4w #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3f69953
perl/Makefile: treat a missing PM.stamp as if empty
Jul 19, 2015
b3a096e
.gitignore: improve MSVC ignore patterns
Jul 19, 2015
6eeb75b
.gitignore: ignore library directories created by MSVC VS2008 buildsy…
Feb 23, 2015
42c148a
(msvc-build) Vcproj.pm: remove duplicate GUID
Jul 13, 2015
aa42626
engine.pl: fix error message (lib->link)
Jul 19, 2015
5120f16
engine.pl: Properly accept quoted spaces in filenames
Jul 19, 2015
3bb25de
engine.pl: Fix i18n -o option in msvc buildsystem generator
Feb 9, 2015
e5401f4
engine.pl: name the msvc buildsystem's makedry error file
Jul 19, 2015
933d8c5
engine.pl: delete the captured stderr file if empty
Jul 20, 2015
dd21cb3
engine.pl: add debug line to capture the dry-run
Jul 16, 2015
68618e9
engine.pl: provide more debug print statements
Jul 19, 2015
b8a5f78
Vcproj.pm: list git.exe first to be startup project
Jul 19, 2015
47641d2
vcbuild/readme: Improve layout
Jul 19, 2015
3845b02
msvc-build: add complete Microsoft Visual C compilation script
Jul 19, 2015
63bf613
config.mak.uname: add MSVC No_SafeExeceptionHandler option
Jul 19, 2015
7c8955b
Vcproj.pm: provide more GUIDs
Apr 6, 2016
202357b
msvc.h: include sigset_t definition
Apr 21, 2016
ab77303
compat/win32.h: define variable at start of a block
Apr 21, 2016
b04e05e
compat/msvc.h: define O_ACCMODE for MSVC
Apr 21, 2016
614e4a5
_REPARSE_DATA_BUFFER: add MSCV definitions
Apr 22, 2016
e766ed3
regcomp.c & terminal.c: don't always need <stdint.h> or <inttypes.h>
Apr 22, 2016
e2fcf0a
fixup! _REPARSE_DATA_BUFFER:
Apr 25, 2016
f3de733
remote.c: correct __attribute__ spelling
Apr 25, 2016
86c3672
contrib/buildsystems/engine.pl: detect the curl library option
May 4, 2016
d8a01e0
compat/msvc.h: add pragmas for common warnings
May 4, 2016
5c9518c
config.mak.uname: quick fix NO_EXPAT, NO_CURL ?
May 4, 2016
63ebfb8
compat/msvc.h: add more pregmas
May 4, 2016
4a7c8a6
exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions
May 6, 2016
88bee55
Initialise variables: get past a compiler workaround
May 6, 2016
20d2f5f
fixup! exec_cmd.c
May 10, 2016
b75e351
fast-import.c: remove old compiler workaround
May 10, 2016
91ef678
msvc.h, mingw.h: continue to clear errors: ftello and curl
May 12, 2016
71915be
git-compat-util.h: add SUPPRESS_UNINITIALIZD_WARNINGS value definition
May 12, 2016
42041f7
wip debug: capture the dry run as a text file
Jun 16, 2016
cc1b013
msvc-build: beginnings of Post Build step
Jun 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
/gitweb/gitweb.cgi
/gitweb/static/gitweb.js
/gitweb/static/gitweb.min.*
/libgit
/test-chmtime
/test-ctype
/test-config
Expand Down Expand Up @@ -213,6 +214,8 @@
/test-urlmatch-normalization
/test-wildmatch
/common-cmds.h
/vcs-svn_lib
/xdiff_lib
*.tar.gz
*.dsc
*.deb
Expand Down Expand Up @@ -250,8 +253,9 @@
*.user
*.idb
*.pdb
/Debug/
/Release/
*.manifest
Debug/
Release/
/.vagrant/
/vagrant2[0-9][0-9][0-9]*-*-*
/d2[0-9][0-9][0-9]*-*-*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX
exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \
'-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \
'-DBINDIR="$(bindir_relative_SQ)"' \
'-DPREFIX="$(prefix_SQ)"'
'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'

builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX
builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
Expand Down
2 changes: 1 addition & 1 deletion builtin/rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
mark_edges_uninteresting(&revs, show_edge);

if (bisect_list) {
int reaches = reaches, all = all;
int reaches = 0, all = 0;

revs.commits = find_bisection(revs.commits, &reaches, &all,
bisect_find_all);
Expand Down
2 changes: 1 addition & 1 deletion compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2287,7 +2287,7 @@ int symlink(const char *target, const char *link)
return 0;
}

#ifndef _WINNT_H
#if !defined(_WINNT_H) && !defined(_MSC_VER)
/*
* The REPARSE_DATA_BUFFER structure is defined in the Windows DDK (in
* ntifs.h) and in MSYS1's winnt.h (which defines _WINNT_H). So define
Expand Down
8 changes: 8 additions & 0 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ typedef _sigset_t sigset_t;
#include <winsock2.h>
#include <ws2tcpip.h>

#pragma comment(lib, "Ws2_32.lib")
/* add the MS linker for winsock2 when compiling on Visual Studio
https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629%28v=vs.85%29.aspx*/

#pragma comment(lib, "wldap32.lib")
/* some ()https://curl.haxx.se/mail/lib-2007-11/0297.html) report that this clears the
unresolved external symbol __imp__curl_* errors */

/* MinGW-w64 reports to have flockfile, but it does not actually have it. */
#ifdef __MINGW64_VERSION_MAJOR
#undef _POSIX_THREAD_SAFE_FUNCTIONS
Expand Down
50 changes: 50 additions & 0 deletions compat/msvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <malloc.h>
#include <io.h>

#pragma warning(disable: 4018) /* signed/unsigned comparison */
#pragma warning(disable: 4244) /* type conversion, possible loss of data */
#pragma warning(disable: 4090) /* 'function' : different 'const' qualifiers (ALLOC_GROW etc.)*/

/* porting function */
#define inline __inline
#define __inline__ __inline
Expand All @@ -24,6 +28,52 @@ static __inline int strcasecmp (const char *s1, const char *s2)

#undef ERROR

#ifdef _MSC_VER
typedef int sigset_t;
#define O_ACCMODE _O_RDWR /* open for reading and writing (not in fcntl.h) */

/* http://thompsonng.blogspot.co.uk/2011/09/vs2010-fseeko.html */
#ifdef _WIN32
# ifdef __MINGW32__
# define fseeko fseeko64
# define ftello ftello64
# else
# define fseeko _fseeki64
# define ftello _ftelli64
# endif
#endif

/* https://msdn.microsoft.com/en-us/library/ff552012.aspx */
typedef struct _REPARSE_DATA_BUFFER {
ULONG ReparseTag;
USHORT ReparseDataLength;
USHORT Reserved;
union {
struct {
USHORT SubstituteNameOffset;
USHORT SubstituteNameLength;
USHORT PrintNameOffset;
USHORT PrintNameLength;
ULONG Flags;
WCHAR PathBuffer[1];
} SymbolicLinkReparseBuffer;
struct {
USHORT SubstituteNameOffset;
USHORT SubstituteNameLength;
USHORT PrintNameOffset;
USHORT PrintNameLength;
WCHAR PathBuffer[1];
} MountPointReparseBuffer;
struct {
UCHAR DataBuffer[1];
} GenericReparseBuffer;
};
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;

/* in the absence of the ntifs.h DDK (device driver development kit) */

#endif

#include "compat/mingw.h"

#endif
4 changes: 4 additions & 0 deletions compat/regex/regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. */

#if defined(_MSC_VER) && _MSC_VER<=1500

#else
#include <stdint.h>
#endif

static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
size_t length, reg_syntax_t syntax);
Expand Down
6 changes: 5 additions & 1 deletion compat/terminal.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <inttypes.h>
#include "git-compat-util.h"
#include "run-command.h"
#if defined(_MSC_VER) && _MSC_VER<=1500

#else
#include <inttypes.h>
#endif
#include "compat/terminal.h"
#include "sigchain.h"
#include "strbuf.h"
Expand Down
27 changes: 19 additions & 8 deletions compat/vcbuild/README
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ The Steps of Build Git with VS2008
1. You need the build environment, which contains the Git dependencies
to be able to compile, link and run Git with MSVC.

You can either use the binary repository:
You can either:
use the binary repository:

WWW: http://repo.or.cz/w/msvcgit.git
Git: git clone git://repo.or.cz/msvcgit.git
Zip: http://repo.or.cz/w/msvcgit.git?a=snapshot;h=master;sf=zip

and call the setup_32bit_env.cmd batch script before compiling Git,
(see repo/package README for details), or the source repository:
and call the setup_32bit_env.cmd batch script before compiling Git,
(see repo/package README for details),

or:
use the source repository:

WWW: http://repo.or.cz/w/gitbuild.git
Git: git clone git://repo.or.cz/gitbuild.git
Zip: (None, as it's a project with submodules)

and build the support libs as instructed in that repo/package.
and build the support libs as instructed in that repo/package.

2. Ensure you have the msysgit environment in your path, so you have
GNU Make, bash and perl available.
Expand All @@ -33,18 +37,25 @@ The Steps of Build Git with VS2008
make common-cmds.h
to generate the common-cmds.h file needed to compile git.

4. Then either build Git with the GNU Make Makefile in the Git projects
root
4. Then either

build Git with the GNU Make Makefile in the Git projects root
make MSVC=1
or generate Visual Studio solution/projects (.sln/.vcproj) with the
or

generate Visual Studio solution/projects (.sln/.vcproj) with the
command
perl contrib/buildsystems/generate -g Vcproj
and open and build the solution with the IDE
devenv git.sln /useenv
or build with the IDE build engine directly from the command line
or

build with the IDE build engine directly from the command line
devenv git.sln /useenv /build "Release|Win32"
The /useenv option is required, so Visual Studio picks up the
environment variables for the support libraries required to build
Git, which you set up in step 1.

Done!

Or, use the msvc-build script; available from /compat/vcbuild/scripts/.
86 changes: 86 additions & 0 deletions compat/vcbuild/scripts/msvc-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/sh

# This msvc-build command should be executed from the msysgit directory level
# This is so that the 'cd/git' step works and the subequent operations have the right msysgit super directory.
set -e # Exit immediately if a command exits with a nonzero exit status.

gui=
clean=
while test $# -gt 0
do
case "$1" in
--gui|--dev|--devenv|--vs|--visual-studio)
gui=t
;;
clean)
clean=t
;;
*)
echo "Usage: $0 [--vs] [clean]" >&2
exit 1
;;
esac
shift
done

cd $(git rev-parse --show-toplevel)

case "$clean" in
t)
case "$gui" in
t)
rm -rf git.sln git.sdf libgit vcs-svn_lib xdiff_lib
# remove any other new VS2010... stuff as well: rm -rf ?
;;
'')
make clean
;;
esac
exit
;;
esac

to_ignore="$(git ls-files --other --exclude-standard msvcgit msvc-build.cmd)"
test -z "$to_ignore" || {
mkdir -p .git/info &&
echo "$to_ignore" |
sed 's/^/\//' >> .git/info/exclude
} || exit

test -d msvcgit || git clone git://repo.or.cz/msvcgit.git

This comment was marked as off-topic.

This comment was marked as off-topic.


vsvars=
# assume cl.exe will populate its relevant environment variables
# if cl.exe does not exist, populate vsvars with the most recent Visual Studio path
type cl.exe 2> /dev/null ||
vsvars="$(ls -t \
"$PROGRAMFILES/Microsoft Visual Studio"*/Common7/Tools/vsvars32.bat |

This comment was marked as off-topic.

This comment was marked as off-topic.

head -n 1)"


config_mak=
# if a config.mak file (dot, not underscore) exists, back it up,
# remember the backup file name in config_mak.
test -f config.mak &&
config_mak=config.mak.bup.$$ &&
mv config.mak $config_mak

cat > config.mak << EOF
CFLAGS += -Imsvcgit/32bits/include
LDFLAGS += -Lmsvcgit/32bits/lib
EOF

echo "call \"$vsvars\"" > msvc-build.cmd
if test -z "$gui"
then
echo 'make MSVC=1' >> msvc-build.cmd
else
echo 'perl contrib/buildsystems/generate -g Vcproj' >> msvc-build.cmd
echo 'start git.sln' >> msvc-build.cmd
fi

cmd /c msvc-build.cmd

# if we made a backup file (name in config_mak), then restore it.
test -z "$config_mak" ||
mv $config_mak config.mak
4 changes: 3 additions & 1 deletion compat/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ static inline void *get_proc_addr(struct proc_addr *proc)
/* only do this once */
if (!proc->initialized) {
proc->initialized = 1;
HANDLE hnd = LoadLibraryA(proc->dll);
{
HMODULE hnd = LoadLibraryA(proc->dll);
if (hnd)
proc->pfunction = GetProcAddress(hnd, proc->function);
}
}
/* set ENOSYS if DLL or function was not found */
if (!proc->pfunction)
Expand Down
12 changes: 12 additions & 0 deletions config.mak.uname
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Platform specific Makefile tweaks based on uname detection

# Define NO_SAFESEH if you need MSVC/Visual Studio to ignore the lack of
# Microsoft's Safe Exception Handling in libraries (such as zlib).
# Typically required for VS2013+/32-bit compilation on Vista+ versions.

uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
Expand Down Expand Up @@ -370,6 +374,9 @@ ifeq ($(uname_S),Windows)
NATIVE_CRLF = YesPlease
DEFAULT_HELP_FORMAT = html

NO_EXPAT =
NO_CURL =

CC = compat/vcbuild/scripts/clink.pl
AR = compat/vcbuild/scripts/lib.pl
CFLAGS =
Expand All @@ -383,6 +390,11 @@ ifeq ($(uname_S),Windows)
PTHREAD_LIBS =
lib =
BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1

ifdef NO_SAFESEH
LDFLAGS += -SAFESEH:NO
endif

ifndef DEBUG
BASIC_CFLAGS += -GL -Os -MD
BASIC_LDFLAGS += -LTCG
Expand Down
Loading