Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit e5e9d62

Browse files
authored
Merge pull request #962 from alanz/merge-ghc-8.6.1
Support for GHC 8.6 and preliminary new-build
2 parents 962de0b + db78daf commit e5e9d62

32 files changed

+503
-143
lines changed

.circleci/config.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ defaults: &defaults
2222

2323
- restore_cache:
2424
keys:
25-
- stack-cache-11-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}-{{ checksum "all-cabal.txt" }}
26-
- stack-cache-11-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}
27-
- stack-cache-11-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }}
25+
- stack-cache-12-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}-{{ checksum "all-cabal.txt" }}
26+
- stack-cache-12-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}
27+
- stack-cache-12-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }}
2828

2929
- run:
3030
name: Stack setup
@@ -39,9 +39,13 @@ defaults: &defaults
3939
command: stack --stack-yaml=${STACK_FILE} install hoogle
4040

4141
- run:
42-
name: Build
42+
name: Build (we need the exe for tests)
4343
command: stack -j 2 --stack-yaml=${STACK_FILE} install
4444

45+
- run:
46+
name: Build Testsuite without running it
47+
command: stack -j 2 --stack-yaml=${STACK_FILE} build --test --no-run-tests
48+
4549
- store_artifacts:
4650
path: ~/.local/bin
4751
destination: bin
@@ -55,7 +59,7 @@ defaults: &defaults
5559
command: rm -fr ~/.cache/cabal-helper
5660

5761
- save_cache:
58-
key: stack-cache-11-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }}
62+
key: stack-cache-12-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }}
5963
paths:
6064
- ~/.stack
6165
- ~/.cache
@@ -77,7 +81,7 @@ defaults: &defaults
7781
path: test-logs
7882

7983
- save_cache:
80-
key: stack-cache-11-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}
84+
key: stack-cache-12-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}
8185
paths:
8286
- ~/.stack
8387
- ~/.cache
@@ -90,7 +94,7 @@ defaults: &defaults
9094
- ~/build/submodules/cabal-helper/.stack-work
9195

9296
- save_cache:
93-
key: stack-cache-11-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}-{{ checksum "all-cabal.txt" }}
97+
key: stack-cache-12-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "stack-build.txt" }}-{{ checksum "all-cabal.txt" }}
9498
paths:
9599
- ~/.stack
96100
- ~/.cache
@@ -134,6 +138,15 @@ jobs:
134138
- STACK_FILE: "stack-8.4.4.yaml"
135139
<<: *defaults
136140

141+
ghc-8.6.1:
142+
environment:
143+
- STACK_FILE: "stack-8.6.1.yaml"
144+
<<: *defaults
145+
146+
ghc-8.6.2:
147+
environment:
148+
- STACK_FILE: "stack-8.6.2.yaml"
149+
<<: *defaults
137150

138151
ghc-nightly:
139152
environment:
@@ -143,7 +156,8 @@ jobs:
143156
cabal:
144157
working_directory: ~/build
145158
docker:
146-
- image: quay.io/haskell_works/ghc-8.4.3
159+
# - image: quay.io/haskell_works/ghc-8.4.3
160+
- image: quay.io/haskell_works/ghc-8.6.1
147161
steps:
148162
- checkout
149163
- run:
@@ -154,7 +168,7 @@ jobs:
154168
command: git submodule update --recursive --init
155169
- restore-cache:
156170
keys:
157-
- cabal-03
171+
- cabal-12-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
158172
- run:
159173
name: Cabal version
160174
command: cabal --version
@@ -168,7 +182,7 @@ jobs:
168182
name: Build
169183
command: cabal new-build -j2
170184
- save_cache:
171-
key: cabal-03
185+
key: cabal-12-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
172186
paths:
173187
- ~/.cabal
174188

@@ -182,5 +196,7 @@ workflows:
182196
- ghc-8.4.2
183197
- ghc-8.4.3
184198
- ghc-8.4.4
199+
- ghc-8.6.1
200+
- ghc-8.6.2
185201
- ghc-nightly
186202
- cabal

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ test-logs/
6464

6565
.hspec-failures
6666
/test/testdata/addPragmas/stack.yaml
67+
.vscode

