Commenting for clarity
This commit is contained in:
parent
9eaf30bbf9
commit
b9d529161c
21
compile.ps1
21
compile.ps1
@ -1,7 +1,9 @@
|
|||||||
Param(
|
# Default params, if $Cores must be set to 0 to automatically detect core count.
|
||||||
|
Param(
|
||||||
[Int]$Cores = 0
|
[Int]$Cores = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# If $Cores param is set to 0, detect how many cores this machine has, else use $Cores
|
||||||
if ($Cores-ne 0) {
|
if ($Cores-ne 0) {
|
||||||
Write-Host "Overriding core count with $Cores."
|
Write-Host "Overriding core count with $Cores."
|
||||||
$MaxThreads = $Cores
|
$MaxThreads = $Cores
|
||||||
@ -11,29 +13,38 @@ else {
|
|||||||
Write-Host "Running with $MaxThreads" Cores by default.
|
Write-Host "Running with $MaxThreads" Cores by default.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generate a list of files to process
|
||||||
$files = (ls *.pwn).Name
|
$files = (ls *.pwn).Name
|
||||||
|
|
||||||
|
# Set the working directory to pass in to the background job
|
||||||
$workdir = (pwd)
|
$workdir = (pwd)
|
||||||
|
|
||||||
|
# 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 = {
|
$Block = {
|
||||||
Param([string] $file, [string] $workdir)
|
Param([string] $file, [string] $workdir)
|
||||||
& cd $workdir; .\pawncc.exe $file
|
& cd $workdir; .\pawncc.exe $file
|
||||||
}
|
}
|
||||||
#Remove all jobs
|
|
||||||
|
#Remove all jobs, in case there are old ones from a failed build
|
||||||
Get-Job | Remove-Job
|
Get-Job | Remove-Job
|
||||||
#Start the jobs. Max 4 jobs running simultaneously.
|
|
||||||
|
#Start the jobs. Max jobs running simultaneously defined by $MaxThreads set above.
|
||||||
foreach($file in $files){
|
foreach($file in $files){
|
||||||
While ($(Get-Job -state running).count -ge $MaxThreads){
|
While ($(Get-Job -state running).count -ge $MaxThreads){
|
||||||
Start-Sleep -Milliseconds 3
|
Start-Sleep -Milliseconds 3
|
||||||
}
|
}
|
||||||
Start-Job -Scriptblock $Block -ArgumentList $file, $workdir
|
Start-Job -Scriptblock $Block -ArgumentList $file, $workdir
|
||||||
}
|
}
|
||||||
#Wait for all jobs to finish.
|
|
||||||
|
#Once last job has been started, wait for all jobs to finish.
|
||||||
While ($(Get-Job -State Running).count -gt 0){
|
While ($(Get-Job -State Running).count -gt 0){
|
||||||
start-sleep 1
|
start-sleep 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get information from each job.
|
#Get information from each job.
|
||||||
foreach($job in Get-Job){
|
foreach($job in Get-Job){
|
||||||
$info= Receive-Job -Id ($job.Id)
|
$info= Receive-Job -Id ($job.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#Remove all jobs created.
|
#Remove all jobs created.
|
||||||
Get-Job | Remove-Job
|
Get-Job | Remove-Job
|
Loading…
x
Reference in New Issue
Block a user