digitalmars.D.learn - dub for lib & app?
- mark (10/10) Feb 04 2020 Is it possible to create a dub project that has one library and
- Andre Pany (6/16) Feb 04 2020 Yes, using sub packages. Set the targetType of the root package
- mark (10/18) Feb 04 2020 Ah, thank you.
- Paul Backus (4/9) Feb 04 2020 For a library, you can name the source files anything you want.
Is it possible to create a dub project that has one library and one or more executables (that use the library)? If so, could someone point me to the docs for this since I couldn't find this in the dub docs? Aside: I'm learning D to give me something approaching the convenience of Python with the fast executable that I'd get with Rust. I love Rust's cargo tool, but find that Rust is very frustrating to do prototyping or experimentation whereas D seems easy for these purposes. But dub does seem a bit basic (or maybe I just haven't found the right docs).
Feb 04 2020
On Tuesday, 4 February 2020 at 09:13:48 UTC, mark wrote:Is it possible to create a dub project that has one library and one or more executables (that use the library)? If so, could someone point me to the docs for this since I couldn't find this in the dub docs? Aside: I'm learning D to give me something approaching the convenience of Python with the fast executable that I'd get with Rust. I love Rust's cargo tool, but find that Rust is very frustrating to do prototyping or experimentation whereas D seems easy for these purposes. But dub does seem a bit basic (or maybe I just haven't found the right docs).Yes, using sub packages. Set the targetType of the root package to None and introduce 2 sub packages of targetType Executable and Library. Kind regards Andre
Feb 04 2020
On Tuesday, 4 February 2020 at 09:21:17 UTC, Andre Pany wrote:On Tuesday, 4 February 2020 at 09:13:48 UTC, mark wrote:[snip]Is it possible to create a dub project that has one library and one or more executables (that use the library)? If so, could someone point me to the docs for this since I couldn't find this in the dub docs?Yes, using sub packages. Set the targetType of the root package to None and introduce 2 sub packages of targetType Executable and Library.Ah, thank you. And if I'm doing *separate* individual projects, for an app, dub creates source/app.d (which I rename src/app.d). But what should it be for a library? Should it be src/package.d along with any supporting src/one.d src/two.do etc? And is this documented anywhere? (I thought I'd seen dub used with a --template argument, but can't find it; so maybe I'm mixing it up with something else?)
Feb 04 2020
On Tuesday, 4 February 2020 at 19:21:07 UTC, mark wrote:Ah, thank you. And if I'm doing *separate* individual projects, for an app, dub creates source/app.d (which I rename src/app.d). But what should it be for a library? Should it be src/package.d along with any supporting src/one.d src/two.do etc?For a library, you can name the source files anything you want. If you put your code in `src/mylib.d`, for example, users of your library can import it with `import mylib`.
Feb 04 2020