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 19, 2024
1 parent 984eaa6 commit 2757e4a
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 65 deletions.
48 changes: 27 additions & 21 deletions scripts/git_commit_all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ DESCRIPTION:
AUTHOR:
Adam Erickson (Nervosys)
DATE:
11-17-2023
02-19-2024
NOTES:
Assumes: PowerShell version >= 7, Unreal Engine >= 5, CMake >= 3.14, Visual Studio 2022.
Script is intended to run from AutonomySim base project directory.
Copyright © 2024 Nervosys, LLC
#>

# Command-line arguments
###
### Command-line interface (CLI) arguments
###

param(
[Parameter(Mandatory, HelpMessage = 'Root directory of Unreal Engine environment git repositories.')]
[string]
Expand All @@ -24,14 +27,24 @@ param(
$CommitMessage = 'Automatic update from `AutonomySim\scripts\git_commit_all.ps1`'
)

###
### Imports
###

# Common utilities:
# Add-Directories, Remove-Directories, Invoke-Fail, Test-WorkingDirectory, Test-VariableDefined,
# Get-EnvVariables, Get-ProgramVersion, Get-VersionMajorMinor, Get-VersionMajorMinorBuild,
# Get-WindowsInfo, Get-WindowsVersion, Get-Architecture, Get-ArchitectureWidth, Set-ProcessorCount
Import-Module "${PWD}\scripts\utils.psm1"

###
### Variables
###

# Static variables
$PROJECT_DIR = "$PWD"
$SCRIPT_DIR = "$PROJECT_DIR\scripts"
$GIT_REPO_DIRS = [String[]](
$SCRIPT_DIR = "${PROJECT_DIR}\scripts"
$GIT_REPO_DIRS = @(
'1919Presentation',
'Africa',
'AutonomySimEnvNH',
Expand All @@ -54,36 +67,29 @@ $GIT_REPO_DIRS = [String[]](
'ZhangJiaJie'
)

# Command-line arguments
$REPO_ROOT_DIR = $RepoRootDir
$COMMIT_MESSAGE = $CommitMessage

###
### Functions
###

function Invoke-Fail {
param(
[Parameter(Mandatory)]
[ErrorRecord]
$ErrorCode
)
Write-Output "Usage: $SCRIPT_DIR\git_commit_all.ps1 <repo root> <commit message>"
Write-Error "Error occured while updating git repositories: $ErrorCode" -ErrorAction Stop
function Write-Usage {
Write-Output "Usage: ${SCRIPT_DIR}\git_commit_all.ps1 <repo root> <commit message>"
}

function Update-GitRepositories {
Set-Location $REPO_ROOT_DIR
Set-Location "$RepoRootDir"
foreach ($RepoDir in $GIT_REPO_DIRS) {
Write-Output "Updating git repository directory: $RepoDir"
Set-Location $RepoDir
Start-Process -FilePath 'git.exe' -ArgumentList 'add', '-A' -Wait -NoNewWindow
Start-Process -FilePath 'git.exe' -ArgumentList 'commit', "-m $COMMIT_MESSAGE" -Wait -NoNewWindow
Start-Process -FilePath 'git.exe' -ArgumentList 'commit', "-m $CommitMessage" -Wait -NoNewWindow
Start-Process -FilePath 'git.exe' -ArgumentList 'push' -Wait -NoNewWindow
if (!$?) { Invoke-Fail -ErrorCode $LASTEXITCODE } # exit on error
Set-Location $REPO_ROOT_DIR
# Exit on error
if (!$?) {
Invoke-Fail -ErrorCode $LASTEXITCODE -ErrorMessage "Usage: ${SCRIPT_DIR}\git_commit_all.ps1 <repo root> <commit message>"
}
Set-Location "$RepoRootDir"
}
Set-Location $PROJECT_DIR
Set-Location "$PROJECT_DIR"
}

###
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_cmake.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Install-Cmake {
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
Invoke-Fail -ErrorMessage "Error: Failed to install CMake."
}
}

Expand Down
12 changes: 6 additions & 6 deletions scripts/test_eigen.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ Import-Module "${PWD}\scripts\utils.psm1"
###

function Test-EigenVersion {
if ( -not (Test-Path -LiteralPath $EIGEN_DIR) ) {
if ( -not (Test-Path -LiteralPath "$EIGEN_DIR") ) {
[System.IO.Directory]::CreateDirectory('AutonomyLib\deps')

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest $EIGEN_URL -OutFile 'temp\eigen3.zip'
Invoke-WebRequest "$EIGEN_URL" -OutFile 'temp\eigen3.zip'

Expand-Archive -Path 'temp\eigen3.zip' -DestinationPath 'AutonomyLib\deps'
Move-Item -Path AutonomyLib\deps\eigen* -Destination 'AutonomyLib\deps\del_eigen'

[System.IO.Directory]::CreateDirectory($EIGEN_DIR)
[System.IO.Directory]::CreateDirectory("$EIGEN_DIR")
Move-Item -Path 'AutonomyLib\deps\del_eigen\Eigen' -Destination "$EIGEN_DIR\Eigen"
Remove-Item 'AutonomyLib\deps\del_eigen' -Force -Recurse
Remove-Item 'temp\eigen3.zip' -Force
}
if ( -not (Test-Path -LiteralPath $EIGEN_DIR) ) {
Write-Error "Eigen library directory not found: $EIGEN_DIR" -ErrorAction SilentlyContinue
Invoke-Fail
if ( -not (Test-Path -LiteralPath "$EIGEN_DIR") ) {
Write-Error "Eigen library directory not found: ${EIGEN_DIR}" -ErrorAction SilentlyContinue
Invoke-Fail -ErrorMessage "Error: Failed to download and unpack Eigen."
}
}

Expand Down
27 changes: 14 additions & 13 deletions scripts/test_rpclib.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Import-Module "${PWD}\scripts\utils.psm1"
### Variables
###

[String]$RPCLIB_VERSION = '2.3.0'
[String]$RPCLIB_PATH = "external\rpclib\rpclib-${RPCLIB_VERSION}"
[String]$RPCLIB_URL = "https://github.com/rpclib/rpclib/archive/v${RPCLIB_VERSION}.zip"
[Version]$RPCLIB_VERSION = '2.3.0'
[String]$RCPLIB_VERSION_MAJ_MIN_BUILD = Get-VersionMajorMinorBuild -Version "$RPCLIB_VERSION"
[String]$RPCLIB_PATH = "external\rpclib\rpclib-${RCPLIB_VERSION_MAJ_MIN_BUILD}"
[String]$RPCLIB_URL = "https://github.com/rpclib/rpclib/archive/v${RCPLIB_VERSION_MAJ_MIN_BUILD}.zip"
[String]$VS_GENERATOR = 'Visual Studio 17 2022'

###
Expand All @@ -52,9 +53,9 @@ function Get-RpcLib {
Remove-Item 'temp\rpclib.zip'

# Fail build if unable to download and/or unpack rpclib
if ( -not (Test-Path -LiteralPath $RPCLIB_PATH) ) {
if ( -not (Test-Path -LiteralPath "$RPCLIB_PATH") ) {
Write-Error 'Error: Unable to download rpclib. Stopping build.' -ErrorAction SilentlyContinue
Invoke-Fail
Invoke-Fail -ErrorMessage "Error: Failed to download and unpack RCPLib."
}
}

Expand All @@ -65,9 +66,9 @@ function Build-RpcLib {
Write-Output '-----------------------------------------------------------------------------------------'
Write-Output ''

[System.IO.Directory]::CreateDirectory("$RPCLIB_PATH\build")
Set-Location "$RPCLIB_PATH\build"
Write-Output "Current directory: $RPCLIB_PATH\build"
[System.IO.Directory]::CreateDirectory("${RPCLIB_PATH}\build")
Set-Location "${RPCLIB_PATH}\build"
Write-Output "Current directory: ${RPCLIB_PATH}\build"

Start-Process -FilePath 'cmake.exe' -ArgumentList "-G $VS_GENERATOR", '..' -Wait -NoNewWindow
if ( $BUILD_MODE -eq 'Release' ) {
Expand All @@ -79,8 +80,8 @@ function Build-RpcLib {
}
if (!$?) { exit $LASTEXITCODE } # exit on error

Set-Location $PROJECT_DIR
Write-Output "Current directory: $PROJECT_DIR"
Set-Location "$PROJECT_DIR"
Write-Output "Current directory: ${PROJECT_DIR}"

# Copy rpclib binaries and include folder inside AutonomyLib folder
$RPCLIB_TARGET_LIB = 'AutonomyLib\deps\rpclib\lib\x64'
Expand All @@ -100,16 +101,16 @@ function Build-RpcLib {
}

function Test-RpcLibVersion {
if ( -not (Test-Path -LiteralPath $RPCLIB_PATH) ) {
if ( -not (Test-Path -LiteralPath "$RPCLIB_PATH") ) {
# Remove previous installations
Remove-Item 'external\rpclib' -Force -Recurse
# Download and build rpclib
Get-RpcLib
Build-RpcLib
# Fail if rpclib version path not found
if ( -not (Test-Path -LiteralPath $RPCLIB_PATH) ) {
if ( -not (Test-Path -LiteralPath "$RPCLIB_PATH") ) {
Write-Error 'Error: Download and build of rpclib failed. Stopping build.' -ErrorAction SilentlyContinue
Invoke-Fail
Invoke-Fail -ErrorMessage "Error: Failed to download and build RCPLib."
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_unrealasset.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function Test-AssetSuvVersion {
# If high-polycount SUV is unable to download, notify users that gokart will be used
if ( -not (Test-Path -LiteralPath "${ADVANCED_VEHICLE_DIR}\SUV") ) {
Write-Output 'Download of high-polycount SUV failed. AutonomySim will use the default vehicle.'
Invoke-Fail
Invoke-Fail -ErrorMessage "Error: Failed to download and unpack high-polygon-count SUV asset."
}
}
else {
Expand Down
7 changes: 3 additions & 4 deletions scripts/test_visualstudio.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function Set-VsInstance {
$selected = Read-Host "Enter the '#' of the Visual Studio installation to use. Press <Enter> to quit: "
if (-not $selected) {
Write-Output "No Visual Studio installation selected. Exiting program."
Invoke-Fail
Invoke-Fail -ErrorMessage "Error: Failed to select Visual Studio installation."
}
$config = $configs | Where-Object { $_."#" -eq $selected }
return $config
Expand All @@ -85,8 +85,7 @@ function Test-VisualStudioVersion {
$VsInstance = Set-VsInstance
$CurrentVersion = Get-VsInstanceVersion($VsInstance)
if ( $null -eq $CurrentVersion ) {
Write-Error 'Error: Failed to locate a Visual Studio instance.'
Invoke-Fail
Invoke-Fail -ErrorMessage "Error: Failed to locate a Visual Studio instance."
}
if ($CurrentVersion -lt $MinimumVersion) {
# install CMake if it is less than the required version
Expand All @@ -95,7 +94,7 @@ function Test-VisualStudioVersion {
Write-Output 'AutonomySim supports up to Unreal Engine 5.3 and Visual Studio 2022.'
Write-Output 'Here are few easy steps to perform the upgrade:'
Write-Output ' https://github.com/nervosys/AutonomySim/blob/master/docs/unreal_upgrade.md'
Invoke-Fail
Invoke-Fail -ErrorMessage "Error: Visual Studio version does not meet minimum requirement."
}
else {
Write-Output "Success: Visual Studio version ${CurrentVersion} meets the minimum requirements."
Expand Down
46 changes: 27 additions & 19 deletions scripts/utils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ NOTES:
### Functions
###

function Test-VariableDefined {
param(
[Parameter(Mandatory)]
[String]
$Variable
)
return [Boolean](Get-Variable $Variable -ErrorAction SilentlyContinue)
}

function Test-WorkingDirectory {
$WorkingDirectory = Split-Path "$PWD" -Leaf
if ($WorkingDirectory -ne 'AutonomySim') {
Write-Output "Present working directory: ${PWD}"
Write-Error "Error: Script must be run from 'AutonomySim' project directory." -ErrorAction Stop
}
}

function Add-Directories {
param(
[Parameter()]
Expand Down Expand Up @@ -46,28 +63,19 @@ function Invoke-Fail {
$ProjectDir = "$PWD",
[Parameter()]
[Switch]
$RemoveDirs = $false
$RemoveDirs = $false,
[Parameter()]
[ErrorRecord]
$ErrorCode,
[Parameter()]
[String]
$ErrorMessage
)
Set-Location $ProjectDir
if ($RemoveDirs -eq $true) { Remove-Directories }
Write-Error 'Error: Build failed. Exiting Program.' -ErrorAction Stop
}

function Test-WorkingDirectory {
$WorkingDirectory = Split-Path "$PWD" -Leaf
if ($WorkingDirectory -ne 'AutonomySim') {
Write-Output "Present working directory: ${PWD}"
Write-Error "Error: Script must be run from 'AutonomySim' project directory." -ErrorAction Stop
}
}

function Test-VariableDefined {
param(
[Parameter(Mandatory)]
[String]
$Variable
)
return [Boolean](Get-Variable $Variable -ErrorAction SilentlyContinue)
if (Test-VariableDefined -Variable $ErrorCode -eq $true) { Write-Error "Error code: ${ErrorCode}" -ErrorAction Continue }
if (Test-VariableDefined -Variable $ErrorMessage -eq $true) { Write-Error "$ErrorMessage" -ErrorAction Continue }
Write-Error 'Build failed. Exiting Program.' -ErrorAction Stop
}

function Get-EnvVariables {
Expand Down

0 comments on commit 2757e4a

Please sign in to comment.