OCaml Forge

Detail: [#1229] oasis should use bash on windows whenever possible (cmd as fallback)

Feature Requests: Browse | Download .csv | Monitor

[#1229] oasis should use bash on windows whenever possible (cmd as fallback)

Date:
2012-10-26 14:28
Priority:
3
State:
Open
Submitted by:
Andreas Hauptmann (anhau)
Assigned to:
Sylvain Le Gall (gildor-admin)
Resolution:
None
Due in version:
None
Product:
OASIS
Component:
OASIS
Operating System:
Windows XP
 
Summary:
oasis should use bash on windows whenever possible (cmd as fallback)

Detailed description
During porting several godi packages to windows, I've encountered
various issues with packages that use oasis.

There are two main problems:

- oasis doesn't quote parameteres passed to external command ( or quotes
them in a wrong way)
- oasis use cmd.exe (via Sys.command)

cmd.exe has several disadvantages:

- cmd.exe can't execute PostConfCommand and similar instructions in the
_oasis files (at least in most cases)
- there are also path in _oasis and other locations with *nix path
separators. cmd.exe can't deal with them properly. (It's a problem
of cmd.exe, windows itself excepts both, '/' and '\', as path
separator)
- the command line length is restricted (~8000), the quoting of
arguments is problematic.

Calling bash.exe / sh.exe (msys/cygwin) instead would solve the first
and last poinst:

- bash could execute most PostConfCommands
- the command line length limit is less restricted (only the limits
imposed by CreateProcess)

However, there are also disadvantages:

- Some (but not all) utils of cygwin have problems with windows path
separators (paths like 'C:/cygwin/tmp/test.dat' seem to work)
- bash is not installed by default ( currently not an issue. Users
have to install msys or cygwin in any case - because of ocamlbuild )

For testing purpose, I've modified some files (see https://github.com/arirux/oasis )

- OASISExec now uses bash, if bash and other unix tools are found in
$PATH.
- I've introduced OASISHostPath.quote. Filename.quote can't be used
any longer, because bash requires different quoting.
- I've rewritten OASISHostPath.of_unix. If "/" is enforced as path
separators for bash and "\" for cmd.exe, there a less problems with
quoting.

I've tested the changes with following packages that use oasis:

godi-batteries
godi-benchmark
godi-cfg
godi-ocaml-data-notation
godi-ocaml-expect
godi-ocaml-fileutils
godi-ocaml-text
godi-ounit
godi-pomap
godi-res
godi-sexplib
godi-sqlite3
godi-type_conv
godi-xmlm

There are still problems, because OASISHostPath.quote and
OASISHostPath.of_unix are not always used, where they should be used.
But beside of this, all package now compile cleanly with bash AND cmd.
Before the changes, they couldn't be installed at all, only partially
(installing files with ocamlfind usually worked, copying documentation
and similar files not) , and/or it was depending on a right
combination of forward/backward slashes in various command-line
switches and environment variables like OCAMLLIB.

Followup

Message
Date: 2012-10-26 16:35
Sender: Sylvain Le Gall

Here is my point of view:
1. try to avoid a strong dependencies on bash, we should target at avoiding it for Windows user
2. provide it as a compat layer through a command line flag, like "--use-bash cmd", so that it will allow people to get out of problematic situation, but still be able to use cmd.exe in most of the case
3. the "best" options will be to be able to detect the most common problem directly when we compile _oasis -> setup.ml, i.e. make sure everything is well quoted for both Windows and UNIX. I don't know to what extent this is possible but it would be a very nice feature to have.
4. the "ultra top" options is to have a "sh" interpreter directly into the setup.ml (is it possible ?)

But overall thanks a lot for the patch, please send a pull request with at least 1. and 2. so that we can talk about implementation. Point 3. and 4. are nice to have, but only if you want to invest time on it.

Attached Files:

Changes:

Field Old Value Date By
assigned_tonone2014-06-16 09:41gildor-admin