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

SCM Repository

[diderot] Diff of /trunk/src/compiler/c-util/run-cc.sml
ViewVC logotype

Diff of /trunk/src/compiler/c-util/run-cc.sml

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

revision 1166, Tue May 10 03:39:35 2011 UTC revision 1232, Mon May 16 23:37:52 2011 UTC
# Line 8  Line 8 
8    
9  structure RunCC : sig  structure RunCC : sig
10    
11    (* compile "base" -- compiles the file "base.c" to produce "base.o". *)    (* compile ("base", cflags) -- compiles the file "base.c" to produce "base.o". *)
12      val compile : string -> unit      val compile : string * string list -> unit
13    
14    (* link "base" -- links base.o with the Diderot runtime to produce the executable    (* link ("base", opts) -- links base.o using the given options (libraries, etc.) *)
15     * "base".      val link : string * string list -> unit
    *)  
     val link : string -> unit  
16    
17    end = struct    end = struct
18    
   (* FIXME: control flags that should go somewhere else *)  
     val debug = ref false  
     val verbose = ref true  
   
19      fun system cmd = (      fun system cmd = (
20            if !verbose            Log.msg(cmd ^ "\n");
             then Log.msg(cmd ^ "\n")  
             else ();  
21            if OS.Process.isSuccess(OS.Process.system cmd)            if OS.Process.isSuccess(OS.Process.system cmd)
22              then ()              then ()
23              else raise Fail "error compiling/linking")              else raise Fail "error compiling/linking")
24    
25      fun compile baseName = let      fun compile (baseName, cflags) = let
26            val cFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"c"}            val cFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"c"}
27            val cflags = if !debug            val cmd = String.concatWith " " ([Paths.cc, "-c"] @ cflags @ [cFile])
                 then Paths.cflags  
                 else String.concatWith " " ["-DNDEBUG", Paths.cflags]  
           val cmd = String.concatWith " " [  
                   Paths.cc, "-c", cflags,  
                   "-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude,  
                   cFile  
                 ]  
28            in            in
29              PhaseTimer.withTimer Timers.timeCC system cmd              PhaseTimer.withTimer Timers.timeCC system cmd
30            end            end
31    
32      fun link baseName = let      fun link (baseName, ldOpts) = let
33            val objFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"o"}            val objFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"o"}
34            val exeFile = baseName            val exeFile = baseName
35            val cmd = String.concatWith " " ([            val cmd = String.concatWith " " ([Paths.cc, "-o", exeFile, objFile] @ ldOpts)
                   Paths.cc, "-o", exeFile, objFile,  
                   OS.Path.concat(Paths.diderotLib, "diderot-lib.o")  
                 ] @ Paths.teemLinkFlags @ [Paths.extraLibs])  
36            in            in
37              PhaseTimer.withTimer Timers.timeCC system cmd              PhaseTimer.withTimer Timers.timeCC system cmd
38            end            end

Legend:
Removed from v.1166  
changed lines
  Added in v.1232

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