-
-
Notifications
You must be signed in to change notification settings - Fork 230
Cookbook
- Creating windows package that has 32 and 64-bit dlls
- Working with submodules or packages that are not in the registry
- Adding multiple versions of a local package
- Creating a custom main for the test build
###Creating windows package that has 32 and 64-bit dlls
-
Create
lib
andlib64
folders in your project root (the same folder asdub.json
) -
Put your 32-bit dll files in a
lib
folder and 64-bit dlls inlib64
Dub offers copyFiles build setting that we will use to get things done. This option allows to copy files to the applications directory. Also this option can have platform specific suffixes, which we will use to copy specific files to each platform. -
Put these lines in your dub.json. They will copy every
.dll
file found in lib folder into application folder.
"copyFiles-windows-x86" : ["lib/*.dll"],
"copyFiles-windows-x86_64" : ["lib64/*.dll"],
-
Final folder structure:
project dub.json /lib freetype.dll, etc. /lib64 freetype.dll, etc. 64-bit version
###Working with submodules or packages that are not in the registry
It is a common practice to either have a project as a git submodule of a master project, or to use an unregistered project as a dependency for development.
In this setup, setting the project to depend on a project at a given path, rather than looking up the repository, can come handy.
Here's an example of such a package:
````json
{
"name": "dlang-org",
"dependencies": [
"libddoc": { "path": "./libddoc" },
"libdparse": { "path": "./libdparse" }
]
}
Another possibility is to add-local a package. This is particular useful during development, when you want to test a package with some libraries using that package.
dub add-local myrepo
dub list
###Adding multiple versions of a local package
To use different versions of a local package, one can clone the local repo, check out specific versions, and dub add-local
each clone.
git clone -b v0.2.0 myrepo myrepo-0.2.0
dub add-local myrepo-0.2.0
git clone -b v0.2.1 myrepo myrepo-0.2.1
dub add-local myrepo-0.2.1
See #525 for more details.
###Creating a custom main for the test build
You can override the main function that dub creates by passing the path of the file with the custom main implementation to --main-file
flag.
example customTest.d
import dub_test_root; //import the list of all modules
int main() {
// allModules contains a list of all modules from your project
// you might want to call something like this:
return runUnitTests!allModules;
}
execute:
dub test --main-file=customTest.d