|
1 | 1 | function Compile-SourceScript { |
2 | 2 | <# |
3 | 3 | .SYNOPSIS |
4 | | - A wrapper for compiling SourceMod (.sp) and AMX Mod X (.sma) plugin source files for Source / GoldSource games. |
| 4 | + A wrapper for compiling SourceMod (.sp) and AMX Mod X (.sma) plugin source files for Source / Goldsource games. |
5 | 5 |
|
6 | 6 | .DESCRIPTION |
7 | 7 | Specified plugins are compiled and subsequently copied into the mod's plugins directory if found to be new or have been changed. |
@@ -55,6 +55,9 @@ function Compile-SourceScript { |
55 | 55 | if (!$MOD_NAME) { |
56 | 56 | throw "File is not a '.sp' or '.sma' source file." |
57 | 57 | } |
| 58 | + if (!($sourceFile.DirectoryName | Split-Path)) { |
| 59 | + throw "The directory 'addons/$MOD_NAME/' cannot exist relative to the specified plugin source file '$($sourceFile.FullName)'." |
| 60 | + } |
58 | 61 |
|
59 | 62 | # Initialize variables |
60 | 63 | $MOD = @{ |
@@ -100,10 +103,14 @@ function Compile-SourceScript { |
100 | 103 | } |
101 | 104 | $SCRIPTING_DIR = $sourceFile.DirectoryName |
102 | 105 | $COMPILED_DIR = Join-Path $SCRIPTING_DIR $MOD[$MOD_NAME]['compiled_dir_name'] |
| 106 | + $COMPILER_PATH = Join-Path $SCRIPTING_DIR $COMPILER_NAME |
103 | 107 | $PLUGINS_DIR = Join-Path (Split-Path $SCRIPTING_DIR -Parent) $MOD[$MOD_NAME]['plugins_dir_name'] |
104 | 108 |
|
105 | 109 | # Verify the presence of the compiler item |
106 | | - $compiler = Get-Item -Path (Join-Path $SCRIPTING_DIR $COMPILER_NAME) |
| 110 | + $compiler = Get-Item -Path $COMPILER_PATH -ErrorAction SilentlyContinue |
| 111 | + if (!$compiler) { |
| 112 | + throw "Cannot find the plugin compiler at the path '$COMPILER_PATH'." |
| 113 | + } |
107 | 114 |
|
108 | 115 | }catch { |
109 | 116 | Write-Error -Exception $_.Exception -Message $_.Exception.Message -Category $_.CategoryInfo.Category -TargetObject $_.TargetObject |
@@ -165,7 +172,7 @@ function Compile-SourceScript { |
165 | 172 | "`nNo changes to plugins were found. No operations were performed." | Write-Host -ForegroundColor Magenta |
166 | 173 | return |
167 | 174 |
|
168 | | - }else { |
| 175 | + }else { |
169 | 176 | # List successfully compiled plugins |
170 | 177 | "`nNewly compiled plugins:" | Write-Host -ForegroundColor Cyan |
171 | 178 | $compiledDirItemsDiff | % { |
|
0 commit comments