]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add a new program option: -dwarning-as-error
authorPatrick McCarty <pnorcks@gmail.com>
Sun, 5 Jul 2009 19:56:34 +0000 (12:56 -0700)
committerPatrick McCarty <pnorcks@gmail.com>
Thu, 16 Jul 2009 06:12:23 +0000 (23:12 -0700)
(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
lily/program-option-scheme.cc
scm/backend-library.scm
scm/lily.scm

index 6aedacca91202ad7f5a05b6558ea3905d4d33ce8..3f98b8eb869322c294e42ddfcf935f754113bb92 100644 (file)
@@ -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 ()
index 1e03c5f951bae8e38a4d8d257205d206f60068e4..dca049028860bd85bdca04903588d5cf91a505ee 100644 (file)
@@ -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);
 }
index 301868cb84d66baf54838e71738b45ec19a3ddbf..71ef9096f8e314249dfdd773f0a660918215473a 100644 (file)
@@ -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")
     (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))
       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)))
index 53dd68596139da4597e8be155b596c07e567c450..49d822c6cceb3ab60af44fe5381874bac26911e0 100644 (file)
@@ -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