Commit 4c75d3ff authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Merge pull request #123 from angerman/feature/fix-clang

Feature/fix clang
parents 79a0bf31 5ccd03ca
......@@ -51,8 +51,7 @@ install:
- ( cd ghc/shake-build && cabal install --only-dependencies )
- ( cd ghc && ./boot )
- if [ $TRAVIS_OS_NAME == osx ]; then ( cd ghc && ./configure --with-gcc="$(which clang)"); fi
- if [ $TRAVIS_OS_NAME == linux ]; then ( cd ghc && ./configure ); fi
- ( cd ghc && ./configure )
script:
- ./ghc/shake-build/build.sh -j --no-progress
......
......@@ -32,9 +32,6 @@ git submodule update --init
git clone git://github.com/snowleopard/shaking-up-ghc shake-build
./boot
./configure
# or if you want to use clang (e.g. building on OS X)
./configure --with-gcc=$(which clang) # See #26
```
Now you have a couple of options:
......
......@@ -27,6 +27,7 @@ executable ghc-shake
, Oracles.Config.Flag
, Oracles.Config.Setting
, Oracles.Dependencies
, Oracles.LookupInPath
, Oracles.ModuleFiles
, Oracles.PackageData
, Oracles.PackageDeps
......
......@@ -24,7 +24,7 @@ module Base (
-- * Miscellaneous utilities
bimap, minusOrd, intersectOrd, replaceEq, replace, quote, chunksOfSize,
replaceSeparators, decodeModule, encodeModule, unifyPath, (-/-),
versionToInt, removeFileIfExists, removeDirectoryIfExists
versionToInt, removeFileIfExists, removeDirectoryIfExists, wordsWhen
) where
import Control.Applicative
......@@ -238,3 +238,12 @@ removeFileIfExists f = liftIO . whenM (IO.doesFileExist f) $ IO.removeFile f
removeDirectoryIfExists :: FilePath -> Action ()
removeDirectoryIfExists d =
liftIO . whenM (IO.doesDirectoryExist d) $ IO.removeDirectoryRecursive d
-- | Split function. Splits a string @s@ into chunks
-- when the predicate @p@ holds. See: http://stackoverflow.com/a/4981265
wordsWhen :: Eq a => (a -> Bool) -> [a] -> [[a]]
wordsWhen p s =
case dropWhile p s of
[] -> []
s' -> w : wordsWhen p s''
where (w, s'') = break p s'
......@@ -94,7 +94,11 @@ builderPath builder = do
path <- askConfigWithDefault (builderKey builder) $
putError $ "\nCannot find path to '" ++ (builderKey builder)
++ "' in configuration files."
fixAbsolutePathOnWindows $ if null path then "" else path -<.> exe
windows <- windowsHost
case (path, windows) of
("", _) -> return path
(p, True) -> fixAbsolutePathOnWindows (p -<.> exe)
(p, False) -> lookupInPath (p -<.> exe)
getBuilderPath :: Builder -> ReaderT a Action FilePath
getBuilderPath = lift . builderPath
......
......@@ -3,6 +3,7 @@ module Oracles (
module Oracles.Config.Flag,
module Oracles.Config.Setting,
module Oracles.Dependencies,
module Oracles.LookupInPath,
module Oracles.PackageData,
module Oracles.PackageDeps,
module Oracles.WindowsRoot
......@@ -12,6 +13,7 @@ import Oracles.Config
import Oracles.Config.Flag
import Oracles.Config.Setting
import Oracles.Dependencies
import Oracles.LookupInPath
import Oracles.PackageData
import Oracles.PackageDeps
import Oracles.WindowsRoot
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module Oracles.LookupInPath (
lookupInPath, lookupInPathOracle
) where
import Base
newtype LookupInPath = LookupInPath String
deriving (Show, Typeable, Eq, Hashable, Binary, NFData)
-- | Fetches the absolute FilePath to a given FilePath from the
-- Oracle.
commandPath :: FilePath -> Action FilePath
commandPath = askOracle . LookupInPath
-- | Lookup a @command@ in @PATH@ environment.
lookupInPath :: FilePath -> Action FilePath
lookupInPath c
| c /= takeFileName c = return c
| otherwise = commandPath c
lookupInPathOracle :: Rules ()
lookupInPathOracle = do
o <- newCache $ \c -> do
envPaths <- wordsWhen (== ':') <$> getEnvWithDefault "" "PATH"
let candidates = map (-/- c) envPaths
-- this will crash if we do not find any valid candidate.
fullCommand <- head <$> filterM doesFileExist candidates
putOracle $ "Found '" ++ c ++ "' at " ++ "'" ++ fullCommand ++ "'"
return fullCommand
_ <- addOracle $ \(LookupInPath c) -> o c
return ()
......@@ -10,6 +10,7 @@ oracleRules = do
argsHashOracle -- see Oracles.ArgsHash
configOracle -- see Oracles.Config
dependenciesOracle -- see Oracles.Dependencies
lookupInPathOracle -- see Oracles.LookupInPath
moduleFilesOracle -- see Oracles.ModuleFiles
packageDataOracle -- see Oracles.PackageData
packageDepsOracle -- see Oracles.PackageDeps
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment