Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Msvc build fix (for generating git.sln) #318

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,15 @@
/gitweb/gitweb.cgi
/gitweb/static/gitweb.js
/gitweb/static/gitweb.min.*
/libgit
/test-chmtime
/test-ctype
/test-date
/test-delta
/test-dump-cache-tree
/test-scrap-cache-tree
/test-genrandom
/test-hashmap
/test-index-version
/test-line-buffer
/test-match-trees
Expand All @@ -202,6 +204,8 @@
/test-urlmatch-normalization
/test-wildmatch
/common-cmds.h
/vcs-svn_lib
/xdiff_lib
*.tar.gz
*.dsc
*.deb
Expand Down Expand Up @@ -238,5 +242,6 @@
*.user
*.idb
*.pdb
/Debug/
/Release/
*.manifest
**/Debug/
**/Release/
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,9 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak

perl/perl.mak: perl/PM.stamp

# 'make -n' (dry-run) will not execute this target which creates/updates the PM.stamp file.
# To avoid the error of failing to find the target PM.stamp, either use NO_PERL=1 (YesPlease),
# or add a leading '+' to the recipe '+$(QUIET_GEN)$(FIND) perl ...' so that it is executed.
perl/PM.stamp: FORCE
$(QUIET_GEN)$(FIND) perl -type f -name '*.pm' | sort >$@+ && \
{ cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \
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 Msysgit msvc-build script; available from that project.
1 change: 0 additions & 1 deletion contrib/buildsystems/Generators/Vcproj.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
35 changes: 28 additions & 7 deletions contrib/buildsystems/engine.pl
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use File::Spec;
use Cwd;
use Generators;
use Text::ParseWords;

my (%build_structure, %compile_options, @makedry);
my $out_dir = getcwd();
Expand Down Expand Up @@ -40,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);
Expand Down Expand Up @@ -72,7 +74,13 @@ 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 NO_PERL=1 V=1 1>makedry.txt 2>$ErrsFile`; # capture the dry run as a text file
@makedry = `cd $git_dir && make -n MSVC=1 NO_PERL=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();
Expand Down Expand Up @@ -122,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;
Expand All @@ -140,6 +149,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);
Expand Down Expand Up @@ -231,7 +246,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) {
Expand All @@ -250,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";
}
}
Expand All @@ -265,7 +281,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);
Expand All @@ -275,14 +291,15 @@ sub handleLibLine
$libout = $part;
$libout =~ s/\.a$//;
} else {
print "full line: $line\n";
die "Unhandled lib option @ line $lineno: $part";
}
}
# print "LibOut: '$libout'\nLFlags: @lflags\nOfiles: @objfiles\n";
# 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"}});
Expand All @@ -306,7 +323,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/) {
Expand All @@ -326,8 +343,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 lib option @ line $lineno: $part";
}
Expand All @@ -336,7 +357,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"}});
Expand Down