mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-06 07:38:45 +00:00
setup inital build script to start tackling compile errors
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# This is meant to be used with build.ps1, and is not a standalone script.
|
||||
|
||||
function Get-IniContent { param([ string]$filePath )
|
||||
$ini = @{}
|
||||
$currentSection = $null
|
||||
switch -regex -file $filePath
|
||||
{
|
||||
"^\[(.+)\]$" {
|
||||
$currentSection = $matches[1].Trim()
|
||||
$ini[$currentSection] = @{}
|
||||
}
|
||||
"^(.+?)\s*=\s*(.*)" {
|
||||
$key, $value = $matches[1].Trim(), $matches[2].Trim()
|
||||
if ($null -ne $currentSection) {
|
||||
$ini[$currentSection][$key] = $value
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ini
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
|
||||
function clone-gitrepo { param( [string] $path, [string] $url )
|
||||
if (test-path $path) {
|
||||
# git -C $path pull
|
||||
}
|
||||
else {
|
||||
Write-Host "Cloning $url ..."
|
||||
git clone $url $path
|
||||
}
|
||||
}
|
||||
function get-initcontent { param( [string] $path_file )
|
||||
$ini = @{}
|
||||
$currentSection = $null
|
||||
switch -regex -file $path_file
|
||||
{
|
||||
"^\[(.+)\]$" {
|
||||
$currentSection = $matches[1].Trim()
|
||||
$ini[ $currentSection ] = @{}
|
||||
}
|
||||
"^(.+?)\s*=\s*(.*)" {
|
||||
$key, $value = $matches[1].Trim(), $matches[2].Trim()
|
||||
if ($null -ne $currentSection) {
|
||||
$ini[ $currentSection ][ $key ] = $value
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ini
|
||||
}
|
||||
|
||||
function Get-ScriptRepoRoot {
|
||||
$currentPath = $PSScriptRoot
|
||||
while ($currentPath -ne $null -and $currentPath -ne "")
|
||||
{
|
||||
if (Test-Path (Join-Path $currentPath ".git")) {
|
||||
return $currentPath
|
||||
}
|
||||
# Also check for .git file which indicates a submodule
|
||||
$gitFile = Join-Path $currentPath ".git"
|
||||
if (Test-Path $gitFile -PathType Leaf)
|
||||
{
|
||||
$gitContent = Get-Content $gitFile
|
||||
if ($gitContent -match "gitdir: (.+)") {
|
||||
return $currentPath
|
||||
}
|
||||
}
|
||||
$currentPath = Split-Path $currentPath -Parent
|
||||
}
|
||||
throw "Unable to find repository root"
|
||||
}
|
||||
|
||||
function Invoke-WithColorCodedOutput { param( [scriptblock] $command )
|
||||
& $command 2>&1 | ForEach-Object {
|
||||
# Write-Host "Type: $($_.GetType().FullName)" # Add this line for debugging
|
||||
$color = 'White' # Default text color
|
||||
switch ($_) {
|
||||
{ $_ -imatch "error" } { $color = 'Red'; break }
|
||||
{ $_ -imatch "warning" } { $color = 'Yellow'; break }
|
||||
}
|
||||
Write-Host "`t$_" -ForegroundColor $color
|
||||
}
|
||||
}
|
||||
function update-gitrepo
|
||||
{
|
||||
param( [string] $path, [string] $url, [string] $build_command )
|
||||
|
||||
$repo_name = $url.Split('/')[-1].Replace('.git', '')
|
||||
|
||||
$last_built_commit = join-path $path_build "last_built_commit_$repo_name.txt"
|
||||
if ( -not(test-path -Path $path))
|
||||
{
|
||||
write-host "Cloining repo from $url to $path"
|
||||
git clone $url $path
|
||||
|
||||
write-host "Building $url"
|
||||
push-location $path
|
||||
if ( $build_command -ne '' )
|
||||
{
|
||||
& "$build_command"
|
||||
}
|
||||
pop-location
|
||||
|
||||
git -C $path rev-parse HEAD | out-file $last_built_commit
|
||||
$script:binaries_dirty = $true
|
||||
write-host
|
||||
return
|
||||
}
|
||||
|
||||
git -C $path fetch
|
||||
$latest_commit_hash = git -C $path rev-parse '@{u}'
|
||||
$last_built_hash = if (Test-Path $last_built_commit) { Get-Content $last_built_commit } else { "" }
|
||||
|
||||
if ( $latest_commit_hash -eq $last_built_hash ) {
|
||||
write-host
|
||||
return
|
||||
}
|
||||
|
||||
write-host "Build out of date for: $path, updating"
|
||||
write-host 'Pulling...'
|
||||
git -C $path pull
|
||||
|
||||
write-host "Building $url"
|
||||
push-location $path
|
||||
if ( $build_command -ne '' )
|
||||
{
|
||||
& $build_command
|
||||
}
|
||||
pop-location
|
||||
|
||||
$latest_commit_hash | out-file $last_built_commit
|
||||
$script:binaries_dirty = $true
|
||||
write-host
|
||||
}
|
||||
|
||||
function verify-path { param( $path )
|
||||
if (test-path $path) {return $true}
|
||||
|
||||
new-item -ItemType Directory -Path $path
|
||||
return $false
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
function Get-ScriptRepoRoot {
|
||||
$currentPath = $PSScriptRoot
|
||||
while ($currentPath -ne $null -and $currentPath -ne "")
|
||||
{
|
||||
if (Test-Path (Join-Path $currentPath ".git")) {
|
||||
return $currentPath
|
||||
}
|
||||
# Also check for .git file which indicates a submodule
|
||||
$gitFile = Join-Path $currentPath ".git"
|
||||
if (Test-Path $gitFile -PathType Leaf)
|
||||
{
|
||||
$gitContent = Get-Content $gitFile
|
||||
if ($gitContent -match "gitdir: (.+)") {
|
||||
return $currentPath
|
||||
}
|
||||
}
|
||||
$currentPath = Split-Path $currentPath -Parent
|
||||
}
|
||||
throw "Unable to find repository root"
|
||||
}
|
||||
@@ -404,7 +404,6 @@ if ( $vendor -match "msvc" )
|
||||
$flag_optimize_intrinsics = '/Oi'
|
||||
$flag_optimized_debug_forceinline = '/d2Obforceinline'
|
||||
$flag_optimized_debug = '/Zo'
|
||||
$flag_
|
||||
# $flag_out_name = '/OUT:'
|
||||
$flag_path_interm = '/Fo'
|
||||
$flag_path_debug = '/Fd'
|
||||
|
||||
Reference in New Issue
Block a user