mirror of
https://github.com/Ed94/refactor.git
synced 2025-07-01 03:11:06 -07:00
Compare commits
33 Commits
build_work
...
Release
Author | SHA1 | Date | |
---|---|---|---|
bdc272cc2b | |||
8d5cdec586 | |||
1d807eaf0a | |||
2fe7ded7ec | |||
1f2d3cdd42 | |||
03f5441b25 | |||
b05ee03609 | |||
e30539fe32 | |||
935bfe63ad | |||
d95d4a8d06 | |||
7d7c34d157 | |||
25df998dc2 | |||
9479a28282 | |||
0246b8419a | |||
0da1505190 | |||
d73d22282b | |||
78cdfcd7b3 | |||
018286be6f | |||
a0a3e42e6a | |||
f9b8f02351 | |||
5bfa8395db | |||
048fcac1bf | |||
eccbdac3b2 | |||
2933393f55 | |||
61880e8dee | |||
9bf6af8ce5 | |||
20dd92a684 | |||
be6b37ae00 | |||
e867768862 | |||
b08ff787a8 | |||
263fa66f7f | |||
6e9d35cb37 | |||
2176314adf |
67
.github/workflows/main.yml
vendored
67
.github/workflows/main.yml
vendored
@ -1,43 +1,76 @@
|
||||
# Name of the workflow
|
||||
name: Build
|
||||
|
||||
# Events used by github actions to know when to execute this workflow
|
||||
on:
|
||||
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
type:
|
||||
description: 'Meson buildtype (release, debug, etc.)'
|
||||
required: false
|
||||
|
||||
test:
|
||||
description: 'Run tests (test)'
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
runs-on:
|
||||
windows-latest
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install Meson, Ninja, and Clang with Scoop
|
||||
|
||||
- name: Install Meson, Ninja, and Clang with Chocolatey and pip
|
||||
shell: pwsh
|
||||
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
|
||||
scoop install meson ninja llvm
|
||||
if (-not (Get-Command choco -ErrorAction SilentlyContinue))
|
||||
{
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
|
||||
}
|
||||
|
||||
if (-not (choco list --local-only | Select-String "python"))
|
||||
{
|
||||
choco install -y python
|
||||
}
|
||||
|
||||
if (-not (choco list --local-only | Select-String "ninja"))
|
||||
{
|
||||
choco install -y ninja
|
||||
}
|
||||
|
||||
if (-not (choco list --local-only | Select-String "llvm"))
|
||||
{
|
||||
choco install -y llvm
|
||||
}
|
||||
|
||||
python -m pip install meson
|
||||
|
||||
|
||||
- name: Run PowerShell build script
|
||||
|
||||
shell: pwsh
|
||||
|
||||
env:
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
BUILD_TYPE: ${{ github.event.inputs.type }}
|
||||
RUN_TESTS: ${{ github.event.inputs.test }}
|
||||
|
||||
run: |
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
@ -48,4 +81,28 @@ jobs:
|
||||
if (-not [string]::IsNullOrEmpty($type)) { $args += $type }
|
||||
if (-not [string]::IsNullOrEmpty($test)) { $args += $test }
|
||||
|
||||
& .\scripts\build.ps1 @args
|
||||
& .\scripts\build.ci.ps1 debug test
|
||||
|
||||
- name: Get Short Commit SHA
|
||||
shell: pwsh
|
||||
run: |
|
||||
$shortSHA = $env:github_sha.Substring(0, 7)
|
||||
echo "Short SHA: $shortSHA"
|
||||
echo "SHORT_SHA=$shortSHA" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||
|
||||
- name: Create Package
|
||||
shell: pwsh
|
||||
run: |
|
||||
New-Item -ItemType Directory -Path "./artifact"
|
||||
Copy-Item "./build/refactor.exe" -Destination "./artifact/refactor.exe"
|
||||
|
||||
Compress-Archive -Path "./artifact/*" -DestinationPath "./artifact/refactor-${env:SHORT_SHA}.zip"
|
||||
|
||||
- name: Upload Release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
tag: Release
|
||||
artifacts: ./artifact/refactor-${env:SHORT_SHA}.zip
|
||||
omitBody: true
|
||||
# bodyFile: "body.md"
|
||||
allowUpdates: true
|
||||
|
@ -26,8 +26,7 @@ However, the rest of the categorical keywords (word, namespace), can really be u
|
||||
There is no semantic awareness this is truely just a simple find and replace, but with some filters specifiable, and
|
||||
words/namespaces only being restricted to the rules for C/C++ identifiers (alphanumeric or underscores only)
|
||||
|
||||
The main benefit for using this over alts is its problably more ergonomic and performant for large refactors on libraries that
|
||||
you may want to have automated in a script.
|
||||
The main benefit for using this over alts is its problably more ergonomic and performant for large refactors on libraries you may want to have automated in a script.
|
||||
|
||||
There are other programs more robust for doing that sort of thing but I was not able to find something this simple.
|
||||
|
||||
@ -44,6 +43,7 @@ TODO:
|
||||
|
||||
* Possibly come up with a better name.
|
||||
* Test to see how much needs to be ported for other platforms (if at all)
|
||||
* Setup as api.
|
||||
* Provide binaries in the release page for github. (debug and release builds)
|
||||
* Directive to ignore comments (with a way to specify the comment signature). Right now comments that meet the signature of words or namespaces are refactored.
|
||||
* Provide a GUI build.
|
||||
* Provide as a single-header library.
|
||||
|
@ -1,11 +1,14 @@
|
||||
#define BLOAT_IMPL
|
||||
#include "Bloat.hpp"
|
||||
|
||||
|
||||
namespace Global
|
||||
{
|
||||
bool ShouldShowDebug = false;
|
||||
}
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
static zpl_arena Global_Arena {};
|
||||
zpl_arena Global_Arena {};
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
@ -8,14 +8,6 @@
|
||||
# define ZPL_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#if __clang__
|
||||
# pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||
# pragma clang diagnostic ignored "-Wswitch"
|
||||
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#pragma region ZPL INCLUDE
|
||||
#if __clang__
|
||||
# pragma clang diagnostic push
|
||||
@ -48,6 +40,15 @@
|
||||
|
||||
|
||||
|
||||
#if __clang__
|
||||
# pragma clang diagnostic ignored "-Wunused-const-variable"
|
||||
# pragma clang diagnostic ignored "-Wswitch"
|
||||
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define bit( Value_ ) ( 1 << Value_ )
|
||||
#define bitfield_is_equal( Field_, Mask_ ) ( ( Mask_ & Field_ ) == Mask_ )
|
||||
#define ct constexpr
|
||||
@ -88,6 +89,11 @@ using Array_Line = zpl_array( Line );
|
||||
ct char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||
|
||||
|
||||
namespace Global
|
||||
{
|
||||
extern bool ShouldShowDebug;
|
||||
}
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
ct uw Initial_Reserve = zpl_megabytes(2);
|
||||
@ -103,10 +109,13 @@ namespace Memory
|
||||
// Had to be made to support multiple sub-arguments per "opt" argument.
|
||||
b32 opts_custom_compile(zpl_opts *opts, int argc, char **argv);
|
||||
|
||||
|
||||
inline
|
||||
sw log_fmt(char const *fmt, ...)
|
||||
{
|
||||
#if Build_Debug
|
||||
if ( Global::ShouldShowDebug == false )
|
||||
return 0;
|
||||
|
||||
sw res;
|
||||
va_list va;
|
||||
|
||||
@ -115,10 +124,6 @@ sw log_fmt(char const *fmt, ...)
|
||||
va_end(va);
|
||||
|
||||
return res;
|
||||
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
@ -142,9 +142,6 @@ namespace Spec
|
||||
bool ignore = false;
|
||||
Entry entry {};
|
||||
|
||||
log_fmt("\nIGNORE WORD COUNT: %d", zpl_array_count(Ignore_Words));
|
||||
|
||||
|
||||
// Find a valid token
|
||||
find_next_token( type, token, line, length );
|
||||
|
||||
@ -327,15 +324,5 @@ namespace Spec
|
||||
}
|
||||
}
|
||||
while ( lines++, left--, left > 0 );
|
||||
|
||||
Spec::Entry* ignore = Spec::Ignore_Words;
|
||||
sw ignores_left = zpl_array_count( Spec::Ignore_Words);
|
||||
|
||||
zpl_printf("\nIgnores: ");
|
||||
for ( ; ignores_left; ignores_left--, ignore++ )
|
||||
{
|
||||
zpl_printf("\n%s", ignore->Sig);
|
||||
}
|
||||
zpl_printf("\n");
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Spec.cpp"
|
||||
|
||||
|
||||
|
||||
void parse_options( int num, char** arguments )
|
||||
{
|
||||
zpl_opts opts;
|
||||
@ -12,21 +13,21 @@ void parse_options( int num, char** arguments )
|
||||
zpl_opts_add( & opts, "dst" , "dst" , "File/s post refactor" , ZPL_OPTS_STRING);
|
||||
zpl_opts_add( & opts, "spec", "spec", "Specification for refactoring", ZPL_OPTS_STRING);
|
||||
|
||||
#if Build_Debug
|
||||
zpl_opts_add( & opts, "debug", "debug", "Allows for wait to attach", ZPL_OPTS_FLAG);
|
||||
#endif
|
||||
|
||||
if (opts_custom_compile( & opts, num, arguments))
|
||||
{
|
||||
sw num = 0;
|
||||
|
||||
#if Build_Debug
|
||||
if ( zpl_opts_has_arg( & opts, "debug" ) )
|
||||
{
|
||||
#if Build_Debug
|
||||
zpl_printf("Will wait (pause available for attachment)");
|
||||
char pause = getchar();
|
||||
#endif
|
||||
|
||||
Global::ShouldShowDebug = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( zpl_opts_has_arg( & opts, "num" ) )
|
||||
{
|
||||
@ -49,8 +50,6 @@ void parse_options( int num, char** arguments )
|
||||
zpl_array_init_reserve( IO::Destinations, g_allocator, 1 );
|
||||
}
|
||||
|
||||
zpl_printf("NUM IS: %d", num);
|
||||
|
||||
if ( zpl_opts_has_arg( & opts, "src" ) )
|
||||
{
|
||||
zpl_string opt = zpl_opts_string( & opts, "src", "INVALID SRC ARGUMENT" );
|
||||
@ -589,10 +588,6 @@ void refactor()
|
||||
}
|
||||
|
||||
move_forward( 1 );
|
||||
|
||||
// zpl_string_clear( preview );
|
||||
// preview = zpl_string_append_length( preview, src, 100);
|
||||
// log_fmt( "__PREVIEW: %d \nn%s\n\n__PREVIEW_END", left, preview );
|
||||
}
|
||||
while ( left );
|
||||
End_Search:
|
||||
|
81
scripts/build.ci.ps1
Normal file
81
scripts/build.ci.ps1
Normal file
@ -0,0 +1,81 @@
|
||||
[string] $type = $null
|
||||
[string] $test = $false
|
||||
|
||||
foreach ( $arg in $args )
|
||||
{
|
||||
if ( $arg -eq "test" )
|
||||
{
|
||||
$test = $true
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = $arg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Regular Build
|
||||
|
||||
write-host "Building project`n"
|
||||
|
||||
$path_root = git rev-parse --show-toplevel
|
||||
$path_build = Join-Path $path_root build
|
||||
$path_scripts = Join-Path $path_root scripts
|
||||
|
||||
|
||||
if ( -not( Test-Path $path_build ) )
|
||||
{
|
||||
$args_meson = @()
|
||||
$args_meson += "setup"
|
||||
$args_meson += $path_build
|
||||
|
||||
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
|
||||
}
|
||||
|
||||
if ( $type )
|
||||
{
|
||||
$args_meson = @()
|
||||
$args_meson += "configure"
|
||||
$args_meson += $path_build
|
||||
$args_meson += "--buildtype $($type)"
|
||||
|
||||
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
|
||||
}
|
||||
|
||||
$args_ninja = @()
|
||||
$args_ninja += "-C"
|
||||
$args_ninja += $path_build
|
||||
|
||||
Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root
|
||||
#endregion Regular Build
|
||||
|
||||
|
||||
if ( $test -eq $true )
|
||||
{
|
||||
#region Test Build
|
||||
write-host "`n`nBuilding Test`n"
|
||||
|
||||
# Refactor thirdparty libraries
|
||||
& (Join-Path $PSScriptRoot 'refactor_and_format.ps1')
|
||||
|
||||
$path_test = Join-Path $path_root test
|
||||
$path_test_build = Join-Path $path_test build
|
||||
|
||||
if ( -not( Test-Path $path_test_build ) )
|
||||
{
|
||||
$args_meson = @()
|
||||
$args_meson += "setup"
|
||||
$args_meson += $path_test_build
|
||||
|
||||
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_test
|
||||
}
|
||||
|
||||
$args_ninja = @()
|
||||
$args_ninja += "-C"
|
||||
$args_ninja += $path_test_build
|
||||
|
||||
write-host $args_ninja
|
||||
|
||||
Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root
|
||||
#endregion Test Build
|
||||
}
|
@ -1,80 +1,2 @@
|
||||
cls
|
||||
|
||||
[string] $type = $null
|
||||
[string] $test = $false
|
||||
|
||||
foreach ( $arg in $args )
|
||||
{
|
||||
if ( $arg -eq "test" )
|
||||
{
|
||||
$test = $true
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = $arg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Regular Build
|
||||
write-host "Building project`n"
|
||||
|
||||
$path_root = git rev-parse --show-toplevel
|
||||
$path_build = Join-Path $path_root build
|
||||
$path_scripts = Join-Path $path_root scripts
|
||||
|
||||
|
||||
if ( -not( Test-Path $path_build ) )
|
||||
{
|
||||
$args_meson = @()
|
||||
$args_meson += "setup"
|
||||
$args_meson += $path_build
|
||||
|
||||
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
|
||||
}
|
||||
|
||||
if ( $type )
|
||||
{
|
||||
$args_meson = @()
|
||||
$args_meson += "configure"
|
||||
$args_meson += $path_build
|
||||
$args_meson += "--buildtype $($type)"
|
||||
|
||||
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
|
||||
}
|
||||
|
||||
$args_ninja = @()
|
||||
$args_ninja += "-C"
|
||||
$args_ninja += $path_build
|
||||
|
||||
Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_root
|
||||
#endregion Regular Build
|
||||
|
||||
|
||||
if ( $test -eq $true )
|
||||
{
|
||||
#region Test Build
|
||||
write-host "`n`nBuilding Test`n"
|
||||
|
||||
# Refactor thirdparty libraries
|
||||
& .\refactor_and_format.ps1
|
||||
|
||||
$path_test = Join-Path $path_root test
|
||||
$path_test_build = Join-Path $path_test build
|
||||
|
||||
if ( -not( Test-Path $path_test_build ) )
|
||||
{
|
||||
$args_meson = @()
|
||||
$args_meson += "setup"
|
||||
$args_meson += $path_test_build
|
||||
|
||||
Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_test
|
||||
}
|
||||
|
||||
$args_ninja = @()
|
||||
$args_ninja += "-C"
|
||||
$args_ninja += $path_test_build
|
||||
|
||||
Start-Process ninja $args_ninja -Wait -NoNewWindow -WorkingDirectory $path_test
|
||||
#endregion Test Build
|
||||
}
|
||||
& (Join-Path $PSScriptRoot 'build.ci.ps1')
|
||||
|
@ -18,4 +18,7 @@ if ( Test-Path $path_test_build )
|
||||
|
||||
$files = Get-ChildItem -Recurse -Path $path_test -Include $include -Exclude $exclude
|
||||
|
||||
Remove-Item $files
|
||||
if ( $files )
|
||||
{
|
||||
Remove-Item $files
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ if ( $false ){
|
||||
}
|
||||
else {
|
||||
$refactorParams = @(
|
||||
"-debug",
|
||||
# "-debug",
|
||||
"-num=$($targetFiles.Count)"
|
||||
"-src=$($targetFiles)",
|
||||
"-dst=$($refactoredFiles)",
|
||||
@ -86,7 +86,7 @@ foreach ( $file in $targetFiles )
|
||||
}
|
||||
|
||||
$refactorParams = @(
|
||||
"-debug",
|
||||
# "-debug",
|
||||
"-num=$($targetFiles.Count)"
|
||||
"-src=$($targetFiles)",
|
||||
"-dst=$($refactoredFiles)",
|
||||
|
Reference in New Issue
Block a user