Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1da1b88201 | ||
|
|
d9dc60918c | ||
|
|
bb31a7befc | ||
|
|
b1b7a3dbc0 | ||
|
|
8275f893dd | ||
|
|
36f12d6d4e | ||
|
|
a4d82bf45b | ||
|
|
d925414bc8 | ||
|
|
9f9fe18926 | ||
|
|
d8d044f439 | ||
|
|
517bee9b9e |
@@ -1,35 +0,0 @@
|
||||
name: public-benchmark-pages
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [build-test-release]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: alkane-toolkit-public-benchmark-pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: alkane-verify
|
||||
container:
|
||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install SSH client
|
||||
run: bash ci/ensure-build-deps.sh ssh
|
||||
- name: Render measured benchmark history
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: python3 ci/bench_history.py render
|
||||
- name: Publish public benchmark page
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
BENCH_PAGES_DEPLOY_KEY: ${{ secrets.BENCH_PAGES_DEPLOY_KEY }}
|
||||
run: python3 ci/publish-bench-pages.py toolkit
|
||||
- name: Clean generated page
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
@@ -0,0 +1,47 @@
|
||||
name: pages
|
||||
|
||||
# The project site, https://blueflare.gitea.bluefla.re/alkane-toolkit/ :
|
||||
# overview, user manual (docs/manual), code-quality dashboard (from the
|
||||
# quality record main CI publishes with the badges) and benchmark history.
|
||||
# Rebuilt after every main build-test-release run and published to this
|
||||
# repository's gh-pages branch.
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [build-test-release]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: alkane-toolkit-pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: alkane-verify
|
||||
container:
|
||||
image: gitea.bluefla.re/blueflare/alkane-ci@sha256:4929b2979851f1f12fb8f92ef74236ae4c2ea735a41ead94a16af416a4f0a1a5
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install page tools
|
||||
run: bash ci/ensure-build-deps.sh pages
|
||||
- name: Render measured benchmark history
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: python3 ci/bench_history.py render
|
||||
- name: Fetch measured quality record
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: python3 ci/fetch-quality.py quality.json
|
||||
- name: Build site
|
||||
run: |
|
||||
python3 ci/build-pages.py --out site --quality quality.json \
|
||||
--bench bench-site/index.html --sha "$GITHUB_SHA"
|
||||
- name: Publish site
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: python3 ci/publish-pages.py site
|
||||
- name: Clean generated site
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
@@ -271,8 +271,10 @@ jobs:
|
||||
set -euo pipefail
|
||||
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
|
||||
[ "$(cargo llvm-cov --version)" = 'cargo-llvm-cov 0.8.7' ]
|
||||
PCT=$(bash ci/coverage.sh --summary-only \
|
||||
| awk '/^TOTAL/{gsub(/%/,"",$10); print $10}')
|
||||
# Keep the whole table: gen-badges turns it into the per-crate and
|
||||
# per-file breakdown on the Pages quality dashboard.
|
||||
bash ci/coverage.sh --summary-only | tee coverage-summary.txt
|
||||
PCT=$(awk '/^TOTAL/{gsub(/%/,"",$10); print $10}' coverage-summary.txt)
|
||||
[ -n "$PCT" ] || { echo "coverage report produced no TOTAL line" >&2; exit 1; }
|
||||
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
||||
echo "line coverage (tests + self-test): ${PCT}%"
|
||||
@@ -300,7 +302,8 @@ jobs:
|
||||
python3 ci/gen-badges.py --tests "$PASS" \
|
||||
--coverage "${{ steps.cov.outputs.pct }}" \
|
||||
--bench-coverage "${{ steps.benchcov.outputs.pct }}" \
|
||||
--bench-delta "$BENCH_DELTA" --clippy clean
|
||||
--bench-delta "$BENCH_DELTA" --clippy clean \
|
||||
--coverage-summary coverage-summary.txt
|
||||
|
||||
- name: Publish measured badges
|
||||
env:
|
||||
|
||||
@@ -2,3 +2,8 @@
|
||||
**/target
|
||||
.claude/
|
||||
__pycache__/
|
||||
# Internal working notes live outside this public repository.
|
||||
/AGENTS.md
|
||||
/HANDOFF.md
|
||||
/CLAUDE.md
|
||||
code-review-report*.md
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Blueflare
|
||||
Copyright (c) 2026 BlueFlare Energy Solutions Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
# Alkane Toolkit
|
||||
|
||||
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/)
|
||||
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/#coverage)
|
||||
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/bench/)
|
||||
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/)
|
||||
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/#coverage)
|
||||
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/)
|
||||
[](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/)
|
||||
[](LICENSE)
|
||||
|
||||
The code quality grade reports GUI Clippy and first-party Rust formatting checks
|
||||
from the last successful main build. Test coverage has a separate badge.
|
||||
The badges link to the [project site](https://blueflare.gitea.bluefla.re/alkane-toolkit/): the [manual](https://blueflare.gitea.bluefla.re/alkane-toolkit/manual/),
|
||||
the [code-quality dashboard](https://blueflare.gitea.bluefla.re/alkane-toolkit/quality/) (how the grade is set, coverage by
|
||||
crate and file) and the [benchmark history](https://blueflare.gitea.bluefla.re/alkane-toolkit/bench/).
|
||||
|
||||
Desktop miner discovery and monitoring. The Rust GUI uses wxWidgets through
|
||||
a patched [wx-rs bridge](thirdparty/wx-rs). In-app image flashing is disabled
|
||||
@@ -31,7 +32,9 @@ uses offline fixtures and does not contact hardware.
|
||||
Windows 10/11 builds are cross-compiled on Linux (`scripts/build-wx-windows.sh`,
|
||||
then `scripts/build-gui-windows.sh`) and attached to every release as a
|
||||
self-contained `alkane-toolkit.exe`; see [docs/windows.md](docs/windows.md).
|
||||
macOS is not built.
|
||||
macOS builds run on a Mac (`scripts/build-wx-macos.sh`, then
|
||||
`scripts/build-gui-macos.sh`) and produce one universal app for Apple Silicon
|
||||
and Intel, macOS 11 or later; see [docs/macos.md](docs/macos.md).
|
||||
|
||||
## Current scope
|
||||
|
||||
@@ -42,8 +45,7 @@ macOS is not built.
|
||||
aftermarket firmware to stock.
|
||||
|
||||
Discovery is read-only. Control and restore actions change miners. Check the
|
||||
selected devices before applying them. See the [implementation plan](docs/IMPLEMENTATION-PLAN.md)
|
||||
and [firmware matrix](docs/aftermarket-parity-roadmap.md) for planned coverage.
|
||||
selected devices before applying them.
|
||||
|
||||
## Development
|
||||
|
||||
@@ -55,8 +57,8 @@ WX_RS_WXCONFIG="$HOME/.cache/wx-3.3.3-linux/bin/wx-config" \
|
||||
|
||||
Keep build output off the source share. `main` runs full CI and publishes
|
||||
qualifying releases; `next` builds `-rc` candidates. Badges measure host
|
||||
code, not installation support. See the public
|
||||
[benchmark history](https://blueflare.gitea.bluefla.re/alkane-benchmarks/toolkit/).
|
||||
code, not installation support. See the
|
||||
[benchmark history](https://blueflare.gitea.bluefla.re/alkane-toolkit/bench/).
|
||||
|
||||
## Firmware safety
|
||||
|
||||
|
||||
Executable
+293
@@ -0,0 +1,293 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Build the Alkane Toolkit Pages site (served from this repo's gh-pages).
|
||||
|
||||
build-pages.py --out site [--manual docs/manual] [--quality quality.json]
|
||||
[--bench bench-site/index.html] [--sha SHA]
|
||||
|
||||
Pages:
|
||||
/ overview and downloads
|
||||
/manual/ the user manual, one page per docs/manual/NN-name.md chapter
|
||||
/quality/ code-quality dashboard from the measured quality.json that main
|
||||
CI publishes next to the badges (ci/gen-badges.py)
|
||||
/bench/ the measured benchmark history (ci/bench_history.py render)
|
||||
|
||||
Every value taken from CI data is HTML-escaped; the manual is Markdown written
|
||||
in this repository.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import markdown
|
||||
|
||||
REPO = "https://gitea.bluefla.re/blueflare/alkane-toolkit"
|
||||
RELEASES = REPO + "/releases"
|
||||
SECTIONS = (("", "Overview"), ("manual/", "Manual"), ("quality/", "Code quality"),
|
||||
("bench/", "Benchmarks"))
|
||||
|
||||
CSS = """
|
||||
:root { --bg:#ffffff; --fg:#1f2328; --muted:#59636e; --line:#d1d9e0; --card:#f6f8fa;
|
||||
--accent:#d9822b; --link:#0969da; --good:#1a7f37; --warn:#9a6700; --bad:#cf222e; }
|
||||
@media (prefers-color-scheme: dark) { :root { --bg:#0d1117; --fg:#e6edf3; --muted:#9198a1;
|
||||
--line:#30363d; --card:#151b23; --link:#4493f8; --good:#3fb950; --warn:#d29922; --bad:#f85149; } }
|
||||
* { box-sizing: border-box; }
|
||||
body { margin:0; background:var(--bg); color:var(--fg);
|
||||
font:16px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,sans-serif; }
|
||||
a { color:var(--link); text-decoration:none; } a:hover { text-decoration:underline; }
|
||||
header { border-bottom:1px solid var(--line); }
|
||||
header .bar, main { max-width:1040px; margin:0 auto; padding:0 16px; }
|
||||
header .bar { display:flex; align-items:center; gap:24px; height:56px; flex-wrap:wrap; }
|
||||
header .brand { font-weight:700; color:var(--fg); display:flex; gap:8px; align-items:center; }
|
||||
header .brand i { width:20px; height:20px; border-radius:5px; background:var(--accent); display:inline-block; }
|
||||
header nav { display:flex; gap:18px; flex-wrap:wrap; }
|
||||
header nav a { color:var(--muted); } header nav a.on { color:var(--fg); font-weight:600; }
|
||||
main { padding:28px 16px 64px; }
|
||||
h1 { font-size:1.9rem; margin:.2em 0 .4em; } h2 { margin-top:1.8em; border-bottom:1px solid var(--line); padding-bottom:.25em; }
|
||||
code { background:var(--card); border:1px solid var(--line); border-radius:5px; padding:.1em .35em; font-size:.92em; }
|
||||
pre { background:var(--card); border:1px solid var(--line); border-radius:8px; padding:12px; overflow:auto; }
|
||||
pre code { border:0; padding:0; }
|
||||
table { border-collapse:collapse; width:100%; margin:1em 0; display:block; overflow-x:auto; }
|
||||
th, td { border:1px solid var(--line); padding:6px 10px; text-align:left; vertical-align:top; }
|
||||
th { background:var(--card); }
|
||||
td.num, th.num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
|
||||
.cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:12px; margin:1.2em 0; }
|
||||
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:14px; }
|
||||
.card b { display:block; font-size:1.6rem; } .card span { color:var(--muted); font-size:.9rem; }
|
||||
.good { color:var(--good); } .warn { color:var(--warn); } .bad { color:var(--bad); }
|
||||
.bar-cell { min-width:120px; } .meter { height:8px; background:var(--line); border-radius:4px; overflow:hidden; }
|
||||
.meter i { display:block; height:100%; }
|
||||
.layout { display:grid; grid-template-columns:220px 1fr; gap:32px; }
|
||||
.layout aside ol { padding-left:1.2em; margin:0; } .layout aside li { margin:.3em 0; }
|
||||
.layout aside a.on { font-weight:600; color:var(--fg); }
|
||||
@media (max-width:760px) { .layout { grid-template-columns:1fr; } }
|
||||
.buttons a { display:inline-block; margin:4px 8px 4px 0; padding:8px 14px; border-radius:8px;
|
||||
border:1px solid var(--line); background:var(--card); color:var(--fg); }
|
||||
.buttons a.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
|
||||
footer { color:var(--muted); font-size:.85rem; margin-top:48px; }
|
||||
"""
|
||||
|
||||
|
||||
def page(title: str, body: str, depth: int, current: str, sha: str) -> str:
|
||||
up = "../" * depth
|
||||
nav = "".join(
|
||||
f'<a href="{up}{path}"{" class=on" if path == current else ""}>{label}</a>'
|
||||
for path, label in SECTIONS)
|
||||
built = f"Built from {html.escape(sha[:10])}. " if sha else ""
|
||||
return f"""<!doctype html>
|
||||
<html lang="en"><head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{html.escape(title)} - Alkane Toolkit</title>
|
||||
<link rel="stylesheet" href="{up}style.css"></head>
|
||||
<body><header><div class="bar"><a class="brand" href="{up}"><i></i>Alkane Toolkit</a>
|
||||
<nav>{nav}<a href="{RELEASES}">Downloads</a><a href="{REPO}">Source</a></nav></div></header>
|
||||
<main>{body}
|
||||
<footer>{built}Alkane Toolkit is MIT licensed.</footer></main></body></html>
|
||||
"""
|
||||
|
||||
|
||||
def write(out: Path, rel: str, text: str) -> None:
|
||||
path = out / rel
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text, encoding="utf-8")
|
||||
|
||||
|
||||
# ---- manual -----------------------------------------------------------------
|
||||
|
||||
def chapters(manual: Path) -> list[tuple[str, str, str]]:
|
||||
"""(slug, title, markdown) for docs/manual/NN-slug.md, in file-name order."""
|
||||
out = []
|
||||
for path in sorted(manual.glob("[0-9][0-9]-*.md")):
|
||||
text = path.read_text(encoding="utf-8")
|
||||
m = re.search(r"^# (.+)$", text, re.M)
|
||||
title = m.group(1).strip() if m else path.stem
|
||||
out.append((path.stem[3:], title, text))
|
||||
return out
|
||||
|
||||
|
||||
def build_manual(out: Path, manual: Path, sha: str) -> None:
|
||||
items = chapters(manual)
|
||||
if not items:
|
||||
raise SystemExit(f"no manual chapters in {manual}")
|
||||
|
||||
def toc(current: str) -> str:
|
||||
links = "".join(
|
||||
f'<li><a href="{slug}.html"{" class=on" if slug == current else ""}>'
|
||||
f"{html.escape(title)}</a></li>" for slug, title, _ in items)
|
||||
return f"<aside><ol>{links}</ol></aside>"
|
||||
|
||||
for slug, title, text in items:
|
||||
# Chapters link to each other as NN-name.md in the repo; on the site
|
||||
# they are name.html.
|
||||
text = re.sub(r"\]\((?:\./)?[0-9][0-9]-([a-z0-9-]+)\.md(#[^)]*)?\)", r"](\1.html\2)", text)
|
||||
body_html = markdown.markdown(text, extensions=["tables", "fenced_code", "toc"])
|
||||
write(out, f"manual/{slug}.html",
|
||||
page(title, f'<div class="layout">{toc(slug)}<article>{body_html}</article></div>',
|
||||
1, "manual/", sha))
|
||||
first = items[0][0]
|
||||
listing = "".join(f'<li><a href="{s}.html">{html.escape(t)}</a></li>' for s, t, _ in items)
|
||||
write(out, "manual/index.html",
|
||||
page("Manual", f"<h1>Manual</h1><p>Start with "
|
||||
f'<a href="{first}.html">{html.escape(items[0][1])}</a>.</p><ol>{listing}</ol>',
|
||||
1, "manual/", sha))
|
||||
|
||||
|
||||
# ---- quality dashboard ---------------------------------------------------------
|
||||
|
||||
def pct_class(pct: float | None) -> str:
|
||||
if pct is None:
|
||||
return ""
|
||||
return "good" if pct >= 80 else "warn" if pct >= 40 else "bad"
|
||||
|
||||
|
||||
def meter(pct: float) -> str:
|
||||
colour = {"good": "var(--good)", "warn": "var(--warn)", "bad": "var(--bad)"}[pct_class(pct)]
|
||||
return f'<div class="meter"><i style="width:{max(0.0, min(pct, 100.0)):.1f}%;background:{colour}"></i></div>'
|
||||
|
||||
|
||||
def build_quality(out: Path, quality: dict | None, sha: str) -> None:
|
||||
e = html.escape
|
||||
if not quality:
|
||||
write(out, "quality/index.html", page(
|
||||
"Code quality", "<h1>Code quality</h1><p>No measurement has been published yet; "
|
||||
"the next main build will fill this page.</p>", 1, "quality/", sha))
|
||||
return
|
||||
grade = str(quality.get("grade", "pending"))
|
||||
cov = quality.get("coverage_pct")
|
||||
bench_cov = quality.get("bench_coverage_pct")
|
||||
delta = quality.get("bench_delta_pct")
|
||||
|
||||
def card(value: str, label: str, cls: str = "") -> str:
|
||||
return f'<div class="card"><b class="{cls}">{value}</b><span>{label}</span></div>'
|
||||
|
||||
cards = "".join([
|
||||
card(e(grade), "Quality grade", {"A": "good", "B": "good", "C": "warn"}.get(grade, "bad")),
|
||||
card(e(str(quality.get("tests_passed", "-"))), "Tests passing", "good"),
|
||||
card(f"{cov:.1f}%" if cov is not None else "-", "Line coverage", pct_class(cov)),
|
||||
card(f"{bench_cov:.1f}%" if bench_cov is not None else "-", "Benchmark coverage", pct_class(bench_cov)),
|
||||
card(e(str(quality.get("clippy") or "-")), "Clippy (warnings are errors)",
|
||||
"good" if quality.get("clippy") == "clean" else "bad"),
|
||||
card(e(str(quality.get("rustfmt") or "-")), "rustfmt", "good" if quality.get("rustfmt") == "clean" else ""),
|
||||
card(f"{quality.get('loc', 0):,}", "Lines of Rust"),
|
||||
card(e(str(quality.get("dependencies", "-"))), "Crates in Cargo.lock"),
|
||||
card((f"{'+' if delta > 0 else ''}{delta:.1f}%" if delta is not None else "-"),
|
||||
"Benchmarks vs previous" + (" (same inputs)" if quality.get("bench_same_inputs") else ""),
|
||||
"" if delta is None else "good" if delta >= 2 else "" if delta > -2 else "warn"),
|
||||
])
|
||||
bands = ", ".join(f"{e(str(letter))} at {floor:.0f}% or more"
|
||||
for floor, letter in quality.get("grade_bands", []))
|
||||
grade_rule = (f"<p>The grade is F if Clippy or rustfmt fails on main. Otherwise it is the "
|
||||
f"line-coverage band: {bands}, and F below that. The coverage badge uses the "
|
||||
f"same bands for its colour, so the two never disagree.</p>")
|
||||
|
||||
crates = quality.get("coverage_by_crate", {})
|
||||
loc = quality.get("loc_by_crate", {})
|
||||
rows = []
|
||||
for name in sorted(set(crates) | set(loc)):
|
||||
c = crates.get(name)
|
||||
if c and c["lines"]:
|
||||
pct = 100.0 * (c["lines"] - c["missed"]) / c["lines"]
|
||||
cov_cells = (f'<td class="num {pct_class(pct)}">{pct:.1f}%</td>'
|
||||
f'<td class="bar-cell">{meter(pct)}</td>'
|
||||
f'<td class="num">{c["lines"] - c["missed"]:,} / {c["lines"]:,}</td>')
|
||||
else:
|
||||
cov_cells = '<td class="num">-</td><td></td><td class="num">-</td>'
|
||||
rows.append(f"<tr><td>{e(name)}</td>{cov_cells}<td class='num'>{loc.get(name, 0):,}</td></tr>")
|
||||
crate_table = ("<table><tr><th>Crate</th><th class=num>Line coverage</th><th></th>"
|
||||
"<th class=num>Covered lines</th><th class=num>Lines of Rust</th></tr>"
|
||||
+ "".join(rows) + "</table>")
|
||||
|
||||
files = sorted(quality.get("coverage_by_file", []),
|
||||
key=lambda r: (r["lines"] - r["missed"]) / r["lines"] if r["lines"] else 1)
|
||||
file_rows = "".join(
|
||||
f"<tr><td><code>{e(r['file'])}</code></td>"
|
||||
f"<td class='num {pct_class(100.0 * (r['lines'] - r['missed']) / r['lines'])}'>"
|
||||
f"{100.0 * (r['lines'] - r['missed']) / r['lines']:.1f}%</td>"
|
||||
f"<td class='num'>{r['missed']:,}</td><td class='num'>{r['lines']:,}</td></tr>"
|
||||
for r in files if r["lines"])
|
||||
file_table = ("<table><tr><th>File (least covered first)</th><th class=num>Coverage</th>"
|
||||
"<th class=num>Uncovered lines</th><th class=num>Lines</th></tr>"
|
||||
+ file_rows + "</table>") if file_rows else ""
|
||||
|
||||
measured = str(quality.get("sha", ""))[:10]
|
||||
of_build = f" (this page: <code>{e(measured)}</code>)" if measured else ""
|
||||
body = f"""<h1>Code quality</h1>
|
||||
<p>Measured by main CI on every build{of_build}:
|
||||
unit tests, line coverage (unit tests plus the headless UI self-test), Clippy with
|
||||
warnings as errors, and rustfmt. Windows builds run the same tests under Wine and
|
||||
on real Windows 11.</p>
|
||||
<div class="cards">{cards}</div>
|
||||
<h2 id="grade">How the grade is set</h2>{grade_rule}
|
||||
<h2 id="coverage">Coverage by crate</h2>{crate_table}
|
||||
<h2 id="files">Coverage by file</h2>{file_table}
|
||||
<p>The dependency count is every package in <code>Cargo.lock</code>, direct and
|
||||
transitive. Lines of Rust count every <code>.rs</code> line under <code>crates/</code>,
|
||||
tests included.</p>"""
|
||||
write(out, "quality/index.html", page("Code quality", body, 1, "quality/", sha))
|
||||
|
||||
|
||||
# ---- benchmarks + overview -------------------------------------------------------
|
||||
|
||||
def build_bench(out: Path, bench: Path | None, sha: str) -> None:
|
||||
if bench is None or not bench.is_file():
|
||||
write(out, "bench/index.html", page(
|
||||
"Benchmarks", "<h1>Benchmarks</h1><p>No benchmark history yet.</p>", 1, "bench/", sha))
|
||||
return
|
||||
rendered = bench.read_text(encoding="utf-8")
|
||||
# The history renderer emits a complete document; keep its body (and its
|
||||
# own styles) under the site's header.
|
||||
styles = "".join(re.findall(r"<style[^>]*>.*?</style>", rendered, re.S | re.I))
|
||||
m = re.search(r"<body[^>]*>(.*)</body>", rendered, re.S | re.I)
|
||||
inner = m.group(1) if m else rendered
|
||||
text = page("Benchmarks", inner, 1, "bench/", sha)
|
||||
write(out, "bench/index.html", text.replace("</head>", styles + "</head>", 1))
|
||||
|
||||
|
||||
def build_index(out: Path, quality: dict | None, sha: str) -> None:
|
||||
grade = html.escape(str((quality or {}).get("grade", "pending")))
|
||||
body = f"""<h1>Alkane Toolkit</h1>
|
||||
<p>Desktop discovery and monitoring for ASIC miners on your network: find every
|
||||
miner in your IP ranges, see hashrate, power, temperatures, fans and hashboard
|
||||
health at a glance, and run the controls each firmware supports.</p>
|
||||
<div class="buttons"><a class="primary" href="{RELEASES}">Download for Windows or Linux</a>
|
||||
<a href="manual/">Read the manual</a><a href="quality/">Code quality: {grade}</a>
|
||||
<a href="bench/">Benchmarks</a></div>
|
||||
<h2>Platforms</h2>
|
||||
<ul><li><b>Windows 10 and 11</b> (x86_64): one signed, self-contained <code>alkane-toolkit.exe</code>.</li>
|
||||
<li><b>Linux</b> (x86_64, GTK 3): one binary.</li></ul>
|
||||
<p>Every release is built, tested and signed by CI from the public source.</p>"""
|
||||
write(out, "index.html", page("Overview", body, 0, "", sha))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
ap = argparse.ArgumentParser(description=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
ap.add_argument("--out", required=True)
|
||||
ap.add_argument("--manual", default="docs/manual")
|
||||
ap.add_argument("--quality", default=None)
|
||||
ap.add_argument("--bench", default=None)
|
||||
ap.add_argument("--sha", default="")
|
||||
args = ap.parse_args()
|
||||
out = Path(args.out)
|
||||
if out.exists():
|
||||
shutil.rmtree(out)
|
||||
out.mkdir(parents=True)
|
||||
quality = None
|
||||
if args.quality and Path(args.quality).is_file():
|
||||
quality = json.loads(Path(args.quality).read_text())
|
||||
if not isinstance(quality, dict) or quality.get("schema") != 1:
|
||||
raise SystemExit("unsupported quality.json")
|
||||
(out / "style.css").write_text(CSS.strip() + "\n", encoding="utf-8")
|
||||
build_index(out, quality, args.sha)
|
||||
build_manual(out, Path(args.manual), args.sha)
|
||||
build_quality(out, quality, args.sha)
|
||||
build_bench(out, Path(args.bench) if args.bench else None, args.sha)
|
||||
print(f"built {sum(1 for _ in out.rglob('*.html'))} pages in {out}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -32,12 +32,12 @@ def main() -> int:
|
||||
print(f"{path.name}: {name} has a different runner image", file=sys.stderr)
|
||||
return 1
|
||||
pages = yaml.load(
|
||||
(ROOT / ".gitea/workflows/bench-pages.yml").read_text(),
|
||||
(ROOT / ".gitea/workflows/pages.yml").read_text(),
|
||||
Loader=yaml.BaseLoader,
|
||||
)
|
||||
if (pages["on"]["workflow_run"]["workflows"] != ["build-test-release"]
|
||||
or pages["jobs"]["publish"].get("runs-on") != "alkane-verify"):
|
||||
print("Benchmark Pages must follow main CI on the trusted verifier", file=sys.stderr)
|
||||
print("Pages must follow main CI on the trusted verifier", file=sys.stderr)
|
||||
return 1
|
||||
release = yaml.load(
|
||||
(ROOT / ".gitea/workflows/release.yml").read_text(),
|
||||
@@ -46,7 +46,7 @@ def main() -> int:
|
||||
if release["jobs"]["release"].get("runs-on") != "alkane-ci":
|
||||
print("Main release must use the dedicated Alkane build pool", file=sys.stderr)
|
||||
return 1
|
||||
if any("ci/publish-bench-pages.py" in step.get("run", "")
|
||||
if any("ci/publish-pages.py" in step.get("run", "")
|
||||
for step in release["jobs"]["release"]["steps"]):
|
||||
print("Main release must not publish Pages from GARM", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
@@ -9,9 +9,9 @@ import sys
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DIRECTORIES = ("target", "dist", "coverage", "bench-site")
|
||||
FILES = ("bench-current.txt",)
|
||||
BADGE_FILES = ("bench-baseline.json", "bench-context.json")
|
||||
DIRECTORIES = ("target", "dist", "coverage", "bench-site", "site")
|
||||
FILES = ("bench-current.txt", "coverage-summary.txt", "quality.json")
|
||||
BADGE_FILES = ("bench-baseline.json", "bench-context.json", "quality.json")
|
||||
|
||||
|
||||
def cleanup() -> None:
|
||||
|
||||
@@ -46,7 +46,7 @@ vendor/*|thirdparty/asic-rs/*)
|
||||
# resources, embedded assets). ui.rs/fixtures.rs/bin
|
||||
# match the UI arm above first, so they still bump Z, not Y.
|
||||
backend=true ;;
|
||||
*) : ;; # docs, HANDOFF, README, thirdparty/wxwidgets tree: no bump
|
||||
*) : ;; # docs, README, thirdparty/wxwidgets tree: no bump
|
||||
esac
|
||||
done <<< "$changed"
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
# Use the preinstalled CI image or install missing packages on older runners.
|
||||
set -euo pipefail
|
||||
|
||||
mode="${1:?usage: ensure-build-deps.sh base|ui|all|ssh|windows}"
|
||||
mode="${1:?usage: ensure-build-deps.sh base|ui|all|ssh|windows|pages}"
|
||||
case "$mode" in
|
||||
base) packages=(libssl-dev pkg-config ca-certificates) ;;
|
||||
ui) packages=(xvfb xauth dbus-x11 fonts-dejavu-core) ;;
|
||||
ssh) packages=(openssh-client) ;;
|
||||
pages) packages=(python3-markdown) ;;
|
||||
all) packages=(libssl-dev pkg-config ca-certificates openssh-client
|
||||
xvfb xauth dbus-x11 fonts-dejavu-core) ;;
|
||||
# Windows cross build (mingw-w64, posix threads) + Wine for its tests.
|
||||
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Download the measured quality record (badges/quality.json on ci-badges).
|
||||
|
||||
fetch-quality.py OUT.json
|
||||
|
||||
Writes nothing (and exits 0) when main CI has not published one yet, so the
|
||||
Pages build shows a "not measured yet" dashboard instead of failing.
|
||||
"""
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
|
||||
def main() -> None:
|
||||
out = Path(sys.argv[1])
|
||||
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
url = f"{api}/repos/{repo}/contents/badges/quality.json?ref=ci-badges"
|
||||
request = Request(url, headers={"Authorization": f"token {os.environ['GITEA_TOKEN']}"})
|
||||
try:
|
||||
with urlopen(request, timeout=20) as response:
|
||||
content = base64.b64decode(json.load(response)["content"])
|
||||
except HTTPError as error:
|
||||
if error.code == 404:
|
||||
print("No quality record published yet")
|
||||
return
|
||||
raise
|
||||
if not isinstance(json.loads(content), dict):
|
||||
sys.exit("invalid quality record")
|
||||
out.write_bytes(content)
|
||||
print(f"Fetched quality record ({len(content)} bytes)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+103
-8
@@ -135,10 +135,72 @@ def cov_color(pct: float) -> str:
|
||||
return "red"
|
||||
|
||||
|
||||
def quality_grade(clippy: str | None) -> str:
|
||||
if clippy is None:
|
||||
# Code-quality grade (shown on the badge and explained on the Pages quality
|
||||
# dashboard). Lint failures fail the grade outright; otherwise the grade is the
|
||||
# measured line-coverage band, using the same bands as the coverage badge
|
||||
# colour, so the two badges can never disagree.
|
||||
GRADE_BANDS = ((80.0, "A"), (60.0, "B"), (40.0, "C"), (20.0, "D"))
|
||||
GRADE_COLORS = {"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
|
||||
"D": "orange", "F": "red", "pending": "lightgrey"}
|
||||
|
||||
|
||||
def quality_grade(clippy: str | None, coverage: float | None = None) -> str:
|
||||
if clippy is None or (clippy == "clean" and coverage is None):
|
||||
return "pending"
|
||||
return "A" if clippy == "clean" else "F"
|
||||
if clippy != "clean":
|
||||
return "F"
|
||||
for floor, grade in GRADE_BANDS:
|
||||
if coverage >= floor:
|
||||
return grade
|
||||
return "F"
|
||||
|
||||
|
||||
def coverage_by_file(summary_path: str | None, root: str) -> list[dict]:
|
||||
"""Per-file line coverage from a `cargo llvm-cov --summary-only` table.
|
||||
|
||||
Columns: Filename, Regions, Missed Regions, Cover, Functions, Missed
|
||||
Functions, Executed, Lines, Missed Lines, Cover, ...
|
||||
"""
|
||||
if not summary_path:
|
||||
return []
|
||||
rows = []
|
||||
root_abs = os.path.abspath(root).rstrip("/") + "/"
|
||||
for line in Path(summary_path).read_text(errors="replace").splitlines():
|
||||
cols = line.split()
|
||||
if len(cols) < 10 or cols[0] in ("Filename", "TOTAL") or not cols[0].endswith(".rs"):
|
||||
continue
|
||||
try:
|
||||
lines, missed = int(cols[7]), int(cols[8])
|
||||
except ValueError:
|
||||
continue
|
||||
name = cols[0][len(root_abs):] if cols[0].startswith(root_abs) else cols[0]
|
||||
# llvm-cov drops the prefix every file shares, so when only workspace
|
||||
# crates are measured "crates/alkane-gui/src/x.rs" is printed as
|
||||
# "alkane-gui/src/x.rs". Put the prefix back.
|
||||
first = Path(name).parts[0] if Path(name).parts else ""
|
||||
if not name.startswith("crates/") and (Path(root) / "crates" / first).is_dir():
|
||||
name = f"crates/{name}"
|
||||
rows.append({"file": name, "lines": lines, "missed": missed})
|
||||
return rows
|
||||
|
||||
|
||||
def crate_of(path: str) -> str:
|
||||
parts = Path(path).parts
|
||||
if "crates" in parts and parts.index("crates") + 1 < len(parts):
|
||||
return parts[parts.index("crates") + 1]
|
||||
if "wx-rs-0.2.0-patched" in parts:
|
||||
return "wx-rs (bridge)"
|
||||
return "other"
|
||||
|
||||
|
||||
def loc_by_crate(root: str) -> dict[str, int]:
|
||||
out: dict[str, int] = {}
|
||||
crates = Path(root) / "crates"
|
||||
for path in sorted(crates.glob("*/**/*.rs")):
|
||||
crate = path.relative_to(crates).parts[0]
|
||||
with open(path, encoding="utf-8", errors="ignore") as fh:
|
||||
out[crate] = out.get(crate, 0) + sum(1 for _ in fh)
|
||||
return out
|
||||
|
||||
|
||||
def human(n: int) -> str:
|
||||
@@ -169,6 +231,9 @@ def main() -> int:
|
||||
# percentage string, or "NEW" when there is no baseline.
|
||||
ap.add_argument("--bench-delta", default=None)
|
||||
ap.add_argument("--clippy", choices=("clean", "failed"))
|
||||
# The full `cargo llvm-cov --summary-only` table, for the per-crate and
|
||||
# per-file breakdown in quality.json (the Pages quality dashboard).
|
||||
ap.add_argument("--coverage-summary", default=None)
|
||||
args = ap.parse_args()
|
||||
for value in (args.coverage, args.bench_coverage):
|
||||
if value is not None and (not math.isfinite(value) or not 0 <= value <= 100):
|
||||
@@ -189,11 +254,9 @@ def main() -> int:
|
||||
write("loc", "lines of code", human(loc), loc_color(loc))
|
||||
write("license", "license", lic, "blue")
|
||||
write("dependencies", "dependencies", str(deps), "blue")
|
||||
grade = quality_grade(args.clippy)
|
||||
write("quality", "code quality", grade,
|
||||
{"A": "brightgreen", "B": "yellowgreen", "C": "yellow",
|
||||
"D": "orange", "F": "red", "pending": "lightgrey"}[grade],
|
||||
f"code quality: {grade} (GUI Clippy and first-party rustfmt)")
|
||||
grade = quality_grade(args.clippy, args.coverage)
|
||||
write("quality", "code quality", grade, GRADE_COLORS[grade],
|
||||
f"code quality: {grade} (Clippy, rustfmt and line coverage)")
|
||||
if args.tests is not None:
|
||||
write("tests", "tests", f"{args.tests} passing", "brightgreen")
|
||||
if args.coverage is not None:
|
||||
@@ -228,6 +291,38 @@ def main() -> int:
|
||||
write("bench", "bench", "baseline set", "blue")
|
||||
elif args.bench is not None:
|
||||
write("bench", "bench", args.bench, "blue")
|
||||
|
||||
# Everything above, plus the per-crate breakdowns, for the Pages quality
|
||||
# dashboard (ci/build-pages.py).
|
||||
files = coverage_by_file(args.coverage_summary, args.root)
|
||||
crates: dict[str, dict] = {}
|
||||
for row in files:
|
||||
c = crates.setdefault(crate_of(row["file"]), {"lines": 0, "missed": 0})
|
||||
c["lines"] += row["lines"]
|
||||
c["missed"] += row["missed"]
|
||||
quality = {
|
||||
"schema": 1,
|
||||
"sha": os.environ.get("GITHUB_SHA", ""),
|
||||
"grade": grade,
|
||||
"grade_bands": [[floor, letter] for floor, letter in GRADE_BANDS],
|
||||
"clippy": args.clippy,
|
||||
"rustfmt": "clean" if args.clippy is not None else None,
|
||||
"tests_passed": args.tests,
|
||||
"coverage_pct": args.coverage,
|
||||
"bench_coverage_pct": args.bench_coverage,
|
||||
"bench_delta_pct": delta,
|
||||
"bench_same_inputs": same_inputs,
|
||||
"loc": loc,
|
||||
"loc_by_crate": loc_by_crate(args.root),
|
||||
"dependencies": deps,
|
||||
"license": lic,
|
||||
"coverage_by_crate": crates,
|
||||
"coverage_by_file": files,
|
||||
}
|
||||
path = os.path.join(args.root, args.out, "quality.json")
|
||||
with open(path, "w", encoding="utf-8") as fh:
|
||||
json.dump(quality, fh, indent=1, sort_keys=True)
|
||||
print(f"wrote {path}")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Executable
+109
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Package the universal macOS build as an app bundle, for release.
|
||||
|
||||
package-macos.py VERSION BINARY OUT_DIR
|
||||
|
||||
BINARY is the universal (arm64 + x86_64) alkane-toolkit executable made by
|
||||
scripts/build-gui-macos.sh. Writes
|
||||
dist/alkane-toolkit-vVERSION-macos-universal.zip holding "Alkane Toolkit.app",
|
||||
LICENSE and README.txt, and prints its path. Runs on macOS (lipo, codesign,
|
||||
ditto).
|
||||
|
||||
The bundle is ad-hoc signed only (Apple Silicon refuses to run unsigned
|
||||
code); it is not signed with a Developer ID or notarized, so Gatekeeper asks
|
||||
the user to confirm the first launch. README.txt says how.
|
||||
"""
|
||||
|
||||
import pathlib
|
||||
import plistlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
APP = "Alkane Toolkit.app"
|
||||
BUNDLE_ID = "re.bluefla.alkane-toolkit"
|
||||
MIN_MACOS = "11.0"
|
||||
|
||||
|
||||
def run(*args: str) -> str:
|
||||
return subprocess.run(args, check=True, capture_output=True, text=True).stdout
|
||||
|
||||
|
||||
def build_app(version: str, binary: pathlib.Path, dest: pathlib.Path) -> pathlib.Path:
|
||||
archs = run("lipo", "-archs", str(binary)).split()
|
||||
if sorted(archs) != ["arm64", "x86_64"]:
|
||||
sys.exit(f"{binary} is not a universal arm64 + x86_64 binary: {archs}")
|
||||
app = dest / APP
|
||||
macos = app / "Contents" / "MacOS"
|
||||
resources = app / "Contents" / "Resources"
|
||||
macos.mkdir(parents=True)
|
||||
resources.mkdir()
|
||||
shutil.copy2(binary, macos / "alkane-toolkit")
|
||||
shutil.copy2(ROOT / "crates/alkane-gui/macos/alkane-toolkit.icns", resources)
|
||||
info = {
|
||||
"CFBundleName": "Alkane Toolkit",
|
||||
"CFBundleDisplayName": "Alkane Toolkit",
|
||||
"CFBundleIdentifier": BUNDLE_ID,
|
||||
"CFBundleExecutable": "alkane-toolkit",
|
||||
"CFBundleIconFile": "alkane-toolkit",
|
||||
"CFBundlePackageType": "APPL",
|
||||
"CFBundleShortVersionString": version,
|
||||
"CFBundleVersion": version,
|
||||
"CFBundleInfoDictionaryVersion": "6.0",
|
||||
"LSMinimumSystemVersion": MIN_MACOS,
|
||||
"NSHighResolutionCapable": True,
|
||||
"NSPrincipalClass": "NSApplication",
|
||||
# The scanner talks to miners on the local network.
|
||||
"NSLocalNetworkUsageDescription":
|
||||
"Alkane Toolkit scans your local network to find and manage miners.",
|
||||
"NSHumanReadableCopyright":
|
||||
"Copyright (c) 2026 BlueFlare Energy Solutions Inc. (MIT License)",
|
||||
}
|
||||
with open(app / "Contents" / "Info.plist", "wb") as fh:
|
||||
plistlib.dump(info, fh)
|
||||
(app / "Contents" / "PkgInfo").write_text("APPL????")
|
||||
# Ad-hoc signature over the whole bundle (the linker's per-slice
|
||||
# signatures do not cover Info.plist or the resources).
|
||||
run("codesign", "--force", "--sign", "-", "--timestamp=none", str(app))
|
||||
run("codesign", "--verify", "--strict", str(app))
|
||||
return app
|
||||
|
||||
|
||||
def release(version: str, binary: str, out_dir: str) -> None:
|
||||
name = f"alkane-toolkit-v{version}-macos-universal"
|
||||
out = pathlib.Path(out_dir).resolve() / f"{name}.zip"
|
||||
out.parent.mkdir(parents=True, exist_ok=True)
|
||||
readme = (
|
||||
f"alkane-toolkit v{version} (macOS, Apple Silicon and Intel)\n"
|
||||
"\n"
|
||||
f"Runs on macOS {MIN_MACOS} (Big Sur) or later. Drag \"Alkane Toolkit\"\n"
|
||||
"to Applications, then open it.\n"
|
||||
"\n"
|
||||
"The app is not notarized by Apple, so the first launch is blocked\n"
|
||||
"with a warning. To allow it once:\n"
|
||||
" - macOS 15 or later: try to open it, then System Settings >\n"
|
||||
" Privacy & Security > \"Open Anyway\" for Alkane Toolkit.\n"
|
||||
" - macOS 11 to 14: Control-click the app, choose Open, then Open.\n"
|
||||
"Or, in Terminal: xattr -dr com.apple.quarantine \"/Applications/Alkane Toolkit.app\"\n"
|
||||
"\n"
|
||||
"Settings are stored in ~/.config/alkane-toolkit/.\n"
|
||||
"Manual: https://blueflare.gitea.bluefla.re/alkane-toolkit/manual/\n"
|
||||
)
|
||||
with tempfile.TemporaryDirectory(prefix="alkane-macos-") as tmp:
|
||||
folder = pathlib.Path(tmp) / name
|
||||
folder.mkdir()
|
||||
build_app(version, pathlib.Path(binary), folder)
|
||||
shutil.copy2(ROOT / "LICENSE", folder / "LICENSE")
|
||||
(folder / "README.txt").write_text(readme)
|
||||
out.unlink(missing_ok=True)
|
||||
run("ditto", "-c", "-k", "--keepParent", str(folder), str(out))
|
||||
print(out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 4:
|
||||
sys.exit(__doc__)
|
||||
release(*sys.argv[1:])
|
||||
@@ -38,7 +38,7 @@ def release(version: str, exe: str, out_dir: str) -> None:
|
||||
"the executable is self-contained and runs on Windows 10 and 11.\r\n"
|
||||
"\r\n"
|
||||
+ (
|
||||
"The executable is signed by Blueflare (Azure Artifact Signing). To check:\r\n"
|
||||
"The executable is signed by BlueFlare Energy Solutions Inc. (Azure Artifact Signing). To check:\r\n"
|
||||
"right-click alkane-toolkit.exe > Properties > Digital Signatures.\r\n"
|
||||
if signed else
|
||||
"This build is not code-signed, so Windows SmartScreen may warn on first\r\n"
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Publish a measured benchmark page to the public, data-only Pages repo."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import tempfile
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
PAGES_REPO = "ssh://git@gitea.bluefla.re:2222/blueflare/alkane-benchmarks.git"
|
||||
GUARD_REPO = "https://gitea.bluefla.re/blueflare/alkane-benchmarks.git"
|
||||
GUARD_COMMIT = "ea160545c49bc419a245692deda8dd7db7a611eb"
|
||||
PAGES_HOST = "gitea.bluefla.re"
|
||||
PAGES_HOST_FINGERPRINT = "SHA256:lqB5cmC9E5HNeg/lkzdOwQ++I8A70Wx7lnNs6liN24g"
|
||||
PAGES_HOST_KEY = "[gitea.bluefla.re]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO1II6NkmRW+QAd+Wj+7qbNrA8Oo+/N/WRog4hELskn/"
|
||||
|
||||
|
||||
def run(*args: str, env: dict[str, str] | None = None,
|
||||
cwd: Path | None = None) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.run(args, env=env, cwd=cwd, text=True,
|
||||
capture_output=True, check=True)
|
||||
|
||||
|
||||
def current_main_sha() -> str:
|
||||
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
token = os.environ["GITEA_TOKEN"]
|
||||
request = Request(f"{api}/repos/{repo}/branches/main",
|
||||
headers={"Authorization": f"token {token}"})
|
||||
with urlopen(request, timeout=20) as response:
|
||||
branch = json.load(response)
|
||||
return branch["commit"]["id"]
|
||||
|
||||
|
||||
def publish(site: str) -> None:
|
||||
if os.environ.get("GITHUB_REF") != "refs/heads/main":
|
||||
raise ValueError("benchmark Pages publication requires main")
|
||||
sha = os.environ["GITHUB_SHA"]
|
||||
if current_main_sha() != sha:
|
||||
print("Skipping benchmark page from a superseded main commit")
|
||||
return
|
||||
page = Path("bench-site/index.html").read_bytes()
|
||||
if not page.startswith(b"<!doctype html>") or len(page) > 1_048_576:
|
||||
raise ValueError("invalid benchmark page")
|
||||
with tempfile.TemporaryDirectory(prefix="alkane-pages-") as directory:
|
||||
temporary = Path(directory)
|
||||
guard_checkout = temporary / "guard"
|
||||
run("git", "clone", "--quiet", "--single-branch", "--branch", "next",
|
||||
GUARD_REPO, str(guard_checkout))
|
||||
guard_source = run("git", "show", f"{GUARD_COMMIT}:ci/validate_site.py",
|
||||
cwd=guard_checkout).stdout
|
||||
guard_script = temporary / "validate_site.py"
|
||||
guard_script.write_text(guard_source)
|
||||
run("python3", str(guard_script), "--page", site,
|
||||
str(Path("bench-site/index.html").resolve()))
|
||||
key = os.environ["BENCH_PAGES_DEPLOY_KEY"]
|
||||
if not key.startswith("-----BEGIN OPENSSH PRIVATE KEY-----"):
|
||||
raise ValueError("missing benchmark Pages deploy key")
|
||||
key_path = temporary / "deploy_key"
|
||||
key_path.write_text(key.rstrip("\n") + "\n")
|
||||
key_path.chmod(0o600)
|
||||
known_hosts = temporary / "known_hosts"
|
||||
known_hosts.write_text(PAGES_HOST_KEY + "\n")
|
||||
fingerprint = run("ssh-keygen", "-lf", str(known_hosts)).stdout.split()[1]
|
||||
if fingerprint != PAGES_HOST_FINGERPRINT:
|
||||
raise ValueError("benchmark Pages SSH host key changed")
|
||||
git_env = os.environ.copy()
|
||||
ssh_command = (f"ssh -i {shlex.quote(str(key_path))} -o IdentitiesOnly=yes "
|
||||
f"-o UserKnownHostsFile={shlex.quote(str(known_hosts))} "
|
||||
"-o StrictHostKeyChecking=yes -o ConnectTimeout=10")
|
||||
git_env["GIT_SSH_COMMAND"] = ssh_command
|
||||
git_env["GIT_TERMINAL_PROMPT"] = "0"
|
||||
checkout = temporary / "site"
|
||||
run("git", "clone", "--quiet", "--single-branch", "--branch", "gh-pages",
|
||||
PAGES_REPO, str(checkout), env=git_env)
|
||||
run("git", "config", "user.name", "Alkane CI", cwd=checkout)
|
||||
run("git", "config", "user.email", "ci@bluefla.re", cwd=checkout)
|
||||
for attempt in range(3):
|
||||
if current_main_sha() != sha:
|
||||
print("Skipping benchmark page from a superseded main commit")
|
||||
return
|
||||
run("git", "fetch", "--quiet", "origin", "gh-pages", env=git_env,
|
||||
cwd=checkout)
|
||||
run("git", "checkout", "-q", "-B", "bench-publish", "origin/gh-pages",
|
||||
cwd=checkout)
|
||||
destination = checkout / site / "index.html"
|
||||
destination.parent.mkdir(exist_ok=True)
|
||||
destination.write_bytes(page)
|
||||
run("git", "add", f"{site}/index.html", cwd=checkout)
|
||||
changed = subprocess.run(("git", "diff", "--cached", "--quiet"),
|
||||
cwd=checkout, check=False)
|
||||
if changed.returncode == 0:
|
||||
print(f"{site} benchmark page is already current")
|
||||
return
|
||||
if changed.returncode != 1:
|
||||
raise RuntimeError("cannot compare benchmark page")
|
||||
run("git", "commit", "-q", "-m",
|
||||
f"Update {site} benchmarks for {sha[:10]} [skip ci]", cwd=checkout)
|
||||
pushed = subprocess.run(("git", "push", "--quiet", "origin",
|
||||
"HEAD:gh-pages"), env=git_env, cwd=checkout,
|
||||
text=True, capture_output=True, check=False)
|
||||
if pushed.returncode == 0:
|
||||
print(f"Published {site} benchmark page for {sha[:10]}")
|
||||
return
|
||||
if attempt == 2:
|
||||
raise RuntimeError(f"benchmark Pages push failed: {pushed.stderr.strip()}")
|
||||
raise RuntimeError("benchmark Pages publication did not complete")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("site", choices=("sdk", "os", "toolkit"))
|
||||
publish(parser.parse_args().site)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Publish measured toolkit badges to the private Gitea badge branch."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
@@ -22,7 +23,14 @@ def main() -> None:
|
||||
raise ValueError(f"invalid {name} SVG")
|
||||
publish_file(api, repo, f"badges/{name}.svg", data, token,
|
||||
f"Update measured {name} badge")
|
||||
print(f"Published {len(NAMES)} measured badge SVGs")
|
||||
# The full measurement record behind the badges, read by the Pages
|
||||
# quality dashboard (ci/build-pages.py).
|
||||
data = (ROOT / "badges" / "quality.json").read_bytes()
|
||||
if not isinstance(json.loads(data), dict):
|
||||
raise ValueError("invalid quality.json")
|
||||
publish_file(api, repo, "badges/quality.json", data, token,
|
||||
"Update measured quality record", max_bytes=262_144)
|
||||
print(f"Published {len(NAMES)} measured badge SVGs and quality.json")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Publish the built Pages site to this repository's gh-pages branch.
|
||||
|
||||
publish-pages.py SITE_DIR
|
||||
|
||||
Served at https://blueflare.gitea.bluefla.re/alkane-toolkit/ by the Pages
|
||||
server, which serves the gh-pages branch of public repositories. Each publish
|
||||
is one orphan commit (force-pushed), so the branch never accumulates history.
|
||||
Only main may publish, and a run for a superseded main commit skips.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
BRANCH = "gh-pages"
|
||||
MAX_BYTES = 20 * 1024 * 1024
|
||||
|
||||
|
||||
def current_main_sha(api: str, repo: str, token: str) -> str:
|
||||
request = Request(f"{api}/repos/{repo}/branches/main",
|
||||
headers={"Authorization": f"token {token}"})
|
||||
with urlopen(request, timeout=20) as response:
|
||||
return json.load(response)["commit"]["id"]
|
||||
|
||||
|
||||
def git(*args: str, cwd: Path, env: dict | None = None) -> None:
|
||||
subprocess.run(("git", *args), cwd=cwd, env=env, check=True)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit(__doc__)
|
||||
site = Path(sys.argv[1])
|
||||
if not (site / "index.html").is_file():
|
||||
sys.exit(f"{site} has no index.html")
|
||||
size = sum(p.stat().st_size for p in site.rglob("*") if p.is_file())
|
||||
if size > MAX_BYTES:
|
||||
sys.exit(f"site is {size} bytes, over the {MAX_BYTES} byte limit")
|
||||
for path in site.rglob("*"):
|
||||
if path.is_file() and path.suffix not in {".html", ".css", ".svg", ".png", ".json"}:
|
||||
sys.exit(f"unexpected file type on the site: {path}")
|
||||
|
||||
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
sha = os.environ["GITHUB_SHA"]
|
||||
token = os.environ["GITEA_TOKEN"]
|
||||
if os.environ.get("GITHUB_REF") != "refs/heads/main":
|
||||
sys.exit("Pages publication requires main")
|
||||
if current_main_sha(api, repo, token) != sha:
|
||||
print("Skipping Pages for a superseded main commit")
|
||||
return
|
||||
|
||||
server = api.removesuffix("/api/v1")
|
||||
with tempfile.TemporaryDirectory(prefix="alkane-pages-") as directory:
|
||||
work = Path(directory)
|
||||
shutil.copytree(site, work, dirs_exist_ok=True)
|
||||
env = dict(os.environ, GIT_TERMINAL_PROMPT="0")
|
||||
git("init", "-q", "-b", BRANCH, cwd=work)
|
||||
git("-c", "user.name=Alkane CI", "-c", "user.email=ci@noreply.gitea.bluefla.re",
|
||||
"add", "-A", cwd=work)
|
||||
git("-c", "user.name=Alkane CI", "-c", "user.email=ci@noreply.gitea.bluefla.re",
|
||||
"commit", "-q", "-m", f"Publish site for {sha[:10]} [skip ci]", cwd=work)
|
||||
# The token is read from the environment by the credential helper at
|
||||
# push time; it never appears on a command line or in the remote URL.
|
||||
helper = '!f() { echo username=alkane-ci; echo "password=$GITEA_TOKEN"; }; f'
|
||||
git("-c", f"credential.helper={helper}", "push", "-q", "--force",
|
||||
f"{server}/{repo}.git", f"HEAD:refs/heads/{BRANCH}", cwd=work, env=env)
|
||||
print(f"Published Pages for {sha[:10]} to {BRANCH}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+41
-10
@@ -5,6 +5,7 @@
|
||||
import importlib.util
|
||||
import re
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
@@ -50,16 +51,46 @@ class BenchBadgeTests(unittest.TestCase):
|
||||
self.assertEqual(gen_badges.bench_color(30.0), "brightgreen")
|
||||
self.assertEqual(gen_badges.bench_color(-55.5555556), "orange")
|
||||
|
||||
def test_quality_grade_is_only_the_clippy_result(self):
|
||||
self.assertEqual(gen_badges.quality_grade("clean"), "A")
|
||||
self.assertEqual(gen_badges.quality_grade("failed"), "F")
|
||||
self.assertEqual(gen_badges.quality_grade(None), "pending")
|
||||
svg = gen_badges.badge_svg(
|
||||
"code quality", "A", "brightgreen",
|
||||
"code quality: A (GUI Clippy and first-party rustfmt)",
|
||||
)
|
||||
self.assertIn('aria-label="code quality: A (GUI Clippy and first-party rustfmt)"', svg)
|
||||
self.assertIn('>A</text>', svg)
|
||||
def test_quality_grade_follows_lint_and_coverage(self):
|
||||
# A lint failure fails the grade; otherwise it is the coverage band,
|
||||
# with the same floors as the coverage badge colour.
|
||||
self.assertEqual(gen_badges.quality_grade("failed", 95.0), "F")
|
||||
self.assertEqual(gen_badges.quality_grade("clean", 85.0), "A")
|
||||
self.assertEqual(gen_badges.quality_grade("clean", 65.6), "B")
|
||||
self.assertEqual(gen_badges.quality_grade("clean", 48.0), "C")
|
||||
self.assertEqual(gen_badges.quality_grade("clean", 25.0), "D")
|
||||
self.assertEqual(gen_badges.quality_grade("clean", 5.0), "F")
|
||||
self.assertEqual(gen_badges.quality_grade("clean"), "pending")
|
||||
self.assertEqual(gen_badges.quality_grade(None, 90.0), "pending")
|
||||
for pct in (85.0, 65.6, 48.0, 25.0):
|
||||
grade = gen_badges.quality_grade("clean", pct)
|
||||
self.assertEqual(gen_badges.GRADE_COLORS[grade], gen_badges.cov_color(pct))
|
||||
|
||||
def test_coverage_table_is_split_by_crate(self):
|
||||
with tempfile.TemporaryDirectory(prefix="alkane-cov-") as directory:
|
||||
summary = Path(directory) / "summary.txt"
|
||||
summary.write_text(
|
||||
"Filename Regions Missed Regions Cover Functions Missed Functions "
|
||||
"Executed Lines Missed Lines Cover\n"
|
||||
"crates/alkane-gui/src/ui.rs 10 5 50.00% 4 2 50.00% 100 60 40.00%\n"
|
||||
"crates/alkane-core/src/platform.rs 4 0 100.00% 2 0 100.00% 50 5 90.00%\n"
|
||||
"TOTAL 14 5 64.29% 6 2 66.67% 150 65 56.67%\n")
|
||||
rows = gen_badges.coverage_by_file(str(summary), directory)
|
||||
self.assertEqual([r["file"] for r in rows],
|
||||
["crates/alkane-gui/src/ui.rs", "crates/alkane-core/src/platform.rs"])
|
||||
self.assertEqual(rows[0]["missed"], 60)
|
||||
self.assertEqual(gen_badges.crate_of(rows[1]["file"]), "alkane-core")
|
||||
|
||||
def test_coverage_table_restores_the_stripped_crates_prefix(self):
|
||||
with tempfile.TemporaryDirectory(prefix="alkane-cov-") as directory:
|
||||
(Path(directory) / "crates" / "alkane-cli").mkdir(parents=True)
|
||||
summary = Path(directory) / "summary.txt"
|
||||
summary.write_text(
|
||||
"alkane-cli/src/main.rs 4 4 0.00% 1 1 0.00% 23 23 0.00%\n")
|
||||
rows = gen_badges.coverage_by_file(str(summary), directory)
|
||||
self.assertEqual(rows[0], {"file": "crates/alkane-cli/src/main.rs",
|
||||
"lines": 23, "missed": 23})
|
||||
self.assertEqual(gen_badges.crate_of(rows[0]["file"]), "alkane-cli")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Binary file not shown.
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# Regenerate alkane-toolkit.icns (the macOS app icon) from the in-repo
|
||||
# microchip glyph: the same white chip on a rounded amber tile as the Windows
|
||||
# icon, at the sizes macOS asks for (16-1024 px). Needs rsvg-convert,
|
||||
# ImageMagick and python3; the .icns is committed, so a build never runs this.
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
GLYPH=../assets/icons/microchip-solid-full.svg
|
||||
TMP=$(mktemp -d)
|
||||
trap 'rm -rf "$TMP"' 0
|
||||
sed 's/currentColor/#ffffff/g; s/<svg /<svg fill="#ffffff" /' "$GLYPH" > "$TMP/glyph.svg"
|
||||
for s in 16 32 64 128 256 512 1024; do
|
||||
# Apple's grid: the tile fills ~80% of the canvas, centred.
|
||||
t=$((s * 80 / 100)); m=$(((s - t) / 2)); r=$((t * 22 / 100))
|
||||
g=$((t * 60 / 100)); o=$(((s - g) / 2))
|
||||
rsvg-convert -w "$g" -h "$g" "$TMP/glyph.svg" -o "$TMP/g$s.png"
|
||||
convert -size "${s}x${s}" xc:none -fill '#d9822b' \
|
||||
-draw "roundrectangle $m,$m $((m + t - 1)),$((m + t - 1)) $r,$r" \
|
||||
"$TMP/g$s.png" -geometry "+$o+$o" -composite "PNG32:$TMP/i$s.png"
|
||||
done
|
||||
python3 - "$TMP" alkane-toolkit.icns <<'PY'
|
||||
import pathlib, struct, sys
|
||||
tmp, out = pathlib.Path(sys.argv[1]), sys.argv[2]
|
||||
# ICNS element types that hold PNG data, by pixel size.
|
||||
types = [("icp4", 16), ("icp5", 32), ("icp6", 64), ("ic07", 128), ("ic08", 256),
|
||||
("ic09", 512), ("ic10", 1024), ("ic11", 32), ("ic12", 64), ("ic13", 256),
|
||||
("ic14", 512)]
|
||||
body = b""
|
||||
for kind, size in types:
|
||||
data = (tmp / f"i{size}.png").read_bytes()
|
||||
body += kind.encode() + struct.pack(">I", len(data) + 8) + data
|
||||
pathlib.Path(out).write_bytes(b"icns" + struct.pack(">I", len(body) + 8) + body)
|
||||
PY
|
||||
echo "wrote $(pwd)/alkane-toolkit.icns"
|
||||
@@ -69,13 +69,26 @@ pub fn load_ssh_credentials() -> Option<(String, String)> {
|
||||
load_creds_file(SSH_CREDENTIALS_FILE)
|
||||
}
|
||||
|
||||
/// Save the SSH username/password (0600). Retained for a future SSH-login dialog
|
||||
/// now that the SSH PIC probe that used to save it has been removed (round 14 #5).
|
||||
#[allow(dead_code)]
|
||||
/// Save the SSH username/password (0600), from the Credentials dialog.
|
||||
pub fn save_ssh_credentials(user: &str, pass: &str) -> std::io::Result<()> {
|
||||
save_creds_file(SSH_CREDENTIALS_FILE, user, pass)
|
||||
}
|
||||
|
||||
/// Remove the saved SSH login, if any. Not an error if none was saved.
|
||||
pub fn clear_ssh_credentials() -> std::io::Result<()> {
|
||||
clear_creds_file(SSH_CREDENTIALS_FILE)
|
||||
}
|
||||
|
||||
/// The SSH username to use: the saved one, or `root` (the control-board login
|
||||
/// on every firmware the restore flow drives over SSH) when none was entered.
|
||||
pub fn ssh_user_or_default(user: &str) -> String {
|
||||
if user.trim().is_empty() {
|
||||
"root".to_string()
|
||||
} else {
|
||||
user.trim().to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove the saved web/API credentials, if any. Not an error if none were saved.
|
||||
pub fn clear_credentials() -> std::io::Result<()> {
|
||||
match clear_creds_file(CREDENTIALS_FILE) {
|
||||
@@ -272,6 +285,28 @@ mod tests {
|
||||
assert_eq!(load_credentials(), None, "cleared -> None");
|
||||
clear_credentials().unwrap(); // idempotent: clearing an already-clear store is not an error
|
||||
|
||||
// SSH login: separate file, same 0600 rule, clear is idempotent.
|
||||
assert_eq!(load_ssh_credentials(), None, "no SSH file -> None");
|
||||
save_ssh_credentials("root", "ssh-pass").unwrap();
|
||||
assert_owner_only(
|
||||
&config_path(SSH_CREDENTIALS_FILE),
|
||||
"SSH creds file must be 0600",
|
||||
);
|
||||
assert_eq!(
|
||||
load_ssh_credentials(),
|
||||
Some(("root".to_string(), "ssh-pass".to_string()))
|
||||
);
|
||||
assert_eq!(
|
||||
load_credentials(),
|
||||
None,
|
||||
"SSH save leaves the web login alone"
|
||||
);
|
||||
clear_ssh_credentials().unwrap();
|
||||
assert_eq!(load_ssh_credentials(), None, "cleared -> None");
|
||||
clear_ssh_credentials().unwrap();
|
||||
assert_eq!(ssh_user_or_default(""), "root");
|
||||
assert_eq!(ssh_user_or_default(" admin "), "admin");
|
||||
|
||||
// Per-firmware overrides (round 12 #13). Kept in this same test because
|
||||
// HOME is process-global: a second #[test] mutating it would race under
|
||||
// cargo's default parallel runner.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Bench-fleet fixtures: the expected hardware output of the 9 boards on
|
||||
//! 10.255.1.0/24 (see ../../../HANDOFF.md section 7 and the parent project's
|
||||
//! [removed]). These are the reference values the workflow tests compare
|
||||
//! Fixture fleet: the expected hardware output of nine representative miners
|
||||
//! (one per control-board family / firmware). These are the reference values
|
||||
//! the workflow tests compare
|
||||
//! the application's actual output against, and the rows the offline
|
||||
//! `ALKANE_FAKE_SCAN` demo mode renders. Only miners that respond become rows,
|
||||
//! so there is no synthetic "offline" fixture.
|
||||
|
||||
@@ -245,7 +245,7 @@ fn restore_braiins(ip: &str, user: &str, pass: &str) -> (bool, String) {
|
||||
if pass.is_empty() {
|
||||
return (
|
||||
false,
|
||||
"Braiins restore needs an SSH password (set the SSH login)".into(),
|
||||
"Braiins restore needs an SSH password (Credentials > SSH)".into(),
|
||||
);
|
||||
}
|
||||
let target = format!("{user}@{ip}");
|
||||
|
||||
@@ -86,7 +86,9 @@ pub fn save_scan_concurrency(n: usize) -> std::io::Result<()> {
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
pub const DEFAULT_RANGE: &str = "10.255.1.0/24";
|
||||
/// The usual home/site router subnet. Host bits are masked off, so this scans
|
||||
/// 192.168.1.0/24.
|
||||
pub const DEFAULT_RANGE: &str = "192.168.1.1/24";
|
||||
/// Default seconds between automatic rescans.
|
||||
pub const DEFAULT_AUTO_SECS: u64 = 300;
|
||||
|
||||
@@ -2267,6 +2269,13 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_range_covers_the_whole_192_168_1_subnet() {
|
||||
let ips = parse_line(DEFAULT_RANGE).unwrap();
|
||||
let cidrs = targets_to_cidrs(&ips);
|
||||
assert_eq!(cidrs, vec![(Ipv4Addr::new(192, 168, 1, 0), 24)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cidr_aggregation_round_trips() {
|
||||
// a /24 must aggregate back to exactly one /24 block
|
||||
|
||||
@@ -770,6 +770,8 @@ pub struct App {
|
||||
// Credentials dialog (round 13 #2). Empty when no global credential is set.
|
||||
creds_user_input: Widget,
|
||||
creds_pass_input: Widget,
|
||||
ssh_user_input: Widget,
|
||||
ssh_pass_input: Widget,
|
||||
// The Credentials dialog (round 13 #2): the global login above plus one
|
||||
// (firmware name, user field, pass field) row per registry firmware.
|
||||
fwcreds_dialog: Widget,
|
||||
@@ -1138,6 +1140,8 @@ pub fn build(frame: Widget) -> App {
|
||||
header_menu_col: None,
|
||||
creds_user_input: frame,
|
||||
creds_pass_input: frame,
|
||||
ssh_user_input: frame,
|
||||
ssh_pass_input: frame,
|
||||
fwcreds_dialog: frame,
|
||||
fwcreds_rows: Vec::new(),
|
||||
access_probe: None,
|
||||
@@ -2355,6 +2359,7 @@ impl App {
|
||||
vnish_pass
|
||||
};
|
||||
let (ssh_user, ssh_pass) = credentials::load_ssh_credentials().unwrap_or_default();
|
||||
let ssh_user = credentials::ssh_user_or_default(&ssh_user);
|
||||
let ips: Vec<String> = targets.iter().map(|t| t.ip.clone()).collect();
|
||||
self.restore_dialog.close(1);
|
||||
crate::logs::log(format!("restore {} miner(s) to stock", ips.len()));
|
||||
@@ -3112,6 +3117,52 @@ impl App {
|
||||
);
|
||||
self.creds_user_input = user_input;
|
||||
self.creds_pass_input = pass_input;
|
||||
// SSH login for the control board (Braiins restore-to-stock). Same rule
|
||||
// as the global login: the password is never shown, blank keeps it.
|
||||
let (ssh_user, ssh_pass) = credentials::load_ssh_credentials().unwrap_or_default();
|
||||
let s_hint = if ssh_pass.is_empty() {
|
||||
"SSH (restore)"
|
||||
} else {
|
||||
"SSH (password saved; blank keeps it)"
|
||||
};
|
||||
let srow = Widget::box_sizer(false);
|
||||
let slabel = Widget::static_text(dlg, s_hint);
|
||||
slabel.set_min_size(150, -1);
|
||||
srow.add(
|
||||
slabel,
|
||||
0,
|
||||
sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT,
|
||||
6,
|
||||
);
|
||||
let ssh_user_input = Widget::text_ctrl(dlg, false);
|
||||
ssh_user_input.set_min_size(150, -1);
|
||||
ssh_user_input.set_value(if ssh_user.is_empty() {
|
||||
"root"
|
||||
} else {
|
||||
&ssh_user
|
||||
});
|
||||
srow.add(
|
||||
ssh_user_input,
|
||||
0,
|
||||
sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT,
|
||||
6,
|
||||
);
|
||||
let ssh_pass_input = Widget::password_ctrl(dlg);
|
||||
ssh_pass_input.set_min_size(150, -1);
|
||||
srow.add(
|
||||
ssh_pass_input,
|
||||
1,
|
||||
sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_LEFT | sf::BORDER_RIGHT,
|
||||
6,
|
||||
);
|
||||
root.add_sizer(
|
||||
srow,
|
||||
0,
|
||||
sf::EXPAND | sf::BORDER_LEFT | sf::BORDER_RIGHT | sf::BORDER_TOP,
|
||||
6,
|
||||
);
|
||||
self.ssh_user_input = ssh_user_input;
|
||||
self.ssh_pass_input = ssh_pass_input;
|
||||
// Column headers.
|
||||
let head = Widget::box_sizer(false);
|
||||
let h_fw = Widget::static_text(dlg, "Firmware");
|
||||
@@ -3223,6 +3274,21 @@ impl App {
|
||||
wx_rs::set_status_text(&format!("failed to save global login: {e}"));
|
||||
return;
|
||||
}
|
||||
// SSH login: a blank password keeps the saved one; with nothing saved
|
||||
// and no password entered there is nothing to store.
|
||||
let s_user = credentials::ssh_user_or_default(&self.ssh_user_input.get_value());
|
||||
let s_pass = self.ssh_pass_input.get_value();
|
||||
let ssh_result = if !s_pass.is_empty() {
|
||||
credentials::save_ssh_credentials(&s_user, &s_pass)
|
||||
} else if let Some((_, saved)) = credentials::load_ssh_credentials() {
|
||||
credentials::save_ssh_credentials(&s_user, &saved)
|
||||
} else {
|
||||
Ok(())
|
||||
};
|
||||
if let Err(e) = ssh_result {
|
||||
wx_rs::set_status_text(&format!("failed to save SSH login: {e}"));
|
||||
return;
|
||||
}
|
||||
// Per-firmware overrides.
|
||||
let mut map: std::collections::HashMap<String, (String, String)> =
|
||||
std::collections::HashMap::new();
|
||||
@@ -3259,6 +3325,8 @@ impl App {
|
||||
fn apply_firmware_creds_reset(&mut self) {
|
||||
self.creds_user_input.set_value("");
|
||||
self.creds_pass_input.set_value("");
|
||||
self.ssh_user_input.set_value("root");
|
||||
self.ssh_pass_input.set_value("");
|
||||
for (name, user_ctrl, pass_ctrl) in &self.fwcreds_rows {
|
||||
let (user, pass) = credentials::firmware_default_for(name);
|
||||
user_ctrl.set_value(&user);
|
||||
@@ -3266,7 +3334,8 @@ impl App {
|
||||
}
|
||||
let per_fw = credentials::clear_firmware_credentials();
|
||||
let global = credentials::clear_credentials();
|
||||
match per_fw.and(global) {
|
||||
let ssh = credentials::clear_ssh_credentials();
|
||||
match per_fw.and(global).and(ssh) {
|
||||
Ok(()) => wx_rs::set_status_text("credentials reset to defaults"),
|
||||
Err(e) => wx_rs::set_status_text(&format!("failed to reset credentials: {e}")),
|
||||
}
|
||||
@@ -3878,7 +3947,7 @@ impl App {
|
||||
let edit = Widget::text_ctrl(dlg, true);
|
||||
edit.set_value(&scan::load_ranges().join("\n"));
|
||||
edit.set_tool_tip(
|
||||
"One range per line:\n CIDR 10.255.1.0/24\n range 10.253.1.3-10.253.1.234\n single 10.253.1.5",
|
||||
"One range per line:\n CIDR 192.168.1.0/24\n range 192.168.1.3-192.168.1.234\n single 192.168.1.5",
|
||||
);
|
||||
root.add(edit, 1, sf::EXPAND | sf::BORDER_ALL, 6);
|
||||
// Auto-rescan interval (seconds; 0 = off) and per-miner scan timeout.
|
||||
|
||||
@@ -25,11 +25,11 @@ BEGIN
|
||||
BEGIN
|
||||
BLOCK "040904B0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Blueflare"
|
||||
VALUE "CompanyName", "BlueFlare Energy Solutions Inc."
|
||||
VALUE "FileDescription", "Alkane Toolkit"
|
||||
VALUE "FileVersion", ALKANE_VER_STR
|
||||
VALUE "InternalName", "alkane-toolkit"
|
||||
VALUE "LegalCopyright", "Copyright (c) 2026 Blueflare (MIT License)"
|
||||
VALUE "LegalCopyright", "Copyright (c) 2026 BlueFlare Energy Solutions Inc. (MIT License)"
|
||||
VALUE "OriginalFilename", "alkane-toolkit.exe"
|
||||
VALUE "ProductName", "Alkane Toolkit"
|
||||
VALUE "ProductVersion", ALKANE_VER_STR
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
# macOS
|
||||
|
||||
The macOS build is one universal app, `Alkane Toolkit.app`, that runs natively
|
||||
on Apple Silicon and Intel Macs with macOS 11 (Big Sur) or later. It ships as
|
||||
`alkane-toolkit-vX.Y.Z-macos-universal.zip`, holding the app, `LICENSE` and a
|
||||
`README.txt`.
|
||||
|
||||
## Using it
|
||||
|
||||
- Settings live in `~/.config/alkane-toolkit`, the same files as on Linux.
|
||||
- SSH actions use the system `ssh`; HTTP actions use the system `curl`.
|
||||
- The app is ad-hoc signed but not notarized, so macOS blocks the first launch.
|
||||
On macOS 15 or later, try to open it, then choose **Open Anyway** in
|
||||
System Settings > Privacy & Security. On macOS 11 to 14, Control-click the
|
||||
app and choose **Open**. Or clear the quarantine flag once:
|
||||
`xattr -dr com.apple.quarantine "/Applications/Alkane Toolkit.app"`.
|
||||
- The first scan asks for permission to find devices on the local network
|
||||
(macOS 15 and later). Scanning needs it.
|
||||
- Offline demo: `ALKANE_FAKE_SCAN=1 "/Applications/Alkane Toolkit.app/Contents/MacOS/alkane-toolkit"`.
|
||||
|
||||
## Building
|
||||
|
||||
macOS builds only on a Mac. It needs the Xcode Command Line Tools
|
||||
(`xcode-select --install`) and rustup with both Apple targets:
|
||||
|
||||
```sh
|
||||
rustup target add aarch64-apple-darwin x86_64-apple-darwin
|
||||
scripts/build-wx-macos.sh # once: universal static wxOSX 3.3.3 in ~/.cache/wx-3.3.3-macos
|
||||
scripts/build-gui-macos.sh # both slices, merged with lipo
|
||||
python3 ci/package-macos.py X.Y.Z target/universal-apple-darwin/release/alkane-toolkit dist
|
||||
```
|
||||
|
||||
`build-wx-macos.sh` builds wxWidgets once for arm64 and x86_64 together, with
|
||||
wx's bundled image, zlib, regex and expat libraries, so the app links only
|
||||
against system frameworks. `build-gui-macos.sh` builds each Rust target
|
||||
against that prefix and merges them. `package-macos.py` writes the bundle
|
||||
(Info.plist, icon), ad-hoc signs it and zips it with `ditto`.
|
||||
|
||||
To test on the Mac:
|
||||
|
||||
```sh
|
||||
ALKANE_SELFTEST=1 target/universal-apple-darwin/release/alkane-toolkit # headless UI self-test
|
||||
cargo test --release --offline --target aarch64-apple-darwin --workspace --exclude wx-rs
|
||||
```
|
||||
|
||||
The self-test opens a window briefly, so it needs a logged-in desktop
|
||||
session. Running the x86_64 slice on Apple Silicon needs Rosetta 2.
|
||||
|
||||
## Why macOS 11
|
||||
|
||||
Current Xcode SDKs ship a libc++ that supports macOS 11 and later only;
|
||||
building for an older target compiles, but the app could fail at run time on
|
||||
the older system. macOS 11 is also the first release for Apple Silicon. Older
|
||||
Intel Macs would need a build with an older SDK.
|
||||
|
||||
## Notes for the bridge
|
||||
|
||||
wxOSX reports logical (point) sizes, like the GTK and MSW bridges; the
|
||||
bridge never scales to physical pixels. wxOSX's Objective-C uses
|
||||
`@available`, so `build.rs` links clang's compiler runtime
|
||||
(`libclang_rt.osx.a`), which rustc's link does not include by itself. Both
|
||||
are wx-rs patch `0009`.
|
||||
@@ -0,0 +1,66 @@
|
||||
# Getting started
|
||||
|
||||
Alkane Toolkit finds the ASIC miners on your network and shows them in one
|
||||
table: model, firmware, hashrate, power, temperatures, fans and the health of
|
||||
every hashboard. From the same table you can run the controls each miner's
|
||||
firmware supports, such as pausing, restarting or changing pools.
|
||||
|
||||
## Download
|
||||
|
||||
Get the latest release from the
|
||||
[downloads page](https://gitea.bluefla.re/blueflare/alkane-toolkit/releases).
|
||||
|
||||
| Platform | File | Notes |
|
||||
|---|---|---|
|
||||
| Windows 10 and 11 (x86_64) | `alkane-toolkit-vX.Y.Z-windows-x86_64.zip` | One signed `alkane-toolkit.exe`; nothing to install |
|
||||
| Linux (x86_64) | `alkane-toolkit-vX.Y.Z-linux-x86_64.tar.gz` | One binary; needs GTK 3 (`sudo apt install libgtk-3-0`) |
|
||||
| macOS 11 or later (Apple Silicon and Intel) | `alkane-toolkit-vX.Y.Z-macos-universal.zip` | One app; not notarized, so confirm the first launch |
|
||||
|
||||
### Windows
|
||||
|
||||
1. Download the zip, right-click it, choose **Properties**, tick **Unblock** if
|
||||
it is shown, then extract it.
|
||||
2. Run `alkane-toolkit.exe`. Windows shows *BlueFlare Energy Solutions Inc.* as
|
||||
the verified publisher. To check the signature yourself, right-click the exe,
|
||||
choose **Properties** and open **Digital Signatures**.
|
||||
|
||||
### macOS
|
||||
|
||||
1. Download the zip and open it; drag **Alkane Toolkit** to Applications.
|
||||
2. Open it. The app is not notarized, so macOS blocks the first launch:
|
||||
- macOS 15 or later: open **System Settings > Privacy & Security** and
|
||||
choose **Open Anyway** for Alkane Toolkit.
|
||||
- macOS 11 to 14: Control-click the app, choose **Open**, then **Open**.
|
||||
3. When asked, allow it to find devices on your local network. Scanning
|
||||
needs this.
|
||||
|
||||
### Linux
|
||||
|
||||
```sh
|
||||
tar xzf alkane-toolkit-vX.Y.Z-linux-x86_64.tar.gz
|
||||
./alkane-toolkit-vX.Y.Z-linux-x86_64/alkane-toolkit
|
||||
```
|
||||
|
||||
## First run
|
||||
|
||||
The toolkit starts a scan as soon as it opens. Set your own ranges first with
|
||||
**Scan ranges** (see [Scanning](02-scanning.md)); until you do, it scans
|
||||
192.168.1.0/24, the usual router subnet.
|
||||
|
||||
To look around without touching any miner, start it in demo mode. It shows a
|
||||
built-in sample fleet and simulates every action:
|
||||
|
||||
| Platform | Command |
|
||||
|---|---|
|
||||
| Windows (Command Prompt) | `set ALKANE_FAKE_SCAN=1 && alkane-toolkit.exe` |
|
||||
| Linux | `ALKANE_FAKE_SCAN=1 ./alkane-toolkit` |
|
||||
|
||||
## Where settings are kept
|
||||
|
||||
| Platform | Folder |
|
||||
|---|---|
|
||||
| Windows | `%APPDATA%\alkane-toolkit` |
|
||||
| Linux | `~/.config/alkane-toolkit` |
|
||||
|
||||
See [Settings and credentials](06-settings.md) for the files in that folder.
|
||||
Deleting the folder resets the toolkit to its defaults.
|
||||
@@ -0,0 +1,51 @@
|
||||
# Scanning
|
||||
|
||||
Discovery is read-only: a scan asks each address what it is and records what
|
||||
it reports. It never changes a miner.
|
||||
|
||||
## Scan ranges
|
||||
|
||||
Click **Scan ranges** to edit the addresses to scan. Put one entry per line;
|
||||
blank lines and lines starting with `#` are ignored.
|
||||
|
||||
| Form | Example | Scans |
|
||||
|---|---|---|
|
||||
| Single address | `192.168.1.50` | that address |
|
||||
| CIDR block | `192.168.1.0/24` | the whole block |
|
||||
| Full range | `192.168.1.10-192.168.2.40` | every address between the two, inclusive |
|
||||
| Short range | `192.168.1.10-90` | `.10` to `.90` within the same /24 |
|
||||
| Per-octet ranges | `10.1-4.0-1.1-255` | every combination (10.1.0.1 ... 10.4.1.255) |
|
||||
|
||||
Commas or spaces between several entries on one line are not accepted; use one
|
||||
line each. Duplicates are removed automatically. One line, and all lines
|
||||
together, may cover at most 1,000,000 addresses.
|
||||
|
||||
**Apply** saves the ranges and starts a scan. A mistake keeps the dialog open
|
||||
and the status bar explains it, for example `invalid range: bad octet range`.
|
||||
|
||||
The same dialog has three numbers:
|
||||
|
||||
| Field | Meaning | Default |
|
||||
|---|---|---|
|
||||
| Rescan (s) | seconds between automatic rescans; `0` turns auto-rescan off | 300 |
|
||||
| Timeout (s) | how long to wait for one miner (scans, refreshes, actions and log fetches) | 10 |
|
||||
| Concurrency | how many addresses are probed at once (8 to 256); higher is faster but slow miners may report fewer values | 128 |
|
||||
|
||||
When the ranges change, miners outside the new ranges leave the table at the
|
||||
next scan.
|
||||
|
||||
## Running, pausing and stopping
|
||||
|
||||
The three buttons next to **Scan ranges** control scanning:
|
||||
|
||||
- **Play** (green) turns auto-rescan on and starts a scan now if none is running.
|
||||
- **Pause** (amber) turns auto-rescan off and lets the current scan finish.
|
||||
- **Stop** (red) turns auto-rescan off and cancels the current scan.
|
||||
|
||||
While a scan runs, a progress bar spans the top of the table and the status bar
|
||||
shows progress such as `1935/4590 - scanning 192.168.1.86 (92 found)`. Afterwards
|
||||
it shows the count and the time to the next scan, for example
|
||||
`245 miners - next scan in 4m 12s`.
|
||||
|
||||
Actions that change miners wait for the scan to finish; see
|
||||
[Actions](05-actions.md).
|
||||
@@ -0,0 +1,80 @@
|
||||
# The table and header
|
||||
|
||||
## Summary cards
|
||||
|
||||
The cards at the top count the miners **currently shown** (after any filter).
|
||||
Each miner is in exactly one status: slow, paused, hashing or not hashing.
|
||||
|
||||
| Card | Counts | Click |
|
||||
|---|---|---|
|
||||
| Total | rows in the view | - |
|
||||
| Hashing (green rabbit) | mining at 80% of expected hashrate or more | show only these; click again to clear |
|
||||
| Slow (amber turtle) | mining below 80% of expected hashrate | show only these |
|
||||
| Not hashing (red glass) | answering but not mining | show only these |
|
||||
| Paused (blue otter) | stopped on purpose (paused, stopped, suspended) | show only these |
|
||||
| SHA-256 Hashrate | total hashrate, per algorithm | switch algorithm when the fleet runs more than one |
|
||||
| Est. power | total reported power draw | - |
|
||||
|
||||
On a narrow window the hashrate and power cards are hidden.
|
||||
|
||||
## Columns
|
||||
|
||||
IP is always the first column. The default view shows Model, Health,
|
||||
Hashrate, Power, Chip temp, Firmware, CPU, Access and Light. More than seventy
|
||||
other columns are available, grouped as Identity, Firmware and board, Health
|
||||
and status, Performance, Temperature, Cooling, Hardware and Pools.
|
||||
|
||||
- **Columns** opens a checklist: tick to show, drag to reorder, or sort the list
|
||||
alphabetically or by category. *Hide columns with no scanned values* hides
|
||||
columns that are empty for every miner (it resets when the app restarts).
|
||||
- Drag a column header to move it.
|
||||
- Right-click a header to sort by it, auto-size one or all columns, hide it, or
|
||||
open the column chooser.
|
||||
|
||||
Some values worth knowing:
|
||||
|
||||
| Column | Shows |
|
||||
|---|---|
|
||||
| Hashrate | actual/expected, for example `95.0T/96.0T`; the actual part is red at 50% of expected or less, amber around 75%, green at 100% |
|
||||
| Chip temp | hottest chip on each hashboard, for example `77 / 64 / 74`; blue when cool, red at 90 C and above |
|
||||
| Firmware | the firmware family, coloured (Braiins purple, LuxOS gold, VNish green, ePIC light blue, Hiveon orange, Bixbit pink); stock firmware uses the normal text colour |
|
||||
| Pool account / Worker | the pool user split at the first dot |
|
||||
| Board HR / V / freq | per-hashboard hashrate, voltage and frequency |
|
||||
|
||||
A blank cell means the miner did not report that value.
|
||||
|
||||
## Sorting
|
||||
|
||||
Click a header to sort ascending, again for descending, again to clear.
|
||||
|
||||
- **Hashrate** also sorts by *relative* hashrate (actual as a share of
|
||||
expected), shown as `%^` and `%v` in the header.
|
||||
- **Health** sorts by overall health, then by power (`Pwr`), fans (`Fan`) and
|
||||
hashboards (`Brd`). Ascending puts the most broken miners first.
|
||||
|
||||
## Selecting miners
|
||||
|
||||
Click a row to select it; Ctrl-click and Shift-click add to the selection, and
|
||||
you can drag across rows to select a block. The selection follows miners by IP,
|
||||
so it survives rescans. Double-click a row (or press Enter) to open the miner's
|
||||
web page in your browser. Right-click the selection for [actions](05-actions.md).
|
||||
|
||||
## Filters and presets
|
||||
|
||||
**Filter** keeps only the rows that match. Pick a column, then:
|
||||
|
||||
- for numbers: between, =, !=, >, >=, < or <= (blank cells never match);
|
||||
- for text: *is any of* (tick values; `(blank)` matches empty cells), contains,
|
||||
does not contain, begins with, ends with or equals (case does not matter).
|
||||
|
||||
Filters on different columns must all match. **Reset** clears them. Clicking a
|
||||
status card is a quick filter of its own.
|
||||
|
||||
**Presets** saves and loads whole views: column order and visibility, sort and
|
||||
filters. *Default* is built in and cannot be deleted; saving under an existing
|
||||
name replaces it.
|
||||
|
||||
## Zoom and theme
|
||||
|
||||
The slider in the bottom-right corner zooms the table: text, icons and column
|
||||
widths scale together. The window follows the system light or dark theme.
|
||||
@@ -0,0 +1,54 @@
|
||||
# Health, access and light
|
||||
|
||||
## The Health column
|
||||
|
||||
Each miner gets a row of icons, always in the same order, so problems line up
|
||||
across the table:
|
||||
|
||||
1. **Bolt**: the power supply
|
||||
2. **Brain**: the control board
|
||||
3. **Fan**: one icon per fan
|
||||
4. **Chip**: one icon per hashboard
|
||||
|
||||
Hover over any icon to see its details: PSU voltage and current, the fan speed,
|
||||
or a hashboard's actual and expected hashrate, frequency and voltage, and any
|
||||
fault message with its code.
|
||||
|
||||
| Colour | Meaning |
|
||||
|---|---|
|
||||
| Green | healthy |
|
||||
| Amber | working but below par (a slow board, a fan well below the others, a PSU fault while still mining) |
|
||||
| Red | detected but down (a faulted board, a stopped fan, a PSU that is not delivering) |
|
||||
| Grey | expected but not detected or not reachable |
|
||||
| Blue | the miner is paused, so its boards and stopped fans are idle on purpose |
|
||||
|
||||
How each part is judged:
|
||||
|
||||
- **Power** is green when the miner draws power, its PSU fan turns or it is
|
||||
mining; a reported PSU fault makes it amber (still mining) or red.
|
||||
- **Control board** is red for a control-board fault and amber for a
|
||||
miner-wide warning such as a high ambient temperature.
|
||||
- **Fans** are red at 0 rpm and amber below half the speed of the fastest fan.
|
||||
- **Hashboards** follow the status the miner reports for each board. When the
|
||||
firmware names the failing boards, only those turn red. A board the miner
|
||||
cannot see is grey.
|
||||
|
||||
While an action runs on a miner, its Health cell shows progress such as
|
||||
`restarting...` or `refreshing...`.
|
||||
|
||||
## Access
|
||||
|
||||
The padlock shows whether the toolkit can change the miner:
|
||||
|
||||
- **green, open**: changes are possible with the saved credentials;
|
||||
- **red, closed**: view only;
|
||||
- **blank**: not known yet.
|
||||
|
||||
After a scan the padlock is an estimate from what the firmware offers. Use
|
||||
**Check access (auth)** in the right-click menu for a real, read-only login
|
||||
test.
|
||||
|
||||
## Light
|
||||
|
||||
A flashing green-over-red dot means the miner's locate light is on. Turn it on
|
||||
or off with **Flash lights** / **Stop flashing lights**.
|
||||
@@ -0,0 +1,60 @@
|
||||
# Actions
|
||||
|
||||
Right-click one or more selected miners for the actions menu. With several
|
||||
miners selected, labels show the count, for example *Restart (12)*. An action
|
||||
appears only when **every** selected miner's firmware supports it, so the menu
|
||||
changes with the selection.
|
||||
|
||||
| Action | What it does | Changes the miner |
|
||||
|---|---|---|
|
||||
| Open in browser | opens each miner's web page | no |
|
||||
| Refresh | re-reads just these miners | no |
|
||||
| Check access (auth) | tests whether the saved login is accepted | no |
|
||||
| View log (API)... | shows the first selected miner's log (WhatsMiner: its active fault codes) | no |
|
||||
| Restore to stock firmware... | removes aftermarket firmware; see [Restore to stock](07-restore.md) | yes, reboots |
|
||||
| Flash lights / Stop flashing lights | locate light on or off | yes, harmless |
|
||||
| Pause mining / Resume mining | stop or start hashing | yes |
|
||||
| Set tuning %... | tuning level, 0 to 100 | yes |
|
||||
| Set power target... | power target in watts; the prompt shows the current value and the allowed range | yes |
|
||||
| Set hashrate target... | hashrate target in TH/s, for firmware that tunes by hashrate | yes |
|
||||
| Set profile... | pick a firmware profile or preset (only profiles every selected miner has are listed) | yes |
|
||||
| Restart | reboot | yes |
|
||||
| Configure pools... | set up to three pools | yes |
|
||||
| Set timezone... | IANA time zone, for example `America/Edmonton` | yes |
|
||||
| Change password... | new web/API password | yes |
|
||||
| Factory reset... | wipes pools, tuning and network settings and reboots; the miner may come back on a new DHCP address | yes, destructive |
|
||||
|
||||
## Safety
|
||||
|
||||
- Pause, Resume, Restart and Factory reset ask for confirmation. Value prompts
|
||||
(tuning, targets, timezone, password) apply when you confirm the value.
|
||||
- Actions that change miners do not start while a scan is running, including an
|
||||
automatic rescan. Wait for it to finish or press **Pause**. Scans in turn wait
|
||||
for running actions.
|
||||
- Each changed miner is re-read automatically when the action finishes. Results
|
||||
and failures appear in the bottom-right corner of the status bar and in
|
||||
**Settings > Logs**.
|
||||
- If **Change password** succeeds on every selected miner, the saved global
|
||||
login is updated to the new password. If only some succeed, the saved login
|
||||
is left alone and the log says so.
|
||||
|
||||
## Configuring pools
|
||||
|
||||
The pool dialog has three rows: Address, Account, Worker and Password. A row is
|
||||
used only when it has an address and an account. A blank password becomes `x`.
|
||||
The miner's username becomes `account.worker`.
|
||||
|
||||
Each field has a **+** menu with common pool addresses and the values you saved
|
||||
before (**Add new...** edits that list). Worker names can use placeholders that
|
||||
are filled in per miner:
|
||||
|
||||
| Placeholder | Becomes |
|
||||
|---|---|
|
||||
| `{ip1}` to `{ip4}` | one octet of the miner's IP |
|
||||
| `{serial}`, `{mac}` | serial number; MAC without colons |
|
||||
| `{hostname}` | the miner's hostname |
|
||||
| `{brand}`, `{model}`, `{submodel}` | make and model |
|
||||
| `{firmware}`, `{cpu}`, `{cb}` | firmware family, control-board CPU and board |
|
||||
| `{nameplate-hr}` | the model's rated hashrate |
|
||||
|
||||
For example, `rack3-{ip3}-{ip4}` gives `rack3-1-50` for `10.0.1.50`.
|
||||
@@ -0,0 +1,72 @@
|
||||
# Settings and credentials
|
||||
|
||||
**Settings** opens a menu with Credentials, Language and Logs.
|
||||
|
||||
## Credentials
|
||||
|
||||
Miners need a login for anything beyond basic discovery: for some details, and
|
||||
for every action. The Credentials dialog has three parts:
|
||||
|
||||
- **All firmwares** at the top: one username and password tried on every miner.
|
||||
The saved password is never shown; leave the field blank to keep it. Blank
|
||||
username and password clear it.
|
||||
- **SSH (restore)**: the control-board SSH login used to restore Braiins OS to
|
||||
stock (see [SSH login](#ssh-login)).
|
||||
- **One row per firmware**, pre-filled with that firmware's factory default.
|
||||
Change a row to override the login for that firmware only.
|
||||
|
||||
The toolkit tries, in order, the firmware's own row, then the global login,
|
||||
then the firmware's built-in default.
|
||||
|
||||
| Firmware | Factory default (user / password) |
|
||||
|---|---|
|
||||
| AntMiner Stock | root / root |
|
||||
| WhatsMiner Stock | admin / admin |
|
||||
| Braiins | root / root |
|
||||
| VNish | (none) / admin |
|
||||
| LuxOS | root / root |
|
||||
| UMC OS | (none) / letmein |
|
||||
| Marathon | root / root |
|
||||
| VolcMiner Stock | root / ltc@dog |
|
||||
| Elphapex Stock | root / root |
|
||||
| FutureBit Stock | futurebit / futurebit123 |
|
||||
| SealMiner Stock | seal / seal |
|
||||
| Auradine Stock | admin / admin |
|
||||
|
||||
**Reset to defaults** clears every override, the global login and the SSH
|
||||
login at once.
|
||||
|
||||
Logins are stored as plain text in the settings folder, readable only by your
|
||||
user account (Linux file mode 0600; on Windows, your profile folder's
|
||||
permissions).
|
||||
|
||||
### SSH login
|
||||
|
||||
Restoring Braiins to stock runs a command over SSH, using the system `ssh`
|
||||
client (built into Windows 10/11). Set its login in the **SSH (restore)** row
|
||||
of the Credentials dialog. The username defaults to `root`. As with the global
|
||||
login, the saved password is never shown and a blank password keeps it.
|
||||
|
||||
## Language
|
||||
|
||||
English, Chinese, Russian, French, Spanish and Portuguese. The toolbar, cards
|
||||
and column headers switch immediately; menus and dialogs not yet translated
|
||||
stay in English.
|
||||
|
||||
## Logs
|
||||
|
||||
An activity log of scans, actions, errors and exports, newest last, kept for
|
||||
the current session (the last 2000 lines). Times are shown in UTC.
|
||||
|
||||
## Files in the settings folder
|
||||
|
||||
| File | Holds |
|
||||
|---|---|
|
||||
| `scan-ranges.txt` | scan ranges, one per line |
|
||||
| `auto-rescan-secs.txt`, `scan-timeout-secs.txt`, `scan-concurrency.txt` | the three scan numbers |
|
||||
| `scan-credentials.txt` | global login |
|
||||
| `firmware-credentials.txt` | per-firmware logins |
|
||||
| `ssh-credentials.txt` | SSH login |
|
||||
| `presets.json` | saved views |
|
||||
| `language.txt` | UI language |
|
||||
| `pool-addresses.txt`, `pool-accounts.txt`, `pool-workers.txt`, `pool-passwords.txt` | saved pool values |
|
||||
@@ -0,0 +1,18 @@
|
||||
# Restore to stock firmware
|
||||
|
||||
**Restore to stock firmware...** removes aftermarket firmware and returns the
|
||||
miner to the manufacturer's firmware it keeps on board. Nothing is uploaded.
|
||||
The miner reboots, and some firmwares come back on a new address.
|
||||
|
||||
It is offered when the selection includes a supported firmware, and asks for
|
||||
confirmation with the list of miners first.
|
||||
|
||||
| Firmware | How it is removed | Login used |
|
||||
|---|---|---|
|
||||
| VNish (and builds based on it) | web API: unlock, then remove firmware; reboots in seconds | the VNish row in Credentials, else `admin` |
|
||||
| LuxOS | miner API: log on, then uninstall | none |
|
||||
| Braiins OS | SSH: runs the firmware's own `uninstall.sh` | the SSH row in Credentials (see [Settings](06-settings.md#ssh-login)) |
|
||||
|
||||
Miners are restored one at a time. A dropped connection after the command is
|
||||
sent counts as success, because that is the reboot. A refused login counts as
|
||||
a failure and leaves the miner unchanged.
|
||||
@@ -0,0 +1,14 @@
|
||||
# Export
|
||||
|
||||
**Export** saves the scan as a CSV file for spreadsheets or other tools.
|
||||
|
||||
1. Choose the fields to include (all are ticked by default; **All** and
|
||||
**None** help).
|
||||
2. Pick where to save. The suggested name is `alkane-export-YYYYMMDD-HHMMSS.csv`.
|
||||
|
||||
The export contains **every scanned miner**, not just the rows the current
|
||||
filter shows. Per-board temperatures, fan speeds, board status and pools
|
||||
become numbered columns (`board_temp_1_c`, `fan_2_rpm`, `pool_1_url`, ...).
|
||||
|
||||
Values that start with `=`, `+`, `-` or `@` are prefixed with `'` so a
|
||||
spreadsheet treats them as text, not formulas.
|
||||
@@ -0,0 +1,32 @@
|
||||
# Command line and environment
|
||||
|
||||
## Environment variables
|
||||
|
||||
| Variable | Effect |
|
||||
|---|---|
|
||||
| `ALKANE_FAKE_SCAN=1` | demo mode: a built-in sample fleet, no network traffic, simulated actions |
|
||||
| `ALKANE_APPEARANCE=light` or `dark` | force the light or dark theme |
|
||||
| `ALKANE_SELFTEST=1` | run the built-in UI self-test on the sample fleet and exit (prints `SELFTEST PASS` or `FAIL`) |
|
||||
| `ALKANE_ACCESS_PROBE="<ip> <make>"` | print whether the saved login can change that miner, then exit |
|
||||
| `ALKANE_LOG_SCAN="<ip> <brand>"` | fetch that miner's log through its API, print the size, then exit |
|
||||
|
||||
On Windows these one-shot modes print to the Command Prompt they are started
|
||||
from.
|
||||
|
||||
## miner_probe
|
||||
|
||||
`miner_probe` is a command-line companion for scripting and diagnosis. These
|
||||
commands only read:
|
||||
|
||||
| Command | Prints |
|
||||
|---|---|
|
||||
| `miner_probe scan <cidr> [<cidr>...]` | discovered miners and their telemetry, as tab-separated values |
|
||||
| `miner_probe hashrate <cidr>...` | raw hashrate and algorithm |
|
||||
| `miner_probe msgs <ip>` | fault messages and per-board data |
|
||||
| `miner_probe tune <ip>` | tuning support and limits |
|
||||
| `miner_probe presets <ip>` | available firmware profiles |
|
||||
| `miner_probe timezone <ip>` | the current time zone |
|
||||
|
||||
Its other commands change miners. It uses the global login from the settings
|
||||
folder, or `ALKANE_PROBE_USER` and `ALKANE_PROBE_PASS`, and
|
||||
`ALKANE_PROBE_CONCURRENCY` (default 128).
|
||||
@@ -0,0 +1,28 @@
|
||||
# Troubleshooting
|
||||
|
||||
**Windows says "Windows protected your PC".** SmartScreen warns about new
|
||||
downloads until a certificate has built up reputation. The publisher shown
|
||||
should be *BlueFlare Energy Solutions Inc.*; click **More info**, then **Run
|
||||
anyway**. If no publisher is shown, do not run the file and download it again
|
||||
from the releases page.
|
||||
|
||||
**A miner is missing.** Check that its address is inside the scan ranges and
|
||||
that it answers on its web page from this computer. On busy or slow networks,
|
||||
raise **Timeout** or lower **Concurrency** in the Scan ranges dialog.
|
||||
|
||||
**An action is missing from the right-click menu.** Actions appear only when
|
||||
every selected miner supports them. Select fewer miners, or only miners with
|
||||
the same firmware.
|
||||
|
||||
**An action does nothing and the status says a scan is in progress.** Changes
|
||||
wait for scans. Press **Pause**, let the scan finish, then try again.
|
||||
|
||||
**Check access says locked.** The saved login is not accepted. Set the right
|
||||
password in **Settings > Credentials**, either for all firmwares or for that
|
||||
firmware's row.
|
||||
|
||||
**Values are blank.** The firmware did not report them, or it needs a login to
|
||||
report them. Try **Check access** and the Credentials dialog.
|
||||
|
||||
**The window is too small or too large.** It opens at most as large as your
|
||||
screen's work area. Use the zoom slider in the status bar to scale the table.
|
||||
+2
-3
@@ -63,7 +63,7 @@ credential; the script pins the new digest everywhere.
|
||||
|
||||
Release and `-rc` executables are Authenticode-signed with Azure Artifact
|
||||
Signing (formerly Trusted Signing), so Windows and SmartScreen show
|
||||
"Blueflare" as the verified publisher instead of "Unknown publisher".
|
||||
"BlueFlare Energy Solutions Inc." as the verified publisher instead of "Unknown publisher".
|
||||
|
||||
| Piece | Where |
|
||||
|-------|-------|
|
||||
@@ -99,8 +99,7 @@ AZURE_SIGNING_TOKEN=$(az account get-access-token --resource https://codesigning
|
||||
## Native Windows runner
|
||||
|
||||
`windows-native.yml` runs on the self-hosted runner `win11-test-vm`
|
||||
(label `alkane-windows`, host mode) inside the Windows 11 test VM
|
||||
(a local test VM). It downloads the
|
||||
(label `alkane-windows`, host mode) inside a Windows 11 test VM. It downloads the
|
||||
`alkane-toolkit-windows-tests` artifact of the triggering main run, runs every
|
||||
test executable and the UI self-test natively, and never blocks a release:
|
||||
while the VM is off, the job waits for the runner.
|
||||
|
||||
@@ -1,9 +1,28 @@
|
||||
#!/bin/sh
|
||||
# Build the alkane-toolkit GUI on macOS.
|
||||
# wx-rs upstream supports macOS: its build.rs clones/builds wx 3.2.2.1 into
|
||||
# ./dist (osx-release-build) on first build. Requires Xcode Command Line
|
||||
# Tools. Run this ON a Mac - macOS cannot be linked from Linux.
|
||||
# Build the alkane-toolkit GUI on macOS as one universal binary.
|
||||
#
|
||||
# scripts/build-gui-macos.sh [extra cargo build args]
|
||||
# -> target/universal-apple-darwin/release/alkane-toolkit (arm64 + x86_64)
|
||||
#
|
||||
# Needs the Xcode Command Line Tools, rustup with the aarch64-apple-darwin and
|
||||
# x86_64-apple-darwin targets, and the universal static wx prefix from
|
||||
# scripts/build-wx-macos.sh (WX_MACOS_PREFIX, default ~/.cache/wx-3.3.3-macos).
|
||||
# Each target is built separately against that prefix, then the two slices
|
||||
# are merged with lipo. MACOSX_DEPLOYMENT_TARGET matches the wx build.
|
||||
set -e
|
||||
cd "$(dirname -- "$0")/.."
|
||||
cargo build --release -p alkane-gui
|
||||
echo "binary: target/release/alkane-toolkit (app bundle packaging is follow-up)"
|
||||
PREFIX="${WX_MACOS_PREFIX:-$HOME/.cache/wx-3.3.3-macos}"
|
||||
[ -x "$PREFIX/bin/wx-config" ] || {
|
||||
echo "no wx prefix at $PREFIX; run scripts/build-wx-macos.sh first" >&2; exit 1; }
|
||||
export WX_RS_WXCONFIG="$PREFIX/bin/wx-config"
|
||||
export MACOSX_DEPLOYMENT_TARGET="${MACOSX_MIN:-11.0}"
|
||||
for target in aarch64-apple-darwin x86_64-apple-darwin; do
|
||||
cargo build --release --offline -p alkane-gui --target "$target" "$@"
|
||||
done
|
||||
out=target/universal-apple-darwin/release
|
||||
mkdir -p "$out"
|
||||
lipo -create -output "$out/alkane-toolkit" \
|
||||
target/aarch64-apple-darwin/release/alkane-toolkit \
|
||||
target/x86_64-apple-darwin/release/alkane-toolkit
|
||||
lipo -info "$out/alkane-toolkit"
|
||||
echo "binary: $out/alkane-toolkit"
|
||||
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
# Build the vendored wxWidgets 3.3.3 for macOS: wxOSX/Cocoa, static,
|
||||
# monolithic, and universal (arm64 + x86_64) so one prefix serves both Rust
|
||||
# targets. Run on a Mac with the Xcode Command Line Tools.
|
||||
#
|
||||
# scripts/build-wx-macos.sh -> ~/.cache/wx-3.3.3-macos
|
||||
#
|
||||
# Dependency tracking is off: its bootstrap fails with several -arch flags.
|
||||
# MACOSX_MIN (default 11.0) is the oldest macOS the app runs on, for both
|
||||
# slices: the libc++ in current SDKs supports nothing older, and macOS 11 is
|
||||
# also where Apple Silicon starts. Image/zlib/regex/expat libraries are
|
||||
# wx's bundled copies, so the app links only against system frameworks.
|
||||
# The repo's vendor tree stays pristine; the build lives in ~/.cache/wxbuild.
|
||||
set -e
|
||||
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
SRC="$REPO/thirdparty/wxwidgets/wxWidgets-3.3.3"
|
||||
BUILD="$HOME/.cache/wxbuild/wxWidgets-3.3.3-macos"
|
||||
PREFIX="${WX_MACOS_PREFIX:-$HOME/.cache/wx-3.3.3-macos}"
|
||||
MACOSX_MIN="${MACOSX_MIN:-11.0}"
|
||||
JOBS="${JOBS:-$(sysctl -n hw.ncpu)}"
|
||||
[ -d "$SRC" ] || { echo "thirdparty wxWidgets tree missing: $SRC" >&2; exit 1; }
|
||||
rm -rf "$BUILD"
|
||||
mkdir -p "$HOME/.cache/wxbuild"
|
||||
cp -R "$SRC" "$BUILD"
|
||||
trap 'rm -rf "$BUILD"' 0
|
||||
chmod +x "$BUILD/configure" "$BUILD/config.guess" "$BUILD/config.sub" "$BUILD/install-sh" 2>/dev/null || true
|
||||
mkdir -p "$BUILD/build-macos"
|
||||
cd "$BUILD/build-macos"
|
||||
sh ../configure --prefix="$PREFIX" --with-osx_cocoa \
|
||||
--disable-shared --enable-monolithic \
|
||||
--enable-universal_binary=arm64,x86_64 \
|
||||
--with-macosx-version-min="$MACOSX_MIN" \
|
||||
--disable-dependency-tracking \
|
||||
--with-libpng=builtin --with-libjpeg=builtin --without-libtiff \
|
||||
--with-zlib=builtin --with-expat=builtin --with-regex=builtin \
|
||||
--without-liblzma --without-libcurl \
|
||||
--with-opengl=no --disable-stc --disable-webview --disable-mediactrl \
|
||||
--disable-tests
|
||||
make -j"$JOBS"
|
||||
make install
|
||||
lib=$(ls "$PREFIX"/lib/libwx_osx_cocoau-3.3*.a | head -1)
|
||||
lipo -info "$lib"
|
||||
echo "installed: $PREFIX ($lib)"
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
Subject: [PATCH 0009] macOS: wxOSX through wx-config, logical sizes, clang runtime
|
||||
|
||||
--- a/build.rs
|
||||
+++ b/build.rs
|
||||
@@ -42,12 +42,12 @@
|
||||
target_os() == "linux"
|
||||
}
|
||||
|
||||
-// alkane-toolkit patch: Linux (wxGTK) and Windows/GNU (wxMSW built with
|
||||
-// mingw-w64, natively or cross from Linux) both build against a wx prefix
|
||||
-// described by its wx-config script, so they share one code path. Upstream's
|
||||
-// MSVC/nmake and macOS download-and-build paths are left as they were.
|
||||
+// alkane-toolkit patch: Linux (wxGTK), macOS (wxOSX/Cocoa, universal static
|
||||
+// build) and Windows/GNU (wxMSW built with mingw-w64, natively or cross from
|
||||
+// Linux) all build against a wx prefix described by its wx-config script, so
|
||||
+// they share one code path. Upstream's MSVC/nmake path is left as it was.
|
||||
fn uses_wx_config() -> bool {
|
||||
- is_linux() || (is_windows() && !is_msvc())
|
||||
+ is_linux() || is_osx() || (is_windows() && !is_msvc())
|
||||
}
|
||||
|
||||
fn is_stub() -> bool {
|
||||
@@ -278,7 +278,14 @@
|
||||
build.cpp(true)
|
||||
.file("cpp_src/wxbridge.cpp")
|
||||
.file("cpp_src/widgets_bridge.cpp");
|
||||
- for f in cxxflags.split_whitespace() {
|
||||
+ let mut flags = cxxflags.split_whitespace();
|
||||
+ while let Some(f) = flags.next() {
|
||||
+ // A universal wx prefix reports `-arch arm64 -arch x86_64`; cargo builds
|
||||
+ // one target at a time and cc adds that target's own -arch.
|
||||
+ if is_osx() && f == "-arch" {
|
||||
+ flags.next();
|
||||
+ continue;
|
||||
+ }
|
||||
build.flag(f);
|
||||
}
|
||||
if is_linux() {
|
||||
@@ -308,7 +315,53 @@
|
||||
}
|
||||
build.compile("wxbridge");
|
||||
|
||||
- for flag in libs.split_whitespace() {
|
||||
+ if is_osx() {
|
||||
+ // wxOSX's Objective-C uses @available, which calls
|
||||
+ // ___isPlatformVersionAtLeast from clang's compiler runtime. clang
|
||||
+ // links that runtime itself, but rustc drives the link without it.
|
||||
+ let resource_dir = Command::new("clang")
|
||||
+ .arg("-print-resource-dir")
|
||||
+ .output()
|
||||
+ .ok()
|
||||
+ .filter(|o| o.status.success())
|
||||
+ .and_then(|o| String::from_utf8(o.stdout).ok())
|
||||
+ .map(|s| s.trim().to_string())
|
||||
+ .ok_or("wx-rs: cannot ask clang for its resource directory")?;
|
||||
+ let rt = Path::new(&resource_dir).join("lib").join("darwin");
|
||||
+ if !rt.join("libclang_rt.osx.a").exists() {
|
||||
+ return Err(format!("wx-rs: no libclang_rt.osx.a in {}", rt.display()).into());
|
||||
+ }
|
||||
+ println!("cargo:rustc-link-search=native={}", rt.display());
|
||||
+ println!("cargo:rustc-link-lib=static=clang_rt.osx");
|
||||
+ }
|
||||
+
|
||||
+ let mut lib_flags = libs.split_whitespace();
|
||||
+ while let Some(flag) = lib_flags.next() {
|
||||
+ if is_osx() {
|
||||
+ match flag {
|
||||
+ "-arch" => {
|
||||
+ lib_flags.next();
|
||||
+ continue;
|
||||
+ }
|
||||
+ "-framework" => {
|
||||
+ if let Some(name) = lib_flags.next() {
|
||||
+ println!("cargo:rustc-link-lib=framework={}", name);
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+ "-weak_framework" => {
|
||||
+ if let Some(name) = lib_flags.next() {
|
||||
+ println!("cargo:rustc-link-arg=-Wl,-weak_framework,{}", name);
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+ _ if flag.starts_with("-Wl,") => {
|
||||
+ println!("cargo:rustc-link-arg={}", flag);
|
||||
+ continue;
|
||||
+ }
|
||||
+ _ => {}
|
||||
+ }
|
||||
+ }
|
||||
if flag.ends_with(".a") && Path::new(flag).is_absolute() {
|
||||
// static wx builds: wx-config emits the archive as a full path
|
||||
let file = Path::new(flag).file_name().and_then(|f| f.to_str()).unwrap_or(flag);
|
||||
--- a/cpp_src/wxbridge.cpp
|
||||
+++ b/cpp_src/wxbridge.cpp
|
||||
@@ -492,21 +492,12 @@
|
||||
|
||||
// The logical window size
|
||||
Size get_client_size() {
|
||||
-#ifdef __APPLE__
|
||||
- int status_bar_height;
|
||||
- if (wxGetApp().frame->GetStatusBar()) {
|
||||
- status_bar_height = wxGetApp().frame->GetStatusBar()->GetRect().height;
|
||||
- } else {
|
||||
- status_bar_height = 0;
|
||||
- }
|
||||
- float scale_factor = wxGetApp().frame->GetDPIScaleFactor();
|
||||
- wxSize s = wxGetApp().frame->GetClientSize();
|
||||
- struct Size sz = {s.x * scale_factor, (s.y + status_bar_height) * scale_factor};
|
||||
- return sz;
|
||||
-#elif defined(__linux__)
|
||||
- // alkane-toolkit patch: wxGTK3 path (upstream only knew Apple vs Windows)
|
||||
+#if defined(__linux__) || defined(__APPLE__)
|
||||
+ // alkane-toolkit patch: wxGTK3 and wxOSX both report logical (DIP) sizes,
|
||||
+ // like every other bridge size. Upstream's Apple branch scaled to physical
|
||||
+ // pixels through a float -> int narrowing current clang rejects.
|
||||
wxSize s = wxGetApp().frame->GetClientSize();
|
||||
- return Size {(unsigned int)s.x, (unsigned int)s.y};
|
||||
+ return Size {s.x, s.y};
|
||||
#else
|
||||
HWND hwnd = (HWND) wxGetApp().frame->GetHandle();
|
||||
RECT rect;
|
||||
@@ -559,15 +550,10 @@
|
||||
}
|
||||
|
||||
Size get_mouse_position(wxMouseEvent &event) {
|
||||
-#ifdef __APPLE__
|
||||
- wxPoint p = event.GetPosition();
|
||||
- float scale_factor = wxGetApp().frame->GetDPIScaleFactor();
|
||||
- struct Size s = {p.x * scale_factor, p.y * scale_factor};
|
||||
- return s;
|
||||
-#else
|
||||
+ // alkane-toolkit patch: logical (DIP) coordinates on every platform,
|
||||
+ // matching get_client_size (upstream scaled them on Apple).
|
||||
wxPoint p = event.GetPosition();
|
||||
return Size {p.x, p.y};
|
||||
-#endif
|
||||
}
|
||||
|
||||
int get_mouse_wheel_rotation(wxMouseEvent &event) {
|
||||
Vendored
+1
@@ -27,6 +27,7 @@ later changes go in new patches.
|
||||
| 0006 | Build: platform from the target, not the host; Windows/GNU via `wx-config` |
|
||||
| 0007 | `wxbridge.cpp` on wxMSW: no input-swallowing overlay, appearance before the first window, work-area sizing, executable icon, UTF-8 menu fix |
|
||||
| 0008 | Widget bridge on wxMSW: generic data-view input and tooltips, DIP boundary, anti-aliased shapes, themed selection colours |
|
||||
| 0009 | macOS: wxOSX (universal static) through `wx-config`, logical sizes on Apple, clang compiler runtime for `@available` |
|
||||
|
||||
History: the round 19 health-tooltip fix (GTK tip area converted from
|
||||
bin-window to widget coordinates) used to be a separate patch on top of an
|
||||
|
||||
+60
-7
@@ -42,12 +42,12 @@ fn is_linux() -> bool {
|
||||
target_os() == "linux"
|
||||
}
|
||||
|
||||
// alkane-toolkit patch: Linux (wxGTK) and Windows/GNU (wxMSW built with
|
||||
// mingw-w64, natively or cross from Linux) both build against a wx prefix
|
||||
// described by its wx-config script, so they share one code path. Upstream's
|
||||
// MSVC/nmake and macOS download-and-build paths are left as they were.
|
||||
// alkane-toolkit patch: Linux (wxGTK), macOS (wxOSX/Cocoa, universal static
|
||||
// build) and Windows/GNU (wxMSW built with mingw-w64, natively or cross from
|
||||
// Linux) all build against a wx prefix described by its wx-config script, so
|
||||
// they share one code path. Upstream's MSVC/nmake path is left as it was.
|
||||
fn uses_wx_config() -> bool {
|
||||
is_linux() || (is_windows() && !is_msvc())
|
||||
is_linux() || is_osx() || (is_windows() && !is_msvc())
|
||||
}
|
||||
|
||||
fn is_stub() -> bool {
|
||||
@@ -278,7 +278,14 @@ fn build_with_wx_config() -> Result<(), Box<dyn Error>> {
|
||||
build.cpp(true)
|
||||
.file("cpp_src/wxbridge.cpp")
|
||||
.file("cpp_src/widgets_bridge.cpp");
|
||||
for f in cxxflags.split_whitespace() {
|
||||
let mut flags = cxxflags.split_whitespace();
|
||||
while let Some(f) = flags.next() {
|
||||
// A universal wx prefix reports `-arch arm64 -arch x86_64`; cargo builds
|
||||
// one target at a time and cc adds that target's own -arch.
|
||||
if is_osx() && f == "-arch" {
|
||||
flags.next();
|
||||
continue;
|
||||
}
|
||||
build.flag(f);
|
||||
}
|
||||
if is_linux() {
|
||||
@@ -308,7 +315,53 @@ fn build_with_wx_config() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
build.compile("wxbridge");
|
||||
|
||||
for flag in libs.split_whitespace() {
|
||||
if is_osx() {
|
||||
// wxOSX's Objective-C uses @available, which calls
|
||||
// ___isPlatformVersionAtLeast from clang's compiler runtime. clang
|
||||
// links that runtime itself, but rustc drives the link without it.
|
||||
let resource_dir = Command::new("clang")
|
||||
.arg("-print-resource-dir")
|
||||
.output()
|
||||
.ok()
|
||||
.filter(|o| o.status.success())
|
||||
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||
.map(|s| s.trim().to_string())
|
||||
.ok_or("wx-rs: cannot ask clang for its resource directory")?;
|
||||
let rt = Path::new(&resource_dir).join("lib").join("darwin");
|
||||
if !rt.join("libclang_rt.osx.a").exists() {
|
||||
return Err(format!("wx-rs: no libclang_rt.osx.a in {}", rt.display()).into());
|
||||
}
|
||||
println!("cargo:rustc-link-search=native={}", rt.display());
|
||||
println!("cargo:rustc-link-lib=static=clang_rt.osx");
|
||||
}
|
||||
|
||||
let mut lib_flags = libs.split_whitespace();
|
||||
while let Some(flag) = lib_flags.next() {
|
||||
if is_osx() {
|
||||
match flag {
|
||||
"-arch" => {
|
||||
lib_flags.next();
|
||||
continue;
|
||||
}
|
||||
"-framework" => {
|
||||
if let Some(name) = lib_flags.next() {
|
||||
println!("cargo:rustc-link-lib=framework={}", name);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
"-weak_framework" => {
|
||||
if let Some(name) = lib_flags.next() {
|
||||
println!("cargo:rustc-link-arg=-Wl,-weak_framework,{}", name);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
_ if flag.starts_with("-Wl,") => {
|
||||
println!("cargo:rustc-link-arg={}", flag);
|
||||
continue;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if flag.ends_with(".a") && Path::new(flag).is_absolute() {
|
||||
// static wx builds: wx-config emits the archive as a full path
|
||||
let file = Path::new(flag).file_name().and_then(|f| f.to_str()).unwrap_or(flag);
|
||||
|
||||
+7
-21
@@ -492,21 +492,12 @@ extern "C" {
|
||||
|
||||
// The logical window size
|
||||
Size get_client_size() {
|
||||
#ifdef __APPLE__
|
||||
int status_bar_height;
|
||||
if (wxGetApp().frame->GetStatusBar()) {
|
||||
status_bar_height = wxGetApp().frame->GetStatusBar()->GetRect().height;
|
||||
} else {
|
||||
status_bar_height = 0;
|
||||
}
|
||||
float scale_factor = wxGetApp().frame->GetDPIScaleFactor();
|
||||
wxSize s = wxGetApp().frame->GetClientSize();
|
||||
struct Size sz = {s.x * scale_factor, (s.y + status_bar_height) * scale_factor};
|
||||
return sz;
|
||||
#elif defined(__linux__)
|
||||
// alkane-toolkit patch: wxGTK3 path (upstream only knew Apple vs Windows)
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
// alkane-toolkit patch: wxGTK3 and wxOSX both report logical (DIP) sizes,
|
||||
// like every other bridge size. Upstream's Apple branch scaled to physical
|
||||
// pixels through a float -> int narrowing current clang rejects.
|
||||
wxSize s = wxGetApp().frame->GetClientSize();
|
||||
return Size {(unsigned int)s.x, (unsigned int)s.y};
|
||||
return Size {s.x, s.y};
|
||||
#else
|
||||
HWND hwnd = (HWND) wxGetApp().frame->GetHandle();
|
||||
RECT rect;
|
||||
@@ -559,15 +550,10 @@ extern "C" {
|
||||
}
|
||||
|
||||
Size get_mouse_position(wxMouseEvent &event) {
|
||||
#ifdef __APPLE__
|
||||
wxPoint p = event.GetPosition();
|
||||
float scale_factor = wxGetApp().frame->GetDPIScaleFactor();
|
||||
struct Size s = {p.x * scale_factor, p.y * scale_factor};
|
||||
return s;
|
||||
#else
|
||||
// alkane-toolkit patch: logical (DIP) coordinates on every platform,
|
||||
// matching get_client_size (upstream scaled them on Apple).
|
||||
wxPoint p = event.GetPosition();
|
||||
return Size {p.x, p.y};
|
||||
#endif
|
||||
}
|
||||
|
||||
int get_mouse_wheel_rotation(wxMouseEvent &event) {
|
||||
|
||||
Reference in New Issue
Block a user