Skip to content

Commit

Permalink
Fix pre-processing for executables
Browse files Browse the repository at this point in the history
The pre-processed files should go into the exe's build dir, not the
lib's build dir. Also pre-process main modules, fixing bug haskell#14.
  • Loading branch information
dcoutts committed Sep 22, 2007
1 parent ee135f8 commit c5c6616
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ build pkg_descr lbi verbosity = do
runGhcProg args
| filename <- cSources exeBi]

srcMainFile <- findFile (hsSourceDirs exeBi) modPath
srcMainFile <- findFile (exeDir : hsSourceDirs exeBi) modPath

let cObjs = map (`replaceExtension` objExtension) (cSources exeBi)
let binArgs linkExe profExe =
Expand Down
9 changes: 7 additions & 2 deletions Distribution/Simple/PreProcess.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ import Data.Maybe (fromMaybe)
import Data.List (nub)
import System.Directory (removeFile, getModificationTime)
import System.Info (os, arch)
import System.FilePath (splitExtension, (</>), (<.>), takeDirectory, normalise)
import System.FilePath (splitExtension, dropExtensions, (</>), (<.>),
takeDirectory, normalise)

-- |The interface to a preprocessor, which may be implemented using an
-- external program, but need not be. The arguments are the name of
Expand Down Expand Up @@ -176,11 +177,15 @@ preprocessSources pkg_descr lbi forSDist verbosity handlers = do
withExe pkg_descr $ \ theExe -> 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)))
(buildDir lbi) forSDist
exeDir forSDist
modu verbosity builtinSuffixes biHandlers
| modu <- otherModules bi]
preprocessModule (hsSourceDirs bi) exeDir forSDist
(dropExtensions (modulePath theExe))
verbosity builtinSuffixes biHandlers
where hc = compilerFlavor (compiler lbi)
builtinSuffixes
| hc == NHC = ["hs", "lhs", "gc"]
Expand Down

0 comments on commit c5c6616

Please sign in to comment.