Hipreme's #8 Tip of the day - Using custom runtime with dub projects

Hipreme msnmancini at hotmail.com
Sun Jan 22 16:57:56 UTC 2023


I have been working with WebAssembly for at least 1 entire month 
into getting my entire Game Engine and DRuntime ported to it. As 
I'm almost reaching the point of the new announcement, I come 
here to show how I've done DUB's dependency compatibility with a 
custom runtime.

The way to use dub's packages is by using the DFLAGS. With 
DFLAGS, I can set the import path to my own DRuntime and own std. 
That way I can make the dependencies behave more or less the 
same, this is an example of what is being done now:


```
set DFLAGS=-I=%HIPREME_ENGINE%/modules/d_std/source ^
-I=%HIPREME_ENGINE%/build/wasm/runtime/webassembly/arsd-webassembly ^
-preview=shortenedMethods ^
-L-allow-undefined ^
-fvisibility=hidden ^
-d-version=CarelessAlocation

dub build --build=debug -c wasm  
--arch=wasm32-unknown-unknown-wasm
```


So, when dub tried to build their dependencies, your custom 
runtime overrides D's default ones. In that case I'm overriding 
both D std and D core/** and object.d

Keep in mind that you'll probably need to setup some env 
variables such as mine done for making your script a little more 
portable to other developer's PCs. I would really like if there 
was a way to define global dflags on dub though.


More information about the Digitalmars-d-learn mailing list