Merge branch 'hs-bindgen-fixes' into dev

This commit is contained in:
andromeda
2026-02-12 22:28:47 +01:00
4 changed files with 37 additions and 50 deletions

38
flake.lock generated
View File

@@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1767609335, "lastModified": 1769996383,
"narHash": "sha256-feveD98mQpptwrAEggBQKJTYbvwwglSbOv53uCfH9PY=", "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "250481aafeb741edfe23d29195671c19b36b6dca", "rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -25,11 +25,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1769198512, "lastModified": 1770911191,
"narHash": "sha256-ZsQm3CwvicJBv4CMJJzRkTcYYcrghqzVabL9IehNz9k=", "narHash": "sha256-fePV3+4uHg1tQH83rUO/7gQOGexHdaxyVkO2X3HkOA0=",
"owner": "well-typed", "owner": "well-typed",
"repo": "hs-bindgen", "repo": "hs-bindgen",
"rev": "f99ed4ddfc7808b3eb28bbf089612b6a52983685", "rev": "087884c110948e7bd67bec0ae8004e5396f63241",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -41,27 +41,27 @@
"libclang-bindings-src": { "libclang-bindings-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1768982090, "lastModified": 1770274896,
"narHash": "sha256-EgM9ZJvbM0+SQ8f9P27Rnx4dY8Q1fWtGVXsRl5f0Vfk=", "narHash": "sha256-JnxJBo2L4URFD8JbpjnPG/ej/xKFe7y5ZpjnvIztwAM=",
"owner": "well-typed", "owner": "well-typed",
"repo": "libclang", "repo": "libclang",
"rev": "27f20c2e320f779314175ee3e82072fec61b8391", "rev": "155642a4a4a9f0414a058a8f08f39aa6c7bb57ed",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "well-typed", "owner": "well-typed",
"repo": "libclang", "repo": "libclang",
"rev": "27f20c2e320f779314175ee3e82072fec61b8391", "rev": "155642a4a4a9f0414a058a8f08f39aa6c7bb57ed",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1767364772, "lastModified": 1770169770,
"narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=", "narHash": "sha256-awR8qIwJxJJiOmcEGgP2KUqYmHG4v/z8XpL9z8FnT1A=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa", "rev": "aa290c9891fa4ebe88f8889e59633d20cc06a5f2",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -73,11 +73,11 @@
}, },
"nixpkgs-lib": { "nixpkgs-lib": {
"locked": { "locked": {
"lastModified": 1765674936, "lastModified": 1769909678,
"narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixpkgs.lib", "repo": "nixpkgs.lib",
"rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", "rev": "72716169fe93074c333e8d0173151350670b824c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -88,11 +88,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1765772535, "lastModified": 1770843696,
"narHash": "sha256-aq+dQoaPONOSjtFIBnAXseDm9TUhIbe215TPmkfMYww=", "narHash": "sha256-LovWTGDwXhkfCOmbgLVA10bvsi/P8eDDpRudgk68HA8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "09b8fda8959d761445f12b55f380d90375a1d6bb", "rev": "2343bbb58f99267223bc2aac4fc9ea301a155a16",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -1,4 +1,3 @@
set -x
echo "# copying header..." echo "# copying header..."
mkdir -p lib/include mkdir -p lib/include
@@ -19,33 +18,32 @@ done
echo "# creating c file from header..." echo "# creating c file from header..."
# other macro definitions should be defined with ghc-options: -copt-D in *.cabal
cat > lib/RGFW.c <<EOF cat > lib/RGFW.c <<EOF
#define RGFW_IMPLEMENTATION #define RGFW_IMPLEMENTATION
#define RGFW_OPENGL
#define RGFW_EXPORT
#include "RGFW.h" #include "RGFW.h"
EOF EOF
echo "# creating c object file..."
clang -c lib/RGFW.c -o lib/RGFW.o $CFLAGS -Ilib/include
echo "# generating library RGFW.Generated..." echo "# generating library RGFW.Generated..."
# --unsafe _unsafe \
# --pointer _pointer \
set -x
hs-bindgen-cli preprocess \ hs-bindgen-cli preprocess \
-Ilib/include \ -Ilib/include \
--parse-from-main-header-dirs \ --unique-id andromeda.hs-rgfw \
--create-output-dirs \ --create-output-dirs \
--overwrite-files \ --overwrite-files \
--single-file \
--safe _safe \
--hs-output-dir lib \ --hs-output-dir lib \
--module RGFW.Generated \ --module RGFW.Generated \
--define-macro=RGFW_OPENGL \ --define-macro=RGFW_OPENGL \
--define-macro=RGFW_EXPORT \ --define-macro=RGFW_EXPORT \
--define-macro=RGFW_IMPLEMENTATION \
$HBC_ARGS \ $HBC_ARGS \
RGFW.h RGFW.h
echo "# file tree generated:"
tree lib
set +x set +x
echo "# generated filetree:"
tree lib

View File

@@ -8,22 +8,12 @@ maintainer: Matrix @andromeda:tchncs.de
build-type: Simple build-type: Simple
extra-doc-files: README.md extra-doc-files: README.md
common warnings common warnings
ghc-options: ghc-options: -Wall
-Wall
-DRGFW_IMPLEMENTATION
-DRGFW_OPENGL
-- the following irresponsibly copy-pasted from `nix develop --command "pkg-config --libs --cflags <lots of things>`
-I/nix/store/b608h3ylrhrwpi9bc0y0014jf7j03pzl-libglvnd-1.7.0-dev/include -I/nix/store/sbhg4bnrg0l22936dbwrnl33vzd3kcmf-libx11-1.8.12-dev/include -I/nix/store/l7mab2s2kjsz2pz8dfgvh39af7w7gji1-xorgproto-2024.1/include -I/nix/store/7ys6dfy22hkm2bklwq7ll7pmby443fka-libxcursor-1.2.3-dev/include -I/nix/store/jb2w03lbwm7j01zn9qzcnnqcc1ca5dyj-libxi-1.8.2-dev/include -I/nix/store/1315vzcs2vm98pgsdzwsxm7i2mzjc0g7-libxext-1.3.6-dev/include -I/nix/store/vr2rj7zz28zvsnycx45kn6hhim0ky94z-libxfixes-6.0.2-dev/include -I/nix/store/wkrn5svcggds11pbkyjfka7b2i3wbmhj-libxrender-0.9.12-dev/include -I/nix/store/s7q5sdki2ax8gla778mbhddf5v9gk4vb-libxrandr-1.5.4-dev/include -L/nix/store/mm4v6w3wj8wi5qc6rwdrb2rkqs08whp9-libglvnd-1.7.0/lib -L/nix/store/ja09m2gfni7pqk4bsrhjb8y9cq74rspp-libx11-1.8.12/lib -L/nix/store/ldl1g8r8jfhjv4asb7zkr7ljpgk7q6dv-libxcursor-1.2.3/lib -L/nix/store/xg9763xyrnkxhvqgvxdbfiwxnmz391rx-libxi-1.8.2/lib -L/nix/store/55071y2xjibw8f317scvlg788w31k7k8-libxext-1.3.6/lib -L/nix/store/i6mb757zbagjs50kh7n9sk51f7wsr5f3-libxfixes-6.0.2/lib -L/nix/store/dgjd3hf8ny62vbjg10w64x4jwm7cv81k-libxrender-0.9.12/lib -L/nix/store/llr8wn0a3q8vfrg6i7vr2l2k66izm56a-libxrandr-1.5.4/lib -lXcursor -lXrandr -lXi -lGL -lXrender -lX11 -lXext -lXfixes
lib/RGFW.c
-fPIC
library library
import: warnings import: warnings
exposed-modules: -- hs-bindgen-cli uses --single-file flag, so no other modules
, RGFW.Generated exposed-modules: RGFW.Generated
, RGFW.Generated.FunPtr
, RGFW.Generated.Safe
, RGFW.Generated.Unsafe
build-depends: build-depends:
, base , base
, primitive , primitive
@@ -39,6 +29,10 @@ library
hs-source-dirs: lib hs-source-dirs: lib
default-language: Haskell2010 default-language: Haskell2010
default-extensions: FlexibleInstances default-extensions: FlexibleInstances
-- options for RGFW passed here
ghc-options:
-optc-DRGFW_OPENGL
-optc-DRGFW_EXPORT
c-sources: lib/RGFW.c c-sources: lib/RGFW.c
executable hs-rgfw executable hs-rgfw

View File

@@ -1,10 +1,5 @@
module Main where module Main where
import qualified Foreign.Ptr (ToFunPtr)
import qualified RGFW.Generated as RGFW
main :: IO () main :: IO ()
main = do main = do
putStrLn "Hello World" putStrLn "Hello World"
window <- toFunPtr ()