Skip to content

Commit

Permalink
Fix search dirs used for pre-processing executables
Browse files Browse the repository at this point in the history
It was combining the executable's hs-source-dirs with the library's
hs-source-dirs when pre-processing executables. This was inconsistent
with the search path used for finding ordinary .hs files and with
sdist and lead to confusing behaviour. See ticket #161.
If an executable needs source files from the library then it must specify
the right hs-source-dirs, including '.' if appropriate.
The behaviour is that if hs-source-dirs is not specified then the default
is '.' however if hs-source-dirs is specified then '.' is not implicitly
added. If it's needed then it must be added explicitly. This was always
the case for ordinary .hs files, this patch just brings things into line
for files that need pre-processing.
  • Loading branch information
dcoutts committed Mar 12, 2008
1 parent 1cda110 commit 0d66e76
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Distribution/Simple/PreProcess.hs
Expand Up @@ -64,7 +64,7 @@ import Distribution.Simple.Compiler (CompilerFlavor(..), Compiler(..), compilerV
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..))
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, readUTF8File, writeUTF8File
, die, setupMessage
, die, setupMessage, intercalate
, findFileWithExtension, findFileWithExtension', dotToSep )
import Distribution.Simple.Program (Program(..), ConfiguredProgram(..),
lookupProgram, programPath,
Expand All @@ -77,7 +77,6 @@ import Distribution.Verbosity

import Control.Monad (when, unless, join)
import Data.Maybe (fromMaybe)
import Data.List (nub)
import System.Directory (getModificationTime)
import System.Info (os, arch)
import System.FilePath (splitExtension, dropExtensions, (</>), (<.>),
Expand Down Expand Up @@ -179,9 +178,7 @@ preprocessSources pkg_descr lbi forSDist verbosity handlers = do
let bi = buildInfo theExe
let biHandlers = localHandlers bi
let exeDir = buildDir lbi </> exeName theExe </> exeName theExe ++ "-tmp"
sequence_ [ preprocessModule (nub $ (hsSourceDirs bi)
++ (maybe [] (hsSourceDirs . libBuildInfo) (library pkg_descr)))
exeDir forSDist
sequence_ [ preprocessModule (hsSourceDirs bi) exeDir forSDist
modu verbosity builtinSuffixes biHandlers
| modu <- otherModules bi]
preprocessModule (hsSourceDirs bi) exeDir forSDist
Expand Down Expand Up @@ -213,7 +210,8 @@ preprocessModule searchLoc buildLoc forSDist modu verbosity builtinSuffixes hand
Nothing -> do
bsrcFiles <- findFileWithExtension builtinSuffixes searchLoc (dotToSep modu)
case bsrcFiles of
Nothing -> die ("can't find source for " ++ modu ++ " in " ++ show searchLoc)
Nothing -> die ("can't find source for " ++ modu ++ " in "
++ intercalate ", " searchLoc)
_ -> return ()
-- found a pre-processable file in one of the source dirs
Just (psrcLoc, psrcRelFile) -> do
Expand Down

0 comments on commit 0d66e76

Please sign in to comment.