build error

This commit is contained in:
andromeda
2026-01-31 13:18:14 +01:00
parent 4858c3ee2e
commit 2b84809d84
5 changed files with 77 additions and 12 deletions

1
.gitignore vendored
View File

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

View File

@@ -26,7 +26,9 @@
libXi, libXi,
xrandr, xrandr,
# shell deps # shell deps
clang,
hs-bindgen-cli, hs-bindgen-cli,
tree,
}: }:
mkDerivation { mkDerivation {
pname = "hs-rgfw"; pname = "hs-rgfw";
@@ -44,9 +46,9 @@
libXi libXi
xrandr xrandr
]; ];
preBuild = '' preConfigure = ''
set -x set -x
export PATH=${hs-bindgen-cli}/bin:$PATH export PATH=${clang}/bin:${hs-bindgen-cli}/bin:${tree}/bin:$PATH
./generate.sh ./generate.sh
set +x set +x
''; '';

View File

@@ -1,11 +1,51 @@
echo "#" set -x
echo "# generating library RGFW.Generated in folder lib" echo "# copying header..."
echo "#"
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 \ hs-bindgen-cli preprocess \
-Irgfw \ -Ilib/include \
--parse-from-main-header-dirs \
--create-output-dirs \ --create-output-dirs \
--overwrite-files \ --overwrite-files \
--hs-output-dir lib \ --hs-output-dir lib \
--module RGFW.Generated \ --module RGFW.Generated \
--clang-option=-DRGFW_OPENGL \ --define-macro=RGFW_OPENGL \
--define-macro=RGFW_EXPORT \
--define-macro=RGFW_IMPLEMENTATION \
$HBC_ARGS \
RGFW.h RGFW.h
echo "# file tree generated:"
tree lib
set +x

View File

@@ -8,20 +8,38 @@ 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: -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 library
import: warnings import: warnings
exposed-modules: RGFW.Generated exposed-modules:
, RGFW.Generated
, RGFW.Generated.FunPtr
, RGFW.Generated.Safe
, RGFW.Generated.Unsafe
build-depends: build-depends:
, base , base
, primitive , primitive
, c-expr-runtime , c-expr-runtime
, hs-bindgen-runtime , hs-bindgen-runtime
include-dirs: rgfw pkgconfig-depends:
, gl
, x11
, xcursor
, xrandr
, xi
include-dirs: lib/include
hs-source-dirs: lib hs-source-dirs: lib
default-language: Haskell2010 default-language: Haskell2010
default-extensions: FlexibleInstances default-extensions: FlexibleInstances
c-sources: lib/RGFW.c
executable hs-rgfw executable hs-rgfw
import: warnings import: warnings
@@ -37,6 +55,6 @@ executable hs-rgfw
, xcursor , xcursor
, xrandr , xrandr
, xi , xi
include-dirs: rgfw include-dirs: lib/include
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010

View File

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