Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an API module to the executable spec, removed Lib #270

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
cRet=$(echo "$closure" | tr '\n' ' ')
echo "derivation=$dRet" >> $GITHUB_OUTPUT
echo "closure=$cRet" >> $GITHUB_OUTPUT
rsync -r --exclude={'**/nix-support','**/lib'} outputs/ledger*/* docs/
rsync -r --exclude={'**/nix-support','**/lib'} outputs/ledger*/* docs/ledger/

- name: Build midnight
id: midnight
Expand All @@ -100,7 +100,7 @@ jobs:
cRet=$(echo "$closure" | tr '\n' ' ')
echo "derivation=$dRet" >> $GITHUB_OUTPUT
echo "closure=$cRet" >> $GITHUB_OUTPUT
rsync -r --exclude={'**/nix-support','**/lib'} outputs/midnight*/* docs/
rsync -r --exclude={'**/nix-support','**/lib'} outputs/midnight*/* docs/midnight/

- name: Export all derivations
id: export-derivations
Expand Down
13 changes: 8 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ rec {

mkSpecDerivation = { project, main }: rec {
docs = stdenv.mkDerivation {
pname = "docs";
pname = "${project}-docs";
version = "0.1";
src = "${formalLedger}";
meta = { };
Expand All @@ -87,7 +87,7 @@ rec {
};

html = stdenv.mkDerivation {
pname = "html";
pname = "${project}-html";
version = "0.1";
src = "${formalLedger}";
meta = { };
Expand All @@ -103,7 +103,7 @@ rec {
};

hsSrc = stdenv.mkDerivation {
pname = "hs-src";
pname = "${project}-hs-src";
version = "0.1";
src = "${formalLedger}";
meta = { };
Expand All @@ -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
'';
Comment on lines +125 to +128
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: we now have to be careful not to generate both Ledger and MidnightExample under the same directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean by that, Nix has different outputs for midnight and ledger, so that shouldn't ever happen

Copy link
Collaborator

@omelkonian omelkonian Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c.f. build.yml, where we call nix-build twice (once for Ledger and once for MidnightExample but then rsync their output folders under a common docs/ folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yeah, that's going to cause problems

};

# hsDocs = stdenv.mkDerivation {
Expand All @@ -144,7 +147,7 @@ rec {
# dontInstall = true;
# };

hsExe = haskellPackages.callCabal2nix "${project}" "${hsSrc}/haskell/${main}" { };
hsExe = haskellPackages.callCabal2nix "${project}" "${hsSrc}" { };

};

Expand Down
6 changes: 3 additions & 3 deletions src/Ledger/hs-src/cardano-ledger-executable-spec.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion src/Ledger/hs-src/test/UtxowSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

(.->) = (,)

Expand Down
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down