cabal-read: emigrate

This commit is contained in:
tv 2024-06-05 13:55:17 +02:00
parent 0f5512c06d
commit 401f0e1159

View File

@ -1,39 +0,0 @@
{ writeHaskellPackage }:
# Because `sed -n 's/.*\<ghc-options:\s\+\(.*\)/\1/p'` is too simple.
writeHaskellPackage "cabal-read" {
executables.ghc-options = {
extra-depends = ["Cabal"];
text = /* haskell */ ''
{-# LANGUAGE CPP #-}
module Main (main) where
import Data.List
import Data.Maybe
import Distribution.Compiler
import Distribution.PackageDescription.Parsec
import Distribution.Types.BuildInfo
import Distribution.Types.CondTree
import Distribution.Types.Executable
import Distribution.Types.GenericPackageDescription
import Distribution.Types.UnqualComponentName
import Distribution.Verbosity
import System.Environment
main :: IO ()
main = do
[path, name] <- getArgs
desc <- readGenericPackageDescription normal path
case lookup (mkUnqualComponentName name) (condExecutables desc) of
Just exe ->
putStrLn . intercalate " " . fromMaybe [] . lookup GHC
#if MIN_VERSION_Cabal(3,0,0)
. perCompilerFlavorToList
#endif
. options . buildInfo . condTreeData $ exe
Nothing ->
error ("executable " <> name <> " not found in " <> path)
'';
};
}