Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / backends / C / c_backend.ml @ cefc3744

History | View | Annotate | Download (2.53 KB)

1
(* ----------------------------------------------------------------------------
2
 * SchedMCore - A MultiCore Scheduling Framework
3
 * Copyright (C) 2009-2013, ONERA, Toulouse, FRANCE - LIFL, Lille, FRANCE
4
 * Copyright (C) 2012-2013, INPT, Toulouse, FRANCE
5
 *
6
 * This file is part of Prelude
7
 *
8
 * Prelude is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public License
10
 * as published by the Free Software Foundation ; either version 2 of
11
 * the License, or (at your option) any later version.
12
 *
13
 * Prelude is distributed in the hope that it will be useful, but
14
 * WITHOUT ANY WARRANTY ; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this program ; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21
 * USA
22
 *---------------------------------------------------------------------------- *)
23

    
24
(* This module is used for the lustre to C compiler *)
25

    
26

    
27
(********************************************************************************************)
28
(*                         Translation function                                             *)
29
(********************************************************************************************)
30

    
31

    
32
let translate_to_c header_fmt source_fmt makefile_fmt spec_fmt_opt 
33
                   basename prog machines dependencies =
34

    
35

    
36
  let module HeaderMod = C_backend_header.EmptyMod in
37
  let module Header = C_backend_header.Main (HeaderMod) in
38

    
39
  let module SourceMod = C_backend_src.EmptyMod in
40
  let module Source = C_backend_src.Main (SourceMod) in
41

    
42
  let module MakefileMod = C_backend_makefile.EmptyMod in
43
  let module Makefile = C_backend_makefile.Main (MakefileMod) in
44

    
45

    
46
  (* Generating H file *)
47
  Header.print_header header_fmt basename prog machines;
48

    
49
  (* Generating C file *)
50
  Source.print_c source_fmt basename prog machines dependencies;
51

    
52
  (* Generating Makefile *)
53
  (* If a main node is identified, generate a main target for it *)
54
  match !Options.main_node with
55
      | "" ->  ()
56
      | main_node -> (
57
	match Machine_code.get_machine_opt main_node machines with
58
	| None -> Format.eprintf "Unable to find a main node named %s@.@?" main_node; 
59
	  ()
60
	| Some _ -> Makefile.print_makefile basename !Options.main_node dependencies makefile_fmt
61
      )
62

    
63
(* Local Variables: *)
64
(* compile-command:"make -C ../../.." *)
65
(* End: *)