Skip to content

Commit

Permalink
future-proofed cwd dub fix
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Jan 9, 2023
1 parent 4780aad commit 6e42edf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
9 changes: 5 additions & 4 deletions workspace-d/source/workspaced/com/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -585,14 +585,15 @@ class DubComponent : ComponentWrapper
auto compiler = _compiler;
auto buildPlatform = _platform;

string cwd = instance.cwd;

GeneratorSettings settings;
settings.platform = buildPlatform;
settings.config = _configuration;
settings.buildType = _buildType;
settings.compiler = compiler;
settings.buildSettings = _dub.project.rootPackage.getBuildSettings(buildPlatform, _configuration);

string cwd = instance.cwd;
static if (is(typeof(settings.overrideToolWorkingDirectory)))
settings.overrideToolWorkingDirectory = NativePath(cwd);

auto ret = new typeof(return);
new Thread({
Expand Down Expand Up @@ -638,7 +639,7 @@ class DubComponent : ComponentWrapper
import workspaced.dub.lintgenerator : DubLintGenerator;
import std.file : chdir;

new DubLintGenerator(_dub.project).generate(settings);
new DubLintGenerator(_dub.project, NativePath(cwd)).generate(settings);
}
catch (CompilerInvocationException e)
{
Expand Down
18 changes: 12 additions & 6 deletions workspace-d/source/workspaced/dub/lintgenerator.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ import std.string;

class DubLintGenerator : ProjectGenerator
{
this(Project project)
private
{
NativePath m_cwd;
}

this(Project project, NativePath cwd)
{
super(project);
m_cwd = cwd;
}

override void generateTargets(GeneratorSettings settings, in TargetInfo[string] targets)
Expand All @@ -48,14 +54,12 @@ class DubLintGenerator : ProjectGenerator
private void performDirectBuild(GeneratorSettings settings,
ref BuildSettings buildsettings, in Package pack, string config)
{
auto cwd = NativePath(getcwd());

tracef("%s %s: building configuration %s", pack.name, pack.version_, config);

// make all target/import paths relative
string makeRelative(string path)
{
return shrinkPath(NativePath(path), cwd);
return shrinkPath(NativePath(path), m_cwd);
}

buildsettings.targetPath = makeRelative(buildsettings.targetPath);
Expand All @@ -81,11 +85,13 @@ class DubLintGenerator : ProjectGenerator
buildsettings.lflags = null;
buildsettings.addOptions(BuildOption.syntaxOnly);
buildsettings.sourceFiles = buildsettings.sourceFiles.filter!(f => !isLinkerFile(settings.platform, f)).array;
trace("Build settings: ", buildsettings);

settings.compiler.prepareBuildSettings(buildsettings, settings.platform, BuildSetting.commandLine);

settings.compiler.invoke(buildsettings, settings.platform, settings.compileCallback);
static if (is(typeof(settings.toolWorkingDirectory)))
settings.compiler.invoke(buildsettings, settings.platform, settings.compileCallback, settings.toolWorkingDirectory);
else
settings.compiler.invoke(buildsettings, settings.platform, settings.compileCallback);
}
}

Expand Down

0 comments on commit 6e42edf

Please sign in to comment.