Mercurial > urweb
comparison src/compiler.sml @ 378:168667cdaa95
Proper configuration and installation
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 19 Oct 2008 12:47:10 -0400 |
parents | 78358e5df273 |
children | 1195f6e4d208 |
comparison
equal
deleted
inserted
replaced
377:78358e5df273 | 378:168667cdaa95 |
---|---|
353 print = SourcePrint.p_file | 353 print = SourcePrint.p_file |
354 } | 354 } |
355 | 355 |
356 val toParse = transform parse "parse" o toParseJob | 356 val toParse = transform parse "parse" o toParseJob |
357 | 357 |
358 fun libFile s = OS.Path.joinDirFile {dir = Config.libUr, | |
359 file = s} | |
360 fun clibFile s = OS.Path.joinDirFile {dir = Config.libC, | |
361 file = s} | |
362 | |
358 val elaborate = { | 363 val elaborate = { |
359 func = fn file => let | 364 func = fn file => let |
360 val basis = #func parseUrs "lib/basis.urs" | 365 val basis = #func parseUrs (libFile "basis.urs") |
361 val topSgn = #func parseUrs "lib/top.urs" | 366 val topSgn = #func parseUrs (libFile "top.urs") |
362 val topStr = #func parseUr "lib/top.ur" | 367 val topStr = #func parseUr (libFile "top.ur") |
363 in | 368 in |
364 Elaborate.elabFile basis topStr topSgn ElabEnv.empty file | 369 Elaborate.elabFile basis topStr topSgn ElabEnv.empty file |
365 end, | 370 end, |
366 print = ElabPrint.p_file ElabEnv.empty | 371 print = ElabPrint.p_file ElabEnv.empty |
367 } | 372 } |
491 | 496 |
492 val toSqlify = transform sqlify "sqlify" o toMono_opt2 | 497 val toSqlify = transform sqlify "sqlify" o toMono_opt2 |
493 | 498 |
494 fun compileC {cname, oname, ename} = | 499 fun compileC {cname, oname, ename} = |
495 let | 500 let |
501 val urweb_o = clibFile "urweb.o" | |
502 val driver_o = clibFile "driver.o" | |
503 | |
496 val compile = "gcc -Wstrict-prototypes -Werror -O3 -I include -c " ^ cname ^ " -o " ^ oname | 504 val compile = "gcc -Wstrict-prototypes -Werror -O3 -I include -c " ^ cname ^ " -o " ^ oname |
497 val link = "gcc -Werror -O3 -pthread -lpq clib/urweb.o " ^ oname ^ " clib/driver.o -o " ^ ename | 505 val link = "gcc -Werror -O3 -pthread -lpq " ^ urweb_o ^ " " ^ oname ^ " " ^ driver_o ^ " -o " ^ ename |
498 in | 506 in |
499 if not (OS.Process.isSuccess (OS.Process.system compile)) then | 507 if not (OS.Process.isSuccess (OS.Process.system compile)) then |
500 print "C compilation failed\n" | 508 print "C compilation failed\n" |
501 else if not (OS.Process.isSuccess (OS.Process.system link)) then | 509 else if not (OS.Process.isSuccess (OS.Process.system link)) then |
502 print "C linking failed\n" | 510 print "C linking failed\n" |
515 if #debug job then | 523 if #debug job then |
516 ("/tmp/urweb.c", "/tmp/urweb.o", fn () => ()) | 524 ("/tmp/urweb.c", "/tmp/urweb.o", fn () => ()) |
517 else | 525 else |
518 let | 526 let |
519 val dir = OS.FileSys.tmpName () | 527 val dir = OS.FileSys.tmpName () |
528 val () = OS.FileSys.remove dir | |
520 val cname = OS.Path.joinDirFile {dir = dir, file = "urweb.c"} | 529 val cname = OS.Path.joinDirFile {dir = dir, file = "urweb.c"} |
521 val oname = OS.Path.joinDirFile {dir = dir, file = "urweb.o"} | 530 val oname = OS.Path.joinDirFile {dir = dir, file = "urweb.o"} |
522 in | 531 in |
523 OS.FileSys.mkDir dir; | 532 OS.FileSys.mkDir dir; |
524 (cname, oname, | 533 (cname, oname, |