aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorletouzey2011-04-21 16:12:34 +0000
committerletouzey2011-04-21 16:12:34 +0000
commit9ccd1899dba51e24216d0de8865eecf029f44cef (patch)
tree0b25a558459b4d8f789e87162646587488f31ae9
parent08642139dc3edf2caf94e7f246c15644daca16ad (diff)
Win32: remove the need for Coq.bat and Coqide.bat
This is an adaptation of commit r13750 of branch 8.3 - coqlib is currently computed relatively of Sys.executable_name, hence no need to set it manually - in Win32, better detection of user home dir : in System.ml, if HOME isn't set, we look now for HOMEDRIVE\HOMEPATH, and then for USERPROFILE - concerning PATH, in Win32 we now add coqbin (or the location of coqide) to PATH during the initialization. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@14041 85f007b7-540e-0410-9357-904b9bb8a0f7
-rwxr-xr-xCoq.bat8
-rwxr-xr-xCoqide.bat7
-rw-r--r--README.win10
-rw-r--r--ide/coqide_main.ml49
-rw-r--r--ide/minilib.ml8
-rw-r--r--ide/utils/configwin_messages.ml4
-rw-r--r--lib/envars.ml7
-rw-r--r--lib/system.ml13
8 files changed, 42 insertions, 24 deletions
diff --git a/Coq.bat b/Coq.bat
deleted file mode 100755
index cdd7d50de1..0000000000
--- a/Coq.bat
+++ /dev/null
@@ -1,8 +0,0 @@
-@echo off
-set COQBIN=%~0\..\bin
-set COQLIB=%~0\..\lib
-echo Using COQBIN= %COQBIN%
-echo and COQLIB= %COQLIB%
-echo Starting Coq
-%~0\..\bin\coqtop.opt.exe
-pause \ No newline at end of file
diff --git a/Coqide.bat b/Coqide.bat
deleted file mode 100755
index f955a97063..0000000000
--- a/Coqide.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-@echo off
-set COQBIN=%~0\..\bin
-set COQLIB=%~0\..\lib
-echo Using COQBIN= %COQBIN%
-echo and COQLIB= %COQLIB%
-echo Starting Coqide
-%~0\..\bin\coqide.opt.exe \ No newline at end of file
diff --git a/README.win b/README.win
index 9f6eff7997..5027016f54 100644
--- a/README.win
+++ b/README.win
@@ -9,9 +9,9 @@ INSTALLATION.
The Coq package for Windows comes with an auto-installer. It will
install Coq binaries and libraries under any directory you specify
(C:\Program Files\Coq is the default path). It also creates shortcuts
-in the Windows menus. Alternatively, you can launch Coq using Coq.bat
-and Coqide.bat in the installation directory (C:\Program Files\Coq by
-default).
+in the Windows menus. Alternatively, you can launch Coq using coqide.exe
+or coqtop.exe in the bin sub-directory of the installation
+(C:\Program Files\Coq\bin by default).
COMPILATION.
============
@@ -52,4 +52,8 @@ COMPILATION.
Good luck :-)
+ Alternatively, it is now possible (and even recommended ...) to build
+ Windows executables of coq from Linux thanks to a mingw cross-compiler.
+ If interested, please contact us for more details.
+
The Coq Team.
diff --git a/ide/coqide_main.ml4 b/ide/coqide_main.ml4
index 9fc0f72b71..7c0f231706 100644
--- a/ide/coqide_main.ml4
+++ b/ide/coqide_main.ml4
@@ -18,7 +18,16 @@ let initmac () = IFDEF MacInt THEN gtk_mac_init Coqide.do_load Coqide.forbid_qui
let macready () = IFDEF MacInt THEN gtk_mac_ready () ELSE () END
+(* On win32, we add the directory of coqide to the PATH at launch-time
+ (this used to be done in a .bat script). *)
+
+let winpath () =
+ if Coq_config.arch = "win32" then
+ Unix.putenv "PATH" (Filename.dirname Sys.executable_name ^ ";" ^
+ (try Sys.getenv "PATH" with _ -> ""))
+
let () =
+ winpath ();
let argl = Array.to_list Sys.argv in
let argl = Coqide.set_coqtop_path argl in
let files = Coqide.process_argv argl in
diff --git a/ide/minilib.ml b/ide/minilib.ml
index 9833fbd6bc..f072ff9fa2 100644
--- a/ide/minilib.ml
+++ b/ide/minilib.ml
@@ -58,7 +58,13 @@ let list_filter_i p =
let subst_command_placeholder s t =
Str.global_replace (Str.regexp_string "%s") s t
-let home = try Sys.getenv "HOME" with Not_found -> "."
+(* On win32, the home directory is probably not in $HOME, but in
+ some other environment variable *)
+
+let home =
+ try Sys.getenv "HOME" with Not_found ->
+ try (Sys.getenv "HOMEDRIVE")^(Sys.getenv "HOMEPATH") with Not_found ->
+ try Sys.getenv "USERPROFILE" with Not_found -> "."
let coqlib = ref ""
let coqtop_path = ref ""
diff --git a/ide/utils/configwin_messages.ml b/ide/utils/configwin_messages.ml
index f89844627e..de29243182 100644
--- a/ide/utils/configwin_messages.ml
+++ b/ide/utils/configwin_messages.ml
@@ -30,9 +30,7 @@ let version = "1.2";;
let html_config = "Configwin bindings configurator for html parameters"
-let home =
- try Sys.getenv "HOME"
- with Not_found -> ""
+let home = Minilib.home
let mCapture = "Capture";;
let mType_key = "Type key" ;;
diff --git a/lib/envars.ml b/lib/envars.ml
index a05029c95b..f19834527d 100644
--- a/lib/envars.ml
+++ b/lib/envars.ml
@@ -14,6 +14,13 @@ let coqbin () =
then Filename.concat Coq_config.coqsrc "bin"
else System.canonical_path_name (Filename.dirname Sys.executable_name)
+(* On win32, we add coqbin to the PATH at launch-time (this used to be
+ done in a .bat script). *)
+
+let _ =
+ if Coq_config.arch = "win32" then
+ Unix.putenv "PATH" (coqbin() ^ ";" ^ System.getenv_else "PATH" "")
+
let guess_coqlib () =
let file = "states/initial.coq" in
if Sys.file_exists (Filename.concat Coq_config.coqlib file)
diff --git a/lib/system.ml b/lib/system.ml
index 23c6081bbd..f5c96256ff 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -19,12 +19,21 @@ let safe_getenv_def var def =
Sys.getenv var
with Not_found ->
warning ("Environment variable "^var^" not found: using '"^def^"' .");
- flush Pervasives.stdout;
+ flush_all ();
def
let getenv_else s dft = try Sys.getenv s with Not_found -> dft
-let home = (safe_getenv_def "HOME" ".")
+(* On win32, the home directory is probably not in $HOME, but in
+ some other environment variable *)
+
+let home =
+ try Sys.getenv "HOME" with Not_found ->
+ try (Sys.getenv "HOMEDRIVE")^(Sys.getenv "HOMEPATH") with Not_found ->
+ try Sys.getenv "USERPROFILE" with Not_found ->
+ warning ("Cannot determine user home directory, using '.' .");
+ flush_all ();
+ "."
let safe_getenv n = safe_getenv_def n ("$"^n)