Skip to content

Commit 688d166

Browse files
committed
msvc: add a Makefile target to pre-generate the VS solution
The entire idea of generating the VS solution makes only sense if we generate it via Continuous Integration; otherwise potential users would still have to download the entire Git for Windows SDK. So let's just add a target in the Makefile that can be used to generate said solution; The generated files will then be committed so that they can be pushed to a branch ready to check out by Visual Studio users. To make things even more useful, we also generate and commit other files that are required to run the test suite, such as templates and bin-wrappers: with this, developers can run the test suite in a regular Git Bash (that is part of a regular Git for Windows installation) after building the solution in Visual Studio. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 06e8cc2 commit 688d166

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

config.mak.uname

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ include compat/vcbuild/MSVC-DEFS-GEN
2525
# See if vcpkg and the vcpkg-build versions of the third-party
2626
# libraries that we use are installed. We include the result
2727
# to get $(vcpkg_*) variables defined for the Makefile.
28+
ifeq (,$(SKIP_VCPKG))
2829
compat/vcbuild/VCPKG-DEFS: compat/vcbuild/vcpkg_install.bat
2930
@"$<"
3031
include compat/vcbuild/VCPKG-DEFS
3132
endif
33+
endif
3234

3335
# We choose to avoid "if .. else if .. else .. endif endif"
3436
# because maintaining the nesting to match is a pain. If
@@ -686,3 +688,62 @@ ifeq ($(uname_S),QNX)
686688
NO_STRCASESTR = YesPlease
687689
NO_STRLCPY = YesPlease
688690
endif
691+
692+
vcxproj:
693+
# Require clean work tree
694+
git update-index -q --refresh && \
695+
git diff-files --quiet && \
696+
git diff-index --cached --quiet HEAD --
697+
698+
# Make .vcxproj files and add them
699+
unset QUIET_GEN QUIET_BUILT_IN; \
700+
perl contrib/buildsystems/generate -g Vcxproj
701+
git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj
702+
703+
# Add command-list.h
704+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h
705+
git add -f command-list.h
706+
707+
# Add scripts
708+
rm -f perl/perl.mak
709+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 \
710+
$(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
711+
# Strip out the sane tool path, needed only for building
712+
sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
713+
git add -f $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
714+
715+
# Add Perl module
716+
$(MAKE) $(LIB_PERL_GEN)
717+
git add -f perl/build
718+
719+
# Add bin-wrappers, for testing
720+
rm -rf bin-wrappers/
721+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(test_bindir_programs)
722+
# Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute
723+
# path of the repository is not hard-coded (GIT_EXEC_PATH will be set
724+
# by test-lib.sh according to the current setup)
725+
sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\
726+
\1="$$(cygpath -u "$$\1")"/' \
727+
-e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/*
728+
# Ensure that test-* helpers find the .dll files copied to top-level
729+
sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-*
730+
# We do not want to force hard-linking builtins
731+
sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \
732+
bin-wrappers/git-{receive-pack,upload-archive}
733+
git add -f $(test_bindir_programs)
734+
# remote-ext is a builtin, but invoked as if it were external
735+
sed 's|receive-pack|remote-ext|g' \
736+
<bin-wrappers/git-receive-pack >bin-wrappers/git-remote-ext
737+
git add -f bin-wrappers/git-remote-ext
738+
739+
# Add templates
740+
$(MAKE) -C templates
741+
git add -f templates/boilerplates.made templates/blt/
742+
743+
# Add build options
744+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS
745+
git add -f GIT-BUILD-OPTIONS
746+
747+
# Commit the whole shebang
748+
git commit -m "Generate Visual Studio solution" \
749+
-m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"

contrib/buildsystems/engine.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ sub showUsage
8282
# Capture the make dry stderr to file for review (will be empty for a release build).
8383

8484
my $ErrsFile = "msvc-build-makedryerrors.txt";
85-
@makedry = `make -C $git_dir -n MSVC=1 V=1 2>$ErrsFile` if !@makedry;
85+
@makedry = `make -C $git_dir -n MSVC=1 SKIP_VCPKG=1 V=1 2>$ErrsFile`
86+
if !@makedry;
8687
# test for an empty Errors file and remove it
8788
unlink $ErrsFile if -f -z $ErrsFile;
8889

0 commit comments

Comments
 (0)