Skip to content

Compile json output #1065

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
Nov 18, 2020
Merged

Compile json output #1065

merged 7 commits into from
Nov 18, 2020

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Nov 12, 2020

This PR implements the --format json output in compile command.
This is how a complete result looks like:

$ arduino-cli compile --fqbn arduino:samd:mkr1000 --format json
{
  "compiler_out": "WARNING: library Audio claims to run on sam architecture(s) and may be incompatible with your current board which runs on samd architecture(s).\n",
  "compiler_err": "In file included from /home/cmaglie/Workspace/sketchbook-cores-beta/libraries/Audio/src/Audio.h:16:0,\n                 from /home/cmaglie/Workspace/sketchbook-cores-beta/Prova_Spazio/Prova_Spazio.ino:2:\n/home/cmaglie/Workspace/sketchbook-cores-beta/libraries/Audio/src/DAC.h:21:16: error: expected ')' before '*' token\n  DACClass(Dacc *_dac, uint32_t _dacId, IRQn_Type _isrId) :\n                ^\n/home/cmaglie/Workspace/sketchbook-cores-beta/libraries/Audio/src/DAC.h:35:2: error: 'Dacc' does not name a type; did you mean 'Dac'?\n  Dacc *dac;\n  ^~~~\n  Dac\nIn file included from /home/cmaglie/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,\n                 from /home/cmaglie/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd.h:105,\n                 from /home/cmaglie/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/sam.h:540,\n                 from /home/cmaglie/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.h:48,\n                 from /tmp/arduino-sketch-677AAB20E80739BE543EDDAC5861B7C0/sketch/Prova_Spazio.ino.cpp:1:\n/home/cmaglie/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:421:38: error: expected ')' before '*' token\n #define DAC               ((Dac      *)0x42004800UL) /**\u003c \\brief (DAC) APB Base Address */\n                                      ^\n/home/cmaglie/Workspace/sketchbook-cores-beta/libraries/Audio/src/DAC.h:42:17: note: in expansion of macro 'DAC'\n extern DACClass DAC;\n                 ^~~\n/home/cmaglie/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:421:38: error: expected ')' before '*' token\n #define DAC               ((Dac      *)0x42004800UL) /**\u003c \\brief (DAC) APB Base Address */\n                                      ^\n/home/cmaglie/Workspace/sketchbook-cores-beta/libraries/Audio/src/DAC.h:42:17: note: in expansion of macro 'DAC'\n extern DACClass DAC;\n                 ^~~\n",
  "builder_result": {
    "build_path": "/tmp/arduino-sketch-677AAB20E80739BE543EDDAC5861B7C0",
    "used_libraries": [
      {
        "name": "SPI",
        "author": "Jonathan BAUDIN, Thibaut VIARD, Arduino",
        "maintainer": "Arduino \[email protected]\u003e",
        "sentence": "Enables the communication with devices that use the Serial Peripheral Interface (SPI) Bus. Specific implementation for Arduino Zero.",
        "website": "http://www.arduino.cc/en/Reference/SPI",
        "category": "Communication",
        "architectures": [
          "samd"
        ],
        "install_dir": "/home/cmaglie/.arduino15/packages/arduino/hardware/samd/1.8.9/libraries/SPI",
        "source_dir": "/home/cmaglie/.arduino15/packages/arduino/hardware/samd/1.8.9/libraries/SPI",
        "container_platform": "arduino:[email protected]",
        "real_name": "SPI",
        "version": "1.0",
        "license": "Unspecified",
        "location": 2,
        "examples": [
          "/home/cmaglie/.arduino15/packages/arduino/hardware/samd/1.8.9/libraries/SPI/examples/BarometricPressureSensor",
          "/home/cmaglie/.arduino15/packages/arduino/hardware/samd/1.8.9/libraries/SPI/examples/DigitalPotControl"
        ]
      },
      {
        "name": "Audio",
        "author": "Arduino",
        "maintainer": "Arduino \[email protected]\u003e",
        "sentence": "Allows playing audio files from an SD card. For Arduino DUE only.",
        "paragraph": "With this library you can use the Arduino Due DAC outputs to play audio files.\u003cbr /\u003eThe audio files must be in the raw .wav format.",
        "website": "http://www.arduino.cc/en/Reference/Audio",
        "category": "Signal Input/Output",
        "architectures": [
          "sam"
        ],
        "install_dir": "/home/cmaglie/Workspace/sketchbook-cores-beta/libraries/Audio",
        "source_dir": "/home/cmaglie/Workspace/sketchbook-cores-beta/libraries/Audio/src",
        "real_name": "Audio",
        "version": "1.0.5",
        "license": "Unspecified",
        "location": 1,
        "layout": 1,
        "examples": [
          "/home/cmaglie/Workspace/sketchbook-cores-beta/libraries/Audio/examples/SimpleAudioPlayer"
        ]
      }
    ]
  },
  "success": false
}

It gives the full compiler output in stdout and stderr (all at once when the build is completed), the build path, the libraries used, and if the compile is successful or not.

@per1234
Copy link
Contributor

per1234 commented Nov 12, 2020

This is really awesome @cmaglie!

Is there any chance of putting the sketch memory usage data in dedicated fields (perhaps in a structure that will accomodate support for additional memory types being added at some future time ala #480)? Having that information in a machine parseable format would be super useful to me.

@ubidefeo
Copy link

add me to the list of @per1234 's request:
MOAR INFO
MOAR INFO

@obra
Copy link
Contributor

obra commented Nov 15, 2020

This is awesome!

One thing that I'd love to see would be the compilation broken into an ordered list of compiler commands run by arduino-cli, with STDOUT and STDERR split out per command. That would make it a lot easier to read and debug builds.

@cmaglie cmaglie force-pushed the compile-json-output branch from 896127c to e3c7d6e Compare November 17, 2020 19:57
@cmaglie
Copy link
Member Author

cmaglie commented Nov 18, 2020

@per1234
I've added the build size section:

  "builder_result": {
    "build_path": "/tmp/arduino-sketch-860CABA8542DB81F417B7278EB3E894A",
    "executable_sections_size": [
      {
        "name": "text",
        "size": 11216,
        "maxSize": 262144
      },
      {
        "name": "data",
        "size": 2364,
        "maxSize": 32768
      }
    ]
  },

@obra
your suggestion is excellent, but it requires much more work. I need this PR merged so, for now, I'm merging it as is.
I will expand this patch it in the future.

@cmaglie cmaglie requested a review from silvanocerza November 18, 2020 10:22
@cmaglie cmaglie merged commit f954d7a into arduino:master Nov 18, 2020
@cmaglie cmaglie deleted the compile-json-output branch November 18, 2020 10:43
@obra
Copy link
Contributor

obra commented Nov 18, 2020

@obra
your suggestion is excellent, but it requires much more work. I need this PR merged so, for now, I'm merging it as is.
I will expand this patch it in the future.

Absolutely! And please don't misunderstand: I'm very happy to see this as-is :)

Would you like me to open a feature request for the much-more-work version? If it's something that's too far in the future to be useful to have in the issue tracker, I 100% understand :)

@cmaglie
Copy link
Member Author

cmaglie commented Nov 18, 2020

Would you like me to open a feature request for the much-more-work version? If it's something that's too far in the future to be useful to have in the issue tracker, I 100% understand :)

yes thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants