Skip to content

Commit

Permalink
update windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
admercs committed Feb 20, 2024
1 parent 364ffb1 commit ed948a8
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:
- name: "Build AutonomySim"
shell: pwsh
run: |
Set-PSDebug -Trace 1
# Set-PSDebug -Trace 1
./scripts/build.ps1 -BuildMode "Release" -Deploy
146 changes: 73 additions & 73 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ NOTES:
###

param(
[Parameter(HelpMessage = 'Options: [ Debug | Release | RelWithDebInfo ]')]
[String]
$BuildMode = 'Release',
[Parameter(HelpMessage = 'Enable to build and serve AutonomySim documentation.')]
[Switch]
$BuildDocs = $false,
[Parameter(HelpMessage = 'Enable for an Unreal Engine full-polycount SUV asset.')]
[Switch]
$FullPolySuv = $false,
[Parameter(HelpMessage = 'Enable for computer system debugging messages.')]
[Switch]
$SystemDebug = $false,
[Parameter(HelpMessage = 'Enable for CI/CD mode (e.g., GitHub Actions).')]
[Switch]
$Deploy = $false
[Parameter(HelpMessage = 'Options: [ Debug | Release | RelWithDebInfo ]')]
[String]
$BuildMode = 'Release',
[Parameter(HelpMessage = 'Enable to build and serve AutonomySim documentation.')]
[Switch]
$BuildDocs = $false,
[Parameter(HelpMessage = 'Enable for an Unreal Engine full-polycount SUV asset.')]
[Switch]
$FullPolySuv = $false,
[Parameter(HelpMessage = 'Enable for computer system debugging messages.')]
[Switch]
$SystemDebug = $false,
[Parameter(HelpMessage = 'Enable for CI/CD mode (e.g., GitHub Actions).')]
[Switch]
$Deploy = $false
)

###
Expand Down Expand Up @@ -94,73 +94,73 @@ $CMAKE_VERSION = Get-ProgramVersion -Program 'cmake'
###

function Build-Solution {
[OutputType()]
param(
[Parameter(Mandatory)]
[String]
$BuildMode,
[Parameter(Mandatory)]
[String]
$SystemPlatform,
[Parameter(Mandatory)]
[UInt8]
$SystemCpuMax
)
if ( $BuildMode -eq 'Release' ) {
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:$SystemCpuMax", "/p:Platform=$SystemPlatform", "/p:Configuration=Debug", 'AutonomySim.sln' -Wait -NoNewWindow
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:$SystemCpuMax", "/p:Platform=$SystemPlatform", "/p:Configuration=Release", 'AutonomySim.sln' -Wait -NoNewWindow
}
else {
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:$SystemCpuMax", "/p:Platform=$SystemPlatform", "/p:Configuration=$BuildMode", 'AutonomySim.sln' -Wait -NoNewWindow
}
if (!$?) { exit $LASTEXITCODE } # exit on error
[OutputType()]
param(
[Parameter(Mandatory)]
[String]
$BuildMode,
[Parameter(Mandatory)]
[String]
$SystemPlatform,
[Parameter(Mandatory)]
[UInt8]
$SystemCpuMax
)
if ( $BuildMode -eq 'Release' ) {
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:$SystemCpuMax", "/p:Platform=$SystemPlatform", "/p:Configuration=Debug", 'AutonomySim.sln' -Wait -NoNewWindow
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:$SystemCpuMax", "/p:Platform=$SystemPlatform", "/p:Configuration=Release", 'AutonomySim.sln' -Wait -NoNewWindow
}
else {
Start-Process -FilePath 'msbuild.exe' -ArgumentList "-maxcpucount:$SystemCpuMax", "/p:Platform=$SystemPlatform", "/p:Configuration=$BuildMode", 'AutonomySim.sln' -Wait -NoNewWindow
}
if (!$?) { exit $LASTEXITCODE } # exit on error
}

