Skip to content

Commit

Permalink
updated for ghc 8.4.2; released source code as a library
Browse files Browse the repository at this point in the history
  • Loading branch information
hpacheco committed Sep 12, 2018
1 parent 89d5b0c commit a8f3a2d
Show file tree
Hide file tree
Showing 17 changed files with 572 additions and 463 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cabal-dev
cabal.sandbox.config
cabal.config
TAGS
*.DS_Store
75 changes: 0 additions & 75 deletions Parsing.hs

This file was deleted.

72 changes: 50 additions & 22 deletions SourceGraph.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: SourceGraph
Version: 0.7.0.7
Version: 0.7.0.8
Synopsis: Static code analysis using graph-theoretic techniques.
Description: {
Statically analyse Haskell source code using graph-theoretic
Expand Down Expand Up @@ -42,30 +42,58 @@ Build-Type: Simple
Extra-Source-Files: TODO
ChangeLog

Tested-With: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4,
GHC == 7.10.2, GHC == 7.11.*
Tested-With: GHC == 8.4.2

Source-Repository head
Type: git
Location: https://github.com/ivan-m/SourceGraph

Library
exposed-modules:
SourceGraph.Analyse.Colors
SourceGraph.Analyse.Everything
SourceGraph.Analyse.GraphRepr
SourceGraph.Analyse.Imports
SourceGraph.Analyse.Module
SourceGraph.Analyse.Utils
SourceGraph.Analyse.Visualise
SourceGraph.Parsing.ParseModule
SourceGraph.Parsing.State
SourceGraph.Parsing.Types
SourceGraph.Analyse
SourceGraph.Parsing
Hs-source-dirs: .
Other-Modules:
Paths_SourceGraph
Build-Depends: base == 4.*,
containers,
multiset,
filepath,
random,
directory,
mtl,
fgl == 5.6.*,
Graphalyze >= 0.15,
graphviz >= 2999.20 && < 2999.21,
Cabal == 2.2.*,
haskell-src-exts == 1.20.*

Executable SourceGraph {

Main-Is: Main.hs
Other-Modules: CabalInfo,
Parsing,
Parsing.ParseModule,
Parsing.State,
Parsing.Types,
Analyse,
Analyse.Utils,
Analyse.Colors,
Analyse.GraphRepr,
Analyse.Visualise,
Analyse.Module,
Analyse.Imports,
Analyse.Everything,
Main-Is: SourceGraph/Main.hs
Other-Modules: SourceGraph.CabalInfo,
SourceGraph.Parsing,
SourceGraph.Parsing.ParseModule,
SourceGraph.Parsing.State,
SourceGraph.Parsing.Types,
SourceGraph.Analyse,
SourceGraph.Analyse.Utils,
SourceGraph.Analyse.Colors,
SourceGraph.Analyse.GraphRepr,
SourceGraph.Analyse.Visualise,
SourceGraph.Analyse.Module,
SourceGraph.Analyse.Imports,
SourceGraph.Analyse.Everything,
Paths_SourceGraph
Ghc-Options: -Wall
Ghc-Prof-Options: -prof
Expand All @@ -77,9 +105,9 @@ Executable SourceGraph {
random,
directory,
mtl,
fgl == 5.5.*,
Graphalyze >= 0.14.1.0 && < 0.15,
graphviz >= 2999.15.0.0 && < 2999.19,
Cabal == 1.22.*,
haskell-src-exts == 1.16.*
fgl == 5.6.*,
Graphalyze >= 0.15,
graphviz >= 2999.20 && < 2999.21,
Cabal == 2.2.*,
haskell-src-exts == 1.20.*
}
12 changes: 6 additions & 6 deletions Analyse.hs → SourceGraph/Analyse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Analyse Haskell software
-}
module Analyse(analyse, sgLegend) where
module SourceGraph.Analyse(analyse, sgLegend) where

import Analyse.Module
import Analyse.Imports
import Analyse.Everything
import Analyse.Colors
import Parsing.Types
import SourceGraph.Analyse.Module
import SourceGraph.Analyse.Imports
import SourceGraph.Analyse.Everything
import SourceGraph.Analyse.Colors
import SourceGraph.Parsing.Types

import Data.Graph.Analysis hiding (Bold)
import qualified Data.Graph.Analysis.Reporting as R (DocInline(Bold))
Expand Down
2 changes: 1 addition & 1 deletion Analyse/Colors.hs → SourceGraph/Analyse/Colors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Utility functions and types for analysis.
-}
module Analyse.Colors where
module SourceGraph.Analyse.Colors where

import Data.GraphViz.Attributes

Expand Down
10 changes: 5 additions & 5 deletions Analyse/Everything.hs → SourceGraph/Analyse/Everything.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Analysis of the entire overall piece of software.
-}
module Analyse.Everything(analyseEverything) where
module SourceGraph.Analyse.Everything(analyseEverything) where

import Parsing.Types
import Analyse.Utils
import Analyse.GraphRepr
import Analyse.Visualise
import SourceGraph.Parsing.Types
import SourceGraph.Analyse.Utils
import SourceGraph.Analyse.GraphRepr
import SourceGraph.Analyse.Visualise

import Data.Graph.Analysis

