Updating readme, adding compile.ps1
This commit is contained in:
parent
6595e2ec27
commit
9eaf30bbf9
17
README.md
17
README.md
@ -1,3 +1,18 @@
|
||||
# pwn-compile
|
||||
|
||||
Compile.ps1 repositor
|
||||
Compile.ps1 repository.
|
||||
|
||||
## Usage
|
||||
|
||||
### All-Cores mode
|
||||
To run this script with all available cores, copy it to your maps directory, open a powershell terminal, cd to this directory and run:
|
||||
|
||||
```powershell
|
||||
.\compile.ps1
|
||||
```
|
||||
|
||||
### X Cores mode
|
||||
To override the number of cores used to compile, set the Cores param when calling the script:
|
||||
```powershell
|
||||
.\compile.ps1 -Cores 2
|
||||
```
|
||||
|
39
compile.ps1
Normal file
39
compile.ps1
Normal file
@ -0,0 +1,39 @@
|
||||
Param(
|
||||
[Int]$Cores = 0
|
||||
)
|
||||
|
||||
if ($Cores-ne 0) {
|
||||
Write-Host "Overriding core count with $Cores."
|
||||
$MaxThreads = $Cores
|
||||
}
|
||||
else {
|
||||
$MaxThreads = (Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors
|
||||
Write-Host "Running with $MaxThreads" Cores by default.
|
||||
}
|
||||
|
||||
|
||||
$files = (ls *.pwn).Name
|
||||
$workdir = (pwd)
|
||||
$Block = {
|
||||
Param([string] $file, [string] $workdir)
|
||||
& cd $workdir; .\pawncc.exe $file
|
||||
}
|
||||
#Remove all jobs
|
||||
Get-Job | Remove-Job
|
||||
#Start the jobs. Max 4 jobs running simultaneously.
|
||||
foreach($file in $files){
|
||||
While ($(Get-Job -state running).count -ge $MaxThreads){
|
||||
Start-Sleep -Milliseconds 3
|
||||
}
|
||||
Start-Job -Scriptblock $Block -ArgumentList $file, $workdir
|
||||
}
|
||||
#Wait for all jobs to finish.
|
||||
While ($(Get-Job -State Running).count -gt 0){
|
||||
start-sleep 1
|
||||
}
|
||||
#Get information from each job.
|
||||
foreach($job in Get-Job){
|
||||
$info= Receive-Job -Id ($job.Id)
|
||||
}
|
||||
#Remove all jobs created.
|
||||
Get-Job | Remove-Job
|
Loading…
x
Reference in New Issue
Block a user