Project

General

Profile

Revision 1e48ef45 src/main_lustre_compiler.ml

View differences:

src/main_lustre_compiler.ml
32 32
  end
33 33

  
34 34
(* compile a .lusi header file *)
35
let compile_header basename extension =
35
let compile_header dirname  basename extension =
36 36
  let destname = !Options.dest_dir ^ "/" ^ basename in
37 37
  let header_name = basename ^ extension in
38 38
  let lusic_ext = extension ^ "c" in
39 39
  begin
40 40
    Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v>");
41
    let header = parse_header true header_name in
41
    let header = parse_header true (dirname ^ "/" ^ header_name) in
42 42
    ignore (Modules.load_header ISet.empty header);
43 43
    ignore (check_top_decls header);
44 44
    create_dest_dir ();
45
    Log.report ~level:1 (fun fmt -> fprintf fmt ".. generating compiled header file %sc@," header_name);
45
    Log.report ~level:1 
46
      (fun fmt -> fprintf fmt ".. generating compiled header file %sc@," (destname ^ extension));
46 47
    Lusic.write_lusic true header destname lusic_ext;
47 48
    Lusic.print_lusic_to_h destname lusic_ext;
48 49
    Log.report ~level:1 (fun fmt -> fprintf fmt ".. done !@ @]@.")
......
82 83
  end
83 84

  
84 85
(* compile a .lus source file *)
85
let rec compile_source basename extension =
86
  let source_name = basename ^ extension in
86
let rec compile_source dirname basename extension =
87
  let source_name = (*dirname ^ "/" ^*) basename ^ extension in
87 88

  
88 89
  Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v>");
89 90

  
......
293 294
    exit 0
294 295
  end
295 296

  
296
let compile basename extension =
297
let compile dirname basename extension =
297 298
  match extension with
298
  | ".lusi"  -> compile_header basename extension
299
  | ".lus"   -> compile_source basename extension
299
  | ".lusi"  -> compile_header dirname basename extension
300
  | ".lus"   -> compile_source dirname basename extension
300 301
  | _        -> assert false
301 302

  
302 303
let anonymous filename =
303
  let ok_ext, ext = List.fold_left (fun (ok, ext) ext' -> if not ok && Filename.check_suffix filename ext' then true, ext' else ok, ext) (false, "") extensions in
304
  let ok_ext, ext = List.fold_left 
305
    (fun (ok, ext) ext' -> 
306
      if not ok && Filename.check_suffix filename ext' then 
307
	true, ext' 
308
      else
309
	ok, ext) 
310
    (false, "") extensions in
304 311
  if ok_ext then
312
    let dirname = Filename.dirname filename in
305 313
    let basename = Filename.chop_suffix (Filename.basename filename) ext in
306
    compile basename ext
314
    compile dirname basename ext
307 315
  else
308 316
    raise (Arg.Bad ("Can only compile *.lusi, *.lus or *.ec files"))
309 317

  

Also available in: Unified diff