forked from trailofbits/cb-multios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
57 lines (49 loc) · 1.46 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$false)]
[ValidateSet("clang", "msvc")]
[string]$Compiler="clang",
[Parameter(Position=1,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ExtraCmakeArgs
)
Write-Host "Preparing to run build script..."
Write-Host ""
Write-Host "Config:"
Write-Host "`tCompiler...........$Compiler"
Write-Host "`tExtra CMake Args:..$ExtraCmakeArgs"
Write-Host ""
if(!$PSScriptRoot){
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$DIR = $PSScriptRoot
$TOOLS = Join-Path $DIR "tools"
$BUILD_DIR = Join-Path $DIR "build"
Write-Host "Checking if required python modules are installed..."
& python -c "import xlsxwriter; import Crypto; import win32api" 2>$null
if ($LASTEXITCODE -ne 0) {
Write-Error "`nPlease install required python packages`n > pip install xlsxwriter pycryptodome pypiwin32"
exit 1
}
Write-Host "All python modules installed.`n"
Write-Host "Creating Build Directory..."
New-Item -Path $BUILD_DIR -Type directory | out-null
Push-Location
Set-Location $BUILD_DIR
Write-Host "`tNow in $BUILD_DIR`n"
Write-Host "Creating Build Files..."
if ($Compiler -eq "clang") {
& cmake -A Win32 -T clangcl -DCLANGCL:BOOL=TRUE ..
} elseIf ($Compiler -eq "msvc") {
& cmake -A Win32 ..
} else {
Write-Error "`tUnrecognized compiler: $Compiler`n"
exit 1
}
if ($LASTEXITCODE -eq 0)
{
Write-Host ""
Write-Host "Building..."
& cmake --build .
}
Pop-Location
exit $LASTEXITCODE