X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2Fmatitamake.ml;h=96fdbfb28ef0727451dc5dd51d2f3617121cbf95;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=8bd5900f5b10d99bcfa105a3aef0179d731f2d4b;hpb=afe21e48aefe81db3ca150fac9a5bbfbc893fa59;p=helm.git diff --git a/helm/matita/matitamake.ml b/helm/matita/matitamake.ml index 8bd5900f5..96fdbfb28 100644 --- a/helm/matita/matitamake.ml +++ b/helm/matita/matitamake.ml @@ -25,146 +25,136 @@ module MK = MatitamakeLib ;; -let _ = +let main () = MatitaInit.load_configuration_file (); - MK.initialize () -;; - -let usage = ref (fun () -> ()) - -let dev_of_name name = - match MK.development_for_name name with - | None -> - prerr_endline ("Unable to find a development called " ^ name); - exit 1 - | Some d -> d -;; - -let dev_for_dir dir = - match MK.development_for_dir dir with - | None -> - prerr_endline ("Unable to find a development holding directory: " ^ dir); - exit 1 - | Some d -> d -;; - -let init_dev_doc = " + MK.initialize (); + let usage = ref (fun () -> ()) in + let dev_of_name name = + match MK.development_for_name name with + | None -> + prerr_endline ("Unable to find a development called " ^ name); + exit 1 + | Some d -> d + in + let dev_for_dir dir = + match MK.development_for_dir dir with + | None -> + prerr_endline ("Unable to find a development holding directory: "^ dir); + exit 1 + | Some d -> d + in + let init_dev_doc = " \tParameters: name (the name of the development, required) \tDescription: tells matitamake that a new development radicated \t\tin the current working directory should be handled." -;; - -let init_dev args = - if List.length args <> 1 then !usage (); - match MK.initialize_development (List.hd args) (Unix.getcwd ()) with - | None -> exit 2 - | Some _ -> exit 0 -;; - -let list_dev_doc = " + in + let init_dev args = + if List.length args <> 1 then !usage (); + match MK.initialize_development (List.hd args) (Unix.getcwd ()) with + | None -> exit 2 + | Some _ -> exit 0 + in + let list_dev_doc = " \tParameters: \tDescription: lists the known developments and their roots." -;; - -let list_dev args = - if List.length args <> 0 then !usage (); - match MK.list_known_developments () with - | [] -> print_string "No developments found.\n"; exit 0 - | l -> - List.iter - (fun (name, root) -> - print_string (Printf.sprintf "%-10s\trooted in %s\n" name root)) - l; - exit 0 -;; - -let destroy_dev_doc = " + in + let list_dev args = + if List.length args <> 0 then !usage (); + match MK.list_known_developments () with + | [] -> print_string "No developments found.\n"; exit 0 + | l -> + List.iter + (fun (name, root) -> + print_string (Printf.sprintf "%-10s\trooted in %s\n" name root)) + l; + exit 0 + in + let destroy_dev_doc = " \tParameters: name (the name of the development to destroy, required) \tDescription: deletes a development (only from matitamake metadat, no \t\t.ma files will be deleted)." - -let destroy_dev args = - if List.length args <> 1 then !usage (); - let name = (List.hd args) in - let dev = dev_of_name name in - MK.destroy_development dev; - exit 0 -;; - -let clean_dev_doc = " + in + let destroy_dev args = + if List.length args <> 1 then !usage (); + let name = (List.hd args) in + let dev = dev_of_name name in + MK.destroy_development dev; + exit 0 + in + let clean_dev_doc = " \tParameters: name (the name of the development to destroy, optional) \t\tIf omitted the development that holds the current working \t\tdirectory is used (if any). \tDescription: clean the develpoment." - -let clean_dev args = - let dev = - match args with - | [] -> dev_for_dir (Unix.getcwd ()) - | [name] -> dev_of_name name - | _ -> !usage (); exit 1 - in - match MK.clean_development dev with - | true -> exit 0 - | false -> exit 1 -;; - -let build_dev_doc = " + in + let clean_dev args = + let dev = + match args with + | [] -> dev_for_dir (Unix.getcwd ()) + | [name] -> dev_of_name name + | _ -> !usage (); exit 1 + in + match MK.clean_development dev with + | true -> exit 0 + | false -> exit 1 + in + let build_dev_doc = " \tParameters: name (the name of the development to build, required) \tDescription: completely builds the develpoment." - -let build_dev args = - if List.length args <> 1 then !usage (); - let name = (List.hd args) in - let dev = dev_of_name name in - match MK.build_development dev with - | true -> exit 0 - | false -> exit 1 -;; - -let target args = - if List.length args < 1 then !usage (); - let dev = dev_for_dir (Unix.getcwd ()) in - List.iter - (fun t -> - ignore(MK.build_development ~target:t dev)) - args -;; - -let params = [ - "-init", init_dev, init_dev_doc; - "-clean", clean_dev, clean_dev_doc; - "-list", list_dev, list_dev_doc; - "-destroy", destroy_dev, destroy_dev_doc; - "-build", build_dev, build_dev_doc; - "-h", (fun _ -> !usage()), "print this help screen"; - "-help", (fun _ -> !usage()), "print this help screen"; -] -;; - -usage := fun () -> - let p = prerr_endline in - p "\nusage:"; - p "\tmatitamake(.opt) [command [options]]\n"; - p "\tmatitamake(.opt) [target]\n"; - p "commands:"; - List.iter (fun (n,_,d) -> p (Printf.sprintf " %-10s%s" n d)) params; - p "\nIf target is omitted a 'all' will be used as the default."; - p "With -build you can build a development wherever it is."; - p "If you specify a target it implicitly refers to the development that"; - p "holds the current working directory (if any).\n"; - exit 1 -;; - -let parse args = - match args with - | [] -> target ["all"] - | s::tl -> - try - let _,f,_ = List.find (fun (n,_,_) -> n = s) params in - f tl - with Not_found -> if s.[0] = '-' then !usage () else target args - -let _ = + in + let build_dev args = + if List.length args <> 1 then !usage (); + let name = (List.hd args) in + let dev = dev_of_name name in + match MK.build_development dev with + | true -> exit 0 + | false -> exit 1 + in + let nodb_doc = " +\tParameters: +\tDescription: avoid using external database connection." + in + let nodb _ = Helm_registry.set_bool "db.nodb" true in + let target args = + if List.length args < 1 then !usage (); + let dev = dev_for_dir (Unix.getcwd ()) in + List.iter + (fun t -> + ignore(MK.build_development ~target:t dev)) + args + in + let params = [ + "-init", init_dev, init_dev_doc; + "-clean", clean_dev, clean_dev_doc; + "-list", list_dev, list_dev_doc; + "-destroy", destroy_dev, destroy_dev_doc; + "-build", build_dev, build_dev_doc; + "-nodb", nodb, nodb_doc; + "-h", (fun _ -> !usage()), "print this help screen"; + "-help", (fun _ -> !usage()), "print this help screen"; + ] + in + usage := (fun () -> + let p = prerr_endline in + p "\nusage:"; + p "\tmatitamake(.opt) [command [options]]\n"; + p "\tmatitamake(.opt) [target]\n"; + p "commands:"; + List.iter (fun (n,_,d) -> p (Printf.sprintf " %-10s%s" n d)) params; + p "\nIf target is omitted a 'all' will be used as the default."; + p "With -build you can build a development wherever it is."; + p "If you specify a target it implicitly refers to the development that"; + p "holds the current working directory (if any).\n"; + exit 1); + let rec parse args = + match args with + | [] -> target ["all"] + | s::tl -> + try + let _,f,_ = List.find (fun (n,_,_) -> n = s) params in + f tl; + parse tl + with Not_found -> if s.[0] = '-' then !usage () else target args + in parse (List.tl (Array.to_list Sys.argv)) - +