add library as git submodule, wayland, window shows
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "lib/RGFW"]
|
||||||
|
path = lib/RGFW
|
||||||
|
url = https://github.com/ColleagueRiley/RGFW
|
||||||
15
flake.nix
15
flake.nix
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
|
||||||
|
self.submodules = true;
|
||||||
};
|
};
|
||||||
outputs = {nixpkgs, ...}: let
|
outputs = {nixpkgs, ...}: let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
@@ -47,10 +48,6 @@
|
|||||||
ghcPackages = p: [
|
ghcPackages = p: [
|
||||||
];
|
];
|
||||||
buildDeps = [
|
buildDeps = [
|
||||||
pkgs.pkg-config
|
|
||||||
pkgs.wayland-protocols
|
|
||||||
pkgs.wayland-scanner
|
|
||||||
|
|
||||||
pkgs.egl-wayland
|
pkgs.egl-wayland
|
||||||
pkgs.libGL
|
pkgs.libGL
|
||||||
pkgs.libxkbcommon
|
pkgs.libxkbcommon
|
||||||
@@ -60,6 +57,12 @@
|
|||||||
pkgs.xorg.libXi
|
pkgs.xorg.libXi
|
||||||
pkgs.xorg.libXrandr
|
pkgs.xorg.libXrandr
|
||||||
];
|
];
|
||||||
|
runtimeDeps = [
|
||||||
|
pkgs.makeWrapper
|
||||||
|
pkgs.pkg-config
|
||||||
|
pkgs.wayland-protocols
|
||||||
|
pkgs.wayland-scanner
|
||||||
|
];
|
||||||
in {
|
in {
|
||||||
packages.${system} = {
|
packages.${system} = {
|
||||||
debug = pkgs.callPackage ./package.nix {
|
debug = pkgs.callPackage ./package.nix {
|
||||||
@@ -67,24 +70,28 @@
|
|||||||
haddockOptions = noHaddockOptions;
|
haddockOptions = noHaddockOptions;
|
||||||
inherit ghcPackages;
|
inherit ghcPackages;
|
||||||
inherit buildDeps;
|
inherit buildDeps;
|
||||||
|
inherit runtimeDeps;
|
||||||
};
|
};
|
||||||
release = pkgs.callPackage ./package.nix {
|
release = pkgs.callPackage ./package.nix {
|
||||||
ghcOptions = releaseGhcOptions;
|
ghcOptions = releaseGhcOptions;
|
||||||
haddockOptions = noHaddockOptions;
|
haddockOptions = noHaddockOptions;
|
||||||
inherit ghcPackages;
|
inherit ghcPackages;
|
||||||
inherit buildDeps;
|
inherit buildDeps;
|
||||||
|
inherit runtimeDeps;
|
||||||
};
|
};
|
||||||
docs = pkgs.callPackage ./package.nix {
|
docs = pkgs.callPackage ./package.nix {
|
||||||
ghcOptions = "--version";
|
ghcOptions = "--version";
|
||||||
inherit haddockOptions;
|
inherit haddockOptions;
|
||||||
inherit ghcPackages;
|
inherit ghcPackages;
|
||||||
inherit buildDeps;
|
inherit buildDeps;
|
||||||
|
inherit runtimeDeps;
|
||||||
};
|
};
|
||||||
default = pkgs.callPackage ./package.nix {
|
default = pkgs.callPackage ./package.nix {
|
||||||
ghcOptions = releaseGhcOptions;
|
ghcOptions = releaseGhcOptions;
|
||||||
inherit haddockOptions;
|
inherit haddockOptions;
|
||||||
inherit ghcPackages;
|
inherit ghcPackages;
|
||||||
inherit buildDeps;
|
inherit buildDeps;
|
||||||
|
inherit runtimeDeps;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
1
lib/RGFW
Submodule
1
lib/RGFW
Submodule
Submodule lib/RGFW added at b7bd582eb3
14040
lib/RGFW.h
14040
lib/RGFW.h
File diff suppressed because it is too large
Load Diff
16
lib/RGFW_HS.h
Normal file
16
lib/RGFW_HS.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef RGFW_HS // avoid repeated imports
|
||||||
|
#define RGFW_HS
|
||||||
|
|
||||||
|
// TODO add actual include logic
|
||||||
|
|
||||||
|
#define RGFW_IMPLEMENTATION
|
||||||
|
#define RGFW_DEBUG
|
||||||
|
#define RGFW_X11
|
||||||
|
#define RGFW_WAYLAND
|
||||||
|
#define RGFW_OPENGL
|
||||||
|
|
||||||
|
#define Time X11Time // fixes namespace clash with GHC when building with Nix
|
||||||
|
#include "RGFW/RGFW.h"
|
||||||
|
#undef Time
|
||||||
|
|
||||||
|
#endif RGFW_HS
|
||||||
10
package.nix
10
package.nix
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
buildDeps,
|
buildDeps,
|
||||||
|
runtimeDeps,
|
||||||
haskellPackages,
|
haskellPackages,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
ghcPackages,
|
ghcPackages,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation rec {
|
||||||
pname = "hs-rgfw";
|
pname = "hs-rgfw";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
@@ -17,11 +18,11 @@ stdenv.mkDerivation {
|
|||||||
[
|
[
|
||||||
(haskellPackages.ghcWithPackages ghcPackages)
|
(haskellPackages.ghcWithPackages ghcPackages)
|
||||||
]
|
]
|
||||||
++ buildDeps;
|
++ buildDeps ++ runtimeDeps;
|
||||||
buildInputs =
|
buildInputs =
|
||||||
[
|
[
|
||||||
]
|
]
|
||||||
++ buildDeps;
|
++ runtimeDeps;
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
export PKG_CONFIG_PATH=/run/current-system/sw/lib/pkgconfig
|
export PKG_CONFIG_PATH=/run/current-system/sw/lib/pkgconfig
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ stdenv.mkDerivation {
|
|||||||
'';
|
'';
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
mkdir src/lib
|
mkdir src/lib
|
||||||
cp lib/* src/lib/
|
cp -r lib/* src/lib/
|
||||||
cp ccode/*.c ./
|
cp ccode/*.c ./
|
||||||
ghc ${ghcOptions} ./src/Main.hs -o ./Main $(pkg-config --cflags --libs gl wayland-client wayland-egl wayland-cursor xkbcommon x11 xcursor xrandr xi) -I./headers/ $(ls *.c)
|
ghc ${ghcOptions} ./src/Main.hs -o ./Main $(pkg-config --cflags --libs gl wayland-client wayland-egl wayland-cursor xkbcommon x11 xcursor xrandr xi) -I./headers/ $(ls *.c)
|
||||||
mkdir ./docs
|
mkdir ./docs
|
||||||
@@ -53,6 +54,7 @@ stdenv.mkDerivation {
|
|||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp ./Main $out/bin/hs-rgfw
|
cp ./Main $out/bin/hs-rgfw
|
||||||
cp ./docs $out/docs -r
|
cp ./docs $out/docs -r
|
||||||
|
wrapProgram "$out/bin/${meta.mainProgram}" --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath buildInputs}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
|||||||
38
src/Main.hs
38
src/Main.hs
@@ -21,25 +21,19 @@ main = do
|
|||||||
800
|
800
|
||||||
600
|
600
|
||||||
$ mkWindowFlags
|
$ mkWindowFlags
|
||||||
[ WindowCenter
|
[ WindowNoResize
|
||||||
, WindowNoResize
|
|
||||||
, WindowOpenGL
|
, WindowOpenGL
|
||||||
|
, WindowFullscreen
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
let loop = do
|
let loop ctr = do
|
||||||
putStrLn $ show window
|
|
||||||
putStrLn
|
|
||||||
$ show
|
|
||||||
$ mkWindowFlags
|
|
||||||
[ WindowCenter
|
|
||||||
, WindowNoResize
|
|
||||||
, WindowOpenGL
|
|
||||||
]
|
|
||||||
shouldClose <- rgfwWindowShouldClose window
|
shouldClose <- rgfwWindowShouldClose window
|
||||||
if 0 == shouldClose
|
if 0 /= shouldClose
|
||||||
then return ()
|
then return shouldClose
|
||||||
else loop
|
else loop $ ctr + 1
|
||||||
loop
|
exitCode <- loop 0
|
||||||
|
putStrLn $ show exitCode
|
||||||
|
return ()
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Haskell-ier abstractions
|
-- Haskell-ier abstractions
|
||||||
@@ -107,15 +101,15 @@ type RGFWwindowFlags = Word32
|
|||||||
|
|
||||||
type RGFWbool = CUInt
|
type RGFWbool = CUInt
|
||||||
|
|
||||||
foreign import capi "lib/RGFW.h RGFW_createWindow" rgfwCreateWindow
|
foreign import capi "lib/RGFW_HS.h RGFW_createWindow" rgfwCreateWindow
|
||||||
:: CString
|
:: Ptr CChar
|
||||||
-> Int32
|
-> CInt
|
||||||
-> Int32
|
-> CInt
|
||||||
-> Int32
|
-> CInt
|
||||||
-> Int32
|
-> CInt
|
||||||
-> RGFWwindowFlags
|
-> RGFWwindowFlags
|
||||||
-> IO RGFWwindowPtr
|
-> IO RGFWwindowPtr
|
||||||
|
|
||||||
foreign import capi "lib/RGFW.h RGFW_window_shouldClose" rgfwWindowShouldClose
|
foreign import capi "lib/RGFW_HS.h RGFW_window_shouldClose" rgfwWindowShouldClose
|
||||||
:: RGFWwindowPtr
|
:: RGFWwindowPtr
|
||||||
-> IO RGFWbool
|
-> IO RGFWbool
|
||||||
|
|||||||
Reference in New Issue
Block a user