From a018cc389a258ef48fde798a4048e199cdf94d86 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Fri, 20 Feb 2026 09:53:12 +0000 Subject: [PATCH] Generate header in Rust build output directory --- generate-bindings | 4 +-- lib/GarnetRs/Raw.hs | 2 +- rust/garnet_rs.h | 63 --------------------------------------------- 3 files changed, 3 insertions(+), 66 deletions(-) delete mode 100644 rust/garnet_rs.h diff --git a/generate-bindings b/generate-bindings index 9b627b3..9f20e90 100755 --- a/generate-bindings +++ b/generate-bindings @@ -19,7 +19,7 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" RUST_DIR="$SCRIPT_DIR/rust" HEADER_NAME="garnet_rs.h" -HEADER="$RUST_DIR/$HEADER_NAME" +HEADER="$RUST_DIR/target/debug/$HEADER_NAME" # --- Step 1: Build Rust static library --- echo "=== Building Rust library ===" @@ -66,7 +66,7 @@ echo " Patched header at $HEADER" echo "=== Configuring Cabal ===" cabal configure \ --extra-lib-dirs="$RUST_DIR/target/debug" \ - --extra-include-dirs="$RUST_DIR" + --extra-include-dirs="$RUST_DIR/target/debug" echo "=== Done ===" echo "Run 'cabal run' to test." diff --git a/lib/GarnetRs/Raw.hs b/lib/GarnetRs/Raw.hs index c1344f1..6344ff2 100644 --- a/lib/GarnetRs/Raw.hs +++ b/lib/GarnetRs/Raw.hs @@ -40,7 +40,7 @@ do <$> runIO (readProcessWithExitCode "cpp" ["-v"] "") withHsBindgen def - { clang = def{extraIncludeDirs = Pkg "rust" : systemDirs} + { clang = def{extraIncludeDirs = Pkg "rust/target/debug" : systemDirs} } def $ hashInclude "garnet_rs.h" diff --git a/rust/garnet_rs.h b/rust/garnet_rs.h deleted file mode 100644 index 4635124..0000000 --- a/rust/garnet_rs.h +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include -#include -#include - -struct T { - bool a; - uint8_t b; -}; - -enum Shape_Tag { - Circle, - Rectangle, -}; - -struct Circle_Body { - double radius; -}; - -struct Rectangle_Body { - double width; - double height; -}; - -struct Shape { - enum Shape_Tag tag; - union { - struct Circle_Body circle; - struct Rectangle_Body rectangle; - } body; -}; - -enum BTreeC_Tag { - Leaf, - Fork, -}; - -struct Leaf_Body { - int64_t value; -}; - -struct Fork_Body { - const struct BTreeC *left; - const struct BTreeC *right; -}; - -struct BTreeC { - enum BTreeC_Tag tag; - union { - struct Leaf_Body leaf; - struct Fork_Body fork; - } body; -}; - -void hello(const char *c); - -void hello_struct(struct T t); - -void hello_shape(struct Shape s); - -__attribute__((const)) int64_t add(int64_t a, int64_t b); - -int64_t sum_tree(struct BTreeC t);