summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/teleia/build.rs3
-rw-r--r--crates/teleia/src/lib.rs8
-rw-r--r--crates/teleia/src/script.rs5
-rw-r--r--flake.lock55
-rw-r--r--flake.nix11
5 files changed, 79 insertions, 3 deletions
diff --git a/crates/teleia/build.rs b/crates/teleia/build.rs
new file mode 100644
index 0000000..0233021
--- /dev/null
+++ b/crates/teleia/build.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("cargo::rustc-link-lib=static=colonq-pit");
+}
diff --git a/crates/teleia/src/lib.rs b/crates/teleia/src/lib.rs
index 8e991ef..894756d 100644
--- a/crates/teleia/src/lib.rs
+++ b/crates/teleia/src/lib.rs
@@ -10,6 +10,7 @@ pub mod mesh;
pub mod texture;
pub mod scene;
pub mod font;
+pub mod script;
pub mod shadow;
pub mod renderer;
pub mod audio;
@@ -72,6 +73,13 @@ where
log::info!("hello computer, starting up...");
+ unsafe {
+ let mut out = vec![' ' as u8; 1024];
+ let buf = std::alloc::alloc(std::alloc::Layout::from_size_align(256 * 1024 * 1024, 64).unwrap());
+ log::info!("pit_runtime_test: {:?}", crate::script::pit_runtime_test(out.as_mut_ptr(), out.len() as i64, buf, 256 * 1024 * 1024));
+ log::info!("out: {}", String::from_utf8(out).unwrap());
+ }
+
let (rglfw, rwindow, gl, events) = {
use glfw::fail_on_errors;
let mut glfw = glfw::init(glfw::fail_on_errors!()).expect("failed to initialize GLFW");
diff --git a/crates/teleia/src/script.rs b/crates/teleia/src/script.rs
new file mode 100644
index 0000000..0282f65
--- /dev/null
+++ b/crates/teleia/src/script.rs
@@ -0,0 +1,5 @@
+use std::ffi::c_int;
+
+unsafe extern "C" {
+ pub fn pit_runtime_test(out: *mut u8, out_len: i64, buf: *mut u8, len: i64) -> c_int;
+}
diff --git a/flake.lock b/flake.lock
index 6306dad..771a645 100644
--- a/flake.lock
+++ b/flake.lock
@@ -33,6 +33,24 @@
"type": "github"
}
},
+ "flake-utils_2": {
+ "inputs": {
+ "systems": "systems_2"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
"nixpkgs": {
"locked": {
"lastModified": 1753432016,
@@ -49,11 +67,33 @@
"type": "github"
}
},
+ "pit": {
+ "inputs": {
+ "flake-utils": "flake-utils_2",
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1776924510,
+ "narHash": "sha256-PCguZ7svx3M+ruhaVt+lgeCXOyo1angw7kNcaJczDWI=",
+ "owner": "lcolonq",
+ "repo": "pit",
+ "rev": "2850670124e5d5398aca6290558317a24291b219",
+ "type": "github"
+ },
+ "original": {
+ "owner": "lcolonq",
+ "repo": "pit",
+ "type": "github"
+ }
+ },
"root": {
"inputs": {
"crane": "crane",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
+ "pit": "pit",
"rust-overlay": "rust-overlay"
}
},
@@ -91,6 +131,21 @@
"repo": "default",
"type": "github"
}
+ },
+ "systems_2": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
}
},
"root": "root",
diff --git a/flake.nix b/flake.nix
index 52c09e2..a5456e1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -11,14 +11,18 @@
nixpkgs.follows = "nixpkgs";
};
};
+ pit = {
+ url = "github:lcolonq/pit";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
};
- outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
+ outputs = inputs@{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
- overlays = [ (import rust-overlay) ];
+ overlays = [ (import inputs.rust-overlay) ];
};
inherit (pkgs) lib;
@@ -29,7 +33,7 @@
"x86_64-pc-windows-gnu"
];
};
- craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchainFor;
+ craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchainFor;
glfw = pkgs.glfw.overrideAttrs (cur: prev: {
cmakeFlags = []; # by default, static linking is disabled here
@@ -57,6 +61,7 @@
pkgs.xorg.libxcb
pkgs.libglvnd
pkgs.alsa-lib
+ inputs.pit.packages.x86_64-linux.default
];
deps = path: nm:
let