main: generate binary files when compiling to .bin

Этот коммит содержится в:
Ayke van Laethem 2018-10-07 22:48:33 +02:00
родитель f0f6a12d19
коммит e50c6f1af1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

13
main.go
Просмотреть файл

@ -146,10 +146,15 @@ func Compile(pkgName, outpath string, spec *TargetSpec, printIR, dumpSSA, debug
}
}
if strings.HasSuffix(outpath, ".hex") {
// Get an Intel .hex file from the .elf file.
tmppath = filepath.Join(dir, "main.hex")
cmd := exec.Command(spec.Objcopy, "-O", "ihex", executable, tmppath)
ext := filepath.Ext(outpath)
if ext == ".hex" || ext == ".bin" {
// Get an Intel .hex file or .bin file from the .elf file.
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.Stderr = os.Stderr
err = cmd.Run()