use upstream fix to avoid header patching hack...
bump - no tag for libclang and alpha1 leads to build errors drop dep argh, unrelated breaking change, and bad names exts
This commit is contained in:
parent
b5fd53b5ec
commit
7ca469a62d
15
flake.lock
generated
15
flake.lock
generated
@ -527,17 +527,17 @@
|
|||||||
"hs-bindgen-src": {
|
"hs-bindgen-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1773399083,
|
"lastModified": 1774599157,
|
||||||
"narHash": "sha256-oF6E1/zRZ4iiZs9QjtQMvHnLMfq/W6CXOX44QbDGYXs=",
|
"narHash": "sha256-jgV67xhWzxMwyiyy5RPtu+VQvGTt+FoMXCWJcZ7lczY=",
|
||||||
"owner": "well-typed",
|
"owner": "well-typed",
|
||||||
"repo": "hs-bindgen",
|
"repo": "hs-bindgen",
|
||||||
"rev": "6ca94188abd756a1fb4dd8a4037de3fa7dca0765",
|
"rev": "3c4af10590d0d09e825a9735e9a03d7f60914e21",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "well-typed",
|
"owner": "well-typed",
|
||||||
|
"ref": "release-0.1-alpha2",
|
||||||
"repo": "hs-bindgen",
|
"repo": "hs-bindgen",
|
||||||
"rev": "6ca94188abd756a1fb4dd8a4037de3fa7dca0765",
|
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -561,17 +561,16 @@
|
|||||||
"libclang-src": {
|
"libclang-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1773221966,
|
"lastModified": 1774600891,
|
||||||
"narHash": "sha256-VPG7jKdq2g/Hwf5cPiy4coAvLULxDeA4KHCVkNSSs5w=",
|
"narHash": "sha256-LTAyNMY4Vu0vPeEq2wXB0KWY4kGtqtHTRmADjLdkv78=",
|
||||||
"owner": "well-typed",
|
"owner": "well-typed",
|
||||||
"repo": "libclang",
|
"repo": "libclang",
|
||||||
"rev": "d6e482df49b88375cf3075928a78ee86c2a068d4",
|
"rev": "1054474fae403bfb52c7919680cac03d3d3d4237",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "well-typed",
|
"owner": "well-typed",
|
||||||
"repo": "libclang",
|
"repo": "libclang",
|
||||||
"rev": "d6e482df49b88375cf3075928a78ee86c2a068d4",
|
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
nix-haskell.url = "github:reflex-frp/nix-haskell";
|
nix-haskell.url = "github:reflex-frp/nix-haskell";
|
||||||
nixpkgs.follows = "nix-haskell/nixpkgs";
|
nixpkgs.follows = "nix-haskell/nixpkgs";
|
||||||
hls-src = { url = "github:haskell/haskell-language-server/2.13.0.0"; flake = false; };
|
hls-src = { url = "github:haskell/haskell-language-server/2.13.0.0"; flake = false; };
|
||||||
hs-bindgen-src = { url = "github:well-typed/hs-bindgen/6ca94188abd756a1fb4dd8a4037de3fa7dca0765"; flake = false; };
|
hs-bindgen-src = { url = "github:well-typed/hs-bindgen/release-0.1-alpha2"; flake = false; };
|
||||||
libclang-src = { url = "github:well-typed/libclang/d6e482df49b88375cf3075928a78ee86c2a068d4"; flake = false; };
|
libclang-src = { url = "github:well-typed/libclang"; flake = false; };
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
crane.url = "github:ipetkov/crane";
|
crane.url = "github:ipetkov/crane";
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
|
|||||||
@ -46,7 +46,6 @@ library
|
|||||||
base,
|
base,
|
||||||
hs-bindgen,
|
hs-bindgen,
|
||||||
hs-bindgen-runtime,
|
hs-bindgen-runtime,
|
||||||
primitive,
|
|
||||||
template-haskell,
|
template-haskell,
|
||||||
|
|
||||||
executable garnet
|
executable garnet
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
{-# LANGUAGE CApiFFI #-}
|
{-# LANGUAGE CApiFFI #-}
|
||||||
{-# LANGUAGE DerivingVia #-}
|
{-# LANGUAGE DerivingVia #-}
|
||||||
{-# LANGUAGE FieldSelectors #-}
|
|
||||||
{-# LANGUAGE MagicHash #-}
|
{-# LANGUAGE MagicHash #-}
|
||||||
{-# LANGUAGE PatternSynonyms #-}
|
{-# LANGUAGE PatternSynonyms #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
@ -42,7 +41,7 @@ do
|
|||||||
withHsBindgen
|
withHsBindgen
|
||||||
def
|
def
|
||||||
{ clang = def{extraIncludeDirs = Pkg "rust/target/debug" : systemDirs}
|
{ clang = def{extraIncludeDirs = Pkg "rust/target/debug" : systemDirs}
|
||||||
, fieldNamingStrategy = EnableRecordDot
|
, fieldNamingStrategy = OmitFieldPrefixes
|
||||||
}
|
}
|
||||||
def
|
def
|
||||||
$ hashInclude "garnet_rs.h"
|
$ hashInclude "garnet_rs.h"
|
||||||
|
|||||||
@ -34,8 +34,8 @@ data Shape
|
|||||||
| Rectangle CDouble CDouble
|
| Rectangle CDouble CDouble
|
||||||
convertShape :: Shape -> Raw.Shape
|
convertShape :: Shape -> Raw.Shape
|
||||||
convertShape = \case
|
convertShape = \case
|
||||||
Circle r -> Raw.Shape Raw.Circle $ Raw.set_shape_body_circle $ Raw.Circle_Body r
|
Circle r -> Raw.Shape Raw.Circle $ Raw.set_shape_circle_circle $ Raw.Circle_Body r
|
||||||
Rectangle w h -> Raw.Shape Raw.Rectangle $ Raw.set_shape_body_rectangle $ Raw.Rectangle_Body w h
|
Rectangle w h -> Raw.Shape Raw.Rectangle $ Raw.set_shape_circle_rectangle $ Raw.Rectangle_Body w h
|
||||||
|
|
||||||
data BTree a
|
data BTree a
|
||||||
= Leaf a
|
= Leaf a
|
||||||
@ -43,14 +43,14 @@ data BTree a
|
|||||||
withBTree :: BTree Int64 -> (Raw.BTreeC -> IO a) -> IO a
|
withBTree :: BTree Int64 -> (Raw.BTreeC -> IO a) -> IO a
|
||||||
withBTree =
|
withBTree =
|
||||||
runContT . fix \f -> \case
|
runContT . fix \f -> \case
|
||||||
Leaf v -> pure $ Raw.BTreeC Raw.Leaf $ Raw.set_bTreeC_body_leaf $ Raw.Leaf_Body v
|
Leaf v -> pure $ Raw.BTreeC Raw.Leaf $ Raw.set_bTreeC_leaf_leaf $ Raw.Leaf_Body v
|
||||||
Fork l r -> do
|
Fork l r -> do
|
||||||
lRaw <- f l
|
lRaw <- f l
|
||||||
rRaw <- f r
|
rRaw <- f r
|
||||||
lPtr <- ContT alloca
|
lPtr <- ContT alloca
|
||||||
rPtr <- ContT alloca
|
rPtr <- ContT alloca
|
||||||
lift $ poke lPtr lRaw >> poke rPtr rRaw
|
lift $ poke lPtr lRaw >> poke rPtr rRaw
|
||||||
pure . Raw.BTreeC Raw.Fork . Raw.set_bTreeC_body_fork $
|
pure . Raw.BTreeC Raw.Fork . Raw.set_bTreeC_leaf_fork $
|
||||||
Raw.Fork_Body (unsafeFromPtr lPtr) (unsafeFromPtr rPtr)
|
Raw.Fork_Body (unsafeFromPtr lPtr) (unsafeFromPtr rPtr)
|
||||||
|
|
||||||
hello :: ByteString -> IO ()
|
hello :: ByteString -> IO ()
|
||||||
|
|||||||
@ -13,31 +13,15 @@ fn main() {
|
|||||||
.generate()
|
.generate()
|
||||||
.expect("Unable to generate bindings");
|
.expect("Unable to generate bindings");
|
||||||
|
|
||||||
// TODO vibe-coded workaround for hs-bindgen issue:
|
|
||||||
// https://github.com/well-typed/hs-bindgen/issues/1649#issuecomment-3994425922
|
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
bindings.write(&mut buf);
|
bindings.write(&mut buf);
|
||||||
let header = String::from_utf8(buf).unwrap();
|
let header = String::from_utf8(buf).unwrap();
|
||||||
let mut patched = String::new();
|
|
||||||
let mut saw_union = false;
|
|
||||||
for line in header.lines() {
|
|
||||||
if line == " };" && saw_union {
|
|
||||||
patched.push_str(" } body;\n");
|
|
||||||
saw_union = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if line == " union {" {
|
|
||||||
saw_union = true;
|
|
||||||
}
|
|
||||||
patched.push_str(line);
|
|
||||||
patched.push('\n');
|
|
||||||
}
|
|
||||||
fs::write(
|
fs::write(
|
||||||
PathBuf::from(&crate_dir)
|
PathBuf::from(&crate_dir)
|
||||||
.join("target")
|
.join("target")
|
||||||
.join(&profile)
|
.join(&profile)
|
||||||
.join("garnet_rs.h"),
|
.join("garnet_rs.h"),
|
||||||
patched,
|
header,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user