What's the proper way to add a local file dependence to dub?
Jacob Carlborg
doob at me.com
Tue Mar 6 17:59:06 UTC 2018
On 2018-03-04 17:46, Marc wrote:
> then copy it to sources folder?
>
> let's say I have a small library folder at C:\mylibrary\D where I want
> to use dir.d from it. How do I add that file dependence to dub? But I do
> not want to that file be passed directly to dmd, I want to that file be
> copied to application's source folder (so it's easy to distribuite, with
> the dependences together as possible) then compiled. So, what I want to
> some extension is dub work with loca files.
> Is this possible to do solely with dub? I know I can easily write a
> script to run before dub which copies the dependence files from
> C:\mylibrary to application's source but I'm looking for a more elegant
> approach as possible; I'm afraid of rewriting a makefile-like soon (I
> find cmake/make/makefiles just ugly).
You can use "preGenerateCommands" or "preBuildCommands" to run arbitrary
commands before Dub builds the project [1]. Alternativly you can use the
"import" expression [2], together with the "stringImportPaths" Dub build
setting. The "import" expression will embed the file into the executable
as a string literal.
[1] https://code.dlang.org/package-format?lang=sdl#build-settings
[2] https://dlang.org/spec/expression.html#import_expressions
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list