Skip to content

When using dub, a project in the workspace root is required. Make it optional. #374

Open
@Reavershark

Description

Because I'm using an external build system (esp-idf), my dub project is a subdirectory in the workspace.
Serve-d finds it just fine (with d.scanAllFolders) and uses it as a dub project, but gives an error when trying to set up the workspace folder as a project, which has no dub.sdl/json.

Currently there is no way to prevent the root folder being used as dub project (without d.neverUseDub).

One solution would be to not force add the workspace as a project, relying instead on d.scanAllFolders to find a dub.sdl/json in the workspace root. This would break projects using "d.scanAllFolders": false and not including "." in the d.extraRoots:

diff --git a/source/served/extension.d b/source/served/extension.d
index 715128e..a1a8d1d 100644
--- a/source/served/extension.d
+++ b/source/served/extension.d
@@ -506,31 +506,28 @@ RootSuggestion[] rootsForProject(string root, bool recursive, string[] blocked,
                if (!ret.canFind!(a => a.dir == dir))
                        ret ~= RootSuggestion(dir, useDub);
        }

-       bool rootDub = dubRecipeExists(root, true);
-       addSuggestion(root, rootDub);
-
        if (recursive)
        {
                foreach (pkg; tryDirEntries(root, "dub.{json,sdl}", fs.SpanMode.breadth))
                {
                        auto dir = dirName(pkg);
                        if (dir.canFind(".dub"))
                                continue;
-                       if (dir == root)
-                               continue;
                        if (blocked.any!(a => globMatch(dir.relativePath(root), a)
                                        || globMatch(pkg.relativePath(root), a) || globMatch((dir ~ "/").relativePath, a)))
                                continue;
                        addSuggestion(dir, true);
                }
        }

Alternatively, another config option could be added to always include the workspace root as dub project, defaulting to true.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions