cabal-version:      1.20
build-type:         Simple
category:           Development
name:               ghcide
version:            0.7.0.0
license:            Apache-2.0
license-file:       LICENSE
author:             Digital Asset and Ghcide contributors
maintainer:         Ghcide contributors
copyright:          Digital Asset and Ghcide contributors 2018-2020
synopsis:           The core of an IDE
description:
    A library for building Haskell IDE's on top of the GHC API.
homepage:           https://github.com/haskell/ghcide#readme
bug-reports:        https://github.com/haskell/ghcide/issues
tested-with:        GHC>=8.6.5
extra-source-files: include/ghc-api-version.h README.md CHANGELOG.md
                    test/data/hover/*.hs
                    test/data/multi/cabal.project
                    test/data/multi/hie.yaml
                    test/data/multi/a/a.cabal
                    test/data/multi/a/*.hs
                    test/data/multi/b/b.cabal
                    test/data/multi/b/*.hs

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

flag ghc-lib
  description: build against ghc-lib instead of the ghc package
  default: False
  manual: True

library
    default-language:   Haskell2010
    build-depends:
        aeson,
        array,
        async,
        base == 4.*,
        binary,
        bytestring,
        case-insensitive,
        containers,
        data-default,
        deepseq,
        directory,
        dlist,
        extra,
        fuzzy,
        filepath,
        fingertree,
        Glob,
        haddock-library >= 1.8,
        hashable,
        haskell-lsp-types == 0.23.*,
        haskell-lsp == 0.23.*,
        hie-compat,
        hls-plugin-api >= 0.6,
        lens,
        mtl,
        network-uri,
        parallel,
        prettyprinter-ansi-terminal,
        prettyprinter-ansi-terminal,
        prettyprinter,
        regex-tdfa >= 1.3.1.0,
        rope-utf16-splay,
        safe,
        safe-exceptions,
        shake >= 0.18.4,
        sorted-list,
        stm,
        syb,
        text,
        time,
        transformers,
        unordered-containers >= 0.2.10.0,
        utf8-string,
        hslogger,
        opentelemetry >=0.6.1,
        heapsize ==0.3.*
    if flag(ghc-lib)
      build-depends:
        ghc-lib >= 8.8,
        ghc-lib-parser >= 8.8
      cpp-options: -DGHC_LIB
    else
      build-depends:
        ghc-boot-th,
        ghc-boot,
        ghc >= 8.6,
        -- These dependencies are used by Development.IDE.Session and are
        -- Haskell specific. So don't use them when building with -fghc-lib!
        ghc-check >=0.5.0.1,
        ghc-paths,
        cryptohash-sha1 >=0.11.100 && <0.12,
        hie-bios >= 0.7.1 && < 0.8.0,
        implicit-hie-cradle >= 0.3.0.2 && < 0.4,
        base16-bytestring >=0.1.1 && <0.2
    if os(windows)
      build-depends:
        Win32
    else
      build-depends:
        unix
      c-sources:
        cbits/getmodtime.c

    default-extensions:
        BangPatterns
        DeriveFunctor
        DeriveGeneric
        FlexibleContexts
        GeneralizedNewtypeDeriving
        LambdaCase
        NamedFieldPuns
        OverloadedStrings
        RecordWildCards
        ScopedTypeVariables
        StandaloneDeriving
        TupleSections
        TypeApplications
        ViewPatterns

    hs-source-dirs:
        src
    include-dirs:
        include
    exposed-modules:
        Development.IDE
        Development.IDE.Core.Debouncer
        Development.IDE.Core.FileStore
        Development.IDE.Core.IdeConfiguration
        Development.IDE.Core.OfInterest
        Development.IDE.Core.PositionMapping
        Development.IDE.Core.Preprocessor
        Development.IDE.Core.Rules
        Development.IDE.Core.RuleTypes
        Development.IDE.Core.Service
        Development.IDE.Core.Shake
        Development.IDE.Core.Tracing
        Development.IDE.GHC.Compat
        Development.IDE.GHC.Error
        Development.IDE.GHC.Orphans
        Development.IDE.GHC.Util
        Development.IDE.Import.DependencyInformation
        Development.IDE.LSP.HoverDefinition
        Development.IDE.LSP.LanguageServer
        Development.IDE.LSP.Outline
        Development.IDE.LSP.Protocol
        Development.IDE.LSP.Server
        Development.IDE.Spans.Common
        Development.IDE.Spans.Documentation
        Development.IDE.Spans.AtPoint
        Development.IDE.Spans.LocalBindings
        Development.IDE.Types.Diagnostics
        Development.IDE.Types.Exports
        Development.IDE.Types.KnownTargets
        Development.IDE.Types.Location
        Development.IDE.Types.Logger
        Development.IDE.Types.Options
        Development.IDE.Types.Shake
        Development.IDE.Plugin
        Development.IDE.Plugin.Completions
        Development.IDE.Plugin.CodeAction
        Development.IDE.Plugin.HLS
        Development.IDE.Plugin.HLS.GhcIde
        Development.IDE.Plugin.Test

    -- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses
    -- the real GHC library and the types are incompatible. Furthermore, when
    -- building with ghc-lib we need to make this Haskell agnostic, so no
    -- hie-bios!
    -- We also put these modules into a separate hs-source-dirs so we can avoid
    -- compiling them at all if ghc-lib is not set
    if !flag(ghc-lib)
      hs-source-dirs:
        session-loader
      exposed-modules:
        Development.IDE.Session
      other-modules:
        Development.IDE.Session.VersionCheck
    other-modules:
        Development.IDE.Core.Compile
        Development.IDE.Core.FileExists
        Development.IDE.GHC.CPP
        Development.IDE.GHC.Warnings
        Development.IDE.Import.FindImports
        Development.IDE.LSP.Notifications
        Development.IDE.Plugin.CodeAction.PositionIndexed
        Development.IDE.Plugin.CodeAction.Rules
        Development.IDE.Plugin.CodeAction.RuleTypes
        Development.IDE.Plugin.Completions.Logic
        Development.IDE.Plugin.Completions.Types
        Development.IDE.Plugin.HLS.Formatter
        Development.IDE.Types.Action
    ghc-options: -Wall -Wno-name-shadowing -Wincomplete-uni-patterns

executable ghcide-test-preprocessor
    default-language: Haskell2010
    hs-source-dirs: test/preprocessor
    ghc-options: -Wall -Wno-name-shadowing
    main-is: Main.hs
    build-depends:
        base == 4.*

benchmark benchHist
    type: exitcode-stdio-1.0
    default-language: Haskell2010
    ghc-options: -Wall -Wno-name-shadowing -threaded
    main-is: Main.hs
    hs-source-dirs: bench/hist bench/lib
    other-modules: Experiments.Types
    build-tool-depends:
        ghcide:ghcide-bench
    default-extensions:
        BangPatterns
        DeriveFunctor
        DeriveGeneric
        FlexibleContexts
        GeneralizedNewtypeDeriving
        LambdaCase
        NamedFieldPuns
        RecordWildCards
        ScopedTypeVariables
        StandaloneDeriving
        TupleSections
        TypeApplications
        ViewPatterns

    build-depends:
        aeson,
        base == 4.*,
        shake-bench == 0.1.*,
        directory,
        filepath,
        shake,
        text,
        yaml

executable ghcide
    if flag(ghc-lib)
      buildable: False
    default-language:   Haskell2010
    hs-source-dirs:     exe
    ghc-options:
                -threaded
                -Wall
                -Wincomplete-uni-patterns
                -Wno-name-shadowing
                -- allow user RTS overrides
                -rtsopts
                -- disable idle GC
                -- disable parallel GC
                -- increase nursery size
                "-with-rtsopts=-I0 -qg -A128M"
    main-is: Main.hs
    build-depends:
        aeson,
        base == 4.*,
        data-default,
        directory,
        extra,
        filepath,
        gitrev,
        hashable,
        haskell-lsp,
        haskell-lsp-types,
        heapsize,
        hie-bios,
        hls-plugin-api,
        ghcide,
        lens,
        optparse-applicative,
        text,
        unordered-containers
    other-modules:
        Arguments
        Paths_ghcide

    default-extensions:
        BangPatterns
        DeriveFunctor
        DeriveGeneric
        FlexibleContexts
        GeneralizedNewtypeDeriving
        LambdaCase
        NamedFieldPuns
        OverloadedStrings
        RecordWildCards
        ScopedTypeVariables
        StandaloneDeriving
        TupleSections
        TypeApplications
        ViewPatterns

test-suite ghcide-tests
    if flag(ghc-lib)
      buildable: False
    type: exitcode-stdio-1.0
    default-language: Haskell2010
    build-tool-depends:
        ghcide:ghcide,
        ghcide:ghcide-test-preprocessor
    build-depends:
        aeson,
        base,
        binary,
        bytestring,
        containers,
        data-default,
        directory,
        extra,
        filepath,
        --------------------------------------------------------------
        -- The MIN_GHC_API_VERSION macro relies on MIN_VERSION pragmas
        -- which require depending on ghc. So the tests need to depend
        -- on ghc if they need to use MIN_GHC_API_VERSION. Maybe a
        -- better solution can be found, but this is a quick solution
        -- which works for now.
        ghc,
        --------------------------------------------------------------
        ghcide,
        ghc-typelits-knownnat,
        haddock-library,
        haskell-lsp,
        haskell-lsp-types,
        hls-plugin-api,
        network-uri,
        lens,
        lsp-test >= 0.11.0.6 && < 0.12,
        optparse-applicative,
        process,
        QuickCheck,
        quickcheck-instances,
        rope-utf16-splay,
        safe,
        safe-exceptions,
        shake,
        tasty,
        tasty-expected-failure,
        tasty-hunit,
        tasty-quickcheck,
        tasty-rerun,
        text
    if (impl(ghc >= 8.6))
      build-depends:
          record-dot-preprocessor,
          record-hasfield
    hs-source-dirs: test/cabal test/exe test/src bench/lib
    include-dirs: include
    ghc-options: -threaded -Wall -Wno-name-shadowing -O0
    main-is: Main.hs
    other-modules:
        Development.IDE.Test
        Development.IDE.Test.Runfiles
        Experiments
        Experiments.Types
    default-extensions:
        BangPatterns
        DeriveFunctor
        DeriveGeneric
        FlexibleContexts
        GeneralizedNewtypeDeriving
        LambdaCase
        NamedFieldPuns
        OverloadedStrings
        RecordWildCards
        ScopedTypeVariables
        StandaloneDeriving
        TupleSections
        TypeApplications
        ViewPatterns

executable ghcide-bench
    default-language: Haskell2010
    build-tool-depends:
        ghcide:ghcide
    build-depends:
        aeson,
        base,
        bytestring,
        containers,
        directory,
        extra,
        filepath,
        ghcide,
        lsp-test >= 0.11.0.2 && < 0.12,
        optparse-applicative,
        process,
        safe-exceptions,
        shake,
        text
    hs-source-dirs: bench/lib bench/exe
    include-dirs: include
    ghc-options: -threaded -Wall -Wno-name-shadowing -rtsopts
    main-is: Main.hs
    other-modules:
        Experiments
        Experiments.Types
    default-extensions:
        BangPatterns
        DeriveFunctor
        DeriveGeneric
        FlexibleContexts
        GeneralizedNewtypeDeriving
        LambdaCase
        NamedFieldPuns
        OverloadedStrings
        RecordWildCards
        ScopedTypeVariables
        StandaloneDeriving
        TupleSections
        TypeApplications
        ViewPatterns