Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

[*.sh]
end_of_line = lf
47 changes: 30 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Test scripts
shell: pwsh
Expand All @@ -29,8 +29,7 @@ jobs:
Invoke-Pester -Configuration $pesterConfig

- name: Upload test results
uses: actions/upload-artifact@v2
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: Pester-Test-Results
path: testResults.xml
Expand All @@ -41,42 +40,56 @@ jobs:
strategy:
fail-fast: false
matrix:
config: [x86, x64, x64-standalone]
config: [x64, x64-standalone]
build-type: [system]
include:
- { config: x64-standalone, build-type: user }
steps:

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup MSYS2
uses: msys2/setup-msys2@v2

- name: Turn off git autocrlf
shell: pwsh
run: git config --global core.autocrlf false

- name: Check OpenOCD repository
shell: pwsh
run: |
$OpenOCDCommit = ((Get-Content .\config\repositories.json | ConvertFrom-Json).repositories | Where-Object { $_.href -like '*openocd.git' } | ForEach-Object { git ls-remote $_.href $_.tree }).Split("`t")[0]
$Bitness = (Get-Content .\config\${{ matrix.config }}.json | ConvertFrom-Json).bitness
Add-Content -Path $env:GITHUB_ENV -Value "OPENOCD_BUILD_ID=openocd-$OpenOCDCommit-$Bitness"
run: .\packages\common\build-id.ps1 openocd .\config\${{ matrix.config }}.json >> $env:GITHUB_ENV

- name: Cache OpenOCD build
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: build/openocd-install
key: ${{ env.OPENOCD_BUILD_ID }}

- name: Check riscv-gnu-toolchain repository
shell: pwsh
run: .\packages\common\build-id.ps1 riscv-gnu-toolchain .\config\${{ matrix.config }}.json >> $env:GITHUB_ENV

- name: Cache riscv-gnu-toolchain build
uses: actions/cache@v4
with:
path: build/riscv-gnu-toolchain-install
key: ${{ env.RISCV-GNU-TOOLCHAIN_BUILD_ID }}

- name: Build ${{ matrix.config }} (${{ matrix.build-type }})
shell: pwsh
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'

subst P: .
P:

.\build.ps1 .\config\${{ matrix.config }}.json -MSYS2Path (msys2 -c 'cygpath -m /').TrimEnd('\/') -SkipSigning -Compression zlib -BuildType ${{ matrix.build-type }}

- name: Upload build artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Package-${{ matrix.config }}-${{ matrix.build-type }}
path: bin/
Expand All @@ -95,22 +108,22 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Download installer artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: Package-${{ matrix.config }}-${{ matrix.build-type }}
path: bin

- name: Test ${{ matrix.config }} (${{ matrix.build-type }})
shell: pwsh
run: docker run --rm -v "$(Get-Location):C:\repo" mcr.microsoft.com/windows/servercore:ltsc${{ matrix.winver }}
powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "cd C:\repo; .\tests\setup.ps1"
run: docker run --rm -v "$(Get-Location):C:\repo" -w C:\repo
mcr.microsoft.com/windows/servercore:ltsc${{ matrix.winver }}
powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File .\tests\setup.ps1

- name: Upload installer logs
uses: actions/upload-artifact@v2
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: Installer-Logs-Windows-${{ matrix.winver }}-${{ matrix.config }}-${{ matrix.build-type }}
path: logs/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ bin/

