Skip to content

Commit ef3a752

Browse files
committed
Add ARM64/aarch64 support
Signed-off-by: Dennis Ameling <dennis@dennisameling.com>
1 parent f851f2a commit ef3a752

File tree

4 files changed

+154
-7
lines changed

4 files changed

+154
-7
lines changed

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 or i686'
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.'
1515
default: 'x86_64'
1616
msys:
1717
required: false

dist/index.js

Lines changed: 66 additions & 2 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: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ 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 {spawnSync} from 'child_process'
5+
import {spawn, spawnSync} from 'child_process'
66
import {getViaGit} from './src/git'
7+
import * as fs from 'fs'
78

89
async function run(): Promise<void> {
910
try {
@@ -15,10 +16,15 @@ async function run(): Promise<void> {
1516
}
1617
const flavor = core.getInput('flavor')
1718
const architecture = core.getInput('architecture')
19+
const architectureToDownload =
20+
architecture === 'aarch64' ? 'x86_64' : architecture
1821
const verbose = core.getInput('verbose')
1922
const msysMode = core.getInput('msys') === 'true'
2023

21-
const {artifactName, download, id} = await getViaGit(flavor, architecture)
24+
const {artifactName, download, id} = await getViaGit(
25+
flavor,
26+
architectureToDownload
27+
)
2228
const outputDirectory = core.getInput('path') || `C:/${artifactName}`
2329
let useCache: boolean
2430
switch (core.getInput('cache')) {
@@ -61,13 +67,31 @@ async function run(): Promise<void> {
6167
}
6268
}
6369

64-
const mingw = architecture === 'i686' ? 'MINGW32' : 'MINGW64'
70+
let mingw = ''
71+
72+
switch (architecture) {
73+
case 'i686':
74+
mingw = 'MINGW32'
75+
break
76+
case 'x86_64':
77+
mingw = 'MINGW64'
78+
break
79+
case 'aarch64':
80+
mingw = 'CLANGARM64'
81+
break
82+
default:
83+
core.setFailed(`Invalid architecture ${architecture} specified`)
84+
}
85+
6586
const msystem = msysMode ? 'MSYS' : mingw
6687

6788
const binPaths = [
6889
// Set up PATH so that Git for Windows' SDK's `bash.exe`, `prove` and `gcc` are found
6990
'/usr/bin/core_perl',
7091
'/usr/bin',
92+
// Some binaries aren't available yet in the /clangarm64/bin folder, but Windows 11 ARM64
93+
// has support for x64 emulation, so let's add /mingw64/bin as a fallback.
94+
...(msystem === 'CLANGARM64' ? ['/mingw64/bin'] : []),
7195
`/${mingw.toLocaleLowerCase()}/bin`
7296
]
7397
for (const binPath of msysMode ? binPaths.reverse() : binPaths) {
@@ -109,9 +133,68 @@ async function run(): Promise<void> {
109133
})) {
110134
ln(`/dev/${linkPath}`, `/proc/self/${target}`)
111135
}
136+
137+
if (msystem === 'CLANGARM64') {
138+
// ARM64 dependencies aren't included yet in the Git for Windows SDK. Ask Pacman to install them.
139+
core.startGroup(`Installing CLANGARM64 dependencies`)
140+
await installArm64Dependencies(outputDirectory, flavor)
141+
core.endGroup()
142+
}
112143
} catch (error) {
113144
core.setFailed(error instanceof Error ? error.message : `${error}`)
114145
}
115146
}
116147

148+
async function installArm64Dependencies(
149+
outputDirectory: string,
150+
flavor: string
151+
): Promise<void> {
152+
mkdirp(`${outputDirectory}/clangarm64`)
153+
fs.appendFileSync(
154+
`${outputDirectory}/etc/pacman.conf`,
155+
`
156+
[clangarm64]
157+
Server = https://mirror.msys2.org/mingw/clangarm64/`
158+
)
159+
160+
const child = spawn('pacman.exe', [
161+
'-Sy',
162+
'--noconfirm',
163+
'base-devel',
164+
'mingw-w64-clang-aarch64-openssl',
165+
'mingw-w64-clang-aarch64-zlib',
166+
'mingw-w64-clang-aarch64-curl',
167+
'mingw-w64-clang-aarch64-expat',
168+
'mingw-w64-clang-aarch64-libiconv',
169+
'mingw-w64-clang-aarch64-pcre2',
170+
'mingw-w64-clang-aarch64-libssp',
171+
...(flavor === 'full' || flavor === 'makepkg-git'
172+
? [
173+
'mingw-w64-clang-aarch64-toolchain',
174+
'mingw-w64-clang-aarch64-asciidoc'
175+
]
176+
: [])
177+
])
178+
179+
child.stdout.setEncoding('utf-8')
180+
child.stderr.setEncoding('utf-8')
181+
182+
child.stdout.on('data', data => {
183+
core.info(data)
184+
})
185+
186+
child.stderr.on('data', data => {
187+
core.error(data)
188+
})
189+
190+
return new Promise((resolve, reject) => {
191+
child.on('error', error => reject(error))
192+
child.on('close', status =>
193+
status === 0
194+
? resolve()
195+
: reject(new Error(`Process exited with status code ${status}`))
196+
)
197+
})
198+
}
199+
117200
run()

0 commit comments

Comments
 (0)