Skip to content

Commit 1161a0e

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 c6092d5 commit 1161a0e

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