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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ zephyr-setup: fprime-venv ## Set up Zephyr environment

.PHONY: pre-commit-install
pre-commit-install: uv ## Install pre-commit hooks
@$(UVX) pre-commit install > /dev/null
@$(UVX_PINNED) pre-commit install > /dev/null

.PHONY: fmt
fmt: pre-commit-install ## Lint and format files
@$(UVX) pre-commit run --all-files
@$(UVX_PINNED) pre-commit run --all-files

.PHONY: data-budget
data-budget: fprime-venv ## Analyze telemetry data budget (use VERBOSE=1 for detailed output)
Expand Down
9 changes: 9 additions & 0 deletions makelib/build-tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ $(TOOLS_DIR):
### Tool Versions
UV_VERSION ?= 0.8.13

### Python version used for tooling environments. Single source of truth is .python-version, so
### that tools do not silently build against whichever interpreter happens to be on the machine.
PYTHON_VERSION ?= $(shell cat .python-version)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/sh
set -eu

make -n PYTHON_VERSION=3.11 fmt | grep -F -- '--python 3.11'
make -n UVX_PINNED=uvx fmt | grep -F -- 'uvx pre-commit'

Repository: Open-Source-Space-Foundation/proves-core-reference

Length of output: 226


🏁 Script executed:

#!/bin/bash
set -eu

printf 'Python version file:\n'
cat -n .python-version 2>/dev/null || true

printf '\nRelevant build-tools.mk section:\n'
sed -n '1,120p' makelib/build-tools.mk 2>/dev/null || true

printf '\nUsages of PYTHON_VERSION/UVX_PINNED:\n'
rg -n 'PYTHON_VERSION|UVX_PINNED|pre-commit|uvx' -S . --glob '!**/.git/**' || true

Repository: Open-Source-Space-Foundation/proves-core-reference

Length of output: 2592


🌐 Web query:

GNU Make conditional assignment ?= environment variable command line override variable documentation

💡 Result:

In GNU Make, the ?= operator is a conditional variable assignment operator that assigns a value to a variable only if that variable is not yet defined [1][2]. Behavior and Precedence The ?= operator is functionally equivalent to [1]: ifeq ($(origin VARIABLE), undefined) VARIABLE = value endif Because it only acts when a variable is undefined, its behavior regarding environment variables and command-line arguments is dictated by the variable's state upon reaching the assignment [1][3]: 1. Command-Line Arguments: If you provide a variable assignment on the command line (e.g., make VAR=foo), that variable is considered defined before the makefile is parsed [3][4]. Consequently, any VAR ?= bar assignment in the makefile will be ignored, and the command-line value will persist [2][3]. 2. Environment Variables: By default, GNU Make imports environment variables as defined variables [5][6]. If a variable exists in the environment, VAR ?= bar will see that the variable is already defined and will not perform the assignment [3]. 3. Override Directive: If you must force a value in the makefile even when a command-line argument or environment variable is present, you can use the override directive (e.g., override VAR?= bar) [7][4]. Key Considerations * Defined vs. Empty: A variable set to an empty value (e.g., VAR=) is still considered defined [1][2]. In this case, VAR ?= bar will not assign "bar" because the variable is already defined, even though it is empty [1][2]. * Environment Overrides (-e): If you run make with the -e (--environment-overrides) flag, environment variables take precedence over ordinary assignments in the makefile [5][6]. However, even with -e, command-line arguments typically retain higher priority [3]. For most use cases, ?= is the standard way to provide default values that users can easily override via the command line or environment [2].

Citations:


Keep .python-version authoritative for tooling.

PYTHON_VERSION ?= and UVX_PINNED ?= let command-line or environment values bypass the intended pin. Set these with non-overridable assignments if .python-version must control pre-commit tooling; otherwise document that overrides intentionally bypass it.

🤖 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 `@makelib/build-tools.mk` at line 15, Update the PYTHON_VERSION assignment in
the build-tools configuration to use a non-overridable assignment so
.python-version remains authoritative for pre-commit tooling; apply the same
policy to the related UVX_PINNED setting if present in the diff, or explicitly
document intentional overrides.


### uv & uvx
UV_DIR ?= $(TOOLS_DIR)/uv-$(UV_VERSION)
UV ?= $(UV_DIR)/uv
UVX ?= $(UV_DIR)/uvx
### Pin the interpreter for uvx-run tooling. pre-commit builds its hook environments with whatever
### Python runs it, so without this a machine defaulting to an older interpreter builds hook
### environments that cannot parse project sources written for .python-version. uv downloads the
### pinned interpreter if it is missing.
UVX_PINNED ?= $(UVX) --python $(PYTHON_VERSION)
.PHONY: uv
uv: $(UV) ## Download uv
$(UV): $(TOOLS_DIR)
Expand Down
Loading