-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add -o flag support to flash command #4937
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
The tinygo flash command currently doesn't support the -o flag to save the built binary to a specified output file, while the tinygo build command does. This inconsistency makes it inconvenient when users want to both flash a device and save the binary file for later use or distribution.
Current Behavior
tinygo build -o firmware.hex -target arduino main.go # Works - saves to firmware.hex
tinygo flash -o firmware.hex -target arduino main.go # Doesn't work - error message to stop.Expected Behavior
tinygo flash -o firmware.hex -target arduino main.go # Should flash device AND save to firmware.hexProposed Implementation
I believe there are two possible approaches:
Approach 1: Minimal Change (Immediate Solution)
- Modify
Flashfunction to copy the built binary to the specified output path after successful build - Pass
outpathas an additional parameter to the Flash function - Pros: Minimal risk, easy to review, maintains backward compatibility
- Cons: Duplicates output logic between
buildandflashcommands, inconsistent parameter handling
Approach 2: Refactor Build Function (Better Long-term Solution)
- Modify
Buildfunction inmain.goto usecompileopts.Optionsinstead of separateoutpathparameter - This would unify the output handling logic between
buildandflashcommands - Pros: Cleaner architecture, consistent design, eliminates code duplication
- Cons: Larger change, requires more careful testing
Personal Preference: I lean toward Approach 2 (refactoring the Build function) as it creates a more consistent and maintainable codebase. However, I understand that Approach 1 might be preferred for minimizing change scope.
Would appreciate feedback on which approach the maintainers prefer before submitting a pull request.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request