Skip to content

Commit f81e6b9

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 bffa7c2 commit f81e6b9

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