51 lines
1.6 KiB
Haskell
Raw Normal View History

{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FieldSelectors #-}
2026-02-20 09:09:12 +00:00
-- {-# LANGUAGE NoFieldSelectors #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}
module GarnetRs.Raw where
-- TODO this causes HLS to panic, and isn't yet supported by Ormolu/Fourmolu
-- {-# LANGUAGE ExplicitLevelImports #-}
-- import HsBindgen.Runtime.LibC qualified
-- import splice Data.List
-- import splice Data.Tuple.Extra
-- import splice HsBindgen.TH
-- import splice Language.Haskell.TH
-- import splice System.Process
-- import splice Prelude
import Data.List
import Data.Text qualified as T
import Data.Tuple.Extra
import HsBindgen.Runtime.LibC qualified
import HsBindgen.TH
import Language.Haskell.TH
import System.Process
do
systemDirs <- -- TODO bit of a hack
map (Dir . T.unpack . T.strip)
. concatMap (takeWhile (maybe False ((== ' ') . fst) . T.uncons) . dropWhile T.null . T.lines)
. drop 1
. T.splitOn "search starts here:"
. T.pack
. thd3
<$> runIO (readProcessWithExitCode "cpp" ["-v"] "")
withHsBindgen
def
{ clang = def{extraIncludeDirs = Pkg "rust" : systemDirs}
2026-02-20 09:09:12 +00:00
-- hmm, I guess there's a reason this wasn't exported
-- , fieldNamingStrategy = EnableRecordDot
, fieldNamingStrategy = PrefixedFieldNames
}
def
$ hashInclude "garnet_rs.h"