Phobos posix.mak -> D file using reggae: round 2

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 18 08:15:26 PDT 2016


Here's[1] another attempt at converting the Makefile for POSIX 
systems to D using reggae[2]. I first tried my hand at writing a 
parser for Makefiles using Pegged and machine translating to D. I 
learned a lot about parsing and GNU make in the process and also 
that:

1. It was about two orders of magnitude more work than I thought 
to support the subset of GNU make used by posix.mak
2. The generated D code wasn't exactly pretty

I concluded that worse is better and hand translated all of 
posix.mak instead. It isn't as pretty as possible either, but 
that's on purpose - since I'll have to mentally apply any further 
diffs and hand translate, I tried to make it as close as possible 
to the existing Makefile. That way the edits should be obvious.

AFAICT by testing manually, it does everything that the original 
Makefile does, including all the different unit test targets and 
documentation. Then again, I only tested on Linux. I've been 
trying to bend the auto-tester to my will to make sure all 
posix.mak systems are still green but I ran into configuration 
issues.

I'll carry on maintaining the D description as updates to 
posix.mak happen for a year. If we haven't switched by then we 
probably never will.

To try it out yourself, get & build/run reggae from dub in this 
branch at the root dir of phobos selecting the backend of choice 
with `-b <backend>`. I suggest the binary one since one of the 
points of this is to remove dependencies from other build 
systems. Then run make/ninja/tup/./build with the same targets as 
usual. If that doesn't work... open an issue on github.

Destroy!

Atila


[1] https://github.com/atilaneves/phobos/blob/reggae/reggaefile.d
[2] https://github.com/atilaneves/reggae


More information about the Digitalmars-d mailing list