lilypond-user
[Top][All Lists]
Advanced

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

Re: Identify included files


From: Fr. Samuel Springuel
Subject: Re: Identify included files
Date: Tue, 26 May 2020 11:15:32 -0400

> On 26 May, 2020, at 6:18 AM, Matt Wallis <address@hidden> wrote:
> 
> For C/C++, there is an excellent discussion of the issues about automatically 
> producing dependencies and dealing with them in make:
> 
> http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
> 
> I think much of this is relevant to lilypond too. There's even a section 
> entitled "Dependencies for non C files".
> 
> With regard to wanting to avoid typesetting when you want to produce only the 
> dependencies, this section discusses how to set up a makefile to use 
> dependency information that is created as a side-effect of compilation:
> 
> http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#combine
> 
> I know I would find it useful if some of the dependency generation flags 
> (-MMD, -MF, -MP, -MF , see 
> https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html) available on 
> C/C++ preprocessor were implemented in lilypond. The work discussed in this 
> thread might be paving a path towards that.

I hadn’t seen that article before, but I’ve started reading it and can 
definitely see that there are some possibilities there.  I’m going to take the 
time to pursue this and see how I can adapt my process.


> Lilypond can produce multiple output files:
> 
> One difference between C/C++ compilers and lilypond is that where a C 
> compiler produces exactly one .o file for each .c file, lilypond can generate 
>  several output files e.g. .pdf and .midi, but there are other examples too - 
> I sometimes produce a separate .png for each page of a score. And I expect 
> that the set of output files may depend on the lilypond command line options, 
> and not just on the .ly file on which it is being run.
> 
> Is there a way to get lilypond to output this list of targets, analogous to 
> the ly:source-files capability?
> 
> I think in most cases, the issues around multiple targets can be ignored but 
> there may be some cases where a full solution would need to handle them ... 
> more thought required.

I’ve already accounted for this in my most recent version of parse-only.ly.  
It’s not as straight forward as ly:source-files but by looking at 
(ly:get-option 'backend), (ly:get-option 'aux-files), (ly:parser-output-name) 
and (ly:output-formats), it is possible to determine which output files 
lilypond is going to produce (except for the midi, I have yet to find any 
option or function which will indicate that a midi is being produced).  The 
applicable code is:

% Construct list of target extensions
% We look at which backend is being used and what formats have been requested 
to determine this list
% Since some backends cause the list of formats to be ignored, we check that 
first, only looking at the
% formats if the backend would allow that.
#(define target-extensions (cond ((equal? (ly:get-option 'backend) 'svg) (list 
"svg"))
                                 ((equal? (ly:get-option 'backend) 'scm) (list 
"scm"))
                                 ((equal? (ly:get-option 'backend) 'ps) 
(uniq-list (sort-list (ly:output-formats) string<?)))
                                 ((equal? (ly:get-option 'backend) 'eps) (map 
(lambda (str) (if (equal? str "ps") "eps" str)) (uniq-list (sort-list 
(ly:output-formats) string<?))))
                                 (else '())))

% add the "." to the beginning of each extension
#(define target-extensions (map (lambda (str) (string-append "." str)) 
target-extensions))

% For the eps backend, we have to add some additional files which are created 
if the aux-files option is true
#(if (and (equal? (ly:get-option 'backend) 'eps) (ly:get-option 'aux-files))
     (if (member "pdf" target-extensions)
         (append! target-extensions '("-systems.tex" "-systems.texi" 
"-systems.count" "-1.eps" "-1.pdf"))
         (append! target-extensions '("-systems.tex" "-systems.texi" 
"-systems.count" "-1.eps"))))

% Construct list of target files.
% First grab the target-basename: either the same as the basename of the input 
file, or from --output=FILE
% (or --output=DIR/FILE).
% Note: If you use --output=DIR (or --output=DIR/FILE) when calling lilypond, 
then this output directory information
%       is used to change the working directory and discarded.  As a result, 
the make rule output by parsing a
%       lilypond file with this file will not contain this information.
%       If you use -dno-strip-output-dir but not --output=..., then the 
directory information of the *input* file
%       will be part of target-basename.
%       If both -dno-strip-output-dir and --output=FILE (or --output=DIR/FILE) 
then the basename will be taken from
%       --output and all directory information will be lost.
#(define target-basename (ly:parser-output-name))
% The target list is then assembled by appending the target-extensions.
#(define target-files 
     (map 
      (lambda (extension) (string-append target-basename extension))
      target-extensions))



✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝✝
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 ☧ ΧΡΙΣΤΟΣ




reply via email to

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