From f693685d7288772e764842ad3226af34f742bcbc Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 12 May 2024 16:02:38 -0400 Subject: [PATCH] Added a script automatically generating a virtual view using symbol links of the codebase So I can finally have some folders for organization --- .editorconfig | 2 + .gitignore | 1 + Readme.md | 3 +- scripts/build.ps1 | 8 ++-- scripts/setup_virtual_code_view.ps1 | 61 +++++++++++++++++++++++++++++ scripts/update_deps.ps1 | 10 +++++ toolchain/Odin | 2 +- 7 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 scripts/setup_virtual_code_view.ps1 diff --git a/.editorconfig b/.editorconfig index e1f1b1d..afc361d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,6 +19,8 @@ indent_size = 4 [*.odin] indent_style = tab indent_size = 2 +charset = utf-8 + [*.{natvis, natstepfilter}] indent_style = tab diff --git a/.gitignore b/.gitignore index 9fc05d3..1ebc837 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build/** logs .ark logs*.zip +code_virtual_view diff --git a/Readme.md b/Readme.md index a8db3ea..6b25ca8 100644 --- a/Readme.md +++ b/Readme.md @@ -17,7 +17,8 @@ The host module loads the main module & its memory. Hot-reloading it's dll when The dependencies are: -* Odin Compiler +* Odin Compiler (Slightly custom) + * Added #region, #endregion directives support for editors * Odin repo's base, core, and vendor(raylib) libaries * An ini parser diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 7954386..d62909b 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -169,8 +169,8 @@ push-location $path_root # $build_args += $flag_micro_architecture_native $build_args += $flag_use_separate_modules $build_args += $flag_thread_count + $CoreCount_Physical - $build_args += $flag_optimize_none - # $build_args += $flag_optimize_minimal + # $build_args += $flag_optimize_none + $build_args += $flag_optimize_minimal # $build_args += $flag_optimize_speed # $build_args += $falg_optimize_aggressive $build_args += $flag_debug @@ -251,8 +251,8 @@ push-location $path_root # $build_args += $flag_micro_architecture_native $build_args += $flag_use_separate_modules $build_args += $flag_thread_count + $CoreCount_Physical - $build_args += $flag_optimize_none - # $build_args += $flag_optimize_minimal + # $build_args += $flag_optimize_none + $build_args += $flag_optimize_minimal # $build_args += $flag_optimize_speed # $build_args += $falg_optimize_aggressive $build_args += $flag_debug diff --git a/scripts/setup_virtual_code_view.ps1 b/scripts/setup_virtual_code_view.ps1 new file mode 100644 index 0000000..928aeb0 --- /dev/null +++ b/scripts/setup_virtual_code_view.ps1 @@ -0,0 +1,61 @@ +# Generates a more ergonomic filesystem organization for nagivating the codebase on windows using symbolic links + +cls +write-host "Build.ps1" + +$incremental_checks = Join-Path $PSScriptRoot 'helpers/incremental_checks.ps1' +. $incremental_checks +write-host 'incremental_checks.ps1 imported' + +$ini_parser = join-path $PSScriptRoot 'helpers/ini.ps1' +. $ini_parser +write-host 'ini.ps1 imported' + +$path_root = git rev-parse --show-toplevel +$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_toolchain = join-path $path_root 'toolchain' +$path_odin = join-path $path_toolchain 'odin' + +$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, create a symbolic link in the root of the original code's path in virtual view + $linkPath = Join-Path $path_virtual_view $fileName + if (-not (Test-Path $linkPath)) { + New-Item -ItemType SymbolicLink -Path $linkPath -Value $file.FullName + } + } +} + +Write-Host "Virtual view created successfully." diff --git a/scripts/update_deps.ps1 b/scripts/update_deps.ps1 index 31e01b2..2e0e03a 100644 --- a/scripts/update_deps.ps1 +++ b/scripts/update_deps.ps1 @@ -42,6 +42,11 @@ function Update-GitRepo write-host "Cloining repo from $url to $path" git clone $url $path + $path_scripts = join-path $path 'scripts' + push-locaiton $path_scripts + & .\build_and_run_gen_src_pass.ps1 + pop-location + write-host "Building $url" push-location $path & "$build_command" @@ -66,6 +71,11 @@ function Update-GitRepo write-host 'Pulling...' git -C $path pull + $path_scripts = join-path $path 'scripts' + push-location $path_scripts + & .\build_and_run_gen_src_pass.ps1 + pop-location + write-host "Building $url" push-location $path & $build_command diff --git a/toolchain/Odin b/toolchain/Odin index e462116..0d4069d 160000 --- a/toolchain/Odin +++ b/toolchain/Odin @@ -1 +1 @@ -Subproject commit e462116f9428c3a871663eae4363c8d7da35497e +Subproject commit 0d4069d2ea7aaf155b8c5d979fbbc590360314d0