Compare commits
1 Commits
hs-bindgen
...
f17acc45e0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f17acc45e0 |
38
flake.lock
generated
38
flake.lock
generated
@@ -5,11 +5,11 @@
|
|||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1769996383,
|
"lastModified": 1767609335,
|
||||||
"narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=",
|
"narHash": "sha256-feveD98mQpptwrAEggBQKJTYbvwwglSbOv53uCfH9PY=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "57928607ea566b5db3ad13af0e57e921e6b12381",
|
"rev": "250481aafeb741edfe23d29195671c19b36b6dca",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770911191,
|
"lastModified": 1769198512,
|
||||||
"narHash": "sha256-fePV3+4uHg1tQH83rUO/7gQOGexHdaxyVkO2X3HkOA0=",
|
"narHash": "sha256-ZsQm3CwvicJBv4CMJJzRkTcYYcrghqzVabL9IehNz9k=",
|
||||||
"owner": "well-typed",
|
"owner": "well-typed",
|
||||||
"repo": "hs-bindgen",
|
"repo": "hs-bindgen",
|
||||||
"rev": "087884c110948e7bd67bec0ae8004e5396f63241",
|
"rev": "f99ed4ddfc7808b3eb28bbf089612b6a52983685",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -41,27 +41,27 @@
|
|||||||
"libclang-bindings-src": {
|
"libclang-bindings-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770274896,
|
"lastModified": 1768982090,
|
||||||
"narHash": "sha256-JnxJBo2L4URFD8JbpjnPG/ej/xKFe7y5ZpjnvIztwAM=",
|
"narHash": "sha256-EgM9ZJvbM0+SQ8f9P27Rnx4dY8Q1fWtGVXsRl5f0Vfk=",
|
||||||
"owner": "well-typed",
|
"owner": "well-typed",
|
||||||
"repo": "libclang",
|
"repo": "libclang",
|
||||||
"rev": "155642a4a4a9f0414a058a8f08f39aa6c7bb57ed",
|
"rev": "27f20c2e320f779314175ee3e82072fec61b8391",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "well-typed",
|
"owner": "well-typed",
|
||||||
"repo": "libclang",
|
"repo": "libclang",
|
||||||
"rev": "155642a4a4a9f0414a058a8f08f39aa6c7bb57ed",
|
"rev": "27f20c2e320f779314175ee3e82072fec61b8391",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770169770,
|
"lastModified": 1767364772,
|
||||||
"narHash": "sha256-awR8qIwJxJJiOmcEGgP2KUqYmHG4v/z8XpL9z8FnT1A=",
|
"narHash": "sha256-fFUnEYMla8b7UKjijLnMe+oVFOz6HjijGGNS1l7dYaQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "aa290c9891fa4ebe88f8889e59633d20cc06a5f2",
|
"rev": "16c7794d0a28b5a37904d55bcca36003b9109aaa",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -73,11 +73,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1769909678,
|
"lastModified": 1765674936,
|
||||||
"narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=",
|
"narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs.lib",
|
"repo": "nixpkgs.lib",
|
||||||
"rev": "72716169fe93074c333e8d0173151350670b824c",
|
"rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -88,11 +88,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770843696,
|
"lastModified": 1765772535,
|
||||||
"narHash": "sha256-LovWTGDwXhkfCOmbgLVA10bvsi/P8eDDpRudgk68HA8=",
|
"narHash": "sha256-aq+dQoaPONOSjtFIBnAXseDm9TUhIbe215TPmkfMYww=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "2343bbb58f99267223bc2aac4fc9ea301a155a16",
|
"rev": "09b8fda8959d761445f12b55f380d90375a1d6bb",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -26,9 +26,7 @@
|
|||||||
libXi,
|
libXi,
|
||||||
xrandr,
|
xrandr,
|
||||||
# shell deps
|
# shell deps
|
||||||
clang,
|
|
||||||
hs-bindgen-cli,
|
hs-bindgen-cli,
|
||||||
tree,
|
|
||||||
}:
|
}:
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
pname = "hs-rgfw";
|
pname = "hs-rgfw";
|
||||||
@@ -46,9 +44,9 @@
|
|||||||
libXi
|
libXi
|
||||||
xrandr
|
xrandr
|
||||||
];
|
];
|
||||||
preConfigure = ''
|
preBuild = ''
|
||||||
set -x
|
set -x
|
||||||
export PATH=${clang}/bin:${hs-bindgen-cli}/bin:${tree}/bin:$PATH
|
export PATH=${hs-bindgen-cli}/bin:$PATH
|
||||||
./generate.sh
|
./generate.sh
|
||||||
set +x
|
set +x
|
||||||
'';
|
'';
|
||||||
|
|||||||
39
generate.sh
39
generate.sh
@@ -1,49 +1,22 @@
|
|||||||
echo "# copying header..."
|
echo "# copying header..."
|
||||||
|
|
||||||
mkdir -p lib/include
|
mkdir lib
|
||||||
|
mkdir lib/include
|
||||||
cp rgfw/RGFW.h lib/include/RGFW.h
|
cp rgfw/RGFW.h lib/include/RGFW.h
|
||||||
|
|
||||||
echo "# creating flags for hs-bindgen-cli..."
|
echo "# creating c file to generate from..."
|
||||||
|
|
||||||
export CFLAGS=$(pkg-config --cflags x11 xcursor xrandr xi gl xrender xext xfixes)
|
clang -E -DRGFW_IMPLEMENTATION -DRGFW_OPENGL lib/include/RGFW.h -o lib/include/RGFW.c
|
||||||
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..."
|
|
||||||
|
|
||||||
# other macro definitions should be defined with ghc-options: -copt-D in *.cabal
|
|
||||||
cat > lib/RGFW.c <<EOF
|
|
||||||
#define RGFW_IMPLEMENTATION
|
|
||||||
#include "RGFW.h"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
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 \
|
||||||
--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 \
|
--clang-option=-DRGFW_OPENGL \
|
||||||
--define-macro=RGFW_EXPORT \
|
--clang-option=-DRGFW_EXPORT \
|
||||||
$HBC_ARGS \
|
|
||||||
RGFW.h
|
RGFW.h
|
||||||
set +x
|
|
||||||
|
|
||||||
echo "# generated filetree:"
|
|
||||||
|
|
||||||
tree lib
|
|
||||||
|
|||||||
@@ -12,28 +12,20 @@ common warnings
|
|||||||
|
|
||||||
library
|
library
|
||||||
import: warnings
|
import: warnings
|
||||||
-- hs-bindgen-cli uses --single-file flag, so no other modules
|
exposed-modules:
|
||||||
exposed-modules: RGFW.Generated
|
, 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
|
||||||
pkgconfig-depends:
|
|
||||||
, gl
|
|
||||||
, x11
|
|
||||||
, xcursor
|
|
||||||
, xrandr
|
|
||||||
, xi
|
|
||||||
include-dirs: lib/include
|
include-dirs: lib/include
|
||||||
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
|
|
||||||
|
|
||||||
executable hs-rgfw
|
executable hs-rgfw
|
||||||
import: warnings
|
import: warnings
|
||||||
|
|||||||
2
rgfw
2
rgfw
Submodule rgfw updated: a971541830...83d945ae89
@@ -1,5 +1,10 @@
|
|||||||
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 ()
|
||||||
|
|||||||
Reference in New Issue
Block a user