aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7>2012-05-16 12:49:19 +0000
committerGravatar letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7>2012-05-16 12:49:19 +0000
commitb2fcd2f27295f0fbb24c9ee95b1ebdfc712bcd83 (patch)
tree76dde320e00220079f4173ebde5c5b79fe8a3ca8
parent2e30c99c1b3bd7e39229efe041ca4677e27fd673 (diff)
Coqide: make some paths win32-compliant
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@15332 85f007b7-540e-0410-9357-904b9bb8a0f7
-rwxr-xr-xconfigure2
-rw-r--r--ide/minilib.ml47
2 files changed, 36 insertions, 13 deletions
diff --git a/configure b/configure
index adf1a75f8..ed9a99e8f 100755
--- a/configure
+++ b/configure
@@ -748,7 +748,7 @@ case $ARCH$CYGWIN in
bindir_def=${W32PREF}bin
libdir_def=${W32PREF}lib
configdir_def=${W32PREF}config
- datadir_def=${W32PREF}data
+ datadir_def=${W32PREF}share
mandir_def=${W32PREF}man
docdir_def=${W32PREF}doc
emacslib_def=${W32PREF}emacs
diff --git a/ide/minilib.ml b/ide/minilib.ml
index 2400872a4..4ccb1ccbd 100644
--- a/ide/minilib.ml
+++ b/ide/minilib.ml
@@ -64,9 +64,10 @@ let string_map f s =
let subst_command_placeholder s t =
Str.global_replace (Str.regexp_string "%s") t s
-let path_to_list p =
- let sep = Str.regexp (if Sys.os_type = "Win32" then ";" else ":") in
- Str.split sep p
+(* Split the content of a variable such as $PATH in a list of directories.
+ The separators are either ":" in unix or ";" in win32 *)
+
+let path_to_list = Str.split (Str.regexp "[:;]")
(* On win32, the home directory is probably not in $HOME, but in
some other environment variable *)
@@ -76,28 +77,50 @@ let home =
try (Sys.getenv "HOMEDRIVE")^(Sys.getenv "HOMEPATH") with Not_found ->
try Sys.getenv "USERPROFILE" with Not_found -> Filename.current_dir_name
+let opt2list = function None -> [] | Some x -> [x]
+
+let rec lconcat = function
+ | [] -> assert false
+ | [x] -> x
+ | x::l -> Filename.concat x (lconcat l)
+
let xdg_config_home =
try
Filename.concat (Sys.getenv "XDG_CONFIG_HOME") "coq"
with Not_found ->
- Filename.concat home "/.config/coq"
+ lconcat [home;".config";"coq"]
+
+let static_xdg_config_dirs =
+ if Sys.os_type = "Win32" then
+ let base = Filename.dirname (Filename.dirname Sys.executable_name) in
+ [Filename.concat base "config"]
+ else ["/etc/xdg/coq"]
let xdg_config_dirs =
- xdg_config_home :: (try
- List.map (fun dir -> Filename.concat dir "coq") (path_to_list (Sys.getenv "XDG_CONFIG_DIRS"))
- with Not_found -> ["/etc/xdg/coq"])@(match Coq_config.configdir with |None -> [] |Some d -> [d])
+ xdg_config_home ::
+ try
+ List.map (fun dir -> Filename.concat dir "coq")
+ (path_to_list (Sys.getenv "XDG_CONFIG_DIRS"))
+ with Not_found -> static_xdg_config_dirs @ opt2list Coq_config.configdir
let xdg_data_home =
try
Filename.concat (Sys.getenv "XDG_DATA_HOME") "coq"
with Not_found ->
- Filename.concat home "/.local/share/coq"
+ lconcat [home;".local";"share";"coq"]
+
+let static_xdg_data_dirs =
+ if Sys.os_type = "Win32" then
+ let base = Filename.dirname (Filename.dirname Sys.executable_name) in
+ [Filename.concat base "share"]
+ else ["/usr/local/share/coq";"/usr/share/coq"]
let xdg_data_dirs =
- xdg_data_home :: (try
- List.map (fun dir -> Filename.concat dir "coq") (path_to_list (Sys.getenv "XDG_DATA_DIRS"))
- with Not_found ->
- ["/usr/local/share/coq";"/usr/share/coq"])@(match Coq_config.datadir with |None -> [] |Some d -> [d])
+ xdg_data_home ::
+ try
+ List.map (fun dir -> Filename.concat dir "coq")
+ (path_to_list (Sys.getenv "XDG_DATA_DIRS"))
+ with Not_found -> static_xdg_data_dirs @ opt2list Coq_config.datadir
let coqtop_path = ref ""