packages feed

buildwrapper 0.8.7 → 0.8.8

raw patch · 4 files changed

+59/−15 lines, 4 filesdep ~haskell-src-exts

Dependency ranges changed: haskell-src-exts

Files

buildwrapper.cabal view
@@ -1,5 +1,5 @@ name:           buildwrapper-version:        0.8.7+version:        0.8.8 cabal-version:  >= 1.8 build-type:     Simple license:        BSD3@@ -34,7 +34,7 @@                    text,                    containers,                    vector >= 0.8,-                   haskell-src-exts >= 1.12 && <1.16,+                   haskell-src-exts >= 1.12 && <1.17,                    cpphs,                    old-time,                    aeson >=0.7 && <0.8,@@ -74,7 +74,7 @@                    mtl,                    ghc,                    cpphs,-                   haskell-src-exts >= 1.12 && <1.16,+                   haskell-src-exts,                    old-time,                    ghc-paths,                    vector >= 0.8,@@ -88,9 +88,9 @@                    transformers   ghc-options:     -Wall -fno-warn-unused-do-bind -optl -s   -- see https://ghc.haskell.org/trac/ghc/ticket/8376-  --  if impl(ghc >= 7.8) && impl(ghc < 7.8.3)-  --    ghc-options: -  --                   -dynamic+--  if impl(ghc >= 7.8) && impl(ghc < 7.8.4)+--    ghc-options: +--                   -dynamic   other-modules:   Language.Haskell.BuildWrapper.CMD   if impl(ghc >= 7.6)     build-depends: 
src/Language/Haskell/BuildWrapper/Cabal.hs view
@@ -147,16 +147,18 @@                 uf<-gets cabalFlags
                 logC<-gets logCabalArgs
                 copts<-gets cabalOpts
+                let sb = (takeDirectory cf) </> "cabal.sandbox.config"
+                hasSb <- liftIO $ doesFileExist sb
                 let args=[
                         "configure",
                         "--verbose=" ++ show (fromEnum v),
-                        "--user",
                         "--enable-tests",
                         "--enable-benchmarks",
                         "--builddir="++dist_dir
                         ] 
                         ++ (if null uf then [] else ["--flags="++uf])
                         ++ copts
+                        ++ if hasSb then [] else ["--user"]
                 liftIO $ do
                         when logC (putStrLn $ showCommandForUser cp args)
                         cd<-getCurrentDirectory
@@ -168,10 +170,11 @@                                 ExitSuccess  -> if any isBWNoteError msgs 
                                         then return (Nothing,msgs)
                                         else do 
+                                                let mghcp=fmap (tail . dropWhile (/= '=')) $ listToMaybe $ filter ("--with-ghc=" `isPrefixOf`) copts
                                                 --lbi<-DSC.getPersistBuildConfig dist_dir
                                                 let setup_config = DSC.localBuildInfoFile dist_dir
                                                 tgs <- DCD.runQuery (DCD.on DCD.localPkgDesc DCD.targets) setup_config
