Skip to content

Commit b6d6708

Browse files
jjtoltonclaude
andcommitted
Add scryer_path/1 manifest term for custom package search paths
Allows projects to specify additional manifest files whose package directories should be searched via the scryer_path/1 term. Example in scryer-manifest.pl: scryer_path(["vendor/scryer-manifest.pl"]). Bakage searches for packages in this order: 1. SCRYER_PATH environment variable (if set) 2. Paths from scryer_path/1 in manifest (backtracking) 3. Default {project_root}/scryer_libs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 478d9fa commit b6d6708

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ dependencies([
2828
% A path to a local package
2929
dependency("test_local", path("./local_package"))
3030
]).
31+
% Optional. Custom search paths for packages.
32+
% Specify paths to other scryer-manifest.pl files whose package directories
33+
% should be searched. Bakage will automatically determine where each manifest's
34+
% packages are located.
35+
scryer_path([
36+
"vendor/scryer-manifest.pl",
37+
"libs/other-project/scryer-manifest.pl"
38+
]).
3139
3240
```
3341

bakage.pl

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,37 @@
430430
append([RootChars, "/scryer_libs"], ScryerPath)
431431
).
432432

433+
% Get the current project's manifest (if it exists)
434+
current_project_manifest(Manifest) :-
435+
find_project_root(Root),
436+
append([Root, "/scryer-manifest.pl"], ManifestPath),
437+
file_exists(ManifestPath),
438+
parse_manifest(ManifestPath, Manifest).
439+
440+
% Extract scryer_path/1 terms from manifest (list of manifest file paths)
441+
manifest_scryer_paths(Manifest, ManifestPaths) :-
442+
member(scryer_path(ManifestPaths), Manifest),
443+
ManifestPaths = [_|_].
444+
445+
% Given a manifest file path, derive where its packages are located
446+
manifest_path_to_scryer_libs(ManifestPathChars, ScryerLibsPath) :-
447+
join_sep_split(ManifestPathChars, "/", Segments),
448+
append(DirSegments, [_ManifestFile], Segments),
449+
join_sep_split(DirChars, "/", DirSegments),
450+
append([DirChars, "/scryer_libs"], ScryerLibsPath).
451+
452+
% Generate scryer path candidates via backtracking
453+
scryer_path_candidate(Path) :-
454+
getenv("SCRYER_PATH", Path).
455+
scryer_path_candidate(ScryerLibsPath) :-
456+
current_project_manifest(Manifest),
457+
manifest_scryer_paths(Manifest, ManifestPaths),
458+
member(ManifestPath, ManifestPaths),
459+
manifest_path_to_scryer_libs(ManifestPath, ScryerLibsPath).
460+
scryer_path_candidate(Path) :-
461+
find_project_root(RootChars),
462+
append([RootChars, "/scryer_libs"], Path).
463+
433464
% the message sent to the user when a dependency is malformed
434465
user_message_malformed_dependency(D, Error):-
435466
current_output(Out),
@@ -550,9 +581,10 @@
550581

551582
package_main_file(Package, PackageMainFile) :-
552583
atom_chars(Package, PackageChars),
553-
scryer_path(ScryerPath),
584+
scryer_path_candidate(ScryerPath),
554585
append([ScryerPath, "/packages/", PackageChars], PackagePath),
555586
append([PackagePath, "/", "scryer-manifest.pl"], ManifestPath),
587+
file_exists(ManifestPath),
556588
parse_manifest(ManifestPath, Manifest),
557589
member(main_file(MainFile), Manifest),
558590
append([PackagePath, "/", MainFile], PackageMainFileChars),

0 commit comments

Comments
 (0)