Commit 544179c9 authored by rrt's avatar rrt
Browse files

[project @ 2001-07-17 14:48:04 by rrt]

1. Make GHC work with paths and filenames containing spaces (hopefully).
This is done by quoting all arguments sent to the shell. To avoid causing
problems, this means that each argument in a list had *better* be a single
argument, hence the next commit to PackageSrc.hs.

2. undosify the path passed as the -h argument to unlit, to make unlit work
on Windows again.

3. Fix getExecDir for Windows (broken by previous changes to the meaning of
-B).
parent 5f6ec2ca
-----------------------------------------------------------------------------
-- $Id: DriverPipeline.hs,v 1.89 2001/07/11 19:48:07 sof Exp $
-- $Id: DriverPipeline.hs,v 1.90 2001/07/17 14:48:04 rrt Exp $
--
-- GHC Driver
--
......@@ -34,7 +34,7 @@ import DriverUtil
import DriverMkDepend
import DriverPhases
import DriverFlags
import SysTools ( newTempName, addFilesToClean, getSysMan )
import SysTools ( newTempName, addFilesToClean, getSysMan, unDosifyPath )
import qualified SysTools
import HscMain
import Finder
......@@ -324,7 +324,10 @@ run_phase :: Phase
run_phase Unlit _basename _suff input_fn output_fn
= do unlit_flags <- getOpts opt_L
SysTools.runUnlit (unlit_flags ++ ["-h", input_fn, input_fn, output_fn])
-- The -h option passes the file name for unlit to put in a #line directive;
-- we undosify it so that it doesn't contain backslashes in Windows, which
-- would disappear in error messages
SysTools.runUnlit (unlit_flags ++ ["-h", unDosifyPath input_fn, input_fn, output_fn])
return (Just output_fn)
-------------------------------------------------------------------------------
......@@ -800,11 +803,11 @@ doLink o_files = do
++ extra_ld_opts
++ if static && not no_hs_main then
#ifdef LEADING_UNDERSCORE
[ "-u _PrelMain_mainIO_closure" ,
"-u ___init_PrelMain"]
[ "-u", "_PrelMain_mainIO_closure" ,
"-u", "___init_PrelMain"]
#else
[ "-u PrelMain_mainIO_closure" ,
"-u __init_PrelMain"]
[ "-u", "PrelMain_mainIO_closure" ,
"-u", "__init_PrelMain"]
#endif
else [])
......
......@@ -24,6 +24,7 @@ module SysTools (
touch, -- String -> String -> IO ()
copy, -- String -> String -> String -> IO ()
unDosifyPath, -- String -> String
-- Temporary-file management
setTmpDir,
......@@ -61,11 +62,9 @@ import System ( system, ExitCode(..), exitWith, getEnv )
import qualified Posix
#else
import Win32DLL
import List ( isPrefixOf )
import List ( isPrefixOf, isSuffixOf )
#endif
import List ( isSuffixOf )
#include "HsVersions.h"
\end{code}
......@@ -242,7 +241,7 @@ initSysTools minusB_args
-- pick up whatever happens to be lying around in the path,
-- possibly including those from a cygwin install on the target,
-- which is exactly what we're trying to avoid.
; let gcc_path | am_installed = installed_bin ("gcc -B" ++ installed "gcc-lib/")
; let gcc_path | am_installed = installed_bin ("gcc -B" ++ "\"" ++ (installed "gcc-lib/") ++ "\"")
| otherwise = cGCC
perl_path | am_installed = installed_bin cGHC_PERL
| otherwise = cGHC_PERL
......@@ -361,7 +360,7 @@ getTopDir minusbs
; return (am_installed, top_dir)
}
where
-- get_proto returns a Unix-format path
-- get_proto returns a Unix-format path (relying on getExecDir to do so too)
get_proto | not (null minusbs)
= return (unDosifyPath (drop 2 (last minusbs))) -- 2 for "-B"
| otherwise
......@@ -369,7 +368,7 @@ getTopDir minusbs
; case maybe_exec_dir of -- (only works on Windows;
-- returns Nothing on Unix)
Nothing -> throwDyn (InstallationError "missing -B<dir> option")
Just dir -> return (unDosifyPath dir)
Just dir -> return dir
}
\end{code}
......@@ -548,8 +547,10 @@ runSomething phase_name pgm args
else return ()
}
where
cmd_line = unwords (pgm : dosifyPaths args)
cmd_line = unwords (pgm : dosifyPaths (map quote args))
-- The pgm is already in native format (appropriate dir separators)
quote "" = ""
quote s = "\"" ++ s ++ "\""
traceCmd :: String -> String -> IO () -> IO ()
-- a) trace the command (at two levels of verbosity)
......@@ -674,7 +675,7 @@ slash s1 s2 = s1 ++ ('/' : s2)
getExecDir :: IO (Maybe String)
getExecDir = do h <- getModuleHandle Nothing
n <- getModuleFileName h
return (Just (reverse (tail (dropWhile (not . isSlash) (reverse (unDosifyPath n))))))
return (Just (reverse (drop (length "/bin/ghc.exe") (reverse (unDosifyPath n)))))
#else
getExecDir :: IO (Maybe String) = do return Nothing
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment