Skip to content

Commit

Permalink
Adds command line option to dump a list of all the files necessary to…
Browse files Browse the repository at this point in the history
… compile the given input files.
  • Loading branch information
modlfo committed Jan 31, 2017
1 parent 9a0a355 commit 7c84059
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/core/typesVult.ml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ type arguments =
mutable template : string;
mutable show_version : bool;
mutable includes : string list;
mutable deps : bool;
}

let default_arguments =
Expand All @@ -227,6 +228,7 @@ let default_arguments =
template = "default";
show_version = false;
includes = [];
deps = false;
}

let makeAttr (loc:Loc.t) : attr =
Expand Down
5 changes: 4 additions & 1 deletion src/loader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ let rec loadFiles_loop (includes:string list) dependencies parsed (files:string
|> List.map List.hd
in
(* finds all the files for the used modules *)
let h_dep_files = List.map (findModule includes) h_deps in
let h_dep_files =
List.map (findModule includes) h_deps
|> List.filter (fun a -> a<>h)
in
(* updates the tables *)
let () = Hashtbl.add dependencies h_module h_deps in
let () = Hashtbl.add parsed h_module h_parsed in
Expand Down
16 changes: 12 additions & 4 deletions src/vult_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let processArguments () : arguments =
let result = { default_arguments with files = [] } in
let opts = [
"-dparse", (Arg.Unit (fun () -> result.dparse <-true)), " Dumps the parse tree (default: off)";
"-deps", (Arg.Unit (fun () -> result.deps <-true)), " Prints all file dependencies";
"-ccode", (Arg.Unit (fun () -> result.ccode <-true)), " Converts the code to c (default: off)";
"-jscode", (Arg.Unit (fun () -> result.jscode <-true)), " Converts the code to javascript (default: off)";
"-luacode", (Arg.Unit (fun () -> result.luacode <-true)), " Converts the code to lua (default: off)";
Expand Down Expand Up @@ -65,7 +66,14 @@ let main () =
print_endline "no input files"
| _ ->
let parser_results = parseFiles args args.files in
(* Prints the parsed files if -dparse was passed as argument *)
Driver.dumpParsedFiles args parser_results;
Driver.generateCode args parser_results |> ignore;
Driver.runFiles args parser_results |> ignore
if args.deps then
List.map (fun r -> r.file) parser_results
|> String.concat " "
|> print_endline
else
begin
(* Prints the parsed files if -dparse was passed as argument *)
Driver.dumpParsedFiles args parser_results;
Driver.generateCode args parser_results |> ignore;
Driver.runFiles args parser_results |> ignore
end

0 comments on commit 7c84059

Please sign in to comment.