From c8f7ac80ee152d737220c75a4d9b10211a37ace8 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Mon, 12 Jun 2017 03:08:56 +0200 Subject: Update and fix support for Cabal HEAD --- Setup.hs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'Setup.hs') diff --git a/Setup.hs b/Setup.hs index 6909c27..94c8493 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,5 +1,14 @@ #!/usr/bin/env runhaskell -{-# LANGUAGE RecordWildCards, NamedFieldPuns #-} +{-# LANGUAGE CPP, RecordWildCards, NamedFieldPuns #-} + +#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,1,0) + +-- https://github.com/haskell/cabal/pull/4501 is upstream in 2.0, yey +import Distribution.Simple +main = defaultMain + +#else + import Distribution.Simple import Distribution.Simple.Utils import Distribution.Simple.Setup @@ -70,7 +79,7 @@ xInstallTarget :: PackageDescription -> (PackageDescription -> LocalBuildInfo -> IO ()) -> IO () xInstallTarget pd lbi cf fn = do - let (extended, regular) = partition isInternal (executables pd) + let (extended, regular) = partition isExeScopePrivate (executables pd) let pd_regular = pd { executables = regular } @@ -96,13 +105,16 @@ xInstallTarget pd lbi cf fn = do fn pd_regular lbi +isExeScopePrivate :: Executable -> Bool +isExeScopePrivate exe = + fromMaybe False $ (=="private") <$> lookup "x-scope" fields where - isInternal :: Executable -> Bool - isInternal exe = - fromMaybe False $ (=="True") <$> lookup "x-internal" (customFieldsBI $ buildInfo exe) + fields = customFieldsBI $ buildInfo exe onlyExePackageDesc :: [Executable] -> PackageDescription -> PackageDescription onlyExePackageDesc exes pd = emptyPackageDescription { package = package pd , executables = exes } + +#endif -- cgit v1.2.3