Commit 44788518 authored by Moritz Angermann's avatar Moritz Angermann
Browse files

Lookup builder in PATH if they are given without path.

`system-gcc` may be given without path (e.g. `clang`), this patch adds lookup using `which`
for those commands. Also drops calling `fixAbsolutePathOnWindows` on non window hosts.
Fixes #26
parent 0fee526a
......@@ -94,7 +94,9 @@ 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
let path' = if null path then "" else path -<.> exe in
(if windows then fixAbsolutePathOnWindows else lookupInPath) path'
getBuilderPath :: Builder -> ReaderT a Action FilePath
getBuilderPath = lift . builderPath
......
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module Oracles.WindowsRoot (
windowsRoot, fixAbsolutePathOnWindows, topDirectory, windowsRootOracle
windowsRoot, fixAbsolutePathOnWindows, lookupInPath, topDirectory, windowsRootOracle
) where
import Data.Char (isSpace)
......@@ -38,6 +38,15 @@ fixAbsolutePathOnWindows path = do
else
return path
-- | Lookup a @command@ in @PATH@ environment.
lookupInPath :: FilePath -> Action FilePath
lookupInPath command
| command /= takeFileName command = return command
| otherwise = do
Stdout out <- quietly $ cmd ["which", command]
let path = dropWhileEnd isSpace out
return path
-- Oracle for windowsRoot. This operation requires caching as looking up
-- the root is slow (at least the current implementation).
windowsRootOracle :: Rules ()
......
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