From 672d69ef7553466673b27f6ad62b8e9d9c104caf Mon Sep 17 00:00:00 2001 From: maxstrb Date: Mon, 23 Feb 2026 14:15:12 +0100 Subject: [PATCH] qalc integrated --- .../30kd4b18byfkr392j9m875zhmn26b0lh-source | 1 - .../s1vk23a6wl4q1bq5h35nzf19pnac2il2-source | 1 + ...e-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa | 2 +- ...5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc | 39 ++++-- Cargo.lock | 125 +++++++++++++++++- Cargo.toml | 6 + build.rs | 21 +++ flake.nix | 10 ++ src/main.rs | 17 ++- src/qalc_bridge.cc | 20 +++ src/qalc_bridge.h | 5 + 11 files changed, 231 insertions(+), 16 deletions(-) delete mode 120000 .direnv/flake-inputs/30kd4b18byfkr392j9m875zhmn26b0lh-source create mode 120000 .direnv/flake-inputs/s1vk23a6wl4q1bq5h35nzf19pnac2il2-source create mode 100644 build.rs create mode 100644 src/qalc_bridge.cc create mode 100644 src/qalc_bridge.h diff --git a/.direnv/flake-inputs/30kd4b18byfkr392j9m875zhmn26b0lh-source b/.direnv/flake-inputs/30kd4b18byfkr392j9m875zhmn26b0lh-source deleted file mode 120000 index 67f70d0..0000000 --- a/.direnv/flake-inputs/30kd4b18byfkr392j9m875zhmn26b0lh-source +++ /dev/null @@ -1 +0,0 @@ -/nix/store/30kd4b18byfkr392j9m875zhmn26b0lh-source \ No newline at end of file diff --git a/.direnv/flake-inputs/s1vk23a6wl4q1bq5h35nzf19pnac2il2-source b/.direnv/flake-inputs/s1vk23a6wl4q1bq5h35nzf19pnac2il2-source new file mode 120000 index 0000000..dfabc37 --- /dev/null +++ b/.direnv/flake-inputs/s1vk23a6wl4q1bq5h35nzf19pnac2il2-source @@ -0,0 +1 @@ +/nix/store/s1vk23a6wl4q1bq5h35nzf19pnac2il2-source \ No newline at end of file diff --git a/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa index a5e0bdc..b8054e5 120000 --- a/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa +++ b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa @@ -1 +1 @@ -/nix/store/zw6zvmvd7w63wm8y562m4hjj2w3gixz4-nix-shell-env \ No newline at end of file +/nix/store/qizs95jwbrx9zb135llw3mm0fm3ijaki-nix-shell-env \ No newline at end of file diff --git a/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc index 0150c11..91dea95 100644 --- a/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc +++ b/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc @@ -23,7 +23,7 @@ export CXX CXX_FOR_TARGET='g++' export CXX_FOR_TARGET HOSTTYPE='x86_64' -HOST_PATH='/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0/bin:/nix/store/i6ppbrlpp6yki8qvka7nyv091xa8dchx-binutils-wrapper-2.44/bin:/nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/bin:/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/bin:/nix/store/hvivh16a630cwbc73j6l60r9z7q4311g-evcxr-0.21.1/bin:/nix/store/rvp7qlpf5jqvdckjy1afjb6aha6j8dxg-pkg-config-wrapper-0.29.2/bin:/nix/store/i2vmgx46q9hd3z6rigaiman3wl3i2gc4-coreutils-9.9/bin:/nix/store/16wfacfgap3chf7mcjnd8dwi85dj4qqi-findutils-4.10.0/bin:/nix/store/3p87h6dn5i87i3iq9364imzbqgwvkg2p-diffutils-3.12/bin:/nix/store/ryz8kcrm2bxpccllfqlb7qldsfnqp5c2-gnused-4.9/bin:/nix/store/02vv0r262agf9j5n2y1gmbjvdf12zkl0-gnugrep-3.12/bin:/nix/store/2xq9rayckw8zq26k274xxlikn77jn60j-gawk-5.3.2/bin:/nix/store/qyg62bc2xnpwz0fa9prqxvvk00zj4g9q-gnutar-1.35/bin:/nix/store/84yyzmxs7mb8nhkvcfv9n1l9irpb6mnq-gzip-1.14/bin:/nix/store/90yw24gqmwph4xjp4mqhpx1y1gcrvqla-bzip2-1.0.8-bin/bin:/nix/store/vbah5c4rzy1q1hbqhginyxjhj8d4dj8j-gnumake-4.4.1/bin:/nix/store/f15k3dpilmiyv6zgpib289rnjykgr1r4-bash-5.3p9/bin:/nix/store/wwij6563c6wbg4kzgjhng7vlhf7api19-patch-2.8/bin:/nix/store/zys6d102zp171wpwcs08g632886w2qxs-xz-5.8.2-bin/bin:/nix/store/nyy0bvgjwd98x7ih8pl6pr79qjljgsf7-file-5.45/bin' +HOST_PATH='/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0/bin:/nix/store/i6ppbrlpp6yki8qvka7nyv091xa8dchx-binutils-wrapper-2.44/bin:/nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/bin:/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/bin:/nix/store/hvivh16a630cwbc73j6l60r9z7q4311g-evcxr-0.21.1/bin:/nix/store/rvp7qlpf5jqvdckjy1afjb6aha6j8dxg-pkg-config-wrapper-0.29.2/bin:/nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev/bin:/nix/store/r40kqrp7ghjypfc0p9kjwgb14mxmjciw-libxml2-2.15.1-bin/bin:/nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev/bin:/nix/store/wwkx16bp7i0v7qalqc3cdqr477pc21h8-libqalculate-5.9.0/bin:/nix/store/i2vmgx46q9hd3z6rigaiman3wl3i2gc4-coreutils-9.9/bin:/nix/store/16wfacfgap3chf7mcjnd8dwi85dj4qqi-findutils-4.10.0/bin:/nix/store/3p87h6dn5i87i3iq9364imzbqgwvkg2p-diffutils-3.12/bin:/nix/store/ryz8kcrm2bxpccllfqlb7qldsfnqp5c2-gnused-4.9/bin:/nix/store/02vv0r262agf9j5n2y1gmbjvdf12zkl0-gnugrep-3.12/bin:/nix/store/2xq9rayckw8zq26k274xxlikn77jn60j-gawk-5.3.2/bin:/nix/store/qyg62bc2xnpwz0fa9prqxvvk00zj4g9q-gnutar-1.35/bin:/nix/store/84yyzmxs7mb8nhkvcfv9n1l9irpb6mnq-gzip-1.14/bin:/nix/store/90yw24gqmwph4xjp4mqhpx1y1gcrvqla-bzip2-1.0.8-bin/bin:/nix/store/vbah5c4rzy1q1hbqhginyxjhj8d4dj8j-gnumake-4.4.1/bin:/nix/store/f15k3dpilmiyv6zgpib289rnjykgr1r4-bash-5.3p9/bin:/nix/store/wwij6563c6wbg4kzgjhng7vlhf7api19-patch-2.8/bin:/nix/store/zys6d102zp171wpwcs08g632886w2qxs-xz-5.8.2-bin/bin:/nix/store/nyy0bvgjwd98x7ih8pl6pr79qjljgsf7-file-5.45/bin' export HOST_PATH IFS=' ' @@ -55,17 +55,17 @@ NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu='1' export NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu NIX_CC_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu='1' export NIX_CC_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu -NIX_CFLAGS_COMPILE=' -frandom-seed=zw6zvmvd7w -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include' +NIX_CFLAGS_COMPILE=' -frandom-seed=qizs95jwbr -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include -isystem /nix/store/igdxf5xmwv09hpcpaz0nd6ik4l3hj44f-libqalculate-5.9.0-dev/include -isystem /nix/store/igdxf5xmwv09hpcpaz0nd6ik4l3hj44f-libqalculate-5.9.0-dev/include -isystem /nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev/include -isystem /nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev/include -isystem /nix/store/g3p48clv29ck5mmhj5qkq6f5yww3kfb6-mpfr-4.2.2-dev/include -isystem /nix/store/g3p48clv29ck5mmhj5qkq6f5yww3kfb6-mpfr-4.2.2-dev/include -isystem /nix/store/fy6kfb982l4aalzlj00fzdmy1i481pjj-gmp-with-cxx-6.3.0-dev/include -isystem /nix/store/fy6kfb982l4aalzlj00fzdmy1i481pjj-gmp-with-cxx-6.3.0-dev/include -isystem /nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev/include -isystem /nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev/include -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include -isystem /nix/store/igdxf5xmwv09hpcpaz0nd6ik4l3hj44f-libqalculate-5.9.0-dev/include -isystem /nix/store/igdxf5xmwv09hpcpaz0nd6ik4l3hj44f-libqalculate-5.9.0-dev/include -isystem /nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev/include -isystem /nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev/include -isystem /nix/store/g3p48clv29ck5mmhj5qkq6f5yww3kfb6-mpfr-4.2.2-dev/include -isystem /nix/store/g3p48clv29ck5mmhj5qkq6f5yww3kfb6-mpfr-4.2.2-dev/include -isystem /nix/store/fy6kfb982l4aalzlj00fzdmy1i481pjj-gmp-with-cxx-6.3.0-dev/include -isystem /nix/store/fy6kfb982l4aalzlj00fzdmy1i481pjj-gmp-with-cxx-6.3.0-dev/include -isystem /nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev/include -isystem /nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev/include' export NIX_CFLAGS_COMPILE -NIX_CFLAGS_COMPILE_FOR_TARGET=' -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include' +NIX_CFLAGS_COMPILE_FOR_TARGET=' -isystem /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/include -isystem /nix/store/igdxf5xmwv09hpcpaz0nd6ik4l3hj44f-libqalculate-5.9.0-dev/include -isystem /nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev/include -isystem /nix/store/g3p48clv29ck5mmhj5qkq6f5yww3kfb6-mpfr-4.2.2-dev/include -isystem /nix/store/fy6kfb982l4aalzlj00fzdmy1i481pjj-gmp-with-cxx-6.3.0-dev/include -isystem /nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev/include' export NIX_CFLAGS_COMPILE_FOR_TARGET NIX_ENFORCE_NO_NATIVE='1' export NIX_ENFORCE_NO_NATIVE NIX_HARDENING_ENABLE='bindnow format fortify fortify3 libcxxhardeningextensive libcxxhardeningfast pic relro stackclashprotection stackprotector strictoverflow zerocallusedregs' export NIX_HARDENING_ENABLE -NIX_LDFLAGS='-rpath /mnt/removable/Projects/Rust/floating-calculator/outputs/out/lib -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib' +NIX_LDFLAGS='-rpath /mnt/removable/Projects/Rust/floating-calculator/outputs/out/lib -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib -L/nix/store/81cfgyhfaadhh0vs4nf74yhcclgbav87-libxml2-2.15.1/lib -L/nix/store/81cfgyhfaadhh0vs4nf74yhcclgbav87-libxml2-2.15.1/lib -L/nix/store/c5p8phmycgqjfrwzf0cpc740b6gvdac5-gmp-with-cxx-6.3.0/lib -L/nix/store/c5p8phmycgqjfrwzf0cpc740b6gvdac5-gmp-with-cxx-6.3.0/lib -L/nix/store/rx9c12rcc10273xrgb21kcpglddh1sry-mpfr-4.2.2/lib -L/nix/store/rx9c12rcc10273xrgb21kcpglddh1sry-mpfr-4.2.2/lib -L/nix/store/q34rjcffjcmhbnsx8nd6w0i2xamz66i3-icu4c-76.1/lib -L/nix/store/q34rjcffjcmhbnsx8nd6w0i2xamz66i3-icu4c-76.1/lib -L/nix/store/wwkx16bp7i0v7qalqc3cdqr477pc21h8-libqalculate-5.9.0/lib -L/nix/store/wwkx16bp7i0v7qalqc3cdqr477pc21h8-libqalculate-5.9.0/lib -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib -L/nix/store/81cfgyhfaadhh0vs4nf74yhcclgbav87-libxml2-2.15.1/lib -L/nix/store/81cfgyhfaadhh0vs4nf74yhcclgbav87-libxml2-2.15.1/lib -L/nix/store/c5p8phmycgqjfrwzf0cpc740b6gvdac5-gmp-with-cxx-6.3.0/lib -L/nix/store/c5p8phmycgqjfrwzf0cpc740b6gvdac5-gmp-with-cxx-6.3.0/lib -L/nix/store/rx9c12rcc10273xrgb21kcpglddh1sry-mpfr-4.2.2/lib -L/nix/store/rx9c12rcc10273xrgb21kcpglddh1sry-mpfr-4.2.2/lib -L/nix/store/q34rjcffjcmhbnsx8nd6w0i2xamz66i3-icu4c-76.1/lib -L/nix/store/q34rjcffjcmhbnsx8nd6w0i2xamz66i3-icu4c-76.1/lib -L/nix/store/wwkx16bp7i0v7qalqc3cdqr477pc21h8-libqalculate-5.9.0/lib -L/nix/store/wwkx16bp7i0v7qalqc3cdqr477pc21h8-libqalculate-5.9.0/lib' export NIX_LDFLAGS -NIX_LDFLAGS_FOR_TARGET=' -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib' +NIX_LDFLAGS_FOR_TARGET=' -L/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/lib -L/nix/store/81cfgyhfaadhh0vs4nf74yhcclgbav87-libxml2-2.15.1/lib -L/nix/store/c5p8phmycgqjfrwzf0cpc740b6gvdac5-gmp-with-cxx-6.3.0/lib -L/nix/store/rx9c12rcc10273xrgb21kcpglddh1sry-mpfr-4.2.2/lib -L/nix/store/q34rjcffjcmhbnsx8nd6w0i2xamz66i3-icu4c-76.1/lib -L/nix/store/wwkx16bp7i0v7qalqc3cdqr477pc21h8-libqalculate-5.9.0/lib' export NIX_LDFLAGS_FOR_TARGET NIX_NO_SELF_RPATH='1' NIX_PKG_CONFIG_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu='1' @@ -88,10 +88,12 @@ OLDPWD='' export OLDPWD OPTERR='1' OSTYPE='linux-gnu' -PATH='/nix/store/c2p7haf4zzkbrir9zs662r68c5dmylbq-patchelf-0.15.2/bin:/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0/bin:/nix/store/mjf8jlq9grydcdvyw6hb063x5c34g5gf-gcc-15.2.0/bin:/nix/store/0bdqq2z98kg2hfn3k60if6pb5fd5p10h-glibc-2.42-47-bin/bin:/nix/store/i2vmgx46q9hd3z6rigaiman3wl3i2gc4-coreutils-9.9/bin:/nix/store/i6ppbrlpp6yki8qvka7nyv091xa8dchx-binutils-wrapper-2.44/bin:/nix/store/47mn80zqpygykqailwzw8zlag4cgl75q-binutils-2.44/bin:/nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/bin:/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/bin:/nix/store/hvivh16a630cwbc73j6l60r9z7q4311g-evcxr-0.21.1/bin:/nix/store/rvp7qlpf5jqvdckjy1afjb6aha6j8dxg-pkg-config-wrapper-0.29.2/bin:/nix/store/i2vmgx46q9hd3z6rigaiman3wl3i2gc4-coreutils-9.9/bin:/nix/store/16wfacfgap3chf7mcjnd8dwi85dj4qqi-findutils-4.10.0/bin:/nix/store/3p87h6dn5i87i3iq9364imzbqgwvkg2p-diffutils-3.12/bin:/nix/store/ryz8kcrm2bxpccllfqlb7qldsfnqp5c2-gnused-4.9/bin:/nix/store/02vv0r262agf9j5n2y1gmbjvdf12zkl0-gnugrep-3.12/bin:/nix/store/2xq9rayckw8zq26k274xxlikn77jn60j-gawk-5.3.2/bin:/nix/store/qyg62bc2xnpwz0fa9prqxvvk00zj4g9q-gnutar-1.35/bin:/nix/store/84yyzmxs7mb8nhkvcfv9n1l9irpb6mnq-gzip-1.14/bin:/nix/store/90yw24gqmwph4xjp4mqhpx1y1gcrvqla-bzip2-1.0.8-bin/bin:/nix/store/vbah5c4rzy1q1hbqhginyxjhj8d4dj8j-gnumake-4.4.1/bin:/nix/store/f15k3dpilmiyv6zgpib289rnjykgr1r4-bash-5.3p9/bin:/nix/store/wwij6563c6wbg4kzgjhng7vlhf7api19-patch-2.8/bin:/nix/store/zys6d102zp171wpwcs08g632886w2qxs-xz-5.8.2-bin/bin:/nix/store/nyy0bvgjwd98x7ih8pl6pr79qjljgsf7-file-5.45/bin' +PATH='/nix/store/c2p7haf4zzkbrir9zs662r68c5dmylbq-patchelf-0.15.2/bin:/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0/bin:/nix/store/mjf8jlq9grydcdvyw6hb063x5c34g5gf-gcc-15.2.0/bin:/nix/store/0bdqq2z98kg2hfn3k60if6pb5fd5p10h-glibc-2.42-47-bin/bin:/nix/store/i2vmgx46q9hd3z6rigaiman3wl3i2gc4-coreutils-9.9/bin:/nix/store/i6ppbrlpp6yki8qvka7nyv091xa8dchx-binutils-wrapper-2.44/bin:/nix/store/47mn80zqpygykqailwzw8zlag4cgl75q-binutils-2.44/bin:/nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1/bin:/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1/bin:/nix/store/hvivh16a630cwbc73j6l60r9z7q4311g-evcxr-0.21.1/bin:/nix/store/rvp7qlpf5jqvdckjy1afjb6aha6j8dxg-pkg-config-wrapper-0.29.2/bin:/nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev/bin:/nix/store/r40kqrp7ghjypfc0p9kjwgb14mxmjciw-libxml2-2.15.1-bin/bin:/nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev/bin:/nix/store/wwkx16bp7i0v7qalqc3cdqr477pc21h8-libqalculate-5.9.0/bin:/nix/store/i2vmgx46q9hd3z6rigaiman3wl3i2gc4-coreutils-9.9/bin:/nix/store/16wfacfgap3chf7mcjnd8dwi85dj4qqi-findutils-4.10.0/bin:/nix/store/3p87h6dn5i87i3iq9364imzbqgwvkg2p-diffutils-3.12/bin:/nix/store/ryz8kcrm2bxpccllfqlb7qldsfnqp5c2-gnused-4.9/bin:/nix/store/02vv0r262agf9j5n2y1gmbjvdf12zkl0-gnugrep-3.12/bin:/nix/store/2xq9rayckw8zq26k274xxlikn77jn60j-gawk-5.3.2/bin:/nix/store/qyg62bc2xnpwz0fa9prqxvvk00zj4g9q-gnutar-1.35/bin:/nix/store/84yyzmxs7mb8nhkvcfv9n1l9irpb6mnq-gzip-1.14/bin:/nix/store/90yw24gqmwph4xjp4mqhpx1y1gcrvqla-bzip2-1.0.8-bin/bin:/nix/store/vbah5c4rzy1q1hbqhginyxjhj8d4dj8j-gnumake-4.4.1/bin:/nix/store/f15k3dpilmiyv6zgpib289rnjykgr1r4-bash-5.3p9/bin:/nix/store/wwij6563c6wbg4kzgjhng7vlhf7api19-patch-2.8/bin:/nix/store/zys6d102zp171wpwcs08g632886w2qxs-xz-5.8.2-bin/bin:/nix/store/nyy0bvgjwd98x7ih8pl6pr79qjljgsf7-file-5.45/bin' export PATH PKG_CONFIG_FOR_TARGET='pkg-config' export PKG_CONFIG_FOR_TARGET +PKG_CONFIG_PATH_FOR_TARGET='/nix/store/igdxf5xmwv09hpcpaz0nd6ik4l3hj44f-libqalculate-5.9.0-dev/lib/pkgconfig:/nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev/lib/pkgconfig:/nix/store/g3p48clv29ck5mmhj5qkq6f5yww3kfb6-mpfr-4.2.2-dev/lib/pkgconfig:/nix/store/fy6kfb982l4aalzlj00fzdmy1i481pjj-gmp-with-cxx-6.3.0-dev/lib/pkgconfig:/nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev/lib/pkgconfig' +export PKG_CONFIG_PATH_FOR_TARGET PS4='+ ' RANLIB='ranlib' export RANLIB @@ -119,10 +121,12 @@ STRIP_FOR_TARGET='strip' export STRIP_FOR_TARGET XDG_DATA_DIRS='/nix/store/c2p7haf4zzkbrir9zs662r68c5dmylbq-patchelf-0.15.2/share' export XDG_DATA_DIRS +XML_CATALOG_FILES=' ' +export XML_CATALOG_FILES __structuredAttrs='' export __structuredAttrs _substituteStream_has_warned_replace_deprecation='false' -buildInputs='/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0 /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1 /nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1 /nix/store/hvivh16a630cwbc73j6l60r9z7q4311g-evcxr-0.21.1 /nix/store/rvp7qlpf5jqvdckjy1afjb6aha6j8dxg-pkg-config-wrapper-0.29.2' +buildInputs='/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0 /nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1 /nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1 /nix/store/hvivh16a630cwbc73j6l60r9z7q4311g-evcxr-0.21.1 /nix/store/rvp7qlpf5jqvdckjy1afjb6aha6j8dxg-pkg-config-wrapper-0.29.2 /nix/store/igdxf5xmwv09hpcpaz0nd6ik4l3hj44f-libqalculate-5.9.0-dev' export buildInputs buildPhase='{ echo "------------------------------------------------------------"; echo " WARNING: the existence of this path is not guaranteed."; @@ -167,11 +171,12 @@ export dontAddDisableDepTrack declare -a envBuildBuildHooks=() declare -a envBuildHostHooks=() declare -a envBuildTargetHooks=() -declare -a envHostHostHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' 'ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' ) -declare -a envHostTargetHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' 'ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' ) +declare -a envHostHostHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' 'ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' 'addXMLCatalogs' ) +declare -a envHostTargetHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' 'ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' 'addXMLCatalogs' ) declare -a envTargetTargetHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' 'pkgConfigWrapper_addPkgConfigPath' ) declare -a fixupOutputHooks=('if [ -z "${dontPatchELF-}" ]; then patchELF "$prefix"; fi' 'if [[ -z "${noAuditTmpdir-}" && -e "$prefix" ]]; then auditTmpdir "$prefix"; fi' 'if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi' '_moveLib64' '_moveSbin' '_moveSystemdUserUnits' 'patchShebangsAuto' '_pruneLibtoolFiles' '_doStrip' ) initialPath='/nix/store/i2vmgx46q9hd3z6rigaiman3wl3i2gc4-coreutils-9.9 /nix/store/16wfacfgap3chf7mcjnd8dwi85dj4qqi-findutils-4.10.0 /nix/store/3p87h6dn5i87i3iq9364imzbqgwvkg2p-diffutils-3.12 /nix/store/ryz8kcrm2bxpccllfqlb7qldsfnqp5c2-gnused-4.9 /nix/store/02vv0r262agf9j5n2y1gmbjvdf12zkl0-gnugrep-3.12 /nix/store/2xq9rayckw8zq26k274xxlikn77jn60j-gawk-5.3.2 /nix/store/qyg62bc2xnpwz0fa9prqxvvk00zj4g9q-gnutar-1.35 /nix/store/84yyzmxs7mb8nhkvcfv9n1l9irpb6mnq-gzip-1.14 /nix/store/90yw24gqmwph4xjp4mqhpx1y1gcrvqla-bzip2-1.0.8-bin /nix/store/vbah5c4rzy1q1hbqhginyxjhj8d4dj8j-gnumake-4.4.1 /nix/store/f15k3dpilmiyv6zgpib289rnjykgr1r4-bash-5.3p9 /nix/store/wwij6563c6wbg4kzgjhng7vlhf7api19-patch-2.8 /nix/store/zys6d102zp171wpwcs08g632886w2qxs-xz-5.8.2-bin /nix/store/nyy0bvgjwd98x7ih8pl6pr79qjljgsf7-file-5.45' +libxmlHookDone='1' mesonFlags='' export mesonFlags name='nix-shell-env' @@ -200,7 +205,7 @@ declare -a pkgsBuildBuild=() declare -a pkgsBuildHost=('/nix/store/c2p7haf4zzkbrir9zs662r68c5dmylbq-patchelf-0.15.2' '/nix/store/y03z7y8cgdck7vk8qpim30vps4d22gzv-update-autotools-gnu-config-scripts-hook' '/nix/store/0y5xmdb7qfvimjwbq7ibg1xdgkgjwqng-no-broken-symlinks.sh' '/nix/store/cv1d7p48379km6a85h4zp6kr86brh32q-audit-tmpdir.sh' '/nix/store/85clx3b0xkdf58jn161iy80y5223ilbi-compress-man-pages.sh' '/nix/store/p3l1a5y7nllfyrjn2krlwgcc3z0cd3fq-make-symlinks-relative.sh' '/nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh' '/nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh' '/nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh' '/nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh' '/nix/store/cmzya9irvxzlkh7lfy6i82gbp0saxqj3-multiple-outputs.sh' '/nix/store/x8c40nfigps493a07sdr2pm5s9j1cdc0-patch-shebangs.sh' '/nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh' '/nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh' '/nix/store/z7k98578dfzi6l3hsvbivzm7hfqlk0zc-set-source-date-epoch-to-latest.sh' '/nix/store/pilsssjjdxvdphlg2h19p0bfx5q0jzkn-strip.sh' '/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0' '/nix/store/i6ppbrlpp6yki8qvka7nyv091xa8dchx-binutils-wrapper-2.44' ) declare -a pkgsBuildTarget=() declare -a pkgsHostHost=('/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0' '/nix/store/i6ppbrlpp6yki8qvka7nyv091xa8dchx-binutils-wrapper-2.44' ) -declare -a pkgsHostTarget=('/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0' '/nix/store/i6ppbrlpp6yki8qvka7nyv091xa8dchx-binutils-wrapper-2.44' '/nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1' '/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1' '/nix/store/hvivh16a630cwbc73j6l60r9z7q4311g-evcxr-0.21.1' '/nix/store/rvp7qlpf5jqvdckjy1afjb6aha6j8dxg-pkg-config-wrapper-0.29.2' ) +declare -a pkgsHostTarget=('/nix/store/a245z3cvf9x9sn0xlk6k8j9xhxbhda1z-gcc-wrapper-15.2.0' '/nix/store/i6ppbrlpp6yki8qvka7nyv091xa8dchx-binutils-wrapper-2.44' '/nix/store/5lyy21zm97pj8l67r2xapdkxpxb6v6y0-gnumake-4.4.1' '/nix/store/9k0snv1492aqrkahlai724yd53qszh7z-rust-default-1.93.1' '/nix/store/hvivh16a630cwbc73j6l60r9z7q4311g-evcxr-0.21.1' '/nix/store/rvp7qlpf5jqvdckjy1afjb6aha6j8dxg-pkg-config-wrapper-0.29.2' '/nix/store/igdxf5xmwv09hpcpaz0nd6ik4l3hj44f-libqalculate-5.9.0-dev' '/nix/store/yl9p47yg3qzw1xf9b3pnfav0mgy1qik9-libxml2-2.15.1-dev' '/nix/store/x3li8bcdrgnwfh397sjfk1sgsbax6wxn-find-xml-catalogs-hook' '/nix/store/r40kqrp7ghjypfc0p9kjwgb14mxmjciw-libxml2-2.15.1-bin' '/nix/store/81cfgyhfaadhh0vs4nf74yhcclgbav87-libxml2-2.15.1' '/nix/store/g3p48clv29ck5mmhj5qkq6f5yww3kfb6-mpfr-4.2.2-dev' '/nix/store/fy6kfb982l4aalzlj00fzdmy1i481pjj-gmp-with-cxx-6.3.0-dev' '/nix/store/c5p8phmycgqjfrwzf0cpc740b6gvdac5-gmp-with-cxx-6.3.0' '/nix/store/rx9c12rcc10273xrgb21kcpglddh1sry-mpfr-4.2.2' '/nix/store/y3b549nnjrn2apah7mfwzz6zwnidpflq-icu4c-76.1-dev' '/nix/store/q34rjcffjcmhbnsx8nd6w0i2xamz66i3-icu4c-76.1' '/nix/store/wwkx16bp7i0v7qalqc3cdqr477pc21h8-libqalculate-5.9.0' ) declare -a pkgsTargetTarget=() declare -a postFixupHooks=('noBrokenSymlinksInAllOutputs' '_makeSymlinksRelative' '_multioutPropagateDev' ) declare -a postUnpackHooks=('_updateSourceDateEpochFromSourceRoot' ) @@ -754,6 +759,20 @@ addToSearchPathWithCustomDelimiter () export "${varName}=${!varName:+${!varName}${delimiter}}${dir}"; fi } +addXMLCatalogs () +{ + + local d i; + for d in $1/share/xml $1/xml/dtd $1/xml/xsl; + do + if [ -d $d ]; then + for i in $(find $d -name catalog.xml); + do + XML_CATALOG_FILES+=" $i"; + done; + fi; + done +} appendToVar () { diff --git a/Cargo.lock b/Cargo.lock index 53c32af..bd0d31f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,6 +76,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + [[package]] name = "anyhow" version = "1.0.102" @@ -435,6 +441,32 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "clap" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +dependencies = [ + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" + [[package]] name = "clipboard-win" version = "5.4.1" @@ -485,6 +517,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + [[package]] name = "combine" version = "4.6.7" @@ -635,6 +678,68 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" +[[package]] +name = "cxx" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747d8437319e3a2f43d93b341c137927ca70c0f5dabeea7a005a73665e247c7e" +dependencies = [ + "cc", + "cxx-build", + "cxxbridge-cmd", + "cxxbridge-flags", + "cxxbridge-macro", + "foldhash 0.2.0", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0f4697d190a142477b16aef7da8a99bfdc41e7e8b1687583c0d23a79c7afc1e" +dependencies = [ + "cc", + "codespan-reporting 0.13.1", + "indexmap", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-cmd" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0956799fa8678d4c50eed028f2de1c0552ae183c76e976cf7ca8c4e36a7c328" +dependencies = [ + "clap", + "codespan-reporting 0.13.1", + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23384a836ab4f0ad98ace7e3955ad2de39de42378ab487dc28d3990392cb283a" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6acc6b5822b9526adfb4fc377b67128fdd60aac757cc4a741a6278603f763cf" +dependencies = [ + "indexmap", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "darling" version = "0.20.11" @@ -821,8 +926,11 @@ checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" name = "floating-calculator" version = "0.1.0" dependencies = [ + "cxx", + "cxx-build", "iced", "iced_layershell", + "pkg-config", ] [[package]] @@ -1627,6 +1735,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" +[[package]] +name = "link-cplusplus" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f78c730aaa7d0b9336a299029ea49f9ee53b0ed06e9202e8cb7db9bae7b8c82" +dependencies = [ + "cc", +] + [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -1775,7 +1892,7 @@ dependencies = [ "bitflags 2.11.0", "cfg-if", "cfg_aliases", - "codespan-reporting", + "codespan-reporting 0.12.0", "half", "hashbrown 0.16.1", "hexf-parse", @@ -2582,6 +2699,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scratch" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" + [[package]] name = "sctk-adwaita" version = "0.10.1" diff --git a/Cargo.toml b/Cargo.toml index b47d7b4..4e39615 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,11 @@ version = "0.1.0" edition = "2024" [dependencies] +cxx = "1.0.194" iced = "0.14.0" iced_layershell = "0.15.0" + + +[build-dependencies] +cxx-build = "1.0" +pkg-config = "0.3" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..a9de17e --- /dev/null +++ b/build.rs @@ -0,0 +1,21 @@ +fn main() { + let lib = pkg_config::probe_library("libqalculate").expect("libqalculate not found"); + + cxx_build::bridge("src/main.rs") + .file("src/qalc_bridge.cc") + .includes(&lib.include_paths) + .include("src") + .flag_if_supported("-std=c++17") + .compiler("g++") + .compile("qalc-bridge"); + + println!( + "cargo:rustc-link-search=native={}", + std::env::var("OUT_DIR").unwrap() + ); + println!("cargo:rustc-link-lib=static=qalc-bridge"); + + println!("cargo:rerun-if-changed=src/main.rs"); + println!("cargo:rerun-if-changed=src/qalc_bridge.cc"); + println!("cargo:rerun-if-changed=src/qalc_bridge.h"); +} diff --git a/flake.nix b/flake.nix index e228948..346fdd1 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,15 @@ version = "0.1.0"; src = ./.; cargoLock.lockFile = ./Cargo.lock; + + nativeBuildInputs = with pkgs; [ + pkg-config + gcc + ]; + + buildInputs = with pkgs; [ + libqalculate + ]; }; }; @@ -36,6 +45,7 @@ rustToolchain evcxr pkg-config + libqalculate ]; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; [ diff --git a/src/main.rs b/src/main.rs index bd7e060..3a50cae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,17 @@ use iced_layershell::reexport::Anchor; use iced_layershell::settings::{LayerShellSettings, Settings, StartMode}; use iced_layershell::to_layer_message; +#[cxx::bridge] +mod ffi { + unsafe extern "C++" { + include!("floating-calculator/src/qalc_bridge.h"); + fn qalc_calculate(expression: &str, timeout_ms: i32) -> String; + } +} + pub fn main() -> Result<(), iced_layershell::Error> { + let _ = ffi::qalc_calculate("", 2000); + let binded_output_name = std::env::args().nth(1); let start_mode = match binded_output_name { Some(output) => StartMode::TargetScreen(output), @@ -70,9 +80,10 @@ fn update(state: &mut State, message: Message) -> Command { Command::none() } Message::TextSubmit => { - state - .history - .push(std::mem::take(&mut state.current_message)); + state.history.push(ffi::qalc_calculate( + &std::mem::take(&mut state.current_message), + 2000, + )); Command::none() } diff --git a/src/qalc_bridge.cc b/src/qalc_bridge.cc new file mode 100644 index 0000000..3aad822 --- /dev/null +++ b/src/qalc_bridge.cc @@ -0,0 +1,20 @@ +#include "floating-calculator/src/qalc_bridge.h" +#include "floating-calculator/src/main.rs.h" +#include + +static Calculator *get_calculator() { + static Calculator *calc = nullptr; + if (!calc) { + calc = new Calculator(); + calc->loadGlobalDefinitions(); + calc->loadLocalDefinitions(); + } + return calc; +} + +rust::String qalc_calculate(rust::Str expression, int32_t timeout_ms) { + Calculator *calc = get_calculator(); + std::string expr(expression.data(), expression.size()); + std::string result = calc->calculateAndPrint(expr, timeout_ms); + return rust::String(result); +} diff --git a/src/qalc_bridge.h b/src/qalc_bridge.h new file mode 100644 index 0000000..0a6922b --- /dev/null +++ b/src/qalc_bridge.h @@ -0,0 +1,5 @@ +#pragma once +#include "rust/cxx.h" +#include + +rust::String qalc_calculate(rust::Str expression, int32_t timeout_ms);