Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 2698: cImportPaths doesn't work with dmd and ldc #2818

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -212,7 +212,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 @@ -133,7 +133,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");
}
Comment on lines +3 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing the implementation in .h files is a terrible practice.
How about declaring the type as a struct or something instead of a function?

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"
Loading