[PATCH v2 00/16] Make the msvc-build scripts work again

22 views
Skip to first unread message

Philip Oakley

unread,
Jul 19, 2015, 4:07:02 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
This updated series fixes the scripts which generated Visual Studio project
files. The scripts had bit rotted over the years as other commits
changed the git makefile which it post-processes.

The series doesn't attempt (yet) to install the Visual Studio compiled product
but allows Windows developers familiar with VS to support the Windows SDK
port of Git.

The fixes are presented in a fine grained manner.

The key change in this series is that the failure of using the git/Makefile
for a clean dry-run has been identified in perl/Makefile. The new fix replaces
two previous hack patches.

Grammatical corrections and other comments have all been included. In
particular the use of deactivated code is now better explained. The false
mode change has also been fixed (from using 'git gui', who's unstage/re-stage
action on Windows with its core.filemode=false loses the 'x' bit).

The previous patch series was not picked up on $gmane, but is available
at http://marc.info/?t=143519065200003&r=1&w=2 (2015-06-25)

Older patch series were at:
$gmane/21132 (2014-11-20),
$gmane/21207 (2014-12-26),
and on Msysgit list (2015-02-23) at
https://groups.google.com/forum/?hl=en_US?hl%3Den#!topic/msysgit/aiEVBKjRshY
and as a PR https://github.com/msysgit/git/pull/318/files


Philip Oakley (16):
perl/Makefile: treat a missing PM.stamp as if empty
.gitignore: improve MSVC ignore patterns
.gitignore: ignore library directories created by MSVC VS2008
buildsystem
(msvc-build) Vcproj.pm: remove duplicate GUID
engine.pl: fix error message (lib->link)
engine.pl: Properly accept quoted spaces in filenames
engine.pl: Fix i18n -o option in msvc buildsystem generator
engine.pl: ignore invalidcontinue.obj which is known to MSVC
engine.pl: name the msvc buildsystem's makedry error file
engine.pl: delete the captured stderr file if empty
engine.pl: add debug line to capture the dry-run
engine.pl: provide more debug print statements
Vcproj.pm: list git.exe first to be startup project
vcbuild/readme: Improve layout
msvc-build: add complete Microsoft Visual C compilation script
config.mak.uname: add MSVC No_SafeExeceptionHandler option

.gitignore | 8 ++-
compat/vcbuild/README | 27 +++++++---
compat/vcbuild/scripts/msvc-build | 86 +++++++++++++++++++++++++++++++
config.mak.uname | 9 ++++
contrib/buildsystems/Generators/Vcproj.pm | 34 ++++++------
contrib/buildsystems/engine.pl | 37 ++++++++++---
perl/Makefile | 2 +
7 files changed, 170 insertions(+), 33 deletions(-)
create mode 100755 compat/vcbuild/scripts/msvc-build

--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:03 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
Signed-off-by: Philip Oakley <philip...@iee.org>
---
.gitignore | 3 +++
1 file changed, 3 insertions(+)

diff --git a/.gitignore b/.gitignore
index 91e75ee..e35c492 100644
--- a/.gitignore
+++ b/.gitignore
@@ -178,6 +178,7 @@
/gitweb/gitweb.cgi
/gitweb/static/gitweb.js
/gitweb/static/gitweb.min.*
+/libgit
/test-chmtime
/test-ctype
/test-config
@@ -210,6 +211,8 @@
/test-urlmatch-normalization
/test-wildmatch
/common-cmds.h
+/vcs-svn_lib
+/xdiff_lib
*.tar.gz
*.dsc
*.deb
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:03 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <philip...@iee.org>
---
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 cfa74ad..1b01d58 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}",
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:03 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
'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 <philip...@iee.org>
---
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 15d96fc..5b86aac 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)
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:04 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
Signed-off-by: Philip Oakley <philip...@iee.org>
---
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 23da787..c8a5258 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -329,7 +329,7 @@ sub handleLinkLine
} elsif ($part =~ /\.(o|obj)$/) {
push(@objfiles, $part);
} 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";
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:07 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <git...@pobox.com>
Signed-off-by: Philip Oakley <philip...@iee.org>
---
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 c8a5258..24b8992 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -12,6 +12,7 @@ use File::Basename;
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/) {
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:08 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <philip...@iee.org>
---
contrib/buildsystems/engine.pl | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl
index 24b8992..60c7a7d 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);
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:09 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
Commit 4b623d8 (MSVC: link in invalidcontinue.obj for better
POSIX compatibility, 2014-03-29) is not processed correctly
by the buildsystem. Ignore it.

Also split the .o and .obj processing; 'make' does not produce .obj
files. Only substitute filenames ending with .o when generating the
source .c filename.

