Skip to content

Commit

Permalink
prepare for supporting sourcePaths for DCD
Browse files Browse the repository at this point in the history
needs upstream changes in DUB merged first
  • Loading branch information
WebFreak001 committed Sep 27, 2023
1 parent aea1291 commit df3033d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions workspace-d/dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ license "MIT"
dependency "dfmt" version="~>0.15.0"
dependency "inifiled" version="1.3.3"
dependency "serve-d:dcd" path=".."
# we can't upgrade to 1.34.0 yet! PR https://github.com/dlang/dub/pull/2703 must
# be merged first to avoid a regression with building that cannot stabily be
# fixed without hardcoding DUB paths into the code here.
dependency "dub" version="1.33.1"
dependency "emsi_containers" version="0.9.0"
dependency "dscanner" version="~>0.16.0-beta.1"
Expand Down
24 changes: 23 additions & 1 deletion workspace-d/source/workspaced/com/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,26 @@ class DubComponent : ComponentWrapper
debugVersions ~= target.buildSettings.debugVersions;
}

_importPaths = importPaths.data;
string[] rootSourcePaths;
if (auto rootTargetIndex = _dub.projectName in gen.targetDescriptionLookup)
{
auto rootTarget = gen.targetDescriptions[*rootTargetIndex];
// upstream PR: https://github.com/dlang/dub/pull/2704
static if (__traits(hasMember, rootTarget.buildSettings, "specifiedSourcePaths"))
{
pragma(msg,
"\n\n\n\n\n\n\nTODO: remove this message and the `static if` around this code, this change made it into DUB now and we upgraded!\n\n"
~ __FILE__ ~ ":" ~ __LINE__.stringof
~ "\n\n\n\n\n\n\n");

// adds the specified `sourcePaths` of the current package (only) as import paths for DCD
foreach (sourcePath; rootTarget.buildSettings.specifiedSourcePaths)
if (!rootTarget.buildSettings.importPaths.canFind(sourcePath))
rootSourcePaths ~= sourcePath;
}
}

_importPaths = rootSourcePaths ~ importPaths.data;
_stringImportPaths = stringImportPaths.data;
_importFiles = sourceFiles.data;
_versions = versions.data;
Expand All @@ -280,6 +299,9 @@ class DubComponent : ComponentWrapper
e.toString);
_importPaths = [];
_stringImportPaths = [];
_importFiles = [];
_versions = [];
_debugVersions = [];
return false;
}
}
Expand Down

0 comments on commit df3033d

Please sign in to comment.