-                                                tgs'<- setOptions dist_dir tgs
+                                                tgs'<- setOptions dist_dir mghcp tgs
                                                 let tgsF=dist_dir </> targetFile
                                                 Prelude.writeFile tgsF $ show tgs'
                                                 return (Just tgs',msgs)
@@ -475,11 +478,15 @@                 return $ filter (\cbi->cabalComponentName (cbiComponent cbi) == ccn) fps
  
 -- | set the GHC options on targets
-setOptions :: FilePath -> [DCD.Target] -> IO [DCD.Target]
-setOptions dist_dir tgs=do
+setOptions 
+  :: FilePath -- ^ dist directory
+  -> Maybe FilePath -- ^ path to GHC if explicitely specified
+  -> [DCD.Target]  -- ^ targets to set options onto
+  -> IO [DCD.Target]
+setOptions dist_dir mghcp tgs=do
   let setup_config = DSC.localBuildInfoFile dist_dir
   cv<-DCD.getCabalVersion setup_config
-  let optStr1 | cv>=Version [1,19,0] [] ="(compiler,_ ,_)<-configure normal Nothing Nothing defaultProgramDb"
+  let optStr1 | cv>=Version [1,19,0] [] ="(compiler,_ ,_)<-configure normal ("++ (show mghcp) ++ ") Nothing defaultProgramDb"
               | otherwise =""
   let optStr | cv>=Version [1,19,0] [] ="renderGhcOptions compiler $ componentGhcOptions V.silent lbi{withOptimization=NoOptimisation} b clbi fp"
              | cv>=Version [1,15,0] [] ="renderGhcOptions ((fst $ head $ readP_to_S  parseVersion  \""++VERSION_ghc++"\") :: Version) $ componentGhcOptions V.silent lbi{withOptimization=NoOptimisation} b clbi fp"
src/Language/Haskell/BuildWrapper/Src.hs view
@@ -70,13 +70,25 @@                         n=matchDecl $ head matches
                         (ty,l2)=addTypeInfo n l
                         in [OutlineDef n [Function] (makeSpan l2) [] ty Nothing Nothing]
+#if MIN_VERSION_haskell_src_exts(1,16,0)
+                declOutline (PatBind l (PVar _ n) _ _)=let
+#else       
                 declOutline (PatBind l (PVar _ n) _ _ _)=let
+#endif
                         nd=nameDecl n
                         (ty,l2)=addTypeInfo nd l
                         in [OutlineDef nd [Function] (makeSpan l2)  [] ty Nothing Nothing]
+#if MIN_VERSION_haskell_src_exts(1,16,0)
+                declOutline (InstDecl l _ h idecls)=[mkOutlineDefWithChildren (iheadRule h) [Instance] (makeSpan l) (maybe [] (concatMap instDecl) idecls)]
+#else                        
                 declOutline (InstDecl l _ h idecls)=[mkOutlineDefWithChildren (iheadDecl h) [Instance] (makeSpan l) (maybe [] (concatMap instDecl) idecls)]
+#endif
                 declOutline (SpliceDecl l e)=[mkOutlineDef (spliceDecl e) [Splice] (makeSpan l)]
                 declOutline _ = []
+#if MIN_VERSION_haskell_src_exts(1,16,0)
+                iheadRule (IRule _ _ _ h) =iheadDecl h
+                iheadRule (IParen _ r)=iheadRule r
+#endif                
                 qualConDeclOutline :: QualConDecl SrcSpanInfo-> OutlineDef
                 qualConDeclOutline (QualConDecl l _ _ con)=let
                         (n,defs)=conDecl con
@@ -85,10 +97,16 @@                 declOutlineInClass (TypeSig l ns _)=map (\n->mkOutlineDef (nameDecl n) [Function] (makeSpan l)) ns
                 declOutlineInClass o=declOutline o
                 headDecl :: DeclHead  a -> T.Text
+#if MIN_VERSION_haskell_src_exts(1,16,0)       
+                headDecl (DHead _ n )=nameDecl n     
+                headDecl (DHInfix _ _ n)=nameDecl n     
+                headDecl (DHApp _ h _)=headDecl h     
+#else
                 headDecl (DHead _ n  _)=nameDecl n
                 headDecl (DHInfix _ _ n _)=nameDecl n
+#endif       
                 headDecl (DHParen _ h)=headDecl h
-                typeDecl :: Type a -> T.Text
+                typeDecl :: Type SrcSpanInfo -> T.Text
 --                typeDecl (TyForall _ mb mc t)=typeDecl t
 --                typeDecl (TyVar _ n )=nameDecl n
 --                typeDecl (TyCon _ qn )=qnameDecl qn
@@ -100,9 +118,16 @@                 matchDecl :: Match a -> T.Text
                 matchDecl (Match _ n _ _ _)=nameDecl n     
                 matchDecl (InfixMatch _ _ n _ _ _)=nameDecl n    
-                iheadDecl :: InstHead a -> T.Text
+                iheadDecl :: InstHead SrcSpanInfo -> T.Text
+#if MIN_VERSION_haskell_src_exts(1,16,0) 
+                iheadDecl (IHCon _ qn)= qnameDecl qn
+                iheadDecl (IHApp _ i t)= T.concat [iheadDecl i, " ",typeDecl t]
+                iheadDecl (IHInfix _ t1 qn)= T.concat  [typeDecl t1, " ", qnameDecl qn]
+#else                
                 iheadDecl (IHead _ qn ts)= T.concat  [qnameDecl qn, " ", T.intercalate " " (map typeDecl ts)]
                 iheadDecl (IHInfix _ t1 qn t2)= T.concat  [typeDecl t1, " ", qnameDecl qn, " ", typeDecl t2]
+#endif
+
                 iheadDecl (IHParen _ i)=iheadDecl i
                 conDecl :: ConDecl SrcSpanInfo -> (T.Text,[OutlineDef])
                 conDecl (ConDecl _ n _)=(nameDecl n,[])
@@ -203,7 +228,11 @@                 headExp (Just (ModuleHead  _ _ _ (Just (ExportSpecList _ exps))))=map expExp exps
                 headExp _ = [] 
                 expExp :: ExportSpec SrcSpanInfo -> ExportDef
+#if MIN_VERSION_haskell_src_exts(1,16,0)  
+                expExp (EVar l _ qn) = ExportDef (qnameDecl qn) IEVar (makeSpan l) []
+#else                
                 expExp (EVar l qn) = ExportDef (qnameDecl qn) IEVar (makeSpan l) []
+#endif
                 expExp (EAbs l qn) = ExportDef (qnameDecl qn) IEAbs (makeSpan l) []
                 expExp (EThingAll l qn) = ExportDef (qnameDecl qn) IEThingAll (makeSpan l) []
                 expExp (EThingWith l qn cns) = ExportDef (qnameDecl qn) IEThingWith (makeSpan l) (map cnameDecl cns)
@@ -211,7 +240,11 @@                 impDefs :: [ImportDecl SrcSpanInfo] -> [ImportDef]
                 impDefs=map impDef
                 impDef :: ImportDecl SrcSpanInfo -> ImportDef
+#if MIN_VERSION_haskell_src_exts(1,16,0)  
+                impDef (ImportDecl l m qual _ _ pkg al specs)=ImportDef (mnnameDecl m) (fmap T.pack pkg) (makeSpan l) qual (hide specs) (alias al) (children specs)
+#else               
                 impDef (ImportDecl l m qual _ pkg al specs)=ImportDef (mnnameDecl m) (fmap T.pack pkg) (makeSpan l) qual (hide specs) (alias al) (children specs)
+#endif            
                 hide :: Maybe (ImportSpecList a)-> Bool
                 hide  (Just (ImportSpecList _ b _))=b
                 hide _=False
@@ -222,7 +255,11 @@                 children (Just (ImportSpecList _ _ ss))=Just $ map child ss
                 children Nothing = Nothing
                 child :: ImportSpec SrcSpanInfo -> ImportSpecDef
+#if MIN_VERSION_haskell_src_exts(1,16,0) 
+                child (IVar l _ n)=ImportSpecDef (nameDecl n) IEVar (makeSpan l) []
+#else                
                 child (IVar l n)=ImportSpecDef (nameDecl n) IEVar (makeSpan l) []
+#endif
                 child (IAbs l n)=ImportSpecDef (nameDecl n) IEAbs (makeSpan l) []
                 child (IThingAll l n) = ImportSpecDef (nameDecl n) IEThingAll (makeSpan l) []
                 child (IThingWith l n cns) = ImportSpecDef (nameDecl n) IEThingWith (makeSpan l) (map cnameDecl cns)
test/Language/Haskell/BuildWrapper/CMDTests.hs view
@@ -581,7 +581,7 @@                 ,OutlineDef "testfunc1" [Function] (InFileSpan (InFileLoc 17 1)(InFileLoc 18 25)) [] (Just "[Char]") Nothing Nothing                 ,OutlineDef "testfunc1bis" [Function] (InFileSpan (InFileLoc 20 1)(InFileLoc 22 25)) [] (Just "String -> [Char]") Nothing Nothing                       ,OutlineDef "testMethod" [Function] (InFileSpan (InFileLoc 24 1)(InFileLoc 27 13))  [] (Just "forall a . (Num a) => a -> a -> a") Nothing Nothing -                ,mkOutlineDefWithChildren "ToString" [Class] (InFileSpan (InFileLoc 29 1)(InFileLoc 32 0))  [+                ,mkOutlineDefWithChildren "ToString" [Class] (InFileSpan (InFileLoc 29 1)(InFileLoc 30 28))  [                         mkOutlineDef "toString" [Function] (InFileSpan (InFileLoc 30 5)(InFileLoc 30 28))                         ]                           ,mkOutlineDefWithChildren "ToString String" [Instance] (InFileSpan (InFileLoc 32 1)(InFileLoc 35 0))  [@@ -654,7 +654,7 @@                 OutlineDef "testfunc1" [Function] (InFileSpan (InFileLoc 8 1)(InFileLoc 9 25)) [] (Just "[Char]") Nothing Nothing                 ,OutlineDef "testfunc1bis" [Function] (InFileSpan (InFileLoc 12 1)(InFileLoc 14 25)) [] (Just "String -> [Char]") (Just "testFunc1bis haddock")  (Just 11)                            ,OutlineDef "testMethod" [Function] (InFileSpan (InFileLoc 18 1)(InFileLoc 21 13))  [] (Just "forall a . (Num a) => a -> a -> a")   (Just "testMethod\n haddock") (Just 16)     -                ,mkOutlineDefWithChildren "ToString" [Class] (InFileSpan (InFileLoc 23 1)(InFileLoc 27 0))  [+                ,mkOutlineDefWithChildren "ToString" [Class] (InFileSpan (InFileLoc 23 1)(InFileLoc 24 28))  [                         OutlineDef "toString" [Function] (InFileSpan (InFileLoc 24 5)(InFileLoc 24 28)) [] Nothing (Just "toString comment") Nothing                         ]                           ,OutlineDef "Str" [Type] (InFileSpan (InFileLoc 27 1)(InFileLoc 27 16)) [] (Just "String") (Just "Str haddock") (Just 26)