Skip to content

Commit 9037bf8

Browse files
aykevldeadprogram
authored andcommitted
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).
1 parent bfe9ee3 commit 9037bf8

File tree

2 files changed

+49
-47
lines changed

2 files changed

+49
-47
lines changed

compileopts/target.go

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,45 @@ import (
2323
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html
2424
// https://github.com/shepmaster/rust-arduino-blink-led-no-core-with-cargo/blob/master/blink/arduino.json
2525
type TargetSpec struct {
26-
Inherits []string `json:"inherits"`
27-
Triple string `json:"llvm-target"`
28-
CPU string `json:"cpu"`
29-
ABI string `json:"target-abi"` // rougly equivalent to -mabi= flag
30-
Features string `json:"features"`
31-
GOOS string `json:"goos"`
32-
GOARCH string `json:"goarch"`
33-
BuildTags []string `json:"build-tags"`
34-
GC string `json:"gc"`
35-
Scheduler string `json:"scheduler"`
36-
Serial string `json:"serial"` // which serial output to use (uart, usb, none)
37-
Linker string `json:"linker"`
38-
RTLib string `json:"rtlib"` // compiler runtime library (libgcc, compiler-rt)
39-
Libc string `json:"libc"`
40-
AutoStackSize *bool `json:"automatic-stack-size"` // Determine stack size automatically at compile time.
41-
DefaultStackSize uint64 `json:"default-stack-size"` // Default stack size if the size couldn't be determined at compile time.
42-
CFlags []string `json:"cflags"`
43-
LDFlags []string `json:"ldflags"`
44-
LinkerScript string `json:"linkerscript"`
45-
ExtraFiles []string `json:"extra-files"`
46-
RP2040BootPatch *bool `json:"rp2040-boot-patch"` // Patch RP2040 2nd stage bootloader checksum
47-
Emulator string `json:"emulator"`
48-
FlashCommand string `json:"flash-command"`
49-
GDB []string `json:"gdb"`
50-
PortReset string `json:"flash-1200-bps-reset"`
51-
SerialPort []string `json:"serial-port"` // serial port IDs in the form "vid:pid"
52-
FlashMethod string `json:"flash-method"`
53-
FlashVolume []string `json:"msd-volume-name"`
54-
FlashFilename string `json:"msd-firmware-name"`
55-
UF2FamilyID string `json:"uf2-family-id"`
56-
BinaryFormat string `json:"binary-format"`
57-
OpenOCDInterface string `json:"openocd-interface"`
58-
OpenOCDTarget string `json:"openocd-target"`
59-
OpenOCDTransport string `json:"openocd-transport"`
60-
OpenOCDCommands []string `json:"openocd-commands"`
61-
OpenOCDVerify *bool `json:"openocd-verify"` // enable verify when flashing with openocd
62-
JLinkDevice string `json:"jlink-device"`
63-
CodeModel string `json:"code-model"`
64-
RelocationModel string `json:"relocation-model"`
26+
Inherits []string `json:"inherits,omitempty"`
27+
Triple string `json:"llvm-target,omitempty"`
28+
CPU string `json:"cpu,omitempty"`
29+
ABI string `json:"target-abi,omitempty"` // rougly equivalent to -mabi= flag
30+
Features string `json:"features,omitempty"`
31+
GOOS string `json:"goos,omitempty"`
32+
GOARCH string `json:"goarch,omitempty"`
33+
BuildTags []string `json:"build-tags,omitempty"`
34+
GC string `json:"gc,omitempty"`
35+
Scheduler string `json:"scheduler,omitempty"`
36+
Serial string `json:"serial,omitempty"` // which serial output to use (uart, usb, none)
37+
Linker string `json:"linker,omitempty"`
38+
RTLib string `json:"rtlib,omitempty"` // compiler runtime library (libgcc, compiler-rt)
39+
Libc string `json:"libc,omitempty"`
40+
AutoStackSize *bool `json:"automatic-stack-size,omitempty"` // Determine stack size automatically at compile time.
41+
DefaultStackSize uint64 `json:"default-stack-size,omitempty"` // Default stack size if the size couldn't be determined at compile time.
42+
CFlags []string `json:"cflags,omitempty"`
43+
LDFlags []string `json:"ldflags,omitempty"`
44+
LinkerScript string `json:"linkerscript,omitempty"`
45+
ExtraFiles []string `json:"extra-files,omitempty"`
46+
RP2040BootPatch *bool `json:"rp2040-boot-patch,omitempty"` // Patch RP2040 2nd stage bootloader checksum
47+
Emulator string `json:"emulator,omitempty"`
48+
FlashCommand string `json:"flash-command,omitempty"`
49+
GDB []string `json:"gdb,omitempty"`
50+
PortReset string `json:"flash-1200-bps-reset,omitempty"`
51+
SerialPort []string `json:"serial-port,omitempty"` // serial port IDs in the form "vid:pid"
52+
FlashMethod string `json:"flash-method,omitempty"`
53+
FlashVolume []string `json:"msd-volume-name,omitempty"`
54+
FlashFilename string `json:"msd-firmware-name,omitempty"`
55+
UF2FamilyID string `json:"uf2-family-id,omitempty"`
56+
BinaryFormat string `json:"binary-format,omitempty"`
57+
OpenOCDInterface string `json:"openocd-interface,omitempty"`
58+
OpenOCDTarget string `json:"openocd-target,omitempty"`
59+
OpenOCDTransport string `json:"openocd-transport,omitempty"`
60+
OpenOCDCommands []string `json:"openocd-commands,omitempty"`
61+
OpenOCDVerify *bool `json:"openocd-verify,omitempty"` // enable verify when flashing with openocd
62+
JLinkDevice string `json:"jlink-device,omitempty"`
63+
CodeModel string `json:"code-model,omitempty"`
64+
RelocationModel string `json:"relocation-model,omitempty"`
6565
}
6666

6767
// overrideProperties overrides all properties that are set in child into itself using reflection.

main.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,15 +1796,17 @@ func main() {
17961796
}
17971797
if flagJSON {
17981798
json, _ := json.MarshalIndent(struct {
1799-
GOROOT string `json:"goroot"`
1800-
GOOS string `json:"goos"`
1801-
GOARCH string `json:"goarch"`
1802-
GOARM string `json:"goarm"`
1803-
BuildTags []string `json:"build_tags"`
1804-
GC string `json:"garbage_collector"`
1805-
Scheduler string `json:"scheduler"`
1806-
LLVMTriple string `json:"llvm_triple"`
1799+
Target *compileopts.TargetSpec `json:"target"`
1800+
GOROOT string `json:"goroot"`
1801+
GOOS string `json:"goos"`
1802+
GOARCH string `json:"goarch"`
1803+
GOARM string `json:"goarm"`
1804+
BuildTags []string `json:"build_tags"`
1805+
GC string `json:"garbage_collector"`
1806+
Scheduler string `json:"scheduler"`
1807+
LLVMTriple string `json:"llvm_triple"`
18071808
}{
1809+
Target: config.Target,
18081810
GOROOT: cachedGOROOT,
18091811
GOOS: config.GOOS(),
18101812
GOARCH: config.GOARCH(),

0 commit comments

Comments
 (0)