dub
dub copied to clipboard
Compilation for library type doesn't work when dub project contains "mainSourceFile"
System information
- dub version: 1.29.1
- OS Platform and distribution: Windows 10
- compiler version v2.100.1
Bug Description
Compilation doesn't work, dmd will not report problems
How to reproduce?
{
"name": "dll",
"targetType": "dynamicLibrary",
"mainSourceFile": "src/dllmain.d",
"sourcePaths": [
"src" ,
],
"importPaths": [
"src",
],
"dflags": [
"-betterC",
],
}
import core.sys.windows.windows;
import core.stdc.stdio;
sdsdsfdfdf
extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved)
{
return true;
}
Expected Behavior
It should complain about sdsdsfdfdf
Solution
The solution was to remove the "mainSourceFile" from the dub.json file
Same behavior with staticLibrary yes?
Same with "staticLibrary", and same with "library"
Ok, so a check some place is missing an exception for shared libraries.
https://github.com/dlang/dub/blob/fe09137708faac9f334eb08ab7d18ec9c2bd6b5c/source/dub/generators/generator.d#L310
Change that goto to a break and it should work.
mainSourceFile is excluded by default in libraries. We should probably warn / error if there is a mainSourceFile in a library configuration.