comparison src/compiler.sml @ 1725:7b9775d4a8ce

'linker' .urp directive
author Adam Chlipala <adam@chlipala.net>
date Sun, 22 Apr 2012 10:57:22 -0400
parents 2b04104896a8
children 4a03aa3251cb
comparison
equal deleted inserted replaced
1724:125f9b01fbf1 1725:7b9775d4a8ce
42 debug : bool, 42 debug : bool,
43 profile : bool, 43 profile : bool,
44 timeout : int, 44 timeout : int,
45 ffi : string list, 45 ffi : string list,
46 link : string list, 46 link : string list,
47 linker : string option,
47 headers : string list, 48 headers : string list,
48 scripts : string list, 49 scripts : string list,
49 clientToServer : Settings.ffi list, 50 clientToServer : Settings.ffi list,
50 effectful : Settings.ffi list, 51 effectful : Settings.ffi list,
51 benignEffectful : Settings.ffi list, 52 benignEffectful : Settings.ffi list,
397 debug = Settings.getDebug (), 398 debug = Settings.getDebug (),
398 profile = false, 399 profile = false,
399 timeout = 60, 400 timeout = 60,
400 ffi = [], 401 ffi = [],
401 link = [], 402 link = [],
403 linker = NONE,
402 headers = [], 404 headers = [],
403 scripts = [], 405 scripts = [],
404 clientToServer = [], 406 clientToServer = [],
405 effectful = [], 407 effectful = [],
406 benignEffectful = [], 408 benignEffectful = [],
516 val debug = ref (Settings.getDebug ()) 518 val debug = ref (Settings.getDebug ())
517 val profile = ref false 519 val profile = ref false
518 val timeout = ref NONE 520 val timeout = ref NONE
519 val ffi = ref [] 521 val ffi = ref []
520 val link = ref [] 522 val link = ref []
523 val linker = ref NONE
521 val headers = ref [] 524 val headers = ref []
522 val scripts = ref [] 525 val scripts = ref []
523 val clientToServer = ref [] 526 val clientToServer = ref []
524 val effectful = ref [] 527 val effectful = ref []
525 val benignEffectful = ref [] 528 val benignEffectful = ref []
550 debug = !debug, 553 debug = !debug,
551 profile = !profile, 554 profile = !profile,
552 timeout = Option.getOpt (!timeout, 60), 555 timeout = Option.getOpt (!timeout, 60),
553 ffi = rev (!ffi), 556 ffi = rev (!ffi),
554 link = rev (!link), 557 link = rev (!link),
558 linker = !linker,
555 headers = rev (!headers), 559 headers = rev (!headers),
556 scripts = rev (!scripts), 560 scripts = rev (!scripts),
557 clientToServer = rev (!clientToServer), 561 clientToServer = rev (!clientToServer),
558 effectful = rev (!effectful), 562 effectful = rev (!effectful),
559 benignEffectful = rev (!benignEffectful), 563 benignEffectful = rev (!benignEffectful),
605 debug = #debug old orelse #debug new, 609 debug = #debug old orelse #debug new,
606 profile = #profile old orelse #profile new, 610 profile = #profile old orelse #profile new,
607 timeout = #timeout old, 611 timeout = #timeout old,
608 ffi = #ffi old @ #ffi new, 612 ffi = #ffi old @ #ffi new,
609 link = #link old @ #link new, 613 link = #link old @ #link new,
614 linker = mergeO (fn (_, new) => new) (#linker old, #linker new),
610 headers = #headers old @ #headers new, 615 headers = #headers old @ #headers new,
611 scripts = #scripts old @ #scripts new, 616 scripts = #scripts old @ #scripts new,
612 clientToServer = #clientToServer old @ #clientToServer new, 617 clientToServer = #clientToServer old @ #clientToServer new,
613 effectful = #effectful old @ #effectful new, 618 effectful = #effectful old @ #effectful new,
614 benignEffectful = #benignEffectful old @ #benignEffectful new, 619 benignEffectful = #benignEffectful old @ #benignEffectful new,
740 else 745 else
741 relifyA arg 746 relifyA arg
742 in 747 in
743 link := arg :: !link 748 link := arg :: !link
744 end 749 end
750 | "linker" => linker := SOME arg
745 | "include" => headers := relifyA arg :: !headers 751 | "include" => headers := relifyA arg :: !headers
746 | "script" => scripts := arg :: !scripts 752 | "script" => scripts := arg :: !scripts
747 | "clientToServer" => clientToServer := ffiS () :: !clientToServer 753 | "clientToServer" => clientToServer := ffiS () :: !clientToServer
748 | "safeGet" => safeGets := arg :: !safeGets 754 | "safeGet" => safeGets := arg :: !safeGets
749 | "effectful" => effectful := ffiS () :: !effectful 755 | "effectful" => effectful := ffiS () :: !effectful
1354 1360
1355 val escapeFilename = String.translate (fn #" " => "\\ " | #"\"" => "\\\"" | #"'" => "\\'" | ch => str ch) 1361 val escapeFilename = String.translate (fn #" " => "\\ " | #"\"" => "\\\"" | #"'" => "\\'" | ch => str ch)
1356 1362
1357 val beforeC = ref (fn () => ()) 1363 val beforeC = ref (fn () => ())
1358 1364
1359 fun compileC {cname, oname, ename, libs, profile, debug, link = link'} = 1365 fun compileC {cname, oname, ename, libs, profile, debug, linker, link = link'} =
1360 let 1366 let
1361 val proto = Settings.currentProtocol () 1367 val proto = Settings.currentProtocol ()
1362 1368
1363 val lib = if Settings.getStaticLinking () then 1369 val lib = if Settings.getStaticLinking () then
1364 #linkStatic proto ^ " " ^ Config.lib ^ "/../liburweb.a" 1370 #linkStatic proto ^ " " ^ Config.lib ^ "/../liburweb.a"
1373 val compile = Config.ccompiler ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadCflags ^ " -Wimplicit -Werror -Wno-unused-value" 1379 val compile = Config.ccompiler ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadCflags ^ " -Wimplicit -Werror -Wno-unused-value"
1374 ^ opt ^ " -I " ^ Config.includ 1380 ^ opt ^ " -I " ^ Config.includ
1375 ^ " " ^ #compile proto 1381 ^ " " ^ #compile proto
1376 ^ " -c " ^ escapeFilename cname ^ " -o " ^ escapeFilename oname 1382 ^ " -c " ^ escapeFilename cname ^ " -o " ^ escapeFilename oname
1377 1383
1378 val link = Config.ccompiler ^ " -Werror" ^ opt ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadCflags ^ " " ^ Config.pthreadLibs 1384 val linker = Option.getOpt (linker, Config.ccompiler ^ " -Werror" ^ opt ^ " " ^ Config.ccArgs ^ " " ^ Config.pthreadCflags ^ " " ^ Config.pthreadLibs)
1385
1386 val link = linker
1379 ^ " " ^ lib ^ " " ^ escapeFilename oname ^ " " ^ libs ^ " -lm " ^ Config.openssl ^ " -o " ^ escapeFilename ename 1387 ^ " " ^ lib ^ " " ^ escapeFilename oname ^ " " ^ libs ^ " -lm " ^ Config.openssl ^ " -o " ^ escapeFilename ename
1380 1388
1381 val (compile, link) = 1389 val (compile, link) =
1382 if profile then 1390 if profile then
1383 (compile ^ " -pg", link ^ " -pg") 1391 (compile ^ " -pg", link ^ " -pg")
1460 Print.fprint s (CjrPrint.p_sql CjrEnv.empty file); 1468 Print.fprint s (CjrPrint.p_sql CjrEnv.empty file);
1461 TextIO.closeOut outf 1469 TextIO.closeOut outf
1462 end; 1470 end;
1463 1471
1464 compileC {cname = cname, oname = oname, ename = ename, libs = libs, 1472 compileC {cname = cname, oname = oname, ename = ename, libs = libs,
1465 profile = #profile job, debug = #debug job, link = #link job} 1473 profile = #profile job, debug = #debug job, linker = #linker job, link = #link job}
1466 1474
1467 before cleanup ()) 1475 before cleanup ())
1468 end 1476 end
1469 handle ex => (((cleanup ()) handle _ => ()); raise ex) 1477 handle ex => (((cleanup ()) handle _ => ()); raise ex)
1470 end 1478 end