a9183756-gh / Arduino-CMake-Toolchain

CMake toolchain for all Arduino compatible boards
MIT License
135 stars 40 forks source link

Add basic support for arduino-cli detection #44

Open gibwar opened 3 years ago

gibwar commented 3 years ago

This adds the most basic of support for the environment created from downloading the Arduino SDK via the official arduino-cli project.

It fixes two issues encountered with detection:

  1. If set(ARDUINO_INSTALL_PATH "$env{LOCALAPPDATA}/Arduino15 is used, it will work, however the make system will loudly complain that it is unable to read lib/version.txt, however generation will succeed.
  2. By default, the cli installation is not detected, so this adds the install path hint of the $env{LOCALAPPDATA}/Arduino15 path and adds basic detection of arduino-cli.yaml which is created from the cli setup process.

The Linux update has been validated using Debian Buser running under WSL1 and all tools work as far as I can tell, including detection, build, sizing, and upload.

I do not have a Mac available to test, but I am basing the assumption of $ENV{HOME}/Library/Arduino15 as the install point since that's in the package path as well.

Using the tool, running a command like arduino-cli core install arduino:samd will download the tooling, the core, and set up the environment.

Originally I was detecting arduino-cli.yaml as the marker file but under a brand new installation on Linux that file did not exist, but inventory.yaml did.

I was unable to detect any version information of a matching SDK or arduino-cli version, so the assumption of the file existing was enough to trigger the new flow.


Fix registry bug when globbing for sketchbook

The existing code fails on Windows installations as it was checking HKEY_LOCAL_MACHINE instead of the user defined/customized HKEY_CURRENT_USER as the Personal registry value only exists in the user registry.

Additionally, the file command does not seem to resolve the registry directive, so an additional call to get_filename_component was added to resolve the directory path.


Add support for cli-installed libs without IDE

If a library is installed from the Arduino CLI via arduino-cli lib install <lib> on Windows, the default location for the installed library is under Documents/Arduino/Libraries/<lib>. When the IDE is not installed, a preferences file pointing to this location is not created and is not recognized by the build system.

This attempts to resolve the issue by detecting a missing sketchbook location and the existance of the _reg_documents variable (resolved when setting up package paths) by resolving the location and setting the appropriate ARDUINO_SKETCHBOOK_PATH variable, allowing library searches to find libraries installed by the CLI.

gibwar commented 3 years ago

Pushed two new commits fixing a bug in the documents directory lookup and added a library lookup fallback for libraries installed by arduino-cli without the IDE installed.