comparison 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
comparison
equal deleted inserted replaced
1380:ede95ecb4000 1381:bf58ca871c00
1335 val cname = OS.Path.joinDirFile {dir = dir, file = "webapp.c"} 1335 val cname = OS.Path.joinDirFile {dir = dir, file = "webapp.c"}
1336 val oname = OS.Path.joinDirFile {dir = dir, file = "webapp.o"} 1336 val oname = OS.Path.joinDirFile {dir = dir, file = "webapp.o"}
1337 in 1337 in
1338 OS.FileSys.mkDir dir; 1338 OS.FileSys.mkDir dir;
1339 (cname, oname, 1339 (cname, oname,
1340 fn () => (OS.FileSys.remove cname; 1340 fn () => (OS.FileSys.remove cname;
1341 OS.FileSys.remove oname; 1341 OS.FileSys.remove oname;
1342 OS.FileSys.rmDir dir) 1342 OS.FileSys.rmDir dir)
1343 handle OS.SysErr _ => OS.FileSys.rmDir dir) 1343 handle OS.SysErr _ => OS.FileSys.rmDir dir)
1344 end 1344 end
1345 val ename = #exe job 1345 val ename = #exe job
1346 in 1346 in
1347 let 1347 let
1348 val outf = TextIO.openOut cname 1348 val outf = TextIO.openOut cname
1357 in 1357 in
1358 Print.fprint s (CjrPrint.p_file CjrEnv.empty file); 1358 Print.fprint s (CjrPrint.p_file CjrEnv.empty file);
1359 TextIO.output1 (outf, #"\n"); 1359 TextIO.output1 (outf, #"\n");
1360 TextIO.closeOut outf; 1360 TextIO.closeOut outf;
1361 1361
1362 case #sql job of 1362 if ErrorMsg.anyErrors () then
1363 NONE => () 1363 false
1364 | SOME sql => 1364 else
1365 let 1365 (case #sql job of
1366 val outf = TextIO.openOut sql 1366 NONE => ()
1367 val s = TextIOPP.openOut {dst = outf, wid = 80} 1367 | SOME sql =>
1368 in 1368 let
1369 Print.fprint s (CjrPrint.p_sql CjrEnv.empty file); 1369 val outf = TextIO.openOut sql
1370 TextIO.closeOut outf 1370 val s = TextIOPP.openOut {dst = outf, wid = 80}
1371 end; 1371 in
1372 1372 Print.fprint s (CjrPrint.p_sql CjrEnv.empty file);
1373 compileC {cname = cname, oname = oname, ename = ename, libs = libs, 1373 TextIO.closeOut outf
1374 profile = #profile job, debug = #debug job, link = #link job} 1374 end;
1375 1375
1376 before cleanup () 1376 compileC {cname = cname, oname = oname, ename = ename, libs = libs,
1377 profile = #profile job, debug = #debug job, link = #link job}
1378
1379 before cleanup ())
1377 end 1380 end
1378 handle ex => (((cleanup ()) handle _ => ()); raise ex) 1381 handle ex => (((cleanup ()) handle _ => ()); raise ex)
1379 end 1382 end
1380 1383
1381 fun compiler job = 1384 fun compiler job =