packages feed

ghcup-0.2.6.0: ghcup.cabal

cabal-version:      2.4
name:               ghcup
version:            0.2.6.0
license:            LGPL-3.0-only
license-file:       LICENSE
copyright:          Julian Ospald 2024
maintainer:         hasufell@posteo.de
author:             Julian Ospald
homepage:           https://github.com/haskell/ghcup-hs
bug-reports:        https://github.com/haskell/ghcup-hs/issues/
synopsis:           ghc toolchain installer
description:
  A rewrite of the shell script ghcup, for providing
  a more stable user experience and exposing an API.

category:           System
build-type:         Simple
extra-doc-files:
  CHANGELOG.md
  data/config.yaml
  README.md

extra-source-files:
  cbits/dirutils.c
  cbits/dirutils.h
  data/build_mk/cross
  data/build_mk/default
  scoop-better-shimexe/shim.c
  scripts/bootstrap/bootstrap-haskell
  scripts/bootstrap/bootstrap-haskell.ps1
  scripts/hooks/stack/ghc-install.sh
  scripts/shell-completions/bash
  scripts/shell-completions/fish
  scripts/shell-completions/zsh
  test/ghcup-test/data/dir/.keep
  test/ghcup-test/data/file
  test/ghcup-test/golden/unix/GHCupInfo.json

tested-with: GHC==9.14.1
           , GHC==9.12.4
           , GHC==9.10.3
           , GHC==9.8.4
           , GHC==9.6.7

source-repository head
  type:     git
  location: https://github.com/haskell/ghcup-hs.git

flag tui
  description:
    Build the brick powered tui (ghcup tui).

  default:     True
  manual:      True

flag internal-downloader
  description:
    Compile the internal downloader, which links against OpenSSL. This is disabled on windows.

  default:     False
  manual:      True

flag strict-metadata-parsing
  description:
    Don't ignore unknown keys in metadata. Useful for metadata testing.

  default:     False
  manual:      True

flag no-exe
  description: Don't build any executables
  default:     False
  manual:      True

flag tar
  description: Use haskell tar instead of libarchive.
  default:     False
  manual:      True

flag yaml-streamly
  description: Use yaml-streamly instead of yaml (based on conduit)
  default:     False
  manual:      True

flag dhall
  description: Add support for dhall encoded metadata
  default:     True
  manual:      True

flag dhall-tests
  description: Run dhall tests depedning on dhall-yaml/dhall-json
  default:     True
  manual:      False

common common-ghc-options
  ghc-options:
    -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns
    -fwarn-incomplete-record-updates -Werror=incomplete-patterns

common common-extensions
  default-extensions:
    DeriveGeneric
    LambdaCase
    MultiWayIf
    NamedFieldPuns
    PackageImports
    QuasiQuotes
    RecordWildCards
    ScopedTypeVariables
    StrictData
    TupleSections
    TypeApplications
    TypeFamilies
    ViewPatterns

common common-language
  default-language: Haskell2010

common platform-ifdefs
  if os(freebsd)
    cpp-options: -DIS_FREEBSD

  if os(windows)
    cpp-options: -DIS_WINDOWS

common app-common-depends
  import: common-ghc-options
  import: common-extensions
  import: common-language
  import: platform-ifdefs

  if flag(dhall)
    cpp-options: -DDHALL
    build-depends:
        dhall  ^>=1.42
      , either ^>=5.0.3

  build-depends:
    , aeson                   >=1.4
    , aeson-pretty           ^>=0.8.8
    , async                  ^>=2.2.3
    , attoparsec             ^>= 0.14
    , base                    >=4.12 && <5
    , bytestring              >=0.10 && <0.13
    , containers             ^>=0.6 || ^>=0.7 || ^>=0.8
    , deepseq                ^>=1.4 || ^>=1.5 || ^>=1.6
    , directory              ^>=1.3.6.0
    , filepath                >=1.4.101.0
    , indexed-traversable    ^>=0.1.4
    , variant                ^>=1.0
    , megaparsec              >=8.0.0 && <9.8
    , mtl                    ^>=2.2 || ^>=2.3
    , optics                 ^>=0.4
    , optparse-applicative    >=0.15.1.0 && <0.20
    , pretty                 ^>=1.1.3.6
    , pretty-terminal        ^>=0.1.0.0
    , process                ^>=1.6.11.0
    , resourcet              ^>=1.2.2 || ^>=1.3
    , safe                   ^>=0.3.18
    , safe-exceptions        ^>=0.1
    , tagsoup                ^>=0.14
    , transformers           ^>=0.5 || ^>=0.6
    , template-haskell        >=2.7 && <2.25
    , temporary              ^>=1.3
    , text                   ^>=2.0 || ^>=2.1
    , time >=1.9.3 && <1.17
    , unordered-containers   ^>=0.2
    , uri-bytestring         ^>=0.4.0.1
    , utf8-string            ^>=1.0
    , vector                  >=0.12 && <0.14
    , versions                >=6.0.5 && <6.1
    , witherable              >=0.4 && <0.6

  if flag(yaml-streamly)
    build-depends:
        yaml-streamly ^>=0.12.5
  else
    build-depends:
        yaml ^>=0.11.0

  if os(windows)
    build-depends:
      , process  ^>=1.6.11.0
      , Win32    >=2.10
  else
    build-depends:
      , unix             ^>=2.7 || ^>=2.8
      , unix-bytestring  ^>=0.4

  if flag(tar)
    cpp-options:   -DTAR
    build-depends:
        tar ^>=0.7.0.0
      , zip ^>=2.0.0 || ^>=2.1.0

  else
    build-depends: libarchive ^>=3.0.3.0