.gitmodules

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@
2626

2727
[submodule "submodules/brittany"]
2828
path = submodules/brittany
29-
url = https://github.com/alanz/brittany.git
29+
url = https://github.com/lspitzner/brittany.git
30+
[submodule "submodules/apply-refact"]
31+
path = submodules/apply-refact
32+
url = https://github.com/alanz/apply-refact.git
33+
[submodule "submodules/lsp-test"]
34+
path = submodules/lsp-test
35+
url = https://github.com/alanz/lsp-test.git

Makefile

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ all: help
55
.PHONY: all
66

77
## Builds hie for all supported GHC versions (8.2.1, 8.2.2, 8.4.2 and 8.4.3, 8.4.4)
8-
build: hie-8.2.1 hie-8.2.2 hie-8.4.2 hie-8.4.3 hie-8.4.4
8+
build: hie-8.2.1 hie-8.2.2 \
9+
hie-8.4.2 hie-8.4.3 hie-8.4.4 \
10+
hie-8.6.1 hie-8.6.2
911
.PHONY: build
1012

1113
## Builds hie and hoogle databases for all supported GHC versions
@@ -15,7 +17,7 @@ build-all: build build-docs
1517
# ------------------------------------------------------
1618

1719
## Builds hie for GHC version 8.2.1 only
18-
hie-8.2.1: submodules
20+
hie-8.2.1: submodules cabal
1921
stack --stack-yaml=stack-8.2.1.yaml install happy
2022
stack --stack-yaml=stack-8.2.1.yaml build
2123
stack --stack-yaml=stack-8.2.1.yaml install \
@@ -24,7 +26,7 @@ hie-8.2.1: submodules
2426
.PHONY: hie-8.2.1
2527

2628
## Builds hie for GHC version 8.2.2 only
27-
hie-8.2.2: submodules
29+
hie-8.2.2: submodules cabal
2830
stack --stack-yaml=stack-8.2.2.yaml install happy
2931
stack --stack-yaml=stack-8.2.2.yaml build
3032
stack --stack-yaml=stack-8.2.2.yaml install \
@@ -33,63 +35,101 @@ hie-8.2.2: submodules
3335
.PHONY: hie-8.2.2
3436

3537
## Builds hie for GHC version 8.4.2 only
36-
hie-8.4.2: submodules
38+
hie-8.4.2: submodules cabal
3739
stack --stack-yaml=stack-8.4.2.yaml build
3840
stack --stack-yaml=stack-8.4.2.yaml install \
3941
&& cp '$(STACKLOCALBINDIR)/hie' '$(STACKLOCALBINDIR)/hie-8.4.2' \
4042
&& cp '$(STACKLOCALBINDIR)/hie-8.4.2' '$(STACKLOCALBINDIR)/hie-8.4'
4143
.PHONY: hie-8.2.2
4244

4345
## Builds hie for GHC version 8.4.3 only
44-
hie-8.4.3: submodules
46+
hie-8.4.3: submodules cabal
4547
stack --stack-yaml=stack-8.4.3.yaml build
4648
stack --stack-yaml=stack-8.4.3.yaml install \
4749
&& cp '$(STACKLOCALBINDIR)/hie' '$(STACKLOCALBINDIR)/hie-8.4.3' \
4850
&& cp '$(STACKLOCALBINDIR)/hie-8.4.3' '$(STACKLOCALBINDIR)/hie-8.4'
4951
.PHONY: hie-8.4.3
5052

5153
## Builds hie for GHC version 8.4.4 only
52-
hie-8.4.4: submodules
54+
hie-8.4.4: submodules cabal
5355
stack --stack-yaml=stack-8.4.4.yaml build
5456
stack --stack-yaml=stack-8.4.4.yaml install \
5557
&& cp '$(STACKLOCALBINDIR)/hie' '$(STACKLOCALBINDIR)/hie-8.4.4' \
5658
&& cp '$(STACKLOCALBINDIR)/hie-8.4.4' '$(STACKLOCALBINDIR)/hie-8.4'
5759
.PHONY: hie-8.4.4
5860

