Skip to content

Commit

Permalink
Adapt naming to fit to plan.json
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Apr 3, 2019
1 parent 64c59ff commit ef3090d
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions Cabal/Distribution/Simple/ShowBuildInfo.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
-- |
-- This module defines a simple JSON-based format for exporting basic
-- information about a Cabal package and the compiler configuration Cabal
-- would use to build it. This can be produced with the @cabal show-build-info@
-- command.
-- would use to build it. This can be produced with the
-- @cabal new-show-build-info@ command.
--
--
-- This format is intended for consumption by external tooling and should
-- therefore be rather stable. Moreover, this allows tooling users to avoid
Expand All @@ -13,42 +14,42 @@
-- Below is an example of the output this module produces,
--
-- @
-- { "cabal_version": "1.23.0.0",
-- { "cabal-version": "1.23.0.0",
-- "compiler": {
-- "flavor": "GHC",
-- "compiler_id": "ghc-7.10.2",
-- "compiler-id": "ghc-7.10.2",
-- "path": "/usr/bin/ghc",
-- },
-- "components": [
-- { "type": "library",
-- "name": "CLibName",
-- "compiler_args":
-- { "type": "lib",
-- "name": "library",
-- "compiler-args":
-- ["-O", "-XHaskell98", "-Wall",
-- "-package-id", "parallel-3.2.0.6-b79c38c5c25fff77f3ea7271851879eb"]
-- "modules": ["Project.ModA", "Project.ModB", "Paths_project"],
-- "source_files": [],
-- "source_dirs": ["src"]
-- "src-files": [],
-- "src-dirs": ["src"]
-- }
-- ]
-- }
-- @
--
-- The @cabal_version@ property provides the version of the Cabal library
-- The @cabal-version@ property provides the version of the Cabal library
-- which generated the output. The @compiler@ property gives some basic
-- information about the compiler Cabal would use to compile the package.
--
-- The @components@ property gives a list of the Cabal 'Component's defined by
-- the package. Each has,
--
-- * @type@: the type of the component (one of @library@, @executable@,
-- @test-suite@, or @benchmark@)
-- * @type@: the type of the component (one of @lib@, @exe@,
-- @test@, @bench@, or @flib@)
-- * @name@: a string serving to uniquely identify the component within the
-- package.
-- * @compiler_args@: the command-line arguments Cabal would pass to the
-- * @compiler-args@: the command-line arguments Cabal would pass to the
-- compiler to compile the component
-- * @modules@: the modules belonging to the component
-- * @source_dirs@: a list of directories where the modules might be found
-- * @source_files@: any other Haskell sources needed by the component
-- * @src-dirs@: a list of directories where the modules might be found
-- * @src-files@: any other Haskell sources needed by the component
--
-- Note: At the moment this is only supported when using the GHC compiler.
--
Expand Down Expand Up @@ -84,14 +85,14 @@ mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
k .= v = (k, v)

info = JsonObject
[ "cabal_version" .= JsonString (display cabalVersion)
[ "cabal-version" .= JsonString (display cabalVersion)
, "compiler" .= mkCompilerInfo
, "components" .= JsonArray (map mkComponentInfo componentsToBuild)
]

mkCompilerInfo = JsonObject
[ "flavour" .= JsonString (prettyShow $ compilerFlavor $ compiler lbi)
, "compiler_id" .= JsonString (showCompilerId $ compiler lbi)
, "compiler-id" .= JsonString (showCompilerId $ compiler lbi)
, "path" .= path
]
where
Expand All @@ -101,25 +102,25 @@ mkBuildInfo pkg_descr lbi _flags targetsToBuild = info
mkComponentInfo (name, clbi) = JsonObject
[ "type" .= JsonString compType
, "name" .= JsonString (prettyShow name)
, "compiler_args" .= JsonArray (map JsonString $ getCompilerArgs bi lbi clbi)
, "compiler-args" .= JsonArray (map JsonString $ getCompilerArgs bi lbi clbi)
, "modules" .= JsonArray (map (JsonString . display) modules)
, "source_files" .= JsonArray (map JsonString source_files)
, "source_dirs" .= JsonArray (map JsonString $ hsSourceDirs bi)
, "src-files" .= JsonArray (map JsonString sourceFiles)
, "src-dirs" .= JsonArray (map JsonString $ hsSourceDirs bi)
]
where
bi = componentBuildInfo comp
Just comp = lookupComponent pkg_descr name
compType = case comp of
CLib _ -> "library"
CExe _ -> "executable"
CTest _ -> "test-suite"
CBench _ -> "benchmark"
CFLib _ -> "foreign-library"
CLib _ -> "lib"
CExe _ -> "exe"
CTest _ -> "test"
CBench _ -> "bench"
CFLib _ -> "flib"
modules = case comp of
CLib lib -> explicitLibModules lib
CExe exe -> exeModules exe
_ -> []
source_files = case comp of
sourceFiles = case comp of
CLib _ -> []
CExe exe -> [modulePath exe]
_ -> []
Expand Down

0 comments on commit ef3090d

Please sign in to comment.