@@ -24,38 +24,10 @@ param (
2424 $SkipDownload ,
2525
2626 [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
3628)
3729
3830# 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- }
5931
6032function mkdirp {
6133 param ([string ] $dir , [switch ] $clean )
@@ -86,7 +58,7 @@ $ProgressPreference = 'SilentlyContinue'
8658
8759Write-Host " Building from $ConfigFile "
8860
89- $suffix = [io.path ]::GetFileNameWithoutExtension($ConfigFile ) + ( $BuildType -eq ' user ' ? ' -user ' : ' ' )
61+ $suffix = [io.path ]::GetFileNameWithoutExtension($ConfigFile )
9062
9163$tools = (Get-Content ' .\config\tools.json' | ConvertFrom-Json ).tools
9264$repositories = (Get-Content ' .\config\repositories.json' | ConvertFrom-Json ).repositories
@@ -97,8 +69,8 @@ if ("" -ne $Version) {
9769 $version = (Get-Content " $PSScriptRoot \version.txt" ).Trim()
9870}
9971$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 ()
10274$downloads = $config.downloads
10375
10476mkdirp " build"
@@ -158,6 +130,8 @@ if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
158130 $env: PATH = $env: PATH + ' ;' + (Resolve-Path .\build\git\cmd).Path
159131}
160132
133+ exec { git config -- global core.autocrlf false }
134+
161135$repositories | ForEach-Object {
162136 $repodir = Join-Path ' build' ([IO.Path ]::GetFileNameWithoutExtension($_.href ))
163137 $repodir = $repodir.TrimEnd (" -rp2350" )
@@ -223,8 +197,8 @@ function msys {
223197
224198# Preserve the current working directory
225199$env: CHERE_INVOKING = ' yes'
226- # Start MINGW32/64 environment
227- $env: MSYSTEM = " MINGW $bitness "
200+ # Use real symlinks
201+ $env: MSYS = " winsymlinks:nativestrict "
228202
229203if (-not $SkipDownload ) {
230204 # First run setup
@@ -234,33 +208,37 @@ if (-not $SkipDownload) {
234208 # Normal update
235209 msys ' pacman --noconfirm -Suu'
236210
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"
238212 # 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 "
240214}
241215
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"
244218}
245219
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 "
248226}
249227
250228if ($version.Substring (0 , 1 ) -ge 2 ) {
251229 # 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"
255233} else {
256234 $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"
258236
259237 # 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"
264242}
265243
266244# Package pico-sdk-tools separately as well
@@ -270,23 +248,23 @@ $filename = 'pico-sdk-tools-{0}-{1}.zip' -f
270248 $suffix
271249
272250Write-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 " ' * ' }
274252
275253# Package picotool separately as well
276254
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' )
278256Write-Host " Picotool version $version "
279257
280258$filename = ' picotool-{0}-{1}.zip' -f
281259 $version ,
282260 $suffix
283261
284262Write-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 " ' * ' }
286264
287265# Package OpenOCD separately as well
288266
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 ]
290268if (-not ($version -match ' Open On-Chip Debugger (?<version>[a-zA-Z0-9\.\-+]+) \((?<timestamp>[0-9\-:]+)\)' )) {
291269 Write-Error ' Could not determine openocd version'
292270}
@@ -297,7 +275,18 @@ $filename = 'openocd-{0}-{1}.zip' -f
297275
298276# Removing files with special char in their names
299277# 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"
301279
302280Write-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