|
1 |
| -$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition |
2 | 1 |
|
3 |
| -function Print-Help { |
4 |
| -" |
5 |
| -Usage: |
6 |
| -build.ps1 [--with-tests] |
| 2 | +<# |
| 3 | +.SYNOPSIS |
| 4 | + Builds Ros2ForUnity asset |
| 5 | +.DESCRIPTION |
| 6 | + This script builds Ros2DorUnity asset |
| 7 | +.PARAMETER with_tests |
| 8 | + Build tests |
| 9 | +.PARAMETER standalone |
| 10 | + Add ros2 binaries. Currently standalone flag is fixed to true, so there is no way to build without standalone libs. Parameter kept for future releases |
| 11 | +.PARAMETER clean_install |
| 12 | + Makes a clean installation. Removes install dir before deploying |
| 13 | +#> |
| 14 | +Param ( |
| 15 | + [Parameter(Mandatory=$false)][switch]$with_tests=$false, |
| 16 | + [Parameter(Mandatory=$false)][switch]$standalone=$true, |
| 17 | + [Parameter(Mandatory=$false)][switch]$clean_install=$false |
| 18 | +) |
| 19 | + |
| 20 | +$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition |
7 | 21 |
|
8 |
| -Options: |
9 |
| ---with-tests - build with tests. |
10 |
| -" |
| 22 | +if(-Not (Test-Path -Path "$scriptPath\src\ros2cs")) { |
| 23 | + Write-Host "Pull repositories with 'pull_repositories.ps1' first." -ForegroundColor Red |
| 24 | + exit 1 |
11 | 25 | }
|
12 | 26 |
|
13 |
| -$tests=0 |
14 |
| -$msg="Build started." |
15 |
| -if ($args[0] -eq "--with-tests") { |
16 |
| - $tests=1 |
17 |
| - $msg+=" (with tests)" |
18 |
| -} elseif ($args[0] -eq "--help" -Or $args[0] -eq "-h") { |
19 |
| - Print-Help |
20 |
| - exit |
| 27 | +Write-Host $msg -ForegroundColor Green |
| 28 | +$options = @{ |
| 29 | + with_tests = $with_tests |
| 30 | + standalone = $standalone |
21 | 31 | }
|
22 | 32 |
|
23 |
| -$tests_info=0 |
24 |
| -$plugin_path=Join-Path -Path $scriptPath -ChildPath "\src\Ros2ForUnity\Plugins\" |
| 33 | +if($clean_install) { |
| 34 | + Write-Host "Cleaning install directory..." -ForegroundColor White |
| 35 | + Remove-Item -Path "$scriptPath\install" -Force -Recurse -ErrorAction Ignore |
| 36 | +} |
| 37 | +& "$scriptPath\src\ros2cs\build.ps1" @options |
| 38 | +if($?) { |
| 39 | + md -Force $scriptPath\install\asset | Out-Null |
| 40 | + Copy-Item -Path $scriptPath\src\Ros2ForUnity -Destination $scriptPath\install\asset\ -Recurse -Force |
| 41 | + |
| 42 | + $plugin_path=Join-Path -Path $scriptPath -ChildPath "\install\asset\Ros2ForUnity\Plugins\" |
| 43 | + Write-Host "Deploying build to $plugin_path" -ForegroundColor Green |
| 44 | + & "$scriptPath\deploy_unity_plugins.ps1" $plugin_path |
| 45 | +} else { |
| 46 | + Write-Host "Ros2cs build failed!" -ForegroundColor Red |
| 47 | + exit 1 |
| 48 | +} |
25 | 49 |
|
26 |
| -Write-Host $msg -ForegroundColor Green |
27 |
| -colcon build --merge-install --event-handlers console_direct+ --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$tests |
28 | 50 |
|
29 |
| -Write-Host "Deploying build to $plugin_path" -ForegroundColor Green |
30 |
| -& "$scriptPath\deploy_unity_plugins.ps1" $plugin_path |
|
0 commit comments