moving to C
This commit is contained in:
1 parent
4ad6685042
commit
8da6770ad6
4 files changed
+21
-250
No files matched your search
@@ -1,4 +1,5 @@
|
||||
.envrc
|
||||
.direnv/
|
||||
docs/local/
|
||||
|
||||
build/
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
# Retained Mode GUI project
|
||||
|
||||
## Hard requirements:
|
||||
- Must be written in C
|
||||
- Must be RETAINED MODE with a document structure that loads from disk
|
||||
- Must be versitile and independent so it can be used for Games, Desktop App GUI, etc.
|
||||
- Must be easy to initalize
|
||||
- Must have a friendly document language (My first thought is Lua as the documenting language)
|
||||
- Must have full Lua API for realtime changes and modability
|
||||
- Must be NATIVE and not use a webview or web backend at all
|
||||
- Used for NATIVE Desktop GUI applications as well as GUI for games
|
||||
- Must compile to native Linux, Windows, Mac, etc, as well as Web (WASM)
|
||||
|
||||
|
||||
## Medium requirements:
|
||||
- Use an existing project to calculate layouts and render commands
|
||||
|
||||
|
||||
## Soft requirements:
|
||||
- Bring your own rendering/platform backend (otherwise, just use OpenGL and SDL3)
|
||||
Generated
-63
@@ -1,63 +0,0 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1793341285,
|
||||
"narHash": "sha256-Y1CiZ4SoBUjLQyQM/pY+rS2dXD3CHLPstF0lmOc73D4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1c89083e451e891152365b799595cf7790a43325",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"odin-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1791295716,
|
||||
"narHash": "sha256-Y8Em52W3ntWXgnRiRAyhWv5Y6+3b/4bj2+TTIvtniYU=",
|
||||
"owner": "odin-lang",
|
||||
"repo": "Odin",
|
||||
"rev": "84bc3fc2100b0f7880a3af37f71bccdcda41c6f9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "odin-lang",
|
||||
"ref": "dev-2026-10",
|
||||
"repo": "Odin",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"ols-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1791685123,
|
||||
"narHash": "sha256-tVg9g5aN4ovUElpDzTSLpTQUq3OEiYUaq3YO98ex8wA=",
|
||||
"owner": "DanielGavin",
|
||||
"repo": "ols",
|
||||
"rev": "c96dea912cf8272da7bb01a68696af5dfe1269ca",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "DanielGavin",
|
||||
"ref": "dev-2026-10",
|
||||
"repo": "ols",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"odin-src": "odin-src",
|
||||
"ols-src": "ols-src"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
{
|
||||
description = "Regolith, a retained mode GUI library for Odin";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
# Pinned to the latest monthly release tag
|
||||
# If you change this, also change odinVersion below
|
||||
odin-src = {
|
||||
url = "github:odin-lang/Odin/dev-2026-10";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# OLS must match the Odin revision
|
||||
ols-src = {
|
||||
url = "github:DanielGavin/ols/dev-2026-10";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, odin-src, ols-src }:
|
||||
let
|
||||
lib = nixpkgs.lib;
|
||||
systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
forAllSystems = f:
|
||||
lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
||||
|
||||
odinVersion = "2026-10";
|
||||
|
||||
build = pkgs:
|
||||
let
|
||||
llvmPackages = pkgs.llvmPackages_20;
|
||||
|
||||
odin = llvmPackages.stdenv.mkDerivation {
|
||||
pname = "odin";
|
||||
version = "dev-${odinVersion}";
|
||||
src = odin-src;
|
||||
|
||||
nativeBuildInputs = [ pkgs.makeBinaryWrapper pkgs.which ];
|
||||
buildInputs = [ llvmPackages.llvm ];
|
||||
|
||||
LLVM_CONFIG = "${llvmPackages.llvm.dev}/bin/llvm-config";
|
||||
|
||||
# The build script stamps the version from the build date, which is
|
||||
# meaningless inside the Nix sandbox. Stamp the tag instead.
|
||||
postPatch = ''
|
||||
substituteInPlace build_odin.sh \
|
||||
--replace-fail '$(date +"%Y-%m")' '${odinVersion}'
|
||||
patchShebangs build_odin.sh
|
||||
'';
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
./build_odin.sh release
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin $out/share
|
||||
cp odin $out/bin/odin
|
||||
for d in base core vendor shared; do
|
||||
if [ -d "$d" ]; then cp -r "$d" $out/share/; fi
|
||||
done
|
||||
|
||||
wrapProgram $out/bin/odin \
|
||||
--prefix PATH : ${lib.makeBinPath [
|
||||
llvmPackages.bintools
|
||||
llvmPackages.clang
|
||||
llvmPackages.lld
|
||||
]} \
|
||||
--set-default ODIN_ROOT $out/share
|
||||
|
||||
# Build the C parts of the vendor collection.
|
||||
for v in stb cgltf miniaudio; do
|
||||
d="$out/share/vendor/$v/src"
|
||||
[ -d "$d" ] || continue
|
||||
if [ -f "$d/Makefile" ] || [ -f "$d/makefile" ] || [ -f "$d/GNUmakefile" ]; then
|
||||
make -C "$d"
|
||||
elif [ -f "$d/build_$v.sh" ]; then
|
||||
patchShebangs "$d/build_$v.sh"
|
||||
(cd "$d" && "./build_$v.sh") || echo "vendor/$v: build script failed, skipping"
|
||||
else
|
||||
echo "vendor/$v/src: no known build entry point, skipping"
|
||||
fi
|
||||
done
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
ols = pkgs.stdenv.mkDerivation {
|
||||
pname = "ols";
|
||||
version = "dev-${odinVersion}";
|
||||
src = ols-src;
|
||||
|
||||
nativeBuildInputs = [ odin ];
|
||||
dontConfigure = true;
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs build.sh odinfmt.sh
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
./build.sh
|
||||
./odinfmt.sh
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm755 ols $out/bin/ols
|
||||
install -Dm755 odinfmt $out/bin/odinfmt
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
{ inherit odin ols llvmPackages; };
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (pkgs:
|
||||
let p = build pkgs; in {
|
||||
inherit (p) odin ols;
|
||||
default = p.odin;
|
||||
});
|
||||
|
||||
devShells = forAllSystems (pkgs:
|
||||
let
|
||||
p = build pkgs;
|
||||
llvmPackages = p.llvmPackages;
|
||||
|
||||
runtimeLibs = with pkgs; [
|
||||
sdl3
|
||||
wayland
|
||||
libxkbcommon
|
||||
libdecor
|
||||
vulkan-loader
|
||||
libGL
|
||||
];
|
||||
in
|
||||
{
|
||||
default = (pkgs.mkShell.override { stdenv = llvmPackages.stdenv; }) {
|
||||
name = "regolith";
|
||||
|
||||
packages = [
|
||||
# Odin toolchain
|
||||
p.odin
|
||||
p.ols
|
||||
llvmPackages.lld
|
||||
llvmPackages.bintools
|
||||
|
||||
# Native build and runtime
|
||||
pkgs.pkg-config
|
||||
pkgs.sdl3
|
||||
|
||||
# WASM
|
||||
pkgs.emscripten
|
||||
pkgs.nodejs
|
||||
pkgs.python3
|
||||
|
||||
# Lua tooling (the engine builds its own vendored Lua)
|
||||
pkgs.lua5_4
|
||||
pkgs.lua54Packages.luacheck
|
||||
|
||||
# Debugging
|
||||
pkgs.gdb
|
||||
pkgs.valgrind
|
||||
pkgs.git
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
# Emscripten needs a writable cache, and the store is read only.
|
||||
export EM_CACHE="$PWD/.cache/emscripten"
|
||||
mkdir -p "$EM_CACHE"
|
||||
|
||||
# SDL3 dlopens these at runtime. nixpkgs SDL3 is patched to find
|
||||
# most of them, this is a fallback for anything built outside Nix.
|
||||
export LD_LIBRARY_PATH="${lib.makeLibraryPath runtimeLibs}:/run/opengl-driver/lib:''${LD_LIBRARY_PATH:-}"
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user