library
  import:             app-common-depends
  exposed-modules:
    GHCup.Builder
    GHCup.CabalConfig
    GHCup.Command.Compile.GHC
    GHCup.Command.Compile.HLS
    GHCup.Command.Install
    GHCup.Command.Install.LowLevel
    GHCup.Command.List
    GHCup.Command.Nuke
    GHCup.Command.DebugInfo
    GHCup.Command.Upgrade
    GHCup.Command.Whereis
    GHCup.Command.GC
    GHCup.Command.HealthCheck
    GHCup.Command.Prefetch
    GHCup.Command.Rm
    GHCup.Command.Set
    GHCup.Command.Test.GHC
    GHCup.Compat.Pager
    GHCup.Compat.Terminal
    GHCup.Download
    GHCup.Errors
    GHCup.Hardcoded.URLs
    GHCup.Hardcoded.Version
    GHCup.Input.Parsers
    GHCup.Input.Parsers.Domain
    GHCup.Input.Parsers.URI
    GHCup.Input.Prompts
    GHCup.Input.SymlinkSpec
    GHCup.Legacy.Cabal
    GHCup.Legacy.HLS
    GHCup.Legacy.Stack
    GHCup.Legacy.Utils
    GHCup.PlanJson
    GHCup.Prelude
    GHCup.Prelude.Attoparsec
    GHCup.Prelude.File
    GHCup.Prelude.File.Search
    GHCup.Prelude.Internal
    GHCup.Prelude.JSON
    GHCup.Prelude.Logger
    GHCup.Prelude.Logger.Internal
    GHCup.Prelude.MegaParsec
    GHCup.Prelude.Process
    GHCup.Prelude.String.QQ
    GHCup.Prelude.Version
    GHCup.Prelude.Version.QQ
    GHCup.Query
    GHCup.Query.DB
    GHCup.Query.DB.HLS
    GHCup.Query.GHCupDirs
    GHCup.Query.Metadata
    GHCup.Query.Symlink
    GHCup.Query.System
    GHCup.Setup
    GHCup.System.Cmd
    GHCup.System.Directory
    GHCup.Types
    GHCup.Types.Dhall
    GHCup.Types.JSON
    GHCup.Types.JSON.MapIgnoreUnknownKeys
    GHCup.Types.JSON.Utils
    GHCup.Types.JSON.Versions
    GHCup.Types.Optics
    GHCup.Types.Stack
    GHCup.Types.Tar
    GHCup.Unpack
    GHCup.Warnings

  hs-source-dirs:     lib
  other-modules:      Paths_ghcup
  autogen-modules:    Paths_ghcup

  build-depends:
    , base16-bytestring     >=0.1.1.6    && <1.1
    , binary                ^>=0.8.6.0 || ^>=0.9 || ^>=0.10
    , bz2                   ^>=1.0.1.1
    , Cabal                 ^>=3.0.0.0 || ^>=3.2.0.0 || ^>=3.4.0.0 || ^>=3.6.0.0 || ^>=3.8.0.0 || ^>= 3.10.0.0 || ^>= 3.12.0.0 || ^>= 3.14.0.0 || ^>= 3.16.0.0
    , Cabal-syntax          ^>=3.6.0.0 || ^>=3.8.0.0 || ^>= 3.10.0.0 || ^>= 3.12.0.0 || ^>= 3.14.0.0 || ^>= 3.16.0.0
    , case-insensitive      ^>=1.2.1.0
    , casing                ^>=0.1.4.1
    , conduit               ^>=1.3
    , conduit-extra         ^>=1.3
    , cryptohash-sha256     ^>=0.11.101.0
    , disk-free-space       ^>=0.1.0.1
    , exceptions            ^>=0.10
    , filepattern           ^>=0.1.3
    , file-uri              ^>=0.1.0.0
    , xz                    ^>=5.6.3
    , os-release            ^>=1.0.0
    , parsec
    , regex-posix           ^>=0.96
    , retry                 >=0.8.1.2    && <0.10
    , scientific
    , split                 ^>=0.2.3.4
    , strict-base           ^>=0.4
    , terminal-size         ^>=0.3.3
    , th-lift               ^>=0.8.7
    , unliftio-core         ^>=0.2.0.1
    , word8                 ^>=0.1.3
    , zlib                  ^>=0.6.2.2 || ^>=0.7

  if flag(yaml-streamly)
    build-depends:
        yaml-streamly ^>=0.12.5
  else
    build-depends:
        yaml ^>=0.11.0

  if (flag(internal-downloader) && !os(windows))
    exposed-modules: GHCup.Download.IOStreams
    cpp-options:     -DINTERNAL_DOWNLOADER
    build-depends:
      , HsOpenSSL              >=0.11.7.2
      , http-io-streams        >=0.1.2.0
      , io-streams             >=1.5.2.1
      , terminal-progress-bar  >=0.4.1

  if os(windows)
    other-modules:
      GHCup.Prelude.File.Windows
      GHCup.Prelude.Windows

    -- GHCup.OptParse.Run uses this
    exposed-modules: GHCup.Prelude.Process.Windows

  else
    other-modules:
      GHCup.Prelude.File.Posix
      GHCup.Prelude.File.Posix.Foreign
      GHCup.Prelude.Posix
      GHCup.Prelude.Process.Posix

    exposed-modules:  GHCup.Prelude.File.Posix.Traversals
    include-dirs:     cbits
    install-includes: dirutils.h
    c-sources:        cbits/dirutils.c

  if flag(tui)
    cpp-options:   -DBRICK
    build-depends: vty ^>=6.0 || ^>=6.1 || ^>=6.2 || ^>=6.3 || ^>=6.4

  if (flag(strict-metadata-parsing))
    cpp-options:     -DSTRICT_METADATA_PARSING

