Skip to content

Commit

Permalink
Fix #2698: cImportPaths doesn't work with dmd and ldc
Browse files Browse the repository at this point in the history
  • Loading branch information
apbryan authored and Geod24 committed Feb 6, 2024
1 parent 5130176 commit 84510a1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog/fix-cimport-paths.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix issue where cImportPaths wasn't working with dmd and ldc

dub was passing -I<import path> instead of -P-I<import path> as is required by those compilers
2 changes: 1 addition & 1 deletion source/dub/compilers/dmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ config /etc/dmd.conf
}

if (!(fields & BuildSetting.cImportPaths)) {
settings.addDFlags(settings.cImportPaths.map!(s => "-I"~s)().array());
settings.addDFlags(settings.cImportPaths.map!(s => "-P-I"~s)().array());

Check warning on line 260 in source/dub/compilers/dmd.d

View check run for this annotation

Codecov / codecov/patch

source/dub/compilers/dmd.d#L260

Added line #L260 was not covered by tests
settings.cImportPaths = null;
}

Expand Down
2 changes: 1 addition & 1 deletion source/dub/compilers/ldc.d
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ config /etc/ldc2.conf (x86_64-pc-linux-gnu)
}

if (!(fields & BuildSetting.cImportPaths)) {
settings.addDFlags(settings.cImportPaths.map!(s => "-I"~s)().array());
settings.addDFlags(settings.cImportPaths.map!(s => "-P-I"~s)().array());

Check warning on line 140 in source/dub/compilers/ldc.d

View check run for this annotation

Codecov / codecov/patch

source/dub/compilers/ldc.d#L140

Added line #L140 was not covered by tests
settings.cImportPaths = null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int bar(void)
{
printf("func bar in foo.h\n");
}
5 changes: 5 additions & 0 deletions test/issue2698-cimportpaths-broken-with-dmd-ldc/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name "issue2698-cimportpaths-broken-with-dmd-ldc"
description "test issue 2698"
authors "alexander bryan"
cSourcePaths "source"
cImportPaths "c_headers"
7 changes: 7 additions & 0 deletions test/issue2698-cimportpaths-broken-with-dmd-ldc/source/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import std.stdio;
import foo;

void main()
{
bar();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "foo.h"

0 comments on commit 84510a1

Please sign in to comment.