Skip to content

Commit 1478e8d

Browse files
authored
Merge pull request #562 from dennisameling/native-arm64-sdk
Use new git-sdk-arm64 for aarch64
2 parents 1a859cf + eb5175d commit 1478e8d

File tree

6 files changed

+34
-138
lines changed

6 files changed

+34
-138
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The supported flavors are:
5151

5252
### CPU architecture support
5353

54-
Git for Windows SDK comes in variants targeting `x86_64` (AKA "64-bit") and `i686` (AKA 32-bit). The default is `x86_64` and can be overridden like this:
54+
Git for Windows SDK comes in variants targeting `x86_64` (AKA "64-bit"), `i686` (AKA 32-bit) and `aarch64` (AKA arm64). The default is `x86_64` and can be overridden like this:
5555

5656
```yaml
5757
- uses: git-for-windows/setup-git-for-windows-sdk
@@ -60,9 +60,7 @@ Git for Windows SDK comes in variants targeting `x86_64` (AKA "64-bit") and `i68
6060
architecture: i686
6161
```
6262

63-
Please note that only the `build-installers` and the `full` flavors are available for `i686`.
64-
65-
As a special case, the architecture `aarch64` (AKA "ARM64") is also handled, even if there is no SDK fully targeting Windows/ARM64 (due to missing Cygwin/MSYS support for that architecture); Selecting this architecture will install the `x86_64` flavor of Git for Windows' SDK and then add the MINGW toolchain targeting Windows/ARM64.
63+
Please note that only the `build-installers` and the `full` flavors are available for `i686`. For `aarch64`, only the `full` flavor is available.
6664

6765
### Verbosity
6866

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inputs:
1111
default: 'minimal'
1212
architecture:
1313
required: false
14-
description: 'The architecture of the SDK: x86_64, i686 or aarch64. Note that "aarch64" uses the x86_64 SDK, but adds "clangarm64" to the path.'
14+
description: 'The architecture of the SDK: x86_64, i686 or aarch64. Note that "aarch64" only supports the "full" flavor for now.'
1515
default: 'x86_64'
1616
msys:
1717
required: false

dist/index.js

Lines changed: 12 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.ts

Lines changed: 8 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as core from '@actions/core'
22
import {mkdirp} from './src/downloader'
33
import {restoreCache, saveCache} from '@actions/cache'
44
import process from 'process'
5-
import {spawn, spawnSync} from 'child_process'
5+
import {spawnSync} from 'child_process'
66
import {
77
getArtifactMetadata,
88
getViaGit,
@@ -13,65 +13,6 @@ import * as fs from 'fs'
1313
const flavor = core.getInput('flavor')
1414
const architecture = core.getInput('architecture')
1515

16-
async function installArm64Dependencies(
17-
outputDirectory: string
18-
): Promise<void> {
19-
if (flavor === 'minimal') {
20-
throw new Error(`ARM64 not yet supported with flavor '${flavor}`)
21-
}
22-
23-
mkdirp(`${outputDirectory}/clangarm64`)
24-
fs.appendFileSync(
25-
`${outputDirectory}/etc/pacman.conf`,
26-
`
27-
[clangarm64]
28-
Server = https://mirror.msys2.org/mingw/clangarm64/`
29-
)
30-
31-
const packages = [
32-
'base-devel',
33-
'mingw-w64-clang-aarch64-openssl',
34-
'mingw-w64-clang-aarch64-zlib',
35-
'mingw-w64-clang-aarch64-curl',
36-
'mingw-w64-clang-aarch64-expat',
37-
'mingw-w64-clang-aarch64-libiconv',
38-
'mingw-w64-clang-aarch64-pcre2',
39-
'mingw-w64-clang-aarch64-libssp'
40-
]
41-
if (
42-
flavor === 'full' ||
43-
flavor === 'makepkg-git' ||
44-
flavor === 'build-installers'
45-
) {
46-
packages.push(
47-
'mingw-w64-clang-aarch64-toolchain',
48-
'mingw-w64-clang-aarch64-asciidoc'
49-
)
50-
}
51-
52-
const child = spawn('pacman.exe', ['-Sy', '--noconfirm', ...packages])
53-
54-
child.stdout.setEncoding('utf-8')
55-
child.stderr.setEncoding('utf-8')
56-
57-
child.stdout.on('data', data => {
58-
core.info(data)
59-
})
60-
61-
child.stderr.on('data', data => {
62-
core.error(data)
63-
})
64-
65-
return new Promise((resolve, reject) => {
66-
child.on('error', error => reject(error))
67-
child.on('close', status =>
68-
status === 0
69-
? resolve()
70-
: reject(new Error(`Process exited with status code ${status}`))
71-
)
72-
})
73-
}
74-
7516
async function run(): Promise<void> {
7617
try {
7718
if (process.platform !== 'win32') {
@@ -81,15 +22,19 @@ async function run(): Promise<void> {
8122
return
8223
}
8324

84-
const architectureToDownload =
85-
architecture === 'aarch64' ? 'x86_64' : architecture
25+
if (architecture === 'aarch64' && flavor !== 'full') {
26+
throw new Error(
27+
'On aarch64, only the "full" flavor is supported at this time.'
28+
)
29+
}
30+
8631
const githubToken = core.getInput('github-token')
8732
const verbose = core.getInput('verbose')
8833
const msysMode = core.getInput('msys') === 'true'
8934

9035
const {artifactName, download, id} = await getViaGit(
9136
flavor,
92-
architectureToDownload,
37+
architecture,
9338
githubToken
9439
)
9540
const outputDirectory = core.getInput('path') || `C:/${artifactName}`
@@ -154,12 +99,6 @@ async function run(): Promise<void> {
15499
`/${mingw.toLocaleLowerCase()}/bin`
155100
]
156101

157-
if (architecture === 'aarch64') {
158-
// Some binaries aren't available yet in the /clangarm64/bin folder, but Windows 11 ARM64
159-
// has support for x64 emulation, so let's add /mingw64/bin as a fallback.
160-
binPaths.splice(binPaths.length - 1, 0, '/mingw64/bin')
161-
}
162-
163102
for (const binPath of msysMode ? binPaths.reverse() : binPaths) {
164103
core.addPath(`${outputDirectory}${binPath}`)
165104
}
@@ -199,13 +138,6 @@ async function run(): Promise<void> {
199138
})) {
200139
ln(`/dev/${linkPath}`, `/proc/self/${target}`)
201140
}
202-
203-
if (msystem === 'CLANGARM64') {
204-
// ARM64 dependencies aren't included yet in the Git for Windows SDK. Ask Pacman to install them.
205-
core.startGroup(`Installing CLANGARM64 dependencies`)
206-
await installArm64Dependencies(outputDirectory)
207-
core.endGroup()
208-
}
209141
} catch (error) {
210142
core.setFailed(error instanceof Error ? error.message : `${error}`)
211143
}

src/git.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ export function getArtifactMetadata(
3030
architecture: string
3131
): {bitness: string; repo: string; artifactName: string} {
3232
const bitness = architecture === 'i686' ? '32' : '64'
33-
const repo = `git-sdk-${bitness}`
33+
const repo = {
34+
i686: 'git-sdk-32',
35+
x86_64: 'git-sdk-64',
36+
aarch64: 'git-sdk-arm64'
37+
}[architecture]
38+
39+
if (repo === undefined) {
40+
throw new Error(`Invalid architecture ${architecture} specified`)
41+
}
42+
3443
const artifactName = `${repo}-${flavor}`
3544

3645
return {bitness, repo, artifactName}

0 commit comments

Comments
 (0)