Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ dependencies([
% A path to a local package
dependency("test_local", path("./local_package"))
]).
% Optional. Custom search paths for packages.
% Specify paths to other scryer-manifest.pl files whose package directories
% should be searched. Bakage will automatically determine where each manifest's
% packages are located.
scryer_path([
"vendor/scryer-manifest.pl",
"libs/other-project/scryer-manifest.pl"
]).

```

Expand Down
39 changes: 38 additions & 1 deletion src/bakage.pl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,41 @@
append([RootChars, "/scryer_libs"], ScryerPath)
).

% Get the current project's manifest (if it exists)
current_project_manifest(Manifest) :-
find_project_root(Root),
append([Root, "/scryer-manifest.pl"], ManifestPath),
file_exists(ManifestPath),
parse_manifest(ManifestPath, Manifest).

% Extract scryer_path/1 terms from manifest (list of manifest file paths)
manifest_scryer_paths(Manifest, ManifestPaths) :-
member(scryer_path(ManifestPaths), Manifest),
ManifestPaths = [_|_].

% Given a manifest file path, derive where its packages are located
manifest_path_to_scryer_libs(ManifestPathChars, ScryerLibsPath) :-
join_sep_split(ManifestPathChars, "/", Segments),
append(DirSegments, [_ManifestFile], Segments),
join_sep_split(DirChars, "/", DirSegments),
append([DirChars, "/scryer_libs"], ScryerLibsPath).

% Generate scryer path candidates via backtracking
scryer_path_candidate(Path) :-
getenv("SCRYER_PATH", Path).
scryer_path_candidate(ScryerLibsPath) :-
current_project_manifest(Manifest),
manifest_scryer_paths(Manifest, ManifestPaths),
member(ManifestPath, ManifestPaths),
manifest_path_to_scryer_libs(ManifestPath, ScryerLibsPath).
scryer_path_candidate(Path) :-
find_project_root(RootChars),
append([RootChars, "/scryer_libs"], Path).

% Collect all scryer path candidates into a list
all_scryer_path_candidates(Paths) :-
findall(Path, scryer_path_candidate(Path), Paths).

% the message sent to the user when a dependency is malformed
user_message_malformed_dependency(D, Error):-
current_output(Out),
Expand All @@ -144,9 +179,11 @@

package_main_file(Package, PackageMainFile) :-
atom_chars(Package, PackageChars),
scryer_path(ScryerPath),
all_scryer_path_candidates(CandidatePaths),
member(ScryerPath, CandidatePaths),
append([ScryerPath, "/packages/", PackageChars], PackagePath),
append([PackagePath, "/", "scryer-manifest.pl"], ManifestPath),
file_exists(ManifestPath),
parse_manifest(ManifestPath, Manifest),
member(main_file(MainFile), Manifest),
append([PackagePath, "/", MainFile], PackageMainFileChars),
Expand Down