Skip to content

Commit

Permalink
generate JSON file
Browse files Browse the repository at this point in the history
  • Loading branch information
wavewave committed Sep 6, 2018
1 parent 6a7e926 commit 01f4c94
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
5 changes: 5 additions & 0 deletions fficxx/lib/FFICXX/Generate/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ simpleBuilder topLevelMod mumap (cabal,classes,toplevelfunctions,templates) extr
(cabal_additional_c_srcs cabal)
hsbootlst = mkHSBOOTCandidateList mods
cabalFileName = unCabalName pkgname <.> "cabal"
jsonFileName = unCabalName pkgname <.> "json"
--
notExistThenCreate workingDir
notExistThenCreate installDir
Expand All @@ -82,6 +83,9 @@ simpleBuilder topLevelMod mumap (cabal,classes,toplevelfunctions,templates) extr
putStrLn "Generating Cabal file"
buildCabalFile cabal topLevelMod pkgconfig extralibs (workingDir</>cabalFileName)
--
putStrLn "Generating JSON file"
buildJSONFile cabal topLevelMod pkgconfig extralibs (workingDir</>jsonFileName)
--
putStrLn "Generating Header file"
let typmacro = TypMcro ("__" <> macrofy (unCabalName (cabal_pkgname cabal)) <> "__")
gen :: FilePath -> String -> IO ()
Expand Down Expand Up @@ -164,6 +168,7 @@ simpleBuilder topLevelMod mumap (cabal,classes,toplevelfunctions,templates) extr
putStrLn "Copying generated files to target directory"
touch (workingDir </> "LICENSE")
copyFileWithMD5Check (workingDir </> cabalFileName) (installDir </> cabalFileName)
copyFileWithMD5Check (workingDir </> jsonFileName) (installDir </> jsonFileName)
copyFileWithMD5Check (workingDir </> "LICENSE") (installDir </> "LICENSE")

copyCppFiles workingDir (csrcDir installDir) (unCabalName pkgname) pkgconfig
Expand Down
27 changes: 17 additions & 10 deletions fficxx/lib/FFICXX/Generate/Code/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

module FFICXX.Generate.Code.Cabal where

import Data.Aeson.Encode.Pretty (encodePretty)
import qualified Data.ByteString.Lazy as BL
import Data.List (intercalate,nub)
import Data.Monoid ((<>))
import Data.Text (Text)
Expand Down Expand Up @@ -256,19 +258,24 @@ buildCabalFile
:: Cabal
-> String
-> PackageConfig
-> [String] -- ^ extra libs
-> FilePath
-> [String] -- ^ Extra libs
-> FilePath -- ^ Cabal file path
-> IO ()
buildCabalFile cabal summarymodule pkgconfig extralibs cabalfile = do
let
{- tih = pcfg_topLevelImportHeader pkgconfig
classmodules = pcfg_classModules pkgconfig
cih = pcfg_classImportHeaders pkgconfig
tmods = pcfg_templateClassModules pkgconfig
tcih = pcfg_templateClassImportHeaders pkgconfig
acincs = pcfg_additional_c_incs pkgconfig
acsrcs = pcfg_additional_c_srcs pkgconfig
extrafiles = cabal_extrafiles cabal -}
cinfo = genCabalInfo cabal summarymodule pkgconfig extralibs
txt = genCabalFile cinfo
TIO.writeFile cabalfile txt


-- |
buildJSONFile
:: Cabal
-> String
-> PackageConfig
-> [String] -- ^ Extra libs
-> FilePath -- ^ JSON file path
-> IO ()
buildJSONFile cabal summarymodule pkgconfig extralibs jsonfile = do
let cinfo = genCabalInfo cabal summarymodule pkgconfig extralibs
BL.writeFile jsonfile (encodePretty cinfo)
2 changes: 1 addition & 1 deletion stdcxx-gen/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ in
{ mkDerivation, base, fficxx, fficxx-runtime, stdenv, template-haskell }:
mkDerivation {
pname = "stdcxx";
version = "0.0";
version = "0.5";
src = stdcxx-src;
libraryHaskellDepends = [
base fficxx fficxx-runtime template-haskell
Expand Down

0 comments on commit 01f4c94

Please sign in to comment.