aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CabalHelper/Licenses.hs18
-rw-r--r--CabalHelper/Main.hs12
-rw-r--r--cabal-helper.cabal27
3 files changed, 45 insertions, 12 deletions
diff --git a/CabalHelper/Licenses.hs b/CabalHelper/Licenses.hs
index 4660c15..b16f61d 100644
--- a/CabalHelper/Licenses.hs
+++ b/CabalHelper/Licenses.hs
@@ -23,9 +23,12 @@ import Distribution.Simple.Configure
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.PackageIndex
import Distribution.Text
+import Distribution.ModuleName
--------------------------------------------------------------------------------
-#if CABAL_MAJOR == 1 && CABAL_MINOR > 22
+
+
+#if CABAL_MAJOR == 1 && CABAL_MINOR > 22
type CPackageIndex a = PackageIndex (InstalledPackageInfo)
#elif CABAL_MAJOR == 1 && CABAL_MINOR >= 22
type CPackageIndex a = PackageIndex (InstalledPackageInfo_ a)
@@ -35,6 +38,7 @@ type CPackageIndex a = PackageIndex
#if CABAL_MAJOR == 1 && CABAL_MINOR >= 23
type CInstalledPackageId = UnitId
+lookupInstalledPackageId' :: PackageIndex a -> UnitId -> Maybe a
lookupInstalledPackageId' = lookupUnitId
#elif CABAL_MAJOR == 1 && CABAL_MINOR > 22
type CInstalledPackageId = ComponentId
@@ -45,7 +49,7 @@ lookupInstalledPackageId' = lookupInstalledPackageId
#endif
findTransitiveDependencies
- :: CPackageIndex a
+ :: CPackageIndex Distribution.ModuleName.ModuleName
-> Set CInstalledPackageId
-> Set CInstalledPackageId
findTransitiveDependencies pkgIdx set0 = go Set.empty (Set.toList set0)
@@ -86,16 +90,16 @@ groupByLicense
:: [InstalledPackageInfo]
-> [(License, [InstalledPackageInfo])]
groupByLicense = foldl'
- (\assoc ipi -> insert (license ipi) ipi assoc) []
+ (\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.
- insert :: Eq k => k -> v -> [(k, [v])] -> [(k, [v])]
- insert k v [] = [(k, [v])]
- insert k v ((k', vs) : kvs)
+ 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) : insert k v kvs
+ | otherwise = (k', vs) : insertAList k v kvs
--------------------------------------------------------------------------------
diff --git a/CabalHelper/Main.hs b/CabalHelper/Main.hs
index 2170d30..f35ed3f 100644
--- a/CabalHelper/Main.hs
+++ b/CabalHelper/Main.hs
@@ -14,7 +14,7 @@
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-{-# LANGUAGE CPP, BangPatterns, RecordWildCards #-}
+{-# LANGUAGE CPP, BangPatterns, RecordWildCards, RankNTypes #-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}
import Distribution.Simple.Utils (cabalVersion)
import Distribution.Simple.Configure
@@ -441,11 +441,19 @@ nubPackageFlags opts = opts
nubPackageFlags opts = opts { ghcOptPackages = nub $ ghcOptPackages opts }
#endif
+renderGhcOptions' :: LocalBuildInfo
+ -> Verbosity
+ -> GhcOptions
+ -> IO [String]
renderGhcOptions' lbi v opts = do
#if CABAL_MAJOR == 1 && CABAL_MINOR < 20
(ghcProg, _) <- requireProgram v ghcProgram (withPrograms lbi)
let Just ghcVer = programVersion ghcProg
return $ renderGhcOptions ghcVer opts
-#else
+#elif CABAL_MAJOR == 1 && CABAL_MINOR >= 22 && CABAL_MINOR < 24
+-- && CABAL_MINOR < 24
return $ renderGhcOptions (compiler lbi) opts
+#elif CABAL_MAJOR == 1 && CABAL_MINOR >= 24
+-- CABAL_MAJOR == 1 && CABAL_MINOR >= 24
+ return $ renderGhcOptions (compiler lbi) (hostPlatform lbi) opts
#endif
diff --git a/cabal-helper.cabal b/cabal-helper.cabal
index d5723ca..58bac7b 100644
--- a/cabal-helper.cabal
+++ b/cabal-helper.cabal
@@ -49,7 +49,7 @@ library
default-language: Haskell2010
GHC-Options: -Wall
Build-Depends: base >= 4.5 && < 5
- , Cabal >= 1.14 && < 1.24
+ , Cabal >= 1.14 && < 1.25
, directory
, filepath
, transformers
@@ -73,7 +73,7 @@ Executable cabal-helper-wrapper
X-Install-Target: $libexecdir
Build-Depends: base >= 4.5 && < 5
, bytestring
- , Cabal >= 1.14 && < 1.24
+ , Cabal >= 1.14 && < 1.25
, directory
, filepath
, process
@@ -83,6 +83,22 @@ Executable cabal-helper-wrapper
, utf8-string
, ghc-prim
+Executable cabal-helper-main
+ if flag(dev)
+ Buildable: True
+ else
+ Buildable: False
+ Default-Language: Haskell98
+ Main-Is: CabalHelper/Main.hs
+ Other-Modules:
+ GHC-Options: -Wall -fno-warn-unused-imports -optP-DCABAL_MAJOR=1 -optP-DCABAL_MINOR=24 -optP-DCABAL_HELPER=1 -optP-DCABAL_HELPER_DEV=1
+ Build-Depends: base
+ , Cabal
+ , containers
+ , bytestring
+ , filepath
+ , directory
+
Test-Suite spec
Default-Language: Haskell2010
Type: exitcode-stdio-1.0
@@ -102,7 +118,7 @@ Test-Suite spec
, cabal-helper
, extra
, unix
- , Cabal >= 1.14 && < 1.24
+ , Cabal >= 1.14 && < 1.25
, directory
, filepath
, transformers
@@ -113,3 +129,8 @@ Test-Suite spec
, utf8-string
, template-haskell
, temporary
+
+flag dev
+ description: Build development components
+ default: False
+ manual: True \ No newline at end of file