function Copy-GeneratedBinaries {
# Copy binaries and includes for MavLinkCom in deps
$MAVLINK_TARGET_LIB = 'AutonomyLib\deps\MavLinkCom\lib'
$MAVLINK_TARGET_INCLUDE = 'AutonomyLib\deps\MavLinkCom\include'
[System.IO.Directory]::CreateDirectory($MAVLINK_TARGET_LIB)
[System.IO.Directory]::CreateDirectory($MAVLINK_TARGET_INCLUDE)
Copy-Item -Path 'MavLinkCom\include' -Destination $MAVLINK_TARGET_INCLUDE
Copy-Item -Path 'MavLinkCom\lib' -Destination $MAVLINK_TARGET_LIB

# Copy outputs into Unreal/Plugins directory
$AUTONOMYLIB_PLUGIN_DIR = 'Unreal\Plugins\AutonomySim\Source\AutonomyLib'
[System.IO.Directory]::CreateDirectory($AUTONOMYLIB_PLUGIN_DIR)
Copy-Item -Path 'AutonomyLib' -Destination $AUTONOMYLIB_PLUGIN_DIR
Copy-Item -Path 'AutonomySim.props' -Destination $AUTONOMYLIB_PLUGIN_DIR
# Copy binaries and includes for MavLinkCom in deps
$MAVLINK_TARGET_LIB = 'AutonomyLib\deps\MavLinkCom\lib'
$MAVLINK_TARGET_INCLUDE = 'AutonomyLib\deps\MavLinkCom\include'
[System.IO.Directory]::CreateDirectory($MAVLINK_TARGET_LIB)
[System.IO.Directory]::CreateDirectory($MAVLINK_TARGET_INCLUDE)
Copy-Item -Path 'MavLinkCom\include' -Destination $MAVLINK_TARGET_INCLUDE
Copy-Item -Path 'MavLinkCom\lib' -Destination $MAVLINK_TARGET_LIB

# Copy outputs into Unreal/Plugins directory
$AUTONOMYLIB_PLUGIN_DIR = 'Unreal\Plugins\AutonomySim\Source\AutonomyLib'
[System.IO.Directory]::CreateDirectory($AUTONOMYLIB_PLUGIN_DIR)
Copy-Item -Path 'AutonomyLib' -Destination $AUTONOMYLIB_PLUGIN_DIR
Copy-Item -Path 'AutonomySim.props' -Destination $AUTONOMYLIB_PLUGIN_DIR
}

function Get-VsUnrealProjectFiles {
param(
[Parameter(Mandatory)]
[String]
$UnrealEnvDir,
[Parameter()]
[String]
$ProjectDir = "$PWD"
)
Set-Location $UnrealEnvDir
Import-Module "$UnrealEnvDir\scripts\update_unreal_env.psm1" # imports: Test-DirectoryPath, Copy-UnrealEnvItems, Remove-UnrealEnvItems, Invoke-VsUnrealProjectFileGenerator
#Test-DirectoryPath -Path $ProjectDir
Copy-UnrealEnvItems -Path $ProjectDir
Remove-UnrealEnvItems
Invoke-VsUnrealProjectFileGenerator
Remove-Module "$UnrealEnvDir\scripts\update_unreal_env.psm1"
Set-Location $ProjectDir
param(
[Parameter(Mandatory)]
[String]
$UnrealEnvDir,
[Parameter()]
[String]
$ProjectDir = "$PWD"
)
Set-Location $UnrealEnvDir
Import-Module "$UnrealEnvDir\scripts\update_unreal_env.psm1" # imports: Test-DirectoryPath, Copy-UnrealEnvItems, Remove-UnrealEnvItems, Invoke-VsUnrealProjectFileGenerator
#Test-DirectoryPath -Path $ProjectDir
Copy-UnrealEnvItems -Path $ProjectDir
Remove-UnrealEnvItems
Invoke-VsUnrealProjectFileGenerator
Remove-Module "$UnrealEnvDir\scripts\update_unreal_env.psm1"
Set-Location $ProjectDir
}

function Update-VsUnrealProjectFiles {
param(
[Parameter()]
[String]
$ProjectDir = "$PWD"
)
$UnrealEnvDirs = (Get-ChildItem -Path 'Unreal\Environments' -Directory | Select-Object FullName).FullName # remove attribute decorator
foreach ($UnrealEnvDir in $UnrealEnvDirs) {
Get-VsUnrealProjectFiles -UnrealEnvDir $UnrealEnvDir -ProjectDir $ProjectDir
}
param(
[Parameter()]
[String]
$ProjectDir = "$PWD"
)
$UnrealEnvDirs = (Get-ChildItem -Path 'Unreal\Environments' -Directory | Select-Object FullName).FullName # remove attribute decorator
foreach ($UnrealEnvDir in $UnrealEnvDirs) {
Get-VsUnrealProjectFiles -UnrealEnvDir $UnrealEnvDir -ProjectDir $ProjectDir
}
}

###
Expand Down
74 changes: 38 additions & 36 deletions scripts/test_cmake.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -35,45 +35,47 @@ Import-Module "${PWD}\scripts\utils.psm1"
###

