mkHomeModLocation2, -- :: ModuleName -> FilePath -> String -> IO ModLocation
addHomeModuleToFinder, -- :: HscEnv -> Module -> ModLocation -> IO ()
uncacheModule, -- :: HscEnv -> Module -> IO ()
+ mkStubPaths,
findObjectLinkableMaybe,
findObjectLinkable,
import Util
import DynFlags ( DynFlags(..), isOneShot, GhcMode(..) )
import Outputable
+import Maybes ( expectJust )
import DATA_IOREF ( IORef, writeIORef, readIORef )
return result
where
- basename = dots_to_slashes (moduleUserString mod)
+ basename = dots_to_slashes (moduleString mod)
to_search :: [(FilePath, IO FinderCacheEntry)]
to_search = [ (file, fn path basename)
-> String -- Suffix
-> IO ModLocation
mkHomeModLocation2 dflags mod src_basename ext = do
- let mod_basename = dots_to_slashes (moduleUserString mod)
+ let mod_basename = dots_to_slashes (moduleString mod)
- obj_fn <- mkObjPath dflags src_basename mod_basename
- hi_fn <- mkHiPath dflags src_basename mod_basename
+ obj_fn <- mkObjPath dflags src_basename mod_basename
+ hi_fn <- mkHiPath dflags src_basename mod_basename
return (ModLocation{ ml_hs_file = Just (src_basename `joinFileExt` ext),
ml_hi_file = hi_fn,
hiOnlyModLocation :: DynFlags -> FilePath -> String -> Suffix -> IO ModLocation
hiOnlyModLocation dflags path basename hisuf
= do let full_basename = path `joinFileName` basename
- obj_fn <- mkObjPath dflags full_basename basename
+ obj_fn <- mkObjPath dflags full_basename basename
return ModLocation{ ml_hs_file = Nothing,
ml_hi_file = full_basename `joinFileExt` hisuf,
-- Remove the .hi-boot suffix from
-> IO FilePath
mkObjPath dflags basename mod_basename
= do let
- odir = outputDir dflags
+ odir = objectDir dflags
osuf = objectSuf dflags
obj_basename | Just dir <- odir = dir `joinFileName` mod_basename
-- -----------------------------------------------------------------------------
+-- Filenames of the stub files
+
+-- We don't have to store these in ModLocations, because they can be derived
+-- from other available information, and they're only rarely needed.
+
+mkStubPaths
+ :: DynFlags
+ -> Module
+ -> ModLocation
+ -> (FilePath,FilePath)
+
+mkStubPaths dflags mod location
+ = let
+ stubdir = stubDir dflags
+
+ mod_basename = dots_to_slashes (moduleString mod)
+ src_basename = basenameOf (expectJust "mkStubPaths"
+ (ml_hs_file location))
+
+ stub_basename0
+ | Just dir <- stubdir = dir `joinFileName` mod_basename
+ | otherwise = src_basename
+
+ stub_basename = stub_basename0 ++ "_stub"
+ in
+ (stub_basename `joinFileExt` "c",
+ stub_basename `joinFileExt` "h")
+ -- the _stub.o filename is derived from the ml_obj_file.
+
+-- -----------------------------------------------------------------------------
-- findLinkable isn't related to the other stuff in here,
-- but there's no other obvious place for it