@@ -1767,16 +1767,19 @@ export const preflightLinuxDesktopBuild = Effect.fn("preflightLinuxDesktopBuild"
17671767 const reuseResourceMonitor = yield * Config . boolean ( "T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR" ) . pipe (
17681768 Config . withDefault ( false ) ,
17691769 ) ;
1770+ const reuseCaptureHelpers = yield * Config . boolean (
1771+ "T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS" ,
1772+ ) . pipe ( Config . withDefault ( false ) ) ;
1773+ // Rust is only optional when every Linux Rust artifact comes from a cache.
1774+ const needsRust = ! reuseResourceMonitor || ! reuseCaptureHelpers ;
17701775 const rustTarget = resolveResourceMonitorRustTargets ( "linux" , arch ) [ 0 ] ! ;
17711776
17721777 const checks = yield * Effect . all (
17731778 {
1774- cargo : reuseResourceMonitor
1775- ? Effect . succeed ( true )
1776- : desktopBuildProbeSucceeds ( ChildProcess . make ( "cargo" , [ "--version" ] ) , "cargo" ) ,
1777- "rust-target" : reuseResourceMonitor
1778- ? Effect . succeed ( true )
1779- : rustTargetIsInstalled ( rustTarget ) ,
1779+ cargo : needsRust
1780+ ? desktopBuildProbeSucceeds ( ChildProcess . make ( "cargo" , [ "--version" ] ) , "cargo" )
1781+ : Effect . succeed ( true ) ,
1782+ "rust-target" : needsRust ? rustTargetIsInstalled ( rustTarget ) : Effect . succeed ( true ) ,
17801783 cc : desktopBuildProbeSucceeds ( ChildProcess . make ( "cc" , [ "--version" ] ) , "cc" ) ,
17811784 make : desktopBuildProbeSucceeds ( ChildProcess . make ( "make" , [ "--version" ] ) , "make" ) ,
17821785 libsecret : desktopBuildProbeSucceeds (
@@ -2176,37 +2179,49 @@ export const stageLinuxCaptureHelper = Effect.fn("stageLinuxCaptureHelper")(func
21762179 const fs = yield * FileSystem . FileSystem ;
21772180 const path = yield * Path . Path ;
21782181 const [ rustTarget ] = resolveResourceMonitorRustTargets ( "linux" , input . arch ) ;
2179- const spawnCommand = yield * resolveSpawnCommand ( "cargo" , [
2180- "build" ,
2181- "--locked" ,
2182- "--release" ,
2183- "--manifest-path" ,
2184- path . join ( input . repoRoot , `native/${ input . backend } -snap-shot/Cargo.toml` ) ,
2185- "--target" ,
2182+ // Release CI restores these binaries from a cache keyed on the crate sources and
2183+ // skips the Rust toolchain on a hit, so the build must be skippable too.
2184+ const reuseHelpers = yield * Config . boolean ( "T3CODE_DESKTOP_REUSE_LINUX_CAPTURE_HELPERS" ) . pipe (
2185+ Config . withDefault ( false ) ,
2186+ ) ;
2187+ const binaryPath = path . join (
2188+ input . repoRoot ,
2189+ `native/${ input . backend } -snap-shot/target` ,
21862190 rustTarget ! ,
2187- ] ) ;
2188- yield * runCommand (
2189- ChildProcess . make ( spawnCommand . command , spawnCommand . args , {
2190- cwd : input . repoRoot ,
2191- shell : spawnCommand . shell ,
2192- } ) ,
2193- {
2194- label : `cargo build ${ input . backend } capture helper (${ rustTarget } )` ,
2195- verbose : input . verbose ,
2196- } ,
2191+ `release/t3-${ input . backend } -snap-shot` ,
21972192 ) ;
2193+ if ( ! reuseHelpers ) {
2194+ const spawnCommand = yield * resolveSpawnCommand ( "cargo" , [
2195+ "build" ,
2196+ "--locked" ,
2197+ "--release" ,
2198+ "--manifest-path" ,
2199+ path . join ( input . repoRoot , `native/${ input . backend } -snap-shot/Cargo.toml` ) ,
2200+ "--target" ,
2201+ rustTarget ! ,
2202+ ] ) ;
2203+ yield * runCommand (
2204+ ChildProcess . make ( spawnCommand . command , spawnCommand . args , {
2205+ cwd : input . repoRoot ,
2206+ shell : spawnCommand . shell ,
2207+ } ) ,
2208+ {
2209+ label : `cargo build ${ input . backend } capture helper (${ rustTarget } )` ,
2210+ verbose : input . verbose ,
2211+ } ,
2212+ ) ;
2213+ } else if ( ! ( yield * fs . exists ( binaryPath ) ) ) {
2214+ return yield * new ResourceMonitorBuildOutputMissingError ( {
2215+ binaryPath,
2216+ rustTarget : rustTarget ! ,
2217+ platform : "linux" ,
2218+ arch : input . arch ,
2219+ } ) ;
2220+ }
21982221 const destination = path . join ( input . stageResourcesDir , `${ input . backend } -capture` ) ;
21992222 yield * fs . makeDirectory ( destination , { recursive : true } ) ;
22002223 const executable = path . join ( destination , `t3-${ input . backend } -snap-shot` ) ;
2201- yield * fs . copyFile (
2202- path . join (
2203- input . repoRoot ,
2204- `native/${ input . backend } -snap-shot/target` ,
2205- rustTarget ! ,
2206- `release/t3-${ input . backend } -snap-shot` ,
2207- ) ,
2208- executable ,
2209- ) ;
2224+ yield * fs . copyFile ( binaryPath , executable ) ;
22102225 yield * fs . chmod ( executable , 0o755 ) ;
22112226 if ( input . backend === "hyprland" ) {
22122227 // The official protocol XML includes the BSD notices required with binary distribution.
0 commit comments