Skip to content
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

Add basic support for arduino-cli detection #44

Open
wants to merge 3 commits into
base: release-1.1-dev
Choose a base branch
from

Conversation

gibwar
Copy link

@gibwar gibwar commented Dec 2, 2020

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.

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

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.

[1]: https://github.com/arduino/arduino-cli
gibwar added 2 commits May 17, 2021 19:56
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.
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
Copy link
Author

gibwar commented May 18, 2021

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.

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.

1 participant