Skip to content

Commit aedf21d

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 f4a0c9b commit aedf21d

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

config.mak.uname

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,80 @@ endif
448448
X = .exe
449449

450450
compat/msvc.o: compat/msvc.c compat/mingw.c GIT-CFLAGS
451+
452+
vcxproj:
453+
# Require clean work tree
454+
git update-index -q --refresh && \
455+
git diff-files --quiet && \
456+
git diff-index --cached --quiet HEAD --
457+
458+
# Make .vcxproj files and add them
459+
unset QUIET_GEN QUIET_BUILT_IN; \
460+
perl contrib/buildsystems/generate -g Vcxproj
461+
git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj
462+
463+
# Generate the LinkOrCopyBuiltins.targets file
464+
(echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \
465+
echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \
466+
for name in $(BUILT_INS);\
467+
do \
468+
echo ' <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
469+
done && \
470+
for name in $(REMOTE_CURL_ALIASES); \
471+
do \
472+
echo ' <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \
473+
done && \
474+
echo ' </Target>' && \
475+
echo '</Project>') >git/LinkOrCopyBuiltins.targets
476+
git add -f git/LinkOrCopyBuiltins.targets
477+
478+
# Add command-list.h
479+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h
480+
git add -f command-list.h
481+
482+
# Add scripts
483+
rm -f perl/perl.mak
484+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 \
485+
$(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
486+
# Strip out the sane tool path, needed only for building
487+
sed -i '/^git_broken_path_fix ".*/d' git-sh-setup
488+
git add -f $(SCRIPT_LIB) $(SCRIPT_SH_GEN) $(SCRIPT_PERL_GEN)
489+
490+
# Add Perl module
491+
$(MAKE) $(LIB_PERL_GEN)
492+
git add -f perl/build
493+
494+
# Add bin-wrappers, for testing
495+
rm -rf bin-wrappers/
496+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(test_bindir_programs)
497+
# Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute
498+
# path of the repository is not hard-coded (GIT_EXEC_PATH will be set
499+
# by test-lib.sh according to the current setup)
500+
sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\
501+
\1="$$(cygpath -u "$$\1")"/' \
502+
-e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/*
503+
# Ensure that test-* helpers find the .dll files copied to top-level
504+
sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-*
505+
# We do not want to force hard-linking builtins
506+
sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \
507+
bin-wrappers/git-{receive-pack,upload-archive}
508+
git add -f $(test_bindir_programs)
509+
# remote-ext is a builtin, but invoked as if it were external
510+
sed 's|receive-pack|remote-ext|g' \
511+
<bin-wrappers/git-receive-pack >bin-wrappers/git-remote-ext
512+
git add -f bin-wrappers/git-remote-ext
513+
514+
# Add templates
515+
$(MAKE) -C templates
516+
git add -f templates/boilerplates.made templates/blt/
517+
518+
# Add build options
519+
$(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS
520+
git add -f GIT-BUILD-OPTIONS
521+
522+
# Commit the whole shebang
523+
git commit -m "Generate Visual Studio solution" \
524+
-m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`"
451525
endif
452526
ifeq ($(uname_S),Interix)
453527
NO_INITGROUPS = YesPlease

0 commit comments

Comments
 (0)