Drafting up scripts (not tested)

This commit is contained in:
2024-06-30 20:41:50 -04:00
parent b7a5a89e16
commit f6a3f50fa1
7 changed files with 328 additions and 0 deletions

80
scripts/helpers/misc.ps1 Normal file
View File

@@ -0,0 +1,80 @@
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
}
}
# TODO(Ed): This is garbage for odin's output..
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 )
if ( $build_command -eq $null ) {
write-host "Attempted to call Update-GitRepo without build_command specified"
return
}
$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
& "$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
& $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
}

View File

@@ -0,0 +1,63 @@
# Not meant to be used standalone
# Odin Compiler Flags
# For a beakdown of any flag, type <odin_compiler> <command> -help
$command_build = 'build'
$command_check = 'check'
$command_query = 'query'
$command_report = 'report'
$command_run = 'run'
$flag_build_mode = '-build-mode:'
$flag_build_mode_dll = '-build-mode:dll'
$flag_collection = '-collection:'
$flag_debug = '-debug'
$flag_define = '-define:'
$flag_default_allocator_nil = '-default-to-nil-allocator'
$flag_disable_assert = '-disable-assert'
$flag_dynamic_map_calls = '-dynamic-map-calls'
$flag_extra_assembler_flags = '-extra_assembler-flags:'
$flag_extra_linker_flags = '-extra-linker-flags:'
$flag_ignore_unknown_attributes = '-ignore-unknown-attributes'
$flag_keep_temp_files = '-keep-temp-files'
$flag_max_error_count = '-max-error-count:'
$flag_micro_architecture_native = '-microarch:native'
$flag_no_bounds_check = '-no-bounds-check'
$flag_no_crt = '-no-crt'
$flag_no_entrypoint = '-no-entry-point'
$flag_no_thread_local = '-no-thread-local'
$flag_no_thread_checker = '-no-threaded-checker'
$flag_output_path = '-out='
$flag_optimization_level = '-opt:'
$flag_optimize_none = '-o:none'
$flag_optimize_minimal = '-o:minimal'
$flag_optimize_size = '-o:size'
$flag_optimize_speed = '-o:speed'
$falg_optimize_aggressive = '-o:aggressive'
$flag_pdb_name = '-pdb-name:'
$flag_sanitize_address = '-sanitize:address'
$flag_sanitize_memory = '-sanitize:memory'
$flag_sanitize_thread = '-sanitize:thread'
$flag_subsystem = '-subsystem:'
$flag_show_timings = '-show-timings'
$flag_show_more_timings = '-show-more-timings'
$flag_show_system_calls = '-show-system-calls'
$flag_target = '-target:'
$flag_thread_count = '-thread-count:'
$flag_use_lld = '-lld'
$flag_use_separate_modules = '-use-separate-modules'
$flag_vet_all = '-vet'
$flag_vet_unused_entities = '-vet-unused'
$flag_vet_semicolon = '-vet-semicolon'
$flag_vet_shadow_vars = '-vet-shadowing'
$flag_vet_using_stmt = '-vet-using-stmt'
$flag_msvc_link_disable_dynamic_base = '/DYNAMICBASE:NO'
$flag_msvc_link_base_address = '/BASE:'
$flag_msvc_link_fixed_base_address = '/FIXED'
$flag_msvc_link_stack_size = '/STACK'
$flag_msvc_link_debug = '/DEBUG'
# Assuming to be in default path, change if otherwise
$odin_compiler = 'odin.exe'