Skip to content

Commit

Permalink
Win32: remove the need for Coq.bat and Coqide.bat
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
letouzey committed Apr 21, 2011
1 parent 0864213 commit 9ccd189
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 24 deletions.
8 changes: 0 additions & 8 deletions Coq.bat

This file was deleted.

7 changes: 0 additions & 7 deletions Coqide.bat

This file was deleted.

10 changes: 7 additions & 3 deletions README.win
Expand Up @@ -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.
============
Expand Down Expand Up @@ -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.
9 changes: 9 additions & 0 deletions ide/coqide_main.ml4
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion ide/minilib.ml
Expand Up @@ -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 ""
4 changes: 1 addition & 3 deletions ide/utils/configwin_messages.ml
Expand Up @@ -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" ;;
Expand Down
7 changes: 7 additions & 0 deletions lib/envars.ml
Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions lib/system.ml
Expand Up @@ -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)

Expand Down

0 comments on commit 9ccd189

Please sign in to comment.