Adding CI files

This commit is contained in:
PIE Easy Start 2021-08-22 16:04:59 +00:00 committed by Tomer Lev
parent d352ace4d2
commit b712f00b7e
4 changed files with 152 additions and 45 deletions

View file

@ -1,45 +0,0 @@
param(
[Parameter()]
[ValidateSet("Debug", "Release")]
[string] $BuildType = "Release"
)
$SourceDirectory = (Convert-Path "$PSScriptRoot/../").Replace("\", "/")
$WorkingDirectory = "$pwd"
$BuildOutputDirectory = "$SourceDirectory/out/build/x64/$BuildType"
$InstallDirectory = "$SourceDirectory/out/install/x64/$BuildType"
$commands = @()
if (!(Get-Command cl)) {
$commands += '"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"'
}
$commands += @"
cmake.exe
-G "Ninja"
-S "$SourceDirectory"
-B "$WorkingDirectory"
-DCMAKE_BUILD_TYPE:STRING=$BuildType
-DCMAKE_INSTALL_PREFIX:PATH="$InstallDirectory"
-DDISABLE_PYTHON_BINDINGS=1 `
2>&1
"@.Replace("`r`n", "")
$commands += @"
cmake.exe --build $WorkingDirectory --config $BuildType
"@
$commands += @"
cmake.exe --install $WorkingDirectory
"@
cmd /c ($commands -join " && ")
Write-Host "Copying build output to $BuildOutputDirectory..."
mkdir $BuildOutputDirectory -Force | Out-Null
Get-ChildItem $WorkingDirectory -Recurse -Attributes !ReparsePoint | foreach {
$path = $_.FullName.Replace("$pwd", $BuildOutputDirectory)
$parent = Split-Path -Parent $path
mkdir $parent -Force | Out-Null
Copy-Item $_.FullName -Destination $path -Force
}
Write-Host "Done."

View file

@ -0,0 +1,67 @@
{
"version": 2,
"configurePresets": [
{
"name": "base",
"hidden": true,
"description": "Base preset",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x64,version=16.11",
"strategy": "external"
}
},
{
"name": "x64-Debug",
"inherits": "base",
"displayName": "x64 Debug",
"description": "Sets debug build type and x64 arch",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-Release",
"displayName": "x64 Release",
"description": "Sets release build type",
"inherits": "x64-Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "default-debug-build",
"displayName": "Debug Build",
"configurePreset": "x64-Debug"
},
{
"name": "verbose-debug-build",
"displayName": "Verbose Debug Build",
"configurePreset": "x64-Debug",
"nativeToolOptions": [ "-v" ]
},
{
"name": "default-release-build",
"displayName": "Release Build",
"configurePreset": "x64-Release"
},
{
"name": "verbose-release-build",
"displayName": "Verbose Release Build",
"configurePreset": "x64-Release",
"nativeToolOptions": [ "-v" ]
}
],
"testPresets": []
}

View file

@ -0,0 +1,73 @@
param (
[string] $Architecture='x64'
)
if (!(Get-Module VSSetup))
{
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module VSSetup -Force
}
function Get-VSInstallPath {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[int] $MaxVersion
)
$latest = Get-VSSetupInstance `
| where { $_.InstallationVersion.Major -le $MaxVersion } `
| Select-VSSetupInstance -Require Microsoft.VisualStudio.VC.CMake -Latest
if (!$latest)
{
throw [System.IO.FileNotFoundException]::new("No Visual Studio installation found that matches max version: $MaxVersion!")
}
return $latest.InstallationPath
}
function Where-Program {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string] $Program
)
process
{
return Get-Command $Program | select Source -ExpandProperty source | Split-Path -Parent
}
}
function Persist-EnvironmentVariable {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[string] $Name
)
process
{
$value=[System.Environment]::GetEnvironmentVariable($Name)
[System.Environment]::SetEnvironmentVariable($Name, $value, [System.EnvironmentVariableTarget]::Machine)
}
}
$VsInstallationPath = Get-VSInstallPath -MaxVersion 16
Write-Host "Found VS installation: $VsInstallationPath"
[array] $originalEnv = [System.Environment]::GetEnvironmentVariables().Keys
Import-Module "$VsInstallationPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath $VsInstallationPath -SkipAutomaticLocation -DevCmdArguments "-arch=$Architecture"
$Programs = 'cmake', 'Ninja', 'cl'
$programsPath = $Programs | Where-Program
Write-Host "Found paths for $($Programs -join ', '): $($programsPath -join ', ')"
$newPath = "$($programsPath -join ';');${env:Path}"
Write-Host "Persisting new PATH: $newPath"
[System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Machine)
[array] $vsEnv = [System.Environment]::GetEnvironmentVariables().Keys
[array] $newEnv = $vsEnv | where { $_ -notin $originalEnv -and $_ -ne 'PATH' }
Write-Host "Persisting new environment variables: $($newEnv -join ', ')"
$newEnv | Persist-EnvironmentVariable

View file

@ -0,0 +1,12 @@
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install conan -y
choco install sed -y
choco install winflexbison -y
if (!(Get-Command python))
{
choco install python -y
}
[System.Environment]::SetEnvironmentVariable('PATH', "C:\Program Files\Git\bin;${env:PATH}", [System.EnvironmentVariableTarget]::Machine)