Skip to content

Commit adbe1c7

Browse files
committed
Add pull-cddls
1 parent 699aab4 commit adbe1c7

File tree

3 files changed

+99
-2
lines changed

3 files changed

+99
-2
lines changed

cabal.project

+30
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,33 @@ if impl (ghc >= 9.12)
7272
, ouroboros-network-api:base
7373
, network-mux:base
7474
, ouroboros-network:base
75+
76+
source-repository-package
77+
type: git
78+
location: https://github.com/IntersectMBO/cardano-ledger
79+
tag: 0540540858ced73be648669182729a59e4d9bb1b
80+
subdir:
81+
eras/allegra/impl
82+
eras/alonzo/impl
83+
eras/alonzo/test-suite
84+
eras/babbage/impl
85+
eras/babbage/test-suite
86+
eras/conway/impl
87+
eras/conway/test-suite
88+
eras/mary/impl
89+
eras/shelley/impl
90+
eras/shelley/test-suite
91+
eras/shelley-ma/test-suite
92+
libs/cardano-ledger-api
93+
libs/cardano-ledger-core
94+
libs/cardano-ledger-binary
95+
libs/cardano-protocol-tpraos
96+
libs/non-integral
97+
libs/small-steps
98+
libs/cardano-data
99+
libs/set-algebra
100+
libs/vector-map
101+
eras/byron/chain/executable-spec
102+
eras/byron/ledger/executable-spec
103+
eras/byron/ledger/impl
104+
eras/byron/crypto
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
-- |
2+
3+
module Main (main) where
4+
5+
import qualified Data.ByteString.Lazy as BL
6+
import qualified Data.ByteString.Lazy.UTF8 as BL8
7+
import qualified Test.Cardano.Ledger.Allegra.Binary.Cddl as Allegra
8+
import qualified Test.Cardano.Ledger.Alonzo.Binary.Cddl as Alonzo
9+
import qualified Test.Cardano.Ledger.Babbage.Binary.Cddl as Babbage
10+
import qualified Paths_cardano_ledger_byron as Byron
11+
import qualified Test.Cardano.Ledger.Conway.Binary.Cddl as Conway
12+
import qualified Test.Cardano.Ledger.Mary.Binary.Cddl as Mary
13+
import qualified Test.Cardano.Ledger.Shelley.Binary.Cddl as Shelley
14+
import qualified Data.List as L
15+
import qualified System.Process.ByteString.Lazy as P
16+
import qualified System.Environment as E
17+
import qualified System.FilePath as F
18+
19+
main :: IO ()
20+
main = do
21+
byron <- forwardize . (:[]) <$> Byron.getDataFileName "cddl-spec/byron.cddl"
22+
shelley <- forwardize <$> Shelley.readShelleyCddlFileNames
23+
allegra <- forwardize <$> Allegra.readAllegraCddlFileNames
24+
mary <- forwardize <$> Mary.readMaryCddlFileNames
25+
alonzo <- forwardize <$> Alonzo.readAlonzoCddlFileNames
26+
babbage <- forwardize <$> Babbage.readBabbageCddlFileNames
27+
conway <- forwardize <$> Conway.readConwayCddlFileNames
28+
29+
let include_path = mconcat $ L.intersperse ":" $ [byron, shelley, allegra, mary, alonzo, babbage, conway]
30+
E.setEnv "CDDL_INCLUDE_PATH" (include_path <> ":")
31+
32+
putStrLn . BL8.toString =<< cddlc "ouroboros-consensus-cardano/cddl/disk/block.cddl"
33+
where
34+
forwardize [x] =
35+
let f = [ if c /= '\\' then c else '/' | c <- F.takeDirectory x ]
36+
in if "C:" `L.isPrefixOf` f
37+
then drop 2 f
38+
else f
39+
forwardize x = error $ "match: " <> show x
40+
41+
42+
-- | A 'CDDL' specifcation for a protocol 'ps'.
43+
--
44+
-- newtype CDDLSpec ps = CDDLSpec BL.ByteString
45+
46+
cddlc :: FilePath -> IO BL.ByteString
47+
cddlc path = do
48+
(_, cddl, err) <- P.readProcessWithExitCode "ruby" ["C:/msys64/clang64/bin/cddlc", "-u", "-2", "-t", "cddl", path] mempty
49+
putStrLn $ BL8.toString err
50+
return cddl

ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal

+19-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ library unstable-byron-testlib
229229
cardano-binary,
230230
cardano-crypto,
231231
cardano-crypto-class,
232-
cardano-crypto-test,
233-
cardano-crypto-wrapper,
232+
cardano-crypto-wrapper:{cardano-crypto-wrapper, testlib},
234233
cardano-ledger-binary:{cardano-ledger-binary, testlib},
235234
cardano-ledger-byron,
236235
cardano-ledger-byron-test,
@@ -702,3 +701,21 @@ executable gen-header
702701

703702
autogen-modules:
704703
Paths_ouroboros_consensus_cardano
704+
705+
executable pull-cddls
706+
import: common-exe
707+
hs-source-dirs: cddl
708+
main-is: pull-cddls.hs
709+
build-depends:
710+
base,
711+
bytestring,
712+
cardano-ledger-allegra:testlib,
713+
cardano-ledger-alonzo:testlib,
714+
cardano-ledger-babbage:testlib,
715+
cardano-ledger-byron:testlib,
716+
cardano-ledger-conway:testlib,
717+
cardano-ledger-mary:testlib,
718+
cardano-ledger-shelley:testlib,
719+
process-extras,
720+
utf8-string,
721+
filepath,

0 commit comments

Comments
 (0)