Skip to content

Commit fe4092f

Browse files
authored
Merge pull request #2915 from dennisameling/windows-arm64-support
Windows arm64 support
2 parents d054eb1 + d4e8297 commit fe4092f

File tree

7 files changed

+91
-18
lines changed

7 files changed

+91
-18
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ jobs:
164164
NO_PERL: 1
165165
GIT_CONFIG_PARAMETERS: "'user.name=CI' 'user.email=ci@git'"
166166
runs-on: windows-latest
167+
strategy:
168+
matrix:
169+
arch: [x64, arm64]
167170
steps:
168171
- uses: actions/checkout@v1
169172
- name: download git-sdk-64-minimal
@@ -182,6 +185,7 @@ jobs:
182185
unzip artifacts.zip
183186
rm artifacts.zip
184187
- name: download vcpkg artifacts
188+
if: matrix.arch == 'x64'
185189
shell: powershell
186190
run: |
187191
$urlbase = "https://dev.azure.com/git/git/_apis/build/builds"
@@ -190,20 +194,23 @@ jobs:
190194
(New-Object Net.WebClient).DownloadFile($downloadUrl, "compat.zip")
191195
Expand-Archive compat.zip -DestinationPath . -Force
192196
Remove-Item compat.zip
197+
- name: install vcpkg deps for arm64
198+
if: matrix.arch == 'arm64'
199+
run: .\compat\vcbuild\vcpkg_install.bat arm64-windows
193200
- name: add msbuild to PATH
194201
uses: microsoft/setup-msbuild@v1
195202
- name: copy dlls to root
196203
shell: powershell
197204
run: |
198-
& compat\vcbuild\vcpkg_copy_dlls.bat release
205+
& compat\vcbuild\vcpkg_copy_dlls.bat release ${{ matrix.arch }}-windows
199206
if (!$?) { exit(1) }
200207
- name: generate Visual Studio solution
201208
shell: bash
202209
run: |
203-
cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows \
204-
-DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
210+
cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/${{ matrix.arch }}-windows \
211+
-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
205212
- name: MSBuild
206-
run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
213+
run: msbuild git.sln -property:Configuration=Release -property:Platform=${{ matrix.arch }} -maxCpuCount:4 -property:PlatformToolset=v142
207214
- name: bundle artifact tar
208215
shell: powershell
209216
env:
@@ -217,7 +224,7 @@ jobs:
217224
- name: upload build artifacts
218225
uses: actions/upload-artifact@v1
219226
with:
220-
name: vs-artifacts
227+
name: vs-artifacts-${{ matrix.arch }}
221228
path: artifacts
222229
vs-test:
223230
runs-on: windows-latest
@@ -235,7 +242,7 @@ jobs:
235242
- name: download build artifacts
236243
uses: actions/download-artifact@v1
237244
with:
238-
name: vs-artifacts
245+
name: vs-artifacts-x64
239246
path: ${{github.workspace}}
240247
- name: extract build artifacts
241248
shell: bash

compat/bswap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static inline uint64_t git_bswap64(uint64_t x)
7474
}
7575
#endif
7676

77-
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
77+
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64))
7878

7979
#include <stdlib.h>
8080

compat/vcbuild/README

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ The Steps to Build Git with VS2015 or VS2017 from the command line.
66
Prompt or from an SDK bash window:
77

88
$ cd <repo_root>
9-
$ ./compat/vcbuild/vcpkg_install.bat
9+
$ ./compat/vcbuild/vcpkg_install.bat x64-windows
10+
11+
or
12+
13+
$ ./compat/vcbuild/vcpkg_install.bat arm64-windows
1014

1115
The vcpkg tools and all of the third-party sources will be installed
1216
in this folder:

compat/vcbuild/vcpkg_copy_dlls.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ REM ================================================================
1515
@FOR /F "delims=" %%D IN ("%~dp0") DO @SET cwd=%%~fD
1616
cd %cwd%
1717

18-
SET arch=x64-windows
18+
SET arch=%2
19+
IF NOT DEFINED arch (
20+
echo defaulting to 'x64-windows`. Invoke %0 with 'x86-windows', 'x64-windows', or 'arm64-windows'
21+
set arch=x64-windows
22+
)
23+
1924
SET inst=%cwd%vcpkg\installed\%arch%
2025

2126
IF [%1]==[release] (

compat/vcbuild/vcpkg_install.bat

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ REM ================================================================
3131

3232
SETLOCAL EnableDelayedExpansion
3333

34+
SET arch=%1
35+
IF NOT DEFINED arch (
36+
echo defaulting to 'x64-windows`. Invoke %0 with 'x86-windows', 'x64-windows', or 'arm64-windows'
37+
set arch=x64-windows
38+
)
39+
3440
@FOR /F "delims=" %%D IN ("%~dp0") DO @SET cwd=%%~fD
3541
cd %cwd%
3642

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

5763
:install_libraries
58-
SET arch=x64-windows
5964

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

88+
call :%1_features
89+
8390
REM vcpkg may not be reliable on slow, intermittent or proxy
8491
REM connections, see e.g.
8592
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
8693
REM which explains the hidden 21 second timeout
8794
REM (last post by Dave : Microsoft - Windows Networking team)
8895

89-
.\vcpkg.exe install %1:%arch%
96+
.\vcpkg.exe install %1%features%:%arch%
9097
IF ERRORLEVEL 1 ( EXIT /B 1 )
9198

9299
echo Finished %1
93100
goto :EOF
101+
102+
::
103+
:: features for each vcpkg to install
104+
:: there should be an entry here for each package to install
105+
:: 'set features=' means use the default otherwise
106+
:: 'set features=[comma-delimited-feature-set]' is the syntax
107+
::
108+
109+
:zlib_features
110+
set features=
111+
goto :EOF
112+
113+
:expat_features
114+
set features=
115+
goto :EOF
116+
117+
:libiconv_features
118+
set features=
119+
goto :EOF
120+
121+
:openssl_features
122+
set features=
123+
goto :EOF
124+
125+
:libssh2_features
126+
set features=
127+
goto :EOF
128+
129+
:curl_features
130+
set features=[core,openssl,schannel]
131+
goto :EOF

contrib/buildsystems/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ if(WIN32)
5252
set(VCPKG_DIR "${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg")
5353
if(MSVC AND NOT EXISTS ${VCPKG_DIR})
5454
message("Initializing vcpkg and building the Git's dependencies (this will take a while...)")
55-
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat)
55+
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/compat/vcbuild/vcpkg_install.bat ${VCPKG_ARCH})
5656
endif()
57-
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/x64-windows")
57+
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/installed/${VCPKG_ARCH}")
5858

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

