clash-shake 0.1.0 → 0.1.1
raw patch · 3 files changed
+41/−47 lines, 3 filesdep −ghc-typelits-extradep −ghc-typelits-knownnatdep −ghc-typelits-natnormalisePVP ok
version bump matches the API change (PVP)
Dependencies removed: ghc-typelits-extra, ghc-typelits-knownnat, ghc-typelits-natnormalise
API changes (from Hackage documentation)
+ Clash.Shake: toolchain :: String -> FilePath -> [String] -> Action [String]
Files
- clash-shake.cabal +1/−6
- src/Clash/Shake.hs +38/−25
- src/Clash/Shake/Xilinx.hs +2/−16
clash-shake.cabal view
@@ -3,11 +3,9 @@ -- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: 5f6e45bc2e072294d671a13e35cf938c8c9e4cfb32adee44eba24228b48bb9d6 name: clash-shake-version: 0.1.0+version: 0.1.1 synopsis: Shake rules for building Clash programs description: Shake rules for building Clash programs and synthesizing FPGA configuration. Contains build rules for Xilinx ISE and Xilinx Vivado@@ -48,9 +46,6 @@ , clash-lib >=1.4.2 && <1.5 , clash-prelude >=1.4.2 && <1.5 , directory- , ghc-typelits-extra- , ghc-typelits-knownnat- , ghc-typelits-natnormalise , shake , split , stache
src/Clash/Shake.hs view
@@ -7,6 +7,7 @@ , SynthKit(..) , binImage , useConfig+ , toolchain ) where import Development.Shake@@ -17,6 +18,7 @@ import qualified Clash.Main as Clash import Data.List.Split+import Text.Printf import qualified Data.Text as T import qualified Data.HashMap.Strict as HM@@ -46,6 +48,11 @@ hdlExt Verilog = "v" hdlExt SystemVerilog = "sv" +hdlClashFlag :: HDL -> String+hdlClashFlag VHDL = "--vhdl"+hdlClashFlag Verilog = "--verilog"+hdlClashFlag SystemVerilog = "--systemverilog"+ data ClashKit = ClashKit { clash :: [String] -> Action () , manifestSrcs :: Action [FilePath]@@ -83,34 +90,30 @@ [ map toLower clashTopName <> "_types" | hdl == VHDL ] return [ synOut </> c <.> hdlExt hdl | c <- clashSrcs ] - getSrcs <- do- outDir </> "ghc-deps.make" %> \out -> do- alwaysRerun- -- By writing to a temp file and using `copyFileChanged`,- -- we avoid spurious reruns- -- (https://stackoverflow.com/a/64277431/477476)- withTempFileWithin outDir $ \tmp -> do- clash ["-M", "-dep-suffix", "", "-dep-makefile", tmp, src]- liftIO $ removeFiles outDir [takeBaseName tmp <.> "bak"]- copyFileChanged tmp out-- return $ do- let depFile = outDir </> "ghc-deps.make"- need [depFile]- deps <- parseMakefile <$> liftIO (readFile depFile)- let isHsSource fn- | ext `elem` [".hi"] = False- | ext `elem` [".hs", ".lhs"] = True- | otherwise = error $ "Unrecognized source file: " <> fn- where- ext = takeExtension fn- hsDeps = [fn | (_, fns) <- deps, fn <- fns, isHsSource fn]- return hsDeps+ outDir </> "ghc-deps.make" %> \out -> do+ alwaysRerun+ -- By writing to a temp file and using `copyFileChanged`,+ -- we avoid spurious reruns+ -- (https://stackoverflow.com/a/64277431/477476)+ withTempFileWithin outDir $ \tmp -> do+ clash ["-M", "-dep-suffix", "", "-dep-makefile", tmp, src]+ liftIO $ removeFiles outDir [takeBaseName tmp <.> "bak"]+ copyFileChanged tmp out manifestFile %> \_out -> do- need =<< getSrcs+ let depFile = outDir </> "ghc-deps.make"+ need [depFile]+ deps <- parseMakefile <$> liftIO (readFile depFile)+ let isHsSource fn+ | ext `elem` [".hi"] = False+ | ext `elem` [".hs", ".lhs"] = True+ | otherwise = error $ "Unrecognized source file: " <> fn+ where+ ext = takeExtension fn+ hsDeps = [fn | (_, fns) <- deps, fn <- fns, isHsSource fn]+ need hsDeps extraGenerated- clash [case hdl of { VHDL -> "--vhdl"; Verilog -> "--verilog"; SystemVerilog -> "--systemverilog" }, src]+ clash [hdlClashFlag hdl, src] return ClashKit{..} @@ -150,3 +153,13 @@ isModuleName :: String -> Bool isModuleName = all (isUpper . head) . splitOn "."++toolchain :: String -> FilePath -> [String] -> Action [String]+toolchain name tool args = do+ wrap <- getConfig name+ root <- getConfig $ name <> "_ROOT"+ let exe = case (wrap, root) of+ (Just wrap, _) -> [wrap, tool]+ (Nothing, Just root) -> [root </> tool]+ (Nothing, Nothing) -> error $ printf "%s or %s must be set in build.mk" (name <> "_ROOT") name+ return $ exe ++ args
src/Clash/Shake/Xilinx.hs view
@@ -49,14 +49,7 @@ let projectName = topName rootDir = joinPath . map (const "..") . splitPath $ outDir - let ise tool args = do- root <- getConfig "ISE_ROOT"- wrap <- getConfig "ISE"- let exe = case (wrap, root) of- (Just wrap, _) -> [wrap, tool]- (Nothing, Just root) -> [root </> "ISE/bin/lin64" </> tool]- (Nothing, Nothing) -> error "ISE_ROOT or ISE must be set in build.mk"- cmd_ (Cwd outDir) exe args+ let ise tool args = cmd_ (Cwd outDir) =<< toolchain "ISE" tool args let getFiles dir pats = getDirectoryFiles srcDir [ dir </> pat | pat <- pats ] hdlSrcs = getFiles "src-hdl" ["*.vhdl", "*.v", "*.ucf" ]@@ -114,14 +107,7 @@ xpr = projectDir </> projectName <.> "xpr" rootDir = joinPath . map (const "..") . splitPath $ outDir - let vivado tool args = do- root <- getConfig "VIVADO_ROOT"- wrap <- getConfig "VIVADO"- let exe = case (wrap, root) of- (Just wrap, _) -> [wrap, tool]- (Nothing, Just root) -> [root </> "bin" </> tool]- (Nothing, Nothing) -> error "VIVADO_ROOT or VIVADO must be set in build.mk"- cmd_ (Cwd outDir) exe args+ let vivado tool args = cmd_ (Cwd outDir) =<< toolchain "VIVADO" tool args vivadoBatch tcl = do need [outDir </> tcl] vivado "vivado"