Setup new test and sucessfuly compiles!

This commit is contained in:
Edward R. Gonzalez 2023-03-30 17:36:36 -04:00
parent c4f0b35a30
commit 503df85733
9 changed files with 173 additions and 39 deletions

4
.gitignore vendored
View File

@ -2,4 +2,6 @@
build/* build/*
zpl.refactored.h Test/*.h
Test/*.hpp
Test/*.cpp

View File

@ -4,7 +4,7 @@ project( 'refactor', 'c', 'cpp', default_options : ['buildtype=debug'] )
if get_option('buildtype').startswith('debug') if get_option('buildtype').startswith('debug')
add_project_arguments('-DBuild_Debug', language : 'cpp') add_project_arguments('-DBuild_Debug', language : ['c', 'cpp'])
endif endif

View File

@ -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

View File

@ -20,6 +20,8 @@ not include header/essentials/collections/array.h
not include header/essentials/collections/list.h not include header/essentials/collections/list.h
not include header/core/file.h not include header/core/file.h
not include header/opts.h not include header/opts.h
not include source/core/file.c
not include source/opts.c
// Removes the namespace. // Removes the namespace.
namespace zpl_ namespace zpl_
@ -69,20 +71,20 @@ word opts, a_opts
word pool, a_pool word pool, a_pool
// Conflicts with std. (Uncomment if using c externs) // Conflicts with std. (Uncomment if using c externs)
//not word zpl_memchr not word zpl_memchr
//not word zpl_memmove not word zpl_memmove
//not word zpl_memset not word zpl_memset
//not word zpl_memswap not word zpl_memswap
//not word zpl_memcopy not word zpl_memcopy
//not word zpl_printf not word zpl_printf
//not word zpl_printf_va not word zpl_printf_va
//not word zpl_printf_err not word zpl_printf_err
//not word zpl_printf_err_va not word zpl_printf_err_va
//not word zpl_fprintf not word zpl_fprintf
//not word zpl_fprintf_va not word zpl_fprintf_va
//not word zpl_snprintf not word zpl_snprintf
//not word zpl_snprintf_va not word zpl_snprintf_va
//not word zpl_strchr not word zpl_strchr
//not word zpl_strlen not word zpl_strlen
//not word zpl_strnlen not word zpl_strnlen
//not word zpl_exit not word zpl_exit

View File

@ -51,7 +51,7 @@ Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root
#endregion Regular Build #endregion Regular Build
if ( $test -eq $true -and (Test-Path $path_build) ) if ( $test -eq $true )
{ {
#region Test Build #region Test Build
write-host "`n`nBuilding Test`n" write-host "`n`nBuilding Test`n"
@ -68,12 +68,12 @@ if ( $test -eq $true -and (Test-Path $path_build) )
$args_meson += "setup" $args_meson += "setup"
$args_meson += $path_test_build $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 = @()
$args_ninja += "-C" $args_ninja += "-C"
$args_ninja += $path_build $args_ninja += $path_test_build
Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_test Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_test
#endregion Test Build #endregion Test Build

View File

@ -12,3 +12,10 @@ if ( Test-Path $path_test_build )
{ {
Remove-Item $path_test_build -Recurse 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

View File

@ -1,5 +1,5 @@
[string[]] $include = 'refactor.cpp' #'*.c', '*.cc', '*.cpp' [string[]] $include = 'refactor.cpp' #'*.c', '*.cc', '*.cpp'
# [stirng[]] $exclude = # [string[]] $exclude =
$path_root = git rev-parse --show-toplevel $path_root = git rev-parse --show-toplevel
$path_proj = Join-Path $path_root project $path_proj = Join-Path $path_root project

View File

@ -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') # add_global_arguments('-E', language : 'cpp')

View File

@ -1,9 +1,10 @@
[string[]] $include = '*.h', '*.hh', '*.hpp', '*.c', '*.cc', '*.cpp' [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_root = git rev-parse --show-toplevel
$path_build = Join-Path $path_root build $path_build = Join-Path $path_root build
$path_project = Join-Path $path_root project
$path_test = Join-Path $path_root test $path_test = Join-Path $path_root test
$path_thirdparty = Join-Path $path_root thirdparty $path_thirdparty = Join-Path $path_root thirdparty
@ -12,14 +13,23 @@ $refactor = Join-Path $path_build refactor.exe
# Gather the files to be formatted. # 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 = @()
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 refactor...`n" write-host "Beginning thirdpary refactor...`n"
$refactors = @(@()) $refactors = @(@())
# TODO: Change this to support refactoring the other files in the project directory. if ( $false ){
# It needs two runs, one for the regular files, one for the zpl header.
foreach ( $file in $targetFiles ) foreach ( $file in $targetFiles )
{ {
$destination = Join-Path $path_test (Split-Path $file -leaf) $destination = Join-Path $path_test (Split-Path $file -leaf)
@ -33,6 +43,18 @@ foreach ( $file in $targetFiles )
$refactors += (Start-Process $refactor $refactorParams -NoNewWindow -PassThru) $refactors += (Start-Process $refactor $refactorParams -NoNewWindow -PassThru)
} }
}
else {
$refactorParams = @(
"-debug",
"-num=$($targetFiles.Count)"
"-src=$($targetFiles)",
"-dst=$($refactoredFiles)",
"-spec=$($file_spec)"
)
Start-Process $refactor $refactorParams -NoNewWindow -PassThru -Wait
}
foreach ( $process in $refactors ) foreach ( $process in $refactors )
{ {
@ -44,10 +66,40 @@ foreach ( $process in $refactors )
Write-Host "`nRefactoring complete`n`n" 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) # Can't format zpl library... (It hangs clang format)
if ( $false ) if ( $false ) {
{
Write-Host "Beginning format...`n" Write-Host "Beginning format...`n"
# Format the files. # Format the files.