Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/c-target/c-target.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/c-target/c-target.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 730, Sat Apr 2 00:51:15 2011 UTC revision 731, Sat Apr 2 03:15:31 2011 UTC
# Line 624  Line 624 
624                SOME(CL.I_Array(genInits (0, strands)))))                SOME(CL.I_Array(genInits (0, strands)))))
625            end            end
626    
627      fun generate (baseName, Prog{globals, topDecls, strands, initially}) = let      fun genSrc (baseName, Prog{globals, topDecls, strands, initially}) = let
628            val fileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}            val fileName = OS.Path.joinBaseExt{base=baseName, ext=SOME "c"}
629            val outS = TextIO.openOut fileName            val outS = TextIO.openOut fileName
630            val ppStrm = PrintAsC.new outS            val ppStrm = PrintAsC.new outS
# Line 640  Line 640 
640              TextIO.closeOut outS              TextIO.closeOut outS
641            end            end
642    
643      (* FIXME: control flags that should go somewhere else *)
644        val debug = ref false
645        val verbose = ref true
646    
647        fun system cmd = (
648              if !verbose
649                then print(cmd ^ "\n")
650                else ();
651              if OS.Process.isSuccess(OS.Process.system cmd)
652                then ()
653                else raise Fail "error compiling/linking")
654    
655        fun compile baseName = let
656              val cFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"c"}
657              val cflags = if !debug
658                    then Paths.cflags
659                    else String.concatWith " " ["-NDEBUG", Paths.cflags]
660              val cmd = String.concatWith " " [
661                      Paths.cc, "-c", cflags,
662                      "-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude,
663                      cFile
664                    ]
665              in
666                system cmd
667              end
668    
669        fun link baseName = let
670              val objFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"o"}
671              val exeFile = baseName
672              val cmd = String.concatWith " " [
673                      Paths.cc, "-o", exeFile, objFile,
674                      "-L" ^ Paths.teemLib, "-lteem",
675                      OS.Path.concat(Paths.diderotLib, "diderot-lib.o")
676                    ]
677              in
678                system cmd
679              end
680    
681        fun generate (baseName, prog) = (
682              genSrc (baseName, prog);
683              compile baseName;
684              link baseName)
685    
686    end    end
687    
688  structure CBackEnd = CodeGenFn(CTarget)  structure CBackEnd = CodeGenFn(CTarget)

Legend:
Removed from v.730  
changed lines
  Added in v.731

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0