mirror of
				https://github.com/Ed94/refactor.git
				synced 2025-10-31 06:50:55 -07:00 
			
		
		
		
	Setup new test and sucessfuly compiles!
This commit is contained in:
		
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -2,4 +2,6 @@ | ||||
|  | ||||
| build/* | ||||
|  | ||||
| zpl.refactored.h | ||||
| Test/*.h | ||||
| Test/*.hpp | ||||
| Test/*.cpp | ||||
|   | ||||
| @@ -4,7 +4,7 @@ project( 'refactor', 'c', 'cpp', default_options : ['buildtype=debug'] ) | ||||
|  | ||||
| if get_option('buildtype').startswith('debug') | ||||
|  | ||||
|   add_project_arguments('-DBuild_Debug', language : 'cpp') | ||||
|   add_project_arguments('-DBuild_Debug', language : ['c', 'cpp']) | ||||
|  | ||||
| endif | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,71 @@ | ||||
| __VERSION 1 | ||||
|  | ||||
| // not       : Ignore | ||||
| // include   : #includes | ||||
| // word      : Alphanumeric or underscore | ||||
| // namespace : Prefix search and replace (c-namspaces). | ||||
| // regex     : Unavailable in __VERSION 1.  | ||||
|  | ||||
| // Precedence (highest to lowest): | ||||
| // word, namespace, regex | ||||
|  | ||||
| // Comments | ||||
| not comments | ||||
|  | ||||
| // Includes | ||||
| include zpl.h, zpl.refactored.h | ||||
| include Bloat.hpp, Bloat.refactored.hpp | ||||
| include Bloat.cpp, Bloat.refactored.cpp | ||||
| include IO.hpp, IO.refactored.hpp | ||||
| include IO.cpp, IO.refactored.cpp | ||||
| include Spec.hpp, Spec.refactored.hpp | ||||
| include Spec.cpp, Spec.refactored.cpp | ||||
|  | ||||
| // Remove the zpl namespace. | ||||
| namespace zpl_ | ||||
|  | ||||
| // Don't expose zpl internals | ||||
| not namespace zpl__ | ||||
|  | ||||
| // Macro exposure | ||||
| //namespace ZPL_ | ||||
| //not word ZPL_IMPLEMENTATION | ||||
|  | ||||
| // Name conflicts | ||||
| word opts, options | ||||
|  | ||||
| word zpl_strncmp, str_compare | ||||
| word zpl_strcmp,  str_compare | ||||
|  | ||||
| // Undesired typedefs | ||||
| word zpl_i8,      s8 | ||||
| word zpl_i16,     s16 | ||||
| word zpl_i32,     s32 | ||||
| word zpl_i64,     s64 | ||||
| word zpl_u8,      u8 | ||||
| word zpl_u16,     u16 | ||||
| word zpl_u32,     u32 | ||||
| word zpl_u64,     u64 | ||||
| word zpl_intptr,  sptr | ||||
| word zpl_uintptr, uptr | ||||
| word zpl_usize,   uw | ||||
| word zpl_isize,   sw | ||||
|  | ||||
| // Conflicts with std. (Uncomment if using c externs) | ||||
| not word zpl_memchr | ||||
| not word zpl_memmove | ||||
| not word zpl_memset | ||||
| not word zpl_memswap | ||||
| not word zpl_memcopy | ||||
| not word zpl_printf | ||||
| not word zpl_printf_va | ||||
| not word zpl_printf_err | ||||
| not word zpl_printf_err_va | ||||
| not word zpl_fprintf | ||||
| not word zpl_fprintf_va | ||||
| not word zpl_snprintf | ||||
| not word zpl_snprintf_va | ||||
| not word zpl_strchr | ||||
| not word zpl_strlen | ||||
| not word zpl_strnlen | ||||
| not word zpl_exit | ||||
|   | ||||
| @@ -20,6 +20,8 @@ not include header/essentials/collections/array.h | ||||
| not include header/essentials/collections/list.h | ||||
| not include header/core/file.h | ||||
| not include header/opts.h | ||||
| not include source/core/file.c | ||||
| not include source/opts.c | ||||
|  | ||||
| // Removes the namespace. | ||||
| namespace zpl_ | ||||
| @@ -69,20 +71,20 @@ word opts,      a_opts | ||||
| word pool,      a_pool | ||||
|  | ||||
| // Conflicts with std. (Uncomment if using c externs) | ||||
| //not word zpl_memchr | ||||
| //not word zpl_memmove | ||||
| //not word zpl_memset | ||||
| //not word zpl_memswap | ||||
| //not word zpl_memcopy | ||||
| //not word zpl_printf | ||||
| //not word zpl_printf_va | ||||
| //not word zpl_printf_err | ||||
| //not word zpl_printf_err_va | ||||
| //not word zpl_fprintf | ||||
| //not word zpl_fprintf_va | ||||
| //not word zpl_snprintf | ||||
| //not word zpl_snprintf_va | ||||
| //not word zpl_strchr | ||||
| //not word zpl_strlen | ||||
| //not word zpl_strnlen | ||||
| //not word zpl_exit | ||||
| not word zpl_memchr | ||||
| not word zpl_memmove | ||||
| not word zpl_memset | ||||
| not word zpl_memswap | ||||
| not word zpl_memcopy | ||||
| not word zpl_printf | ||||
| not word zpl_printf_va | ||||
| not word zpl_printf_err | ||||
| not word zpl_printf_err_va | ||||
| not word zpl_fprintf | ||||
| not word zpl_fprintf_va | ||||
| not word zpl_snprintf | ||||
| not word zpl_snprintf_va | ||||
| not word zpl_strchr | ||||
| not word zpl_strlen | ||||
| not word zpl_strnlen | ||||
| not word zpl_exit | ||||
|   | ||||
| @@ -51,7 +51,7 @@ Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root | ||||
| #endregion Regular Build | ||||
|  | ||||
|  | ||||
| if ( $test -eq $true -and (Test-Path $path_build) ) | ||||
| if ( $test -eq $true ) | ||||
| { | ||||
| 	#region Test Build | ||||
| 	write-host "`n`nBuilding Test`n" | ||||
| @@ -68,12 +68,12 @@ if ( $test -eq $true -and (Test-Path $path_build) ) | ||||
| 		$args_meson += "setup" | ||||
| 		$args_meson += $path_test_build | ||||
|  | ||||
| 		Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts | ||||
| 		Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_test | ||||
| 	} | ||||
|  | ||||
| 	$args_ninja = @() | ||||
| 	$args_ninja += "-C" | ||||
| 	$args_ninja += $path_build | ||||
| 	$args_ninja += $path_test_build | ||||
|  | ||||
| 	Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_test | ||||
| 	#endregion Test Build | ||||
|   | ||||
| @@ -12,3 +12,10 @@ if ( Test-Path $path_test_build ) | ||||
| { | ||||
| 	Remove-Item $path_test_build -Recurse | ||||
| } | ||||
|  | ||||
| [string[]] $include = '*.h', '*.hpp', '*.cpp' | ||||
| [string[]] $exclude = | ||||
|  | ||||
| $files = Get-ChildItem -Recurse -Path $path_test -Include $include -Exclude $exclude | ||||
|  | ||||
| Remove-Item $files | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| [string[]] $include = 'refactor.cpp' #'*.c', '*.cc', '*.cpp' | ||||
| # [stirng[]] $exclude = | ||||
| # [string[]] $exclude = | ||||
|  | ||||
| $path_root = git rev-parse --show-toplevel | ||||
| $path_proj = Join-Path $path_root project | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| project( 'refactor', 'c', 'cpp', default_options : ['buildtype=debug'] ) | ||||
| project( 'refactor', 'c', 'cpp', default_options : ['buildtype=release'] ) | ||||
|  | ||||
| # add_global_arguments('-E', language : 'cpp') | ||||
|  | ||||
|   | ||||
| @@ -1,9 +1,10 @@ | ||||
| [string[]] $include = '*.h', '*.hh', '*.hpp', '*.c', '*.cc', '*.cpp' | ||||
| [string[]] $exclude = '*.g.*', '*.refactor', 'bloat.refactored.hpp', 'refactor.refactored.cpp' | ||||
| [string[]] $exclude = '*.g.*', '*.refactor' | ||||
|  | ||||
|  | ||||
| $path_root       = git rev-parse --show-toplevel | ||||
| $path_build      = Join-Path $path_root build | ||||
| $path_project    = Join-Path $path_root project | ||||
| $path_test       = Join-Path $path_root test | ||||
| $path_thirdparty = Join-Path $path_root thirdparty | ||||
|  | ||||
| @@ -11,27 +12,48 @@ $file_spec = Join-Path $path_test zpl.refactor | ||||
| $refactor  = Join-Path $path_build refactor.exe | ||||
|  | ||||
| # Gather the files to be formatted. | ||||
| $targetFiles = @(Get-ChildItem -Recurse -Path $path_thirdparty -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) | ||||
| $targetFiles     = @(Get-ChildItem -Recurse -Path $path_thirdparty -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) | ||||
| $refactoredFiles = @() | ||||
|  | ||||
|  | ||||
| write-host "Beginning refactor...`n" | ||||
|  | ||||
| $refactors = @(@()) | ||||
|  | ||||
| # TODO: Change this to support refactoring the other files in the project directory. | ||||
| # It needs two runs, one for the regular files, one for the zpl header. | ||||
| foreach ( $file in $targetFiles ) | ||||
| { | ||||
|     $destination = Join-Path $path_test (Split-Path $file -leaf) | ||||
|     $destination = $destination.Replace( '.h', '.refactored.h' ) | ||||
|     $destination = $destination.Replace( '.c', '.refactored.c' ) | ||||
|  | ||||
|     $refactoredFiles += $destination | ||||
| } | ||||
|  | ||||
|  | ||||
| write-host "Beginning thirdpary refactor...`n" | ||||
|  | ||||
| $refactors = @(@()) | ||||
|  | ||||
| if ( $false ){ | ||||
|     foreach ( $file in $targetFiles ) | ||||
|     { | ||||
|         $destination = Join-Path $path_test (Split-Path $file -leaf) | ||||
|         $destination = $destination.Replace( '.h', '.refactored.h' ) | ||||
|          | ||||
|         $refactorParams = @( | ||||
|             "-src=$($file)", | ||||
|             "-dst=$($destination)" | ||||
|             "-spec=$($file_spec)" | ||||
|         ) | ||||
|  | ||||
|         $refactors += (Start-Process $refactor $refactorParams -NoNewWindow -PassThru) | ||||
|     } | ||||
| } | ||||
| else { | ||||
|     $refactorParams = @( | ||||
|         "-src=$($file)", | ||||
|         "-dst=$($destination)" | ||||
|         "-debug", | ||||
|         "-num=$($targetFiles.Count)" | ||||
|         "-src=$($targetFiles)", | ||||
|         "-dst=$($refactoredFiles)", | ||||
|         "-spec=$($file_spec)" | ||||
|     ) | ||||
|  | ||||
|     $refactors += (Start-Process $refactor $refactorParams -NoNewWindow -PassThru) | ||||
|     Start-Process $refactor $refactorParams -NoNewWindow -PassThru -Wait | ||||
| } | ||||
|  | ||||
| foreach ( $process in $refactors ) | ||||
| @@ -44,10 +66,40 @@ foreach ( $process in $refactors ) | ||||
|  | ||||
| Write-Host "`nRefactoring complete`n`n" | ||||
|  | ||||
| write-host "Beginning project refactor...`n" | ||||
|  | ||||
| # Gather the files to be formatted. | ||||
| $targetFiles  = @(Get-ChildItem -Recurse -Path $path_project -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName) | ||||
| $refactoredFiles = @() | ||||
|  | ||||
| $file_spec = Join-Path $path_test project.refactor | ||||
|  | ||||
| write-host "FILE SPEC:" $file_spec | ||||
|  | ||||
| foreach ( $file in $targetFiles ) | ||||
| { | ||||
|     $destination = Join-Path $path_test (Split-Path $file -leaf) | ||||
|     $destination = $destination.Replace( '.hpp', '.refactored.hpp' ) | ||||
|     $destination = $destination.Replace( '.cpp', '.refactored.cpp' ) | ||||
|  | ||||
|     $refactoredFiles += $destination | ||||
| } | ||||
|  | ||||
| $refactorParams = @( | ||||
|     "-debug", | ||||
|     "-num=$($targetFiles.Count)" | ||||
|     "-src=$($targetFiles)", | ||||
|     "-dst=$($refactoredFiles)", | ||||
|     "-spec=$($file_spec)" | ||||
| ) | ||||
|  | ||||
| Start-Process $refactor $refactorParams -NoNewWindow -PassThru -Wait | ||||
|  | ||||
| write-host "`nRefactoring complete`n`n" | ||||
|  | ||||
|  | ||||
| # Can't format zpl library... (It hangs clang format) | ||||
| if ( $false ) | ||||
| { | ||||
| if ( $false ) { | ||||
| Write-Host "Beginning format...`n" | ||||
|  | ||||
| # Format the files. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user