# HG changeset patch # User ellis # Date 1685152780 14400 # Node ID af615d1895cb9346512a5fc0274b06840a27fbd3 # Parent e8eb5754d201ca8af6ea763807103b90a116c7ce refactoring, ui stuff (goin with slint for DSL power) diff -r e8eb5754d201 -r af615d1895cb Cargo.toml --- a/Cargo.toml Thu May 25 21:47:14 2023 -0400 +++ b/Cargo.toml Fri May 26 21:59:40 2023 -0400 @@ -4,9 +4,9 @@ build = "build.rs" [lib] path = "lib.rs" -crate-type = ["lib","cdylib","staticlib"] +crate-type = ["rlib","cdylib"] [workspace] -members = ["obj","fig"] +members = ["obj","fig","ui"] [dependencies] libc = "0.2" obj = {version = "0.1.0",path = "obj"} diff -r e8eb5754d201 -r af615d1895cb makefile --- a/makefile Thu May 25 21:47:14 2023 -0400 +++ b/makefile Fri May 26 21:59:40 2023 -0400 @@ -8,7 +8,7 @@ build:$(RS) $(CL);cargo build --$(M);$L install.lisp ffi:build;cp target/$(M)/libdemo.dylib ffi;cd ffi;$(P) ffi/build.py docs:$(RS);cargo doc -test:$(RS);cargo test +test:$(RS) $(CL);cargo test;$L tests.lisp #pack:;scripts/pack.ros #check:;scripts/check.ros ci:clean fmt build ffi docs test; diff -r e8eb5754d201 -r af615d1895cb scripts/build.ros --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/build.ros Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,25 @@ +#!/bin/sh +#|-*- mode:lisp -*-|# +#| +exec ros -Q -- $0 "$@" +|# +(progn ;;init forms + (ros:ensure-asdf) + #+quicklisp(ql:quickload '() :silent t) + ) + +(defpackage :ros.script.build.3891893519 + (:use :cl)) +(in-package :ros.script.build.3891893519) + +(defun main (&rest argv) + (declare (ignorable argv)) + (write-line "> cargo build --release") + (uiop:run-program "cargo build --release") + (wrie-line " built rust libs and bindings") + (asdf:load-asd "cl-demo.asd") + (asdf:load-system "demo") + (asdf:make :demo) + + ) +;;; vim: set ft=lisp lisp: diff -r e8eb5754d201 -r af615d1895cb scripts/check.ros --- a/scripts/check.ros Thu May 25 21:47:14 2023 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#!/bin/sh -#|-*- mode:lisp -*-|# -#| -exec ros -Q -- $0 "$@" -|# -(progn ;;init forms - (ros:ensure-asdf) - #+quicklisp(ql:quickload '() :silent t) - ) - -(defpackage :ros.script.scriptscheck.3892329806 - (:use :cl)) -(in-package :ros.script.scriptscheck.3892329806) - -(defun main (&rest argv) - (declare (ignorable argv))) -;;; vim: set ft=lisp lisp: diff -r e8eb5754d201 -r af615d1895cb scripts/db.ros --- a/scripts/db.ros Thu May 25 21:47:14 2023 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -#!/bin/sh -#|-*- mode:lisp -*-|# -#| -exec ros -Q -- $0 "$@" -|# -(progn ;;init forms - (ros:ensure-asdf) - #+quicklisp(ql:quickload '() :silent t)) - -(defun main (&rest argv) - (declare (ignorable argv)) - (format t "hello world")) diff -r e8eb5754d201 -r af615d1895cb scripts/demo.ros --- a/scripts/demo.ros Thu May 25 21:47:14 2023 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -#!/bin/sh -#|-*- mode:lisp -*-|# -#| -exec ros -Q -- $0 "$@" -|# -(progn ;;init forms - (ros:ensure-asdf) - #+quicklisp(ql:quickload '(demo) :silent t)) - -(defun main (&rest argv) - (declare (ignorable argv)) - (demo:main)) diff -r e8eb5754d201 -r af615d1895cb scripts/pack.ros --- a/scripts/pack.ros Thu May 25 21:47:14 2023 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#!/bin/sh -#|-*- mode:lisp -*-|# -#| -exec ros -Q -- $0 "$@" -|# -(progn ;;init forms - (ros:ensure-asdf) - #+quicklisp(ql:quickload '() :silent t) - ) - -(defpackage :ros.script.pack.3891893796 - (:use :cl)) -(in-package :ros.script.pack.3891893796) - -(defun main (&rest argv) - (declare (ignorable argv))) -;;; vim: set ft=lisp lisp: diff -r e8eb5754d201 -r af615d1895cb scripts/test.ros --- a/scripts/test.ros Thu May 25 21:47:14 2023 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#!/bin/sh -#|-*- mode:lisp -*-|# -#| -exec ros -Q -- $0 "$@" -|# -(progn ;;init forms - (ros:ensure-asdf) - #+quicklisp(ql:quickload '() :silent t)) - -(defun main (&rest argv) - (declare (ignorable argv)) - (write-line "> cargo test") - (uiop:run-program "cargo test") - (write-line " tested rust crates")) diff -r e8eb5754d201 -r af615d1895cb tools/scripts/check.ros --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/scripts/check.ros Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,17 @@ +#!/bin/sh +#|-*- mode:lisp -*-|# +#| +exec ros -Q -- $0 "$@" +|# +(progn ;;init forms + (ros:ensure-asdf) + #+quicklisp(ql:quickload '() :silent t) + ) + +(defpackage :ros.script.scriptscheck.3892329806 + (:use :cl)) +(in-package :ros.script.scriptscheck.3892329806) + +(defun main (&rest argv) + (declare (ignorable argv))) +;;; vim: set ft=lisp lisp: diff -r e8eb5754d201 -r af615d1895cb tools/scripts/db.ros --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/scripts/db.ros Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,12 @@ +#!/bin/sh +#|-*- mode:lisp -*-|# +#| +exec ros -Q -- $0 "$@" +|# +(progn ;;init forms + (ros:ensure-asdf) + #+quicklisp(ql:quickload '() :silent t)) + +(defun main (&rest argv) + (declare (ignorable argv)) + (format t "hello world")) diff -r e8eb5754d201 -r af615d1895cb tools/scripts/demo.ros --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/scripts/demo.ros Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,12 @@ +#!/bin/sh +#|-*- mode:lisp -*-|# +#| +exec ros -Q -- $0 "$@" +|# +(progn ;;init forms + (ros:ensure-asdf) + #+quicklisp(ql:quickload '(demo) :silent t)) + +(defun main (&rest argv) + (declare (ignorable argv)) + (demo:main)) diff -r e8eb5754d201 -r af615d1895cb tools/scripts/pack.ros --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/scripts/pack.ros Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,17 @@ +#!/bin/sh +#|-*- mode:lisp -*-|# +#| +exec ros -Q -- $0 "$@" +|# +(progn ;;init forms + (ros:ensure-asdf) + #+quicklisp(ql:quickload '() :silent t) + ) + +(defpackage :ros.script.pack.3891893796 + (:use :cl)) +(in-package :ros.script.pack.3891893796) + +(defun main (&rest argv) + (declare (ignorable argv))) +;;; vim: set ft=lisp lisp: diff -r e8eb5754d201 -r af615d1895cb tools/scripts/test.ros --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/scripts/test.ros Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,14 @@ +#!/bin/sh +#|-*- mode:lisp -*-|# +#| +exec ros -Q -- $0 "$@" +|# +(progn ;;init forms + (ros:ensure-asdf) + #+quicklisp(ql:quickload '() :silent t)) + +(defun main (&rest argv) + (declare (ignorable argv)) + (write-line "> cargo test") + (uiop:run-program "cargo test") + (write-line " tested rust crates")) diff -r e8eb5754d201 -r af615d1895cb ui/Cargo.toml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/Cargo.toml Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,29 @@ +[package] +name = "ui" +version = "0.1.0" +edition = "2021" +[lib] +path = "src/lib.rs" +crate-type = ["rlib","cdylib"] +[[bin]] +name = "demo-ui" +path = "src/main.rs" +[dependencies] +wgpu = "0.16.1" +winit = "0.28.6" +obj = {version = "0.1.0",path = "../obj"} +fig = {version = "0.1.0",path = "../fig"} +env_logger = "0.10.0" +log = "0.4.17" +cfg-if = "1.0.0" +[target.'cfg(target_arch = "wasm32")'.dependencies] +console_error_panic_hook = "0.1.6" +console_log = "0.2.0" +wgpu = { version = "0.15", features = ["webgl"]} +wasm-bindgen = "0.2" +wasm-bindgen-futures = "0.4.30" +web-sys = { version = "0.3", features = [ + "Document", + "Window", + "Element", +]} diff -r e8eb5754d201 -r af615d1895cb ui/src/lib.rs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/src/lib.rs Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,59 @@ +#[cfg(target_arch="wasm32")] +use wasm_bindgen::prelude::*; +use winit::{ + event::*, + event_loop::{ControlFlow, EventLoop}, + window::WindowBuilder, +}; + +#[cfg_attr(target_arch="wasm32", wasm_bindgen(start))] +pub fn run() { + cfg_if::cfg_if! { + if #[cfg(target_arch = "wasm32")] { + std::panic::set_hook(Box::new(console_error_panic_hook::hook)); + console_log::init_with_level(log::Level::Warn).expect("Couldn't initialize logger"); + } else { + env_logger::init(); + } + } + let event_loop = EventLoop::new(); + let window = WindowBuilder::new().build(&event_loop).unwrap(); + + #[cfg(target_arch = "wasm32")] +{ + // Winit prevents sizing with CSS, so we have to set + // the size manually when on web. + use winit::dpi::PhysicalSize; + window.set_inner_size(PhysicalSize::new(450, 400)); + + use winit::platform::web::WindowExtWebSys; + web_sys::window() + .and_then(|win| win.document()) + .and_then(|doc| { + let dst = doc.get_element_by_id("wasm-example")?; + let canvas = web_sys::Element::from(window.canvas()); + dst.append_child(&canvas).ok()?; + Some(()) + }) + .expect("Couldn't append canvas to document body."); +} + event_loop.run(move |event, _, control_flow| match event { + Event::WindowEvent { + ref event, + window_id, + } if window_id == window.id() => match event { + WindowEvent::CloseRequested + | WindowEvent::KeyboardInput { + input: + KeyboardInput { + state: ElementState::Pressed, + virtual_keycode: Some(VirtualKeyCode::Escape), + .. + }, + .. + } => *control_flow = ControlFlow::Exit, + _ => {} + }, + _ => {} + }); +} diff -r e8eb5754d201 -r af615d1895cb ui/src/main.rs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/src/main.rs Fri May 26 21:59:40 2023 -0400 @@ -0,0 +1,4 @@ +use ui::run; +pub fn main() { + run(); +}