lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: website.make (was: Moving away from make)


From: Julien Rioux
Subject: Re: website.make (was: Moving away from make)
Date: Sun, 02 Oct 2011 14:50:12 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1

On 01/10/2011 2:35 PM, Graham Percival wrote:
On Sat, Oct 01, 2011 at 02:12:44AM +0200, address@hidden wrote:
It might be true that Python is more readable for newcomers than make
(though reading your examples, I'm not at all convinced of that...) --
but how much does that really matter?

Many people already have some familiarity with python --
particularly in lilypond, where a good chunk of our code is in
python.  This lessens the burden of understanding build-system
stuff.

The reason casual contributors
have trouble making build system modifications, is not the syntax (which
is really easy to learn IMHO), but the fact that build systems are
inherently a very complex matter. (As you observed yourself...) The best
syntax imaginable won't do anything to change this.

The benefit of python is that you can leverage existing python
knowledge, as well as using niceties like loops and functions.

For example, take a look at make/website.make.  I spent somewhere
on the order of 50 hours working on the new website build system
(including other scripts, not just that file).  I found some info
on creating loops in gnu make, but it didn't seem possible to have
loops in pure bsd make.  So I resorted to bash, i.e.:

website-xrefs: website-version
         for l in '' $(WEB_LANGS); do \
                 len="$${#l}" ; \
                 r="$$l"; \
                 if [ "$$len" -gt "0" ] ; then \
                         r="$$r"/; \
                 fi ; \
                 $(EXTRACT_TEXI_FILENAMES) \
                         -I $(top-src-dir)/Documentation \
                         -I $(top-src-dir)/Documentation/"$$l" \
                         -I $(OUT) -o $(OUT) --split=node \
                         
--known-missing-files=$(top-src-dir)/scripts/build/website-known-missing-files.txt
\
                         $(quiet-flag) \
                         $(top-src-dir)/Documentation/"$$l"/web.texi
;\
                 for m in $(MANUALS); do \
                         n=`echo "$$m" | sed
's/Documentation/Documentation\/'$$l'/'` ; \
                         b=`basename "$$n" .texi`; \
                         d=`basename "$$b" .tely`; \
                         if [ -e "$$n" ] ; then \
                                 $(EXTRACT_TEXI_FILENAMES) \
                                 -I $(top-src-dir)/Documentation \
                                 -I
$(top-src-dir)/Documentation/"$$l" \
                                 -I
$(top-src-dir)/Documentation/"$$r""$$d" \
                                 
--known-missing-files=$(top-src-dir)/scripts/build/website-known-missing-files.txt
\
                           $(quiet-flag) \
                                 -I $(OUT) -o $(OUT) "$$n" ; \
                         fi ; \
                 done; \
         done;


this is, of course, completely disgusting.  line continuations on
top of a bash for loop on top of make results in horrible
substition rules like
        len="$${#l}"

I really, really wish that I could have written this in python.
Rewriting that as 2 or 3 python functions would make it so much
easier to read and understand!
(can you have functions in makefiles?  that would simplify stuff)


I may have missed some simple way to do the above in make.  If so,
please let me know about it!

Cheers,
- Graham

I had a look at website.make, and it strikes me as a shell script written in make. As with any occurrence of language A rewritten in language B, it reads as a literal translation instead of switching concepts to the new language, and doesn't exploit the concepts and advantages of the new language. For make: automatic dependency tree, only perform necessary actions, parallel builds, all are thrown out the door.

You of course have loops in make, attached you find a short rewrite of that particular snippet. I can probably reduce it to even fewer targets and make it simpler. If you want me to, I can look at the whole file to makeify it.

--
Julien

Attachment: 0001-Makeify-the-website-build.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]