@@ -2,8 +2,9 @@ import * as core from '@actions/core'
2
2
import { mkdirp } from './src/downloader'
3
3
import { restoreCache , saveCache } from '@actions/cache'
4
4
import process from 'process'
5
- import { spawnSync } from 'child_process'
5
+ import { spawn , spawnSync } from 'child_process'
6
6
import { getViaGit } from './src/git'
7
+ import * as fs from 'fs'
7
8
8
9
async function run ( ) : Promise < void > {
9
10
try {
@@ -15,10 +16,15 @@ async function run(): Promise<void> {
15
16
}
16
17
const flavor = core . getInput ( 'flavor' )
17
18
const architecture = core . getInput ( 'architecture' )
19
+ const architectureToDownload =
20
+ architecture === 'aarch64' ? 'x86_64' : architecture
18
21
const verbose = core . getInput ( 'verbose' )
19
22
const msysMode = core . getInput ( 'msys' ) === 'true'
20
23
21
- const { artifactName, download, id} = await getViaGit ( flavor , architecture )
24
+ const { artifactName, download, id} = await getViaGit (
25
+ flavor ,
26
+ architectureToDownload
27
+ )
22
28
const outputDirectory = core . getInput ( 'path' ) || `C:/${ artifactName } `
23
29
let useCache : boolean
24
30
switch ( core . getInput ( 'cache' ) ) {
@@ -61,13 +67,31 @@ async function run(): Promise<void> {
61
67
}
62
68
}
63
69
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
+
65
86
const msystem = msysMode ? 'MSYS' : mingw
66
87
67
88
const binPaths = [
68
89
// Set up PATH so that Git for Windows' SDK's `bash.exe`, `prove` and `gcc` are found
69
90
'/usr/bin/core_perl' ,
70
91
'/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' ] : [ ] ) ,
71
95
`/${ mingw . toLocaleLowerCase ( ) } /bin`
72
96
]
73
97
for ( const binPath of msysMode ? binPaths . reverse ( ) : binPaths ) {
@@ -109,9 +133,68 @@ async function run(): Promise<void> {
109
133
} ) ) {
110
134
ln ( `/dev/${ linkPath } ` , `/proc/self/${ target } ` )
111
135
}
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
+ }
112
143
} catch ( error ) {
113
144
core . setFailed ( error instanceof Error ? error . message : `${ error } ` )
114
145
}
115
146
}
116
147
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
+
117
200
run ( )
0 commit comments