From 526b19074ea48798f8c35ff95d125872580f1e92 Mon Sep 17 00:00:00 2001 From: 21CSM <81891917+21CSM@users.noreply.github.com> Date: Sun, 15 Sep 2024 18:53:10 -0400 Subject: [PATCH] chore: add lldb --- .vscode/launch.json | 36 ++++++++++++++++++++++++++++++ .vscode/tasks.json | 29 ++++++++++++++++++++++++ flake.nix | 43 ++++-------------------------------- nix/checks/check-dev-env.nix | 38 +++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 39 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 nix/checks/check-dev-env.nix diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f82d5d2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Tauri Development Debug", + "cargo": { + "args": [ + "build", + "--manifest-path=./src-tauri/Cargo.toml", + "--no-default-features" + ] + }, + // task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json` + "preLaunchTask": "ui:dev" + }, + { + "type": "lldb", + "request": "launch", + "name": "Tauri Production Debug", + "cargo": { + "args": [ + "build", + "--release", + "--manifest-path=./src-tauri/Cargo.toml" + ] + }, + // task for the `beforeBuildCommand` if used, must be configured in `.vscode/tasks.json` + "preLaunchTask": "ui:build" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..d3e89b0 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,29 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "ui:dev", + "type": "shell", + // `dev` keeps running in the background + // ideally you should also configure a `problemMatcher` + // see https://code.visualstudio.com/docs/editor/tasks#_can-a-background-task-be-used-as-a-prelaunchtask-in-launchjson + "isBackground": true, + // change this to your `beforeDevCommand`: + "command": "pnpm", + "args": [ + "dev" + ] + }, + { + "label": "ui:build", + "type": "shell", + // change this to your `beforeBuildCommand`: + "command": "pnpm", + "args": [ + "build" + ] + } + ] +} diff --git a/flake.nix b/flake.nix index 0df6ede..e026bfa 100644 --- a/flake.nix +++ b/flake.nix @@ -28,8 +28,10 @@ cargo-tauri nodejs_20 pnpm - ] ++ lib.optionals stdenv.isLinux [ pkg-config glib gtk3 webkitgtk libsoup ] + ] ++ lib.optional (pkgs ? lldb) lldb + ++ lib.optionals stdenv.isLinux [ pkg-config glib gtk3 webkitgtk libsoup ] ++ lib.optionals stdenv.isDarwin [ libiconv darwin.apple_sdk.frameworks.WebKit ]; + checks = import ./nix/checks/check-dev-env.nix { inherit pkgs buildInputs; }; in { devShells.default = pkgs.mkShell { @@ -38,44 +40,7 @@ export PATH=${pkgs.lib.makeBinPath buildInputs}:$PATH ''; }; - checks.default = pkgs.runCommand "check-rust-tauri-env" - { - inherit buildInputs; - } '' - export PATH=${pkgs.lib.makeBinPath buildInputs}:$PATH - - # Check Rust toolchain - command -v rustc > /dev/null && command -v cargo > /dev/null || { echo "Rust toolchain not found"; exit 1; } - rustc --version | grep -q "rustc 1" || { echo "Incorrect Rust version"; exit 1; } - - # Check Tauri CLI - command -v cargo-tauri > /dev/null || { echo "Tauri CLI not found"; exit 1; } - cargo_tauri_version=$(cargo-tauri --version) - [[ $cargo_tauri_version == tauri-cli* && $cargo_tauri_version == *2.0.0* ]] || { echo "Incorrect Tauri CLI version: $cargo_tauri_version"; exit 1; } - - # Check Node.js and pnpm - command -v node > /dev/null || { echo "Node.js not found"; exit 1; } - command -v pnpm > /dev/null || { echo "pnpm not found"; exit 1; } - node --version | grep -q "v20" || { echo "Node.js version should be 20.x"; exit 1; } - - # Check OpenSSL - command -v openssl > /dev/null || { echo "OpenSSL not found"; exit 1; } - - ${pkgs.lib.optionalString pkgs.stdenv.isLinux '' - # Linux-specific checks - pkg-config --exists gtk+-3.0 || { echo "GTK3 not found"; exit 1; } - pkg-config --exists webkit2gtk-4.0 || { echo "WebKitGTK not found"; exit 1; } - pkg-config --exists libsoup-2.4 || { echo "libsoup not found"; exit 1; } - ''} - - ${pkgs.lib.optionalString pkgs.stdenv.isDarwin '' - # macOS-specific checks - [ -d /System/Library/Frameworks/WebKit.framework ] || { echo "WebKit framework not found"; exit 1; } - ''} - - echo "All checks passed" - touch $out - ''; + checks.default = checks; formatter = pkgs.nixpkgs-fmt; } ); diff --git a/nix/checks/check-dev-env.nix b/nix/checks/check-dev-env.nix new file mode 100644 index 0000000..c7c9179 --- /dev/null +++ b/nix/checks/check-dev-env.nix @@ -0,0 +1,38 @@ +{ pkgs, buildInputs }: + +pkgs.runCommand "check-dev-env" +{ + inherit buildInputs; +} '' + export PATH=${pkgs.lib.makeBinPath buildInputs}:$PATH + # Check Rust toolchain + command -v rustc > /dev/null && command -v cargo > /dev/null || { echo "Rust toolchain not found"; exit 1; } + rustc --version | grep -q "rustc 1" || { echo "Incorrect Rust version"; exit 1; } + # Check Tauri CLI + command -v cargo-tauri > /dev/null || { echo "Tauri CLI not found"; exit 1; } + cargo_tauri_version=$(cargo-tauri --version) + [[ $cargo_tauri_version == tauri-cli* && $cargo_tauri_version == *2.0.0* ]] || { echo "Incorrect Tauri CLI version: $cargo_tauri_version"; exit 1; } + # Check Node.js and pnpm + command -v node > /dev/null || { echo "Node.js not found"; exit 1; } + command -v pnpm > /dev/null || { echo "pnpm not found"; exit 1; } + node --version | grep -q "v20" || { echo "Node.js version should be 20.x"; exit 1; } + # Check OpenSSL + command -v openssl > /dev/null || { echo "OpenSSL not found"; exit 1; } + # Check LLDB + ${pkgs.lib.optionalString (pkgs ? lldb) '' + command -v lldb > /dev/null || { echo "LLDB not found"; exit 1; } + lldb --version | grep -q "lldb version" || { echo "Incorrect LLDB version"; exit 1; } + ''} + ${pkgs.lib.optionalString pkgs.stdenv.isLinux '' + # Linux-specific checks + pkg-config --exists gtk+-3.0 || { echo "GTK3 not found"; exit 1; } + pkg-config --exists webkit2gtk-4.0 || { echo "WebKitGTK not found"; exit 1; } + pkg-config --exists libsoup-2.4 || { echo "libsoup not found"; exit 1; } + ''} + ${pkgs.lib.optionalString pkgs.stdenv.isDarwin '' + # macOS-specific checks + [ -d /System/Library/Frameworks/WebKit.framework ] || { echo "WebKit framework not found"; exit 1; } + ''} + echo "All checks passed" + touch $out +''