diff --git a/tools/browser_runtime/sgclaw_browser_entry.sh b/tools/browser_runtime/sgclaw_browser_entry.sh new file mode 100755 index 0000000..cf0d585 --- /dev/null +++ b/tools/browser_runtime/sgclaw_browser_entry.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +CRATE_DIR="$(cd -- "${SCRIPT_DIR}/../.." && pwd)" +BIN_PATH="${CRATE_DIR}/target/debug/sgclaw" +MANIFEST_PATH="${CRATE_DIR}/Cargo.toml" + +needs_build=0 +if [[ ! -x "${BIN_PATH}" ]]; then + needs_build=1 +elif [[ "${MANIFEST_PATH}" -nt "${BIN_PATH}" ]]; then + needs_build=1 +elif [[ "${CRATE_DIR}/Cargo.lock" -nt "${BIN_PATH}" ]]; then + needs_build=1 +elif find \ + "${CRATE_DIR}/src" \ + "${CRATE_DIR}/third_party/zeroclaw/src" \ + "${CRATE_DIR}/../skill_lib" \ + -type f -newer "${BIN_PATH}" -print -quit | grep -q .; then + needs_build=1 +fi + +if [[ "${needs_build}" -eq 1 ]]; then + cargo build --manifest-path "${MANIFEST_PATH}" --bin sgclaw +fi + +exec "${BIN_PATH}" "$@"