From 3f69953d86fbf4375dd62f623a0581a723d229e9 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 15:59:04 +0100 Subject: [PATCH 01/35] perl/Makefile: treat a missing PM.stamp as if empty 'make clean', or a 'git clean -dfx' will delete the PM stamp file, so it cannot be a direct target in such clean conditions, resulting in an error. Normally the PM.stamp is recreated by the git/Makefile, except when a dry-run is requested, for example, as used in the msysgit msvc-build script which implements the compat/vcbuild/README using contrib/buildsystems. The script msvc-build is introduced later in this series. Protect the PM.stamp target when the PM.stamp file does not exist, allowing a Git 'Makefile -n' to succeed on a clean repo. Signed-off-by: Philip Oakley --- This is development of the original "[PATCH 4/17] Makefile: a dry-run can error out if no perl. Document the issue" 2015-06-25, (http://marc.info/?l=git&m=143519054716960&w=2), which simply documented the issue and then used NO_PERL to avoid the problem. See follow on email thread for some discussion. --- perl/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/perl/Makefile b/perl/Makefile index 15d96fcc7a5a81..5b86aac41cc5bd 100644 --- a/perl/Makefile +++ b/perl/Makefile @@ -22,7 +22,9 @@ clean: $(RM) $(makfile).old $(RM) PM.stamp +ifneq (,$(wildcard PM.stamp)) $(makfile): PM.stamp +endif ifdef NO_PERL_MAKEMAKER instdir_SQ = $(subst ','\'',$(prefix)/lib) From b3a096ee16a3ba55658b7237282dc0b097403c77 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 16:02:40 +0100 Subject: [PATCH 02/35] .gitignore: improve MSVC ignore patterns Add the Microsoft .manifest pattern, and correct the generic 'Debug' and 'Release' directory patterns which were mechanically adjusted way back in c591d5f (gitignore: root most patterns at the top-level directory, 2009-10-26) to allow multi-level projects within the Git suite. Signed-off-by: Philip Oakley --- Junio's correction http://marc.info/?l=git&m=143524522500906&w=2 (2015-06-25) --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0af86fb7e05ee1..6a554f4ddaaaf2 100644 --- a/.gitignore +++ b/.gitignore @@ -250,8 +250,9 @@ *.user *.idb *.pdb -/Debug/ -/Release/ +*.manifest +Debug/ +Release/ /.vagrant/ /vagrant2[0-9][0-9][0-9]*-*-* /d2[0-9][0-9][0-9]*-*-* From 6eeb75bfb0e4eaffafa19c1c6ebd819cf6cae8e9 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 23 Feb 2015 12:50:35 +0000 Subject: [PATCH 03/35] .gitignore: ignore library directories created by MSVC VS2008 buildsystem Signed-off-by: Philip Oakley --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 6a554f4ddaaaf2..bf3acc08b7f8ae 100644 --- a/.gitignore +++ b/.gitignore @@ -179,6 +179,7 @@ /gitweb/gitweb.cgi /gitweb/static/gitweb.js /gitweb/static/gitweb.min.* +/libgit /test-chmtime /test-ctype /test-config @@ -213,6 +214,8 @@ /test-urlmatch-normalization /test-wildmatch /common-cmds.h +/vcs-svn_lib +/xdiff_lib *.tar.gz *.dsc *.deb From 42c148a53f63075187573724eedabad04c932f3b Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 13 Jul 2015 13:59:55 +0100 Subject: [PATCH 04/35] (msvc-build) Vcproj.pm: remove duplicate GUID Delete the duplicated GUID from the generation code for the Visual Studio .sln project file. The duplicate GUID tended to be allocated to test-svn-fe, which was then ignored by Visual Studio / MSVC, and its omission from the build never noticed. Signed-off-by: Philip Oakley --- Eric Sunshine correction http://marc.info/?l=git&m=143546075320855&w=2 --- contrib/buildsystems/Generators/Vcproj.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index cfa74adcc23881..1b01d5821fb5d7 100644 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ b/contrib/buildsystems/Generators/Vcproj.pm @@ -52,7 +52,6 @@ my @GUIDS = ( "{00785268-A9CC-4E40-AC29-BAC0019159CE}", "{4C06F56A-DCDB-46A6-B67C-02339935CF12}", "{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}", - "{3A62D3FD-519E-4EC9-8171-D2C1BFEA022F}", "{9392EB58-D7BA-410B-B1F0-B2FAA6BC89A7}", "{2ACAB2D5-E0CE-4027-BCA0-D78B2D7A6C66}", "{86E216C3-43CE-481A-BCB2-BE5E62850635}", From aa42626d82e2b090bfef64b1f0fc42514b9df9ae Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 17:41:13 +0100 Subject: [PATCH 05/35] engine.pl: fix error message (lib->link) Signed-off-by: Philip Oakley --- contrib/buildsystems/engine.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 53e65d4db713c3..11f0e16ddacb89 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -333,7 +333,7 @@ sub handleLinkLine } elsif ($part =~ /\.obj$/) { # do nothing, 'make' should not be producing .obj, only .o files } else { - die "Unhandled lib option @ line $lineno: $part"; + die "Unhandled link option @ line $lineno: $part"; } } # print "AppOut: '$appout'\nLFlags: @lflags\nLibs : @libs\nOfiles: @objfiles\n"; From 5120f16d415d0c82555362cf43d85f6929bf1162 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 16:08:21 +0100 Subject: [PATCH 06/35] engine.pl: Properly accept quoted spaces in filenames The engine.pl script barfs on the properly quoted spaces in filename options prevalent on Windows. Use shellwords() rather than split() to separate such options. Helped-by: Junio C Hamano Signed-off-by: Philip Oakley --- Junio's help at gmane.comp.version-control.msysgit/21145 (2014-11-21) & gmane.comp.version-control.msysgit/21147 (2014-11-21) --- contrib/buildsystems/engine.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 11f0e16ddacb89..ad6a82c30ce808 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -12,6 +12,7 @@ use File::Spec; use Cwd; use Generators; +use Text::ParseWords; my (%build_structure, %compile_options, @makedry); my $out_dir = getcwd(); @@ -231,7 +232,7 @@ sub removeDuplicates sub handleCompileLine { my ($line, $lineno) = @_; - my @parts = split(' ', $line); + my @parts = shellwords($line); my $sourcefile; shift(@parts); # ignore cmd while (my $part = shift @parts) { @@ -265,7 +266,7 @@ sub handleLibLine my (@objfiles, @lflags, $libout, $part); # kill cmd and rm 'prefix' $line =~ s/^rm -f .* && .* rcs //; - my @parts = split(' ', $line); + my @parts = shellwords($line); while ($part = shift @parts) { if ($part =~ /^-/) { push(@lflags, $part); @@ -306,7 +307,7 @@ sub handleLinkLine { my ($line, $lineno) = @_; my (@objfiles, @lflags, @libs, $appout, $part); - my @parts = split(' ', $line); + my @parts = shellwords($line); shift(@parts); # ignore cmd while ($part = shift @parts) { if ($part =~ /^-IGNORE/) { From 3bb25dee10cf6220010109b0f62209e2aa7c50b1 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 9 Feb 2015 14:34:29 +0000 Subject: [PATCH 07/35] engine.pl: Fix i18n -o option in msvc buildsystem generator The i18n 5e9637c (i18n: add infrastructure for translating Git with gettext, 2011-11-18) introduced an extra '-o' option into the make file. If the msvc buildsystem is run without NO_GETTEXT being set then this broke the engine.pl code for extracting the git.sln for msvc gui-IDE. The setting of NO_GETTEXT was not fixed until later, relative to the Msysgit project where this issue was being investigated. The presence of these options in the Makefile output should not compromise the derived build structure. They should be ignored. Add tests to remove these non linker options, in same vein as 74cf9bd (engine.pl: Fix a recent breakage of the buildsystem generator, 2010-01-22). Signed-off-by: Philip Oakley --- contrib/buildsystems/engine.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index ad6a82c30ce808..9db3d43a1eb2f7 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -141,6 +141,12 @@ sub parseMakeOutput next; } + if ($text =~ /^(mkdir|msgfmt) /) { + # options to the Portable Object translations + # the line "mkdir ... && msgfmt ..." contains no linker options + next; + } + if($text =~ / -c /) { # compilation handleCompileLine($text, $line); From e5401f41c07e310abcc8cde988b82fa1956da8ed Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 16:45:32 +0100 Subject: [PATCH 08/35] engine.pl: name the msvc buildsystem's makedry error file Save the stderr from the dry MSVC make to a well named file for later review. Use 'msvc-build-makedryerrors.txt' which should be obvious as to its source, and is not ignored by 'git status'. Signed-off-by: Philip Oakley --- fixed false mode change:- Junio's report (last line of) http://marc.info/?l=git&m=143524504500824 (2015-06-25), The cause was probably an early 'commit --amend' during a rebase, and using the git gui to unstage the whole commit, then pick up and commit hunks one at a time. Unfortunately, on Msysgit/g4w core.filemode is false, so the execute bit was lost during the unstage, never noticed, and there's no simple way of adding it back. Discussion on correcting file mode on msysgit/git4Windows is at https://groups.google.com/forum/#!topic/msysgit/zwH-qj0xR48 --- contrib/buildsystems/engine.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 9db3d43a1eb2f7..a6999b6254add1 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -73,7 +73,10 @@ sub showUsage EOM # Pipe a make --dry-run into a variable, if not already loaded from file -@makedry = `cd $git_dir && make -n MSVC=1 V=1 2>/dev/null` if !@makedry; +# Capture the make dry stderr to file for review (will be empty for a release build). + +my $ErrsFile = "msvc-build-makedryerrors.txt"; +@makedry = `cd $git_dir && make -n MSVC=1 V=1 2>$ErrsFile` if !@makedry; # Parse the make output into usable info parseMakeOutput(); From 933d8c5a8f62ede453015385034b4349120fbbab Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 20 Jul 2015 17:02:56 +0100 Subject: [PATCH 09/35] engine.pl: delete the captured stderr file if empty Keep the build clean of extraneous files if it is indeed clean. Otherwise leave the msvc-build-makedryerrors.txt file both as a flag for any CI system or for manual debugging. Alternatively, with improved syntactic sugar[1]: unlink $ErrsFile if -f -z $ErrsFile; could be used but requires Perl 5.10 or later, which is not available on Msysgit, but is available on the newer Git-for-Windows SDK on Msys2 [2]. Note that the file will contain the new values of the GIT_VERSION and GITGUI_VERSION if they were generated by the make file. They are omitted if the release is tagged and indentically defined in their respective GIT_VERSION_GEN file DEF_VER variables. [1]: http://perldoc.perl.org/functions/-X.html [2]: http://git-for-windows.github.io/ Helped-by: Eric Sunshine Signed-off-by: Philip Oakley --- Eric's help gmane.comp.version-control.msysgit/21745 --- contrib/buildsystems/engine.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index a6999b6254add1..154575d1d7c119 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -77,6 +77,8 @@ sub showUsage my $ErrsFile = "msvc-build-makedryerrors.txt"; @makedry = `cd $git_dir && make -n MSVC=1 V=1 2>$ErrsFile` if !@makedry; +# test for an empty Errors file and remove it +unlink $ErrsFile if -f $ErrsFile && -z _; # Parse the make output into usable info parseMakeOutput(); From dd21cb38b1d69d94d92148d4d9c1abb07ce4dd7e Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Thu, 16 Jul 2015 23:40:13 +0100 Subject: [PATCH 10/35] engine.pl: add debug line to capture the dry-run Add a debug suggestion for capturing to file the stdout from the dry-run of the make file used in determining the msvc-build structure for easy debugging. Signed-off-by: Philip Oakley --- contrib/buildsystems/engine.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 154575d1d7c119..42749fe44fa944 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -76,6 +76,7 @@ sub showUsage # Capture the make dry stderr to file for review (will be empty for a release build). my $ErrsFile = "msvc-build-makedryerrors.txt"; +#@makedry = `cd $git_dir && make -n MSVC=1 V=1 1>makedry.txt 2>$ErrsFile`; # capture the dry run as a text file @makedry = `cd $git_dir && make -n MSVC=1 V=1 2>$ErrsFile` if !@makedry; # test for an empty Errors file and remove it unlink $ErrsFile if -f $ErrsFile && -z _; From 68618e9a468bd5d8ecf646a533bc5fac7d323b77 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 16:48:45 +0100 Subject: [PATCH 11/35] engine.pl: provide more debug print statements Assist developers transitioning between the two cultures by including appropriate, but commented out, debug statements. The exception is when an unhandled compiler option is detected, where printing of the full line will supplement the line number and option part. Otherwise the OP has no immediate mechanism for inspecting the relevant part of the makedry output. The commented out code is "deactivated code", not dead code, as per DO178B safety critical software development guideline [1]. These debug print statements act as a guide for a poor man's --verbose option. The test suite doesn't cover the contrib/buildsystems (or Msysgit's msvc-build) contributions so fails to notice breakages there-in. It is doubly hard to get developers to ride both horses so, contrary to normal convention, retain selected debug statements as a safety net for those willing to try. [1] Dead code : Dead code is source code (and it is a part of binary code) that is not executed in the final system and it will be not having traceability to any requirements (one can say unintentional code). Deactivated code: code which is commented out or removed via #ifdef's (it is not a part of final binary code) and it will be having traceability to its low level requirements (its a intentional code and it can be activated in some configurations through hardware traps for debugging or other purposes. Signed-off-by: Philip Oakley --- My response to Sebastian Schuberth's comment on dead code http://marc.info/?l=git&m=143630748919942&w=2 (2015-07-07) --- contrib/buildsystems/engine.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 42749fe44fa944..75300ab0648145 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -41,6 +41,7 @@ sub showUsage # Parse command-line options while (@ARGV) { my $arg = shift @ARGV; + #print "Arg: $arg \n"; if ("$arg" eq "-h" || "$arg" eq "--help" || "$arg" eq "-?") { showUsage(); exit(0); @@ -129,6 +130,7 @@ sub parseMakeOutput print "Parsing GNU Make output to figure out build structure...\n"; my $line = 0; while (my $text = shift @makedry) { + #print "Make: $text\n"; # show the makedry line my $ate_next; do { $ate_next = 0; @@ -263,6 +265,7 @@ sub handleCompileLine } elsif ($part =~ /\.(c|cc|cpp)$/) { $sourcefile = $part; } else { + print "full line: $line\n"; die "Unhandled compiler option @ line $lineno: $part"; } } @@ -288,6 +291,7 @@ sub handleLibLine $libout = $part; $libout =~ s/\.a$//; } else { + print "full line: $line\n"; die "Unhandled lib option @ line $lineno: $part"; } } From b8a5f78b9e583c60b11a5a7f22bb9768ca3f101f Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 17:43:29 +0100 Subject: [PATCH 12/35] Vcproj.pm: list git.exe first to be startup project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Visual Studio takes the first listed application/library as the default startup project [1]. Detect the 'git' project and place it the head of the apps list, rather than the tail. Export the apps list before libs list for both the projects and global structures of the .sln file. [1] http://stackoverflow.com/questions/1238553/ vs2008-where-is-the-startup-project-setting-stored-for-a-solution "In the solution file, there are a list of pseudo-XML "Project" entries. It turns out that whatever is the first one ends up as the Startup Project, unless it’s overridden in the suo file. Argh. I just rearranged the order in the file and it’s good." "just moving the pseudo-xml isn't enough. You also have to move the group of entries in the "GlobalSection(ProjectConfigurationPlatforms) = postSolution" group that has the GUID of the project you moved to the top. So there are two places to move lines." Signed-off-by: Philip Oakley --- contrib/buildsystems/Generators/Vcproj.pm | 33 +++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index 1b01d5821fb5d7..cc2fa21533d271 100644 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ b/contrib/buildsystems/Generators/Vcproj.pm @@ -560,20 +560,18 @@ sub createGlueProject { foreach (@apps) { $_ =~ s/\//_/g; $_ =~ s/\.exe//; - push(@tmp, $_); + if ($_ eq "git" ) { + unshift(@tmp, $_); + } else { + push(@tmp, $_); + } } @apps = @tmp; open F, ">git.sln" || die "Could not open git.sln for writing!\n"; binmode F, ":crlf"; print F "$SLN_HEAD"; - foreach (@libs) { - my $libname = $_; - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; - print F "$SLN_PRE"; - print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\""; - print F "$SLN_POST"; - } + my $uuid_libgit = $build_structure{"LIBS_libgit_GUID"}; my $uuid_xdiff_lib = $build_structure{"LIBS_xdiff_lib_GUID"}; foreach (@apps) { @@ -587,6 +585,13 @@ sub createGlueProject { print F " EndProjectSection"; print F "$SLN_POST"; } + foreach (@libs) { + my $libname = $_; + my $uuid = $build_structure{"LIBS_${libname}_GUID"}; + print F "$SLN_PRE"; + print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\""; + print F "$SLN_POST"; + } print F << "EOM"; Global @@ -598,17 +603,17 @@ EOM print F << "EOM"; GlobalSection(ProjectConfigurationPlatforms) = postSolution EOM - foreach (@libs) { - my $libname = $_; - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; + foreach (@apps) { + my $appname = $_; + my $uuid = $build_structure{"APPS_${appname}_GUID"}; print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n"; print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n"; print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n"; print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n"; } - foreach (@apps) { - my $appname = $_; - my $uuid = $build_structure{"APPS_${appname}_GUID"}; + foreach (@libs) { + my $libname = $_; + my $uuid = $build_structure{"LIBS_${libname}_GUID"}; print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n"; print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n"; print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n"; From 47641d2a459dc45b2ee08707687b98ab0dd00c48 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 17:48:09 +0100 Subject: [PATCH 13/35] vcbuild/readme: Improve layout Layout the 'either/or' with more white space to clarify which alternatives are matched up. A revised copy of the Msysgit msvc-build script which automates this README is introduced in the next commit. Signed-off-by: Philip Oakley --- compat/vcbuild/README | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/compat/vcbuild/README b/compat/vcbuild/README index df8a6574c9ac24..ad8633eb20da13 100644 --- a/compat/vcbuild/README +++ b/compat/vcbuild/README @@ -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. @@ -33,15 +37,20 @@ 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 From 3845b02b330cdbd543ae0893af408e39a96eb69a Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 18:07:10 +0100 Subject: [PATCH 14/35] msvc-build: add complete Microsoft Visual C compilation script Implement the README to facilitate cross community development. Include comments for those Windows folks not yet fully familiar with bash commands. This is identical to the msysgit script, except for the 'cd toplevel' step, and comments for the edification of converts from Windows. Original author: Johannes Schindelin (2011-11-01 3142da4 : Add a script to make the MSVC build more convenient) on Msysgit https://github.com/msysgit/msysgit/commit/3142da4038 and subsequent development. The --gui clean now also removes the VS2010 .sdf file, and the vcs-svn_lib & xdiff_lib directories. The script is made executable in line with $msysgit/cb9836b8a (Mark scripts and binaries in /bin/ as executable, 2012-06-26) Signed-off-by: Philip Oakley --- TODO: resolve any further cleaning of newer VS2010... build products. --- compat/vcbuild/README | 2 + compat/vcbuild/scripts/msvc-build | 86 +++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100755 compat/vcbuild/scripts/msvc-build diff --git a/compat/vcbuild/README b/compat/vcbuild/README index ad8633eb20da13..faaea69852c448 100644 --- a/compat/vcbuild/README +++ b/compat/vcbuild/README @@ -57,3 +57,5 @@ The Steps of Build Git with VS2008 Git, which you set up in step 1. Done! + +Or, use the msvc-build script; available from /compat/vcbuild/scripts/. diff --git a/compat/vcbuild/scripts/msvc-build b/compat/vcbuild/scripts/msvc-build new file mode 100755 index 00000000000000..d67203b51cb882 --- /dev/null +++ b/compat/vcbuild/scripts/msvc-build @@ -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 + +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 | + 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 From 63bf6138986703b0416a3487761eace81981dc68 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sun, 19 Jul 2015 17:03:15 +0100 Subject: [PATCH 15/35] config.mak.uname: add MSVC No_SafeExeceptionHandler option Microsoft flipped the Windows Safe Exception Handling default in VS2013 so that zlib became unacceptable to certain OS versions (Vista and subsequent 32-bit OS's) without the addition of the option -SAFESEH:NO. Provide a switch to disable the Safe Exeption Handler when required. The option ImageHasSafeExceptionHandlers for VS2013 is not available in earlier versions, so use the SAFESEH:NO linker flag. See https://msdn.microsoft.com/en-us/library/9a89h429.aspx for further details. This has only had limited testing due to the lack of a suitable system. Helped-by: Yue Lin Ho Signed-off-by: Philip Oakley --- Junio/my discussion on reviews: http://marc.info/?l=git&m=143526063906215&w=2 (2015-06-25) Patch series v1: https://github.com/msysgit/git/pull/318 Yue Lin Ho: https://github.com/msysgit/git/pull/318#issuecomment-81292918 --- config.mak.uname | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config.mak.uname b/config.mak.uname index ac81fddf6f893d..1e3b7cb61f2497 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -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') @@ -383,6 +387,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 From 7c8955b25ca5f594e2fc2265242e16691c25cf47 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 6 Apr 2016 15:24:42 +0100 Subject: [PATCH 16/35] Vcproj.pm: provide more GUIDs Needed for: test-config; t-dump-split-index; t-dump-untracked-cache; t-fake-ssh; t-sha1-array; t-submodule-config. Plus a few spares. Signed-off-by: Philip Oakley --- contrib/buildsystems/Generators/Vcproj.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm index cc2fa21533d271..0572ba8609670f 100644 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ b/contrib/buildsystems/Generators/Vcproj.pm @@ -62,7 +62,14 @@ my @GUIDS = ( "{294BDC5A-F448-48B6-8110-DD0A81820F8C}", "{4B9F66E9-FAC9-47AB-B1EF-C16756FBFD06}", "{72EA49C6-2806-48BD-B81B-D4905102E19C}", - "{5728EB7E-8929-486C-8CD5-3238D060E768}" + "{5728EB7E-8929-486C-8CD5-3238D060E768}", + "{A3E300FC-5630-4850-A470-E9F2C2EFA7E7}", + "{CEA071D4-D9F3-4250-98F7-44AFDC8ACAA1}", + "{3FD87BB4-2236-4A1B-ADD2-46211A302442}", + "{49B03F41-5157-4079-95A7-64D728BCF74F}", + "{95D5A28B-80E2-40A9-BEA3-C52B9CA488E3}", + "{B85E6545-D523-4323-9F29-45389D090343}", + "{06840CEF-746C-4B71-9442-C395DD6590A5}" ); sub generate { From 202357b1314371201ad657c24b3bb44bfe493fb5 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Thu, 21 Apr 2016 14:07:20 +0100 Subject: [PATCH 17/35] msvc.h: include sigset_t definition On MSVC (VS2008) sigset_t is not defined. Signed-off-by: Philip Oakley --- compat/msvc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compat/msvc.h b/compat/msvc.h index 580bb55bf4a71d..c64d5a56b20507 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -24,6 +24,10 @@ static __inline int strcasecmp (const char *s1, const char *s2) #undef ERROR +#ifdef _MSC_VER +typedef int sigset_t; +#endif + #include "compat/mingw.h" #endif From ab7730341b17112c618771acf2531070ace75d0e Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Thu, 21 Apr 2016 14:51:12 +0100 Subject: [PATCH 18/35] compat/win32.h: define variable at start of a block In C89 (as assumed by MSVC for files *.[ch]) variables must be defined at teh start of a block of function. Place the variable usage inside a {} block. Signed-off-by: Philip Oakley --- compat/win32.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compat/win32.h b/compat/win32.h index a7b81dcd29fa41..dce893c8d47278 100644 --- a/compat/win32.h +++ b/compat/win32.h @@ -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) From b04e05eb96e02af00f7289152a50b461e4e739d7 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Thu, 21 Apr 2016 14:52:05 +0100 Subject: [PATCH 19/35] compat/msvc.h: define O_ACCMODE for MSVC Signed-off-by: Philip Oakley --- compat/msvc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/msvc.h b/compat/msvc.h index c64d5a56b20507..7156fadbc28e36 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -26,6 +26,7 @@ static __inline int strcasecmp (const char *s1, const char *s2) #ifdef _MSC_VER typedef int sigset_t; +#define O_ACCMODE _O_RDWR /* open for reading and writing (not in fcntl.h) */ #endif #include "compat/mingw.h" From 614e4a5375899b79a59f6d27b5277f774aa30c7a Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Fri, 22 Apr 2016 10:48:13 +0100 Subject: [PATCH 20/35] _REPARSE_DATA_BUFFER: add MSCV definitions gcc and MSVC disagree about using the gcc extension _ANONYNOUS_UNION. Add the Microsoft definition of the _REPARSE_DATA_BUFFER struct to msvc.h and improve the conditional in mingw.c Signed-off-by: Philip Oakley --- compat/mingw.c | 2 +- compat/msvc.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index e2e5d2f6b776de..fab6d117735201 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -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 diff --git a/compat/msvc.h b/compat/msvc.h index 7156fadbc28e36..a58b85b610d85c 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -27,6 +27,36 @@ static __inline int strcasecmp (const char *s1, const char *s2) #ifdef _MSC_VER typedef int sigset_t; #define O_ACCMODE _O_RDWR /* open for reading and writing (not in fcntl.h) */ + +/* 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" From e766ed3a3d26d48f43214fb0f70ba6cc65306c4b Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Fri, 22 Apr 2016 13:33:33 +0100 Subject: [PATCH 21/35] regcomp.c & terminal.c: don't always need or These files are not available in the MSVC versions, but their definitions are stubbed elsewhere. Only include them if not on MSVC. Signed-off-by: Philip Oakley --- compat/regex/regcomp.c | 4 ++++ compat/terminal.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c index fba5986399ed20..1c5824999ea3e1 100644 --- a/compat/regex/regcomp.c +++ b/compat/regex/regcomp.c @@ -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 +#endif static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, size_t length, reg_syntax_t syntax); diff --git a/compat/terminal.c b/compat/terminal.c index 1d37f0aafbaeb7..8ca9fce2b229b8 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -1,6 +1,10 @@ -#include #include "git-compat-util.h" #include "run-command.h" +#if defined(_MSC_VER) && _MSC_VER<=1500 + +#else +#include +#endif #include "compat/terminal.h" #include "sigchain.h" #include "strbuf.h" From e2fcf0a078d40d90f58cf814911291f82408f4dd Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 25 Apr 2016 23:06:14 +0100 Subject: [PATCH 22/35] fixup! _REPARSE_DATA_BUFFER: correct line endings Signed-off-by: Philip Oakley --- compat/msvc.h | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/compat/msvc.h b/compat/msvc.h index a58b85b610d85c..b243b7d944856c 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -29,30 +29,30 @@ typedef int sigset_t; #define O_ACCMODE _O_RDWR /* open for reading and writing (not in fcntl.h) */ /* 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; - }; +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) */ From f3de73350642da68c1c53a342ed5a1e8975b3bb1 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 25 Apr 2016 23:07:20 +0100 Subject: [PATCH 23/35] remote.c: correct __attribute__ spelling http://article.gmane.org/gmane.comp.version-control.git/292559 Signed-off-by: Philip Oakley --- remote.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote.c b/remote.c index fc02698587c61d..c3d811c4b8d76e 100644 --- a/remote.c +++ b/remote.c @@ -1659,7 +1659,7 @@ int branch_merge_matches(struct branch *branch, return refname_match(branch->merge[i]->src, refname); } -__attribute((format (printf,2,3))) +__attribute__((format (printf,2,3))) static const char *error_buf(struct strbuf *err, const char *fmt, ...) { if (err) { From 86c36720be57c0ab51d6ad91d6ab638a72508a03 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 4 May 2016 15:53:48 +0100 Subject: [PATCH 24/35] contrib/buildsystems/engine.pl: detect the curl library option The msvcgit repo provides the curl library, but was not invoked by the build system's generator engine. Detect '-lcurl' options and point to the libcurl.lib. While there, fix the elsif indentation. Signed-off-by: Philip Oakley --- contrib/buildsystems/engine.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 75300ab0648145..c383c6eff681d0 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -334,10 +334,12 @@ sub handleLinkLine $appout = shift @parts; } elsif ("$part" eq "-lz") { push(@libs, "zlib.lib"); - } elsif ("$part" eq "-lcrypto") { + } elsif ("$part" eq "-lcrypto") { push(@libs, "libeay32.lib"); } elsif ("$part" eq "-lssl") { push(@libs, "ssleay32.lib"); + } elsif ("$part" eq "-lcurl") { + push(@libs, "libcurl.lib"); } elsif ($part =~ /^-/) { push(@lflags, $part); } elsif ($part =~ /\.(a|lib)$/) { From d8a01e0d3e27be7c487486e6578fb2029073056f Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 4 May 2016 16:18:07 +0100 Subject: [PATCH 25/35] compat/msvc.h: add pragmas for common warnings MNSVC can be over concerned about some warnings. Disable them. Signed-off-by: Philip Oakley --- compat/msvc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat/msvc.h b/compat/msvc.h index b243b7d944856c..861d19dc6f267e 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -6,6 +6,9 @@ #include #include +#pragma warning(disable: 4018) /* signed/unsigned comparison */ +#pragma warning(disable: 4075) /* linker ignoring option due another specification */ + /* porting function */ #define inline __inline #define __inline__ __inline From 5c9518c73143d77d441e5163a535deadef3de252 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 4 May 2016 16:29:33 +0100 Subject: [PATCH 26/35] config.mak.uname: quick fix NO_EXPAT, NO_CURL ? does this fix anything? Signed-off-by: Philip Oakley --- config.mak.uname | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.mak.uname b/config.mak.uname index 1e3b7cb61f2497..803bccb23c6dc2 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -374,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 = From 63ebfb88ee189369dddb7a864f349ae94446a834 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 4 May 2016 17:02:26 +0100 Subject: [PATCH 27/35] compat/msvc.h: add more pregmas Signed-off-by: Philip Oakley --- compat/msvc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compat/msvc.h b/compat/msvc.h index 861d19dc6f267e..f3d4734c90e6b1 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -7,7 +7,8 @@ #include #pragma warning(disable: 4018) /* signed/unsigned comparison */ -#pragma warning(disable: 4075) /* linker ignoring option due another specification */ +#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 From 4a7c8a6af73126bf753d52ff75935543f8bbeb99 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Fri, 6 May 2016 11:46:05 +0100 Subject: [PATCH 28/35] exec_cmd.c, sideband.c, Makefile: avoid multiple PREFIX definitions The short and sweet PREFIX can be confused when used in many places. Rename both usages to better describe their purpose. EXEC_CMD_PREFIX is used in full to disambiguate it from the nearby GIT_EXEC_PATH. The PREFIX in sideband.c, while nominally independant of the exec_cmd PREFIX, does reside within libgit[1], so the definitions would clash when taken together with a PREFIX given on the command line for use by exec_cmd.c. Noticed when compiling Git for Windows using MSVC/Visual Studio [1] which reports the conflict beteeen the command line definition and the definition in sideband.c within the libgit project. [1] the libgit functions are brought into a single sub-project within the Visual Studio construction script provided in contrib, and hence uses a single command for both exec_cmd.c and sideband.c. Signed-off-by: Philip Oakley --- Makefile | 2 +- exec_cmd.c | 4 ++-- sideband.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 33b0f76fd6da0d..7e701b86ff1e5d 100644 --- a/Makefile +++ b/Makefile @@ -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)"' + '-DEXEC_CMD_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 = \ diff --git a/exec_cmd.c b/exec_cmd.c index 9d5703a157fe8e..c3da2e73445290 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -12,7 +12,7 @@ char *system_path(const char *path) #ifdef RUNTIME_PREFIX static const char *prefix; #else - static const char *prefix = PREFIX; + static const char *prefix = EXEC_CMD_PREFIX; #endif struct strbuf d = STRBUF_INIT; @@ -27,7 +27,7 @@ char *system_path(const char *path) !(prefix = strip_path_suffix(argv0_path, GIT_EXEC_PATH)) && !(prefix = strip_path_suffix(argv0_path, BINDIR)) && !(prefix = strip_path_suffix(argv0_path, "git"))) { - prefix = PREFIX; + prefix = EXEC_CMD_PREFIX; trace_printf("RUNTIME_PREFIX requested, " "but prefix computation failed. " "Using static fallback '%s'.\n", prefix); diff --git a/sideband.c b/sideband.c index fde8adc000f316..d448ba79190235 100644 --- a/sideband.c +++ b/sideband.c @@ -13,7 +13,7 @@ * the remote died unexpectedly. A flush() concludes the stream. */ -#define PREFIX "remote:" +#define DISPLAY_PREFIX "remote:" #define ANSI_SUFFIX "\033[K" #define DUMB_SUFFIX " " @@ -22,13 +22,13 @@ int recv_sideband(const char *me, int in_stream, int out) { - unsigned pf = strlen(PREFIX); + unsigned pf = strlen(DISPLAY_PREFIX); unsigned sf; char buf[LARGE_PACKET_MAX + 2*FIX_SIZE]; char *suffix, *term; int skip_pf = 0; - memcpy(buf, PREFIX, pf); + memcpy(buf, DISPLAY_PREFIX, pf); term = getenv("TERM"); if (isatty(2) && term && strcmp(term, "dumb")) suffix = ANSI_SUFFIX; From 88bee554b7c70867bbb94085c6391f03b76603f6 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Fri, 6 May 2016 17:28:43 +0100 Subject: [PATCH 29/35] Initialise variables: get past a compiler workaround MSVC noted read-cache.c(1873) : warning C4700: uninitialized local variable 'saved_namelen' used builtin\rev-list.c(380) : warning C4700: uninitialized local variable 'reaches' used builtin\rev-list.c(380) : warning C4700: uninitialized local variable 'all' used merge-recursive.c(1902) : warning C4700: uninitialized local variable 'mrtree' used These definitions were a compiler workaround which should have been cleared. Three are simple integer variable, while the last is a pointer to a struct. Fix them. Signed-off-by: Philip Oakley --- builtin/rev-list.c | 2 +- merge-recursive.c | 2 +- read-cache.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 275da0d647ebe1..deae1f3159966f 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -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); diff --git a/merge-recursive.c b/merge-recursive.c index b880ae50e7ee4f..ff4852b4a6afe1 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1899,7 +1899,7 @@ int merge_recursive(struct merge_options *o, { struct commit_list *iter; struct commit *merged_common_ancestors; - struct tree *mrtree = mrtree; + struct tree *mrtree = NULL; int clean; if (show(o, 4)) { diff --git a/read-cache.c b/read-cache.c index d9fb78bc559ac9..978d6b6484b4a5 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1870,7 +1870,7 @@ static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce, { int size; struct ondisk_cache_entry *ondisk; - int saved_namelen = saved_namelen; /* compiler workaround */ + int saved_namelen = 0; char *name; int result; From 20d2f5f7a299c921b85b0256864cc8438769f3fb Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Tue, 10 May 2016 23:56:55 +0100 Subject: [PATCH 30/35] fixup! exec_cmd.c Signed-off-by: Philip Oakley --- Makefile | 2 +- exec_cmd.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7e701b86ff1e5d..23aa408a3d3a83 100644 --- a/Makefile +++ b/Makefile @@ -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)"' \ - '-DEXEC_CMD_PREFIX="$(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 = \ diff --git a/exec_cmd.c b/exec_cmd.c index c3da2e73445290..7f1d687c2de75d 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -12,7 +12,7 @@ char *system_path(const char *path) #ifdef RUNTIME_PREFIX static const char *prefix; #else - static const char *prefix = EXEC_CMD_PREFIX; + static const char *prefix = FALLBACK_RUNTIME_PREFIX; #endif struct strbuf d = STRBUF_INIT; @@ -27,7 +27,7 @@ char *system_path(const char *path) !(prefix = strip_path_suffix(argv0_path, GIT_EXEC_PATH)) && !(prefix = strip_path_suffix(argv0_path, BINDIR)) && !(prefix = strip_path_suffix(argv0_path, "git"))) { - prefix = EXEC_CMD_PREFIX; + prefix = FALLBACK_RUNTIME_PREFIX; trace_printf("RUNTIME_PREFIX requested, " "but prefix computation failed. " "Using static fallback '%s'.\n", prefix); From b75e35113e83cea68dfe7a6a13f561332fde29d8 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Wed, 11 May 2016 00:01:07 +0100 Subject: [PATCH 31/35] fast-import.c: remove old compiler workaround Signed-off-by: Philip Oakley --- --- fast-import.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fast-import.c b/fast-import.c index 9fc7093406b1e2..ca66d802fc6722 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2935,7 +2935,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20]) static void parse_get_mark(const char *p) { - struct object_entry *oe = oe; + struct object_entry *oe = NULL; char output[42]; /* get-mark SP LF */ @@ -2952,7 +2952,7 @@ static void parse_get_mark(const char *p) static void parse_cat_blob(const char *p) { - struct object_entry *oe = oe; + struct object_entry *oe = NULL; unsigned char sha1[20]; /* cat-blob SP LF */ From 91ef678d39310d204c838ad1ff4ee278966f5a8e Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Thu, 12 May 2016 14:45:41 +0100 Subject: [PATCH 32/35] msvc.h, mingw.h: continue to clear errors: ftello and curl The expat libray error that its not available is still present. Signed-off-by: Philip Oakley --- compat/mingw.h | 8 ++++++++ compat/msvc.h | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/compat/mingw.h b/compat/mingw.h index aa989e376a964a..ba81a160d28d47 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -6,6 +6,14 @@ typedef _sigset_t sigset_t; #include #include +#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 diff --git a/compat/msvc.h b/compat/msvc.h index f3d4734c90e6b1..6eabfa6ba253bd 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -32,6 +32,17 @@ static __inline int strcasecmp (const char *s1, const char *s2) 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; From 71915bef047c4283829ce07403891c9465749d0e Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Thu, 12 May 2016 14:58:06 +0100 Subject: [PATCH 33/35] git-compat-util.h: add SUPPRESS_UNINITIALIZD_WARNINGS value definition Signed-off-by: Philip Oakley --- git-compat-util.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-compat-util.h b/git-compat-util.h index 5d22c972fe7a6b..035e68f30e8828 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -145,6 +145,12 @@ #define _NETBSD_SOURCE 1 #define _SGI_SOURCE 1 +/* Not all versions of all compilers can cleanly determine + * if a variable either has been, or needs to be, initialized. + * Such variables can be initialized to this value so the + * developer does not need to reason about why the value is chosen*/ +#define SUPPRESS_UNINITIALIZD_WARNINGS 0 + #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */ # if defined (_MSC_VER) && !defined(_WIN32_WINNT) # define _WIN32_WINNT 0x0502 From 42041f7b8aedc9bd90fde43812c94b4a7f281e6b Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Thu, 16 Jun 2016 07:28:56 +0100 Subject: [PATCH 34/35] wip debug: capture the dry run as a text file delete after use! --- contrib/buildsystems/engine.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index c383c6eff681d0..043f4b8c86a745 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -77,7 +77,7 @@ sub showUsage # Capture the make dry stderr to file for review (will be empty for a release build). my $ErrsFile = "msvc-build-makedryerrors.txt"; -#@makedry = `cd $git_dir && make -n MSVC=1 V=1 1>makedry.txt 2>$ErrsFile`; # capture the dry run as a text file +@makedry = `cd $git_dir && make -n MSVC=1 V=1 1>makedry.txt 2>$ErrsFile`; # capture the dry run as a text file @makedry = `cd $git_dir && make -n MSVC=1 V=1 2>$ErrsFile` if !@makedry; # test for an empty Errors file and remove it unlink $ErrsFile if -f $ErrsFile && -z _; From cc1b0130a8162c0009a1676a43cf68b83e83aa92 Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Sat, 18 Jun 2016 22:49:18 +0100 Subject: [PATCH 35/35] msvc-build: beginnings of Post Build step We need to trap the makefile's post build step and save it for the Visual Studio .vcproj file generation. Currently we detect the copy (cp) line, then do nothing with it. Signed-off-by: Philip Oakley --- contrib/buildsystems/engine.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl index 043f4b8c86a745..760f5bf56811cc 100755 --- a/contrib/buildsystems/engine.pl +++ b/contrib/buildsystems/engine.pl @@ -166,6 +166,10 @@ sub parseMakeOutput } elsif ($text =~ /\.o / && $text =~ /\.a /) { # libifying handleLibLine($text, $line); + + } elsif ($text =~ /^cp /) { + # Post-Build + handlePostBuild($text, $line); # # } elsif ($text =~ /^cp /) { # # copy file around @@ -243,6 +247,11 @@ sub removeDuplicates @cflags = keys %dupHash; } +sub handlePostBuild +{ + my ($line, $lineno) = @_; + my @parts = split(' ', $line); +} sub handleCompileLine { my ($line, $lineno) = @_;