15 Commits

Author SHA1 Message Date
andromeda
2b84809d84 build error 2026-01-31 13:18:14 +01:00
andromeda
4858c3ee2e bump hs-bindgen 2026-01-24 19:26:30 +01:00
andromeda
8583f117cc fix error in README.md 2026-01-24 18:57:13 +01:00
andromeda
3d72958712 Merge branch 'master' into nix-err-date-not-found 2026-01-24 18:55:00 +01:00
andromeda
371d2b7f97 builds! 2026-01-24 18:49:56 +01:00
mtgmonkey
93bee37b83 key callbacks, tidy 2025-12-16 11:14:40 +01:00
mtgmonkey
d36bbad5a8 tidy up, submodule RGFW 2025-12-16 01:12:02 +01:00
mtgmonkey
5a701a3632 [feat] unify with example, actually win for once 2025-12-16 00:24:10 +01:00
mtgmonkey
170685f6c8 remove extra files 2025-12-11 23:03:15 +01:00
mtgmonkey
82961432f9 remove Wayland; couldn't figure out 2025-12-11 22:49:07 +01:00
mtgmonkey
15c587d65a remove assertion of Semantic Versioning - Cabal is annoying 2025-12-11 18:19:51 +01:00
mtgmonkey
7cfdb25174 fix typo in CHANGELOG.md 2025-12-11 18:17:08 +01:00
mtgmonkey
8a16c6695e basic functionality on Wayland and X11 2025-12-11 18:15:32 +01:00
mtgmonkey
ab69702910 add library as git submodule, wayland, window shows 2025-12-10 21:12:56 +01:00
mtgmonkey
5e2d2b89c8 init 2025-12-09 22:18:41 +01:00
8 changed files with 101 additions and 28 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
lib
include
result*
dist-newstyle

View File

@@ -1,2 +1,3 @@
`nix build` or `nix run` to build lib or run the example
to do it manually, run `./generate.sh` to generate `lib/` before `cabal build` or `cabal run`

View File

@@ -4,10 +4,10 @@ packages:
source-repository-package
type: git
location: https://github.com/well-typed/hs-bindgen.git
tag: 933d11d771ff13b6a3b851cb0ec9bc3632626f2f
tag: f99ed4ddfc7808b3eb28bbf089612b6a52983685
subdir: hs-bindgen-runtime
source-repository-package
type: git
location: https://github.com/well-typed/hs-bindgen.git
tag: 933d11d771ff13b6a3b851cb0ec9bc3632626f2f
tag: f99ed4ddfc7808b3eb28bbf089612b6a52983685
subdir: c-expr-runtime

32
flake.lock generated
View File

