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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1372 - (view) (download)

1 : jhr 1115 (* run-cc.sml
2 :     *
3 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 :     * Support for running the C compiler to compile and link the generated code.
7 :     *)
8 :    
9 :     structure RunCC : sig
10 :    
11 : jhr 1232 (* compile ("base", cflags) -- compiles the file "base.c" to produce "base.o". *)
12 :     val compile : string * string list -> unit
13 : jhr 1115
14 : jhr 1232 (* link ("base", opts) -- links base.o using the given options (libraries, etc.) *)
15 :     val link : string * string list -> unit
16 : jhr 1115
17 :     end = struct
18 :    
19 :     fun system cmd = (
20 : jhr 1232 Log.msg(cmd ^ "\n");
21 : jhr 1115 if OS.Process.isSuccess(OS.Process.system cmd)
22 :     then ()
23 :     else raise Fail "error compiling/linking")
24 :    
25 : jhr 1232 fun compile (baseName, cflags) = let
26 : jhr 1115 val cFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"c"}
27 : jhr 1232 val cmd = String.concatWith " " ([Paths.cc, "-c"] @ cflags @ [cFile])
28 : jhr 1115 in
29 :     PhaseTimer.withTimer Timers.timeCC system cmd
30 :     end
31 :    
32 : jhr 1232 fun link (baseName, ldOpts) = let
33 : jhr 1115 val objFile = OS.Path.joinBaseExt{base=baseName, ext=SOME"o"}
34 :     val exeFile = baseName
35 : jhr 1232 val cmd = String.concatWith " " ([Paths.cc, "-o", exeFile, objFile] @ ldOpts)
36 : jhr 1115 in
37 :     PhaseTimer.withTimer Timers.timeCC system cmd
38 :     end
39 :    
40 :     end

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