61+
## Builds hie for GHC version 8.6.1 only
62+
hie-8.6.1: submodules cabal
63+
stack --stack-yaml=stack-8.6.1.yaml build
64+
stack --stack-yaml=stack-8.6.1.yaml install \
65+
&& cp '$(STACKLOCALBINDIR)/hie' '$(STACKLOCALBINDIR)/hie-8.6.1' \
66+
&& cp '$(STACKLOCALBINDIR)/hie-8.6.1' '$(STACKLOCALBINDIR)/hie-8.4'
67+
.PHONY: hie-8.6.1
68+
69+
## Builds hie for GHC version 8.6.2 only
70+
hie-8.6.2: submodules cabal
71+
stack --stack-yaml=stack-8.6.2.yaml build
72+
stack --stack-yaml=stack-8.6.2.yaml install \
73+
&& cp '$(STACKLOCALBINDIR)/hie' '$(STACKLOCALBINDIR)/hie-8.6.2' \
74+
&& cp '$(STACKLOCALBINDIR)/hie-8.6.2' '$(STACKLOCALBINDIR)/hie-8.4'
75+
.PHONY: hie-8.6.2
76+
5977
# ------------------------------------------------------
6078

6179
## Updates local git submodules
6280
submodules:
6381
git submodule update --init
6482
.PHONY: submodules
6583

84+
# ------------------------------------------------------
85+
86+
## Makes sure that Cabal the lib is available for cabal-helper-wapper,
87+
## to speed up project start
88+
89+
## NOTE 1: cabal-helper-wrapper builds with old style cabal build, so
90+
## must be installed this way.
91+
## NOTE 2: this is temporary, will go away once the new cabal-helper lands.
92+
## NOTE 3: This is needed for stack only projects too
93+
cabal:
94+
cabal update
95+
cabal install Cabal-2.4.1.0
96+
.PHONY: cabal
97+
98+
# ------------------------------------------------------
99+
66100
## Builds the Hoogle database for all supported GHC versions
67101
build-docs:
68102
stack --stack-yaml=stack-8.2.1.yaml exec hoogle generate \
69103
&& stack --stack-yaml=stack-8.2.2.yaml exec hoogle generate \
70104
&& stack --stack-yaml=stack-8.4.2.yaml exec hoogle generate \
71105
&& stack --stack-yaml=stack-8.4.3.yaml exec hoogle generate \
72106
&& stack --stack-yaml=stack-8.4.4.yaml exec hoogle generate
107+
&& stack --stack-yaml=stack-8.6.1.yaml exec hoogle generate
108+
&& stack --stack-yaml=stack-8.6.2.yaml exec hoogle generate
73109
.PHONY: build-docs
74110

75111

76112
# ------------------------------------------------------
77113

78114
## Runs hie tests
79-
test: submodules
115+
test: submodules cabal
80116
stack --stack-yaml=stack-8.2.1.yaml test \
81117
&& stack --stack-yaml=stack-8.2.2.yaml test \
82118
&& stack --stack-yaml=stack-8.4.2.yaml test \
83119
&& stack --stack-yaml=stack-8.4.3.yaml test \
84120
&& stack --stack-yaml=stack-8.4.4.yaml test
121+
&& stack --stack-yaml=stack-8.6.1.yaml test
122+
&& stack --stack-yaml=stack-8.6.2.yaml test
85123
.PHONY: test
86124

87-
build-copy-compiler-tool: submodules
125+
build-copy-compiler-tool: submodules cabal
88126
stack --stack-yaml=stack-8.2.1.yaml build --copy-compiler-tool \
89127
&& stack --stack-yaml=stack-8.2.2.yaml build --copy-compiler-tool \
90128
&& stack --stack-yaml=stack-8.4.2.yaml build --copy-compiler-tool \
91129
&& stack --stack-yaml=stack-8.4.3.yaml build --copy-compiler-tool \
92130
&& stack --stack-yaml=stack-8.4.4.yaml build --copy-compiler-tool
131+
&& stack --stack-yaml=stack-8.6.1.yaml build --copy-compiler-tool
132+
&& stack --stack-yaml=stack-8.6.2.yaml build --copy-compiler-tool
93133
.PHONY: build-copy-compiler-tool
94134

