> On 15 May, 2020, at 12:03 PM, Fr. Samuel Springuel <[email protected]> > wrote: > >> On 15 May, 2020, at 3:43 AM, Valentin Villenave <[email protected]> >> wrote: >> >> On 5/15/20, Fr. Samuel Springuel <[email protected]> wrote: >>> Before I start writing a script to do this, is there an existing tool which >>> will identify all the `\include` files that a LilyPond file depends on? >>> Even better, one that will work in a recursive fashion? >> >> Since 2.19.39, you can simply use this: >> >> #(display (ly:source-files)) >> > > I’m hoping for something that doesn’t require actually typesetting the > document. My end goal is a script which will somewhat intelligently > determine which files in a project have changed and re-typeset them as > needed. Having to typeset the document in order to determine which files it > depends on means I’ve already done the typesetting. Is there a way to pass > that and \set Score.skipTypesetting = ##t at the command line? >
So, I’ve done some experimenting on my own and here’s what I’ve discovered: `-dno-print-pages` will prevent lilypond from producing typeset output. My preliminary testing seems to indicate that this is indeed faster than actually typesetting, but I haven’t rigorously tested this to determine what kind of speed up is produced. `#(display (ly:source-files))` must be after any `\include` statements in the LilyPond file in order for the list to be complete. As such, it is best positioned at the end of the file. `lilypond -` will read in from stdin, allowing piping input into the command and thus using pipes to modify a file “on-the-fly” without actually changing the file on the disk. Combining all this, I get the following: echo "#(display (time ly:source-files))" | cat <file> - | lilypond -dno-print-pages - This will send a list of the included files to stdout (there’s also some stuff on stderr which you’ll see if testing on the console). The first two entries will be `init.ly` (with full path) and `-`, which can be thrown away, but the remaining entries are what I’m looking for (and it’s fully recursive). One difficulty: if reading input from stdin, `\include` statements which navigate through the directory tree may experience problems if there is a mismatch between the current working directory and the location of the file being pushed through the pipes to stdin. One way to get around this is to make use of the --include option to add in the directory of the file. One easy way to do this is to define a variable `filename` with the name of the file, then the full command is: echo "#(display (time ly:source-files))" | cat “$filename" - | lilypond --include="$(dirname $filename)" -dno-print-pages - Now I just need to turn this list into something that can be used to figure out if the target needs to be recompiled. ✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝ Fr. Samuel, OSB (R. Padraic Springuel) St. Anselm’s Abbey 4501 South Dakota Ave, NE Washington, DC, 20017 202-269-2300 (c) 202-853-7036 PAX ☧ ΧΡΙΣΤΟΣ
