@ -187,7 +187,7 @@ namespace eval ::punkboot {
variable foldername [ file tail $scriptfolder ]
variable foldername [ file tail $scriptfolder ]
variable pkg_requirements [ list ] ; variable pkg_missing [ list ] ; variable pkg_loaded [ list ]
variable pkg_requirements [ list ] ; variable pkg_missing [ list ] ; variable pkg_loaded [ list ]
variable help_flags [ list - help - - help / ? - h]
variable help_flags [ list - help - - help / ? - h]
variable known_commands [ list bakehouse packages modules libs bake bakelist vfslibs bin info check shell vendorupdate bootsupport vfscommonupdate projectversion workflow buildsuite project vfs]
variable known_commands [ list bakehouse packages modules libs bake bakelist vfslibs bin info check shell vendorupdate bootsupport vfscommonupdate projectversion workflow buildsuite tool project vfs]
}
}
@ -2152,6 +2152,11 @@ proc ::punkboot::punkboot_gethelp {args} {
append h " $ s c r i p t n a m e b u i l d s u i t e l i s t | i n f o | b u i l d ? < s u i t e n a m e > ? ? d r i v e r - a r g s . . . ? " \ n
append h " $ s c r i p t n a m e b u i l d s u i t e l i s t | i n f o | b u i l d ? < s u i t e n a m e > ? ? d r i v e r - a r g s . . . ? " \ n
append h " - l i s t t h e d e f i n e d b u i l d s u i t e s u n d e r s r c / b u i l d s u i t e s ( z i g r u n t i m e f a c t o r y ) , s h o w a s u i t e ' s c o n f i g u r e d " \ n
append h " - l i s t t h e d e f i n e d b u i l d s u i t e s u n d e r s r c / b u i l d s u i t e s ( z i g r u n t i m e f a c t o r y ) , s h o w a s u i t e ' s c o n f i g u r e d " \ n
append h " d e t a i l ( s o u r c e s / z i g p i n / p r o d u c t s f r o m i t s s o u r c e s . c o n f i g ) , o r r u n i t s d r i v e r f o r w a r d i n g t h e a r g s " \ n \ n
append h " d e t a i l ( s o u r c e s / z i g p i n / p r o d u c t s f r o m i t s s o u r c e s . c o n f i g ) , o r r u n i t s d r i v e r f o r w a r d i n g t h e a r g s " \ n \ n
append h " $ s c r i p t n a m e t o o l l i s t | i n f o | b u i l d | t e s t ? < t o o l n a m e > . . . ? ? - t e s t 0 | 1 ? " \ n
append h " - v e n d o r e d f i r s t - p a r t y b u i l d t o o l s u n d e r s r c / t o o l s ( z i g s o u r c e ; G - 1 2 6 ) : l i s t / d e t a i l t h e m , r u n t h e i r " \ n
append h " t e s t s u i t e s , o r b u i l d ( t e s t - g a t e d ) a n d i n s t a l l t o < p r o j e c t d i r > / b i n " \ n
append h " - z i g i s O P T I O N A L : p a c k a g e s / b a k e n e v e r r e q u i r e t h i s s t e p ; w i t h o u t a s u i t a b l e t o o l c h a i n t h e s t a t e i s " \ n
append h " r e p o r t e d a n d b u i l d / t e s t e x i t n o n z e r o w i t h f e t c h g u i d a n c e ( b i n / p u n k - g e t z i g . c m d ) " \ n \ n
append h " $ s c r i p t n a m e h e l p ? s u b c o m m a n d ? " \ n
append h " $ s c r i p t n a m e h e l p ? s u b c o m m a n d ? " \ n
append h " - s h o w u s a g e f o r $ s c r i p t n a m e o r o n e o f i t s s u b c o m m a n d s ( e q u i v a l e n t : $ s c r i p t n a m e < s u b c o m m a n d > - h e l p ) " \ n \ n
append h " - s h o w u s a g e f o r $ s c r i p t n a m e o r o n e o f i t s s u b c o m m a n d s ( e q u i v a l e n t : $ s c r i p t n a m e < s u b c o m m a n d > - h e l p ) " \ n \ n
append h " D e p r e c a t e d a l i a s e s ( t r a n s i t i o n w i n d o w ) : " \ n
append h " D e p r e c a t e d a l i a s e s ( t r a n s i t i o n w i n d o w ) : " \ n
@ -2402,6 +2407,14 @@ KEY / NOTES
with binary dependencies, and version-preference outcomes are visible only to
with binary dependencies, and version-preference outcomes are visible only to
the smoke probe - and only for declared packages. ' make.tcl check' reports both.
the smoke probe - and only for declared packages. ' make.tcl check' reports both.
OUT-OF-BAND SUBSYSTEMS ( not part of the packages/ bake data flow above)
' make.tcl tool' builds the vendored first-party zig tools under src/ tools
( G-126 ; punkzip first) into < projectdir> / bin, gated on each tree' s own
' zig build test' exit code. zig is OPTIONAL: packages/ bake never require it.
' make.tcl buildsuite' is the analogous arm' s-length factory for whole Tcl
runtimes built from EXTERNAL sources under src/ buildsuites ( fetch + test-gate
contract per suite; products land in the bin/ runtime store tiers) .
MAINTENANCE ( agents take note)
MAINTENANCE ( agents take note)
----------------------------------------------------------------------------
----------------------------------------------------------------------------
This text is embedded in make.tcl ( : : punkboot : : workflow_text) . When the build
This text is embedded in make.tcl ( : : punkboot : : workflow_text) . When the build
@ -2514,6 +2527,7 @@ if {[info exists ::env(PUNKBOOT_PLAIN)] && [string is true -strict $::env(PUNKBO
shell " R u n t h e p u n k s h e l l u s i n g b o o t s u p p o r t l i b r a r i e s "
shell " R u n t h e p u n k s h e l l u s i n g b o o t s u p p o r t l i b r a r i e s "
help " S h o w u s a g e f o r m a k e . t c l o r o n e o f i t s s u b c o m m a n d s "
help " S h o w u s a g e f o r m a k e . t c l o r o n e o f i t s s u b c o m m a n d s "
buildsuite " L i s t , d e s c r i b e o r r u n t h e d e f i n e d b u i l d s u i t e s u n d e r s r c / b u i l d s u i t e s ( z i g r u n t i m e f a c t o r y ) "
buildsuite " L i s t , d e s c r i b e o r r u n t h e d e f i n e d b u i l d s u i t e s u n d e r s r c / b u i l d s u i t e s ( z i g r u n t i m e f a c t o r y ) "
tool " L i s t , t e s t o r b u i l d t h e v e n d o r e d t o o l s u n d e r s r c / t o o l s ( z i g ) a n d i n s t a l l t h e m t o < p r o j e c t d i r > / b i n "
project " D E P R E C A T E D a l i a s f o r b a k e h o u s e ( o n e - l i n e n o t i c e , t h e n r u n s b a k e h o u s e ) "
project " D E P R E C A T E D a l i a s f o r b a k e h o u s e ( o n e - l i n e n o t i c e , t h e n r u n s b a k e h o u s e ) "
vfs " D E P R E C A T E D a l i a s f o r b a k e ( o n e - l i n e n o t i c e , t h e n r u n s b a k e ) "
vfs " D E P R E C A T E D a l i a s f o r b a k e ( o n e - l i n e n o t i c e , t h e n r u n s b a k e ) "
}
}
@ -2683,6 +2697,45 @@ if {[info exists ::env(PUNKBOOT_PLAIN)] && [string is true -strict $::env(PUNKBO
( copy-and-tweak workflow) appears here automatically with no
( copy-and-tweak workflow) appears here automatically with no
make.tcl edits. The contract is documented in
make.tcl edits. The contract is documented in
src / buildsuites/ README.md."
src / buildsuites/ README.md."
tool
"
Surface for the vendored first-party build tools under src/ tools
( G-126 : zig source vendored in full; boundary and editing policy in
src / tools/ AGENTS.md, per-tree origin/ licence records in
< tool > / PROVENANCE.md) . Discovery is convention-based: a directory
under src/ tools carrying build.zig is a tool; its installed
artifact is < projectdir> / bin/ < name> with the host executable
suffix.
Actions :
tool list
Discover the tools with version ( build.zig.zon ) , declared zig
floor , installed-binary state ( current | stale| absent) and the
vendored upstream commit; report the resolved toolchain.
tool info < name> ...
Per-tool detail: paths, provenance records, toolchain
resolution.
tool build ? < name> ...? ? - test 0 | 1 ?
Resolve a zig satisfying the tool' s declared floor, run the
' zig build test' gate ( default on; the gate is the EXIT CODE -
expected warnings on stderr do not fail it) , build ReleaseSafe
and install to < projectdir> / bin. Nothing is installed when the
gate or the build fails. With no name, all tools are
processed.
tool test ? < name> ...?
Run each tool' s ' zig build test' only.
Toolchain resolution: PUNK_ZIG= < path-to-zig-or-its-folder>
overrides ; otherwise < projectdir> / bin/ tools/ zig* is scanned and
the LOWEST release satisfying the floor wins ( deterministic as
newer toolchains appear beside the pinned one; dev builds count
only when their base version exceeds the floor) . zig is OPTIONAL
for punkshell builds: packages/ bake never require this step -
without a suitable toolchain, list reports the state and
build / test exit nonzero with fetch guidance
( bin / punk-getzig.cmd) . Build caches ( .zig-cache / zig-out) are
deliberately left in place between runs for rebuild speed ( both
git- and fossil-ignored) ."
project
project
"
"
DEPRECATED alias for ' bakehouse' ( G-112 stage-true rename) - prints a
DEPRECATED alias for ' bakehouse' ( G-112 stage-true rename) - prints a
@ -2855,6 +2908,15 @@ if {[info exists ::env(PUNKBOOT_PLAIN)] && [string is true -strict $::env(PUNKBO
arg - type any - optional 1 - multiple 1 - help\
arg - type any - optional 1 - multiple 1 - help\
" A c t i o n ( l i s t | i n f o | b u i l d ) , s u i t e n a m e , a n d - f o r b u i l d - d r i v e r
" A c t i o n ( l i s t | i n f o | b u i l d ) , s u i t e n a m e , a n d - f o r b u i l d - d r i v e r
arguments forwarded to the suite' s suite.tcl untouched." }
arguments forwarded to the suite' s suite.tcl untouched." }
punk : : args::define\
" @ i d - i d ( s c r i p t ) : : p u n k b o o t : : t o o l " \
" @ n o r m a l i z e " \
" @ c m d - n a m e [ l i s t " m a k e . t c l t o o l " ] - s u m m a r y [ l i s t [ d i c t g e t $ S U M M A R I E S t o o l ] ] - h e l p [ l i s t [ d i c t g e t $ H E L P T E X T S t o o l ] ] " \
{ @ form - synopsis " m a k e . t c l t o o l l i s t | i n f o | b u i l d | t e s t ? < t o o l n a m e > . . . ? ? - t e s t 0 | 1 ? " } \
{ @ values - min 0 - max - 1
arg - type any - optional 1 - multiple 1 - help\
" A c t i o n ( l i s t | i n f o | b u i l d | t e s t ) , t o o l n a m e ( s ) , a n d - f o r b u i l d -
the - test 0 | 1 gate flag. Parsed by the handler." }
punk : : args::define\
punk : : args::define\
" @ i d - i d ( s c r i p t ) : : p u n k b o o t : : h e l p " \
" @ i d - i d ( s c r i p t ) : : p u n k b o o t : : h e l p " \
" @ n o r m a l i z e " \
" @ n o r m a l i z e " \
@ -2871,6 +2933,7 @@ if {[info exists ::env(PUNKBOOT_PLAIN)] && [string is true -strict $::env(PUNKBO
" p r o m o t i o n g a t e s " { bootsupport vfscommonupdate}
" p r o m o t i o n g a t e s " { bootsupport vfscommonupdate}
" s o u r c e m a i n t e n a n c e " { vendorupdate }
" s o u r c e m a i n t e n a n c e " { vendorupdate }
" b u i l d s u i t e s " { buildsuite }
" b u i l d s u i t e s " { buildsuite }
" v e n d o r e d t o o l s " { tool }
" i n f o r m a t i o n a l " { info check bakelist projectversion workflow help}
" i n f o r m a t i o n a l " { info check bakelist projectversion workflow help}
" i n t e r a c t i v e " { shell }
" i n t e r a c t i v e " { shell }
" d e p r e c a t e d a l i a s e s " { project vfs}
" d e p r e c a t e d a l i a s e s " { project vfs}
@ -2963,6 +3026,10 @@ if {$::punkboot::punkargs_ok} {
# a r g s ( a r b i t r a r y s u i t e f l a g s ) a r e f o r w a r d e d u n t o u c h e d ( G - 1 0 4 )
# a r g s ( a r b i t r a r y s u i t e f l a g s ) a r e f o r w a r d e d u n t o u c h e d ( G - 1 0 4 )
set : : punkboot::command buildsuite
set : : punkboot::command buildsuite
set : : punkboot::bs_args $subargs
set : : punkboot::bs_args $subargs
} elseif { $subcommand eq " t o o l " } {
# d e c l a r e d p a s s t h r o u g h : t h e h a n d l e r p a r s e s a c t i o n / n a m e s / - t e s t i t s e l f ( G - 1 2 6 )
set : : punkboot::command tool
set : : punkboot::tool_args $subargs
} else {
} else {
if { [ catch { punk : : args::parse $subargs - errorstyle $::punkboot::errstyle withid ( script ) : : punkboot::$subcommand } argd] } {
if { [ catch { punk : : args::parse $subargs - errorstyle $::punkboot::errstyle withid ( script ) : : punkboot::$subcommand } argd] } {
puts stderr $argd
puts stderr $argd
@ -2993,6 +3060,12 @@ if {$::punkboot::punkargs_ok} {
set commands_found [ list buildsuite]
set commands_found [ list buildsuite]
set argsleft [ list ]
set argsleft [ list ]
set : : punkboot::bs_args [ lrange $scriptargs 1 end]
set : : punkboot::bs_args [ lrange $scriptargs 1 end]
} elseif { [ lindex $scriptargs 0 ] eq " t o o l " } {
# d e c l a r e d p a s s t h r o u g h ( a s i n t h e p u n k : : a r g s p a t h ) - t h e h a n d l e r p a r s e s
# a c t i o n / n a m e s / - t e s t i t s e l f ( G - 1 2 6 )
set commands_found [ list tool]
set argsleft [ list ]
set : : punkboot::tool_args [ lrange $scriptargs 1 end]
}
}
while { [ llength $argsleft ] } {
while { [ llength $argsleft ] } {
set a [ lindex $argsleft 0 ]
set a [ lindex $argsleft 0 ]
@ -3116,7 +3189,8 @@ set forcekill $::punkboot::opt_forcekill
# - p a t c h b u m p - > w a r n a n d p r o c e e d ( n o n - b r e a k i n g )
# - p a t c h b u m p - > w a r n a n d p r o c e e d ( n o n - b r e a k i n g )
# ' c h e c k ' i s e x e m p t i n a l l c a s e s — t h e w a r n i n g i s s h o w n a t t h e e n d o f i t s o u t p u t i n s t e a d .
# ' c h e c k ' i s e x e m p t i n a l l c a s e s — t h e w a r n i n g i s s h o w n a t t h e e n d o f i t s o u t p u t i n s t e a d .
# ' p r o j e c t v e r s i o n ' , ' w o r k f l o w ' a n d ' b a k e l i s t ' a r e i n f o r m a t i o n a l / r e a d - o n l y a n d a r e l i k e w i s e e x e m p t .
# ' p r o j e c t v e r s i o n ' , ' w o r k f l o w ' a n d ' b a k e l i s t ' a r e i n f o r m a t i o n a l / r e a d - o n l y a n d a r e l i k e w i s e e x e m p t .
if { [ info exists : : punkboot::stale_bootsupport] && $::punkboot::command ni { check projectversion workflow bakelist buildsuite} } {
# ' b u i l d s u i t e ' a n d ' t o o l ' a r e a r m ' s - l e n g t h s u b s y s t e m s t h a t d o n o t c o n s u m e b o o t s u p p o r t m o d u l e s .
if { [ info exists : : punkboot::stale_bootsupport] && $::punkboot::command ni { check projectversion workflow bakelist buildsuite tool} } {
set _stale $::punkboot::stale_bootsupport
set _stale $::punkboot::stale_bootsupport
set _have_major 0
set _have_major 0
set _have_minor 0
set _have_minor 0
@ -4242,6 +4316,339 @@ if {$::punkboot::command eq "buildsuite"} {
}
}
}
}
if { $::punkboot::command eq " t o o l " } {
# G - 1 2 6 : v e n d o r e d f i r s t - p a r t y b u i l d t o o l s u n d e r s r c / t o o l s ( z i g s o u r c e v e n d o r e d i n
# f u l l - b o u n d a r y a n d e d i t i n g p o l i c y i n s r c / t o o l s / A G E N T S . m d ; p e r - t r e e o r i g i n ,
# r e - v e n d o r p r o c e d u r e a n d l i c e n c e r e c o r d s i n < t o o l > / P R O V E N A N C E . m d ) . D i s c o v e r y i s
# c o n v e n t i o n - b a s e d : a d i r e c t o r y u n d e r s r c / t o o l s c a r r y i n g b u i l d . z i g i s a t o o l , i t s
# n a m e i s t h e d i r e c t o r y n a m e , i t s b u i l d a r t i f a c t i s < t o o l d i r > / z i g - o u t / b i n / < n a m e >
# a n d i t s i n s t a l l e d c o p y i s < p r o j e c t d i r > / b i n / < n a m e > ( h o s t e x e c u t a b l e s u f f i x ) .
# z i g s t a y s O P T I O N A L f o r p u n k s h e l l b u i l d s : n o t h i n g i n p a c k a g e s / b a k e d e p e n d s o n
# t h i s s t e p ; e x p l i c i t b u i l d / t e s t w i t h o u t a s u i t a b l e t o o l c h a i n e x i t s n o n z e r o w i t h
# f e t c h g u i d a n c e . B u i l d c a c h e s ( . z i g - c a c h e / z i g - o u t ) a r e d e l i b e r a t e l y l e f t i n
# p l a c e b e t w e e n b u i l d s f o r r e b u i l d s p e e d ( b o t h g i t - a n d f o s s i l - i g n o r e d ) .
set tool_root [ file join $sourcefolder tools]
if { ! [ info exists : : punkboot::tool_args] } { set : : punkboot::tool_args [ list ] }
set targs $::punkboot::tool_args
set tool_action [ lindex $targs 0 ]
if { $tool_action eq " " } { set tool_action list}
# a r g s a f t e r t h e a c t i o n : t o o l n a m e s p l u s a n o p t i o n a l ' - t e s t 0 | 1 ' f l a g ( b u i l d )
set tool_dotest 1
set tool_names [ list ]
set _i 1
while { $_i < [ llength $targs ] } {
set a [ lindex $targs $_i ]
if { $a eq " - t e s t " } {
incr _i
set v [ lindex $targs $_i ]
if { ! [ string is boolean - strict $v ] } {
puts stderr " m a k e . t c l t o o l : - t e s t r e q u i r e s a b o o l e a n v a l u e ( g o t ' $ v ' ) "
exit 2
}
set tool_dotest [ expr { bool ( $v ) } ]
} else {
lappend tool_names $a
}
incr _i
}
unset - nocomplain _i a v
proc : : punkboot::tool_dirs { tool_root } {
set dirs [ list ]
foreach dir [ lsort [ glob - nocomplain - dir $tool_root - type d * ] ] {
if { ! [ file exists [ file join $dir build.zig] ] } { continue } ; # n o t a t o o l
lappend dirs $dir
}
return $dirs
}
# t o l e r a n t b u i l d . z i g . z o n r e a d e r : t o o l v e r s i o n + d e c l a r e d m i n i m u m z i g v e r s i o n
proc : : punkboot::tool_zoninfo { tooldir } {
set m [ dict create version " " zigfloor " " ]
if { ! [ catch {
set f [ open [ file join $tooldir build.zig.zon] r]
set data [ read $f ]
close $f
} ] } {
if { [ regexp { \ .version \ s* = \ s* " ( [ ^ " ] + ) " } $data - > _v] } { dict set m version $_v }
if { [ regexp { \ .minimum_zig_version \ s* = \ s* " ( [ ^ " ] + ) " } $data - > _fl] } { dict set m zigfloor $_fl }
}
return $m
}
# t o l e r a n t P R O V E N A N C E . m d r e a d e r : v e n d o r e d u p s t r e a m c o m m i t + u p s t r e a m l o c a t i o n
proc : : punkboot::tool_provenance { tooldir } {
set m [ dict create commit " " upstream " " ]
if { ! [ catch {
set f [ open [ file join $tooldir PROVENANCE.md] r]
set data [ read $f ]
close $f
} ] } {
if { [ regexp { Vendored state: commit\ s+ ` ? ( [ 0-9a-fA-F ] { 7 , 40 } ) } $data - > _c] } { dict set m commit $_c }
if { [ regexp { Upstream repository:\ s+ ` ? ( [ ^ ` \ n ] + ) } $data - > _u] } { dict set m upstream [ string trim $_u ] }
}
return $m
}
proc : : punkboot::tool_newest_src_mtime { dir } {
set newest 0
foreach f [ glob - nocomplain - dir $dir - type f * ] {
if { [ file mtime $f ] > $newest } { set newest [ file mtime $f ] }
}
foreach d [ glob - nocomplain - dir $dir - type d * ] {
if { [ file tail $d ] in { zig-out .zig-cache zig-cache} } { continue }
set sub [ : : punkboot : : tool_newest_src_mtime $d ]
if { $sub > $newest } { set newest $sub }
}
return $newest
}
proc : : punkboot::tool_zig_version { zigexe } {
if { [ catch { exec $zigexe version 2 > @ 1 } v] } { return " " }
return [ string trim [ lindex [ split $v \ n] 0 ] ]
}
# a d e v b u i l d ' s b a s e v e r s i o n m u s t E X C E E D t h e f l o o r ( e . g 0 . 1 6 . 0 - d e v < 0 . 1 6 . 0 )
proc : : punkboot::tool_zig_satisfies { ver floor} {
if { $floor eq " " } { return 1 }
set base $ver ; set isdev 0
if { [ regexp { ^ ( [ 0-9 ] [ 0-9. ] * ) [ - + ] } $ver - > b] } { set base $b ; set isdev 1 }
if { [ catch { package vcompare $base $floor } cmp] } { return 0 }
if { $cmp > 0 } { return 1 }
if { $cmp == 0 && ! $isdev } { return 1 }
return 0
}
# r e s o l v e a z i g f o r t h e g i v e n f l o o r : P U N K _ Z I G e n v o v e r r i d e ( p a t h t o t h e z i g
# e x e c u t a b l e o r i t s f o l d e r ) , e l s e s c a n < p r o j e c t d i r > / b i n / t o o l s / z i g * p r e f e r r i n g
# r e l e a s e s o v e r d e v b u i l d s a n d t h e L O W E S T s a t i s f y i n g v e r s i o n - a d e t e r m i n i s t i c
# c h o i c e t h a t s t a y s s t a b l e a s n e w e r t o o l c h a i n s g e t u n p a c k e d b e s i d e t h e p i n n e d o n e
proc : : punkboot::tool_resolve_zig { projectroot floor} {
if { [ info exists : : env( PUNK_ZIG ) ] && $::env ( PUNK_ZIG ) ne " " } {
set cand $::env ( PUNK_ZIG )
if { [ file isdirectory $cand ] } {
foreach n { zig.exe zig} {
if { [ file exists [ file join $cand $n ] ] } { set cand [ file join $cand $n ] ; break }
}
}
set v [ : : punkboot : : tool_zig_version $cand ]
if { $v eq " " } {
return [ dict create note " P U N K _ Z I G = ' $ : : e n v ( P U N K _ Z I G ) ' d i d n o t a n s w e r ' z i g v e r s i o n ' " ]
}
if { ! [ : : punkboot : : tool_zig_satisfies $v $floor ] } {
return [ dict create note " P U N K _ Z I G z i g i s $ v w h i c h d o e s n o t s a t i s f y t h i s t o o l ' s f l o o r ( > = $ f l o o r ) " ]
}
return [ dict create zig $cand version $v via PUNK_ZIG]
}
set best " " ; set bestv " " ; set bestbase " " ; set bestdev 1
foreach dir [ lsort [ glob - nocomplain - dir [ file join $projectroot bin tools] - type d zig* ] ] {
set p " "
foreach n { zig.exe zig} {
if { [ file exists [ file join $dir $n ] ] } { set p [ file join $dir $n ] ; break }
}
if { $p eq " " } { continue }
set v [ : : punkboot : : tool_zig_version $p ]
if { $v eq " " || ! [ : : punkboot : : tool_zig_satisfies $v $floor ] } { continue }
set base $v ; set isdev 0
if { [ regexp { ^ ( [ 0-9 ] [ 0-9. ] * ) [ - + ] } $v - > b] } { set base $b ; set isdev 1 }
set take 0
if { $best eq " " } {
set take 1
} elseif { $bestdev && ! $isdev } {
set take 1
} elseif { $bestdev == $isdev && [ package vcompare $base $bestbase ] < 0 } {
set take 1
}
if { $take } { set best $p ; set bestv $v ; set bestbase $base ; set bestdev $isdev }
}
if { $best eq " " } {
set want [ expr { $floor eq " " ? " a n y v e r s i o n " : " > = $ f l o o r " } ]
return [ dict create note " n o s u i t a b l e z i g t o o l c h a i n ( $ w a n t ) u n d e r [ f i l e j o i n $ p r o j e c t r o o t b i n t o o l s ] - ' b i n / p u n k - g e t z i g . c m d < v e r s i o n > ' f e t c h e s o n e ; P U N K _ Z I G = < p a t h - t o - z i g > o v e r r i d e s " ]
}
return [ dict create zig $best version $bestv via scan]
}
proc : : punkboot::tool_installed_exe { projectroot name} {
set suffix [ punkboot : : lib::platform_exe_suffix $::punkboot::target_platform ]
return [ file join $projectroot bin $ { name } $suffix ]
}
proc : : punkboot::tool_install_state { projectroot tooldir} {
set exe [ : : punkboot : : tool_installed_exe $projectroot [ file tail $tooldir ] ]
if { ! [ file exists $exe ] } { return absent}
if { [ file mtime $exe ] >= [ : : punkboot : : tool_newest_src_mtime $tooldir ] } { return current}
return stale
}
# r u n ' z i g < a r g l > ' w i t h c w d a t t h e t o o l t r e e ( t h e t r e e ' s C L I t e s t s r e s o l v e
# f i x t u r e s a n d z i g - o u t r e l a t i v e t o t h e b u i l d r o o t ) . T h e g a t e i s t h e E X I T C O D E :
# s t d e r r l e g i t i m a t e l y c a r r i e s e x p e c t e d w a r n i n g s ( p u n k z i p ' s z i p s u i t e n e g a t i v e
# t e s t s p r i n t E O C D w a r n i n g s w h i l e p a s s i n g ) . R e t u r n s t h e c h i l d ' s e x i t s t a t u s .
proc : : punkboot::tool_zig_run { zig tooldir argl} {
set saved [ pwd ]
cd $tooldir
set rc 0
if { [ catch { exec $zig { * } $argl > @ stdout 2 > @ stderr} _e _o] } {
set ecode [ dict get $_o - errorcode]
if { [ lindex $ecode 0 ] eq " C H I L D S T A T U S " } {
set rc [ lindex $ecode 2 ]
} else {
puts stderr " t o o l : f a i l e d t o r u n ' $ z i g $ a r g l ' i n $ t o o l d i r : $ _ e "
set rc 1
}
}
cd $saved
return $rc
}
set alldirs [ : : punkboot : : tool_dirs $tool_root ]
set byname [ dict create]
foreach d $alldirs { dict set byname [ file tail $d ] $d }
if { [ llength $tool_names ] } {
set selected [ list ]
foreach n $tool_names {
if { ! [ dict exists $byname $n ] } {
puts stderr " t o o l ' $ n ' n o t f o u n d u n d e r $ t o o l _ r o o t - c o n f i g u r e d t o o l s : [ d i c t k e y s $ b y n a m e ] "
exit 2
}
lappend selected [ dict get $byname $n ]
}
} else {
set selected $alldirs
}
if { ! [ llength $alldirs ] && $tool_action ne " l i s t " } {
puts stderr " n o v e n d o r e d t o o l s f o u n d u n d e r $ t o o l _ r o o t ( a t o o l = a d i r e c t o r y c a r r y i n g b u i l d . z i g ) "
exit 2
}
switch - - $tool_action {
list {
if { ! [ llength $alldirs ] } {
puts stdout " n o v e n d o r e d t o o l s f o u n d u n d e r $ t o o l _ r o o t ( a t o o l = a d i r e c t o r y c a r r y i n g b u i l d . z i g ) "
exit 0
}
puts stdout " v e n d o r e d t o o l s u n d e r $ t o o l _ r o o t ( b o u n d a r y : s r c / t o o l s / A G E N T S . m d ; p e r - t r e e P R O V E N A N C E . m d ) : "
puts stdout [ format " % - 1 0 s % - 9 s % - 1 0 s % - 8 s % s " name version zig-floor bin vendored-commit]
set maxfloor " "
foreach dir $alldirs {
set name [ file tail $dir ]
set zon [ : : punkboot : : tool_zoninfo $dir ]
set prov [ : : punkboot : : tool_provenance $dir ]
set floor [ dict get $zon zigfloor]
if { $floor ne " " && ( $maxfloor eq " " || [ package vcompare $floor $maxfloor ] > 0 ) } {
set maxfloor $floor
}
set commit [ dict get $prov commit]
set commit [ expr { $commit eq " " ? " - " : [ string range $commit 0 11 ] } ]
set floorshow [ expr { $floor eq " " ? " - " : " > = $ f l o o r " } ]
puts stdout [ format " % - 1 0 s % - 9 s % - 1 0 s % - 8 s % s " $name [ dict get $zon version] $floorshow [ : : punkboot : : tool_install_state $projectroot $dir ] $commit ]
}
set zres [ : : punkboot : : tool_resolve_zig $projectroot $maxfloor ]
if { [ dict exists $zres zig] } {
puts stdout " t o o l c h a i n : z i g [ d i c t g e t $ z r e s v e r s i o n ] v i a [ d i c t g e t $ z r e s v i a ] ( [ d i c t g e t $ z r e s z i g ] ) "
} else {
puts stdout " t o o l c h a i n : [ d i c t g e t $ z r e s n o t e ] "
}
puts stdout " "
puts stdout " - ' m a k e . t c l t o o l i n f o < n a m e > ' s h o w s a t o o l ' s d e t a i l "
puts stdout " - ' m a k e . t c l t o o l b u i l d ? < n a m e > . . . ? ? - t e s t 0 | 1 ? ' b u i l d s ( t e s t - g a t e d ) a n d i n s t a l l s t o b i n / "
puts stdout " - z i g i s O P T I O N A L f o r p u n k s h e l l b u i l d s : p a c k a g e s / b a k e n e v e r r e q u i r e t h i s s t e p "
exit 0
}
info {
if { ! [ llength $tool_names ] } {
puts stderr " u s a g e : m a k e . t c l t o o l i n f o < t o o l n a m e > ( ' m a k e . t c l t o o l l i s t ' s h o w s t h e n a m e s ) "
exit 2
}
foreach dir $selected {
set name [ file tail $dir ]
set zon [ : : punkboot : : tool_zoninfo $dir ]
set prov [ : : punkboot : : tool_provenance $dir ]
set floor [ dict get $zon zigfloor]
puts stdout " t o o l : $ n a m e "
puts stdout " p a t h : $ d i r "
puts stdout " v e r s i o n : [ d i c t g e t $ z o n v e r s i o n ] ( b u i l d . z i g . z o n ) "
puts stdout " z i g f l o o r : [ e x p r { $ f l o o r e q " " ? " ( n o n e d e c l a r e d ) " : " > = $ f l o o r " } ] "
puts stdout " u p s t r e a m : [ e x p r { [ d i c t g e t $ p r o v u p s t r e a m ] e q " " ? " ( n o P R O V E N A N C E . m d r e c o r d ) " : [ d i c t g e t $ p r o v u p s t r e a m ] } ] "
puts stdout " v e n d o r e d c o m m i t : [ e x p r { [ d i c t g e t $ p r o v c o m m i t ] e q " " ? " ( n o P R O V E N A N C E . m d r e c o r d ) " : [ d i c t g e t $ p r o v c o m m i t ] } ] "
puts stdout " p r o v e n a n c e : [ f i l e j o i n $ d i r P R O V E N A N C E . m d ] "
set exe [ : : punkboot : : tool_installed_exe $projectroot $name ]
puts stdout " i n s t a l l e d : $ e x e ( [ : : p u n k b o o t : : t o o l _ i n s t a l l _ s t a t e $ p r o j e c t r o o t $ d i r ] ) "
set zres [ : : punkboot : : tool_resolve_zig $projectroot $floor ]
if { [ dict exists $zres zig] } {
puts stdout " t o o l c h a i n : z i g [ d i c t g e t $ z r e s v e r s i o n ] v i a [ d i c t g e t $ z r e s v i a ] ( [ d i c t g e t $ z r e s z i g ] ) "
} else {
puts stdout " t o o l c h a i n : [ d i c t g e t $ z r e s n o t e ] "
}
}
exit 0
}
build {
foreach dir $selected {
set name [ file tail $dir ]
set floor [ dict get [ : : punkboot : : tool_zoninfo $dir ] zigfloor]
set zres [ : : punkboot : : tool_resolve_zig $projectroot $floor ]
if { ! [ dict exists $zres zig] } {
puts stderr " t o o l b u i l d $ n a m e : [ d i c t g e t $ z r e s n o t e ] "
exit 1
}
set zig [ dict get $zres zig]
puts stdout " t o o l b u i l d $ n a m e : z i g [ d i c t g e t $ z r e s v e r s i o n ] v i a [ d i c t g e t $ z r e s v i a ] ( $ z i g ) "
flush stdout
if { $tool_dotest } {
puts stdout " t o o l b u i l d $ n a m e : t e s t g a t e ( ' z i g b u i l d t e s t ' ) . . . "
flush stdout
set rc [ : : punkboot : : tool_zig_run $zig $dir [ list build test] ]
if { $rc != 0 } {
puts stderr " t o o l b u i l d $ n a m e : t e s t g a t e F A I L E D ( e x i t $ r c ) - n o t h i n g i n s t a l l e d "
exit 1
}
puts stdout " t o o l b u i l d $ n a m e : t e s t g a t e p a s s e d "
} else {
puts stdout " t o o l b u i l d $ n a m e : t e s t g a t e S K I P P E D ( - t e s t 0 ) "
}
puts stdout " t o o l b u i l d $ n a m e : b u i l d i n g ( R e l e a s e S a f e ) . . . "
flush stdout
set rc [ : : punkboot : : tool_zig_run $zig $dir [ list build - Doptimize= ReleaseSafe] ]
if { $rc != 0 } {
puts stderr " t o o l b u i l d $ n a m e : b u i l d F A I L E D ( e x i t $ r c ) - n o t h i n g i n s t a l l e d "
exit 1
}
set suffix [ punkboot : : lib::platform_exe_suffix $::punkboot::target_platform ]
set built [ file join $dir zig-out bin $ { name } $suffix ]
if { ! [ file exists $built ] } {
puts stderr " t o o l b u i l d $ n a m e : b u i l d r e p o r t e d s u c c e s s b u t $ b u i l t i s m i s s i n g "
exit 1
}
set exe [ : : punkboot : : tool_installed_exe $projectroot $name ]
if { [ catch { file copy - force $built $exe } cperr] } {
puts stderr " t o o l b u i l d $ n a m e : c o u l d n o t i n s t a l l $ e x e ( $ c p e r r ) - i s a c o p y c u r r e n t l y r u n n i n g ? "
exit 1
}
puts stdout " t o o l b u i l d $ n a m e : i n s t a l l e d $ e x e ( [ f i l e s i z e $ e x e ] b y t e s ) "
}
exit 0
}
test {
foreach dir $selected {
set name [ file tail $dir ]
set floor [ dict get [ : : punkboot : : tool_zoninfo $dir ] zigfloor]
set zres [ : : punkboot : : tool_resolve_zig $projectroot $floor ]
if { ! [ dict exists $zres zig] } {
puts stderr " t o o l t e s t $ n a m e : [ d i c t g e t $ z r e s n o t e ] "
exit 1
}
set zig [ dict get $zres zig]
puts stdout " t o o l t e s t $ n a m e : z i g [ d i c t g e t $ z r e s v e r s i o n ] v i a [ d i c t g e t $ z r e s v i a ] - r u n n i n g ' z i g b u i l d t e s t ' . . . "
flush stdout
set rc [ : : punkboot : : tool_zig_run $zig $dir [ list build test] ]
if { $rc != 0 } {
puts stderr " t o o l t e s t $ n a m e : F A I L E D ( e x i t $ r c ) "
exit 1
}
puts stdout " t o o l t e s t $ n a m e : p a s s e d "
}
exit 0
}
default {
puts stderr " u n k n o w n t o o l a c t i o n ' $ t o o l _ a c t i o n ' - e x p e c t e d l i s t | i n f o | b u i l d | t e s t "
puts stderr " u s a g e : m a k e . t c l t o o l l i s t | i n f o | b u i l d | t e s t ? < t o o l n a m e > . . . ? ? - t e s t 0 | 1 ? "
exit 2
}
}
}
if { $::punkboot::command eq " s h e l l " } {
if { $::punkboot::command eq " s h e l l " } {
# G - 1 1 3 : t h e a n s i s t r i p t r a n s f o r m s e r v e s m a k e . t c l ' s o w n o u t p u t o n l y - t h e r e p l ' s
# G - 1 1 3 : t h e a n s i s t r i p t r a n s f o r m s e r v e s m a k e . t c l ' s o w n o u t p u t o n l y - t h e r e p l ' s
# c o l o u r b e h a v i o u r i s t h e s h e l l ' s o w n c o n c e r n ( c o l o u r o n / o f f + N O _ C O L O R t h e r e ) .
# c o l o u r b e h a v i o u r i s t h e s h e l l ' s o w n c o n c e r n ( c o l o u r o n / o f f + N O _ C O L O R t h e r e ) .