Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Git for Windows start builds in modern Visual Studio #3306

Merged
merged 4 commits into from Oct 12, 2021

Conversation

PhilipOakley
Copy link

@PhilipOakley PhilipOakley commented Jul 2, 2021

The goal of opening and building Git for Windows (GfW) in Visual Studio, without any special configuration, has been a moving target.

Historically Git provided it's own hand rolled generator for VS project .sln (etc.) files in contrib/buildsystems/Generators/* and compat/vcbuild/*.

Git and GfW has now added a CMakeLists.txt script for the use of Cmake as the buildsystem.

Visual Studio has also updated it's default generator (now Ninja).

Builds on ARM are now also possible of GfW, through the addition of a VCPKG_ARCH parameter.

Unfortunately, this left behind the default build as expecting parameters that aren't provided.

This series tries to tidy up the default scenario and the description in the CMakeLists.txt header comment.

Testing of the update requires that the install be 'clean' for both Visual Studio and the worktree.
[updated 28Aug2021]

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the description, I expected that a ton of variables were missing defaults, but the vast majority of the patch is not about that. The only missing default, according to the diff, seems to have been VCPKG_ARCH.

I do like the direction this is going, though.

Visual Studio does not produce a .sln solution file nor the .vcproj files
that may be required by VS extension tools.

To generate the .sln/.vcproj files run Cmake manually, as below.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To generate the .sln/.vcproj files run Cmake manually, as below.
To generate the .sln/.vcproj files run CMake manually, as described below.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To generate the .sln/.vcproj files run CMake manually, as described below.

OK.

It's not clear to me if this will be necessary as VS Ninja will run CMakeLists.txt anyway (lots of round incircles interactions, still need to setup the doubly clean testing)

