Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ docs_summary_check: ## check if there are unlinked documentation files
@echo [DOCS-SUMMARY-MARKDOWN-CHECK]
python3 tools/check_docs_summary.py

python_doc: ## generate trezorctl OPTIONS.rst
make -C python doc

python_doc_check: ## check that trezorctl OPTIONS.rst is up to date
make -C python doc_check
Comment on lines +172 to +176
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check for .PHONY declarations of gen targets

rg -n '\.PHONY.*\b(gen|gen_check|python_doc|python_doc_check)\b' Makefile

Repository: trezor/trezor-firmware

Length of output: 48


🏁 Script executed:

#!/bin/bash
# Check all .PHONY declarations in the Makefile
rg -n '\.PHONY' Makefile -A 1

Repository: trezor/trezor-firmware

Length of output: 48


🏁 Script executed:

#!/bin/bash
# Check if gen and gen_check targets exist
rg -n '^(gen|gen_check|python_doc|python_doc_check):' Makefile -A 2

Repository: trezor/trezor-firmware

Length of output: 750


🏁 Script executed:

#!/bin/bash
# Check if there are any files named gen, gen_check, python_doc, or python_doc_check
fd -e gen -e gen_check -e python_doc -e python_doc_check . 2>/dev/null | head -20

Repository: trezor/trezor-firmware

Length of output: 48


Add .PHONY declarations for targets.

The Makefile currently has no .PHONY declarations. The new python_doc and python_doc_check targets, as well as the existing gen and gen_check targets, are all non-file-producing targets and should be declared as .PHONY to prevent potential conflicts and follow make best practices.

📝 Proposed PHONY declarations
+.PHONY: python_doc python_doc_check gen gen_check
+
 python_doc: ## generate trezorctl OPTIONS.rst
 	make -C python doc
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python_doc: ## generate trezorctl OPTIONS.rst
make -C python doc
python_doc_check: ## check that trezorctl OPTIONS.rst is up to date
make -C python doc_check
.PHONY: python_doc python_doc_check gen gen_check
python_doc: ## generate trezorctl OPTIONS.rst
make -C python doc
python_doc_check: ## check that trezorctl OPTIONS.rst is up to date
make -C python doc_check
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` around lines 172 - 176, Add a .PHONY declaration listing the
non-file targets so make won't treat them as files: declare .PHONY for
python_doc, python_doc_check and also include the existing gen and gen_check
targets (and any other similar meta-targets) by adding a .PHONY line that
references those target names; update the Makefile near existing target
definitions to include ".PHONY: python_doc python_doc_check gen gen_check" so
these commands are always executed regardless of filesystem state.


vendorheader: ## generate vendor header
./core/tools/generate_vendorheader.sh --quiet

Expand Down Expand Up @@ -199,9 +205,9 @@ hsm_keys:
hsm_keys_check:
./core/tools/generate_hsm_keys.py --check

gen: templates mocks icons protobuf vendorheader solana_templates bootloader_hashes lsgen tropic_model_config hsm_keys ## regenerate auto-generated files from sources
gen: templates mocks icons protobuf python_doc vendorheader solana_templates bootloader_hashes lsgen tropic_model_config hsm_keys ## regenerate auto-generated files from sources

gen_check: templates_check mocks_check icons_check protobuf_check vendorheader_check solana_templates_check bootloader_hashes_check lsgen_check tropic_model_config_check hsm_keys_check ## check validity of auto-generated files
gen_check: templates_check mocks_check icons_check protobuf_check python_doc_check vendorheader_check solana_templates_check bootloader_hashes_check lsgen_check tropic_model_config_check hsm_keys_check ## check validity of auto-generated files

uvlock_check: ## check that uv.lock is up to date
@echo [UVLOCK-CHECK]
Expand Down
8 changes: 8 additions & 0 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ dist: doc clean
doc:
$(PYTHON) helper-scripts/make-options-rst.py

doc_check:
@echo [OPTIONS-RST-CHECK]
@set -e; \
tmp=$$(mktemp); \
trap 'rm -f "$$tmp"' EXIT; \
$(PYTHON) helper-scripts/make-options-rst.py --output "$$tmp"; \
diff -u docs/OPTIONS.rst "$$tmp"

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

clean-build: ## remove build artifacts
Expand Down
2 changes: 2 additions & 0 deletions python/docs/OPTIONS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ Miscellaneous debug features.
optiga-set-sec-max Set Optiga's security event counter to maximum.
prodtest-t1 Perform a prodtest on Model One.
record Record screen changes into a specified directory.
set-battery-state Set emulated battery/power state (emulator only).
set-log-filter Set logging filter string.

Device management commands - setup, recover seed, wipe, etc.
Expand Down Expand Up @@ -312,6 +313,7 @@ Evolu commands.
Commands:
get-delegated-identity-key Request the delegated identity key of this device.
get-node Return the SLIP-21 node for Evolu.
index-management Set the optional delegated identity key rotation index if unset.
sign-registration-request Sign a registration request for this device to be registered at...

FIDO2, U2F and WebAuthN management commands.
Expand Down
36 changes: 24 additions & 12 deletions python/helper-scripts/make-options-rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,43 @@
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.

import os
from typing import List
import argparse
from pathlib import Path
from typing import TextIO

import click

from trezorlib.cli import trezorctl

DELIMITER_STR = "### ALL CONTENT BELOW IS GENERATED"
OPTIONS_RST = Path(__file__).resolve().parent / "../docs/OPTIONS.rst"

options_rst = open(os.path.dirname(__file__) + "/../docs/OPTIONS.rst", "r+")
parser = argparse.ArgumentParser()
parser.add_argument(
"--output",
type=Path,
default=OPTIONS_RST,
help="Path to write the generated OPTIONS.rst content.",
)
args = parser.parse_args()

lead_in: List[str] = []
lead_in: list[str] = []

for line in options_rst:
lead_in.append(line)
if DELIMITER_STR in line:
break
with OPTIONS_RST.open() as options_rst:
for line in options_rst:
lead_in.append(line)
if DELIMITER_STR in line:
break

options_rst.seek(0)
options_rst.truncate(0)
output: TextIO
output = args.output.open("w")

for line in lead_in:
options_rst.write(line)
output.write(line)


def _print(s: str = "") -> None:
options_rst.write(s + "\n")
output.write(s + "\n")


def rst_code_block(help_str: str) -> None:
Expand All @@ -68,3 +78,5 @@ def rst_code_block(help_str: str) -> None:
rst_code_block(f"trezorctl {subcommand} --help")
ctx = click.Context(cmd, info_name=f"trezorctl {subcommand}", terminal_width=99)
rst_code_block(cmd.get_help(ctx))

output.close()
4 changes: 4 additions & 0 deletions python/src/trezorlib/cli/evolu.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def index_management(
session: Session,
rotation_index: Optional[int] = None,
) -> str:
"""
Set the optional delegated identity key rotation index if unset.
Use --rotation_index to provide the value; returns the current index as a string.
"""
return str(
evolu.index_management(
session,
Expand Down