diff --git a/sources/workspaces/workspaces.dylan b/sources/workspaces/workspaces.dylan index feaa3a3..ef47cea 100644 --- a/sources/workspaces/workspaces.dylan +++ b/sources/workspaces/workspaces.dylan @@ -48,7 +48,7 @@ define class () // with platform-specific definitions may have multiple lids.) constant slot %lids-by-library :: = make(); - // A map from full absolute pathname of a LID file to the associated . + // A map from full absolute pathname string of a LID file to the associated . constant slot %lids-by-pathname :: = make(if (os/$os-name == #"win32") else end); @@ -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(, 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; @@ -132,8 +140,16 @@ define function find-default-library (ws :: ) => (name :: false-or()) 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") @@ -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" =>