Expand Down
8 changes: 4 additions & 4 deletions Analyse/GraphRepr.hs → SourceGraph/Analyse/GraphRepr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Interacting with GraphData from Graphalyze.
-}
module Analyse.GraphRepr
module SourceGraph.Analyse.GraphRepr
( -- * General stuff
GData(..)
, mapData
Expand Down Expand Up @@ -62,9 +62,9 @@ module Analyse.GraphRepr
, ModGraph
) where

import Analyse.Colors
import Analyse.Utils
import Parsing.Types
import SourceGraph.Analyse.Colors
import SourceGraph.Analyse.Utils
import SourceGraph.Parsing.Types

import Data.Graph.Analysis
import Data.Graph.Inductive
Expand Down
10 changes: 5 additions & 5 deletions Analyse/Imports.hs → SourceGraph/Analyse/Imports.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Analysis of Haskell module importing.
-}
module Analyse.Imports (analyseImports) where
module SourceGraph.Analyse.Imports (analyseImports) where

import Parsing.Types
import Analyse.Utils
import Analyse.GraphRepr
import Analyse.Visualise
import SourceGraph.Parsing.Types
import SourceGraph.Analyse.Utils
import SourceGraph.Analyse.GraphRepr
import SourceGraph.Analyse.Visualise

import Data.Graph.Analysis

Expand Down
10 changes: 5 additions & 5 deletions Analyse/Module.hs → SourceGraph/Analyse/Module.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Analysis of Haskell modules.
-}
module Analyse.Module(analyseModules) where
module SourceGraph.Analyse.Module(analyseModules) where

import Parsing.Types
import Analyse.Utils
import Analyse.GraphRepr
import Analyse.Visualise
import SourceGraph.Parsing.Types
import SourceGraph.Analyse.Utils
import SourceGraph.Analyse.GraphRepr
import SourceGraph.Analyse.Visualise

import Data.Graph.Analysis

Expand Down
2 changes: 1 addition & 1 deletion Analyse/Utils.hs → SourceGraph/Analyse/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Utility functions and types for analysis.
-}
module Analyse.Utils where
module SourceGraph.Analyse.Utils where

import Data.Graph.Analysis hiding (Bold)

Expand Down
10 changes: 5 additions & 5 deletions Analyse/Visualise.hs → SourceGraph/Analyse/Visualise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Utility functions and types for analysis.
-}
module Analyse.Visualise where
module SourceGraph.Analyse.Visualise where

import Analyse.Colors
import Analyse.GraphRepr
import Analyse.Utils
import Parsing.Types
import SourceGraph.Analyse.Colors
import SourceGraph.Analyse.GraphRepr
import SourceGraph.Analyse.Utils
import SourceGraph.Parsing.Types

import Data.Graph.Analysis hiding (Bold)
import Data.GraphViz
Expand Down
30 changes: 26 additions & 4 deletions CabalInfo.hs → SourceGraph/CabalInfo.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{-# LANGUAGE CPP #-}
#if !defined(MIN_VERSION_Cabal)
# define MIN_VERSION_Cabal(a,b,c) 0
#endif

{-
Copyright (C) 2009 Ivan Lazar Miljenovic <[email protected]>
Expand Down Expand Up @@ -27,14 +32,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Used to parse and obtain information from the provided Cabal file.
-}
module CabalInfo(parseCabal) where
module SourceGraph.CabalInfo(parseCabal) where

import Distribution.Compiler (CompilerInfo)
import Distribution.ModuleName (toFilePath)
import Distribution.Package
import Distribution.PackageDescription hiding (author)
import Distribution.PackageDescription.Configuration
#if MIN_VERSION_Cabal(2,0,0)
import Distribution.PackageDescription.Parsec
#else
import Distribution.PackageDescription.Parse
#endif
import Distribution.Simple.Compiler (compilerInfo)
import Distribution.Simple.GHC (configure)
import Distribution.Simple.Program (defaultProgramConfiguration)
Expand All @@ -49,6 +58,19 @@ import System.FilePath (dropExtension)

-- -----------------------------------------------------------------------------

emptyFlagAssignment :: FlagAssignment
#if MIN_VERSION_Cabal(2,0,0)
emptyFlagAssignment = mkFlagAssignment []
#else
emptyFlagAssignment = []
#endif

#if MIN_VERSION_Cabal(2,0,0)
readDescription = readGenericPackageDescription
#else
readDescription = readPackageDescription
#endif

ghcID :: IO CompilerInfo
ghcID = liftM (compilerInfo . getCompiler)
$ configure silent Nothing Nothing defaultProgramConfiguration
Expand All @@ -61,10 +83,10 @@ parseCabal fp = do cID <- ghcID
where
-- Need to specify the Exception type
getDesc :: FilePath -> IO (Either SomeException GenericPackageDescription)
getDesc = try . readPackageDescription silent
getDesc = try . readDescription silent
parseDesc cID = fmap parse . compactEithers . fmap (unGeneric cID)
unGeneric cID = fmap fst
. finalizePackageDescription [] -- flags, use later
. finalizePackageDescription emptyFlagAssignment -- flags, use later
(const True) -- ignore
-- deps
buildPlatform
Expand All @@ -73,7 +95,7 @@ parseCabal fp = do cID <- ghcID
parse pd = (nm, exps)
where
nm = pName . pkgName $ package pd
pName (PackageName nm') = nm'
pName nm' = unPackageName nm'
exes = filter (buildable . buildInfo) $ executables pd
lib = library pd
moduleNames = map toFilePath
Expand Down
Loading

0 comments on commit a8f3a2d

Please sign in to comment.