feat: add -file-format flag for flexible output formats

Add support for -file-format flag to llgo build command allowing users to specify output format independently of target configuration.

Changes:
- Add -file-format flag supporting bin, hex, elf, uf2, zip formats
- Implement two-stage conversion: firmware format → file format
- Add ConvertOutput function with hex format conversion support
- Update build logic to handle different modes (build vs run/install)
- Add verbose logging for conversion operations

For build command: only convert firmware when -file-format is specified
For run/install commands: always convert firmware when target requires it

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Li Jie
2025-09-05 13:50:51 +08:00
parent f41badde20
commit e9170e4cef
3 changed files with 145 additions and 4 deletions

View File

@@ -8,9 +8,11 @@ import (
)
var OutputFile string
var FileFormat string
func AddOutputFlags(fs *flag.FlagSet) {
fs.StringVar(&OutputFile, "o", "", "Output file")
fs.StringVar(&FileFormat, "file-format", "", "File format for target output (e.g., bin, hex, elf, uf2, zip)")
}
var Verbose bool
@@ -48,6 +50,7 @@ func UpdateConfig(conf *build.Config) {
switch conf.Mode {
case build.ModeBuild:
conf.OutFile = OutputFile
conf.FileFormat = FileFormat
case build.ModeCmpTest:
conf.GenExpect = Gen
}