Skip to content
Merged
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
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ $(MPY_DIR):

.PHONY: firmware
firmware: $(MPY_DIR) ## Build MicroPython firmware with current drivers
@set -e
@if [ ! -f "$(MPY_DIR)/lib/micropython-lib/README.md" ]; then \
echo "Initializing submodules for $(BOARD)..."; \
cd $(CURDIR)/$(MPY_DIR)/ports/stm32 && $(MAKE) BOARD=$(BOARD) submodules; \
fi
Comment on lines +102 to +105
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

Because this Makefile sets .ONESHELL, cd $(CURDIR)/$(MPY_DIR)/ports/stm32 && $(MAKE) ... will change the working directory for the remainder of the firmware recipe, which can cause surprising behavior if any later commands start using relative paths. To avoid shell state leakage, consider using $(MAKE) -C $(CURDIR)/$(MPY_DIR)/ports/stm32 BOARD=$(BOARD) submodules (and similarly for other cd ... && $(MAKE) calls), and use $(CURDIR)/$(MPY_DIR)/... in the -f check for consistency with the rest of this target.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid point about cd leaking in .ONESHELL. However, cd ... && $(MAKE) is the pattern used throughout the Makefile (lines 97, 109, 118, 124). Changing only this occurrence would be inconsistent. The set -e added in this PR mitigates the risk: if the cd or $(MAKE) fails, the recipe stops immediately. A global refactor to $(MAKE) -C would be a good follow-up but is out of scope here.

@echo "Linking local drivers..."
rm -rf $(CURDIR)/$(MPY_DIR)/lib/micropython-steami-lib
ln -s $(CURDIR) $(CURDIR)/$(MPY_DIR)/lib/micropython-steami-lib
Expand All @@ -107,6 +112,7 @@ firmware: $(MPY_DIR) ## Build MicroPython firmware with current drivers

.PHONY: firmware-update
firmware-update: $(MPY_DIR) ## Update the MicroPython clone and board-specific submodules
@set -e
@echo "Updating micropython-steami..."
rm -rf $(CURDIR)/$(MPY_DIR)/lib/micropython-steami-lib
cd $(CURDIR)/$(MPY_DIR) && git fetch origin && git checkout $(MICROPYTHON_BRANCH) && git checkout -- lib/micropython-steami-lib && git pull --ff-only
Expand Down
Loading