From 8cc4654a7fd62fab5b52216893a81607a4904aca Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Fri, 31 Oct 2025 19:22:00 +0900 Subject: [PATCH] naming: add hako/hakorune wrappers; hako-check prefers alias via HAKO_BIN or tools/bin/hako; docs updated --- tools/bin/hako | 13 +++++++++++++ tools/bin/hakorune | 6 ++++++ tools/hako-check/README.md | 7 +++++-- tools/hako-check/hako-check.sh | 13 +++++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 tools/bin/hako create mode 100644 tools/bin/hakorune diff --git a/tools/bin/hako b/tools/bin/hako new file mode 100644 index 00000000..92260c9c --- /dev/null +++ b/tools/bin/hako @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)" +BIN="$ROOT_DIR/target/release/nyash" + +if [[ ! -x "$BIN" ]]; then + echo "[info] building (release) ..." >&2 + cargo build --release -q +fi + +exec "$BIN" "$@" + diff --git a/tools/bin/hakorune b/tools/bin/hakorune new file mode 100644 index 00000000..dbdc1e68 --- /dev/null +++ b/tools/bin/hakorune @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)" +"$ROOT_DIR/tools/bin/hako" "$@" + diff --git a/tools/hako-check/README.md b/tools/hako-check/README.md index c3459a03..60c7fcbd 100644 --- a/tools/hako-check/README.md +++ b/tools/hako-check/README.md @@ -5,10 +5,11 @@ Purpose - Useful while Python/llvmlite migration is in-flight to keep scripts healthy. Usage -- Build nyash: +- Build once (auto-build if missing): - cargo build --release - Run checker: - tools/hako-check/hako-check.sh path/to/file.hako + - or set alias explicitly: HAKO_BIN=tools/bin/hako tools/hako-check/hako-check.sh file.hako Behavior - Runs: nyash --backend mir --verify @@ -17,6 +18,8 @@ Behavior - 2+: Parse/MIR verify failure (nyash returns non‑zero; checker forwards) Notes +- Binary alias + - Preferred alias: tools/bin/hako (or tools/bin/hakorune) + - Backward‑compat: target/release/nyash も利用可(自動検出) - This MVP only checks a single file and depends on the Rust parser. - Extend with flags (parser selection, JSON emit) as migration progresses. - diff --git a/tools/hako-check/hako-check.sh b/tools/hako-check/hako-check.sh index 9aa38b39..60295d5d 100644 --- a/tools/hako-check/hako-check.sh +++ b/tools/hako-check/hako-check.sh @@ -7,7 +7,17 @@ if [[ $# -lt 1 ]]; then fi ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)" -BIN="$ROOT_DIR/target/release/nyash" +# Allow alias: HAKO_BIN overrides binary path. Otherwise prefer 'hako' alias, then 'nyash'. +BIN="${HAKO_BIN:-}" +if [[ -z "${BIN}" ]]; then + if [[ -x "$ROOT_DIR/tools/bin/hako" ]]; then + BIN="$ROOT_DIR/tools/bin/hako" + elif [[ -x "$ROOT_DIR/tools/bin/hakorune" ]]; then + BIN="$ROOT_DIR/tools/bin/hakorune" + else + BIN="$ROOT_DIR/target/release/nyash" + fi +fi FILE="$1" if [[ ! -x "$BIN" ]]; then @@ -23,4 +33,3 @@ fi # Parse → MIR build → verify (no execute) "$BIN" --backend mir --verify "$FILE" echo "OK: $FILE" -