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

SCM Repository

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

Diff of /branches/vis12/src/compiler/c-target/c-target.sml

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

revision 1713, Fri Mar 9 21:37:19 2012 UTC revision 1714, Sat Mar 10 00:00:50 2012 UTC
# Line 371  Line 371 
371                  TextIO.closeOut outS                  TextIO.closeOut outS
372                end                end
373    
       (* output the code to a file.  The string is the basename of the file, the extension  
        * is provided by the target.  
        *)  
         fun generateExec (prog as Prog{tgt, ...}) = let  
               val {outDir, outBase, exec, double, parallel, debug, ...} = tgt  
374                fun condCons (true, x, xs) = x::xs                fun condCons (true, x, xs) = x::xs
375                  | condCons (false, _, xs) = xs                  | condCons (false, _, xs) = xs
376    
377            fun compile (tgt : TargetUtil.target_desc, basename) = let
378              (* generate the C compiler flags *)              (* generate the C compiler flags *)
379                val cflags = ["-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude]                val cflags = ["-I" ^ Paths.diderotInclude, "-I" ^ Paths.teemInclude]
380                val cflags = condCons (parallel, #pthread Paths.cflags, cflags)                val cflags = condCons (#parallel tgt, #pthread Paths.cflags, cflags)
381                val cflags = if debug                val cflags = if #debug tgt
382                      then #debug Paths.cflags :: cflags                      then #debug Paths.cflags :: cflags
383                      else #ndebug Paths.cflags :: cflags                      else #ndebug Paths.cflags :: cflags
384                val cflags = #base Paths.cflags :: cflags                val cflags = #base Paths.cflags :: cflags
385              (* generate the loader flags *)                in
386                val extraLibs = condCons (parallel, #pthread Paths.extraLibs, [])                  RunCC.compile (basename, cflags)
387                  end
388    
389            fun ldFlags (tgt : TargetUtil.target_desc) = let
390                  val extraLibs = condCons (#parallel tgt, #pthread Paths.extraLibs, [])
391                val extraLibs = Paths.teemLinkFlags @ #base Paths.extraLibs :: extraLibs                val extraLibs = Paths.teemLinkFlags @ #base Paths.extraLibs :: extraLibs
392                val rtLib = TargetUtil.runtimeName tgt                val rtLib = TargetUtil.runtimeName tgt
393                val ldOpts = rtLib :: extraLibs                in
394                    rtLib :: extraLibs
395                  end
396    
397          (* output the code to a file.  The string is the basename of the file, the extension
398           * is provided by the target.
399           *)
400            fun generateExec (prog as Prog{tgt, ...}) = let
401                  val {outDir, outBase, exec, double, parallel, debug, ...} = tgt
402                val basename = OS.Path.joinDirFile{dir=outDir, file=outBase}                val basename = OS.Path.joinDirFile{dir=outDir, file=outBase}
403                in                in
404                  genExecSrc (basename, prog);                  genExecSrc (basename, prog);
405                  RunCC.compile (basename, cflags);                  compile (tgt, basename);
406                  RunCC.link (basename, ldOpts)                  RunCC.linkExec (basename, ldFlags tgt)
407                end                end
408    
409          fun genLibSrc (baseName, Prog{tgt, strands, nAxes, ...}) = let          fun genLibSrc (baseName, Prog{tgt, strands, nAxes, ...}) = let
# Line 406  Line 415 
415                val ppStrm = PrintAsC.new outS                val ppStrm = PrintAsC.new outS
416                fun ppDecl dcl = PrintAsC.output(ppStrm, dcl)                fun ppDecl dcl = PrintAsC.output(ppStrm, dcl)
417                in                in
418                  List.app ppDecl outputs                  List.app ppDecl outputs;
419                    PrintAsC.close ppStrm;
420                    TextIO.closeOut outS
421                end                end
422    
423          fun generateLib (prog as Prog{tgt, strands, ...}) = let          fun generateLib (prog as Prog{tgt, strands, ...}) = let
# Line 421  Line 432 
432                      outputs = [output]                      outputs = [output]
433                    };                    };
434                (* *)                (* *)
435                  genLibSrc (basename, prog)                  genLibSrc (basename, prog);
436  (* FIXME: compile and link *)                (* compile and link *)
437                    compile (tgt, basename);
438                    RunCC.linkLib (basename, ldFlags tgt)
439                end                end
440    
441          fun generate (prog as Prog{tgt, ...}) = if #exec tgt          fun generate (prog as Prog{tgt, ...}) = if #exec tgt

Legend:
Removed from v.1713  
changed lines
  Added in v.1714

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