diff --git a/changelog/fix-cimport-paths.dd b/changelog/fix-cimport-paths.dd new file mode 100644 index 000000000..7bab23dc4 --- /dev/null +++ b/changelog/fix-cimport-paths.dd @@ -0,0 +1,3 @@ +Fix issue where cImportPaths wasn't working with dmd and ldc + +dub was passing -I instead of -P-I as is required by those compilers diff --git a/source/dub/compilers/dmd.d b/source/dub/compilers/dmd.d index 587079d01..485fc2486 100644 --- a/source/dub/compilers/dmd.d +++ b/source/dub/compilers/dmd.d @@ -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; } diff --git a/source/dub/compilers/ldc.d b/source/dub/compilers/ldc.d index 0ca58c29e..bf9288b88 100644 --- a/source/dub/compilers/ldc.d +++ b/source/dub/compilers/ldc.d @@ -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; } diff --git a/test/issue2698-cimportpaths-broken-with-dmd-ldc/c_headers/foo.h b/test/issue2698-cimportpaths-broken-with-dmd-ldc/c_headers/foo.h new file mode 100644 index 000000000..dab60af48 --- /dev/null +++ b/test/issue2698-cimportpaths-broken-with-dmd-ldc/c_headers/foo.h @@ -0,0 +1,6 @@ +#include + +int bar(void) +{ + printf("func bar in foo.h\n"); +} diff --git a/test/issue2698-cimportpaths-broken-with-dmd-ldc/dub.sdl b/test/issue2698-cimportpaths-broken-with-dmd-ldc/dub.sdl new file mode 100644 index 000000000..837f5274d --- /dev/null +++ b/test/issue2698-cimportpaths-broken-with-dmd-ldc/dub.sdl @@ -0,0 +1,5 @@ +name "issue2698-cimportpaths-broken-with-dmd-ldc" +description "test issue 2698" +authors "alexander bryan" +cSourcePaths "source" +cImportPaths "c_headers" diff --git a/test/issue2698-cimportpaths-broken-with-dmd-ldc/source/app.d b/test/issue2698-cimportpaths-broken-with-dmd-ldc/source/app.d new file mode 100644 index 000000000..6413a1cd8 --- /dev/null +++ b/test/issue2698-cimportpaths-broken-with-dmd-ldc/source/app.d @@ -0,0 +1,7 @@ +import std.stdio; +import foo; + +void main() +{ + bar(); +} diff --git a/test/issue2698-cimportpaths-broken-with-dmd-ldc/source/foo.c b/test/issue2698-cimportpaths-broken-with-dmd-ldc/source/foo.c new file mode 100644 index 000000000..f4de601ff --- /dev/null +++ b/test/issue2698-cimportpaths-broken-with-dmd-ldc/source/foo.c @@ -0,0 +1 @@ +#include "foo.h"