From b1d8fc62a94dcce3e9322c625673f3192e6177a3 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Wed, 24 Jul 2024 16:33:44 +0300 Subject: [PATCH] build suil with symbols; pass features correctly --- .gitignore | 1 + crates/suil/src/lib.rs | 55 +++++++++++++++++++++++++++-------------- crates/suil/src/test.rs | 19 ++++++++------ shell.nix | 8 +++++- 4 files changed, 57 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index c2c7737f..34beaa73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target perf.data* flamegraph*.svg +vgcore* diff --git a/crates/suil/src/lib.rs b/crates/suil/src/lib.rs index 30f55835..62898df4 100644 --- a/crates/suil/src/lib.rs +++ b/crates/suil/src/lib.rs @@ -10,28 +10,20 @@ pub struct Instance(*mut self::bound::SuilInstance); impl Host { pub fn new () -> Self { Self(unsafe { - let argv = &mut [] as *mut *mut *mut i8; - bound::suil_init(&mut 0, argv, 0); + let mut argv = []; + bound::suil_init( + &mut 0, + &mut argv as *mut *mut *mut i8, + 0 + ); bound::suil_host_new( - Some(Self::write), - Some(Self::index), - Some(Self::subscribe), - Some(Self::unsubscribe), + Some(write), + Some(index), + None, + None, ) }) } - unsafe extern "C" fn write ( - _: *mut c_void, _: u32, _: u32, _: u32, _: *const c_void - ) {} - unsafe extern "C" fn index ( - _: *mut c_void, _: *const i8 - ) -> u32 {0} - unsafe extern "C" fn subscribe ( - _: *mut c_void, _: u32, _: u32, _: *const *const bound::LV2_Feature - ) -> u32 {0} - unsafe extern "C" fn unsubscribe ( - _: *mut c_void, _: u32, _: u32, _: *const *const bound::LV2_Feature - ) -> u32 {0} fn set_touch_func (&self) { unimplemented!(); } @@ -68,6 +60,33 @@ impl Host { } } +unsafe extern "C" fn write ( + _: *mut c_void, _: u32, _: u32, _: u32, _: *const c_void +) { + panic!("write") +} + +unsafe extern "C" fn index ( + _: *mut c_void, _: *const i8 +) -> u32 { + panic!("index"); + 0 +} + +//unsafe extern "C" fn subscribe ( + //_: *mut c_void, _: u32, _: u32, _: *const *const bound::LV2_Feature +//) -> u32 { + //panic!("subscribe"); + //0 +//} + +//unsafe extern "C" fn unsubscribe ( + //_: *mut c_void, _: u32, _: u32, _: *const *const bound::LV2_Feature +//) -> u32 { + //panic!("unsubscribe"); + //0 +//} + impl Drop for Host { fn drop (&mut self) -> () { unsafe { diff --git a/crates/suil/src/test.rs b/crates/suil/src/test.rs index b55e7d2f..87447f1a 100644 --- a/crates/suil/src/test.rs +++ b/crates/suil/src/test.rs @@ -2,21 +2,26 @@ use crate::*; use std::sync::Arc; #[test] -fn panics () { +fn test_lv2_ui () { let host = Host::new(); let mut plugin = plugin::LV2Plugin::new("file:///home/user/.lv2/Odin2.lv2").unwrap(); + for ui in plugin.plugin.raw().uis().unwrap().iter() { + println!("{:?}", ui.uri()); + println!("{:?}", ui.classes()); + } + let mut features = []; + std::mem::forget(features); let instance = Arc::new(host.instance( - &mut plugin, - "", + &mut plugin.instance.raw(), + "http://lv2plug.in/ns/extensions/ui#X11UI", "https://thewavewarden.com/odin2", "https://thewavewarden.com/odin2#ParentUI", - "", - "", + "/home/user/.lv2/Odin2.lv2", "/home/user/.lv2/Odin2.lv2/Odin2.so", - &[], + "/home/user/.lv2/Odin2.lv2/Odin2.so", + &features, ).unwrap()); self::ui::UI::run(&instance).join(); - panic!(); } mod ui { diff --git a/shell.nix b/shell.nix index 67bcbdd0..39714b53 100755 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,11 @@ #!/usr/bin/env nix-shell -{pkgs?import{}}:pkgs.mkShell{ +{pkgs?import{}}:let + + suil = pkgs.enableDebugging (pkgs.suil.overrideAttrs (a: b: { + dontStrip = true; separateDebugInfo = true; + })); + +in pkgs.mkShell { nativeBuildInputs = with pkgs; [ pkg-config freetype