On 1/13/15 7:44 PM, Daniel Murphy wrote:
"Andrei Alexandrescu" wrote in message
news:[email protected]...
Over the time a number of stuff has become quite duplicated across our
makefiles for dmd, druntime, and phobos.
These include fetching OS and model but (newer) general-purpose macros
for e.g. rebasing repos, see
https://github.com/D-Programming-Language/dlang.org/blob/master/posix.mak#L37.
I think it's time to reduce clutter and duplication by migrating such
common stuff into one common.mak file. Question is, where should that
file sit? One candidate is tools/ but it's not really a tool. Another
candidate is dmd/src/ because that would be the first thing anyone
depends on.
Ideas?
If it's optional extra stuff like git shortcuts, then removing it from
the makefiles and putting it in tools makes sense. If it's mandatory
stuff like OS detection, then it needs to stay where it is.
Hmmm... I wonder why the distinction.
What's the actual problem you're trying to solve with this? IMO
duplication is less of a problem than overcomplicating the makefiles.
The problem is basic code duplication with its known liabilities. I'm
looking at stuff like this:
https://github.com/D-Programming-Language/dlang.org/blob/master/posix.mak#L58
https://github.com/D-Programming-Language/phobos/blob/master/posix.mak#L31
https://github.com/D-Programming-Language/druntime/blob/master/posix.mak#L8
Three's a charm. That code is relatively verbose (required newlines). I
trust it doesn't need updates often, but it occupies real estate in a
readily accessible position (beginning of file).
The real issue here is that acquiescing to such duplication discourages
attempts at uniformization before they occur. I'm thinking of simpler,
clearer naming conventions and uniform ways of doing the same things
(such as unittesting or documentation).
Getting back to REBASE
(https://github.com/D-Programming-Language/dlang.org/blob/master/posix.mak#L37),
it greatly simplifies my building the entire website in a way I trust is
nice:
make rebase -j && make clean && make rsync -j
(Sadly make clean is necessary because of dub, which makes the process
take a lot longer than it should; with luck, somebody will improve on
that soon.)
Now "make rebase" is really useful for druntime and phobos as well. But
between duplicating more code or just doing it by hand, one may as well
give up and choose the latter.
I'd also like to define "make rebase-dirty" based on this:
REBASE_DIRTY = MYBRANCH=`git rev-parse --abbrev-ref HEAD` &&\
git stash &&\
git co master &&\
git pull --ff-only upstream master &&\
git co $$MYBRANCH &&\
git rebase master &&\
git stash pop
which is useful because it lets me rebase on top of work in progress.
Again the prospect of duplicating this other macro across 3-4 projects
is fairly unattractive.
Andrei