Setup project to auto-grab dependencies directory from a fork of the odin repo.
This commit is contained in:
parent
761794f594
commit
89f2041b79
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
build/**
|
||||
*.exe
|
||||
thirdparty/**
|
@ -125,6 +125,7 @@ render :: proc()
|
||||
draw_text( "Monitor : %v", rl.GetMonitorName(0) )
|
||||
draw_text( "Screen Width : %v", rl.GetScreenWidth() )
|
||||
draw_text( "Screen Height: %v", rl.GetScreenHeight() )
|
||||
// draw_text( "HOT RELOAD BITCHES" )
|
||||
|
||||
draw_debug_text_y = 50
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
cls
|
||||
|
||||
$incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1'
|
||||
. $incremental_checks
|
||||
|
||||
$path_root = git rev-parse --show-toplevel
|
||||
$path_code = join-path $path_root 'code'
|
||||
$path_build = join-path $path_root 'build'
|
||||
$path_thirdparty = join-path $path_root 'thirdparty'
|
||||
$path_code = join-path $path_root 'code'
|
||||
$path_build = join-path $path_root 'build'
|
||||
$path_scripts = join-path $path_root 'scripts'
|
||||
$path_thirdparty = join-path $path_root 'thirdparty'
|
||||
$path_odin = join-path $path_thirdparty 'odin'
|
||||
|
||||
# Odin Compiler Flags
|
||||
|
||||
@ -52,9 +57,16 @@ $flag_use_lld = '-lld'
|
||||
|
||||
push-location $path_root
|
||||
|
||||
$update_deps = join-path $path_scripts 'update_deps.ps1'
|
||||
$odin = join-path $path_odin 'odin.exe'
|
||||
write-host 'OdinPATH: ' + $odin
|
||||
|
||||
if ( -not( test-path 'build') ) {
|
||||
new-item -ItemType Directory -Path 'build'
|
||||
}
|
||||
|
||||
& $update_deps
|
||||
|
||||
function build-prototype
|
||||
{
|
||||
$host_process_active = Get-Process | Where-Object {$_.Name -like 'sectr_host*'}
|
||||
@ -65,7 +77,10 @@ push-location $path_root
|
||||
$executable = join-path $path_build ($project_name + '_host.exe')
|
||||
$pdb = join-path $path_build ($project_name + '_host.pdb')
|
||||
|
||||
if ( -not($host_process_active)) {
|
||||
$module_host = join-path $path_code 'host'
|
||||
|
||||
$should_build = check-ModuleForChanges $module_host
|
||||
if ( -not($host_process_active) -and $should_build ) {
|
||||
$build_args = @()
|
||||
$build_args += $flag_build
|
||||
$build_args += './host'
|
||||
@ -75,31 +90,31 @@ push-location $path_root
|
||||
$build_args += $flag_pdb_name + $pdb
|
||||
$build_args += $flag_subsystem + 'windows'
|
||||
|
||||
& odin $build_args
|
||||
|
||||
$third_party_dlls = Get-ChildItem -Path $path_thirdparty -Filter '*.dll'
|
||||
foreach ($dll in $third_party_dlls) {
|
||||
$destination = join-path $path_build $dll.Name
|
||||
Copy-Item $dll.FullName -Destination $destination -Force
|
||||
}
|
||||
write-host 'Building Host Module'
|
||||
& $odin $build_args
|
||||
}
|
||||
else {
|
||||
write-host 'Skipping sectr_host build, process is active'
|
||||
}
|
||||
|
||||
$module_dll = join-path $path_build ( $project_name + '.dll' )
|
||||
$pdb = join-path $path_build ( $project_name + '.pdb' )
|
||||
$module_sectr = $path_code
|
||||
$should_build = check-ModuleForChanges $module_sectr
|
||||
if ( $should_build ) {
|
||||
$module_dll = join-path $path_build ( $project_name + '.dll' )
|
||||
$pdb = join-path $path_build ( $project_name + '.pdb' )
|
||||
|
||||
$build_args = @()
|
||||
$build_args += $flag_build
|
||||
$build_args += '.'
|
||||
$build_args += $flag_build_mode_dll
|
||||
$build_args += $flag_output_path + $module_dll
|
||||
$build_args += $flag_optimize_none
|
||||
$build_args += $flag_debug
|
||||
$build_args += $flag_pdb_name + $pdb
|
||||
$build_args = @()
|
||||
$build_args += $flag_build
|
||||
$build_args += '.'
|
||||
$build_args += $flag_build_mode_dll
|
||||
$build_args += $flag_output_path + $module_dll
|
||||
$build_args += $flag_optimize_none
|
||||
$build_args += $flag_debug
|
||||
$build_args += $flag_pdb_name + $pdb
|
||||
|
||||
& odin $build_args
|
||||
write-host 'Building Sectr Module'
|
||||
& $odin $build_args
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
}
|
||||
|
73
scripts/helpers/incremental_checks.ps1
Normal file
73
scripts/helpers/incremental_checks.ps1
Normal file
@ -0,0 +1,73 @@
|
||||
# This is meant to be used with build.ps1, and is not a standalone script.
|
||||
|
||||
function check-FileForChanges
|
||||
{
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$path_file
|
||||
)
|
||||
|
||||
if (-not (Test-Path $path_file -PathType Leaf)) {
|
||||
Write-Error "The provided path is not a valid file: $path_file"
|
||||
return $false
|
||||
}
|
||||
$file_name = Split-Path $path_file -Leaf
|
||||
$path_csv = Join-Path $path_build ($file_name + "_file_hash.csv")
|
||||
|
||||
$csv_file_hash = $null
|
||||
if (Test-Path $path_csv) {
|
||||
$csv_file_hash = Import-Csv $path_csv | Select-Object -ExpandProperty value
|
||||
}
|
||||
|
||||
$current_hash_info = Get-FileHash -Path $path_file -Algorithm MD5
|
||||
$current_file_hash = $current_hash_info.Hash
|
||||
|
||||
# Save the current hash to the CSV
|
||||
[PSCustomObject]@{
|
||||
name = $path_file
|
||||
value = $current_file_hash
|
||||
} | Export-Csv $path_csv -NoTypeInformation
|
||||
|
||||
if ($csv_file_hash -and $csv_file_hash -eq $current_file_hash) {
|
||||
return $false
|
||||
} else {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
# Check to see if the module has changed files since the last build
|
||||
function check-ModuleForChanges
|
||||
{
|
||||
param( [string]$path_module, [array]$excludes )
|
||||
|
||||
$module_name = split-path $path_module -leaf
|
||||
$path_csv = Join-Path $path_build ($module_name + "_module_hashes.csv")
|
||||
|
||||
$csv_file_hashes = $null
|
||||
if ( test-path $path_csv ) {
|
||||
$csv_file_hashes = @{}
|
||||
import-csv $path_csv | foreach-object {
|
||||
$csv_file_hashes[ $_.name ] = $_.value
|
||||
}
|
||||
}
|
||||
|
||||
$file_hashes = @{}
|
||||
get-childitem -path $path_module -recurse -file -Exclude $excludes | foreach-object {
|
||||
$id = $_.fullname
|
||||
$hash_info = get-filehash -path $id -Algorithm MD5
|
||||
$file_hashes[ $id ] = $hash_info.Hash
|
||||
}
|
||||
|
||||
$file_hashes.GetEnumerator() | foreach-object { [PSCustomObject]$_ } |
|
||||
export-csv $path_csv -NoTypeInformation
|
||||
|
||||
if ( -not $csv_file_hashes ) { return $true }
|
||||
if ( $csv_file_hashes.Count -ne $file_hashes.Count ) { return $true }
|
||||
|
||||
foreach ( $key in $csv_file_hashes.Keys ) {
|
||||
if ( $csv_file_hashes[ $key ] -ne $file_hashes[ $key ] ) {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
return $false
|
||||
}
|
65
scripts/update_deps.ps1
Normal file
65
scripts/update_deps.ps1
Normal file
@ -0,0 +1,65 @@
|
||||
write-host 'Updating Dependencies..'
|
||||
|
||||
$path_root = git rev-parse --show-toplevel
|
||||
$path_code = join-path $path_root 'code'
|
||||
$path_build = join-path $path_root 'build'
|
||||
$path_thirdparty = join-path $path_root 'thirdparty'
|
||||
|
||||
$url_odin_repo = 'https://github.com/Ed94/Odin.git'
|
||||
$path_odin = join-path $path_thirdparty 'Odin'
|
||||
|
||||
$incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1'
|
||||
. $incremental_checks
|
||||
|
||||
if ( -not(Test-Path $path_thirdparty) ) {
|
||||
new-item -ItemType Directory -Path $path_thirdparty
|
||||
}
|
||||
|
||||
push-location $path_thirdparty
|
||||
|
||||
if (Test-Path -Path $path_odin)
|
||||
{
|
||||
Write-Host "Checking for updates in the Odin repository..."
|
||||
git -C $path_odin fetch
|
||||
|
||||
# Get the latest local and remote commit hashes for the current branch
|
||||
$localCommit = git -C $path_odin rev-parse HEAD
|
||||
$remoteCommit = git -C $path_odin rev-parse '@{u}'
|
||||
|
||||
# Compare local and remote commits
|
||||
if ($localCommit -ne $remoteCommit)
|
||||
{
|
||||
Write-Host "Odin repository is out-of-date. Pulling changes and rebuilding..."
|
||||
git -C $path_odin pull
|
||||
push-location $path_odin
|
||||
& .\build.bat
|
||||
pop-location
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Odin repository is up-to-date. No need to rebuild."
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# Odin directory does not exist, so clone the repository
|
||||
Write-Host "Cloning Odin repository..."
|
||||
git clone $url_odin_repo $path_odin
|
||||
push-location $path_odin
|
||||
& .\build.bat
|
||||
pop-location
|
||||
}
|
||||
|
||||
write-host 'Odin up to date'
|
||||
|
||||
$path_vendor = join-path $path_odin 'vendor'
|
||||
$path_vendor_raylib = join-path $path_vendor 'raylib'
|
||||
$path_raylib_dlls = join-path $path_vendor_raylib 'windows'
|
||||
|
||||
$third_party_dlls = Get-ChildItem -Path $path_raylib_dlls -Filter '*.dll'
|
||||
foreach ($dll in $third_party_dlls) {
|
||||
$destination = join-path $path_build $dll.Name
|
||||
Copy-Item $dll.FullName -Destination $destination -Force
|
||||
}
|
||||
|
||||
pop-location
|
BIN
thirdparty/raygui.dll
vendored
BIN
thirdparty/raygui.dll
vendored
Binary file not shown.
BIN
thirdparty/raylib.dll
vendored
BIN
thirdparty/raylib.dll
vendored
Binary file not shown.
Loading…
Reference in New Issue
Block a user