Skip to content

Commit ecc3cfe

Browse files
committed
Make paths script-relative for better consistency
1 parent 09a8773 commit ecc3cfe

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

scripts/packaging/pack-utils.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Shared utilities for plugin packaging scripts
22

3+
function Get-PluginSpecPath {
4+
return "$PSScriptRoot/../../plugin-dev/Sentry.uplugin"
5+
}
6+
37
function Get-PluginVersion {
4-
$pluginSpecPath = "$PSScriptRoot/../../plugin-dev/Sentry.uplugin"
8+
$pluginSpecPath = Get-PluginSpecPath
59

610
if (-not(Test-Path -Path $pluginSpecPath)) {
711
throw "Plugin spec file not found at: $pluginSpecPath"

scripts/packaging/pack.ps1

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
. $PSScriptRoot/pack-utils.ps1
44

5+
$projectRoot = "$PSScriptRoot/../.."
6+
57
function packFiles()
68
{
7-
Remove-Item "package-release" -Force -Recurse -ErrorAction SilentlyContinue
8-
New-Item "package-release" -ItemType Directory
9+
Remove-Item "$projectRoot/package-release" -Force -Recurse -ErrorAction SilentlyContinue
10+
New-Item "$projectRoot/package-release" -ItemType Directory
911

1012
$exclude = @(
1113
'Sentry.uplugin',
@@ -15,16 +17,16 @@ function packFiles()
1517
'Intermediate'
1618
)
1719

18-
Copy-Item "plugin-dev/*" "package-release/" -Exclude $exclude -Recurse
19-
Copy-Item "CHANGELOG.md" -Destination "package-release/CHANGELOG.md"
20-
Copy-Item "LICENSE" -Destination "package-release/LICENSE"
20+
Copy-Item "$projectRoot/plugin-dev/*" "$projectRoot/package-release/" -Exclude $exclude -Recurse
21+
Copy-Item "$projectRoot/CHANGELOG.md" -Destination "$projectRoot/package-release/CHANGELOG.md"
22+
Copy-Item "$projectRoot/LICENSE" -Destination "$projectRoot/package-release/LICENSE"
2123

2224
# We know the file is meant to be UTF8, so let's be explicit
23-
$sentrySubsystemHeader = Get-Content "plugin-dev/Source/Sentry/Public/SentrySubsystem.h" -Encoding UTF8
25+
$sentrySubsystemHeader = Get-Content "$projectRoot/plugin-dev/Source/Sentry/Public/SentrySubsystem.h" -Encoding UTF8
2426

25-
$pluginSpec = Get-Content "plugin-dev/Sentry.uplugin"
27+
$pluginSpec = Get-Content (Get-PluginSpecPath)
2628
$pluginVersion = Get-PluginVersion
27-
$engineVersions = Get-Content $PSScriptRoot/engine-versions.txt
29+
$engineVersions = Get-Content "$PSScriptRoot/engine-versions.txt"
2830
foreach ($engineVersion in $engineVersions)
2931
{
3032
$packageName = "sentry-unreal-$pluginVersion-engine$engineVersion.zip"
@@ -42,16 +44,11 @@ function packFiles()
4244
$newPluginSpec = $newPluginSpec -replace '"LinuxArm64"', '"LinuxAArch64"'
4345
}
4446

45-
$newPluginSpec | Out-File "package-release/Sentry.uplugin"
47+
$newPluginSpec | Out-File "$projectRoot/package-release/Sentry.uplugin"
4648

4749
# Replacing raw pointers in UPROPERTY fields with TObjectPtr for UE 5.0+
4850
# See https://github.com/getsentry/sentry-unreal/issues/1082
4951

50-
# Workaround for PowerShell 5.1 writing UTF8-BOM
51-
# ======
52-
# Set current directory so that ::WriteAllLines can accept a relative path
53-
[System.Environment]::CurrentDirectory = (Get-Location).Path
54-
5552
$newSentrySubsystemHeader = $sentrySubsystemHeader
5653

5754
if ($engineVersion -ne "4.27")
@@ -64,17 +61,17 @@ function packFiles()
6461
}
6562

6663
# PowerShell 5.1 will write UT8-BOM if we use Out-File, so bypass this issue and use ::WriteAllLines
67-
[System.IO.File]::WriteAllLines("package-release/Source/Sentry/Public/SentrySubsystem.h", $newSentrySubsystemHeader)
64+
[System.IO.File]::WriteAllLines("$projectRoot/package-release/Source/Sentry/Public/SentrySubsystem.h", $newSentrySubsystemHeader)
6865

69-
Remove-Item -ErrorAction SilentlyContinue $packageName
66+
Remove-Item -ErrorAction SilentlyContinue "$projectRoot/$packageName"
7067

7168
# Workaround for Compress-Archive discarding file permissions
7269
# ======
7370
# Use of [System.IO.Compression.ZipFile]::CreateFromDirectory instead of Compress-Archive (or a third-party tool)
7471
# so that we retain file permissions
7572
# For more information, see https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/36
7673
# NOTE: This requires .NET 6+: https://github.com/dotnet/runtime/issues/1548
77-
Push-Location package-release
74+
Push-Location "$projectRoot/package-release"
7875
try
7976
{
8077
$location = Get-Location
@@ -83,7 +80,7 @@ function packFiles()
8380
{
8481
Add-Type -AssemblyName "System.IO.Compression.FileSystem"
8582
}
86-
[System.IO.Compression.ZipFile]::CreateFromDirectory($location, "$location/../$packageName")
83+
[System.IO.Compression.ZipFile]::CreateFromDirectory($location, "$projectRoot/$packageName")
8784
}
8885
finally
8986
{

0 commit comments

Comments
 (0)