www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dynamic linker flags with dub

reply KytoDragon <kytodragon notmyemail.com> writes:
I want to use dll-style hot-reloading for a windows application 
which requires a different name for the PDB file for each 
compilation. (windows locks the pdb file when loading the dll and 
the compiler can't create a new pdb with the same name). How can 
I achieve this with dub? Is there a way to inject variables into 
the linker flags?

E.g. something like this in the dub.json:

"lflags-windows-ldc": ["/PDB:foo_%random%.pdb"]
Apr 29
next sibling parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 30/04/2024 10:20 AM, KytoDragon wrote:
 I want to use dll-style hot-reloading for a windows application which 
 requires a different name for the PDB file for each compilation. 
 (windows locks the pdb file when loading the dll and the compiler can't 
 create a new pdb with the same name). How can I achieve this with dub? 
 Is there a way to inject variables into the linker flags?
 
 E.g. something like this in the dub.json:
 
 "lflags-windows-ldc": ["/PDB:foo_%random%.pdb"]
Your best bet probably is to use dub as a library, and change your ``targetName`` or ``targetPath`` on each compilation. Alternatively you could generate your dub file with the change in it each time that depends upon the actual library (which would be a ``sourceLibrary``).
Apr 29
prev sibling parent KytoDragon <kytodragon notmyemail.com> writes:
For anyone looking for a solution, i created a batch-file called 
"ldc2_random.bat" with this content:

```
 echo off
del myapp_*.pdb > NUL 2> NUL
ldc2 %* -L/PDB:myapp_%random%.pdb
```

and then set my compiler to "--compiler=ldc2_random.bat"
Jun 15