#!/usr/bin/php $version) { unset($lines); echo "finding dep: $name-$version\n"; $cmd = sprintf('find ~/.cargo/registry/src -name %s-%s', escapeshellarg($name), $version); exec($cmd, $lines, $rc); if( $rc ) die("find failed"); $path = @$lines[0]; if(!$path || !file_exists($path)) die("dep path '$path' does not exist for crate $name\n"); $cratepaths[] = $path; } $cratepaths[] = getcwd(); // current crate. $cmd = sprintf("%s/gen_diagrams.php %s %s", escapeshellcmd(__DIR__), escapeshellarg($diagrams_dir), implode(' ', $cratepaths)); shell($cmd) && die(""); echo "\nFinished. Diagrams are in $diagrams_dir\n"; exit(0); function shell($cmd) { passthru($cmd, $rc); return $rc; }