From 20bb4495a862220626fdd7d4a3fed09e33c421dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Wed, 1 Nov 2023 13:57:38 +0200 Subject: [PATCH] Added an API module to the executable spec, removed Lib --- default.nix | 13 ++++++++----- .../hs-src/cardano-ledger-executable-spec.cabal | 6 +++--- .../MAlonzo/Code/Ledger/Foreign/API.hs} | 3 +-- src/Ledger/hs-src/test/UtxowSpec.hs | 2 +- src/Makefile | 6 +++--- 5 files changed, 16 insertions(+), 14 deletions(-) rename src/Ledger/hs-src/{Lib.hs => src/MAlonzo/Code/Ledger/Foreign/API.hs} (83%) diff --git a/default.nix b/default.nix index cb355722f..bedff0290 100644 --- a/default.nix +++ b/default.nix @@ -71,7 +71,7 @@ rec { mkSpecDerivation = { project, main }: rec { docs = stdenv.mkDerivation { - pname = "docs"; + pname = "${project}-docs"; version = "0.1"; src = "${formalLedger}"; meta = { }; @@ -87,7 +87,7 @@ rec { }; html = stdenv.mkDerivation { - pname = "html"; + pname = "${project}-html"; version = "0.1"; src = "${formalLedger}"; meta = { }; @@ -103,7 +103,7 @@ rec { }; hsSrc = stdenv.mkDerivation { - pname = "hs-src"; + pname = "${project}-hs-src"; version = "0.1"; src = "${formalLedger}"; meta = { }; @@ -122,7 +122,10 @@ rec { test -n "$(find $out/haskell/ -type f -name '*.hs')" # OUT_DIR=$out make "${project}".hsTest ''; - dontInstall = true; + installPhase = '' + mv $out/haskell/${main}/* $out + rm -rf $out/haskell + ''; }; # hsDocs = stdenv.mkDerivation { @@ -144,7 +147,7 @@ rec { # dontInstall = true; # }; - hsExe = haskellPackages.callCabal2nix "${project}" "${hsSrc}/haskell/${main}" { }; + hsExe = haskellPackages.callCabal2nix "${project}" "${hsSrc}" { }; }; diff --git a/src/Ledger/hs-src/cardano-ledger-executable-spec.cabal b/src/Ledger/hs-src/cardano-ledger-executable-spec.cabal index 2d19b06b2..5866aa96d 100644 --- a/src/Ledger/hs-src/cardano-ledger-executable-spec.cabal +++ b/src/Ledger/hs-src/cardano-ledger-executable-spec.cabal @@ -47,12 +47,12 @@ test-suite test library import: globalOptions - hs-source-dirs: . - exposed-modules: - Lib + hs-source-dirs: src build-depends: text, ieee, tree-diff + exposed-modules: + MAlonzo.Code.Ledger.Foreign.API -- This will be generated automatically when building with nix other-modules: diff --git a/src/Ledger/hs-src/Lib.hs b/src/Ledger/hs-src/src/MAlonzo/Code/Ledger/Foreign/API.hs similarity index 83% rename from src/Ledger/hs-src/Lib.hs rename to src/Ledger/hs-src/src/MAlonzo/Code/Ledger/Foreign/API.hs index 2adef7629..7976bf9fe 100644 --- a/src/Ledger/hs-src/Lib.hs +++ b/src/Ledger/hs-src/src/MAlonzo/Code/Ledger/Foreign/API.hs @@ -1,8 +1,7 @@ -module Lib +module MAlonzo.Code.Ledger.Foreign.API ( module MAlonzo.Code.Ledger.Foreign.LedgerTypes , module MAlonzo.Code.Ledger.Foreign.HSLedger ) where import MAlonzo.Code.Ledger.Foreign.LedgerTypes import MAlonzo.Code.Ledger.Foreign.HSLedger - diff --git a/src/Ledger/hs-src/test/UtxowSpec.hs b/src/Ledger/hs-src/test/UtxowSpec.hs index 07199fff2..10ec239a3 100644 --- a/src/Ledger/hs-src/test/UtxowSpec.hs +++ b/src/Ledger/hs-src/test/UtxowSpec.hs @@ -7,7 +7,7 @@ import Control.Monad ( foldM ) import Test.Hspec ( Spec, describe, it ) import Test.HUnit ( (@?=) ) -import Lib +import MAlonzo.Code.Ledger.Foreign.API (.->) = (,) diff --git a/src/Makefile b/src/Makefile index 153271516..8f72da9d0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,7 @@ PRE=$(addprefix $(LATEX_DIR)/,\ PDF_DIR=$(OUT_DIR)/pdfs HTML_DIR=$(OUT_DIR)/html HS_DIR=$(OUT_DIR)/haskell -MALONZO_DIR=MAlonzo/Code +MALONZO_DIR=src/MAlonzo/Code CABAL_TEST=cabal run test LEDGER=Ledger MIDNIGHT=MidnightExample @@ -50,8 +50,8 @@ define agdaToHs = mkdir -p $(HS_DIST) cp -r $(PROJECT)/hs-src/* $(HS_DIST)/ cp $(PROJECT)/hs-src/$(CABAL_FILE) $(HS_DIST)/ - $(AGDA) --transliterate -c --ghc-dont-call-ghc --compile-dir $(HS_DIST) $< - find $(HS_DIST)/MAlonzo -name "*.hs" -print\ + $(AGDA) --transliterate -c --ghc-dont-call-ghc --compile-dir $(HS_DIST)/src $< + find $(HS_DIST)/src/MAlonzo -name "*.hs" -print\ | sed "s#^$(HS_DIST)/# #;s#\.hs##;s#/#.#g"\ >> $(HS_DIST)/$(CABAL_FILE) endef