main: add target JSON file in tinygo info output

It looks like this on my system, for example:

    {
      "target": {
        "llvm-target": "aarch64-unknown-linux",
        "cpu": "generic",
        "features": "+neon",
        "goos": "linux",
        "goarch": "arm64",
        "build-tags": [
          "linux",
          "arm64"
        ],
        "gc": "precise",
        "scheduler": "tasks",
        "linker": "ld.lld",
        "rtlib": "compiler-rt",
        "libc": "musl",
        "default-stack-size": 65536,
        "ldflags": [
          "--gc-sections"
        ],
        "extra-files": [
          "src/runtime/asm_arm64.S",
          "src/internal/task/task_stack_arm64.S"
        ],
        "gdb": [
          "gdb"
        ],
        "flash-1200-bps-reset": "false"
      },
      "goroot": "/home/ayke/.cache/tinygo/goroot-23c311bcaa05f188affa3c42310aba343acc82562d5e5f04dea9d5b79ac35f7e",
      "goos": "linux",
      "goarch": "arm64",
      "goarm": "6",
      ...
    }

This can be very useful while working on the automatically generated
target object for example (in my case, GOOS=wasip1).
Этот коммит содержится в:
Ayke van Laethem 2023-08-11 16:02:04 +02:00 коммит произвёл Ron Evans
родитель bfe9ee378f
коммит 9037bf8bf0
2 изменённых файлов: 49 добавлений и 47 удалений

Просмотреть файл

@ -23,45 +23,45 @@ import (
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html // https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html
// https://github.com/shepmaster/rust-arduino-blink-led-no-core-with-cargo/blob/master/blink/arduino.json // https://github.com/shepmaster/rust-arduino-blink-led-no-core-with-cargo/blob/master/blink/arduino.json
type TargetSpec struct { type TargetSpec struct {
Inherits []string `json:"inherits"` Inherits []string `json:"inherits,omitempty"`
Triple string `json:"llvm-target"` Triple string `json:"llvm-target,omitempty"`
CPU string `json:"cpu"` CPU string `json:"cpu,omitempty"`
ABI string `json:"target-abi"` // rougly equivalent to -mabi= flag ABI string `json:"target-abi,omitempty"` // rougly equivalent to -mabi= flag
Features string `json:"features"` Features string `json:"features,omitempty"`
GOOS string `json:"goos"` GOOS string `json:"goos,omitempty"`
GOARCH string `json:"goarch"` GOARCH string `json:"goarch,omitempty"`
BuildTags []string `json:"build-tags"` BuildTags []string `json:"build-tags,omitempty"`
GC string `json:"gc"` GC string `json:"gc,omitempty"`
Scheduler string `json:"scheduler"` Scheduler string `json:"scheduler,omitempty"`
Serial string `json:"serial"` // which serial output to use (uart, usb, none) Serial string `json:"serial,omitempty"` // which serial output to use (uart, usb, none)
Linker string `json:"linker"` Linker string `json:"linker,omitempty"`
RTLib string `json:"rtlib"` // compiler runtime library (libgcc, compiler-rt) RTLib string `json:"rtlib,omitempty"` // compiler runtime library (libgcc, compiler-rt)
Libc string `json:"libc"` Libc string `json:"libc,omitempty"`
AutoStackSize *bool `json:"automatic-stack-size"` // Determine stack size automatically at compile time. AutoStackSize *bool `json:"automatic-stack-size,omitempty"` // Determine stack size automatically at compile time.
DefaultStackSize uint64 `json:"default-stack-size"` // Default stack size if the size couldn't be determined at compile time. DefaultStackSize uint64 `json:"default-stack-size,omitempty"` // Default stack size if the size couldn't be determined at compile time.
CFlags []string `json:"cflags"` CFlags []string `json:"cflags,omitempty"`
LDFlags []string `json:"ldflags"` LDFlags []string `json:"ldflags,omitempty"`
LinkerScript string `json:"linkerscript"` LinkerScript string `json:"linkerscript,omitempty"`
ExtraFiles []string `json:"extra-files"` ExtraFiles []string `json:"extra-files,omitempty"`
RP2040BootPatch *bool `json:"rp2040-boot-patch"` // Patch RP2040 2nd stage bootloader checksum RP2040BootPatch *bool `json:"rp2040-boot-patch,omitempty"` // Patch RP2040 2nd stage bootloader checksum
Emulator string `json:"emulator"` Emulator string `json:"emulator,omitempty"`
FlashCommand string `json:"flash-command"` FlashCommand string `json:"flash-command,omitempty"`
GDB []string `json:"gdb"` GDB []string `json:"gdb,omitempty"`
PortReset string `json:"flash-1200-bps-reset"` PortReset string `json:"flash-1200-bps-reset,omitempty"`
SerialPort []string `json:"serial-port"` // serial port IDs in the form "vid:pid" SerialPort []string `json:"serial-port,omitempty"` // serial port IDs in the form "vid:pid"
FlashMethod string `json:"flash-method"` FlashMethod string `json:"flash-method,omitempty"`
FlashVolume []string `json:"msd-volume-name"` FlashVolume []string `json:"msd-volume-name,omitempty"`
FlashFilename string `json:"msd-firmware-name"` FlashFilename string `json:"msd-firmware-name,omitempty"`
UF2FamilyID string `json:"uf2-family-id"` UF2FamilyID string `json:"uf2-family-id,omitempty"`
BinaryFormat string `json:"binary-format"` BinaryFormat string `json:"binary-format,omitempty"`
OpenOCDInterface string `json:"openocd-interface"` OpenOCDInterface string `json:"openocd-interface,omitempty"`
OpenOCDTarget string `json:"openocd-target"` OpenOCDTarget string `json:"openocd-target,omitempty"`
OpenOCDTransport string `json:"openocd-transport"` OpenOCDTransport string `json:"openocd-transport,omitempty"`
OpenOCDCommands []string `json:"openocd-commands"` OpenOCDCommands []string `json:"openocd-commands,omitempty"`
OpenOCDVerify *bool `json:"openocd-verify"` // enable verify when flashing with openocd OpenOCDVerify *bool `json:"openocd-verify,omitempty"` // enable verify when flashing with openocd
JLinkDevice string `json:"jlink-device"` JLinkDevice string `json:"jlink-device,omitempty"`
CodeModel string `json:"code-model"` CodeModel string `json:"code-model,omitempty"`
RelocationModel string `json:"relocation-model"` RelocationModel string `json:"relocation-model,omitempty"`
} }
// overrideProperties overrides all properties that are set in child into itself using reflection. // overrideProperties overrides all properties that are set in child into itself using reflection.

Просмотреть файл

@ -1796,6 +1796,7 @@ func main() {
} }
if flagJSON { if flagJSON {
json, _ := json.MarshalIndent(struct { json, _ := json.MarshalIndent(struct {
Target *compileopts.TargetSpec `json:"target"`
GOROOT string `json:"goroot"` GOROOT string `json:"goroot"`
GOOS string `json:"goos"` GOOS string `json:"goos"`
GOARCH string `json:"goarch"` GOARCH string `json:"goarch"`
@ -1805,6 +1806,7 @@ func main() {
Scheduler string `json:"scheduler"` Scheduler string `json:"scheduler"`
LLVMTriple string `json:"llvm_triple"` LLVMTriple string `json:"llvm_triple"`
}{ }{
Target: config.Target,
GOROOT: cachedGOROOT, GOROOT: cachedGOROOT,
GOOS: config.GOOS(), GOOS: config.GOOS(),
GOARCH: config.GOARCH(), GOARCH: config.GOARCH(),