1
1
-- |
2
2
-- This module defines a simple JSON-based format for exporting basic
3
3
-- information about a Cabal package and the compiler configuration Cabal
4
- -- would use to build it. This can be produced with the @cabal show-build-info@
5
- -- command.
4
+ -- would use to build it. This can be produced with the
5
+ -- @cabal new-show-build-info@ command.
6
+ --
6
7
--
7
8
-- This format is intended for consumption by external tooling and should
8
9
-- therefore be rather stable. Moreover, this allows tooling users to avoid
13
14
-- Below is an example of the output this module produces,
14
15
--
15
16
-- @
16
- -- { "cabal_version ": "1.23.0.0",
17
+ -- { "cabal-version ": "1.23.0.0",
17
18
-- "compiler": {
18
19
-- "flavor": "GHC",
19
- -- "compiler_id ": "ghc-7.10.2",
20
+ -- "compiler-id ": "ghc-7.10.2",
20
21
-- "path": "/usr/bin/ghc",
21
22
-- },
22
23
-- "components": [
23
- -- { "type": "library ",
24
- -- "name": "CLibName ",
25
- -- "compiler_args ":
24
+ -- { "type": "lib ",
25
+ -- "name": "lib:Cabal ",
26
+ -- "compiler-args ":
26
27
-- ["-O", "-XHaskell98", "-Wall",
27
28
-- "-package-id", "parallel-3.2.0.6-b79c38c5c25fff77f3ea7271851879eb"]
28
29
-- "modules": ["Project.ModA", "Project.ModB", "Paths_project"],
29
- -- "source_files ": [],
30
- -- "source_dirs ": ["src"]
30
+ -- "src-files ": [],
31
+ -- "src-dirs ": ["src"]
31
32
-- }
32
33
-- ]
33
34
-- }
34
35
-- @
35
36
--
36
- -- The @cabal_version @ property provides the version of the Cabal library
37
+ -- The @cabal-version @ property provides the version of the Cabal library
37
38
-- which generated the output. The @compiler@ property gives some basic
38
39
-- information about the compiler Cabal would use to compile the package.
39
40
--
40
41
-- The @components@ property gives a list of the Cabal 'Component's defined by
41
42
-- the package. Each has,
42
43
--
43
- -- * @type@: the type of the component (one of @library @, @executable @,
44
- -- @test-suite @, or @benchmark @)
44
+ -- * @type@: the type of the component (one of @lib @, @exe @,
45
+ -- @test@, @bench@, or @flib @)
45
46
-- * @name@: a string serving to uniquely identify the component within the
46
47
-- package.
47
- -- * @compiler_args @: the command-line arguments Cabal would pass to the
48
+ -- * @compiler-args @: the command-line arguments Cabal would pass to the
48
49
-- compiler to compile the component
49
50
-- * @modules@: the modules belonging to the component
50
- -- * @source_dirs @: a list of directories where the modules might be found
51
- -- * @source_files @: any other Haskell sources needed by the component
51
+ -- * @src-dirs @: a list of directories where the modules might be found
52
+ -- * @src-files @: any other Haskell sources needed by the component
52
53
--
53
54
-- Note: At the moment this is only supported when using the GHC compiler.
54
55
--
@@ -84,14 +85,14 @@ mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
84
85
k .= v = (k, v)
85
86
86
87
info = JsonObject
87
- [ " cabal_version " .= JsonString (display cabalVersion)
88
+ [ " cabal-version " .= JsonString (display cabalVersion)
88
89
, " compiler" .= mkCompilerInfo
89
90
, " components" .= JsonArray (map mkComponentInfo componentsToBuild)
90
91
]
91
92
92
93
mkCompilerInfo = JsonObject
93
94
[ " flavour" .= JsonString (prettyShow $ compilerFlavor $ compiler lbi)
94
- , " compiler_id " .= JsonString (showCompilerId $ compiler lbi)
95
+ , " compiler-id " .= JsonString (showCompilerId $ compiler lbi)
95
96
, " path" .= path
96
97
]
97
98
where
@@ -101,25 +102,25 @@ mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
101
102
mkComponentInfo (name, clbi) = JsonObject
102
103
[ " type" .= JsonString compType
103
104
, " name" .= JsonString (prettyShow name)
104
- , " compiler_args " .= JsonArray (map JsonString $ getCompilerArgs bi lbi clbi)
105
+ , " compiler-args " .= JsonArray (map JsonString $ getCompilerArgs bi lbi clbi)
105
106
, " modules" .= JsonArray (map (JsonString . display) modules)
106
- , " source_files " .= JsonArray (map JsonString source_files )
107
- , " source_dirs " .= JsonArray (map JsonString $ hsSourceDirs bi)
107
+ , " src-files " .= JsonArray (map JsonString sourceFiles )
108
+ , " src-dirs " .= JsonArray (map JsonString $ hsSourceDirs bi)
108
109
]
109
110
where
110
111
bi = componentBuildInfo comp
111
112
Just comp = lookupComponent pkg_descr name
112
113
compType = case comp of
113
- CLib _ -> " library "
114
- CExe _ -> " executable "
115
- CTest _ -> " test-suite "
116
- CBench _ -> " benchmark "
117
- CFLib _ -> " foreign-library "
114
+ CLib _ -> " lib "
115
+ CExe _ -> " exe "
116
+ CTest _ -> " test"
117
+ CBench _ -> " bench "
118
+ CFLib _ -> " flib "
118
119
modules = case comp of
119
120
CLib lib -> explicitLibModules lib
120
121
CExe exe -> exeModules exe
121
122
_ -> []
122
- source_files = case comp of
123
+ sourceFiles = case comp of
123
124
CLib _ -> []
124
125
CExe exe -> [modulePath exe]
125
126
_ -> []
0 commit comments