clang-compilation-database (empty) → 0.1.0.0
raw patch · 6 files changed
+122/−0 lines, 6 filesdep +aesondep +basedep +bytestringsetup-changed
Dependencies added: aeson, base, bytestring, text
Files
- ChangeLog.md +5/−0
- LICENSE +20/−0
- README.md +8/−0
- Setup.hs +2/−0
- clang-compilation-database.cabal +40/−0
- src/Clang/CompilationDatabase.hs +47/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for clang-compilation-database++## 0.1.0.0 -- 2017-10-16++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2017 Aleksey Kliger++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ README.md view
@@ -0,0 +1,8 @@++# Haskell library for working with Clang Compilation Database Format files++This library implements a Haskell encoder and decoder for Clang's [JSON+Compilation Database Format+Specification](http://clang.llvm.org/docs/JSONCompilationDatabase.html) using+[Aeson](http://hackage.haskell.org/package/aeson)+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ clang-compilation-database.cabal view
@@ -0,0 +1,40 @@+-- Initial aeson-compilation-database.cabal generated by cabal init. For +-- further documentation, see http://haskell.org/cabal/users-guide/++name: clang-compilation-database+version: 0.1.0.0+synopsis: JSON Compilation Database Format encoding and decoding+description: See README.md+ .+ This library provides a data type to represent a+ <http://clang.llvm.org/docs/JSONCompilationDatabase.html JSON Compilation Database Format file>+ .+ It may be useful for static analysis tools that need to know the exact commands executed+ by a build system such as make.+homepage: https://github.com/lambdageek/clang-compilation-database+bug-reports: https://github.com/lambdageek/clang-compilation-database/issues+license: MIT+license-file: LICENSE+author: Aleksey Kliger+maintainer: akliger at gmail dot com+category: Language+build-type: Simple+extra-source-files: ChangeLog.md README.md+cabal-version: >=1.10+tested-with: GHC == 7.10.*, GHC == 8.0.*, GHC == 8.2.*++library+ exposed-modules: Clang.CompilationDatabase+ -- other-modules: + -- other-extensions: + build-depends: base >=4.8 && <4.11,+ bytestring >=0.10.6,+ aeson >=1.2.0.0,+ text >=1.2.0.2+ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -Wall++source-repository head+ type: git+ location: git://github.com/lambdageek/clang-compilation-database.git
+ src/Clang/CompilationDatabase.hs view
@@ -0,0 +1,47 @@+-- |+-- Module : Clang.CompilationDatabase+-- Description : JSON Compilation Database Format+-- License : MIT+-- Stability : experimental+--+-- Clang Compilation Database Format parser+--+-- The <http://clang.llvm.org/docs/JSONCompilationDatabase.html Clang Compilation Database Format> is a JSON+-- file format for recording compiler invocations in build systems.+--+--+{-# language DeriveGeneric #-}+module Clang.CompilationDatabase where++import GHC.Generics (Generic)+import Data.Aeson (FromJSON, ToJSON{-, eitherDecode'-})+-- import qualified Data.ByteString.Lazy as B+import Data.Text (Text)++-- | A Compilation database consists of a sequence of 'CommandObject' values each of which is a+-- set of commands that acted upon a single source file.+type CompilationDatabase = [CommandObject]++-- | Each command object contains the translation unit’s main file, the working+-- directory of the compile run and the actual compile command.+data CommandObject = CommandObject {+ directory :: Text, -- ^ The working directory during compilation+ file :: Text, -- ^ The main translation unit processed by this compilation+ -- step. There may be multiple 'CommandObject' values in a+ -- 'CompilationDatabase' for the same file if it was the main+ -- file for multiple compilation steps.+ command :: Maybe Text, -- ^ The command that was executed. Double quotes and+ -- backslashes are escaped by a backslash.+ arguments :: Maybe [Text], -- ^ The compile command executed as a list of+ -- strings. Either 'command' or 'arguments' is+ -- required. __TODO__ model this more faithfully.+ output :: Maybe Text -- ^ Optional name of the output file created by this+ -- compilation step.+ }+ deriving (Generic, Show)++instance FromJSON CommandObject+instance ToJSON CommandObject++-- test :: FilePath -> IO (Either String [CommandObject])+-- test fp = fmap eitherDecode' (B.readFile fp)