From 3fab244300d50f5b57fbde8f8a86333449c78688 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 9 Aug 2026 20:04:37 +0900 Subject: fix(autoload): embed ClassLoader.php and the LICENSE at build time They were copied at run time from a path built out of CARGO_MANIFEST_DIR, so dumping the autoloader failed wherever the build tree was gone. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/autoload/autoload_generator.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'crates/shirabe/src/autoload/autoload_generator.rs') diff --git a/crates/shirabe/src/autoload/autoload_generator.rs b/crates/shirabe/src/autoload/autoload_generator.rs index b21bfabe..835293c4 100644 --- a/crates/shirabe/src/autoload/autoload_generator.rs +++ b/crates/shirabe/src/autoload/autoload_generator.rs @@ -691,21 +691,16 @@ return array( ), )?; - // PHP: __DIR__ refers to the directory of AutoloadGenerator.php, an absolute path - // independent of the cwd. The ClassLoader.php and LICENSE templates are bundled from the - // upstream composer source tree, resolved at build time relative to this crate's manifest - // (mirroring the InstalledVersions.php include in FilesystemRepository). - let autoload_dir = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../../composer/src/Composer/Autoload" - ); - filesystem.safe_copy( - &format!("{}/ClassLoader.php", autoload_dir), + // PHP copies these out of the Composer source tree at __DIR__. The binary has no such + // tree at run time, so they are embedded at build time, as InstalledVersions.php is in + // FilesystemRepository. + filesystem.file_put_contents_if_modified( &format!("{}/ClassLoader.php", target_dir), + include_str!("../../../../composer/src/Composer/Autoload/ClassLoader.php"), )?; - filesystem.safe_copy( - &format!("{}/../../../LICENSE", autoload_dir), + filesystem.file_put_contents_if_modified( &format!("{}/LICENSE", target_dir), + include_str!("../../../../composer/LICENSE"), )?; if self.run_scripts.get() { -- cgit v1.3.1-4-g156e