aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2018-01-13 15:58:35 +0100
committerDaniel Gröber <dxld@darkboxed.org>2018-01-18 14:10:26 +0100
commita543f44bd9541d13d85d9284332705e846c6cb20 (patch)
treebd5cbd7c24a4409b47ecbddfbf7081737a38c17a
parentdbc6285489cb5171c611ebfd214e5c72d61a9dc8 (diff)
Remove package license query
-rw-r--r--cabal-helper.cabal1
-rw-r--r--lib/Distribution/Helper.hs8
-rw-r--r--src/CabalHelper/Compiletime/Data.hs1
-rw-r--r--src/CabalHelper/Runtime/Licenses.hs125
-rw-r--r--src/CabalHelper/Runtime/Main.hs13
5 files changed, 2 insertions, 146 deletions
diff --git a/cabal-helper.cabal b/cabal-helper.cabal
index f62744f..0966dbe 100644
--- a/cabal-helper.cabal
+++ b/cabal-helper.cabal
@@ -268,7 +268,6 @@ executable cabal-helper-main
main-is: CabalHelper/Runtime/Main.hs
hs-source-dirs: src
other-modules:
- CabalHelper.Runtime.Licenses
CabalHelper.Shared.Common
CabalHelper.Shared.InterfaceTypes
CabalHelper.Shared.Sandbox
diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs
index 0d9ab38..7dbfb2f 100644
--- a/lib/Distribution/Helper.hs
+++ b/lib/Distribution/Helper.hs
@@ -36,7 +36,6 @@ module Distribution.Helper (
, packageId
, packageDbStack
, packageFlags
- , packageLicenses
, compilerVersion
, ghcMergedPkgOptions
@@ -194,7 +193,6 @@ mkQueryEnv projdir distdir = QueryEnv {
data SomeLocalBuildInfo = SomeLocalBuildInfo {
slbiPackageDbStack :: [ChPkgDb],
slbiPackageFlags :: [(String, Bool)],
- slbiPkgLicenses :: [(String, [(String, Version)])],
slbiCompilerVersion :: (String, Version),
slbiGhcMergedPkgOptions :: [String],
@@ -270,9 +268,6 @@ packageDbStack :: MonadIO m => Query m [ChPkgDb]
-- | Like @ghcPkgOptions@ but for the whole package not just one component
ghcMergedPkgOptions :: MonadIO m => Query m [String]
--- | Get the licenses of the packages the current project is linking against.
-packageLicenses :: MonadIO m => Query m [(String, [(String, Version)])]
-
-- | Flag definitions from cabal file
packageFlags :: MonadIO m => Query m [(String, Bool)]
@@ -321,7 +316,6 @@ ghcLangOptions :: MonadIO m => ComponentQuery m [String]
packageId = Query $ getPackageId
packageDbStack = Query $ slbiPackageDbStack `liftM` getSlbi
packageFlags = Query $ slbiPackageFlags `liftM` getSlbi
-packageLicenses = Query $ slbiPkgLicenses `liftM` getSlbi
compilerVersion = Query $ slbiCompilerVersion `liftM` getSlbi
ghcMergedPkgOptions = Query $ slbiGhcMergedPkgOptions `liftM` getSlbi
configFlags = Query $ slbiConfigFlags `liftM` getSlbi
@@ -390,7 +384,6 @@ getSomeConfigState = ask >>= \QueryEnv {..} -> do
res <- readHelper
[ "package-db-stack"
, "flags"
- , "licenses"
, "compiler-version"
, "ghc-merged-pkg-options"
@@ -409,7 +402,6 @@ getSomeConfigState = ask >>= \QueryEnv {..} -> do
]
let [ Just (ChResponsePkgDbs slbiPackageDbStack),
Just (ChResponseFlags slbiPackageFlags),
- Just (ChResponseLicenses slbiPkgLicenses),
Just (ChResponseVersion comp compVer),
Just (ChResponseList slbiGhcMergedPkgOptions),
diff --git a/src/CabalHelper/Compiletime/Data.hs b/src/CabalHelper/Compiletime/Data.hs
index 4e512db..818f626 100644
--- a/src/CabalHelper/Compiletime/Data.hs
+++ b/src/CabalHelper/Compiletime/Data.hs
@@ -74,7 +74,6 @@ createHelperSources dir = do
sourceFiles :: [(FilePath, String)]
sourceFiles =
[ ("Runtime/Main.hs", $(LitE . StringL <$> runIO (UTF8.toString <$> BS.readFile "src/CabalHelper/Runtime/Main.hs")))
- , ("Runtime/Licenses.hs", $(LitE . StringL <$> runIO (UTF8.toString <$> BS.readFile "src/CabalHelper/Runtime/Licenses.hs")))
, ("Shared/Common.hs", $(LitE . StringL <$> runIO (UTF8.toString <$> BS.readFile "src/CabalHelper/Shared/Common.hs")))
, ("Shared/Sandbox.hs", $(LitE . StringL <$> runIO (UTF8.toString <$> BS.readFile "src/CabalHelper/Shared/Sandbox.hs")))
, ("Shared/InterfaceTypes.hs", $(LitE . StringL <$> runIO (UTF8.toString <$> BS.readFile "src/CabalHelper/Shared/InterfaceTypes.hs")))
diff --git a/src/CabalHelper/Runtime/Licenses.hs b/src/CabalHelper/Runtime/Licenses.hs
deleted file mode 100644
index a1794ea..0000000
--- a/src/CabalHelper/Runtime/Licenses.hs
+++ /dev/null
@@ -1,125 +0,0 @@
-{-# LANGUAGE CPP #-}
-
-#ifdef MIN_VERSION_Cabal
-#undef CH_MIN_VERSION_Cabal
-#define CH_MIN_VERSION_Cabal MIN_VERSION_Cabal
-#endif
-
-module CabalHelper.Runtime.Licenses (
- displayDependencyLicenseList
- , groupByLicense
- , getDependencyInstalledPackageInfos
- ) where
-
--- Copyright (c) 2014, Jasper Van der Jeugt <m@jaspervdj.be>
-
---------------------------------------------------------------------------------
-import Control.Arrow ((***), (&&&))
-import Control.Monad (forM_, unless)
-import Data.List (foldl', sort)
-import Data.Maybe (catMaybes)
-import Data.Set (Set)
-import qualified Data.Set as Set
-import System.Directory (getDirectoryContents)
-import System.Exit (exitFailure)
-import System.FilePath (takeExtension)
-import System.IO (hPutStrLn, stderr)
-
-import Distribution.InstalledPackageInfo
-import Distribution.License
-import Distribution.Package
-import Distribution.Simple.Configure
-import Distribution.Simple.LocalBuildInfo
-import Distribution.Simple.PackageIndex
-import Distribution.Text
-import Distribution.ModuleName
-import Distribution.Version (Version)
---------------------------------------------------------------------------------
-
-
-
-#if CH_MIN_VERSION_Cabal(1,23,0)
--- CPP > 1.22
-type CPackageIndex a = PackageIndex (InstalledPackageInfo)
-#elif CH_MIN_VERSION_Cabal(1,22,0)
--- CPP >= 1.22
-type CPackageIndex a = PackageIndex (InstalledPackageInfo_ a)
-#else
-type CPackageIndex a = PackageIndex
-#endif
-
-#if CH_MIN_VERSION_Cabal(1,23,0)
--- CPP >= 1.23
-type CInstalledPackageId = UnitId
-lookupInstalledPackageId' :: PackageIndex a -> UnitId -> Maybe a
-lookupInstalledPackageId' = lookupUnitId
-#else
-type CInstalledPackageId = InstalledPackageId
-lookupInstalledPackageId' = lookupInstalledPackageId
-#endif
-
-findTransitiveDependencies
- :: CPackageIndex Distribution.ModuleName.ModuleName
- -> Set CInstalledPackageId
- -> Set CInstalledPackageId
-findTransitiveDependencies pkgIdx set0 = go Set.empty (Set.toList set0)
- where
- go set [] = set
- go set (q : queue)
- | q `Set.member` set = go set queue
- | otherwise =
- case lookupInstalledPackageId' pkgIdx q of
- Nothing ->
- -- Not found can mean that the package still needs to be
- -- installed (e.g. a component of the target cabal package).
- -- We can ignore those.
- go set queue
- Just ipi ->
- go (Set.insert q set) (Distribution.InstalledPackageInfo.depends ipi ++ queue)
-
-
---------------------------------------------------------------------------------
-getDependencyInstalledPackageIds
- :: LocalBuildInfo -> Set CInstalledPackageId
-getDependencyInstalledPackageIds lbi =
- findTransitiveDependencies (installedPkgs lbi) $
- Set.fromList $ map fst $ externalPackageDeps lbi
-
---------------------------------------------------------------------------------
-getDependencyInstalledPackageInfos
- :: LocalBuildInfo -> [InstalledPackageInfo]
-getDependencyInstalledPackageInfos lbi = catMaybes $
- map (lookupInstalledPackageId' pkgIdx) $
- Set.toList (getDependencyInstalledPackageIds lbi)
- where
- pkgIdx = installedPkgs lbi
-
-
---------------------------------------------------------------------------------
-groupByLicense
- :: [InstalledPackageInfo]
- -> [(License, [InstalledPackageInfo])]
-groupByLicense = foldl'
- (\assoc ipi -> insertAList (license ipi) ipi assoc) []
- where
- -- 'Cabal.License' doesn't have an 'Ord' instance so we need to use an
- -- association list instead of 'Map'. The number of licenses probably won't
- -- exceed 100 so I think we're alright.
- insertAList :: Eq k => k -> v -> [(k, [v])] -> [(k, [v])]
- insertAList k v [] = [(k, [v])]
- insertAList k v ((k', vs) : kvs)
- | k == k' = (k, v : vs) : kvs
- | otherwise = (k', vs) : insertAList k v kvs
-
-
---------------------------------------------------------------------------------
-displayDependencyLicenseList
- :: [(License, [InstalledPackageInfo])]
- -> [(String, [(String, Version)])]
-displayDependencyLicenseList =
- map (display *** map (getName &&& getVersion))
- where
- getName =
- display . pkgName . sourcePackageId
- getVersion =
- pkgVersion . sourcePackageId
diff --git a/src/CabalHelper/Runtime/Main.hs b/src/CabalHelper/Runtime/Main.hs
index 0234247..49c6789 100644
--- a/src/CabalHelper/Runtime/Main.hs
+++ b/src/CabalHelper/Runtime/Main.hs
@@ -217,8 +217,6 @@ import CabalHelper.Shared.Sandbox
import CabalHelper.Shared.Common
import CabalHelper.Shared.InterfaceTypes
-import CabalHelper.Runtime.Licenses
-
usage :: IO ()
usage = do
prog <- getProgName
@@ -243,7 +241,6 @@ usage = do
++" | entrypoints\n"
++" | needs-build-output\n"
++" | source-dirs\n"
- ++" | licenses\n"
++" ) ...\n"
commands :: [String]
@@ -262,7 +259,7 @@ commands = [ "print-lbi"
, "entrypoints"
, "needs-build-output"
, "source-dirs"
- , "licenses"]
+ ]
main :: IO ()
main = do
@@ -429,12 +426,6 @@ main = do
res <- componentsMap lbi v distdir $$ \_ _ bi -> return $ hsSourceDirs bi
return $ Just $ ChResponseCompList (res ++ [(ChSetupHsName, [])])
- "licenses":[] -> do
- return $ Just $ ChResponseLicenses $
- map (second (map (second toDataVersion))) $
- displayDependencyLicenseList $
- groupByLicense $ getDependencyInstalledPackageInfos lbi
-
"print-lbi":flags ->
case flags of
["--human"] -> print lbi >> return Nothing
@@ -770,7 +761,7 @@ componentEntrypoints (CFLib (ForeignLib{..}))
componentEntrypoints (CExe Executable {..})
= ChExeEntrypoint
#if CH_MIN_VERSION_Cabal(2,0,0)
- --
+ --
( head ((hsSourceDirs buildInfo) ++ ["."]) </> modulePath)
-- modulePath
#else