library ghcup-optparse
  import:             app-common-depends
  exposed-modules:
    GHCup.OptParse
    GHCup.OptParse.ChangeLog
    GHCup.OptParse.Common
    GHCup.OptParse.Compile
    GHCup.OptParse.Config
    GHCup.OptParse.DebugInfo
    GHCup.OptParse.GC
    GHCup.OptParse.Generate
    GHCup.OptParse.HealthCheck
    GHCup.OptParse.Install
    GHCup.OptParse.List
    GHCup.OptParse.Nuke
    GHCup.OptParse.Prefetch
    GHCup.OptParse.Reset
    GHCup.OptParse.Rm
    GHCup.OptParse.Run
    GHCup.OptParse.Set
    GHCup.OptParse.TUI
    GHCup.OptParse.Test
    GHCup.OptParse.ToolRequirements
    GHCup.OptParse.UnSet
    GHCup.OptParse.Upgrade
    GHCup.OptParse.Whereis
    Options.Applicative.Pretty.Shim

  hs-source-dirs:     lib-opt

  build-depends:      ghcup

  if flag(internal-downloader)
    cpp-options: -DINTERNAL_DOWNLOADER

  if flag(tui)
    cpp-options:   -DBRICK

library ghcup-tui
  import:             app-common-depends
  exposed-modules:
    GHCup.BrickMain
    GHCup.Brick.Widgets.Navigation
    GHCup.Brick.Widgets.Tutorial
    GHCup.Brick.Widgets.KeyInfo
    GHCup.Brick.Widgets.ToolInfo
    GHCup.Brick.Widgets.Menu
    GHCup.Brick.Widgets.Menus.Context
    GHCup.Brick.Widgets.Menus.AdvancedInstall
    GHCup.Brick.Widgets.Menus.CompileGHC
    GHCup.Brick.Widgets.Menus.CompileHLS
    GHCup.Brick.Actions
    GHCup.Brick.App
    GHCup.Brick.BrickState
    GHCup.Brick.Attributes
    GHCup.Brick.Common

  hs-source-dirs:     lib-tui

  build-depends:
    , ghcup
    , ghcup-optparse
    , brick >=2.1 && <2.13
    , vty           ^>=6.0 || ^>=6.1 || ^>=6.2 || ^>=6.3 || ^>=6.4

  if !flag(tui)
    buildable: False

