packages feed

ghc-imported-from 0.1.0.3 → 0.1.0.4

raw patch · 3 files changed

+72/−6 lines, 3 files

Files

+ Language/Haskell/GhcImportedFrom/UtilsFromCabalInstall.hs view
@@ -0,0 +1,46 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  UtilsFromCabalInstall+-- Copyright   :  Carlo Hamalainen 2014+-- License     :  BSD3+--+-- Maintainer  :  carlo@carlo-hamalainen.net+-- Stability   :  experimental+-- Portability :  portable+--+-- We need a function from cabal-install which is not exported.++module Language.Haskell.GhcImportedFrom.UtilsFromCabalInstall where++import Data.Word                              ( Word32 )+import Numeric                                ( showHex )+import Data.List                              ( foldl' )+import Data.Char                              ( ord )+import Data.Bits                              ( shiftL, shiftR, xor )++-- Required for a temporary workaround for https://github.com/carlohamalainen/ghc-imported-from/issues/10++-- https://github.com/haskell/cabal/blob/master/cabal-install/Distribution/Client/Sandbox.hs#L129+sandboxBuildDir :: FilePath -> FilePath+sandboxBuildDir sandboxDir = "dist/dist-sandbox-" ++ showHex sandboxDirHash ""+  where+    sandboxDirHash = jenkins sandboxDir++    -- See http://en.wikipedia.org/wiki/Jenkins_hash_function+    jenkins :: String -> Word32+    jenkins str = loop_finish $ foldl' loop 0 str+      where+        loop :: Word32 -> Char -> Word32+        loop hash key_i' = hash'''+          where+            key_i   = toEnum . ord $ key_i'+            hash'   = hash + key_i+            hash''  = hash' + (shiftL hash' 10)+            hash''' = hash'' `xor` (shiftR hash'' 6)++        loop_finish :: Word32 -> Word32+        loop_finish hash = hash'''+          where+            hash'   = hash + (shiftL hash 3)+            hash''  = hash' `xor` (shiftR hash' 11)+            hash''' = hash'' + (shiftL hash'' 15)
Language/Haskell/GhcImportedFrom/UtilsFromGhcMod.hs view
@@ -25,6 +25,8 @@  module Language.Haskell.GhcImportedFrom.UtilsFromGhcMod where +import Language.Haskell.GhcImportedFrom.UtilsFromCabalInstall+ import Control.Applicative import Data.Generics hiding (typeOf) import GHC@@ -64,6 +66,7 @@ getGHCOptions ghcopts cradle cdir binfo = do     cabalCpp <- cabalCppOptions cdir     let cpps = map ("-optP" ++) $ cppOptions binfo ++ cabalCpp+     return $ ghcopts ++ pkgDb ++ exts ++ [lang] ++ libs ++ libDirs ++ cpps   where     pkgDb = cradlePackageDbOpts cradle@@ -74,13 +77,22 @@  -- ghc-mod/Language/Haskell/GhcMod/CabalApi.hs -- modification: return $ if ... instead of if .. return+-- Extra modification: add dist-sandbox-[hash] directory. cabalCppOptions :: FilePath -> IO [String] cabalCppOptions dir = do-    exist <- doesFileExist cabalMacro-    return $ if exist then ["-include", cabalMacro]-                      else []+    let sandboxSubDir = sandboxBuildDir $ dir </> ".cabal-sandbox"+        sandboxFullPath = dir </> sandboxSubDir++    opts1 <- makeOpt $ dir </> "dist/build/autogen/cabal_macros.h"+    opts2 <- makeOpt $ sandboxFullPath </> "build/autogen/cabal_macros.h"++    return $ opts1 ++ opts2   where-    cabalMacro = dir </> "dist/build/autogen/cabal_macros.h"+    makeOpt :: FilePath -> IO [String]+    makeOpt cabalMacroDotH = do+        exist <- doesFileExist cabalMacroDotH+        return $ if exist then ["-include", cabalMacroDotH]+                          else []  -- ghc-mod/Language/Haskell/GhcMod/CabalApi.hs getGHCId :: IO CompilerId@@ -131,7 +143,12 @@ includeDirectories :: FilePath -> FilePath -> [FilePath] -> [FilePath] includeDirectories cdir wdir dirs = uniqueAndSort (extdirs ++ [cdir,wdir])   where-    extdirs = map expand $ dirs ++ cabalBuildDirs+    sandboxSubDir = sandboxBuildDir $ wdir </> ".cabal-sandbox"+    sandboxFullPath = wdir </> sandboxSubDir++    extdirs = map expand $ dirs ++ cabalBuildDirs ++ [sandboxFullPath </> "build", sandboxFullPath </> "build/autogen"]:: [FilePath]++    expand :: FilePath -> FilePath     expand "."    = cdir     expand subdir = cdir </> subdir 
ghc-imported-from.cabal view
@@ -1,5 +1,5 @@ name:                ghc-imported-from-version:             0.1.0.3+version:             0.1.0.4 synopsis:            Find the Haddock documentation for a symbol. description:         Given a Haskell module and symbol, determine the URL to the Haddock documentation                      for that symbol.@@ -20,6 +20,7 @@ library     exposed-modules: Language.Haskell.GhcImportedFrom     other-modules:   Language.Haskell.GhcImportedFrom.UtilsFromGhcMod+                     Language.Haskell.GhcImportedFrom.UtilsFromCabalInstall                      Language.Haskell.GhcImportedFrom.Types      other-extensions:    CPP, Rank2Types@@ -62,6 +63,8 @@                , containers >= 0.5.0.0 && <= 0.5.0.0                , mtl                , transformers+               , hspec+   if impl(ghc < 7.7)       Build-Depends:  Cabal >= 1.10 && < 1.17   else