From 0527a033c85606b4fa780d2a3734fbb9da10f385 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Thu, 16 May 2024 13:35:03 -0400 Subject: [PATCH] Modifiaitons to build script I only keep the generated code_compiler_staged dir around if there are errors compiling --- Readme.md | 6 ++-- scripts/build.ps1 | 29 +++++++++++++--- scripts/setup_virtual_code_view.ps1 | 53 ----------------------------- 3 files changed, 27 insertions(+), 61 deletions(-) delete mode 100644 scripts/setup_virtual_code_view.ps1 diff --git a/Readme.md b/Readme.md index 28d4258..23d72f4 100644 --- a/Readme.md +++ b/Readme.md @@ -22,17 +22,17 @@ The dependencies are: * Odin repo's base, core, and vendor(raylib) libaries * An ini parser * backtrace +* Powershell (if you want to use my build scripts) The client(sectr) module's organization is relatively flat due to the nature of odin's compiler, not allowing for cyclic dependencies across modules, and modules can only be in one directory. This makes it difficult to unflatten, not something organic todo in a prototype... I have the codebase by default in a non-idomatic layout that I stage to the compiler beforehand. There is a script(`scripts/gen_staged_compiler_codebase.ps1`) that stages a the idiomatic format of the codebase for the compiler to digest when `scripts/build.ps1` is run. -Even so the notable groups are: +Major 'codebase modules': -* API : Provides the overarching interface of the app's general behavior. Host uses this to provide the client its necessary data and exection env. - * Has the following definitions: startup, shutdown, reload, tick, clean_frame * Engine : Main loop, logging, client interface for host, etc + * Has the following definitions: startup, shutdown, reload, tick, clean_frame (which host hooks up to when managing the client dll) * Env : Core Memory & State definition + orchestration * Font Provider : Manages fonts. * When loading fonts, the provider currently uses raylib to generate bitmap glyth sheets for a range of font sizes at once. diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 5572235..63f5c9c 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -224,19 +224,19 @@ push-location $path_root if ( $host_process_active ) { write-host 'Skipping sectr_host build, process is active' - return + return $true } $dependencies_built = $script:sectr_build_code -ne $module_build_failed if ( -not $dependencies_built ) { write-host 'Skipping sectr_host build, dependencies failed to build' - return + return $false } $should_build = (check-ModuleForChanges $module_host) -or ( $script:sectr_build_code -eq $module_built ) if ( -not( $should_build)) { write-host 'Skipping sectr_host build, module up to date' - return + return $true } if (test-path $pdb) { @@ -273,13 +273,32 @@ push-location $path_root # $build_args += $flag_sanitize_address # $build_args += $flag_sanitize_memory + if ( Test-Path $module_dll) { + $module_dll_pre_build_hash = get-filehash -path $module_dll -Algorithm MD5 + } + Invoke-WithColorCodedOutput { & $odin_compiler $build_args } + + if ( Test-Path $module_dll ) { + $module_dll_post_build_hash = get-filehash -path $module_dll -Algorithm MD5 + } + + $built = ($module_dll_pre_build_hash -eq $null) -or ($module_dll_pre_build_hash.Hash -ne $module_dll_post_build_hash.Hash) + if ( -not $built ) { + write-host 'Failed to build, marking module dirty' + mark-ModuleDirty $module_sectr + } + return $built } - build-host + $host_build_code = build-sectr Pop-Location # path_code - if ( test-path $path_code_compiler_staged ) { Remove-Item -Path $path_code_compiler_staged -Force -Recurse } + if ( test-path $path_code_compiler_staged ) { + if ( ($host_build_code -ne $module_build_failed) -and ($script:sectr_build_code -ne $module_build_failed) ) { + Remove-Item -Path $path_code_compiler_staged -Force -Recurse + } + } } build-prototype pop-location # path_root diff --git a/scripts/setup_virtual_code_view.ps1 b/scripts/setup_virtual_code_view.ps1 deleted file mode 100644 index d69accf..0000000 --- a/scripts/setup_virtual_code_view.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -# Generates a more ergonomic filesystem organization for nagivating the codebase on windows using symbolic links - -cls -write-host "Build.ps1" - -$path_root = git rev-parse --show-toplevel -$path_code = join-path $path_root 'code' -$path_scripts = join-path $path_root 'scripts' - -$path_virtual_view = join-path $path_root 'code_virtual_view' - -if (test-path $path_virtual_view) { - Remove-Item -Path $path_virtual_view -Recurse -Force -ErrorAction Ignore -} -New-Item -ItemType Directory -Path $path_virtual_view - -$files = Get-ChildItem -Path $path_code -File -Recurse -foreach ($file in $files) -{ - # Determine if the file name contains a namespace - $fileName = $file.Name - if ($fileName -match '^(.+?)_(.+)\.odin$') - { - # Extract namespace and actual file name - $namespace = $Matches[1] - $actualFileName = $Matches[2] + ".odin" - - # Create a namespace directory in the virtual view if it doesn't exist - $namespaceDir = Join-Path $path_virtual_view $namespace - if (-not (Test-Path $namespaceDir)) { - New-Item -ItemType Directory -Path $namespaceDir - } - - # Create a symbolic link in the namespace directory pointing to the original file - $targetFilePath = $file.FullName - $linkPath = Join-Path $namespaceDir $actualFileName - New-Item -ItemType SymbolicLink -Path $linkPath -Value $targetFilePath - } - else - { - # For files without a namespace, maintain the directory structure in the virtual view - $relativePath = $file.FullName.Substring($path_code.Length + 1) - $linkPath = Join-Path $path_virtual_view $relativePath - $linkDir = Split-Path -Parent $linkPath - - if (-not (Test-Path $linkDir)) { - New-Item -ItemType Directory -Path $linkDir -Force - } - New-Item -ItemType SymbolicLink -Path $linkPath -Value $file.FullName - } -} - -Write-Host "Virtual view created successfully."