Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dist
dist-ssr
*.local

.rustup/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
Expand Down
89 changes: 89 additions & 0 deletions scripts/cargo
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_PATH="$(readlink -f "$0")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"

find_real_cargo() {
local candidates=()
if [[ -n "${CARGO_REAL:-}" ]]; then
candidates+=("$CARGO_REAL")
fi
if [[ -n "${HOME:-}" ]]; then
candidates+=("$HOME/.cargo/bin/cargo")
fi
candidates+=("/usr/bin/cargo" "/usr/local/bin/cargo")

for candidate in "${candidates[@]}"; do
if [[ -x "$candidate" ]]; then
local resolved_candidate
resolved_candidate="$(readlink -f "$candidate" 2>/dev/null || echo "$candidate")"
if [[ "$resolved_candidate" != "$SCRIPT_PATH" ]]; then
echo "$candidate"
return 0
fi
fi
done
return 1
}

REAL_CARGO="$(find_real_cargo)" || {
echo "cargo wrapper: unable to locate a real cargo binary (searched ~/.cargo/bin, /usr/bin, /usr/local/bin)" >&2
exit 1
}

subcommand="${1:-}"

if [[ "$subcommand" != "metadata" ]]; then
exec "$REAL_CARGO" "$@"
fi

tmpfile="$(mktemp)"
cleanup() {
rm -f "$tmpfile"
}
trap cleanup EXIT

if ! "$REAL_CARGO" "$@" >"$tmpfile"; then
status=$?
cat "$tmpfile"
exit $status
fi

manifest_path=""
argv=("$@")
for ((i = 0; i < ${#argv[@]}; i++)); do
if [[ "${argv[$i]}" == "--manifest-path" && $((i + 1)) -lt ${#argv[@]} ]]; then
manifest_path="${argv[$((i + 1))]}"
break
fi
done

if [[ -n "$manifest_path" ]]; then
workspace_root="$(python - <<'PY' "$manifest_path"
import os, sys
print(os.path.dirname(os.path.abspath(sys.argv[1])))
PY
)"
else
workspace_root="$(pwd)"
fi

target_dir="${workspace_root}/target"

python - <<'PY' "$tmpfile" "$workspace_root" "$target_dir"
import json
import sys
path, workspace, target = sys.argv[1:4]
with open(path, 'r', encoding='utf-8') as handle:
data = json.load(handle)

if 'target_directory' not in data:
data['target_directory'] = target
if 'workspace_root' not in data:
data['workspace_root'] = workspace
if 'metadata' not in data:
data['metadata'] = {}

json.dump(data, sys.stdout)
PY
17 changes: 17 additions & 0 deletions scripts/run-tauri.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node
const { spawn } = require('node:child_process');
const path = require('node:path');

const scriptsDir = path.resolve(__dirname);
const env = { ...process.env };
env.PATH = `${scriptsDir}${path.delimiter}${env.PATH || ''}`;

const child = spawn('tauri', ['dev'], {
stdio: 'inherit',
env,
shell: false,
});

child.on('exit', (code) => {
process.exit(code ?? 1);
});
12 changes: 12 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ io = "0.0.2"
half = { version = "2.7.1", features = ["bytemuck"] }
exr = "1.73.0"
glam = "0.30.9"
lru = "0.12"

[build-dependencies]
tauri-build = { version = "2.4", features = [] }
Expand Down
Loading
Loading