@@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"lastModified": 1767609335,
"narHash": "sha256-feveD98mQpptwrAEggBQKJTYbvwwglSbOv53uCfH9PY=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"rev": "250481aafeb741edfe23d29195671c19b36b6dca",
"type": "github"
},
"original": {
@@ -25,43 +25,43 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1765888948,
"narHash": "sha256-rgGAUQVfJ0sKXm9bzh7XIJUHh/JkEsz/LX6k8aCKeD4=",
"lastModified": 1769198512,
"narHash": "sha256-ZsQm3CwvicJBv4CMJJzRkTcYYcrghqzVabL9IehNz9k=",
"owner": "well-typed",
"repo": "hs-bindgen",
"rev": "fd74e8fa4216eccd67069ec9d8637b57000ffc83",
"rev": "f99ed4ddfc7808b3eb28bbf089612b6a52983685",
"type": "github"
},
"original": {
"owner": "well-typed",
"repo": "hs-bindgen",
"rev": "fd74e8fa4216eccd67069ec9d8637b57000ffc83",
"type": "github"
}
},
"libclang-bindings-src": {
"flake": false,
"locked": {
"lastModified": 1765293798,
"narHash": "sha256-fZvyZo5emD1W5LwrIg2zTUYE9StRh3xF8TcuXjzKIAk=",
"lastModified": 1768982090,
"narHash": "sha256-EgM9ZJvbM0+SQ8f9P27Rnx4dY8Q1fWtGVXsRl5f0Vfk=",
"owner": "well-typed",
"repo": "libclang",
"rev": "b8305bd9c3e8e8f63d6f415553388be7f233ef45",
"rev": "27f20c2e320f779314175ee3e82072fec61b8391",
"type": "github"
},
"original": {
"owner": "well-typed",
"repo": "libclang",
"rev": "27f20c2e320f779314175ee3e82072fec61b8391",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1764947035,
"narHash": "sha256-EYHSjVM4Ox4lvCXUMiKKs2vETUSL5mx+J2FfutM7T9w=",
"lastModified": 1767364772,
"narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a672be65651c80d3f592a89b3945466584a22069",
"rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa",
"type": "github"
},
"original": {
@@ -73,11 +73,11 @@
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1761765539,
"narHash": "sha256-b0yj6kfvO8ApcSE+QmA6mUfu8IYG6/uU28OFn4PaC8M=",
"lastModified": 1765674936,
"narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "719359f4562934ae99f5443f20aa06c2ffff91fc",
"rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85",
"type": "github"
},
"original": {

View File

@@ -1,7 +1,7 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
hs-bindgen.url = "github:well-typed/hs-bindgen/fd74e8fa4216eccd67069ec9d8637b57000ffc83";
hs-bindgen.url = "github:well-typed/hs-bindgen";
self.submodules = true;
};
outputs = {
@@ -26,7 +26,9 @@
libXi,
xrandr,
# shell deps
clang,
hs-bindgen-cli,
tree,
}:
mkDerivation {
pname = "hs-rgfw";
@@ -44,9 +46,9 @@
libXi
xrandr
];
preBuild = ''
preConfigure = ''
set -x
export PATH=${hs-bindgen-cli}/bin:\$PATH
export PATH=${clang}/bin:${hs-bindgen-cli}/bin:${tree}/bin:$PATH
./generate.sh
set +x
'';

View File

@@ -1,8 +1,51 @@
set -x
echo "# copying header..."
mkdir -p lib/include
cp rgfw/RGFW.h lib/include/RGFW.h
echo "# creating flags for hs-bindgen-cli..."
export CFLAGS=$(pkg-config --cflags x11 xcursor xrandr xi gl xrender xext xfixes)
HBC_ARGS=""
for token in $CFLAGS; do
case "$token" in
-I* ) HBC_ARGS="$HBC_ARGS $token" ;;
-D* ) HBC_ARGS="$HBC_ARGS --define-macro ${token#-D}" ;;
* ) HBC_ARGS="$HBC_ARGS --clang-option $token" ;;
esac
done
echo "# creating c file from header..."
cat > lib/RGFW.c <<EOF
#define RGFW_IMPLEMENTATION
#define RGFW_OPENGL
#define RGFW_EXPORT
#include "RGFW.h"
EOF
echo "# creating c object file..."
clang -c lib/RGFW.c -o lib/RGFW.o $CFLAGS -Ilib/include
echo "# generating library RGFW.Generated..."
hs-bindgen-cli preprocess \
-Irgfw \
-Ilib/include \
--parse-from-main-header-dirs \
--create-output-dirs \
--overwrite-files \
--hs-output-dir lib \
--module RGFW.Generated \
--clang-option=-DRGFW_OPENGL \
--define-macro=RGFW_OPENGL \
--define-macro=RGFW_EXPORT \
--define-macro=RGFW_IMPLEMENTATION \
$HBC_ARGS \
RGFW.h
echo "# file tree generated:"
tree lib
set +x

View File

@@ -8,19 +8,38 @@ maintainer: Matrix @andromeda:tchncs.de
build-type: Simple
extra-doc-files: README.md
common warnings
ghc-options: -Wall
ghc-options:
-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
import: warnings
exposed-modules: RGFW.Generated
exposed-modules:
, RGFW.Generated
, RGFW.Generated.FunPtr
, RGFW.Generated.Safe
, RGFW.Generated.Unsafe
build-depends:
, base
, primitive
, c-expr-runtime
, hs-bindgen-runtime
include-dirs: rgfw
pkgconfig-depends:
, gl
, x11
, xcursor
, xrandr
, xi
include-dirs: lib/include
hs-source-dirs: lib
default-language: Haskell2010
default-extensions: FlexibleInstances
c-sources: lib/RGFW.c
executable hs-rgfw
import: warnings
@@ -36,6 +55,6 @@ executable hs-rgfw
, xcursor
, xrandr
, xi
include-dirs: rgfw
include-dirs: lib/include
hs-source-dirs: src
default-language: Haskell2010

View File

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