# Builds/staging
build/
build-*/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The rest of this README document is about developing the installer itself. If yo
- [Arm GNU Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
- [CMake](https://cmake.org/download/)
- [Ninja](https://github.com/ninja-build/ninja/releases)
- [Python 3.9](https://www.python.org/downloads/windows/)
- [Python 3.12](https://www.python.org/downloads/windows/)
- [Git for Windows](https://git-scm.com/download/win)
- [Visual Studio Code](https://code.visualstudio.com/)
- [OpenOCD](https://github.com/openocd-org/openocd/)
Expand Down
71 changes: 47 additions & 24 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ $tools = (Get-Content '.\config\tools.json' | ConvertFrom-Json).tools
$repositories = (Get-Content '.\config\repositories.json' | ConvertFrom-Json).repositories
$config = Get-Content $ConfigFile | ConvertFrom-Json
$bitness = $config.bitness
$mingw_arch = $config.mingwArch
$env:MSYSTEM = $config.msysEnv
$msysEnv = $config.msysEnv.ToLowerInvariant()
$downloads = $config.downloads
$componentSelection = ($config | Get-Member componentSelection) ? $config.componentSelection : $false

Expand Down Expand Up @@ -139,7 +140,7 @@ if (Test-Path .\build\python\python.exe) {
}

# Clone additional Pico-specific submodules in TinyUSB
exec { git -C .\build\pico-sdk\lib\tinyusb submodule update --init --depth=1 hw\mcu\raspberry_pi }
# exec { git -C .\build\pico-sdk\lib\tinyusb submodule update --init --depth=1 hw\mcu\raspberry_pi }

$sdkVersion = (cmake -P .\packages\pico-setup-windows\pico-sdk-version.cmake -N | Select-String -Pattern 'PICO_SDK_VERSION_STRING=(.*)$').Matches.Groups[1].Value
if (-not ($sdkVersion -match $versionRegEx)) {
Expand Down Expand Up @@ -187,8 +188,8 @@ function msys {

# Preserve the current working directory
$env:CHERE_INVOKING = 'yes'
# Start MINGW32/64 environment
$env:MSYSTEM = "MINGW$bitness"
# Use real symlinks
$env:MSYS = "winsymlinks:nativestrict"

if (-not $SkipDownload) {
# First run setup
Expand All @@ -198,21 +199,27 @@ if (-not $SkipDownload) {
# Normal update
msys 'pacman --noconfirm -Suu'

msys "pacman -S --noconfirm --needed autoconf automake git libtool make pactoys pkg-config wget"
msys "pacman -S --noconfirm --needed autoconf automake base-devel expat git libtool pactoys patchutils pkg-config"

# pacboy adds MINGW_PACKAGE_PREFIX to package names suffixed with :p
msys "pacboy -S --noconfirm --needed cmake:p ninja:p toolchain:p libusb:p hidapi:p"
msys "pacboy -S --noconfirm --needed cmake:p ninja:p toolchain:p libusb:p hidapi:p libslirp:p"
}

if (-not (Test-Path ".\build\picotool-install\$msysEnv")) {
msys "cd build && ../packages/picotool/build-picotool.sh"
}

if (-not (Test-Path ".\build\openocd-install\mingw$bitness")) {
msys "cd build && ../packages/openocd/build-openocd.sh $bitness $mingw_arch"
if (-not (Test-Path ".\build\openocd-install\$msysEnv")) {
msys "cd build && ../packages/openocd/build-openocd.sh"
}

if (-not (Test-Path ".\build\picotool-install\mingw$bitness")) {
msys "cd build && ../packages/picotool/build-picotool.sh $bitness $mingw_arch"
if (-not (Test-Path ".\build\riscv-gnu-toolchain-install\$msysEnv")) {
msys "cd build && ../packages/riscv/build-riscv-gcc.sh"
}
exec { tar -a -cf "build\riscv-gnu-toolchain.zip" -C "build\riscv-gnu-toolchain-install\$msysEnv" '*' }

$template = Get-Content ".\packages\pico-sdk-tools\pico-sdk-tools-config-version.cmake" -Raw
$ExecutionContext.InvokeCommand.ExpandString($template) | Set-Content ".\build\pico-sdk-tools\mingw$bitness\pico-sdk-tools-config-version.cmake"
$ExecutionContext.InvokeCommand.ExpandString($template) | Set-Content ".\build\pico-sdk-tools\$msysEnv\pico-sdk-tools-config-version.cmake"

exec { .\build\pandoc\pandoc.exe --from gfm --to gfm --output .\build\ReadMe.txt .\docs\tutorial.md }

Expand Down Expand Up @@ -391,6 +398,18 @@ $($componentSelection ? '!insertmacro MUI_PAGE_COMPONENTS' : '')

!include "packages\pico-setup-windows\DumpLog.nsh"

!macro ExpandArchive archivePath

SetCompress off
File "`${archivePath}"
`${GetFileName} "`${archivePath}" `$R0
nsExec::ExecToLog ``powershell -NoProfile -ExecutionPolicy Bypass -Command "Expand-Archive '`$R0' -DestinationPath . -Force"``
Pop `$0
Delete /REBOOTOK "`$OUTDIR\`$R0"
SetCompress auto

!macroend

Function .onInit

SetShellVarContext $($BuildType -eq 'system' ? 'all' : 'current')
Expand Down Expand Up @@ -523,9 +542,16 @@ LangString DESC_Sec$($_.shortName) `${LANG_ENGLISH} "$($_.name)"
Section "-OpenOCD" SecOpenOCD

SetOutPath "`$INSTDIR\openocd"
File "build\openocd-install\mingw$bitness\bin\*.*"
File "build\openocd-install\$msysEnv\bin\*.*"
SetOutPath "`$INSTDIR\openocd\scripts"
File /r "build\openocd-install\mingw$bitness\share\openocd\scripts\*.*"
File /r "build\openocd-install\$msysEnv\share\openocd\scripts\*.*"

SectionEnd

Section "-riscv-gnu-toolchain" SecRiscV

SetOutPath "`$INSTDIR\riscv-gnu-toolchain"
!insertmacro ExpandArchive "build\riscv-gnu-toolchain.zip"

SectionEnd

Expand Down Expand Up @@ -555,12 +581,9 @@ Section "-Pico environment" SecPico
File /r "build\pico-sdk\*.*"

SetOutPath "`$INSTDIR\pico-sdk-tools"
File "build\pico-sdk-tools\mingw$bitness\*.*"
File /r "build\pico-sdk-tools\$msysEnv\*.*"
WriteRegStr `${PICO_REG_ROOT} "Software\Kitware\CMake\Packages\pico-sdk-tools" "v$sdkVersion" "`$INSTDIR\pico-sdk-tools"

SetOutPath "`$INSTDIR\picotool"
File "build\picotool-install\mingw$bitness\*.*"

SetOutPath "`$INSTDIR"
File "build\pico-examples.zip"
WriteINIStr "`$INSTDIR\version.ini" "pico-setup-windows" "PICO_SDK_VERSION" "$sdkVersion"
Expand Down Expand Up @@ -648,15 +671,15 @@ exec { .\build\NSIS\makensis /DBUILD_UNINSTALLER ".\$basename-$suffix.nsi" }

# The 'installer' that just writes the uninstaller asks for admin access, which is not actually needed.
$env:__COMPAT_LAYER = "RunAsInvoker"
exec { Start-Process -FilePath ".\build\build-uninstaller-$suffix.exe" -ArgumentList "/S /D=$PSScriptRoot\build" -Wait }
exec { Start-Process -FilePath ".\build\build-uninstaller-$suffix.exe" -ArgumentList "/S /D=$(Join-Path $PSScriptRoot 'build')" -Wait }
$env:__COMPAT_LAYER = ""

# Sign files before packaging up the installer
sign "build\uninstall-$suffix.exe",
"build\openocd-install\mingw$bitness\bin\openocd.exe",
"build\pico-sdk-tools\mingw$bitness\elf2uf2.exe",
"build\pico-sdk-tools\mingw$bitness\pioasm.exe",
"build\picotool-install\mingw$bitness\picotool.exe"
"build\openocd-install\$msysEnv\bin\openocd.exe",
"build\pico-sdk-tools\$msysEnv\elf2uf2\elf2uf2.exe",
"build\pico-sdk-tools\$msysEnv\pioasm\pioasm.exe",
"build\pico-sdk-tools\$msysEnv\picotool\picotool.exe"

exec { .\build\NSIS\makensis ".\$basename-$suffix.nsi" }
Write-Host "Installer saved to $binfile"
Expand All @@ -666,7 +689,7 @@ sign $binfile

# Package OpenOCD separately as well

$version = (cmd /c ".\build\openocd-install\mingw$bitness\bin\openocd.exe" --version '2>&1')[0]
$version = (cmd /c ".\build\openocd-install\$msysEnv\bin\openocd.exe" --version '2>&1')[0]
if (-not ($version -match 'Open On-Chip Debugger (?<version>[a-zA-Z0-9\.\-+]+) \((?<timestamp>[0-9\-:]+)\)')) {
Write-Error 'Could not determine openocd version'
}
Expand All @@ -677,4 +700,4 @@ $filename = 'openocd-{0}-{1}-{2}.zip' -f
$suffix

Write-Host "Saving OpenOCD package to $filename"
exec { tar -a -cf "bin\$filename" -C "build\openocd-install\mingw$bitness\bin" * -C "..\share\openocd" "scripts" }
exec { tar -a -cf "bin\$filename" -C "build\openocd-install\$msysEnv\bin" * -C "..\share\openocd" "scripts" }
16 changes: 10 additions & 6 deletions config/repositories.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@
"repositories": [
{
"href": "https://github.com/raspberrypi/pico-sdk.git",
"tree": "1.5.1",
"tree": "2.1.0",
"submodules": true
},
{
"href": "https://github.com/raspberrypi/pico-examples.git",
"tree": "sdk-1.5.1"
"tree": "sdk-2.1.0"
},
{
"href": "https://github.com/raspberrypi/pico-extras.git",
"tree": "sdk-1.5.1"
"tree": "sdk-2.1.0"
},
{
"href": "https://github.com/raspberrypi/pico-playground.git",
"tree": "sdk-1.5.1"
"tree": "sdk-2.1.0"
},
{
"href": "https://github.com/raspberrypi/picotool.git",
"tree": "1.1.2"
"tree": "2.1.0"
},
{
"href": "https://github.com/raspberrypi/openocd.git",
"tree": "rp2040-v0.12.0"
"tree": "sdk-2.0.0"
},
{
"href": "https://github.com/riscv/riscv-gnu-toolchain.git",
"tree": "master"
}
]
}
10 changes: 5 additions & 5 deletions config/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
"tools": [
{
"name": "NSIS",
"file": "nsis-3.08.zip",
"href": "https://sourceforge.net/projects/nsis/files/NSIS%203/3.08/nsis-3.08.zip/download",
"file": "nsis-3.10.zip",
"href": "https://sourceforge.net/projects/nsis/files/NSIS%203/3.10/nsis-3.10.zip/download",
"dirName": "NSIS",
"extractStrip": 1
},
{
"name": "MSYS2",
"file": "msys2.exe",
"href": "https://github.com/msys2/msys2-installer/releases/download/2023-01-27/msys2-base-x86_64-20230127.sfx.exe"
"href": "https://github.com/msys2/msys2-installer/releases/download/2024-07-27/msys2-base-x86_64-20240727.sfx.exe"
},
{
"name": "pandoc",
"file": "pandoc-3.1-windows-x86_64.zip",
"href": "https://github.com/jgm/pandoc/releases/download/3.1/pandoc-3.1-windows-x86_64.zip",
"file": "pandoc-3.3-windows-x86_64.zip",
"href": "https://github.com/jgm/pandoc/releases/download/3.3/pandoc-3.3-windows-x86_64.zip",
"dirName": "pandoc",
"extractStrip": 1
},
Expand Down
Loading