Signed-off-by: Philip Oakley <philip...@iee.org>
---
contrib/buildsystems/engine.pl | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl
index 60c7a7d..9db3d43 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -289,7 +289,7 @@ sub handleLibLine
# exit(1);
foreach (@objfiles) {
my $sourcefile = $_;
- $sourcefile =~ s/\.o/.c/;
+ $sourcefile =~ s/\.o$/.c/;
push(@sources, $sourcefile);
push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}});
push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}});
@@ -333,8 +333,12 @@ sub handleLinkLine
} elsif ($part =~ /\.(a|lib)$/) {
$part =~ s/\.a$/.lib/;
push(@libs, $part);
- } elsif ($part =~ /\.(o|obj)$/) {
+ } elsif ($part eq 'invalidcontinue.obj') {
+ # ignore - known to MSVC
+ } elsif ($part =~ /\.o$/) {
push(@objfiles, $part);
+ } elsif ($part =~ /\.obj$/) {
+ # do nothing, 'make' should not be producing .obj, only .o files
} else {
die "Unhandled link option @ line $lineno: $part";
}
@@ -343,7 +347,7 @@ sub handleLinkLine
# exit(1);
foreach (@objfiles) {
my $sourcefile = $_;
- $sourcefile =~ s/\.o/.c/;
+ $sourcefile =~ s/\.o$/.c/;
push(@sources, $sourcefile);
push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}});
push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}});
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:11 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <philip...@iee.org>
---
contrib/buildsystems/engine.pl | 1 +
1 file changed, 1 insertion(+)

diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl
index 020776e..4a843f3 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -76,6 +76,7 @@ EOM
# 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
for ($ErrsFile) {unlink $_ if (-f $_) && (!-s $_);}
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:11 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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.

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.

Signed-off-by: Philip Oakley <philip...@iee.org>
---
contrib/buildsystems/engine.pl | 2 ++
1 file changed, 2 insertions(+)

diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl
index a6999b6..020776e 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -77,6 +77,8 @@ EOM

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
+for ($ErrsFile) {unlink $_ if (-f $_) && (!-s $_);}

# Parse the make output into usable info
parseMakeOutput();
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:11 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <philip...@iee.org>
---
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 9db3d43..a6999b6 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -73,7 +73,10 @@ Running GNU Make to figure out build structure...
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;

Philip Oakley

unread,
Jul 19, 2015, 4:07:12 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <philip...@iee.org>
---
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 1b01d58..cc2fa21 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";
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:13 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <philip...@iee.org>
---
compat/vcbuild/README | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/compat/vcbuild/README b/compat/vcbuild/README
index df8a657..ad8633e 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
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:13 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <philip...@iee.org>
---
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 4a843f3..3238d16 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -41,6 +41,7 @@ EOM
# 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";
}
}
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:13 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
Layout the 'either/or' with more white space to clarify
which alternatives are matched up.

Reference the Msysgit build script which automates one sequence of options.

Signed-off-by: Philip Oakley <philip...@iee.org>
---
compat/vcbuild/README | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/compat/vcbuild/README b/compat/vcbuild/README
index df8a657..7548dc4 100644
@@ -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 Msysgit msvc-build script; available from that project.
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:14 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <philip...@iee.org>
---

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 ad8633e..faaea69 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 0000000..d67203b
--- /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
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:07:16 PM7/19/15
to Git List, Junio C Hamano, MsysGit List, Yue Lin Ho, Philip Oakley
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 <b873...@student.nsysu.edu.tw>
Signed-off-by: Philip Oakley <philip...@iee.org>
---
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 943c439..1c27828 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')
@@ -385,6 +389,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
--
2.4.2.windows.1.5.gd32afb6

Philip Oakley

unread,
Jul 19, 2015, 4:21:50 PM7/19/15
to Philip Oakley, Git List, Junio C Hamano, MsysGit List, Yue Lin Ho
From: "Philip Oakley" <philip...@iee.org>
Sent: Sunday, July 19, 2015 9:08 PM

This "14/16" is the wrong version accidently left over from a previous
draft.
Please use the other version with the shorter subject line.

Sorry for the noise / mistake.

> Layout the 'either/or' with more white space to clarify
> which alternatives are matched up.
>
> Reference the Msysgit build script which automates one sequence of
> options.

This part has been dropped.
>
> Signed-off-by: Philip Oakley <philip...@iee.org>
> ---
[...]
> Done!
> +
> +Or, use the Msysgit msvc-build script; available from that project.
... has gone.

> --
> 2.4.2.windows.1.5.gd32afb6
>
>

Reply all
Reply to author
Forward
0 new messages