[project @ 2001-07-17 17:27:20 by sof]
authorsof <unknown>
Tue, 17 Jul 2001 17:27:21 +0000 (17:27 +0000)
committersof <unknown>
Tue, 17 Jul 2001 17:27:21 +0000 (17:27 +0000)
Drop the dependency on the Win32 library, as it is only used in an
extremely limited way (a single 'foreign import' is all that's reqd)
[Sorry Reuben, I don't buy your 'extra deps are good' argument :-) ]

ghc/compiler/Makefile
ghc/compiler/main/SysTools.lhs

index 5576a79..74029fe 100644 (file)
@@ -1,5 +1,5 @@
 # -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.175 2001/07/16 15:46:09 sof Exp $
+# $Id: Makefile,v 1.176 2001/07/17 17:27:20 sof Exp $
 
 TOP = ..
 include $(TOP)/mk/boilerplate.mk
@@ -224,7 +224,7 @@ SRC_HC_OPTS += \
 ifneq "$(mingw32_TARGET_OS)" "1"
 SRC_HC_OPTS += -package concurrent -package posix -package text -package util
 else
-SRC_HC_OPTS += -package concurrent -package win32 -package text -package util
+SRC_HC_OPTS += -package concurrent -package text -package util
 endif
 
 SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
index 8783498..5489b38 100644 (file)
@@ -54,16 +54,19 @@ import IO
 import Directory       ( doesFileExist, removeFile )
 import IOExts          ( IORef, readIORef, writeIORef )
 import Monad           ( when, unless )
-import System          ( system, ExitCode(..), exitWith, getEnv )
+import System          ( system, ExitCode(..), exitWith )
+import CString
+import Int
+import Addr
     
 #include "../includes/config.h"
 
 #if !defined(mingw32_TARGET_OS)
 import qualified Posix
 #else
-import Win32DLL
-import List            ( isPrefixOf, isSuffixOf )
+import List            ( isPrefixOf )
 #endif
+import MarshalArray
 
 #include "HsVersions.h"
 
@@ -685,9 +688,15 @@ slash s1 s2 = s1 ++ ('/' : s2)
 
 #if defined(mingw32_TARGET_OS)
 getExecDir :: IO (Maybe String)
-getExecDir = do h <- getModuleHandle Nothing
-               n <- getModuleFileName h
-               return (Just (reverse (drop (length "/bin/ghc.exe") (reverse (unDosifyPath n)))))
+getExecDir = do let len = 2048
+               buf <- mallocArray (fromIntegral len)
+               ret <- getModuleFileName nullAddr buf len
+               if ret == 0 then return Nothing
+                           else do s <- peekCString buf
+                                   destructArray (fromIntegral len) buf
+                                   return (Just (reverse (tail (dropWhile (not . isSlash) (reverse (unDosifyPath s))))))
+
+foreign import stdcall "GetModuleFileNameA" getModuleFileName :: Addr -> CString -> Int32 -> IO Int32
 #else
 getExecDir :: IO (Maybe String) = do return Nothing
 #endif