dub
dub copied to clipboard
The compiler is not setting options for the C preprocessor even though "cImportPaths" is set in dub.json.
This is related to the following post in the forum. Dub option for specifying importC include paths
System information
- dub version: 1.34.0(dmd-v2.105.1), 1.33.1(ldc2-1.34.0)
- OS Platform and distribution: Windows 10
- compiler version: dmd-v2.105.1, ldc2-1.34.0 (DMD v2.104.2, LLVM 16.0.6)
Bug Description
The compiler is not setting options for the C preprocessor even though "cImportPaths" is set in dub.json.
In the following code, Lack of append -P when editing DFlag.
settings.addDFlags(settings.cImportPaths.map!(s => "-I"~s)().array());
at
dub/1.34.0/dub/source/dub/compilers/dmd.d(255,32): settings.addDFlags(settings.cImportPaths.map!(s => "-I"~s)().array());
dub/1.34.0/dub/source/dub/compilers/gdc.d(114,32): settings.addDFlags(settings.cImportPaths.map!(s => "-I"~s)().array());
dub/1.34.0/dub/source/dub/compilers/ldc.d(135,32): settings.addDFlags(settings.cImportPaths.map!(s => "-I"~s)().array());
How to reproduce?
dub.json
{
"name": "test",
"cImportPaths": ["include_path"]
}
(base) PS D:\labo\dlang\work\test> D:\scoop\user\apps\dmd\2.105.1\windows\bin\dub.exe build -v --compiler=dmd
Building test ~master: building configuration [application]
[cwd=D:/labo/dlang/work/test] dmd -m64 -c -ofC:\Users\kinut\AppData\Local\dub\cache\test\~master\build\application-debug-wwJttrcyM7Ir6TFENv5q2A\test.obj -debug -g -w -version=Have_test -Isource -Iinclude_path source\app.d -vcolumns
(base) PS D:\labo\dlang\work\test> D:\scoop\user\apps\ldc\1.34.0\bin\dub.exe build -v --compiler=ldc2
Building test ~master: building configuration [application]
ldc2 -c -ofC:\Users\kinut\AppData\Local\dub\cache\test\~master\build\application-debug-GclWdmZTTjBXFPnUBK5wPg\test.obj -d-debug -g -w --oq -od=C:\Users\kinut\AppData\Local\dub\cache\test\~master\build\application-debug-GclWdmZTTjBXFPnUBK5wPg/obj -d-version=Have_test -Isource -Iinclude_path source\app.d -vcolumns
Expected Behavior
dmd --help
(base) PS D:\labo\dlang\work\test> dmd --help
-P=<preprocessorflag>
pass preprocessorflag to C preprocessor
In dmd, -Iinclude_path should be -P=-Iinclude_path
ldc2 --help
(base) PS D:\labo\dlang\work\test> ldc2 --help
-P <cppflag> - Pass <cppflag> to C preprocessor
In ldc, -Iinclude_path should be -P-Iinclude_path
In gdc, it appears -Iinclude_path works, though it is undocumented