960960
#Make the tests work when building out of the source tree

contrib/buildsystems/Generators/Vcxproj.pm

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,21 @@ sub createProject {
116116
<Configuration>Release</Configuration>
117117
<Platform>x64</Platform>
118118
</ProjectConfiguration>
119+
<ProjectConfiguration Include="Debug|ARM64">
120+
<Configuration>Debug</Configuration>
121+
<Platform>ARM64</Platform>
122+
</ProjectConfiguration>
123+
<ProjectConfiguration Include="Release|ARM64">
124+
<Configuration>Release</Configuration>
125+
<Platform>ARM64</Platform>
126+
</ProjectConfiguration>
119127
</ItemGroup>
120128
<PropertyGroup Label="Globals">
121129
<ProjectGuid>$uuid</ProjectGuid>
122130
<Keyword>Win32Proj</Keyword>
123131
<VCPKGArch Condition="'\$(Platform)'=='Win32'">x86-windows</VCPKGArch>
124-
<VCPKGArch Condition="'\$(Platform)'!='Win32'">x64-windows</VCPKGArch>
132+
<VCPKGArch Condition="'\$(Platform)'=='x64'">x64-windows</VCPKGArch>
133+
<VCPKGArch Condition="'\$(Platform)'=='ARM64'">arm64-windows</VCPKGArch>
125134
<VCPKGArchDirectory>$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)</VCPKGArchDirectory>
126135
<VCPKGBinDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\bin</VCPKGBinDirectory>
127136
<VCPKGLibDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\lib</VCPKGLibDirectory>
@@ -142,7 +151,7 @@ sub createProject {
142151
</PropertyGroup>
143152
<PropertyGroup>
144153
<ConfigurationType>$config_type</ConfigurationType>
145-
<PlatformToolset>v140</PlatformToolset>
154+
<PlatformToolset>v142</PlatformToolset>
146155
<!-- <CharacterSet>UTF-8</CharacterSet> -->
147156
<OutDir>..\\</OutDir>
148157
<!-- <IntDir>\$(ProjectDir)\$(Configuration)\\</IntDir> -->
@@ -186,7 +195,7 @@ EOM
186195
<PreBuildEvent Condition="!Exists('$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)\\include\\openssl\\ssl.h')">
187196
<Message>Initialize VCPKG</Message>
188197
<Command>del "$cdup\\compat\\vcbuild\\vcpkg"</Command>
189-
<Command>call "$cdup\\compat\\vcbuild\\vcpkg_install.bat"</Command>
198+
<Command>call "$cdup\\compat\\vcbuild\\vcpkg_install.bat" \$(VCPKGArch)</Command>
190199
</PreBuildEvent>
191200
EOM
192201
}
@@ -348,8 +357,10 @@ sub createGlueProject {
348357
print F << "EOM";
349358
Global
350359
GlobalSection(SolutionConfigurationPlatforms) = preSolution
360+
Debug|ARM64 = Debug|ARM64
351361
Debug|x64 = Debug|x64
352362
Debug|x86 = Debug|x86
363+
Release|ARM64 = Release|ARM64
353364
Release|x64 = Release|x64
354365
Release|x86 = Release|x86
355366
EndGlobalSection
@@ -360,10 +371,14 @@ EOM
360371
foreach (@apps) {
361372
my $appname = $_;
362373
my $uuid = $build_structure{"APPS_${appname}_GUID"};
374+
print F "\t\t${uuid}.Debug|ARM64.ActiveCfg = Debug|ARM64\n";
375+
print F "\t\t${uuid}.Debug|ARM64.Build.0 = Debug|ARM64\n";
363376
print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n";
364377
print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n";
365378
print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n";
366379
print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n";
380+
print F "\t\t${uuid}.Release|ARM64.ActiveCfg = Release|ARM64\n";
381+
print F "\t\t${uuid}.Release|ARM64.Build.0 = Release|ARM64\n";
367382
print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n";
368383
print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n";
369384
print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n";
@@ -372,10 +387,14 @@ EOM
372387
foreach (@libs) {
373388
my $libname = $_;
374389
my $uuid = $build_structure{"LIBS_${libname}_GUID"};
390+
print F "\t\t${uuid}.Debug|ARM64.ActiveCfg = Debug|ARM64\n";
391+
print F "\t\t${uuid}.Debug|ARM64.Build.0 = Debug|ARM64\n";
375392
print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n";
376393
print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n";
377394
print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n";
378395
print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n";
396+
print F "\t\t${uuid}.Release|ARM64.ActiveCfg = Release|ARM64\n";
397+
print F "\t\t${uuid}.Release|ARM64.Build.0 = Release|ARM64\n";
379398
print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n";
380399
print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n";
381400
print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n";

0 commit comments

Comments
 (0)