Skip to content

Commit df3033d

Browse files
committed
prepare for supporting sourcePaths for DCD
needs upstream changes in DUB merged first
1 parent aea1291 commit df3033d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

workspace-d/dub.sdl

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ license "MIT"
77
dependency "dfmt" version="~>0.15.0"
88
dependency "inifiled" version="1.3.3"
99
dependency "serve-d:dcd" path=".."
10+
# we can't upgrade to 1.34.0 yet! PR https://github.com/dlang/dub/pull/2703 must
11+
# be merged first to avoid a regression with building that cannot stabily be
12+
# fixed without hardcoding DUB paths into the code here.
1013
dependency "dub" version="1.33.1"
1114
dependency "emsi_containers" version="0.9.0"
1215
dependency "dscanner" version="~>0.16.0-beta.1"

workspace-d/source/workspaced/com/dub.d

+23-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,26 @@ class DubComponent : ComponentWrapper
264264
debugVersions ~= target.buildSettings.debugVersions;
265265
}
266266

267-
_importPaths = importPaths.data;
267+
string[] rootSourcePaths;
268+
if (auto rootTargetIndex = _dub.projectName in gen.targetDescriptionLookup)
269+
{
270+
auto rootTarget = gen.targetDescriptions[*rootTargetIndex];
271+
// upstream PR: https://github.com/dlang/dub/pull/2704
272+
static if (__traits(hasMember, rootTarget.buildSettings, "specifiedSourcePaths"))
273+
{
274+
pragma(msg,
275+
"\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"
276+
~ __FILE__ ~ ":" ~ __LINE__.stringof
277+
~ "\n\n\n\n\n\n\n");
278+
279+
// adds the specified `sourcePaths` of the current package (only) as import paths for DCD
280+
foreach (sourcePath; rootTarget.buildSettings.specifiedSourcePaths)
281+
if (!rootTarget.buildSettings.importPaths.canFind(sourcePath))
282+
rootSourcePaths ~= sourcePath;
283+
}
284+
}
285+
286+
_importPaths = rootSourcePaths ~ importPaths.data;
268287
_stringImportPaths = stringImportPaths.data;
269288
_importFiles = sourceFiles.data;
270289
_versions = versions.data;
@@ -280,6 +299,9 @@ class DubComponent : ComponentWrapper
280299
e.toString);
281300
_importPaths = [];
282301
_stringImportPaths = [];
302+
_importFiles = [];
303+
_versions = [];
304+
_debugVersions = [];
283305
return false;
284306
}
285307
}

0 commit comments

Comments
 (0)