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

2011-10-05 Thread Graham Percival
On Sun, Oct 02, 2011 at 02:50:12PM +0200, Julien Rioux wrote:
> 
> I had a look at website.make, and it strikes me as a shell script
> written in make.

That's quite a fair assesement.

> 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.

Looks nice, and it seems to work, but I'm not certain that I
follow all the steps.  More comments?  :)

Specifics:
- line 107 has an extra trailing )
- comments like lines 105 and 109 should probably read "get xrefs
  for english te?? manuals"
- I'm not certain if web is "a little bit special" (line 119) or
  not.  My initial instinct is that it's not special in this
  context.

Cheers,
- Graham

___
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel


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

2011-10-02 Thread Julien Rioux

On 01/10/2011 2:35 PM, Graham Percival wrote:

On Sat, Oct 01, 2011 at 02:12:44AM +0200, olafbuddenha...@gmx.net 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
>From eeadbebd9e1be5a08c7d202e9a70707faa016e2d Mon Sep 17 00:00:00 2001
From: Julien Rioux 
Date: Sun, 2 Oct 2011 08:36:46 -0400
Subject: [PATCH] Makeify the website build.

---
 make/website.make |   85 +++-
 1 files changed, 51 insertions(+), 34 deletions(-)

diff --git a/make/website.make b/make/website.make
index ba646b2..54b3738 100644
--- a/make/website.make
+++ b/make/website.make
@@ -54,11 +54,17 @@ endif
 
 OUT=out-website
 
-WEB_LANGS = $(shell MAKEWEB=1 $(PYTHON) $(top-src-dir)/python/langdefs.py)
+WEB_LANGS := $(shell MAKEWEB=1 $(PYTHON) $(top-src-dir)/python/langdefs.py)
 
 TEXI2HTML=ONLY_WEB=1 TOP_SRC_DIR=$(top-src-dir) DEPTH=$(depth) PERL_UNICODE=SD $(TEXI2HTML_PROGRAM)
 
-EXTRACT_TEXI_FILENAMES=python $(script-dir)/extract_texi_filenames.py
+EXTRACT_TEXI_FILENAMES=echo Generating $@ from $< && \
+	$(PYTHON) $(script-dir)/extract_texi_filenames.py $(quiet-flag) \
+	--known-missing-f