Code organization, dub, etc.

Joe jma at fc.com
Mon Mar 13 10:52:11 UTC 2023


I am considering porting 
[Pyrseas](/https://github.com/perseas/Pyrseas) from Python to D.

Pyrseas consists mainly of two executables, `dbtoyaml` and 
`yamltodb`. The former outputs YAML representations of Postgres 
database catalogs and the latter reads the YAML files as well as 
the catalogs of another (or the same) database and outputs SQL to 
sync the definitions. Both programs use a common subpackage named 
`dbobject`.

If I were porting this to C++, I'd use CMake, which would build 
dbobject as a library and both executables with a single `cmake 
--build` (or `ninja` or `make`) command.  In attempting to use 
dub on a similarly structured project, I've found that I'd 
probably have to list each executable as a separate 
"configuration". Furthermore, in order to build both executables, 
I have to either invoke dub twice, i.e., `dub build -c dbtoyaml; 
dub build -c yamltodb`. If I don't specify a configuration, only 
the first one listed in dub.json is built and if I specify two or 
more, only the last one in the command line is built. I know that 
I can create a Makefile with both programs listed in an `all` 
target, but that sort of defeats the purpose of using dub as a 
"build" tool. I have also found a `cmake-d` project on GitHub but 
it hasn't been touched for 18 months.  Am I missing something on 
how to deal with multi-executable projects in dub (and I can 
think of many such projects)?

I also tried to use `dfmt` and found it limited in comparison to 
`clang-format`. I do realize that dfmt is a community-supported 
tool.

I find that D has much to offer in terms of language facilities 
and simplicity. About the only bump in the learning curve is the 
distinction between structs and classes. However, from a 
practical adoption perspective, it seems that in attempting to 
provide all the "batteries" it circumscribes itself to what is or 
can become available in its own community. If I understand 
correctly, GDC and LDC came into being because some people in the 
GCC and LLVM communities became interested in D.  Has someone 
approached Kitware or the CMake community to determine the 
feasibility of supporting D? A similar question arises for 
clang-format, which (to my surprise) supports C#, Java and more?


More information about the Digitalmars-d-learn mailing list