executable ghcup
  import:             app-common-depends
  main-is:            Main.hs

  hs-source-dirs:     app/ghcup

  ghc-options:
    -threaded

  build-depends:
    , ghcup
    , ghcup-optparse

  if flag(internal-downloader)
    cpp-options: -DINTERNAL_DOWNLOADER

  if flag(tui)
    cpp-options:   -DBRICK
    build-depends:
      , ghcup-tui

  if flag(no-exe)
    buildable: False

test-suite ghcup-test
  import: common-ghc-options
  import: common-extensions
  import: common-language
  import: platform-ifdefs
  type:               exitcode-stdio-1.0
  main-is:            Main.hs
  build-tool-depends: hspec-discover:hspec-discover -any
  hs-source-dirs:     test/ghcup-test
  other-modules:
    GHCup.ArbitraryTypes
    GHCup.Prelude.File.Posix.TraversalsSpec
    GHCup.Types.JSONSpec
    GHCup.Utils.FileSpec
    GHCup.ParserSpec
    Spec

  ghc-options:
    -fconstraint-solver-iterations=0

  if flag(dhall) && flag(dhall-tests)
    cpp-options: -DDHALL
    build-depends:
        dhall  ^>=1.42
      , dhall-json ^>= 1.7.11
      , dhall-yaml ^>= 1.2.11
      , either ^>=5.0.3

  build-depends:
    , aeson                      >=1.4
    , aeson-pretty              ^>=0.8.8
    , base                       >=4.12    && <5
    , bytestring                 >=0.10    && <0.13
    , containers                ^>=0.6 || ^>=0.7 || ^>=0.8
    , conduit                   ^>=1.3
    , directory                 ^>=1.3.6.0
    , filepath                   >=1.4.101.0
    , generic-arbitrary         ^>=0.1.0 || ^>=0.2.2 || ^>=1.0.0
    , ghcup
    , hspec                      >=2.7.10  && <2.12
    , hspec-golden              ^>=0.2.2.0
    , hspec-golden-aeson        ^>=0.9
    , megaparsec                 >=8.0.0    && <9.8
    , pretty                    ^>=1.1.3.6
    , QuickCheck                ^>=2.14.1 || ^>=2.15
    , quickcheck-arbitrary-adt  ^>=0.3.1.0
    , text                      ^>=2.0 || ^>=2.1
    , time >=1.9.3 && <1.17
    , uri-bytestring            ^>=0.4.0.1
    , yaml
    , versions                   >=6.0.5      && <6.1

  if os(freebsd)
    cpp-options: -DIS_FREEBSD

  if !os(windows)
    build-depends: unix ^>=2.7 || ^>=2.8

test-suite ghcup-optparse-test
  import: common-ghc-options
  import: common-extensions
  import: common-language
  import: platform-ifdefs
  type:             exitcode-stdio-1.0
  hs-source-dirs:   test/optparse-test
  main-is:          Main.hs
  other-modules:
    ChangeLogTest
    CompileTest
    ConfigTest
    GCTest
    InstallTest
    ListTest
    OtherCommandTest
    RmTest
    RunTest
    SetTest
    UnsetTest
    UpgradeTest
    Utils
    WhereisTest

  build-depends:
    , base
    , ghcup
    , ghcup-optparse
    , optparse-applicative
    , tasty
    , tasty-hunit
    , template-haskell
    , text
    , uri-bytestring
    , versions

benchmark bench
  import: common-ghc-options
  import: common-extensions
  import: common-language
  import: platform-ifdefs

  main-is:          Bench.hs
  other-modules:    BenchList
                    BenchParse
                    BenchSetup
  type:             exitcode-stdio-1.0
  hs-source-dirs:   bench
  ghc-options:      -O2 "-with-rtsopts=-A32m"
  if impl(ghc >= 8.6)
    ghc-options:    -fproc-alignment=64
  build-depends:    base,
                    aeson,
                    bytestring,
                    containers,
                    directory,
                    deepseq,
                    filepath,
                    ghcup,
                    mtl,
                    safe-exceptions,
                    tasty-bench,
                    template-haskell,
                    text,
                    variant,
                    versions,
                    yaml