diff --git a/.gitignore b/.gitignore index 1ebc837..b6c0915 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ build/** logs .ark logs*.zip -code_virtual_view +code_compiler_staged diff --git a/Readme.md b/Readme.md index 1b219ec..28d4258 100644 --- a/Readme.md +++ b/Readme.md @@ -26,6 +26,8 @@ The dependencies are: 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: * API : Provides the overarching interface of the app's general behavior. Host uses this to provide the client its necessary data and exection env. diff --git a/code/app_scratch.odin b/code/app/scratch.odin similarity index 100% rename from code/app_scratch.odin rename to code/app/scratch.odin diff --git a/code/app_screen.odin b/code/app/screen.odin similarity index 100% rename from code/app_screen.odin rename to code/app/screen.odin diff --git a/code/app_serialize.odin b/code/app/serialize.odin similarity index 100% rename from code/app_serialize.odin rename to code/app/serialize.odin diff --git a/code/app_state.odin b/code/app/state.odin similarity index 100% rename from code/app_state.odin rename to code/app/state.odin diff --git a/code/app_ui_theme_default.odin b/code/app/ui_theme_default.odin similarity index 100% rename from code/app_ui_theme_default.odin rename to code/app/ui_theme_default.odin diff --git a/code/engine_client_api.odin b/code/engine/client_api.odin similarity index 100% rename from code/engine_client_api.odin rename to code/engine/client_api.odin diff --git a/code/engine_logger.odin b/code/engine/logger.odin similarity index 100% rename from code/engine_logger.odin rename to code/engine/logger.odin diff --git a/code/engine_render_gl.odin b/code/engine/render_gl.odin similarity index 100% rename from code/engine_render_gl.odin rename to code/engine/render_gl.odin diff --git a/code/engine_render_raylib.odin b/code/engine/render_raylib.odin similarity index 100% rename from code/engine_render_raylib.odin rename to code/engine/render_raylib.odin diff --git a/code/engine_render_text_raylib.odin b/code/engine/render_text_raylib.odin similarity index 100% rename from code/engine_render_text_raylib.odin rename to code/engine/render_text_raylib.odin diff --git a/code/engine_replay.odin b/code/engine/replay.odin similarity index 100% rename from code/engine_replay.odin rename to code/engine/replay.odin diff --git a/code/engine_startup.odin b/code/engine/startup.odin similarity index 100% rename from code/engine_startup.odin rename to code/engine/startup.odin diff --git a/code/engine_update.odin b/code/engine/update.odin similarity index 100% rename from code/engine_update.odin rename to code/engine/update.odin diff --git a/code/font_provider.odin b/code/font/provider.odin similarity index 100% rename from code/font_provider.odin rename to code/font/provider.odin diff --git a/code/grime_arena.odin b/code/grime/arena.odin similarity index 100% rename from code/grime_arena.odin rename to code/grime/arena.odin diff --git a/code/grime_array.odin b/code/grime/array.odin similarity index 100% rename from code/grime_array.odin rename to code/grime/array.odin diff --git a/code/grime_assert.odin b/code/grime/assert.odin similarity index 100% rename from code/grime_assert.odin rename to code/grime/assert.odin diff --git a/code/grime_context.odin b/code/grime/context.odin similarity index 100% rename from code/grime_context.odin rename to code/grime/context.odin diff --git a/code/grime_filesystem.odin b/code/grime/filesystem.odin similarity index 100% rename from code/grime_filesystem.odin rename to code/grime/filesystem.odin diff --git a/code/grime_grime.odin b/code/grime/grime.odin similarity index 100% rename from code/grime_grime.odin rename to code/grime/grime.odin diff --git a/code/grime_hashmap_chained.odin b/code/grime/hashmap_chained.odin similarity index 100% rename from code/grime_hashmap_chained.odin rename to code/grime/hashmap_chained.odin diff --git a/code/grime_hashmap_zpl.odin b/code/grime/hashmap_zpl.odin similarity index 100% rename from code/grime_hashmap_zpl.odin rename to code/grime/hashmap_zpl.odin diff --git a/code/grime_linked_list.odin b/code/grime/linked_list.odin similarity index 100% rename from code/grime_linked_list.odin rename to code/grime/linked_list.odin diff --git a/code/grime_memory.odin b/code/grime/memory.odin similarity index 100% rename from code/grime_memory.odin rename to code/grime/memory.odin diff --git a/code/grime_memory_tracker.odin b/code/grime/memory_tracker.odin similarity index 100% rename from code/grime_memory_tracker.odin rename to code/grime/memory_tracker.odin diff --git a/code/grime_pool_allocator.odin b/code/grime/pool_allocator.odin similarity index 100% rename from code/grime_pool_allocator.odin rename to code/grime/pool_allocator.odin diff --git a/code/grime_profiler.odin b/code/grime/profiler.odin similarity index 100% rename from code/grime_profiler.odin rename to code/grime/profiler.odin diff --git a/code/grime_ptr.odin b/code/grime/ptr.odin similarity index 100% rename from code/grime_ptr.odin rename to code/grime/ptr.odin diff --git a/code/grime_slab_allocator.odin b/code/grime/slab_allocator.odin similarity index 100% rename from code/grime_slab_allocator.odin rename to code/grime/slab_allocator.odin diff --git a/code/grime_stack.odin b/code/grime/stack.odin similarity index 100% rename from code/grime_stack.odin rename to code/grime/stack.odin diff --git a/code/grime_string_format.odin b/code/grime/string_format.odin similarity index 100% rename from code/grime_string_format.odin rename to code/grime/string_format.odin diff --git a/code/grime_string_interning.odin b/code/grime/string_interning.odin similarity index 100% rename from code/grime_string_interning.odin rename to code/grime/string_interning.odin diff --git a/code/grime_unicode.odin b/code/grime/unicode.odin similarity index 100% rename from code/grime_unicode.odin rename to code/grime/unicode.odin diff --git a/code/grime_virtual_arena.odin b/code/grime/virtual_arena.odin similarity index 100% rename from code/grime_virtual_arena.odin rename to code/grime/virtual_arena.odin diff --git a/code/grime_virtual_memory.odin b/code/grime/virtual_memory.odin similarity index 100% rename from code/grime_virtual_memory.odin rename to code/grime/virtual_memory.odin diff --git a/code/grime_windows.odin b/code/grime/windows.odin similarity index 100% rename from code/grime_windows.odin rename to code/grime/windows.odin diff --git a/code/input_actions.odin b/code/input/actions.odin similarity index 100% rename from code/input_actions.odin rename to code/input/actions.odin diff --git a/code/input_event.odin b/code/input/event.odin similarity index 100% rename from code/input_event.odin rename to code/input/event.odin diff --git a/code/input_input.odin b/code/input/input.odin similarity index 100% rename from code/input_input.odin rename to code/input/input.odin diff --git a/code/math_math.odin b/code/math/math.odin similarity index 100% rename from code/math_math.odin rename to code/math/math.odin diff --git a/code/math_pga2.odin b/code/math/pga2.odin similarity index 100% rename from code/math_pga2.odin rename to code/math/pga2.odin diff --git a/code/math_pga3.odin b/code/math/pga3.odin similarity index 100% rename from code/math_pga3.odin rename to code/math/pga3.odin diff --git a/code/math_pga3_grime.odin b/code/math/pga3_grime.odin similarity index 100% rename from code/math_pga3_grime.odin rename to code/math/pga3_grime.odin diff --git a/code/parser_code_agnostic.odin b/code/parser/code_agnostic.odin similarity index 100% rename from code/parser_code_agnostic.odin rename to code/parser/code_agnostic.odin diff --git a/code/parser_code_formatting.odin b/code/parser/code_formatting.odin similarity index 100% rename from code/parser_code_formatting.odin rename to code/parser/code_formatting.odin diff --git a/code/parser_odin_wysiwyg.odin b/code/parser/odin_wysiwyg.odin similarity index 100% rename from code/parser_odin_wysiwyg.odin rename to code/parser/odin_wysiwyg.odin diff --git a/code/parser_whitespace.odin b/code/parser/whitespace.odin similarity index 100% rename from code/parser_whitespace.odin rename to code/parser/whitespace.odin diff --git a/code/project_manual_serialization.odin b/code/project/manual_serialization.odin similarity index 100% rename from code/project_manual_serialization.odin rename to code/project/manual_serialization.odin diff --git a/code/project_project.odin b/code/project/project.odin similarity index 100% rename from code/project_project.odin rename to code/project/project.odin diff --git a/code/project_serialize.odin b/code/project/serialize.odin similarity index 100% rename from code/project_serialize.odin rename to code/project/serialize.odin diff --git a/code/project_workspace.odin b/code/project/workspace.odin similarity index 100% rename from code/project_workspace.odin rename to code/project/workspace.odin diff --git a/code/ui_canvas.odin b/code/ui/canvas.odin similarity index 100% rename from code/ui_canvas.odin rename to code/ui/canvas.odin diff --git a/code/ui_core.odin b/code/ui/core.odin similarity index 100% rename from code/ui_core.odin rename to code/ui/core.odin diff --git a/code/ui_core_box.odin b/code/ui/core_box.odin similarity index 100% rename from code/ui_core_box.odin rename to code/ui/core_box.odin diff --git a/code/ui_core_layout.odin b/code/ui/core_layout.odin similarity index 100% rename from code/ui_core_layout.odin rename to code/ui/core_layout.odin diff --git a/code/ui_core_layout_compute.odin b/code/ui/core_layout_compute.odin similarity index 100% rename from code/ui_core_layout_compute.odin rename to code/ui/core_layout_compute.odin diff --git a/code/ui_core_signal.odin b/code/ui/core_signal.odin similarity index 100% rename from code/ui_core_signal.odin rename to code/ui/core_signal.odin diff --git a/code/ui_core_style.odin b/code/ui/core_style.odin similarity index 100% rename from code/ui_core_style.odin rename to code/ui/core_style.odin diff --git a/code/ui_docking.odin b/code/ui/docking.odin similarity index 100% rename from code/ui_docking.odin rename to code/ui/docking.odin diff --git a/code/ui_floating.odin b/code/ui/floating.odin similarity index 100% rename from code/ui_floating.odin rename to code/ui/floating.odin diff --git a/code/ui_layout_widget.odin b/code/ui/layout_widget.odin similarity index 100% rename from code/ui_layout_widget.odin rename to code/ui/layout_widget.odin diff --git a/code/ui_tests.odin b/code/ui/tests.odin similarity index 100% rename from code/ui_tests.odin rename to code/ui/tests.odin diff --git a/code/ui_theme.odin b/code/ui/theme.odin similarity index 100% rename from code/ui_theme.odin rename to code/ui/theme.odin diff --git a/code/ui_util.odin b/code/ui/util.odin similarity index 100% rename from code/ui_util.odin rename to code/ui/util.odin diff --git a/code/ui_widgets.odin b/code/ui/widgets.odin similarity index 100% rename from code/ui_widgets.odin rename to code/ui/widgets.odin diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 9787847..5572235 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -117,13 +117,18 @@ push-location $path_root function build-prototype { - push-location $path_code + $gen_staged_compiler_codebase = join-path $PSScriptRoot 'gen_staged_compiler_codebase.ps1' + $path_code_compiler_staged = join-path $path_root 'code_compiler_staged' + + . $gen_staged_compiler_codebase + + push-location $path_code_compiler_staged $project_name = 'sectr' write-host "`nBuilding Sectr Prototype`n" - $module_host = join-path $path_code 'host' - $module_sectr = $path_code + $module_host = join-path $path_code_compiler_staged 'host' + $module_sectr = $path_code_compiler_staged $pkg_collection_thirdparty = 'thirdparty=' + $path_thirdparty @@ -273,6 +278,8 @@ push-location $path_root build-host Pop-Location # path_code + + if ( test-path $path_code_compiler_staged ) { Remove-Item -Path $path_code_compiler_staged -Force -Recurse } } build-prototype pop-location # path_root diff --git a/scripts/clean.ps1 b/scripts/clean.ps1 index 3740a45..ab8e94f 100644 --- a/scripts/clean.ps1 +++ b/scripts/clean.ps1 @@ -1,9 +1,9 @@ cls -$path_root = git rev-parse --show-toplevel -$path_code = join-path $path_root 'code' -$path_build = join-path $path_root 'build' +$path_root = git rev-parse --show-toplevel +$path_code = join-path $path_root 'code' +$path_code_compiler_staged = Join-Path $path_root 'code_compiler_staged' +$path_build = join-path $path_root 'build' -if ( test-path $path_build ) { - Remove-Item $path_build -Verbose -Force -Recurse -} +if ( test-path $path_build ) { Remove-Item $path_build -Verbose -Force -Recurse } +if ( test-path $path_code_compiler_staged) { Remove-Item $path_code_compiler_staged -Verbose -Force -Recurse } diff --git a/scripts/gen_staged_compiler_codebase.ps1 b/scripts/gen_staged_compiler_codebase.ps1 new file mode 100644 index 0000000..c33122e --- /dev/null +++ b/scripts/gen_staged_compiler_codebase.ps1 @@ -0,0 +1,67 @@ +cls +Write-Host "Reverse Build.ps1" + +$path_root = git rev-parse --show-toplevel +$path_code = Join-Path $path_root 'code' +$path_code_compiler_staged = Join-Path $path_root 'code_compiler_staged' + +if (Test-Path $path_code_compiler_staged) { + Remove-Item -Path $path_code_compiler_staged -Recurse -Force -ErrorAction Ignore +} +New-Item -ItemType Directory -Path $path_code_compiler_staged + +$whitelist_package = 'sectr' + +$files = Get-ChildItem -Path $path_code -File -Recurse +foreach ($file in $files) +{ + # Read the file line by line to determine the package name, ignoring comments + $packageName = $null + Get-Content -Path $file.FullName | ForEach-Object { + if ($_ -notmatch '^\s*//') + { + if ($_ -match '^package\s+(\w+)$') { + $packageName = $Matches[1] + return $false + } + } + } + + if ($packageName) + { + # Calculate relative path and prepend directory names to the file name + $relativePath = $file.FullName.Substring($path_code.Length + 1) + $relativeDir = Split-Path $relativePath -Parent + $relativeDir = $relativeDir.Replace('\', '_').Replace('/', '_') + + if ($relativeDir -ne '') { + $targetFileName = "$relativeDir" + "_" + $file.Name + } else { + $targetFileName = $file.Name + } + + # Determine target directory based on the package name + if ($packageName -eq $whitelist_package) { + $targetDir = $path_code_compiler_staged + } else { + $targetDir = Join-Path $path_code_compiler_staged $packageName + if (-not (Test-Path $targetDir)) { + New-Item -ItemType Directory -Path $targetDir + } + } + + $targetFilePath = Join-Path $targetDir $targetFileName + + # Check if the target file path already exists and handle it accordingly + if (-not (Test-Path $targetFilePath)) { + New-Item -ItemType SymbolicLink -Path $targetFilePath -Value $file.FullName + } else { + Write-Host "Warning: The link for $($file.FullName) already exists at $targetFilePath. Skipping..." + } + } + else { + Write-Host "Warning: The file $($file.FullName) does not contain a valid package declaration." + } +} + +Write-Host "Compiler staged directory structure created successfully."