forked from thomasblanc/ocp-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanagerSwitch.ml
50 lines (42 loc) · 1.33 KB
/
managerSwitch.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
open ManagerMisc
open ManagerWrapper
open ManagerInit
let print_current_version msg =
Printf.printf "Current version: %s\n" current_version;
begin
match get_current_compiler_opt () with
| Some c ->
Printf.printf "\tbinaries in %S\n" (compiler_bindir c)
| None ->
Printf.printf "\tWarning: could not find binaries of %S\n" current_version
end
let list_switches () =
let alternatives = compilers_list in
print_current_version "Current version";
Printf.printf "Alternatives:\n";
List.iter (fun c ->
Printf.printf "\t%s\n" c.compiler_name) alternatives;
Printf.printf "%!"
let set_current_switch version =
try
let c = StringMap.find version compilers in
let oc = open_out current_filename in
output_string oc c.compiler_name;
output_char oc '\n';
close_out oc;
print_current_version "Old version";
Printf.printf "New version: %s\n%!" version;
with Not_found ->
Printf.fprintf stderr "Error: no such alternative [%s]\n" version;
Printf.fprintf stderr "\tuse -list to list alternatives\n%!";
exit 2
let print_directory s =
let c = get_current_compiler () in
Printf.printf "%s\n%!"
(
match s with
"bin" -> compiler_bindir c
| "prefix" -> compiler_prefix c
| "lib" -> compiler_libdir c
| _ -> failwith "bad dir kind"
)