Added logging
This commit is contained in:
parent
1c4e395b0f
commit
4af48d5341
10
README.md
10
README.md
@ -31,3 +31,13 @@ To override the number of cores used to compile, set the Cores param when callin
|
||||
```powershell
|
||||
.\compile.ps1 -Cores 2
|
||||
```
|
||||
|
||||
### Enable Logging
|
||||
To have the script log to ```compile.txt``` in the maps directory, set the ```$Logs``` param to ```$True```:
|
||||
```powershell
|
||||
.\compile.ps1 -Logs $True
|
||||
```
|
||||
Or update the default Parameter on line 4 to ```$True```
|
||||
|
||||
### Performance Note
|
||||
When logging is enabled, although the files compile just as fast, the script takes longer to finish as it writes the file. All you need to know is that as soon as the red text starts rushing past, all the files have finished compiling.
|
||||
|
20
compile.ps1
20
compile.ps1
@ -1,8 +1,19 @@
|
||||
# Default params, $Cores must be set to 0 to automatically detect core count.
|
||||
Param(
|
||||
[Int]$Cores = 0
|
||||
[Int]$Cores = 0,
|
||||
[Bool]$Log = $False
|
||||
)
|
||||
|
||||
# Set the working directory to pass in to the background job
|
||||
$workdir = (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
|
||||
|
||||
# Start logging
|
||||
|
||||
if ($Log) {
|
||||
Start-Transcript -Path $workdir\compile.txt
|
||||
}
|
||||
|
||||
|
||||
# If $Cores param is set to 0, detect how many cores this machine has, else use $Cores
|
||||
if ($Cores-ne 0) {
|
||||
Write-Host "Overriding core count with $Cores."
|
||||
@ -16,9 +27,6 @@ else {
|
||||
# Generate a list of files to process
|
||||
$files = (ls *.pwn).Name
|
||||
|
||||
# Set the working directory to pass in to the background job
|
||||
$workdir = (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
|
||||
|
||||
# Define the script block, used by start-job when initiating the background job. This block defines the command that will be run, along with it's parameters.
|
||||
$Block = {
|
||||
Param([string] $file, [string] $workdir)
|
||||
@ -48,3 +56,7 @@ foreach($job in Get-Job){
|
||||
|
||||
# Remove all jobs created.
|
||||
Get-Job | Remove-Job
|
||||
|
||||
if ($Log) {
|
||||
Stop-Transcript
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user