This PR adds support for the CI system for native Windows as well. It allows you to build NuttX on GitHub and test it locally for Windows users. With these CI tools with PowerShell scripts, it is possible to build NuttX for Windows Native using (for now only) Cmake + Ninja with the same logic as the CI system with Bash scripts. This allows the msvc job to be used not only with the simulator (currently only with Visual Studio 17 2022), but also with other architectures using the same Windows runner to get more coverage and avoid future breakage. As with the other jobs, we use artifacts to save the compilation result at the end of the workflow execution (previously for the simulator it was not done). The proposed solution is based on the following additions and modified: Modified Files buildyml -> only CI Jobs MSVC New Files in tools/ ci/cibuild.ps1 -> Added Powershell script for Run the CI Builds ci/platforms/windows.ps1 -> Added Powershell script for installing toolchains and tools. testlist/windows.dat -> Target (Add sim (msvc), risc-v arm) tools/testbuild.ps1 We tested the NuttX build on GitHub and locally. How we build on GitHub and test locally. Locally cd .\nuttx\tools\ci\ .\cibuild.ps1 -n -i -A -C -N .\testlist\windows.dat Signed-off-by: simbit18 <simbit18@gmail.com>
165 lines
4.4 KiB
PowerShell
165 lines
4.4 KiB
PowerShell
#!/usr/bin/env pswd
|
|
############################################################################
|
|
# tools/ci/cibuild.ps1
|
|
# PowerShell script for CI on Windows Native
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
# this work for additional information regarding copyright ownership. The
|
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
# "License"); you may not use this file except in compliance with the
|
|
# License. You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
############################################################################
|
|
|
|
# Set-PSDebug -Trace 0
|
|
|
|
Write-Host "===================================================================================="
|
|
$timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
|
|
Write-Host "Start CI build: $timestamp" -ForegroundColor Yellow
|
|
Write-Host "------------------------------------------------------------------------------------"
|
|
|
|
|
|
$myname = $($MyInvocation.MyCommand.Name)
|
|
|
|
$CID = Get-Location
|
|
$CIWORKSPACE = Resolve-Path("$CID\..\..\..")
|
|
$CIPLAT = "$CIWORKSPACE\nuttx\tools\ci\platforms"
|
|
$nuttx = "$CIWORKSPACE\nuttx"
|
|
$apps = "$CIWORKSPACE\apps"
|
|
|
|
if ($IsWindows -or ($Env:OS -match '^($|(Windows )?Win)')) {
|
|
Write-Host "$ENV:OS"
|
|
}
|
|
else {
|
|
Write-Host "Not Windows"
|
|
}
|
|
|
|
function install_tools {
|
|
$NUTTXTOOLS = "$CIWORKSPACE\tools"
|
|
$env:NUTTXTOOLS = "$NUTTXTOOLS"
|
|
if (-not (Test-Path -Path $NUTTXTOOLS)) {
|
|
New-Item -ItemType Directory -Path $NUTTXTOOLS -Force > $null
|
|
}
|
|
$Pathps1 = "$CIPLAT\windows.ps1"
|
|
# Check if the file exists
|
|
if (Test-Path $Pathps1) {
|
|
try {
|
|
# Run the script
|
|
& $Pathps1
|
|
}
|
|
catch {
|
|
# Handle errors
|
|
Write-Host "An error occurred while executing the script: $_" -ForegroundColor Red
|
|
}
|
|
}
|
|
else {
|
|
Write-Host "The specified script does not exist: $Pathps1" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# Function to display the help
|
|
function usage {
|
|
Write-Host ""
|
|
Write-Host "USAGE: $myname [-h] [-i] [-s] [-c] [-*] <testlist>"
|
|
Write-Host ""
|
|
Write-Host "Where:"
|
|
Write-Host " -i install tools"
|
|
Write-Host " -s setup repos"
|
|
Write-Host " -c enable ccache"
|
|
Write-Host " -* support all options in testbuild.ps1"
|
|
Write-Host " -h will show this help text and terminate"
|
|
Write-Host " <testlist> select testlist file"
|
|
Write-Host ""
|
|
exit 1
|
|
}
|
|
|
|
function enable_ccache {
|
|
# Currently for windows not needed
|
|
Write-Host "enable_ccache: to-do"
|
|
}
|
|
|
|
function setup_repos {
|
|
$oldpath = Get-Location
|
|
|
|
if (Test-Path $nuttx) {
|
|
Set-Location "$nuttx"
|
|
git pull
|
|
|
|
}
|
|
else {
|
|
git clone https://github.com/apache/nuttx.git "$nuttx"
|
|
Set-Location "$nuttx"
|
|
}
|
|
git log -1
|
|
|
|
if (Test-Path $apps) {
|
|
Set-Location "$apps"
|
|
git pull
|
|
}
|
|
else {
|
|
git clone https://github.com/apache/nuttx-apps.git "$apps"
|
|
Set-Location "$apps"
|
|
}
|
|
git log -1
|
|
|
|
Set-Location "$oldpath"
|
|
}
|
|
|
|
function run_builds {
|
|
if ($null -eq $builds) {
|
|
Write-Host "ERROR: Missing test list file" -ForegroundColor Yellow
|
|
usage
|
|
}
|
|
|
|
foreach ( $build in $builds ) {
|
|
& $nuttx\tools\testbuild.ps1 $options $build
|
|
}
|
|
|
|
}
|
|
|
|
$builds = @()
|
|
|
|
if (!$args[0]) {
|
|
usage
|
|
}
|
|
for ( $i = 0; $i -lt $args.count; $i++ ) {
|
|
switch -regex -casesensitive ($($args[$i])) {
|
|
'-h' {
|
|
usage
|
|
}
|
|
'-i' {
|
|
install_tools
|
|
continue
|
|
}
|
|
'-c' {
|
|
enable_ccache
|
|
continue
|
|
}
|
|
'-s' {
|
|
setup_repos
|
|
continue
|
|
}
|
|
{ $_ -like '-*' } {
|
|
$options += "$($args[$i]) "
|
|
continue
|
|
}
|
|
default {
|
|
$builds += $($args[$i])
|
|
}
|
|
}
|
|
}
|
|
|
|
# Main script execution
|
|
run_builds
|