From aee1314a3c7b533680a537de1dc3056ea1b3d421 Mon Sep 17 00:00:00 2001 From: dopamane Date: Wed, 12 Jun 2024 10:45:26 -0700 Subject: [PATCH] Add pcf to data-files --- bayeux.cabal | 4 ++++ {exe => data}/FiatLux.pcf | 0 {exe => data}/RgbCounter.pcf | 0 {exe => data}/RgbCycle.pcf | 0 lib/Bayeux.hs | 8 +++++--- lib/Bayeux/Flow.hs | 4 ++-- 6 files changed, 11 insertions(+), 5 deletions(-) rename {exe => data}/FiatLux.pcf (100%) rename {exe => data}/RgbCounter.pcf (100%) rename {exe => data}/RgbCycle.pcf (100%) diff --git a/bayeux.cabal b/bayeux.cabal index 8195c33..b7f1649 100644 --- a/bayeux.cabal +++ b/bayeux.cabal @@ -10,6 +10,7 @@ copyright: David Cox category: Language build-type: Simple extra-doc-files: CHANGELOG.md +data-files: data/**/*.pcf library ghc-options: -Wall @@ -20,8 +21,11 @@ library , Bayeux.RgbCounter , Bayeux.Rtlil , Bayeux.Tableaux + other-modules: Paths_bayeux + autogen-modules: Paths_bayeux build-depends: base , containers + , filepath , megaparsec , mtl , parser-combinators diff --git a/exe/FiatLux.pcf b/data/FiatLux.pcf similarity index 100% rename from exe/FiatLux.pcf rename to data/FiatLux.pcf diff --git a/exe/RgbCounter.pcf b/data/RgbCounter.pcf similarity index 100% rename from exe/RgbCounter.pcf rename to data/RgbCounter.pcf diff --git a/exe/RgbCycle.pcf b/data/RgbCycle.pcf similarity index 100% rename from exe/RgbCycle.pcf rename to data/RgbCycle.pcf diff --git a/lib/Bayeux.hs b/lib/Bayeux.hs index 10473e0..04a7552 100644 --- a/lib/Bayeux.hs +++ b/lib/Bayeux.hs @@ -13,14 +13,16 @@ import Data.Maybe import qualified Data.Text as T import qualified Data.Text.IO as TIO import qualified Data.Set as S +import Paths_bayeux +import System.FilePath import Text.Megaparsec hiding (parse) app :: Cli -> IO () app = \case CliDemo demo iceprog -> case demo of - FiatLux -> flow iceprog "FiatLux" "exe/FiatLux.pcf" fiatLux - RgbCounter -> flow iceprog "RgbCounter" "exe/RgbCounter.pcf" rgbCounter - RgbCycle -> flow iceprog "RgbCycle" "exe/RgbCycle.pcf" rgbCycle + FiatLux -> flow iceprog "FiatLux" fiatLux =<< getDataFileName ("data" "FiatLux" <.> "pcf") + RgbCounter -> flow iceprog "RgbCounter" rgbCounter =<< getDataFileName ("data" "RgbCounter" <.> "pcf") + RgbCycle -> flow iceprog "RgbCycle" rgbCycle =<< getDataFileName ("data" "RgbCycle" <.> "pcf") CliProve cli -> do lp <- fromJust <$> case input cli of FileInput f -> parseMaybe (parse <* eof) <$> TIO.readFile f diff --git a/lib/Bayeux/Flow.hs b/lib/Bayeux/Flow.hs index 2d6a65b..3105b2f 100644 --- a/lib/Bayeux/Flow.hs +++ b/lib/Bayeux/Flow.hs @@ -10,8 +10,8 @@ import qualified Data.Text.IO as TIO import Prettyprinter import Prettyprinter.Render.Text -flow :: Bool -> String -> FilePath -> File -> IO () -flow prog name pcfFile designFile = shake shakeOptions{ shakeFiles = "_build" name } $ do +flow :: Bool -> String -> File -> FilePath -> IO () +flow prog name designFile pcfFile = shake shakeOptions{ shakeFiles = "_build" name } $ do want $ if prog then ["prog"]