Run `make` to build Git on Linux/*BSD/MacOS.
Open git.sln on Windows and build Git.

NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
to use another tool say `ninja` add this to the command line when configuring.
`-G Ninja`

The Visual Studio default generator changed in v16.6 from its visual studio
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Visual Studio default generator changed in v16.6 from its visual studio
The Visual Studio default generator changed in v16.6 from its Visual Studio

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Visual Studio default generator changed in v16.6 from its Visual Studio

OK

]]
cmake_minimum_required(VERSION 3.14)

#set the source directory to root of git
set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
if(WIN32)
set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
message("WIN32: ${WIN32}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why print out WIN32 when it is a Boolean and we're inside the conditional block where we know that it is true?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why print out WIN32 when it is a Boolean and we're inside the conditional block where we know that it is true?

Thanks for the prompt comments.

While we may assume it's evaluated to true, it's not obvious what it's actual text value is (or has become in future cases).

I found that much of the CMake documentation left a lot to be desired about those sorts of things (confusions between existence, particular text values etc. Previously it was part of a logic term (AND MSVC iirc).

if(NOT EXISTS ${VCPKG_ARCH})
message("VCPKG_ARCH: unset, using 'x64-windows'")
set(VCPKG_ARCH "x64-windows") # default from vcpkg_install.bat
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to print out VCPKG_ARCH in case it was already specified?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to print out VCPKG_ARCH in case it was already specified?

Good idea. Will add.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a good idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this concern has been addressed as part of a reply to a different comment.

contrib/buildsystems/CMakeLists.txt Show resolved Hide resolved
if(MSVC AND NOT EXISTS ${VCPKG_DIR})
message("Initializing vcpkg and building the Git's dependencies (this will take a while...)")
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat ${VCPKG_ARCH})
endif()
if(NOT EXISTS ${VCPKG_ARCH})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit weird to do this after we print out all the other build configuration information and run the vcpkg_install script using this option anyways, is there a reason it is printed out here rather than with the others?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit weird to do this after we print out all the other build configuration information and run the vcpkg_install script using this option anyways, is there a reason

The other printouts are as a reflection of the implicit Build Options. Dscho has asked that I include the VCPKG_ARCH in the list of those options.

The reason I put the message here is because the default arch is set within vcpkg_install script and I was keeping that dependency logic, so if a user ran vcpkg_install first, manually, without parameters, then we'd have the same end result.

Dscho made a similar comment wrt detecting the Visual Studio default, and the same logic should apply that we should only have one source of truth.

Hmm. Just rechecking. The on-line gui suggests you only highlighted one line, but maybe not. I'll need to check that the rebase onto upstream hasn't created some out of sequence interaction - I see an AND MSVC above which I wasn't expecting.

will re-check

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Looks like I goofed up the rebase / conflict.

I'd also thought that the MSVC dependency had gone, because Visual Studio is now using Ninja, but maybe my memory is getting confused.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so I had a patch make it into seen that does do some work in regards to that dependency here. Where we generate the compile_commands.json file by default. So many tools can operate off of CMake builds with little work.

More relevant here we add the USE_VCPKG option, here so maybe it's better to base this off of that work as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so I had a patch make it into seen that does do some work in regards to that dependency here. Where we generate the compile_commands.json file by default. So many tools can operate off of CMake builds with little work.

More relevant here we add the USE_VCPKG option, here so maybe it's better to base this off of that work as well?

Definitely. I had it in my mind that that work was already in GfW, and so would have been picked up when I rebased my series onto GfW (my upstream)...

I did a quick tweak of script to assume MSVC was true (by deleting it!), and VS has loaded vcpkg - Yay.

I'm preping to be away for a four-day weekend. Hopefully have something done on Wedn next.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lost track. Does this still need to be resolved, or has it been addressed already?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this concern has been addressed as part of a reply to a different comment.

@PhilipOakley
Copy link
Author

here's the screenshot of my Visual Studio deciding that the CMakeLists script and it disagree.. (I had included the agreed minor corrections)

image

  1. Offering to configure CMake (i.e. it may never work out of the box, rather always require user to chose stuff they don't yet understand)
  2. CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
  3. CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/CMakeDetermineSystem.cmake:129 (message):
    Could not find toolchain file:
    C:/git-sdk-64/usr/src/git/contrib/buildsystems/../../compat/vcbuild/vcpkg/scripts/buildsystems/vcpkg.cmake C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/CMakeDetermineSystem.cmake 129
  4. implies that MSVC is false, hence vcpkg never installed...
  5. I'd not noticed the CMAKE_C_COMPILER not set previously

Annoying. and Confused.

@PhilipOakley
Copy link
Author

Ok so the Output window also gives

1> CMake generation started for default configuration: 'windows-default'.
1> Environment settings:
1>     CommandPromptType=Native
1>     DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\
1>     ExtensionSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs
1>     Framework40Version=v4.0
1>     FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework64\
1>     FrameworkDIR64=C:\WINDOWS\Microsoft.NET\Framework64
1>     FrameworkVersion=v4.0.30319
1>     FrameworkVersion64=v4.0.30319
1>     INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt
1>     LIB=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64
1>     LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.19041.0;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319
1>     NETFXSDKDir=C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\
1>     Path=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\\Extensions\Microsoft\IntelliCode\CLI;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\\MSBuild\Current\Bin;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\MiKTeX\miktex\bin\x64\;C:\Program Files\Git\cmd;C:\Users\phili\AppData\Local\Microsoft\WindowsApps;C:\Users\phili\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\phili\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;C:\Users\phili\AppData\Roaming\npm;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
1>     PROMPT=$P$G
1>     UCRTVersion=10.0.19041.0
1>     UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10\
1>     VCIDEInstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\
1>     VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\
1>     VCToolsInstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\
1>     VCToolsRedistDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.29.30036\
1>     VCToolsVersion=14.29.30037
1>     VS160COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\
1>     VSCMD_ARG_app_plat=Desktop
1>     VSCMD_ARG_HOST_ARCH=x64
1>     VSCMD_ARG_no_logo=1
1>     VSCMD_ARG_TGT_ARCH=x64
1>     VSCMD_DEBUG=5 
1>     VSCMD_VER=16.10.2
1>     VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\
1>     WindowsLibPath=C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.19041.0
1>     WindowsSdkBinPath=C:\Program Files (x86)\Windows Kits\10\bin\
1>     WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\
1>     WindowsSDKLibVersion=10.0.19041.0\
1>     WindowsSdkVerBinPath=C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\
1>     WindowsSDKVersion=10.0.19041.0\
1>     WindowsSDK_ExecutablePath_x64=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\
1>     WindowsSDK_ExecutablePath_x86=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\
1>     __devinit_path=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\devinit\devinit.exe
1>     __DOTNET_ADD_64BIT=1
1>     __DOTNET_PREFERRED_BITNESS=64
1>     __VSCMD_PREINIT_PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\MiKTeX\miktex\bin\x64\;C:\Program Files\Git\cmd;C:\Users\phili\AppData\Local\Microsoft\WindowsApps;C:\Users\phili\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\phili\AppData\Local\Programs\MiKTeX 2.9\miktex\bin\x64\;C:\Users\phili\AppData\Roaming\npm
1>     __VSCMD_script_err_count=0
1>     PROCESSOR_ARCHITEW6432=AMD64
1>     DriverData=C:\Windows\System32\Drivers\DriverData
1>     COMPUTERNAME=PHILIP-WIN10
1>     CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
1>     OneDrive=C:\Users\phili\OneDrive
1>     HOMEPATH=\Users\phili
1>     VisualStudioEdition=Microsoft Visual Studio Community 2019
1>     ServiceHubLogSessionKey=97E647DB
1>     MOZ_PLUGIN_PATH=C:\Program Files (x86)\Foxit Software\Foxit Reader\plugins\
1>     PROCESSOR_REVISION=9e0a
1>     ThreadedWaitDialogDpiContext=-4
1>     PkgDefApplicationConfigFile=C:\Users\phili\AppData\Local\Microsoft\VisualStudio\16.0_36d5070d\devenv.exe.config
1>     PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
1>     TMP=C:\Users\phili\AppData\Local\Temp
1>     TEMP=C:\Users\phili\AppData\Local\Temp
1>     LOCALAPPDATA=C:\Users\phili\AppData\Local
1>     PUBLIC=C:\Users\Public
1>     VSAPPIDNAME=devenv.exe
1>     SignInWithHomeTenantOnly=False
1>     USERDOMAIN=PHILIP-WIN10
1>     ProgramFiles(x86)=C:\Program Files (x86)
1>     PROCESSOR_LEVEL=6
1>     PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
1>     ForceIdentityAuthenticationType=Embedded
1>     PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
1>     NUMBER_OF_PROCESSORS=6
1>     FPS_BROWSER_USER_PROFILE_STRING=Default
1>     CommonProgramFiles=C:\Program Files (x86)\Common Files
1>     VisualStudioDir=D:\Philip\Visual Studio 2019
1>     ProgramData=C:\ProgramData
1>     ProgramW6432=C:\Program Files
1>     ProgramFiles=C:\Program Files (x86)
1>     VSSKUEDITION=Community
1>     SystemRoot=C:\WINDOWS
1>     VSAPPIDDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\
1>     SESSIONNAME=Console
1>     VisualStudioVersion=16.0
1>     CommonProgramW6432=C:\Program Files\Common Files
1>     LOGONSERVER=\\PHILIP-WIN10
1>     USERPROFILE=C:\Users\phili
1>     MSBuildLoadMicrosoftTargetsReadOnly=true
1>     VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
1>     VSLANG=1033
1>     USERDOMAIN_ROAMINGPROFILE=PHILIP-WIN10
1>     APPDATA=C:\Users\phili\AppData\Roaming
1>     HOMEDRIVE=C:
1>     VBOX_MSI_INSTALL_PATH=C:\Program Files\VirtualBox\
1>     USERNAME=phili
1>     FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
1>     PROCESSOR_ARCHITECTURE=x86
1>     OS=Windows_NT
1>     ComSpec=C:\WINDOWS\system32\cmd.exe
1>     SystemDrive=C:
1>     windir=C:\WINDOWS
1>     OneDriveConsumer=C:\Users\phili\OneDrive
1>     ALLUSERSPROFILE=C:\ProgramData
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:STRING="C:/git-sdk-64/usr/src/git/contrib/buildsystems/out/install/windows-default"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\git-sdk-64\usr\src\git\contrib\buildsystems" 2>&1"
1> Working directory: C:/git-sdk-64/usr/src/git/contrib/buildsystems/out/build/windows-default
1> [CMake] WIN32: 1
1> [CMake] VCPKG_DIR: C:/git-sdk-64/usr/src/git/contrib/buildsystems/../../compat/vcbuild/vcpkg
1> [CMake] VCPKG_ARCH: 
1> [CMake] MSVC: 
1> [CMake] CMAKE_GENERATOR: Ninja
1> [CMake] CMAKE_CXX_COMPILER_ID: 
1> [CMake] CMAKE_GENERATOR_PLATFORM: 
1> [CMake] VCPKG_ARCH: unset, using 'x64-windows'
1> [CMake] CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/CMakeDetermineSystem.cmake:129 (message):
1> [CMake]   Could not find toolchain file:
1> [CMake]   C:/git-sdk-64/usr/src/git/contrib/buildsystems/../../compat/vcbuild/vcpkg/scripts/buildsystems/vcpkg.cmake
1> [CMake] Call Stack (most recent call first):
1> [CMake]   CMakeLists.txt:110 (project)
1> [CMake] CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
1> [CMake] -- Configuring incomplete, errors occurred!
1> 'C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:STRING="C:/git-sdk-64/usr/src/git/contrib/buildsystems/out/install/windows-default"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\git-sdk-64\usr\src\git\contrib\buildsystems" 2>&1"' execution failed with error: ''C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:STRING="C:/git-sdk-64/usr/src/git/contrib/buildsystems/out/install/windows-default"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\git-sdk-64\usr\src\git\contrib\buildsystems" 2>&1"' returned with exit code: 1'.

@PhilipOakley
Copy link
Author

@dscho @ROGERSM94 @dennisameling

I'm progressing the fixup for the out of the box building of Git for Windows in Visual Studio, but I've hit a CI failure that looks to be a set of intertwined dependencies that I haven't got to the bottom of and I looking for a bit of help. The Visual Studio build does complete, though shows the information message mentioned later.

In part it looks as if some vcpkg dependencies have gone missing (around the effects of NO_GETTEXT).

I've picked up Matt's CMake improvements that are in git/next, and added my fixes for the vcpkg_arch, all on top of git-for-windows/main, which is posted at my repo https://github.com/PhilipOakley/git/tree/vs-sln (the commit messages still need tidying as per other comments)

However it has CI build failures around picking up the po/ messages, see https://github.com/git-for-windows/git/runs/3049476520?check_suite_focus=true . where the make -n artifacts-tar fails with tar: po/build/locale/bg/LC_MESSAGES/git.mo: Cannot stat: No such file or directory (etc.)

In my local testing I'm seeing that ce24797d38 (cmake: add warning for ignored MSGFMT_EXE, 2021-06-06) on my system induces a

1> [CMake] CMake Warning at C:\git-sdk-64\usr\src\git\contrib\buildsystems\CMakeLists.txt:216 (message):
1> [CMake]   Text Translations won't be built

i.e. https://github.com/git/git/blame/master/contrib/buildsystems/CMakeLists.txt#L181-L185 isn't finding /compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe

I'm not sure why msys2 tools are not there in my system (and potentially for the CI build fail). I know I had cleaned my local workdir not long ago, so it could be that the 'out of the box' build doesn't pick up those specific msys2 tools (I only have 7zip, nuget and powershell-core in that /compat/vcbuild/vcpkg/downloads/tools dir).

How would the msys2 tools normally be added to that vcpkg subdir normally (locally and the CI)?

Should the CI system see that same, or different, issues? Maybe the Git, and Git-for-Windows views of the CI are different.

Thoughts?

#3306 (this)
#3176 (other discussion)

@rimrul
Copy link
Member

rimrul commented Jul 13, 2021

In part it looks as if some vcpkg dependencies have gone missing (around the effects of NO_GETTEXT).

[…]

However it has CI build failures around picking up the po/ messages, see https://github.com/git-for-windows/git/runs/3049476520?check_suite_focus=true . where the make -n artifacts-tar fails with tar: po/build/locale/bg/LC_MESSAGES/git.mo: Cannot stat: No such file or directory (etc.)

That sounds a lot like the issue Junio had with v1 of gitgitgadget#878

Does your make artifacts-tar know about NO_GETTEXT?

@PhilipOakley
Copy link
Author

Does your make artifacts-tar know about NO_GETTEXT?

IIUC the artifacts-tar unconditionally includes the $(MOFILES) list in the Makefile, but I haven't been able to dig any deeper yet as to how that is created. (Makefiles is not a strong point..)

I'll look at the linked Junio comment as well.

@PhilipOakley
Copy link
Author

I looked at gitgitgadget#878 and it does look to be the same CI-breakage issue.

Still not sure of the history of the sometimes included /compat/vcbuild/vcpkg/downloads/tools/msys2/msys64/usr/bin/msgfmt.exe is.

@dscho
Copy link
Member

dscho commented Jul 14, 2021

@PhilipOakley if you don't want to base your commits on Git for Windows main, you may want to rebase onto https://github.com/gitster/git/commits/js/ci-windows-update

@PhilipOakley
Copy link
Author

@dscho hi,

if you don't want to base your commits on Git for Windows main,

my series is on the GfW origin/main, which is still at the tag: v2.32.0.windows.2 (which doesn't yet have Matt's fixes)

you may want to rebase onto https://github.com/gitster/git/commits/js/ci-windows-update

Hmm, that suggestion made me do a double-think to realise that I'd been working on the expectation that I'd need the VS compiled codebase to be based on the Git-for-Windows version, to be a 'real', installable version.

If it's just to get a clean compile, both locally (via the CMakeLists.txt) and in the CI (when pushed to my GitHub fork), that would effectively drop the 'installable' aspect, but it's still 'real code' for code investigation/tracing/visualisation.

I can try your suggestion and see how it goes for the local test aspects. Your series should implicitly include Matt's fixes as that's on next already.

@PhilipOakley
Copy link
Author

@gifhuppp Thanks for the support.

It's not quite ready yet as there are a few different patch sets that need to come together to ensure that both the Git (upstream) and Git-for-Windows CI (continuous integration) tests pass and that it works well on my (and hopefully everyone else's) machines 😉

Longer term I've still got a desire to look at the '4Gb' file size limit on GfW, but that is a big change (hundreds of Int -> Size_t; a bit ugly!)

@dscho
Copy link
Member

dscho commented Jul 15, 2021

I've still got a desire to look at the '4Gb' file size limit on GfW, but that is a big change (hundreds of Int -> Size_t; a bit ugly!)

I showed you how to break it into smaller chunks. I'm still convinced that would be a better way to go.

@PhilipOakley
Copy link
Author

I showed you how to break it into smaller chunks. I'm still convinced that would be a better way to go.

Hmm. You suggested it should be broken into many smaller chunks, but I didn't see how. That's the gap.

The test of rebasing my fixups (for this issue ) on your js/ci-windows-update branch has worked locally, but I've jet to push it up to GitHub (as a fresh branch) to see if the CI works OK (should do but, need to check ..) I've got household tasks at the moment.

@PhilipOakley
Copy link
Author

I pushed my local changes to https://github.com/PhilipOakley/git/tree/vs-sln-git with (passing) results at https://github.com/PhilipOakley/git/actions/runs/1034204853.

I had had it in my head that the compile_commands.json file would also be generated by Matt's fixes but it looks like I misunderstood (at least for my local build).

@PhilipOakley
Copy link
Author

Just rechecked the build for the CMAKE_EXPORT_COMPILE_COMMANDS value and while it is listed in the advanced screen of the CMake window (in Visual Studio), the checkbox was unticked (implying false or similar). So the setting of that variable to TRUE hadn't stuck. (Check done on my vs-sln-git branch)

Not sure if there is a cache issue. @ROGERSM94, any ideas?
(PhilipOakley@d8e3828 is one version)

@ROGERSM94
Copy link

CMAKE_EXPORT_COMPILE_COMMANDS is implemented only by makefille and Ninja generators, so that would probably expxlain why it isn't working there.

@PhilipOakley
Copy link
Author

Thanks Matt, The ninja stuff in VS gets confusing. The initial CMake suggests it has CMAKE_GENERATOR: Ninja.

I did see in other web searches that suggest MSVC doesn't provide that https://stackoverflow.com/a/67384920/717355

While others suggest that there is a cache issue making it look like it needs two passes https://gitlab.kitware.com/cmake/cmake/-/issues/16588 (linked from another SO answer https://stackoverflow.com/a/66560758/717355 to same question).

I'll maybe try and see what happens if I add the extra Cache setting...

... goes and looks

Hmm, my CMakeLists.txt file doesn't even appear to have that setting. Maybe I've got the wrong mental model of dscho's upstream branch (in seen..) and whether it includes yours that's in next.

Loks like I've some extra digging to do.

@PhilipOakley
Copy link
Author

ci-

Hmm, my CMakeLists.txt file doesn't even appear to have that setting. Maybe I've got the wrong mental model of dscho's upstream branch (in seen..) and whether it includes yours that's in next.

Looks like I've some extra digging to do.

Sigh. Yes, mental model was wrong. I had it in my head that, ultimately, dscho's https://github.com/gitster/git/commits/js/ci-windows-update would be on top of Matt's 409047a2b3 cmake: create compile_commands.json by default.

Hey-ho.

@PhilipOakley
Copy link
Author

Yes, mental model was wrong.

OK, so been round the houses a couple of times. I had perceived that everything in seen would contain anything in next & master, but I'd picked a tip of a series in seen, but not the merge of that tip...

I think I have a better view of the mental model (sic), and I've shifted to the regularly rebuilt GfW/shears/master (my origin remote).

The shears/master has (as best I understand it) all those topics that have graduated to Junio's /master branch, and all the Git for Windows patches rebased on top, including any accepted new patches. So I've rebased the series onto there (with new name..) https://github.com/PhilipOakley/git/tree/vs-sln-gfw.

This means that all the different 'dependent' series needed to ensure that Visual Studio will build this mega series (no, it's a micro series, but needed a lot of prereqs ;-) straight out of the box, and will pass the CI (i.e. no sparse warnings or any of the other niff-naff and trivia from elsewhere ;-)

I have included all the changes requested, except that the CMakeLists.txt default architecture is still driven by the vcpkg_install.bat fall back value, which happens to match the current Visual Studio default - dog wags tails.

Testing is still manual. I haven't looked into which CI system would provide the Windows & Visual Studio environments that can be driven by a scheduled event (e.g. weekly), nor how to code it...

Question for @dscho , given that the 'series is on top of shears/master, what is the right/best way to generate a suitable pull request, noting that this series sort of depends on the local(GfW) ARM arch developments, can interact (context line conflicts) with upstream and needs a few upstream CI-test fixups?

@gifhuppp

This comment was marked as spam.

@dscho
Copy link
Member

dscho commented Jul 31, 2021

shears/master is autogenerated automatically every time Git for Windows' and/or Git's main branch advance. Not a good target branch.

The best you could do is by starting with a merge of the respective gitster/git branch you rely on (as identified by the merge commit in upstream's master branch). If more than one branch is required, merge each of them individually. Then apply your commit(s) on top.

@PhilipOakley
Copy link
Author

shears/master is autogenerated automatically every time Git for Windows' and/or Git's main branch advance. Not a good target branch.

It does properly combine the two sets of problematic commits, it is the most easy to access.

The best you could do is by starting with a merge of the respective gitster/git branch you rely on (as identified by the merge commit in upstream's master branch). If more than one branch is required, merge each of them individually. Then apply your commit(s) on top.

This is essentially the same as shears/master.

However, in the meanwhile, the v2.33.0-rc0 version has been released, and the Git-for-Windows origin/main has also advanced, so I have rebased this vs-sln series onto that, and forced pushed an update with the new origin/main base commit, which should hopefully resolve the concerns about using shears/master.

@dscho
Copy link
Member

dscho commented Aug 5, 2021

shears/master is autogenerated automatically every time Git for Windows' and/or Git's main branch advance. Not a good target branch.

It does properly combine the two sets of problematic commits, it is the most easy to access.

It is a moving target. Every time either Git for Windows' or Git's main branch advances, shears/master is rebased. It won't fast-forward. Git's merge base algorithm will get confused. You will get merge conflicts that you have no idea where they come from.

The best you could do is by starting with a merge of the respective gitster/git branch you rely on (as identified by the merge commit in upstream's master branch). If more than one branch is required, merge each of them individually. Then apply your commit(s) on top.

This is essentially the same as shears/master.

With the notable difference that it isn't force-pushed all the time, and the other notable difference that it only contains what you actually need.

The shears/* branches are really unsuitable to base your work on. Unless you love frequent rebases.

@PhilipOakley
Copy link
Author

You will get merge conflicts that you have no idea where they come from

That hasn't occurred, at all. In fact it's the opposite. It (shears/master) provides that 'good' basis of the latest GfW commits (which I needed) on top of the recent git fixes (inc. CI-fixes). For me, it is the build you suggested. All the rebases have been quick (instant) and clean, not like when I was trying to do a rather nasty pick and mix of guessed-at commits that might represent those apriori fixes I'd need - simply taking them all is much simpler.

Anyway. It (my little 4 patch series) is now on top of main (which was just 1 commit adrift from shears/master, so no conflicts there either ;-), so are there any further fixes required.

I've separately to liaise with @ROGERSM94 about his CMAKE_EXPORT_COMPILE_COMMANDS check as it appears that Visual Studio's Ninja already has that defined, but unset (based on looking at the CMake advanced options tab), but that's not a formal part of this series (to set the default architecture).

git-for-windows-ci pushed a commit that referenced this pull request Apr 19, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 22, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 22, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 23, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 23, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 24, 2024
Make Git for Windows start builds in modern Visual Studio
dscho added a commit to microsoft/git that referenced this pull request Apr 24, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 24, 2024
Make Git for Windows start builds in modern Visual Studio
dscho added a commit that referenced this pull request Apr 25, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 25, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 25, 2024
Make Git for Windows start builds in modern Visual Studio
dscho added a commit that referenced this pull request Apr 25, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 25, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 26, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 26, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 26, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 26, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 26, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 27, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 27, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 29, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 29, 2024
Make Git for Windows start builds in modern Visual Studio
dscho added a commit to microsoft/git that referenced this pull request Apr 29, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 29, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request Apr 29, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request May 1, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request May 1, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request May 1, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request May 4, 2024
Make Git for Windows start builds in modern Visual Studio
git-for-windows-ci pushed a commit that referenced this pull request May 4, 2024
Make Git for Windows start builds in modern Visual Studio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants