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 986, Tue Apr 26 21:32:17 2011 UTC revision 987, Tue Apr 26 21:43:17 2011 UTC
# Line 310  Line 310 
310                  TextIO.closeOut outS                  TextIO.closeOut outS
311                end                end
312    
       (* FIXME: control flags that should go somewhere else *)  
         val debug = ref false  
         val verbose = ref true  
   
         fun system cmd = (  
               if !verbose  
                 then print(cmd ^ "\n")  
                 else ();  
               if OS.Process.isSuccess(OS.Process.system cmd)  
                 then ()  
                 else raise Fail "error compiling/linking")  
   
         fun compile baseName = let  
               val cFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"c"}  
               val cflags = if !debug  
                     then Paths.cflags  
                     else String.concatWith " " ["-DNDEBUG", Paths.cflags]  
               val cmd = String.concatWith " " [  
                       Paths.cc, "-c", cflags,  
                       "-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude,  
                       cFile  
                     ]  
               in  
                 system cmd  
               end  
   
         fun link baseName = let  
               val objFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"o"}  
               val exeFile = baseName  
               val cmd = String.concatWith " " [  
                       Paths.cc, "-o", exeFile, objFile,  
                       "-Wl,-rpath=" ^ Paths.teemLib,    (* so that dynamic loading works *)  
                       "-L" ^ Paths.teemLib, "-lteem",  
                       OS.Path.concat(Paths.diderotLib, "diderot-lib.o")  
                     ]  
               in  
                 system cmd  
               end  
   
313        (* output the code to a file.  The string is the basename of the file, the extension        (* output the code to a file.  The string is the basename of the file, the extension
314         * is provided by the target.         * is provided by the target.
315         *)         *)
316          fun generate (baseName, prog) = (          fun generate (baseName, prog) = (
317                genSrc (baseName, prog);                genSrc (baseName, prog);
318                compile baseName;                RunCC.compile baseName;
319                link baseName)                RunCC.link baseName)
320    
321        end        end
322    

Legend:
Removed from v.986  
changed lines
  Added in v.987

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