95135
## Fixes icu related problems in MacOS
@@ -114,6 +154,12 @@ icu-macos-fix-build:
114154
--extra-lib-dirs=/usr/local/opt/icu4c/lib \
115155
--extra-include-dirs=/usr/local/opt/icu4c/include \
116156
&& stack --stack-yaml=stack-8.4.4.yaml build text-icu \
157+
--extra-lib-dirs=/usr/local/opt/icu4c/lib \
158+
--extra-include-dirs=/usr/local/opt/icu4c/include \
159+
&& stack --stack-yaml=stack-8.6.1.yaml build text-icu \
160+
--extra-lib-dirs=/usr/local/opt/icu4c/lib \
161+
--extra-include-dirs=/usr/local/opt/icu4c/include \
162+
&& stack --stack-yaml=stack-8.6.2.yaml build text-icu \
117163
--extra-lib-dirs=/usr/local/opt/icu4c/lib \
118164
--extra-include-dirs=/usr/local/opt/icu4c/include
119165
.PHONY: icu-macos-fix-build

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ sudo apt install libicu-dev libtinfo-dev
105105
```
106106

107107

108-
### Getting the source for GHC 8.2.1, 8.2.2, 8.4.2, 8.4.3
108+
### Getting the source for GHC 8.2.1 to 8.6.2
109109

110110
HIE builds from source code, so first,
111111

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
version: 1.0.{build}
22
environment:
33
matrix:
4+
- GHCVER: 8.6.2
5+
- GHCVER: 8.6.1
46
- GHCVER: 8.4.4
57
- GHCVER: 8.4.3
68
- GHCVER: 8.4.2

cabal.project

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ packages:
22
./
33
./hie-plugin-api/
44

5-
./submodules/brittany
65
./submodules/HaRe
6+
./submodules/brittany
7+
./submodules/cabal-helper/
78
./submodules/ghc-mod/
89
./submodules/ghc-mod/core/
9-
./submodules/cabal-helper/
10+
11+
12+
-- allow-newer:ekg-core-0.1.1.4:base
13+
-- allow-newer:ekg-json-0.1.0.6:base

haskell-ide-engine.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ test-suite func-test
309309
, data-default
310310
, directory
311311
, filepath
312-
, lsp-test == 0.4.*
312+
, lsp-test == 0.5.*
313313
, haskell-ide-engine
314314
-- , hie-test-utils
315315
, hie-plugin-api

hie-plugin-api/Haskell/Ide/Engine/ArtifactMap.hs

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,19 @@ genLocMap tm = names
6969
checker (GHC.L (GHC.RealSrcSpan r) x) = IM.singleton (rspToInt r) x
7070
checker _ = IM.empty
7171

72-
#if __GLASGOW_HASKELL__ > 710
72+
#if __GLASGOW_HASKELL__ >= 806
73+
fieldOcc :: GHC.FieldOcc GM.GhcRn -> LocMap
74+
fieldOcc (GHC.FieldOcc n (GHC.L (GHC.RealSrcSpan r) _)) = IM.singleton (rspToInt r) n
75+
fieldOcc _ = IM.empty
76+
77+
hsRecFieldN :: GHC.LHsExpr GM.GhcRn -> LocMap
78+
hsRecFieldN (GHC.L _ (GHC.HsRecFld _ (GHC.Unambiguous n (GHC.L (GHC.RealSrcSpan r) _)) )) = IM.singleton (rspToInt r) n
79+
hsRecFieldN _ = IM.empty
80+
81+
hsRecFieldT :: GHC.LHsExpr GM.GhcTc -> LocMap
82+
hsRecFieldT (GHC.L _ (GHC.HsRecFld _ (GHC.Ambiguous n (GHC.L (GHC.RealSrcSpan r) _)) )) = IM.singleton (rspToInt r) (Var.varName n)
83+
hsRecFieldT _ = IM.empty
84+
#elif __GLASGOW_HASKELL__ > 710
7385
fieldOcc :: GHC.FieldOcc GM.GhcRn -> LocMap
7486
fieldOcc (GHC.FieldOcc (GHC.L (GHC.RealSrcSpan r) _) n) = IM.singleton (rspToInt r) n
7587
fieldOcc _ = IM.empty
@@ -104,7 +116,11 @@ genImportMap tm = moduleMap
104116
goImp acc _ = acc
105117

106118
goExp :: ModuleMap -> GHC.LIE name -> ModuleMap
119+
#if __GLASGOW_HASKELL__ >= 806
120+
goExp acc (GHC.L (GHC.RealSrcSpan r) (GHC.IEModuleContents _ lmn)) =
121+
#else
107122
goExp acc (GHC.L (GHC.RealSrcSpan r) (GHC.IEModuleContents lmn)) =
123+
#endif
108124
IM.insert (rspToInt r) (GHC.unLoc lmn) acc
109125
goExp acc _ = acc
110126

@@ -115,22 +131,43 @@ genDefMap tm = mconcat $ map (go . GHC.unLoc) decls
115131
where
116132
go :: GHC.HsDecl GM.GhcPs -> DefMap
117133
-- Type signatures
134+
#if __GLASGOW_HASKELL__ >= 806
135+
go (GHC.SigD _ (GHC.TypeSig _ lns _)) =
136+
#else
118137
go (GHC.SigD (GHC.TypeSig lns _)) =
138+
#endif
119139
foldl IM.union mempty $ fmap go' lns
120-
where go' (GHC.L (GHC.RealSrcSpan r) n) = IM.singleton (rspToInt r) n
140+
where go' (GHC.L (GHC.RealSrcSpan r) n) = IM.singleton (rspToInt r) n
121141
go' _ = mempty
122142
-- Definitions
143+
#if __GLASGOW_HASKELL__ >= 806
144+
go (GHC.ValD _ (GHC.FunBind _ (GHC.L (GHC.RealSrcSpan r) n) GHC.MG { GHC.mg_alts = llms } _ _)) =
145+
#else
123146
go (GHC.ValD (GHC.FunBind (GHC.L (GHC.RealSrcSpan r) n) GHC.MG { GHC.mg_alts = llms } _ _ _)) =
147+
#endif
124148
IM.insert (rspToInt r) n wheres
125149
where
126150
wheres = mconcat $ fmap (gomatch . GHC.unLoc) (GHC.unLoc llms)
127151

128152
gomatch GHC.Match { GHC.m_grhss = GHC.GRHSs { GHC.grhssLocalBinds = lbs } } =
129153
golbs (GHC.unLoc lbs)
154+
#if __GLASGOW_HASKELL__ >= 806
155+
gomatch GHC.XMatch{} = error "GHC.XMatch"
156+
gomatch (GHC.Match _ _ _ (GHC.XGRHSs _)) = error "GHC.XMatch"
157+
#endif
130158

159+
#if __GLASGOW_HASKELL__ >= 806
160+
golbs (GHC.HsValBinds _ (GHC.ValBinds _ lhsbs lsigs)) =
161+
#else
131162
golbs (GHC.HsValBinds (GHC.ValBindsIn lhsbs lsigs)) =
163+
#endif
164+
#if __GLASGOW_HASKELL__ >= 806
165+
foldl (\acc x -> IM.union acc (go $ GHC.ValD GHC.NoExt $ GHC.unLoc x)) mempty lhsbs
166+
`mappend` foldl IM.union mempty (fmap (go . GHC.SigD GHC.NoExt . GHC.unLoc) lsigs)
167+
#else
132168
foldl (\acc x -> IM.union acc (go $ GHC.ValD $ GHC.unLoc x)) mempty lhsbs
133169
`mappend` foldl IM.union mempty (fmap (go . GHC.SigD . GHC.unLoc) lsigs)
170+
#endif
134171
golbs _ = mempty
135172
go _ = mempty
136173
decls = GHC.hsmodDecls $ GHC.unLoc $ GHC.pm_parsed_source $ GHC.tm_parsed_module tm
@@ -168,6 +205,3 @@ toPos (l,c) = Position (l-1) (c-1)
168205

169206
-- ---------------------------------------------------------------------
170207
-- ---------------------------------------------------------------------
171-
172-
173-

0 commit comments

Comments
 (0)