where
getRootSummary :: FilePath -> IO ModSummary
getRootSummary file
- | haskellish_src_file file
+ | isHaskellSrcFilename file
= do exists <- doesFileExist file
if exists then summariseFile file else do
throwDyn (CmdLineError ("can't find file `" ++ file ++ "'"))
import Packages
import DriverState ( v_Library_paths, v_Opt_l, v_Ld_inputs, getStaticOpts, v_ExplicitPackages )
+import DriverPhases ( isObjectFilename, isDynLibFilename )
import DriverUtil ( getFileSuffix )
#ifdef darwin_TARGET_OS
import DriverState ( v_Cmdline_frameworks, v_Framework_paths )
; lib_paths <- readIORef v_Library_paths
; cmdline_ld_inputs <- readIORef v_Ld_inputs
- ; let (cmdline_libs, cmdline_objs) = partition libish cmdline_ld_inputs
+ ; classified_ld_inputs <- mapM classifyLdInput cmdline_ld_inputs
-- (e) Link any MacOS frameworks
#ifdef darwin_TARGET_OS
; let framework_paths = []
#endif
-- Finally do (c),(d),(e)
- ; let cmdline_lib_specs = map Object cmdline_objs
- ++ map DLLPath cmdline_libs
+ ; let cmdline_lib_specs = [ l | Just l <- classified_ld_inputs ]
++ map DLL minus_ls
++ map Framework frameworks
; if null cmdline_lib_specs then return ()
else throwDyn (InstallationError "linking extra libraries/objects failed")
}}
-libish :: String -> Bool
-libish f = getFileSuffix f `elem` dynlib_suffixes
-
-#ifdef mingw32_TARGET_OS
-dynlib_suffixes = ["dll", "DLL"]
-#elif defined(darwin_TARGET_OS)
-dynlib_suffixes = ["dylib"]
-#else
-dynlib_suffixes = ["so"]
-#endif
+classifyLdInput :: FilePath -> IO (Maybe LibrarySpec)
+classifyLdInput f
+ | isObjectFilename f = return (Just (Object f))
+ | isDynLibFilename f = return (Just (DLLPath f))
+ | otherwise = do
+ hPutStrLn stderr ("Warning: ignoring unrecognised input `" ++ f ++ "'")
+ return Nothing
preloadLib :: DynFlags -> [String] -> [String] -> LibrarySpec -> IO ()
preloadLib dflags lib_paths framework_paths lib_spec
-----------------------------------------------------------------------------
--- $Id: DriverPhases.hs,v 1.27 2003/06/26 21:55:47 sof Exp $
+-- $Id: DriverPhases.hs,v 1.28 2003/10/22 14:31:09 simonmar Exp $
--
-- GHC Driver
--
startPhase, -- :: String -> Phase
phaseInputExt, -- :: Phase -> String
- haskellish_file, haskellish_suffix,
- haskellish_src_file, haskellish_src_suffix,
- objish_file, objish_suffix,
- cish_file, cish_suffix,
- isExtCore_file, extcoreish_suffix,
- haskellish_user_src_file,
- isSourceFile -- :: FilePath -> Bool
+ isHaskellishFilename,
+ isHaskellSrcFilename,
+ isObjectFilename,
+ isCishFilename,
+ isExtCoreFilename,
+ isDynLibFilename,
+ isHaskellUserSrcFilename,
+ isSourceFilename -- :: FilePath -> Bool
) where
import DriverUtil
phaseInputExt Ilasm = "il"
#endif
-haskellish_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ])
-haskellish_src_suffix = (`elem` [ "hs", "lhs", "hspp", "hscpp", "hcr"])
-cish_suffix = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ])
-extcoreish_suffix = (`elem` [ "hcr" ])
-haskellish_user_src_suffix = (`elem` [ "hs", "lhs" ])
+haskellish_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ]
+haskellish_src_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr"]
+cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S" ]
+extcoreish_suffixes = [ "hcr" ]
+haskellish_user_src_suffixes = [ "hs", "lhs" ]
-- Use the appropriate suffix for the system on which
-- the GHC-compiled code will run
#if mingw32_TARGET_OS || cygwin32_TARGET_OS
-objish_suffix = (`elem` [ "o", "O", "obj", "OBJ" ])
+objish_suffixes = [ "o", "O", "obj", "OBJ" ]
#else
-objish_suffix = (`elem` [ "o" ])
+objish_suffixes = [ "o" ]
#endif
-haskellish_file = haskellish_suffix . getFileSuffix
-haskellish_src_file = haskellish_src_suffix . getFileSuffix
-cish_file = cish_suffix . getFileSuffix
-isExtCore_file = extcoreish_suffix . getFileSuffix
-objish_file = objish_suffix . getFileSuffix
-haskellish_user_src_file = haskellish_user_src_suffix . getFileSuffix
-
-isSourceFile :: FilePath -> Bool
-isSourceFile f =
- haskellish_file f ||
- cish_file f
+#ifdef mingw32_TARGET_OS
+dynlib_suffixes = ["dll", "DLL"]
+#elif defined(darwin_TARGET_OS)
+dynlib_suffixes = ["dylib"]
+#else
+dynlib_suffixes = ["so"]
+#endif
+
+isHaskellishFilename f = getFileSuffix f `elem` haskellish_suffixes
+isHaskellSrcFilename f = getFileSuffix f `elem` haskellish_src_suffixes
+isCishFilename f = getFileSuffix f `elem` cish_suffixes
+isExtCoreFilename f = getFileSuffix f `elem` extcoreish_suffixes
+isObjectFilename f = getFileSuffix f `elem` objish_suffixes
+isHaskellUserSrcFilename f = getFileSuffix f `elem` haskellish_user_src_suffixes
+isDynLibFilename f = getFileSuffix f `elem` dynlib_suffixes
+
+isSourceFilename :: FilePath -> Bool
+isSourceFilename f =
+ isHaskellishFilename f ||
+ isCishFilename f
preprocess :: FilePath -> IO FilePath
preprocess filename =
- ASSERT(haskellish_src_file filename)
+ ASSERT(isHaskellSrcFilename filename)
do restoreDynFlags -- Restore to state of last save
runPipeline (StopBefore Hsc) ("preprocess")
False{-temporary output file-}
-- gather the imports and module name
(_,_,mod_name) <-
- if extcoreish_suffix suff
+ if isExtCoreFilename ('.':suff)
then do
-- no explicit imports in ExtCore input.
m <- getCoreModuleName input_fn
import CodeOutput ( codeOutput )
import CmdLineOpts
-import DriverPhases ( isExtCore_file )
+import DriverPhases ( isExtCoreFilename )
import ErrUtils ( dumpIfSet, dumpIfSet_dyn, showPass )
import UniqSupply ( mkSplitUniqSupply )
; let dflags = hsc_dflags hsc_env
; let toInterp = dopt_HscLang dflags == HscInterpreted
; let toCore = isJust (ml_hs_file location) &&
- isExtCore_file (fromJust (ml_hs_file location))
+ isExtCoreFilename (fromJust (ml_hs_file location))
; when (not one_shot && verbosity dflags >= 1) $
hPutStrLn stderr ("Compiling " ++
{-# OPTIONS -fno-warn-incomplete-patterns -optc-DNON_POSIX_SOURCE #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.134 2003/10/09 11:58:57 simonpj Exp $
+-- $Id: Main.hs,v 1.135 2003/10/22 14:31:10 simonmar Exp $
--
-- GHC Driver program
--
dynamic_flags, processArgs, static_flags)
import DriverMkDepend ( beginMkDependHS, endMkDependHS )
-import DriverPhases ( isSourceFile )
+import DriverPhases ( isSourceFilename )
import DriverUtil ( add, handle, handleDyn, later, unknownFlagsErr )
import CmdLineOpts ( dynFlag, restoreDynFlags,
Everything else is considered to be a linker object, and passed
straight through to the linker.
-}
- looks_like_an_input m = isSourceFile m
+ looks_like_an_input m = isSourceFilename m
|| looksLikeModuleName m
|| '.' `notElem` m
#include "HsVersions.h"
import DriverUtil
-import DriverPhases ( haskellish_user_src_file )
+import DriverPhases ( isHaskellUserSrcFilename )
import Config
import Outputable
import Panic ( progName, GhcException(..) )
hPutStrLn stderr ("WARNING - NOT deleting source files: " ++ unwords non_deletees)
act
- (non_deletees, deletees) = partition haskellish_user_src_file fs
+ (non_deletees, deletees) = partition isHaskellUserSrcFilename fs
rm f = removeFile f `IO.catch`
(\_ignored ->