Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit 3bf3d4c

Browse files
committed
Refactor .cabal to use sub-lib for vendored lib
A practical benefit is that we can control the build-depends and also avoid some recompilation between library and test-suite.
1 parent 49f6fad commit 3bf3d4c

File tree

1 file changed

+42
-21
lines changed

1 file changed

+42
-21
lines changed

haddock-library/haddock-library.cabal

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ library
2424
base >= 4.5 && < 4.11
2525
, bytestring >= 0.9.2.1 && < 0.11
2626
, transformers >= 0.3.0 && < 0.6
27-
, deepseq >= 1.3 && < 1.5
2827

29-
hs-source-dirs: src, vendor/attoparsec-0.13.1.0
28+
-- internal sub-lib
29+
build-depends: attoparsec
30+
31+
hs-source-dirs: src
3032
ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2
3133

3234
exposed-modules:
@@ -37,48 +39,61 @@ library
3739
Documentation.Haddock.Utf8
3840

3941
other-modules:
40-
Data.Attoparsec
42+
Documentation.Haddock.Parser.Util
43+
44+
ghc-options: -Wall
45+
if impl(ghc >= 8.0)
46+
ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
47+
48+
library attoparsec
49+
default-language: Haskell2010
50+
51+
build-depends:
52+
base >= 4.5 && < 4.11
53+
, bytestring >= 0.9.2.1 && < 0.11
54+
, deepseq >= 1.3 && < 1.5
55+
56+
hs-source-dirs: vendor/attoparsec-0.13.1.0
57+
58+
-- NB: haddock-library needs only small part of lib:attoparsec
59+
-- internally, so we only bundle that subset here
60+
exposed-modules:
4161
Data.Attoparsec.ByteString
42-
Data.Attoparsec.ByteString.Buffer
4362
Data.Attoparsec.ByteString.Char8
63+
64+
other-modules:
65+
Data.Attoparsec
66+
Data.Attoparsec.ByteString.Buffer
4467
Data.Attoparsec.ByteString.FastSet
4568
Data.Attoparsec.ByteString.Internal
4669
Data.Attoparsec.Combinator
4770
Data.Attoparsec.Internal
4871
Data.Attoparsec.Internal.Fhthagn
4972
Data.Attoparsec.Internal.Types
5073
Data.Attoparsec.Number
51-
Documentation.Haddock.Parser.Util
74+
75+
ghc-options: -funbox-strict-fields -Wall -fwarn-tabs -O2
5276

5377
ghc-options: -Wall
5478
if impl(ghc >= 8.0)
5579
ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
5680
else
5781
build-depends: semigroups ^>= 0.18.3, fail ^>= 4.9.0.0
5882

83+
5984
test-suite spec
6085
type: exitcode-stdio-1.0
6186
default-language: Haskell2010
6287
main-is: Spec.hs
6388
hs-source-dirs:
6489
test
6590
, src
66-
, vendor/attoparsec-0.13.1.0
6791
ghc-options: -Wall
6892

6993
cpp-options:
7094
-DTEST
7195

7296
other-modules:
73-
Data.Attoparsec.ByteString
74-
Data.Attoparsec.ByteString.Buffer
75-
Data.Attoparsec.ByteString.Char8
76-
Data.Attoparsec.ByteString.FastSet
77-
Data.Attoparsec.ByteString.Internal
78-
Data.Attoparsec.Combinator
79-
Data.Attoparsec.Internal
80-
Data.Attoparsec.Internal.Fhthagn
81-
Data.Attoparsec.Internal.Types
8297
Documentation.Haddock.Doc
8398
Documentation.Haddock.Parser
8499
Documentation.Haddock.Parser.Monad
@@ -89,18 +104,24 @@ test-suite spec
89104
Documentation.Haddock.Utf8
90105
Documentation.Haddock.Utf8Spec
91106

107+
build-depends:
108+
base-compat ^>= 0.9.3
109+
, transformers >= 0.3.0 && < 0.6
110+
, hspec ^>= 2.4.4
111+
, QuickCheck ^>= 2.10
112+
113+
-- internal sub-lib
114+
build-depends: attoparsec
115+
116+
-- Versions for the dependencies below are transitively pinned by
117+
-- dependency on haddock-library:lib:attoparsec
92118
build-depends:
93119
base
94120
, bytestring
95-
, transformers
96121
, deepseq
97122

98-
, base-compat
99-
, hspec
100-
, QuickCheck == 2.*
101-
102123
build-tool-depends:
103-
hspec-discover:hspec-discover
124+
hspec-discover:hspec-discover ^>= 2.4.4
104125

105126
source-repository head
106127
type: git

0 commit comments

Comments
 (0)