Skip to content

Commit

Permalink
Fix dlang#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 55e3ad4 commit 6c0e3a3
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());
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());
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 6c0e3a3

Please sign in to comment.