Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2915 from dennisameling/windows-arm64-support
Windows arm64 support
  • Loading branch information
dscho committed Dec 9, 2020
2 parents d054eb1 + d4e8297 commit fe4092f
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 18 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/main.yml
Expand Up @@ -164,6 +164,9 @@ jobs:
NO_PERL: 1
GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
runs-on: windows-latest
strategy:
matrix:
arch: [x64, arm64]
steps:
- uses: actions/checkout@v1
- name: download git-sdk-64-minimal
Expand All @@ -182,6 +185,7 @@ jobs:
unzip artifacts.zip
rm artifacts.zip
- name: download vcpkg artifacts
if: matrix.arch == 'x64'
shell: powershell
run: |
$urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
Expand All @@ -190,20 +194,23 @@ jobs:
(New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
Expand-Archive compat.zip -DestinationPath . -Force
Remove-Item compat.zip
- name: install vcpkg deps for arm64
if: matrix.arch == 'arm64'
run: .\compat\vcbuild\vcpkg_install.bat arm64-windows
- name: add msbuild to PATH
uses: microsoft/setup-msbuild@v1
- name: copy dlls to root
shell: powershell
run: |
& compat\vcbuild\vcpkg_copy_dlls.bat release
& compat\vcbuild\vcpkg_copy_dlls.bat release ${{ matrix.arch }}-windows
if (!$?) { exit(1) }
- name: generate Visual Studio solution
shell: bash
run: |
cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
-DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/${{ matrix.arch }}-windows \
-DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON -DCMAKE_GENERATOR_PLATFORM=${{ matrix.arch }} -DVCPKG_ARCH=${{ matrix.arch }}-windows
- name: MSBuild
run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
run: msbuild git.sln -property:Configuration=Release -property:Platform=${{ matrix.arch }} -maxCpuCount:4 -property:PlatformToolset=v142
- name: bundle artifact tar
shell: powershell
env:
Expand All @@ -217,7 +224,7 @@ jobs:
- name: upload build artifacts
uses: actions/upload-artifact@v1
with:
name: vs-artifacts
name: vs-artifacts-${{ matrix.arch }}
path: artifacts
vs-test:
runs-on: windows-latest
Expand All @@ -235,7 +242,7 @@ jobs:
- name: download build artifacts
uses: actions/download-artifact@v1
with:
name: vs-artifacts
name: vs-artifacts-x64
path: ${{github.workspace}}
- name: extract build artifacts
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion compat/bswap.h
Expand Up @@ -74,7 +74,7 @@ static inline uint64_t git_bswap64(uint64_t x)
}
#endif

#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64))

#include <stdlib.h>

Expand Down
6 changes: 5 additions & 1 deletion compat/vcbuild/README
Expand Up @@ -6,7 +6,11 @@ The Steps to Build Git with VS2015 or VS2017 from the command line.
Prompt or from an SDK bash window:

$ cd <repo_root>
$ ./compat/vcbuild/vcpkg_install.bat
$ ./compat/vcbuild/vcpkg_install.bat x64-windows

or

$ ./compat/vcbuild/vcpkg_install.bat arm64-windows

The vcpkg tools and all of the third-party sources will be installed
in this folder:
Expand Down
7 changes: 6 additions & 1 deletion compat/vcbuild/vcpkg_copy_dlls.bat
Expand Up @@ -15,7 +15,12 @@ REM ================================================================
@FOR /F "delims=" %%D IN ("%~dp0") DO @SET cwd=%%~fD
cd %cwd%

SET arch=x64-windows
SET arch=%2
IF NOT DEFINED arch (
echo defaulting to 'x64-windows`. Invoke %0 with 'x86-windows', 'x64-windows', or 'arm64-windows'
set arch=x64-windows
)

SET inst=%cwd%vcpkg\installed\%arch%

