Skip to content
Open
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
37 changes: 29 additions & 8 deletions sources/workspaces/workspaces.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ define class <workspace> (<object>)
// with platform-specific definitions may have multiple lids.)
constant slot %lids-by-library :: <istring-table> = make(<istring-table>);

// A map from full absolute pathname of a LID file to the associated <lid>.
// A map from full absolute pathname string of a LID file to the associated <lid>.
constant slot %lids-by-pathname :: <table>
= make(if (os/$os-name == #"win32") <istring-table> else <string-table> end);

Expand Down Expand Up @@ -117,13 +117,21 @@ define function load-workspace
$workspace-file-name, $dylan-package-file-name);
let ws-dir = locator-directory(ws-file | dp-file);
let active-packages = find-active-packages(ws-dir);
// The "multi-package" terminology isn't great. What it really means is "are the
// projects in a subdirectory of the workspace root directory". That matters here...
let multi?
= (active-packages.size > 1
| (ws-file
& dp-file
& (ws-file.locator-directory ~= dp-file.locator-directory)
// lsp-dylan may open files under _packages due to xrefs in dependencies
// and call load-workspace with their directory. We don't want to treat
// those packages as "active" so exclude them here.
& ~member?(pm/$package-directory-name, dp-file.locator-path, test: \=)));
let ws = make(<workspace>,
directory: ws-dir,
active-packages: active-packages,
multi-package?: (active-packages.size > 1
| (ws-file
& dp-file
& (ws-file.locator-directory ~= dp-file.locator-directory))));
multi-package?: multi?);
ws-file & load-workspace-config(ws, ws-file);
ws
end function;
Expand All @@ -132,8 +140,16 @@ define function find-default-library
(ws :: <workspace>) => (name :: false-or(<string>))
block (return)
let fallback = #f;
for (lids keyed-by package in ws.lids-by-release)
for (lid in lids)
// Sort for consistent behavior, here and below.
let keys = sort!(key-sequence(ws.lids-by-release),
test: method (p1, p2)
p1.pm/package-name < p2.pm/package-name
end);
for (package in keys)
let lids = ws.lids-by-release[package];
for (lid in sort!(lids, test: method (l1, l2)
l1.library-name < l2.library-name
end))
let name = lid.library-name;
fallback := fallback | name;
if (ends-with?(name, "-test-suite-app")
Expand Down Expand Up @@ -188,9 +204,14 @@ define function scan-workspace-file
// available in the catalog for now. Ultimately we should have an escape hatch
// like the ability to use a local package catalog IN ADDITION to the main
// catalog. Or just make this configurable?
// TODO: Handle Mercurial. Anything else?
let subdir = subdirectory-locator(dir, name);
let subdir/git = subdirectory-locator(subdir, ".git");
if (name ~= ".git" & ~fs/file-exists?(subdir/git))
// TODO: use build-root-directory-name() instead of "_build", once it is exported
// from the build-system library.
if (name ~= "_build" // Dylan build directory
& name ~= ".git" // the main project's .git directory
& ~fs/file-exists?(subdir/git)) // a submodule's .git directory
fs/do-directory(curry(scan-workspace-file, ws, active-package), subdir);
end;
#"link" =>
Expand Down
Loading