@@ -24,38 +24,10 @@ param (
24
24
$SkipDownload ,
25
25
26
26
[switch ]
27
- $SkipSigning ,
28
-
29
- [ValidateSet (' zlib' , ' bzip2' , ' lzma' )]
30
- [string ]
31
- $Compression = ' lzma' ,
32
-
33
- [ValidateSet (' system' , ' user' )]
34
- [string ]
35
- $BuildType = ' system'
27
+ $SkipSigning
36
28
)
37
29
38
30
# Requires -Version 7.2
39
-
40
- function crawl {
41
- param ([string ]$url )
42
-
43
- (Invoke-WebRequest $url - UseBasicParsing).Links |
44
- Where-Object {
45
- ($_ | Get-Member href) -and
46
- [uri ]::IsWellFormedUriString($_.href , [System.UriKind ]::RelativeOrAbsolute)
47
- } |
48
- ForEach-Object {
49
- $href = [System.Net.WebUtility ]::HtmlDecode($_.href )
50
-
51
- try {
52
- (New-Object System.Uri([uri ]$url , $href )).AbsoluteUri
53
- }
54
- catch {
55
- $href
56
- }
57
- }
58
- }
59
31
60
32
function mkdirp {
61
33
param ([string ] $dir , [switch ] $clean )
@@ -86,7 +58,7 @@ $ProgressPreference = 'SilentlyContinue'
86
58
87
59
Write-Host " Building from $ConfigFile "
88
60
89
- $suffix = [io.path ]::GetFileNameWithoutExtension($ConfigFile ) + ( $BuildType -eq ' user ' ? ' -user ' : ' ' )
61
+ $suffix = [io.path ]::GetFileNameWithoutExtension($ConfigFile )
90
62
91
63
$tools = (Get-Content ' .\config\tools.json' | ConvertFrom-Json ).tools
92
64
$repositories = (Get-Content ' .\config\repositories.json' | ConvertFrom-Json ).repositories
@@ -97,8 +69,8 @@ if ("" -ne $Version) {
97
69
$version = (Get-Content " $PSScriptRoot \version.txt" ).Trim()
98
70
}
99
71
$config = Get-Content $ConfigFile | ConvertFrom-Json
100
- $bitness = $config.bitness
101
- $mingw_arch = $config.mingwArch
72
+ $env: MSYSTEM = $config.msysEnv
73
+ $msysEnv = $config.msysEnv.ToLowerInvariant ()
102
74
$downloads = $config.downloads
103
75
104
76
mkdirp " build"
@@ -158,6 +130,8 @@ if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
158
130
$env: PATH = $env: PATH + ' ;' + (Resolve-Path .\build\git\cmd).Path
159
131
}
160
132
133
+ exec { git config -- global core.autocrlf false }
134
+
161
135
$repositories | ForEach-Object {
162
136
$repodir = Join-Path ' build' ([IO.Path ]::GetFileNameWithoutExtension($_.href ))
163
137
$repodir = $repodir.TrimEnd (" -rp2350" )
@@ -223,8 +197,8 @@ function msys {
223
197
224
198
# Preserve the current working directory
225
199
$env: CHERE_INVOKING = ' yes'
226
- # Start MINGW32/64 environment
227
- $env: MSYSTEM = " MINGW $bitness "
200
+ # Use real symlinks
201
+ $env: MSYS = " winsymlinks:nativestrict "
228
202
229
203
if (-not $SkipDownload ) {
230
204
# First run setup
@@ -234,33 +208,37 @@ if (-not $SkipDownload) {
234
208
# Normal update
235
209
msys ' pacman --noconfirm -Suu'
236
210
237
- msys " pacman -S --noconfirm --needed autoconf automake git libtool make pactoys pkg-config wget "
211
+ msys " pacman -S --noconfirm --needed autoconf automake base-devel expat git libtool pactoys patchutils pkg-config"
238
212
# pacboy adds MINGW_PACKAGE_PREFIX to package names suffixed with :p
239
- msys " pacboy -S --noconfirm --needed cmake:p ninja:p toolchain:p libusb:p hidapi:p"
213
+ msys " pacboy -S --noconfirm --needed cmake:p ninja:p toolchain:p libusb:p hidapi:p libslirp:p "
240
214
}
241
215
242
- if (-not (Test-Path " .\build\openocd -install\mingw $bitness " )) {
243
- msys " cd build && ../packages/windows/openocd /build-openocd .sh $bitness $mingw_arch "
216
+ if (-not (Test-Path " .\build\riscv -install\$msysEnv " ) -and ( $ env: SKIP_RISCV -ne ' 1 ' )) {
217
+ msys " cd build && ../packages/windows/riscv /build-riscv-gcc .sh"
244
218
}
245
219
246
- if (-not (Test-Path " .\build\picotool-install\mingw$bitness " )) {
247
- msys " cd build && ../packages/windows/picotool/build-picotool.sh $bitness $mingw_arch $version "
220
+ if (-not (Test-Path " .\build\openocd-install\$msysEnv " ) -and ($env: SKIP_OPENOCD -ne ' 1' )) {
221
+ msys " cd build && ../packages/windows/openocd/build-openocd.sh"
222
+ }
223
+
224
+ if (-not (Test-Path " .\build\picotool-install\$msysEnv " )) {
225
+ msys " cd build && ../packages/windows/picotool/build-picotool.sh $version "
248
226
}
249
227
250
228
if ($version.Substring (0 , 1 ) -ge 2 ) {
251
229
# Sign files before packaging up the installer
252
- sign " build\openocd-install\mingw $bitness \bin\openocd.exe" ,
253
- " build\pico-sdk-tools\mingw $bitness \pioasm\pioasm.exe" ,
254
- " build\picotool-install\mingw $bitness \picotool\picotool.exe"
230
+ sign " build\openocd-install\$msysEnv \bin\openocd.exe" ,
231
+ " build\pico-sdk-tools\$msysEnv \pioasm\pioasm.exe" ,
232
+ " build\picotool-install\$msysEnv \picotool\picotool.exe"
255
233
} else {
256
234
$template = Get-Content " .\packages\windows\pico-sdk-tools\pico-sdk-tools-config-version.cmake" - Raw
257
- $ExecutionContext.InvokeCommand.ExpandString ($template ) | Set-Content " .\build\pico-sdk-tools\mingw $bitness \pico-sdk-tools-config-version.cmake"
235
+ $ExecutionContext.InvokeCommand.ExpandString ($template ) | Set-Content " .\build\pico-sdk-tools\$msysEnv \pico-sdk-tools-config-version.cmake"
258
236
259
237
# Sign files before packaging up the installer
260
- sign " build\openocd-install\mingw $bitness \bin\openocd.exe" ,
261
- " build\pico-sdk-tools\mingw $bitness \elf2uf2.exe" ,
262
- " build\pico-sdk-tools\mingw $bitness \pioasm.exe" ,
263
- " build\picotool-install\mingw $bitness \picotool.exe"
238
+ sign " build\openocd-install\$msysEnv \bin\openocd.exe" ,
239
+ " build\pico-sdk-tools\$msysEnv \elf2uf2.exe" ,
240
+ " build\pico-sdk-tools\$msysEnv \pioasm.exe" ,
241
+ " build\picotool-install\$msysEnv \picotool.exe"
264
242
}
265
243
266
244
# Package pico-sdk-tools separately as well
@@ -270,23 +248,23 @@ $filename = 'pico-sdk-tools-{0}-{1}.zip' -f
270
248
$suffix
271
249
272
250
Write-Host " Saving pico-sdk-tools package to $filename "
273
- exec { tar - a - cf " bin\$filename " - C " build\pico-sdk-tools\mingw $bitness \ " * }
251
+ exec { tar - a - cf " bin\$filename " - C " build\pico-sdk-tools\$msysEnv " ' * ' }
274
252
275
253
# Package picotool separately as well
276
254
277
- $version = (cmd / c " .\build\picotool-install\mingw $bitness \picotool\picotool.exe" version - s ' 2>&1' )
255
+ $version = (cmd / c " .\build\picotool-install\$msysEnv \picotool\picotool.exe" version - s ' 2>&1' )
278
256
Write-Host " Picotool version $version "
279
257
280
258
$filename = ' picotool-{0}-{1}.zip' -f
281
259
$version ,
282
260
$suffix
283
261
284
262
Write-Host " Saving picotool package to $filename "
285
- exec { tar - a - cf " bin\$filename " - C " build\picotool-install\mingw $bitness \ " * }
263
+ exec { tar - a - cf " bin\$filename " - C " build\picotool-install\$msysEnv " ' * ' }
286
264
287
265
# Package OpenOCD separately as well
288
266
289
- $version = (cmd / c " .\build\openocd-install\mingw $bitness \bin\openocd.exe" -- version ' 2>&1' )[0 ]
267
+ $version = (cmd / c " .\build\openocd-install\$msysEnv \bin\openocd.exe" -- version ' 2>&1' )[0 ]
290
268
if (-not ($version -match ' Open On-Chip Debugger (?<version>[a-zA-Z0-9\.\-+]+) \((?<timestamp>[0-9\-:]+)\)' )) {
291
269
Write-Error ' Could not determine openocd version'
292
270
}
@@ -297,7 +275,18 @@ $filename = 'openocd-{0}-{1}.zip' -f
297
275
298
276
# Removing files with special char in their names
299
277
# they cause issues with some decompression libraries
300
- exec { Remove-Item " build\openocd-install\mingw $bitness \share\openocd\scripts\target\1986*.cfg" }
278
+ Remove-Item " build\openocd-install\$msysEnv \share\openocd\scripts\target\1986*.cfg"
301
279
302
280
Write-Host " Saving OpenOCD package to $filename "
303
- exec { tar - a - cf " bin\$filename " - C " build\openocd-install\mingw$bitness \bin" * - C " ..\share\openocd" " scripts" }
281
+ exec { tar - a - cf " bin\$filename " - C " build\openocd-install\$msysEnv \bin" ' *' - C " ..\share\openocd" " scripts" }
282
+
283
+ # Package Risc-V separately as well
284
+
285
+ $version = ((. " .\build\riscv-install\$msysEnv \bin\riscv32-unknown-elf-gcc.exe" - dumpversion) -split ' \.' )[0 ]
286
+
287
+ $filename = ' riscv-toolchain-{0}-{1}.zip' -f
288
+ $version ,
289
+ $suffix
290
+
291
+ Write-Host " Saving Risc-V toolchain package to $filename "
292
+ exec { tar - a - cf " bin\$filename " - C " build\riscv-install\$msysEnv " ' *' }
0 commit comments