From 0af04b384b79837d4da7b2bab314066c7f947b20 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Sun, 5 Jul 2009 12:56:34 -0700 Subject: [PATCH] Add a new program option: -dwarning-as-error (Thanks to Han-Wen and Jan for the initial idea) - If a valid stencil expression is found, but is undefined in the current backend, issue a warning for every occurrence. - The option -dwarning-as-error will cause LilyPond to output an error and exit upon the first warning encountered. --- lily/paper-outputter.cc | 7 +++++++ lily/program-option-scheme.cc | 2 ++ scm/backend-library.scm | 17 +++++++++++++++-- scm/lily.scm | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 6aedacca91..3f98b8eb86 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -37,6 +37,13 @@ Paper_outputter::Paper_outputter (SCM port, string format) string module_name = "scm output-" + format; output_module_ = scm_c_resolve_module (module_name.c_str ()); + + /* + Enable errors for undefined stencil routines if + -dwarning-as-error is specified; else enable warnings. + */ + SCM proc = ly_lily_module_constant ("backend-testing"); + scm_call_1 (proc, output_module_); } Paper_outputter::~Paper_outputter () diff --git a/lily/program-option-scheme.cc b/lily/program-option-scheme.cc index 1e03c5f951..dca0490288 100644 --- a/lily/program-option-scheme.cc +++ b/lily/program-option-scheme.cc @@ -113,6 +113,8 @@ internal_set_option (SCM var, relative_includes = to_boolean (val); val = scm_from_bool (to_boolean (val)); } + else if (var == ly_symbol2scm ("warning-as-error")) + val = scm_from_bool (to_boolean (val)); scm_hashq_set_x (option_hash, var, val); } diff --git a/scm/backend-library.scm b/scm/backend-library.scm index 301868cb84..71ef9096f8 100644 --- a/scm/backend-library.scm +++ b/scm/backend-library.scm @@ -8,6 +8,9 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; backend helpers. +(use-modules (scm ps-to-png) + (ice-9 optargs)) + (define-public (ly:system command . rest) (let* ((status 0) (dev-null "/dev/null") @@ -118,8 +121,6 @@ (ly:progress "\n") (ly:system cmd))) -(use-modules (scm ps-to-png)) - (define-public (postscript->png resolution paper-width paper-height name) (let* ((verbose (ly:get-option 'verbose)) (rename-page-1 #f)) @@ -189,3 +190,15 @@ scope))) (apply string-append (map output-scope scopes))) +(define-public (backend-testing output-module) + (define (missing-stencil-expression name) + (apply + (if (ly:get-option 'warning-as-error) ly:error ly:warning) + (list (_ "missing stencil expression `~S'") name))) + + (map (lambda (x) + (if (not (module-defined? output-module x)) + (module-define! output-module x + (lambda* (#:optional y . z) + (missing-stencil-expression x))))) + (ly:all-stencil-expressions))) diff --git a/scm/lily.scm b/scm/lily.scm index 53dd685961..49d822c6cc 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -152,6 +152,9 @@ second. Dump results to `FILE.stacks' and "List available font names.") (verbose ,(ly:command-line-verbose?) "Value of the --verbose flag (read-only).") + (warning-as-error #f +"Exit if an undefined stencil expression is +found.") )) ;; Need to do this in the beginning. Other parts of the Scheme -- 2.39.2