firmweaver: build/run script

Allow running ./firmweaver directly without a manual build step.

BUG=b:475292981
TEST=go test -v -race ./...

Change-Id: I83d9d0f3fd6673d9d408ebbaef1f81a14a83d05f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/firmweaver/+/8522578
Tested-by: Kshitij Shah <tij@google.com>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Commit-Queue: Kshitij Shah <tij@google.com>
diff --git a/.gitignore b/.gitignore
index 4fdcb51..bd45ab5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
 # Binaries
-firmweaver
+/.bin/
 cov.out
 *.test
 
diff --git a/README.md b/README.md
index 2ee6ac8..5491316 100644
--- a/README.md
+++ b/README.md
@@ -23,12 +23,23 @@
 
 ## Getting Started
 
-### Building Firmweaver
+### Running Firmweaver
 
-Build the `firmweaver` binary from the repository root:
+Run `./firmweaver` from this directory. On first use (and after source
+changes) it builds the tool for your machine into `.bin/`. Requires Go on
+your `PATH`.
 
 ```bash
-go build -o firmweaver .
+./firmweaver --help
+```
+
+### Building for Development
+
+To build without running, write the binary to `.bin/` (where `./firmweaver`
+looks for it). Don't use `-o firmweaver`; that overwrites the wrapper script.
+
+```bash
+go build -o .bin/firmweaver .
 ```
 
 ### Authentication
diff --git a/firmweaver b/firmweaver
new file mode 100755
index 0000000..93c6b4b
--- /dev/null
+++ b/firmweaver
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Copyright 2026 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Builds firmweaver for this machine when the sources change, then runs it.
+
+set -e
+
+dir="$(dirname "$(readlink -f "$0")")"
+bin="${dir}/.bin/firmweaver"
+
+if [[ ! -x "${bin}" || -n "$(find "${dir}" \( -name '*.go' -o -name 'go.*' -o -name '*.json' \) -newer "${bin}")" ]]; then
+  echo "Building firmweaver (only needed on first run or after source changes)..." >&2
+  mkdir -p "$(dirname "${bin}")"
+  (cd "${dir}" && go build -o "${bin}" .) >&2
+fi
+
+exec "${bin}" "$@"
diff --git a/zephyr_dtsi/README.md b/zephyr_dtsi/README.md
index 0dd96e5..20b87ce 100644
--- a/zephyr_dtsi/README.md
+++ b/zephyr_dtsi/README.md
@@ -83,15 +83,7 @@
                --output=/path/to/platform/ec/zephyr/program/fatcat/generated_ite.dtsi
 ```
 
-### 3. Building and Running Binary
-Build the standalone `zephyr_dtsi` binary from the repository root:
-
-```bash
-go build -o firmweaver .
-./firmweaver dtsi --chip=it82202ax --csv=/path/to/hylia.csv --output=generated.dtsi
-```
-
-### 4. Adding Custom Chip Pin Maps
+### 3. Adding Custom Chip Pin Maps
 To register custom EC chip models at runtime without modifying code:
 1. Create a JSON file (e.g. `custom_chip.json`):
    ```json
@@ -109,7 +101,7 @@
    ./firmweaver dtsi --chip-data-dir=/path/to/custom_chips --chip=custom_chip --csv=board.csv
    ```
 
-### 5. Running Tests
+### 4. Running Tests
 Run unit tests across the `zephyr_dtsi` tool:
 
 ```bash