{-# LANGUAGE TemplateHaskell #-} module CodeGen.Runtime.PrintRuntime (printCRuntime) where import Data.FileEmbed (embedFile, makeRelativeToProject) import qualified Data.Text.Encoding as Txt import qualified Data.Text.IO as Txt import System.IO (IOMode (WriteMode), withFile) printCRuntime :: FilePath -> IO () printCRuntime :: FilePath -> IO () printCRuntime FilePath outputFilePath = do let runtimeFileText :: Text runtimeFileText = ByteString -> Text Txt.decodeUtf8 $(makeRelativeToProject "lib/CodeGen/Runtime/runtime.c" >>= embedFile) FilePath -> IOMode -> (Handle -> IO ()) -> IO () forall r. FilePath -> IOMode -> (Handle -> IO r) -> IO r withFile FilePath outputFilePath IOMode WriteMode ((Handle -> IO ()) -> IO ()) -> (Handle -> IO ()) -> IO () forall a b. (a -> b) -> a -> b $ \Handle handle -> do Handle -> Text -> IO () Txt.hPutStr Handle handle Text runtimeFileText