IF [%1]==[release] (
Expand Down
44 changes: 41 additions & 3 deletions compat/vcbuild/vcpkg_install.bat
Expand Up @@ -31,6 +31,12 @@ REM ================================================================

SETLOCAL EnableDelayedExpansion

SET arch=%1
IF NOT DEFINED arch (
echo defaulting to 'x64-windows`. Invoke %0 with 'x86-windows', 'x64-windows', or 'arm64-windows'
set arch=x64-windows
)

@FOR /F "delims=" %%D IN ("%~dp0") DO @SET cwd=%%~fD
cd %cwd%

Expand All @@ -55,9 +61,8 @@ REM ================================================================
echo Successfully installed %cwd%vcpkg\vcpkg.exe

:install_libraries
SET arch=x64-windows

echo Installing third-party libraries...
echo Installing third-party libraries(%arch%)...
FOR %%i IN (zlib expat libiconv openssl libssh2 curl) DO (
cd %cwd%vcpkg
IF NOT EXIST "packages\%%i_%arch%" CALL :sub__install_one %%i
Expand All @@ -80,14 +85,47 @@ REM ================================================================
:sub__install_one
echo Installing package %1...

call :%1_features

REM vcpkg may not be reliable on slow, intermittent or proxy
REM connections, see e.g.
REM https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/4a8f7be5-5e15-4213-a7bb-ddf424a954e6/winhttpsendrequest-ends-with-12002-errorhttptimeout-after-21-seconds-no-matter-what-timeout?forum=windowssdk
REM which explains the hidden 21 second timeout
REM (last post by Dave : Microsoft - Windows Networking team)

.\vcpkg.exe install %1:%arch%
.\vcpkg.exe install %1%features%:%arch%
IF ERRORLEVEL 1 ( EXIT /B 1 )

echo Finished %1
goto :EOF

::
:: features for each vcpkg to install
:: there should be an entry here for each package to install
:: 'set features=' means use the default otherwise
:: 'set features=[comma-delimited-feature-set]' is the syntax
::

:zlib_features
set features=
goto :EOF

:expat_features
set features=
goto :EOF

:libiconv_features
set features=
goto :EOF

:openssl_features
set features=
goto :EOF

:libssh2_features
set features=
goto :EOF

:curl_features
set features=[core,openssl,schannel]
goto :EOF
6 changes: 3 additions & 3 deletions contrib/buildsystems/CMakeLists.txt
Expand Up @@ -52,9 +52,9 @@ if(WIN32)
set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
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)
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat ${VCPKG_ARCH})
endif()
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/x64-windows")
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/${VCPKG_ARCH}")

# In the vcpkg edition, we need this to be able to link to libcurl
set(CURL_NO_CURL_CMAKE ON)
Expand Down Expand Up @@ -954,7 +954,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n"
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
if(WIN32)
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/${VCPKG_ARCH}/bin\"\n")
endif()

#Make the tests work when building out of the source tree
Expand Down
25 changes: 22 additions & 3 deletions contrib/buildsystems/Generators/Vcxproj.pm
Expand Up @@ -116,12 +116,21 @@ sub createProject {
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>$uuid</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<VCPKGArch Condition="'\$(Platform)'=='Win32'">x86-windows</VCPKGArch>
<VCPKGArch Condition="'\$(Platform)'!='Win32'">x64-windows</VCPKGArch>
<VCPKGArch Condition="'\$(Platform)'=='x64'">x64-windows</VCPKGArch>
<VCPKGArch Condition="'\$(Platform)'=='ARM64'">arm64-windows</VCPKGArch>
<VCPKGArchDirectory>$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)</VCPKGArchDirectory>
<VCPKGBinDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\bin</VCPKGBinDirectory>
<VCPKGLibDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\lib</VCPKGLibDirectory>
Expand All @@ -142,7 +151,7 @@ sub createProject {
</PropertyGroup>
<PropertyGroup>
<ConfigurationType>$config_type</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<!-- <CharacterSet>UTF-8</CharacterSet> -->
<OutDir>..\\</OutDir>
<!-- <IntDir>\$(ProjectDir)\$(Configuration)\\</IntDir> -->
Expand Down Expand Up @@ -186,7 +195,7 @@ EOM
<PreBuildEvent Condition="!Exists('$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)\\include\\openssl\\ssl.h')">
<Message>Initialize VCPKG</Message>
<Command>del "$cdup\\compat\\vcbuild\\vcpkg"</Command>
<Command>call "$cdup\\compat\\vcbuild\\vcpkg_install.bat"</Command>
<Command>call "$cdup\\compat\\vcbuild\\vcpkg_install.bat" \$(VCPKGArch)</Command>
</PreBuildEvent>
EOM
}
Expand Down Expand Up @@ -348,8 +357,10 @@ sub createGlueProject {
print F << "EOM";
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
Expand All @@ -360,10 +371,14 @@ EOM
foreach (@apps) {
my $appname = $_;
my $uuid = $build_structure{"APPS_${appname}_GUID"};
print F "\t\t${uuid}.Debug|ARM64.ActiveCfg = Debug|ARM64\n";
print F "\t\t${uuid}.Debug|ARM64.Build.0 = Debug|ARM64\n";
print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n";
print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n";
print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n";
print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n";
print F "\t\t${uuid}.Release|ARM64.ActiveCfg = Release|ARM64\n";
print F "\t\t${uuid}.Release|ARM64.Build.0 = Release|ARM64\n";
print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n";
print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n";
print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n";
Expand All @@ -372,10 +387,14 @@ EOM
foreach (@libs) {
my $libname = $_;
my $uuid = $build_structure{"LIBS_${libname}_GUID"};
print F "\t\t${uuid}.Debug|ARM64.ActiveCfg = Debug|ARM64\n";
print F "\t\t${uuid}.Debug|ARM64.Build.0 = Debug|ARM64\n";
print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n";
print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n";
print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n";
print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n";
print F "\t\t${uuid}.Release|ARM64.ActiveCfg = Release|ARM64\n";
print F "\t\t${uuid}.Release|ARM64.Build.0 = Release|ARM64\n";
print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n";
print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n";
print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n";
Expand Down

0 comments on commit fe4092f

Please sign in to comment.