Skip to content

Commit effcfff

Browse files
committed
Build common haskell code as a library, which should avoid building things twice for executable and tests.
1 parent 4d33af5 commit effcfff

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

devbox.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"./build_dev_bin.sh"
2121
],
2222
"test": [
23-
"cabal test"
23+
"cabal test -f dev"
2424
],
2525
"compiler": [
2626
"GREN_BIN=$PWD/gren node cli.js"

gren.cabal

+20-12
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@ source-repository head
2929
type: git
3030
location: git://github.com/gren/compiler.git
3131

32-
3332
Flag dev {
3433
Description: Turn off optimization and make warnings errors
3534
Default: False
3635
}
3736

3837

39-
Common gren-common
38+
Library common
4039
if flag(dev)
4140
ghc-options: -O0 -Wall
4241
else
43-
ghc-options: -O2 -Wall -Werror -threaded "-with-rtsopts=-N"
42+
ghc-options: -O2 -Wall -Werror
4443

4544
default-language: GHC2021
4645

@@ -49,7 +48,7 @@ Common gren-common
4948
builder/src
5049
terminal
5150

52-
other-modules:
51+
Exposed-Modules:
5352
Format
5453
Init
5554
Make
@@ -219,19 +218,23 @@ Common gren-common
219218
indexed-traversable
220219

221220
Executable gren
222-
Import:
223-
gren-common
224-
225221
default-language: GHC2021
222+
main-is: terminal/Main.hs
223+
224+
if flag(dev)
225+
ghc-options: -O0 -Wall
226+
else
227+
ghc-options: -O2 -Wall -Werror -threaded "-with-rtsopts=-N"
226228

227-
Main-Is:
228-
Main.hs
229+
build-depends:
230+
gren:common,
231+
base >= 4.17 && <5,
232+
bytestring >= 0.11 && < 0.12,
229233

230234
Test-Suite gren-tests
231-
Import:
232-
gren-common
233-
234235
default-language: GHC2021
236+
237+
ghc-options: -O0 -Wall
235238

236239
Type:
237240
exitcode-stdio-1.0
@@ -257,6 +260,11 @@ Test-Suite gren-tests
257260
Parse.DeclSpec
258261

259262
Build-Depends:
263+
gren:common,
264+
base >= 4.17 && <5,
265+
text >= 2 && < 3,
266+
utf8-string,
267+
bytestring >= 0.11 && < 0.12,
260268
hspec >= 2.7.10 && < 3
261269

262270
Build-Tool-Depends:

0 commit comments

Comments
 (0)