X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FSysTools.lhs;h=11e31b823474aa67a1d10b0010942daa49435fa1;hb=9bcd5a09b7b57de8b7d6780fa7a767ff72049a7a;hp=9d53b81852f96ae6b72dc43aa6a462c149f8c9b3;hpb=9412e62942ebab0599c7fb0b358a9d4869647b67;p=ghc-hetmet.git diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index 9d53b81..11e31b8 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -163,16 +163,11 @@ initSysTools mbMinusB dflags0 ; let installed, installed_bin :: FilePath -> FilePath installed_bin pgm = top_dir pgm installed file = top_dir file - inplace dir pgm = let real_top_dir = foldr () "" - $ reverse - $ drop 4 - $ reverse - $ splitDirectories top_dir - in real_top_dir dir pgm + inplace dir pgm = top_dir dir pgm ; let pkgconfig_path | am_installed = installed "package.conf" - | otherwise = inplace cGHC_DRIVER_DIR_REL "package.conf.inplace" + | otherwise = inplace "inplace-datadir" "package.conf" ghc_usage_msg_path | am_installed = installed "ghc-usage.txt" @@ -327,11 +322,16 @@ findTopDir :: Maybe String -- Maybe TopDir path (without the '-B' prefix). findTopDir mbMinusB = do { top_dir <- get_proto - -- Discover whether we're running in a build tree or in an installation, - -- by looking for the package configuration file. - ; am_installed <- doesFileExist (top_dir "package.conf") + ; exists1 <- doesFileExist (top_dir "package.conf") + ; exists2 <- doesFileExist (top_dir "inplace") + ; let amInplace = not exists1 -- On Windows, package.conf doesn't exist + -- when we are inplace + || exists2 -- On Linux, the presence of inplace signals + -- that we are inplace - ; return (am_installed, top_dir) + ; let real_top = if exists2 then top_dir ".." else top_dir + + ; return (not amInplace, real_top) } where -- get_proto returns a Unix-format path (relying on getBaseDir to do so too) @@ -856,9 +856,14 @@ getBaseDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32. rootDir s = case splitFileName $ normalise s of (d, "ghc.exe") -> case splitFileName $ takeDirectory d of + -- installed ghc.exe is in $topdir/bin/ghc.exe (d', "bin") -> takeDirectory d' - _ -> panic ("Expected \"bin\" in " ++ show s) - _ -> panic ("Expected \"ghc.exe\" in " ++ show s) + -- inplace ghc.exe is in $topdir/ghc/stage1-inplace/ghc.exe + (d', x) | "-inplace" `isSuffixOf` x -> + takeDirectory d' ".." + _ -> fail + _ -> fail + where fail = panic ("can't decompose ghc.exe path: " ++ show s) foreign import stdcall unsafe "GetModuleFileNameA" getModuleFileName :: Ptr () -> CString -> Int -> IO Int32