Skip to content

compile --show-properties now correctly output the result in text and JSON format #2035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 17, 2023

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Jan 17, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)

What kind of change does this PR introduce?

compile --show-properties now correctly output the result in text and JSON format.

What is the current behavior?

The properties are mixed with the build recap:

$ arduino-cli compile -b arduino:avr:uno --show-properties -v
Utilizzo della scheda 'uno' dalla piattaforma nella cartella: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6
Utilizzo del core 'arduino' dalla piattaforma nella cartella: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6
_id=uno
archive_file_path={build.path}/{archive_file}
bootloader.extended_fuses=0xFD
bootloader.file=optiboot/optiboot_atmega328.hex
[.......CUT......]
vid.1=0x2341
vid.2=0x2A03
vid.3=0x2341
vid.4=0x2341

Piattaforma utilizzata Versione Percorso                                                    
arduino:avr            1.8.6    /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6

A crash occurs if wrong FQBN is set:

$ arduino-cli compile -b arduino:avr:unoa --show-properties -v
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xc0a47c]

goroutine 1 [running]:
github.com/arduino/arduino-cli/commands/compile.Compile({0x16edb40?, 0x0?}, 0xc0000c06e0, {0x10f36c0?, 0xc0000132d8}, {0x10f36c0?, 0xc0000132f0}, 0x0)
	/home/megabug/Workspace/arduino-cli/commands/compile/compile.go:192 +0x17bc
github.com/arduino/arduino-cli/internal/cli/compile.runCompileCommand(0xc00038d400?, {0xc00024ddc0, 0x0, 0x4?})
	/home/megabug/Workspace/arduino-cli/internal/cli/compile/compile.go:216 +0x989
github.com/spf13/cobra.(*Command).execute(0xc00038d400, {0xc00024dd80, 0x4, 0x4})
	/home/megabug/Software/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xc00028db80)
	/home/megabug/Software/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	/home/megabug/Software/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
	/home/megabug/Workspace/arduino-cli/main.go:31 +0x77

JSON output is mixed with build properties:

$ arduino-cli compile -b arduino:avr:uno --show-properties --format json -v
_id=uno
archive_file_path={build.path}/{archive_file}
bootloader.extended_fuses=0xFD
bootloader.file=optiboot/optiboot_atmega328.hex
bootloader.high_fuses=0xDE
[.......CUT.......]
vid.1=0x2341
vid.2=0x2A03
vid.3=0x2341
vid.4=0x2341
{
  "compiler_out": "Utilizzo della scheda 'uno' dalla piattaforma nella cartella: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6\nUtilizzo del core 'arduino' dalla piattaforma nella cartella: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6\n",
  "compiler_err": "",
  "builder_result": {
    "build_path": "/tmp/arduino/sketch-002050EAA7EFB9A4FC451CDFBC0FA2D3",
    "board_platform": {
      "id": "arduino:avr",
      "version": "1.8.6",
      "install_dir": "/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6"
    },
    "build_platform": {
      "id": "arduino:avr",
      "version": "1.8.6",
      "install_dir": "/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6"
    }
  },
  "success": true
}

What is the new behavior?

$ arduino-cli compile -b arduino:avr:uno --show-properties -v
_id=uno
archive_file_path={build.path}/{archive_file}
bootloader.extended_fuses=0xFD
bootloader.file=optiboot/optiboot_atmega328.hex
bootloader.high_fuses=0xDE
bootloader.lock_bits=0x0F
bootloader.low_fuses=0xFF
...
$ arduino-cli compile -b arduino:avr:unoa --show-properties -v
Si è verificato un errore durante la compilazione: Si è verificato un errore durante la risoluzione di FQBN: la scheda arduino:avr:unoa non è stata trovata

$ arduino-cli compile -b arduino:avr:unoa --show-properties -v --format json
{
  "compiler_out": "",
  "compiler_err": "",
  "builder_result": {
    "build_path": "/tmp/arduino/sketch-002050EAA7EFB9A4FC451CDFBC0FA2D3"
  },
  "success": false,
  "error": "Si è verificato un errore durante la compilazione: Si è verificato un errore durante la risoluzione di FQBN: la scheda arduino:avr:unoa non è stata trovata"
}

$ arduino-cli compile -b arduino:avr:uno --show-properties --format json -v
{
  "compiler_out": "Utilizzo della scheda 'uno' dalla piattaforma nella cartella: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6\nUtilizzo del core 'arduino' dalla piattaforma nella cartella: /home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6\n",
  "compiler_err": "",
  "builder_result": {
    "build_path": "/tmp/arduino/sketch-002050EAA7EFB9A4FC451CDFBC0FA2D3",
    "board_platform": {
      "id": "arduino:avr",
      "version": "1.8.6",
      "install_dir": "/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6"
    },
    "build_platform": {
      "id": "arduino:avr",
      "version": "1.8.6",
      "install_dir": "/home/megabug/.arduino15/packages/arduino/hardware/avr/1.8.6"
    },
    "build_properties": [
      "_id=uno",
      "archive_file_path={build.path}/{archive_file}",
      "bootloader.extended_fuses=0xFD",
      "bootloader.file=optiboot/optiboot_atmega328.hex",
[.........CUT.........]
      "vid.1=0x2341",
      "vid.2=0x2A03",
      "vid.3=0x2341",
      "vid.4=0x2341"
    ]
  },
  "success": true
}

Does this PR introduce a breaking change, and is titled accordingly?

No breaking changes

@cmaglie cmaglie self-assigned this Jan 17, 2023
@cmaglie cmaglie added priority: high Resolution is a high priority type: imperfection Perceived defect in any part of project criticality: low Of low impact topic: CLI Related to the command line interface topic: gRPC Related to the gRPC interface labels Jan 17, 2023
@codecov
Copy link

codecov bot commented Jan 17, 2023

Codecov Report

Base: 36.57% // Head: 36.56% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (67eec02) compared to base (b3e8f8a).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2035      +/-   ##
==========================================
- Coverage   36.57%   36.56%   -0.01%     
==========================================
  Files         230      229       -1     
  Lines       19353    19366      +13     
==========================================
+ Hits         7079     7082       +3     
- Misses      11439    11450      +11     
+ Partials      835      834       -1     
Flag Coverage Δ
unit 36.56% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
commands/compile/compile.go 0.00% <0.00%> (ø)
internal/cli/compile/compile.go 0.00% <0.00%> (ø)
internal/cli/feedback/stdio.go 28.12% <0.00%> (-9.38%) ⬇️
legacy/builder/builder.go 81.15% <0.00%> (+3.38%) ⬆️
arduino/cores/packagemanager/package_manager.go 66.58% <0.00%> (+0.75%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@cmaglie cmaglie marked this pull request as ready for review January 17, 2023 13:26
@cmaglie cmaglie merged commit 271d241 into arduino:master Jan 17, 2023
@cmaglie cmaglie deleted the feedback_improvement branch January 17, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
criticality: low Of low impact priority: high Resolution is a high priority topic: CLI Related to the command line interface topic: gRPC Related to the gRPC interface type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

arduino-cli compile does not output correctly when using --show-properties and --format json
2 participants