1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//! Lmcpp Toolchain CLI — manage local builds of **llama.cpp**
//! ==================================================
//!
//! A thin command-line wrapper around the `campion_toolchain` library that
//! **downloads, builds, validates, and removes** cached copies of *llama.cpp*
//! for a chosen compute backend (CPU, CUDA, Metal, …).
//!
//! ---
//! ## Building the binary
//! ```bash
//! cargo build --bin lmcpp-toolchain-cli
//! ```
//!
//! ## Quick start
//! Install the latest CPU-only build into the default cache root:
//! ```bash
//! cargo run --bin lmcpp-toolchain-cli -- install
//! ```
//!
//! ---
//! ## Subcommands
//! | Command | What it does |
//! |-------------------|----------------------------------------------------------------------------------------------|
//! | **install** | Build *or* fetch a pre-built artefact, then cache it. Re-runs only if the spec changed. |
//! | **validate** | Check that a cached build exists **and** matches the requested spec; prints a status report. |
//! | **remove** | Delete the cached files for the requested spec. |
//!
//! (Add `--help` after any subcommand to see all flags.)
//!
//! ---
//! ## Shared *recipe* flags
//! | Flag (*repeatable?*) | Default | Purpose |
//! |-------------------------------------|-------------------------|-------------------------------------------------------------|
//! | `--repo-tag <TAG>` | library default | Git tag or commit to check out. |
//! | `--backend <BACKEND>` | `default` | Target hardware: `cpu`, `cuda`, `cuda-if-available`, … |
//! | `--mode <MODE>` | `build-or-install` | Choose build-from-source, install-only, or auto. |
//! | `--build-arg <FLAG>` *(repeatable)* | _(none)_ | Extra `-D…` CMake flags forwarded verbatim. |
//!
//! ## Global flags
//! | Flag | Default path / value | Purpose |
//! |----------------------|---------------------------|-----------------------------------------------------------|
//! | `--root <PATH>` | platform data directory | Override the cache / build root. |
//! | `--project <NAME>` | `campion_toolchain` | Sub-directory name under the data dir. |
//!
//! ---
//! ## Examples
//! *Build a tagged CUDA build into `/tmp/campion`:*
//! ```bash
//! lmcpp-toolchain-cli install --repo-tag v0.2.1 --backend cuda --root /tmp/campion
//! ```
//!
//! *Validate an existing Metal build:*
//! ```bash
//! lmcpp-toolchain-cli validate --backend metal
//! ```
//!
//! *Nuke the default spec from the cache:*
//! ```bash
//! lmcpp-toolchain-cli remove --backend default
//! ```
//!
//! ---
//! ## Exit codes
//! * `0` — success / up-to-date
//! * `1` — validation or build error
//! * `2` — argument parsing error (from **clap**)
//!
use *;