function Install-Cmake {
param(
[Parameter()]
[Version]
$Version = $CMAKE_VERSION_LATEST
)
Write-Host -NoNewLine "Download and install CMake v${Version}? [y|N]"
$Response = [System.Console]::ReadKey().Key.ToString() # uses automatic capitalization
if ( $Response -eq 'Y' ) {
$VersionMajMin = Get-VersionMajorMinor $Version
$VersionMajMinBuild = Get-VersionMajorMinorBuild $Version
$Installer = "cmake-${VersionMajMinBuild}-x86_64.msi"
Invoke-WebRequest "https://cmake.org/files/v${VersionMajMin}/${Installer}" -OutFile "temp\${Installer}"
Start-Process -FilePath "temp\${Installer}" -Wait
Remove-Item -Path "temp\${Installer}"
} else {
Write-Error "Error: CMake version ${CMAKE_VERSION_MINIMUM} or greater is required, but was neither found nor installed." -ErrorAction Continue
Invoke-Fail -ErrorMessage "Error: Failed to install CMake."
}
param(
[Parameter()]
[Version]
$Version = $CMAKE_VERSION_LATEST
)
Write-Host -NoNewLine "Download and install CMake v${Version}? [y|N]"
$Response = [System.Console]::ReadKey().Key.ToString() # uses automatic capitalization
if ( $Response -eq 'Y' ) {
$VersionMajMin = Get-VersionMajorMinor $Version
$VersionMajMinBuild = Get-VersionMajorMinorBuild $Version
$Installer = "cmake-${VersionMajMinBuild}-x86_64.msi"
Invoke-WebRequest "https://cmake.org/files/v${VersionMajMin}/${Installer}" -OutFile "temp\${Installer}"
Start-Process -FilePath "temp\${Installer}" -Wait
Remove-Item -Path "temp\${Installer}"
}
else {
Write-Error "Error: CMake version ${CMAKE_VERSION_MINIMUM} or greater is required, but was neither found nor installed." -ErrorAction Continue
Invoke-Fail -ErrorMessage "Error: Failed to install CMake."
}
}

function Test-CmakeVersion {
[OutputType([Boolean])]
param(
[Parameter()]
[Version]
$MinimumVersion = $CMAKE_VERSION_MINIMUM,
[Parameter()]
[String]
$Program = 'cmake'
)
$CurrentVersion = Get-ProgramVersion -Program $Program
if ( $null -eq $CurrentVersion ) { Install-Cmake } # install CMake if it is missing
if ($CurrentVersion -lt $MinimumVersion) {
# install CMake if it is less than the required version
Write-Error "Error: $($Program) version $($CurrentVersion) is less than the minimum supported." -ErrorAction SilentlyContinue
Install-Cmake
} else {
Write-Output "Success: CMake version ${CurrentVersion} meets the minimum requirements."
}
[OutputType([Boolean])]
param(
[Parameter()]
[Version]
$MinimumVersion = $CMAKE_VERSION_MINIMUM,
[Parameter()]
[String]
$Program = 'cmake'
)
$CurrentVersion = Get-ProgramVersion -Program $Program
if ( $null -eq $CurrentVersion ) { Install-Cmake } # install CMake if it is missing
if ($CurrentVersion -lt $MinimumVersion) {
# install CMake if it is less than the required version
Write-Error "Error: $($Program) version $($CurrentVersion) is less than the minimum supported." -ErrorAction SilentlyContinue
Install-Cmake
}
else {
Write-Output "Success: CMake version ${CurrentVersion} meets the minimum requirements."
}
}

###
Expand Down
11 changes: 6 additions & 5 deletions scripts/test_visualstudio.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ function Set-VsInstance {
$DisplayProperties = @("#") + $DisplayProperties
# Add an ID number for each installation
$Configs = $Configs |
Sort-Object displayName, installationDate |
ForEach-Object { $i = 0; $i++; $_ | Add-Member -NotePropertyName "#" -NotePropertyValue $i -PassThru }
Sort-Object displayName, installationDate |
ForEach-Object { $i = 0; $i++; $_ | Add-Member -NotePropertyName "#" -NotePropertyValue $i -PassThru }
Write-Output "The following Visual Studio installations were found:"
$Configs | Format-Table -Property $DisplayProperties | Out-String | ForEach-Object { Write-Output $_ }
if ($Automate -eq $true) {
$Selected = 1
} else {
$Selected = "1"
}
elseif ($Automate -eq $false) {
$Selected = Read-Host "Enter the '#' of the Visual Studio installation to use. Press <Enter> to quit: "
}
if (-not $Selected) {
else {
Write-Output "No Visual Studio installation selected. Exiting program."
Invoke-Fail -ErrorMessage "Error: Failed to select Visual Studio installation."
}
Expand Down

0 comments on commit ed948a8

Please sign in to comment.