From df3033dd0c69e840139008ffaa3b04bc05419a31 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Wed, 27 Sep 2023 03:08:21 +0200 Subject: [PATCH] prepare for supporting sourcePaths for DCD needs upstream changes in DUB merged first --- workspace-d/dub.sdl | 3 +++ workspace-d/source/workspaced/com/dub.d | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/workspace-d/dub.sdl b/workspace-d/dub.sdl index 26f226b7..7197026c 100644 --- a/workspace-d/dub.sdl +++ b/workspace-d/dub.sdl @@ -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" diff --git a/workspace-d/source/workspaced/com/dub.d b/workspace-d/source/workspaced/com/dub.d index 31d6caae..b001be20 100644 --- a/workspace-d/source/workspaced/com/dub.d +++ b/workspace-d/source/workspaced/com/dub.d @@ -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; @@ -280,6 +299,9 @@ class DubComponent : ComponentWrapper e.toString); _importPaths = []; _stringImportPaths = []; + _importFiles = []; + _versions = []; + _debugVersions = []; return false; } }