buildwrapper 0.8.2 → 0.8.3
raw patch · 4 files changed
+47/−34 lines, 4 files
Files
- buildwrapper.cabal +1/−1
- src/Language/Haskell/BuildWrapper/API.hs +30/−26
- src/Language/Haskell/BuildWrapper/Cabal.hs +1/−2
- test/Language/Haskell/BuildWrapper/CMDTests.hs +15/−5
buildwrapper.cabal view
@@ -1,5 +1,5 @@ name: buildwrapper-version: 0.8.2+version: 0.8.3 cabal-version: >= 1.8 build-type: Simple license: BSD3
src/Language/Haskell/BuildWrapper/API.hs view
@@ -325,32 +325,36 @@ getBuildFlags fp mccn=do tgt<-getTargetPath fp src<-getCabalFile Source - modSrc<-liftIO $ getModificationTime src - mbf<-liftIO $ readBuildFlagsInfo tgt modSrc - case filterBuildFlags mbf of - Just bf-> return bf - Nothing -> do - (mcbi,bwns)<-getBuildInfo fp mccn - --liftIO $ print mcbi - ret<-case mcbi of - Just cbi->do - opts2<-fileGhcOptions $ snd cbi - -- liftIO $ Prelude.print fp - -- liftIO $ Prelude.print $ cbiModulePaths $ snd cbi - -- liftIO $ Prelude.print opts2 - let - fullFp=takeDirectory src </> fp - modName=listToMaybe $ mapMaybe fst (filter (\ (_, f) -> f == fullFp) $ cbiModulePaths $ snd cbi) - -- (modName,_)=cabalExtensions $ snd cbi - cppo=fileCppOptions (snd cbi) ++ unlitF - modS=fmap moduleToString modName - -- liftIO $ Prelude.print opts - -- ghcOptions is sufficient, contains extensions and such - -- opts ++ - return (BuildFlags opts2 cppo modS (Just $ cabalComponentName $ cbiComponent $ snd cbi),bwns) - Nothing -> return (BuildFlags [] unlitF Nothing Nothing,[]) - liftIO $ storeBuildFlagsInfo tgt ret - return ret + ex <- liftIO $ doesFileExist src + if ex + then do + modSrc<-liftIO $ getModificationTime src + mbf<-liftIO $ readBuildFlagsInfo tgt modSrc + case filterBuildFlags mbf of + Just bf-> return bf + Nothing -> do + (mcbi,bwns)<-getBuildInfo fp mccn + --liftIO $ print mcbi + ret<-case mcbi of + Just cbi->do + opts2<-fileGhcOptions $ snd cbi + -- liftIO $ Prelude.print fp + -- liftIO $ Prelude.print $ cbiModulePaths $ snd cbi + -- liftIO $ Prelude.print opts2 + let + fullFp=takeDirectory src </> fp + modName=listToMaybe $ mapMaybe fst (filter (\ (_, f) -> f == fullFp) $ cbiModulePaths $ snd cbi) + -- (modName,_)=cabalExtensions $ snd cbi + cppo=fileCppOptions (snd cbi) ++ unlitF + modS=fmap moduleToString modName + -- liftIO $ Prelude.print opts + -- ghcOptions is sufficient, contains extensions and such + -- opts ++ + return (BuildFlags opts2 cppo modS (Just $ cabalComponentName $ cbiComponent $ snd cbi),bwns) + Nothing -> return (BuildFlags [] unlitF Nothing Nothing,[]) + liftIO $ storeBuildFlagsInfo tgt ret + return ret + else return (BuildFlags [] unlitF Nothing Nothing,[]) where unlitF=let lit=".lhs" == takeExtension fp
src/Language/Haskell/BuildWrapper/Cabal.hs view
@@ -511,8 +511,7 @@ ,"let pkg=localPkgDescr lbi" ,"r<-newIORef DM.empty" ,"let fmp=DM."++ show fmp - ,"(compiler,_ ,_)<-configure normal Nothing Nothing defaultProgramDb" - ,withStr++" pkg lbi (\\c clbi->do" + ,withStr++" pkg lbi (\\c clbi->do" ," let b=componentBuildInfo c" ," let n=foldComponent (const \"\") exeName testName benchmarkName c" ," let fp=fromJust $ DM.lookup n fmp"
test/Language/Haskell/BuildWrapper/CMDTests.hs view
@@ -51,6 +51,7 @@ build1c :: a -> FilePath -> FilePath -> String -> IO (OpResult (Maybe [NameDef])) getBuildFlags :: a -> FilePath -> FilePath -> IO (OpResult BuildFlags) getOutline :: a -> FilePath -> FilePath -> IO (OpResult OutlineResult)+ getOutlineNC :: a -> FilePath -> FilePath -> IO (OpResult OutlineResult) getTokenTypes :: a -> FilePath -> FilePath -> IO (OpResult [TokenDef]) getOccurrences :: a -> FilePath -> FilePath -> String -> IO (OpResult [TokenDef]) getThingAtPoint :: a -> FilePath -> FilePath -> Int -> Int -> IO (OpResult (Maybe ThingAtPoint))@@ -82,6 +83,7 @@ build1c (CMDAPI c _) r fp ccn= runAPI c r "build1" ["--file="++fp,"--component="++ccn] getBuildFlags (CMDAPI c _) r fp= runAPI c r "getbuildflags" ["--file="++fp] getOutline (CMDAPI c _) r fp= runAPI c r "outline" ["--file="++fp]+ getOutlineNC (CMDAPI c _) r fp= runAPI' False c r "outline" ["--file="++fp] getTokenTypes (CMDAPI c _) r fp= runAPI c r "tokentypes" ["--file="++fp] getOccurrences (CMDAPI c _) r fp s= runAPI c r "occurrences" ["--file="++fp,"--token="++s] getThingAtPoint (CMDAPI c _) r fp l cl= removeLayoutTAP <$> runAPI c r "thingatpoint" ["--file="++fp,"--line="++ show l,"--column="++ show cl]@@ -506,8 +508,13 @@ test_Outline :: Assertion-test_Outline = do- let api=cabalAPI+test_Outline = doTestOutline cabalAPI getOutline++test_OutlineNoCabal :: Assertion+test_OutlineNoCabal = doTestOutline cabalAPI getOutlineNC++doTestOutline :: APIFacade a => a -> (a -> FilePath -> FilePath -> IO (OpResult OutlineResult)) -> Assertion+doTestOutline api f = do root<-createTestProject synchronize api root False let rel="src"</>"A.hs"@@ -556,7 +563,7 @@ " }" ] (_,nsErrors3f)<-getBuildFlags api root rel assertBool (null nsErrors3f) - (OutlineResult defs es is,nsErrors1)<-getOutline api root rel+ (OutlineResult defs es is,nsErrors1)<-f api root rel assertBool (null nsErrors1) let expected=[ mkOutlineDefWithChildren "XList" [Data,Family] (InFileSpan (InFileLoc 8 1)(InFileLoc 8 20)) []@@ -2062,9 +2069,12 @@ runAPI:: (FromJSON a,Show a) => FilePath -> FilePath -> String -> [String] -> IO a-runAPI cabal root command args= do+runAPI= runAPI' True++runAPI':: (FromJSON a,Show a) => Bool -> FilePath -> FilePath -> String -> [String] -> IO a+runAPI' withCabal cabal root command args= do cd<-getCurrentDirectory- let fullargs=[command,"--tempfolder=.dist-buildwrapper","--cabalpath="++cabal,"--cabalfile="++ testCabalFile root] ++ args+ let fullargs=[command,"--tempfolder=.dist-buildwrapper","--cabalpath=" ++ cabal] ++ (if withCabal then ["--cabalfile="++ testCabalFile root] else []) ++ args exePath<-filterM doesFileExist [".dist-buildwrapper/dist/build/buildwrapper/buildwrapper" <.> exeExtension,"dist/build/buildwrapper/buildwrapper" <.> exeExtension] assertBool (0<length exePath) setCurrentDirectory root