Search code examples
ddub

In dub, how do I set a custom optimization level to only certain files?


I have some files that are several megabytes generated code. I would like to compile those files only with optimization level 0, and all other files with optimization level 3. How would I specify this in dub?

If the generated code files compile at -O3, they never finish compiling.


Solution

  • dub is not set up to have you list specific files. It pulls in every file in whatever source directories you set. As such, it really isn't set up to have some files compiled one way and some another. However, you could always create a sub-package just for those files, and have its dub configuration set with flags to optimize it differently. However, at that point, it is technically a separate library, so your actual code has to be organized in a way for that separation to work.