From abfb33a8b82a6bbd424228bb666ee5285b4e0ac7 Mon Sep 17 00:00:00 2001 From: admercs Date: Mon, 26 Feb 2024 15:46:25 -0800 Subject: [PATCH] update windows build script --- scripts/mod_rpclib.psm1 | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/scripts/mod_rpclib.psm1 b/scripts/mod_rpclib.psm1 index 30f5fa49..9d583ffd 100644 --- a/scripts/mod_rpclib.psm1 +++ b/scripts/mod_rpclib.psm1 @@ -28,7 +28,7 @@ Import-Module "${PWD}\scripts\mod_utils.psm1" ### [String]$PROJECT_DIR = "$PWD" -#[String]$SCRIPT_DIR = "${PROJECT_DIR}\scripts" +[String]$SCRIPT_DIR = "${PROJECT_DIR}\scripts" [Version]$RPCLIB_VERSION = '2.3.0' [String]$RCPLIB_VERSION_MAJ_MIN_BUILD = Get-VersionMajorMinorBuild -Version "$RPCLIB_VERSION" @@ -43,7 +43,14 @@ Import-Module "${PWD}\scripts\mod_utils.psm1" function Install-RpcLib { [OutputType()] - param() + param( + [Parameter(HelpMessage='')] + [String] + $RpcLibPath = $RPCLIB_PATH, + [Parameter(HelpMessage='')] + [String] + $RpcLibUrl = $RPCLIB_URL + ) if ( $Verbose.IsPresent ) { Write-Output '-----------------------------------------------------------------------------------------' Write-Output ' Installing rpclib...' @@ -51,12 +58,12 @@ function Install-RpcLib { } # Set security protocol used for web requests and download rpclib [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # TLS v1.2 - Invoke-WebRequest "$RPCLIB_URL" -OutFile '.\temp\rpclib.zip' -HttpVersion '2.0' + Invoke-WebRequest "$RpcLibUrl" -OutFile '.\temp\rpclib.zip' -HttpVersion '2.0' # Unpack and remove archive Expand-Archive -Path '.\temp\rpclib.zip' -DestinationPath '.\external\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 "$RpcLibPath") ) { Write-Error 'Error: Unable to download rpclib. Stopping build.' -ErrorAction SilentlyContinue Invoke-Fail -ErrorMessage "Error: Failed to download and unpack RCPLib." } @@ -66,6 +73,9 @@ function Install-RpcLib { function Build-RpcLib { [OutputType()] param( + [Parameter(HelpMessage='')] + [String] + $RpcLibPath = $RPCLIB_PATH, [Parameter(HelpMessage = 'Options: [ "Visual Studio 17 2022" | "Visual Studio 16 2019" ]')] [String] $CmakeGenerator = "$CMAKE_GENERATOR" @@ -75,12 +85,12 @@ function Build-RpcLib { Write-Output ' Building rpclib...' Write-Output '-----------------------------------------------------------------------------------------' } - New-Item -ItemType Directory -Path "${RPCLIB_PATH}\build" -Force | Out-Null - Set-Location "${RPCLIB_PATH}\build" - if ( $Verbose.IsPresent ) { Write-Output "Current directory: ${RPCLIB_PATH}\build" } + New-Item -ItemType Directory -Path "${RpcLibPath}\build" -Force | Out-Null + Set-Location "${RpcLibPath}\build" + if ( $Verbose.IsPresent ) { Write-Output "Current directory: ${RpcLibPath}\build" } # Generate RpcLib build files Write-Output "Using CMake generator: ${CmakeGenerator}" - $ENV:CMAKE_GENERATOR = "$CmakeGenerator" + ${env:CMAKE_GENERATOR} = "$CmakeGenerator" # [System.Environment]::GetEnvironmentVariables() Start-Process -FilePath 'cmake.exe' -ArgumentList "-G `"${CmakeGenerator}"`", '..' -Wait -NoNewWindow # Build RpcLib if ( $BUILD_MODE -eq 'Release' ) { @@ -98,13 +108,13 @@ function Build-RpcLib { [String]$RPCLIB_TARGET_INCLUDE = '.\AutonomyLib\deps\rpclib\include' New-Item -ItemType Directory -Path ("$RPCLIB_TARGET_LIB", "$RPCLIB_TARGET_INCLUDE") -Force | Out-Null # copy directories robustly - Copy-Item -Path "${RPCLIB_PATH}\include" -Destination "${RPCLIB_TARGET_INCLUDE}" -Recurse -Force + Copy-Item -Path "${RpcLibPath}\include" -Destination "${RPCLIB_TARGET_INCLUDE}" -Recurse -Force if ( $BUILD_MODE -eq 'Release' ) { - Copy-Item -Path "${RPCLIB_PATH}\build\Debug" -Destination "${RPCLIB_TARGET_LIB}\Debug" -Recurse -Force - Copy-Item -Path "${RPCLIB_PATH}\build\Release" -Destination "${RPCLIB_TARGET_LIB}\Release" -Recurse -Force + Copy-Item -Path "${RpcLibPath}\build\Debug" -Destination "${RPCLIB_TARGET_LIB}\Debug" -Recurse -Force + Copy-Item -Path "${RpcLibPath}\build\Release" -Destination "${RPCLIB_TARGET_LIB}\Release" -Recurse -Force } else { - Copy-Item -Path "${RPCLIB_PATH}\build\${BUILD_MODE}" -Destination "${RPCLIB_TARGET_LIB}\$BUILD_MODE" -Recurse -Force + Copy-Item -Path "${RpcLibPath}\build\${BUILD_MODE}" -Destination "${RPCLIB_TARGET_LIB}\$BUILD_MODE" -Recurse -Force } return $null } @@ -112,17 +122,20 @@ function Build-RpcLib { function Test-RpcLibVersion { [OutputType()] param( + [Parameter(HelpMessage='')] + [String] + $RpcLibPath = $RPCLIB_PATH, [Parameter(HelpMessage = 'Options: [ "Visual Studio 17 2022" | "Visual Studio 16 2019" ]')] [String] $CmakeGenerator = "$CMAKE_GENERATOR" ) - if ( -not (Test-Path -LiteralPath "$RPCLIB_PATH") ) { + if ( -not (Test-Path -LiteralPath "$RpcLibPath") ) { # Remove previous installations Remove-Item '.\external\rpclib' -Force -Recurse Install-RpcLib Build-RpcLib -CmakeGenerator "$CmakeGenerator" # Fail if rpclib version path not found - if ( -not (Test-Path -LiteralPath "$RPCLIB_PATH") ) { + if ( -not (Test-Path -LiteralPath "$RpcLibPath") ) { Write-Error 'Error: Download and build of rpclib failed. Stopping build.' -ErrorAction SilentlyContinue Invoke-Fail -ErrorMessage "Error: Failed to download and build rpclib." }