DUB - call to arms

Julian julian.fondren at gmail.com
Wed Apr 17 18:17:25 UTC 2019


On Wednesday, 17 April 2019 at 17:53:35 UTC, H. S. Teoh wrote:
> In other words, we hide the complexity of the build system
> under one or more canned invocation commands (e.g., 'make',
> 'make clean', 'make docs', 'make test', for a standard set of
> actions you might commonly want to do), and have the wrapper
> package tell us what the build artifacts are.

What you lose with this is dub's current platform independence.
That's not always present anyway, for example a project could rely
on specific cPanel or macOS features, but it would be nice to
retain it as the default.

Ada's gprbuild has project files like this:

   project Packetbl is
      for Object_Dir use "build";
      for Exec_Dir use "bin";
      for Source_Dirs use ("src");
      for Languages use ("Ada", "C");
      for Main use ("packetbl.adb");
      package Compiler is
         for Default_Switches ("Ada") use ("-O3", "-gnata", 
"-gnaty-m", "-gnatwa");
         for Default_Switches ("C") use ("-O3", "-Wall");
      end Compiler;
      package Linker is
         for Default_Switches ("Ada") use ("-lnfnetlink", 
"-lnetfilter_queue", "-lanl");
      end Linker;
   end Packetbl;

So, this project uses Ada and C languages, a binary should be 
built
with packetbl.adb as the main, and other language files under src/
are linked in. This project doesn't bother to list source files,
but gprbuild knows what .adb/.ads and .c files are, so it builds
them all with the appropriate compiler and then links them
together.

To know how to compile, gprbuild has a system configuration that
includes the exact compilers to use for each language, their 
paths,
etc. The sort of thing you'd set with 'dub init', with probable
defaults, and with compiler knowledge (of how to invoke "gcc",
"clang", etc.) built into dub.


More information about the Digitalmars-d mailing list