[GSoC] Header Generation for C/C++

Iain Buclaw ibuclaw at gdcproject.org
Wed Jul 17 12:40:38 UTC 2019


On Tue, 16 Jul 2019 at 15:20, Eduard Staniloiu via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> Project goal
> ------------
>
> The deliverable of the project is a tool that automatically
> generates C and C++
> header files from D module files. This can be achieved either by
> a library solution using
> DMD as a Library, or by adding this feature in the DMD frontend
> through a compiler
> switch.
>
> The advantage of using DMD as a Library is that this wouldn’t
> increase the
> complexity of compiler frontend codebase. The disadvantage will
> be that the user will be
> required to install a third-party tool. Contrasting to this, the
> addition of the feature to the
> frontend would result in a smoother integration with all the
> backends that use the DMD
> frontend.
>
> We have decided to go with the compiler switch approach.
>
> One major milestone (and success marker) for the project is to
> automatically generate the
> DMD frontend headers required by GDC/LDC.
>

As there will be for a long time the need to bootstrap, I think the
desired end result would be to have the generated header checked in to
dmd, and for this header to be rebuilt during the 'make' build
process.

The CI infrastructure we have can then assert that this header doesn't
change during the build, so PRs should never forget to check-in the
new header.

>
> So now, the current state of affairs is that the code in the PR
> [0] can link with and pass the `cxx-unittests`.
>

So it's probably worth giving the generated header a test against gdc then.

https://github.com/gcc-mirror/gcc/tree/ibuclaw/gdc


> How to use it
> -------------
>
> The current PR [0] code is generating a `C++` header file out of
> a list of `.d` modules passed at compile time.
>
> The simplest form of the CLI switch is `dmd -HC a.d b.d`
>
> This will visit the ASTs of modules `a` and `b` and output a
> single header file at `stdout`.
>
> By using the `-HCf=<file-name>` switch, the above result will be
> written in specified file name. Using `-HCd=<path>` will write
> the `file-name` in the specified `path`.
>
> So, by running,
> `dmd -HCf=ab.h -HCd=mypath/ a.d b.d` will write the generated
> header in `mypath/ab.h`, relative to the current directory.
>
> If you have some spare time and curiosity I would appreciate your
> `test drive` and bug reports :)
>

So this would be part of the compiler rather than a standalone
application?  What's the rationale there?

-- 
Iain



More information about the Digitalmars-d mailing list