diff src/compiler.sml @ 1381:bf58ca871c00

Detect missing 'database' directive; don't compile garbage C files
author Adam Chlipala <adam@chlipala.net>
date Thu, 06 Jan 2011 09:14:06 -0500
parents b2bc8bcd546f
children 802c179dac1f
line wrap: on
line diff
--- a/src/compiler.sml	Thu Jan 06 08:55:53 2011 -0500
+++ b/src/compiler.sml	Thu Jan 06 09:14:06 2011 -0500
@@ -1337,10 +1337,10 @@
                     in
                         OS.FileSys.mkDir dir;
                         (cname, oname,
-                         fn () => (OS.FileSys.remove cname;
-                                   OS.FileSys.remove oname;
-                                   OS.FileSys.rmDir dir)
-                            handle OS.SysErr _ => OS.FileSys.rmDir dir)
+                      fn () => (OS.FileSys.remove cname;
+                                OS.FileSys.remove oname;
+                                OS.FileSys.rmDir dir)
+                         handle OS.SysErr _ => OS.FileSys.rmDir dir)
                     end
             val ename = #exe job
         in
@@ -1359,21 +1359,24 @@
 		TextIO.output1 (outf, #"\n");
                 TextIO.closeOut outf;
 
-                case #sql job of
-                    NONE => ()
-                  | SOME sql =>
-                    let
-                        val outf = TextIO.openOut sql
-                        val s = TextIOPP.openOut {dst = outf, wid = 80}
-                    in
-                        Print.fprint s (CjrPrint.p_sql CjrEnv.empty file);
-                        TextIO.closeOut outf
-                    end;
+                if ErrorMsg.anyErrors () then
+                    false
+                else
+                    (case #sql job of
+                         NONE => ()
+                       | SOME sql =>
+                         let
+                             val outf = TextIO.openOut sql
+                             val s = TextIOPP.openOut {dst = outf, wid = 80}
+                         in
+                             Print.fprint s (CjrPrint.p_sql CjrEnv.empty file);
+                             TextIO.closeOut outf
+                         end;
 
-                compileC {cname = cname, oname = oname, ename = ename, libs = libs,
-                          profile = #profile job, debug = #debug job, link = #link job}
-                
-                before cleanup ()
+                     compileC {cname = cname, oname = oname, ename = ename, libs = libs,
+                               profile = #profile job, debug = #debug job, link = #link job}
+                     
+                     before cleanup ())
             end
             handle ex => (((cleanup ()) handle _ => ()); raise ex)
         end