aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-09 20:04:37 +0900
committernsfisis <nsfisis@gmail.com>2026-08-09 20:04:37 +0900
commit3fab244300d50f5b57fbde8f8a86333449c78688 (patch)
tree3eb782400b0a10af3335e19728bf5a7511e9f7bf /crates/shirabe/src
parentbad46664a71c8e12330d548c07e2daae90b54e75 (diff)
downloadphp-shirabe-3fab244300d50f5b57fbde8f8a86333449c78688.tar.gz
php-shirabe-3fab244300d50f5b57fbde8f8a86333449c78688.tar.zst
php-shirabe-3fab244300d50f5b57fbde8f8a86333449c78688.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src')
-rw-r--r--crates/shirabe/src/autoload/autoload_generator.rs19
1 files changed, 7 insertions, 12 deletions
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() {