Skip to content

Commit

Permalink
simplify hlint plugin Cabal descriptor (haskell#2867)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra authored and sloorush committed May 21, 2022
1 parent 5d77f67 commit 83da009
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 68 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/flags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ jobs:
- name: Build `hls-graph` with flags
run: cabal v2-build hls-graph --flags="embed-files stm-stats"

- if: matrix.ghc != '8.6.5' && matrix.ghc != '8.8.4'
name: Build `hie-compat` with flags
run: cabal v2-build hie-compat --flags="ghc-lib"

- name: Build `ghcide` with flags
run: cabal v2-build ghcide --flags="ghc-patched-unboxed-bytecode test-exe executable bench-exe"

Expand Down
1 change: 0 additions & 1 deletion cabal-ghc90.project
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ write-ghc-environment-files: never
index-state: 2022-04-27T09:22:49Z

constraints:
hls-hlint-plugin +ghc-lib

-- although we are not building all plugins cabal solver phase is run for all packages
-- this way we track explicitly all transitive dependencies which need support for ghc-9
Expand Down
2 changes: 0 additions & 2 deletions cabal-ghc92.project
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ constraints:
-retrie
-splice
-tactic,
hls-hlint-plugin +ghc-lib,
-- # Use ghc-lib force instead of ghc itself
ghc-lib-parser-ex -auto,
hlint +ghc-lib,
stylish-haskell +ghc-lib
Expand Down
10 changes: 7 additions & 3 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ optional-packages: vendored/*/*.cabal
tests: true

package *
ghc-options: -haddock
-- ghc 8.10 cannot build ghc-lib 9.2 with --haddock
-- ghc-options: -haddock
test-show-details: direct

write-ghc-environment-files: never

index-state: 2022-03-08T10:53:01Z
index-state: 2022-04-27T09:22:49Z

constraints:
hyphenation +embed
hyphenation +embed,
-- remove this when hlint sets ghc-lib to true by default
-- https://github.com/ndmitchell/hlint/issues/1376
hlint +ghc-lib

allow-newer:
-- for shake-bench
Expand Down
2 changes: 1 addition & 1 deletion hie-compat/hie-compat.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ library
build-depends:
base < 4.17, array, bytestring, containers, directory, filepath, transformers
if flag(ghc-lib)
build-depends: ghc-lib
build-depends: ghc-lib < 9.0
else
build-depends: ghc, ghc-boot
if (impl(ghc >= 9.0) && impl(ghc < 9.1))
Expand Down
52 changes: 7 additions & 45 deletions plugins/hls-hlint-plugin/hls-hlint-plugin.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,9 @@ flag pedantic
manual: True

flag ghc-lib
default: False
manual: True
description:
Force dependency on ghc-lib-parser even if GHC API in the ghc package is supported

flag hlint34
default: True
manual: False
description:
Hlint-3.4 doesn't support versions ghc-lib < 9.0.1 nor ghc <= 8.6, so we can use hlint-3.2 for backwards compat
This flag can be removed when all dependencies support ghc-lib-9.0.* and we drop support for ghc-8.6
default: True
manual: True
description: Use ghc-lib types (requires hlint to be built with ghc-lib)

library
exposed-modules: Ide.Plugin.Hlint
Expand All @@ -56,7 +48,7 @@ library
, ghc-exactprint >=0.6.3.4
, ghcide ^>=1.7
, hashable
, hlint
, hlint < 3.5
, hls-plugin-api ^>=1.4
, hslogger
, lens
Expand All @@ -69,41 +61,11 @@ library
, transformers
, unordered-containers
, apply-refact >=0.9.0.0
-- can be removed if https://github.com/ndmitchell/hlint/pull/1325#issue-1077062712 is merged
-- and https://github.com/haskell/haskell-language-server/pull/2464#issue-1077133441 is updated
-- accordingly
, ghc-lib
, ghc-lib-parser
, ghc-lib-parser-ex

if (flag(hlint34))
-- This mirrors the logic in hlint.cabal for hlint-3.3
-- https://github.com/ndmitchell/hlint/blob/d3576de4529d8df6cca5a345f5b7e04474ff7bff/hlint.cabal#L79-L88
-- so we can make sure that we do the same thing as hlint
build-depends: hlint ^>=3.4

if (!flag(ghc-lib) && impl(ghc >=9.0.1) && impl(ghc <9.1.0))
build-depends: ghc ==9.0.*
else
build-depends:
, ghc-lib ^>=9.2
, ghc-lib-parser-ex ^>=9.2
, ghc-lib-parser ^>=9.2

cpp-options: -DHLINT_ON_GHC_LIB

else
-- This mirrors the logic in hlint.cabal for hlint-3.2
-- https://github.com/ndmitchell/hlint/blob/c7354e473c7d09213c8adc3dc94bf50a6eb4a42d/hlint.cabal#L79-L88
build-depends: hlint ^>=3.2
if (!flag(ghc-lib) && impl(ghc >=8.10.1) && impl(ghc < 8.11.0))
build-depends: ghc >=8.10 && <9.0
else
build-depends:
, ghc
, ghc-lib ^>=8.10.7.20210828
, ghc-lib-parser-ex ^>=8.10

cpp-options: -DHLINT_ON_GHC_LIB

cpp-options: -DHLINT_ON_GHC_LIB
ghc-options:
-Wall -Wredundant-constraints -Wno-name-shadowing
-Wno-unticked-promoted-constructors
Expand Down
2 changes: 1 addition & 1 deletion plugins/hls-hlint-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ disableHlint = sendConfigurationChanged $ toJSON $ def { Plugin.plugins = Map.fr
-- Although a given hlint version supports one direct ghc, we could use several versions of hlint
-- each one supporting a different ghc version. It should be a temporary situation though.
knownBrokenForHlintOnGhcLib :: String -> TestTree -> TestTree
knownBrokenForHlintOnGhcLib = knownBrokenForGhcVersions [GHC86, GHC88, GHC90, GHC92]
knownBrokenForHlintOnGhcLib = expectFailBecause

-- 1's based
data Point = Point {
Expand Down
6 changes: 2 additions & 4 deletions stack-lts16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ flags:
pedantic: true
retrie:
BuildExecutable: false
# Stack doesn't support automatic flags.
# Until the formatters support ghc-lib-9, we need this flag disabled
hls-hlint-plugin:
hlint34: false
hyphenation:
embed: true
hlint:
ghc-lib: true

nix:
packages: [icu libcxx zlib]
Expand Down
6 changes: 2 additions & 4 deletions stack-lts19.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ flags:
retrie:
BuildExecutable: false
# Stack doesn't support automatic flags.
# Until the formatters support ghc-lib-9, we need this flag disabled
hls-hlint-plugin:
hlint34: true
ghc-lib: true
hyphenation:
embed: true
hlint:
ghc-lib: true

nix:
packages: [ icu libcxx zlib ]
Expand Down
3 changes: 0 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ flags:
retrie:
BuildExecutable: false
# Stack doesn't support automatic flags.
hls-hlint-plugin:
hlint34: true
ghc-lib: true
# Use ghc-lib force instead of ghc itself
ghc-lib-parser-ex:
auto: false
Expand Down

0 comments on commit 83da009

Please sign in to comment.