Skip to content

Add compilerLocation to Compiler datatype #7507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cabal/src/Distribution/Simple/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import Distribution.Compiler
import Distribution.Version
import Language.Haskell.Extension
import Distribution.Simple.Utils
import Distribution.Simple.Program.Types (ProgramLocation)

import qualified Data.Map as Map (lookup)
import System.Directory (canonicalizePath)
Expand All @@ -97,8 +98,10 @@ data Compiler = Compiler {
-- ^ Supported language standards.
compilerExtensions :: [(Extension, Maybe CompilerFlag)],
-- ^ Supported extensions.
compilerProperties :: Map String String
compilerProperties :: Map String String,
-- ^ A key-value map for properties not covered by the above fields.
compilerLocation :: ProgramLocation
-- ^ Compiler location
}
deriving (Eq, Generic, Typeable, Show, Read)

Expand Down
3 changes: 2 additions & 1 deletion Cabal/src/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ configure verbosity hcPath hcPkgPath conf0 = do
compilerCompat = [],
compilerLanguages = languages,
compilerExtensions = extensions,
compilerProperties = ghcInfoMap
compilerProperties = ghcInfoMap,
compilerLocation = programLocation ghcProg
}
compPlatform = Internal.targetPlatform ghcInfo
-- configure gcc and ld
Expand Down
3 changes: 2 additions & 1 deletion Cabal/src/Distribution/Simple/GHCJS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ configure verbosity hcPath hcPkgPath conf0 = do
compilerCompat = [CompilerId GHC ghcjsGhcVersion],
compilerLanguages = languages,
compilerExtensions = extensions,
compilerProperties = ghcInfoMap
compilerProperties = ghcInfoMap,
compilerLocation = programLocation ghcjsProg
}
compPlatform = Internal.targetPlatform ghcjsInfo
return (comp, compPlatform, progdb3)
Expand Down
3 changes: 2 additions & 1 deletion Cabal/src/Distribution/Simple/HaskellSuite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ configure verbosity mbHcPath hcPkgPath progdb0 = do
compilerCompat = [],
compilerLanguages = languages,
compilerExtensions = extensions,
compilerProperties = mempty
compilerProperties = mempty,
compilerLocation = programLocation confdCompiler
}

return (comp, confdCompiler, progdb2)
Expand Down
13 changes: 1 addition & 12 deletions Cabal/src/Distribution/Simple/ShowBuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,8 @@ mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
mkCompilerInfo = JsonObject
[ "flavour" .= JsonString (prettyShow $ compilerFlavor $ compiler lbi)
, "compiler-id" .= JsonString (showCompilerId $ compiler lbi)
, "path" .= path
, "path" .= JsonString (locationPath $ compilerLocation $ compiler lbi)
]
where
path = maybe JsonNull (JsonString . programPath)
$ (flavorToProgram . compilerFlavor $ compiler lbi)
>>= flip lookupProgram (withPrograms lbi)

flavorToProgram :: CompilerFlavor -> Maybe Program
flavorToProgram GHC = Just ghcProgram
flavorToProgram GHCJS = Just ghcjsProgram
flavorToProgram UHC = Just uhcProgram
flavorToProgram JHC = Just jhcProgram
flavorToProgram _ = Nothing

mkComponentInfo (name, clbi) = JsonObject
[ "type" .= JsonString compType
Expand Down
5 changes: 3 additions & 2 deletions Cabal/src/Distribution/Simple/UHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ configure :: Verbosity -> Maybe FilePath -> Maybe FilePath
-> ProgramDb -> IO (Compiler, Maybe Platform, ProgramDb)
configure verbosity hcPath _hcPkgPath progdb = do

(_uhcProg, uhcVersion, progdb') <-
(uhcProg, uhcVersion, progdb') <-
requireProgramVersion verbosity uhcProgram
(orLaterVersion (mkVersion [1,0,2]))
(userMaybeSpecifyPath "uhc" hcPath progdb)
Expand All @@ -65,7 +65,8 @@ configure verbosity hcPath _hcPkgPath progdb = do
compilerCompat = [],
compilerLanguages = uhcLanguages,
compilerExtensions = uhcLanguageExtensions,
compilerProperties = Map.empty
compilerProperties = Map.empty,
compilerLocation = programLocation uhcProg
}
compPlatform = Nothing
return (comp, compPlatform, progdb')
Expand Down