mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 22:13:39 +00:00
main: generate binary files when compiling to .bin
This commit is contained in:
@@ -146,10 +146,15 @@ func Compile(pkgName, outpath string, spec *TargetSpec, printIR, dumpSSA, debug
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(outpath, ".hex") {
|
ext := filepath.Ext(outpath)
|
||||||
// Get an Intel .hex file from the .elf file.
|
if ext == ".hex" || ext == ".bin" {
|
||||||
tmppath = filepath.Join(dir, "main.hex")
|
// Get an Intel .hex file or .bin file from the .elf file.
|
||||||
cmd := exec.Command(spec.Objcopy, "-O", "ihex", executable, tmppath)
|
tmppath = filepath.Join(dir, "main"+ext)
|
||||||
|
format := map[string]string{
|
||||||
|
".hex": "ihex",
|
||||||
|
".bin": "binary",
|
||||||
|
}[ext]
|
||||||
|
cmd := exec.Command(spec.Objcopy, "-O", format, executable, tmppath)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
|
|||||||
Reference in New Issue
Block a user