mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-07-23 16:07:50 +00:00
reduce cruft
This commit is contained in:
+6
-38
@@ -317,36 +317,14 @@ function build-graphis_hello {
|
||||
}
|
||||
# build-graphis_hello
|
||||
|
||||
# ps1-meta orchestrator. Replaces generate-TapeAtomOffsets +
|
||||
# generate-TapeAtomAnnotations with a single invocation. Dispatches
|
||||
# the 6 passes (word-counts / components / annotation / offsets /
|
||||
# static-analysis / report) in dependency-topological order.
|
||||
|
||||
function any-stale {
|
||||
param([Parameter(Mandatory=$true)][string[]]$sources,
|
||||
[Parameter(Mandatory=$true)][string]$metadata,
|
||||
[Parameter(Mandatory=$true)][string]$out_root)
|
||||
# Always return true. ps1-meta writes to TWO locations:
|
||||
# 1. <out_root> (annotation + offsets passes — build/gen/)
|
||||
# 2. <src.dir>/gen/ (component pass — code/duffle/gen/, etc.)
|
||||
# Tracking only <out_root>'s mtime is fragile — if the in-source
|
||||
# gen dir was wiped but <out_root> still exists with a newer mtime,
|
||||
# we'd skip the regen and the compile would fail with a missing
|
||||
# duffle.macs.h. ps1-meta is fast enough (~100ms) that always
|
||||
# running it is the safe default.
|
||||
return $true
|
||||
}
|
||||
|
||||
function ps1-meta {
|
||||
param(
|
||||
function ps1-meta { param(
|
||||
[Parameter(Mandatory=$true)][string[]]$sources,
|
||||
[Parameter(Mandatory=$true)][string]$metadata,
|
||||
[string]$out_root = (join-path $path_build 'gen'),
|
||||
[string[]]$passes = @('--all')
|
||||
[string[]]$passes = @('--all')
|
||||
)
|
||||
$script = join-path $path_scripts 'ps1_meta.lua'
|
||||
write-host "ps1-meta $($sources.Count) source(s), passes=$($passes -join ',')" `
|
||||
-ForegroundColor Magenta
|
||||
write-host "ps1-meta $($sources.Count) source(s), passes=$($passes -join ',')" ` -ForegroundColor Magenta
|
||||
$arg_list = @($passes) + @('--metadata', $metadata) + @('--out-root', $out_root)
|
||||
foreach ($s in $sources) { $arg_list += @('--source', $s) }
|
||||
& luajit $script @arg_list
|
||||
@@ -365,13 +343,7 @@ function build-gte_hello {
|
||||
|
||||
$source_dirs = @($path_duffle, $path_module)
|
||||
$atom_sources = Get-SourceFiles -paths $source_dirs -extensions @('.h', '.c')
|
||||
|
||||
if (any-stale -sources $atom_sources -metadata $path_atom_metadata -out_root (join-path $path_build 'gen')) {
|
||||
ps1-meta -sources $atom_sources -metadata $path_atom_metadata -out_root (join-path $path_build 'gen')
|
||||
} else {
|
||||
write-host "ps1-meta all $($atom_sources.Count) source(s) up-to-date" `
|
||||
-ForegroundColor DarkGray
|
||||
}
|
||||
ps1-meta -sources $atom_sources -metadata $path_atom_metadata -out_root (join-path $path_build 'gen')
|
||||
|
||||
$assemble_args = @()
|
||||
$assemble_args += $f_debug
|
||||
@@ -416,18 +388,14 @@ build-gte_hello
|
||||
|
||||
|
||||
# NO idea if this works yet...
|
||||
function Send-ToEmulator { param(
|
||||
[string]$exePath
|
||||
)
|
||||
function Send-ToEmulator { param( [string]$exePath )
|
||||
$uri = "http://localhost:8080/api/v1/load-exec"
|
||||
|
||||
# Absolute path is safest for the emulator web server
|
||||
$absolutePath = [System.IO.Path]::GetFullPath($exePath)
|
||||
|
||||
# Create JSON payload pointing to your compiled .ps-exe
|
||||
$body = @{
|
||||
filename = $absolutePath
|
||||
} | ConvertTo-Json
|
||||
$body = @{ filename = $absolutePath } | ConvertTo-Json
|
||||
|
||||
Write-Host "Pushing hot-reload to PCSX-Redux..." -ForegroundColor Magenta
|
||||
try {
|
||||
|
||||
@@ -184,12 +184,25 @@ function M.write_file(path, content)
|
||||
f:close()
|
||||
end
|
||||
|
||||
-- Cache of directories already verified to exist in this process. Each
|
||||
-- ensure_dir() call may otherwise spawn a `cmd.exe mkdir` (50-100ms
|
||||
-- per call on Windows) — calling it inside per-source loops added 1.5+
|
||||
-- seconds to the report pass. Cache makes ensure_dir idempotent within
|
||||
-- the process lifetime (safe across passes; the dir state doesn't change).
|
||||
local _ensured_dirs = {}
|
||||
|
||||
function M.ensure_dir(path)
|
||||
if _ensured_dirs[path] then return end
|
||||
_ensured_dirs[path] = true
|
||||
local is_win = package.config:sub(1, 1) == "\\"
|
||||
os.execute(is_win and ('if not exist "' .. path .. '" mkdir "' .. path .. '"')
|
||||
or ('mkdir -p "' .. path .. '" 2>/dev/null'))
|
||||
end
|
||||
|
||||
-- Test helper: clear the cache (used by tests + between process runs).
|
||||
-- Not normally needed since Lua state is per-process.
|
||||
function M._reset_ensured_dirs() _ensured_dirs = {} end
|
||||
|
||||
-- ════════════════════════════════════════════════════════════════════════════
|
||||
-- Section 4: C-language scanner primitives
|
||||
-- ════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -763,4 +763,4 @@ function M.run(ctx)
|
||||
return { outputs = outputs, errors = errors, warnings = warnings }
|
||||
end
|
||||
|
||||
return M
|
||||
return M
|
||||
|
||||
@@ -688,4 +688,4 @@ function M.run(ctx)
|
||||
return { outputs = outputs, errors = errors, warnings = warnings }
|
||||
end
|
||||
|
||||
return M
|
||||
return M
|
||||
|
||||
@@ -162,12 +162,13 @@ function M.run(ctx)
|
||||
local annot_results = (ctx.flags and ctx.flags._annot_results) or {}
|
||||
|
||||
-- Render per-source reports.
|
||||
-- Hoist ensure_dir out of the loop (cache + hoisting = single mkdir).
|
||||
if not ctx.dry_run then ensure_dir(ctx.out_root) end
|
||||
for _, entry in ipairs(annot_results) do
|
||||
local src = entry.source
|
||||
local result = entry.result
|
||||
local out_path = ctx.out_root .. "/" .. src.basename .. ".annotations.txt"
|
||||
if not ctx.dry_run then
|
||||
ensure_dir(ctx.out_root)
|
||||
write_file(out_path, render_source_report(src.path, result))
|
||||
end
|
||||
table.insert(outputs, { annotations_txt = out_path })
|
||||
@@ -177,12 +178,12 @@ function M.run(ctx)
|
||||
if not ctx.dry_run then
|
||||
-- The project report references each source by its absolute path.
|
||||
-- Augment the entries with a .source field for the per-source error counts.
|
||||
-- ensure_dir was already hoisted above; cache makes this a no-op.
|
||||
local all_results = {}
|
||||
for _, entry in ipairs(annot_results) do
|
||||
entry.result.source = entry.source.path
|
||||
table.insert(all_results, entry.result)
|
||||
end
|
||||
ensure_dir(ctx.out_root)
|
||||
local summary_path = ctx.out_root .. "/annotation_validation.txt"
|
||||
write_file(summary_path, render_project_report(all_results))
|
||||
table.insert(outputs, { summary_txt = summary_path })
|
||||
@@ -191,4 +192,4 @@ function M.run(ctx)
|
||||
return { outputs = outputs, errors = errors, warnings = warnings }
|
||||
end
|
||||
|
||||
return M
|
||||
return M
|
||||
|
||||
@@ -570,4 +570,4 @@ local function main(argv)
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
main({...})
|
||||
main({...})
|
||||
|
||||
Reference in New Issue
Block a user