]> matita.cs.unibo.it Git - helm.git/blob - matita/matitac.ml
matita 0.5.1 tagged
[helm.git] / matita / matitac.ml
1 (* Copyright (C) 2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (* $Id$ *)
27
28 (* compiler ala pascal/java using make *)
29 let main_compiler () =
30   MatitaInit.initialize_all ();
31   (* targets and deps *)
32   let targets = Helm_registry.get_list Helm_registry.string "matita.args" in
33   let target, root = 
34     match targets with
35     | [] ->
36       (match Librarian.find_roots_in_dir (Sys.getcwd ()) with
37       | [x] -> [], Filename.dirname x
38       | [] -> 
39          prerr_endline "No targets and no root found"; exit 1
40       | roots -> 
41          let roots = List.map (HExtlib.chop_prefix (Sys.getcwd()^"/")) roots in
42          prerr_endline ("Too many roots found:\n\t" ^ String.concat "\n\t" roots);
43          prerr_endline ("\nEnter one of these directories and retry");
44          exit 1);
45     | hds -> 
46       let roots_and_targets = 
47        List.map (fun (root, buri, file, target) -> root,target)
48         (List.map (Librarian.baseuri_of_script ~include_paths:[]) hds) in
49       let roots,targets = List.split roots_and_targets in
50       let root = List.hd roots in
51       if (List.exists (fun root' -> root' <> root) roots) then
52        (prerr_endline "Only targets in the same root can be specified.";exit 1);
53       targets, root
54   in
55   (* must be called after init since args are set by cmdline parsing *)
56   let system_mode =  Helm_registry.get_bool "matita.system" in
57   if system_mode then HLog.message "Compiling in system space";
58   (* here we go *)
59   if not (Helm_registry.get_bool "matita.verbose") then MatitaMisc.shutup ();
60   if MatitacLib.Make.make root target then 
61     HLog.message "Compilation successful"
62   else
63     HLog.message "Compilation failed"
64 ;;
65
66 let main () =
67   Sys.catch_break true;
68   let bin = Filename.basename Sys.argv.(0) in
69   if      Pcre.pmatch ~pat:"^matitadep"    bin then Matitadep.main ()
70   else if Pcre.pmatch ~pat:"^matitaclean"  bin then Matitaclean.main ()
71   else if Pcre.pmatch ~pat:"^matitawiki"   bin then MatitaWiki.main ()
72   else main_compiler ()
73 ;;
74
75 let _ = main ()
76